Advertisement
nene1234

ip work

Jul 3rd, 2025
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.42 KB | None | 0 0
  1. #include <lilka.h>
  2. #include "ipapp.h"
  3. #include "servicemanager.h"
  4. #include "services/network.h"
  5.  
  6. IPApp::IPApp() : App("IP Address") {}
  7.  
  8. void IPApp::run() {
  9.     while (true) {
  10.         NetworkService* networkService = static_cast<NetworkService*>(ServiceManager::getInstance()->getService<NetworkService>("network"));
  11.         String ipAddress = networkService ? networkService->getIpAddr().c_str() : "Не підключено";
  12.  
  13.         // Читаємо стан кнопок
  14.         lilka::State state = lilka::controller.getState();
  15.         if (state.b.pressed) {
  16.             return;
  17.         }
  18.  
  19.         // Використовуємо готовий UI-компонент
  20.         lilka::Alert alert("IP Адреса", ipAddress);
  21.         alert.draw(canvas);
  22.         queueDraw();
  23.  
  24.         // Можна додати очікування, поки користувач не натисне кнопку для виходу
  25.         while (!alert.isFinished()) {
  26.             alert.update();
  27.             vTaskDelay(LILKA_UI_UPDATE_DELAY_MS / portTICK_PERIOD_MS);
  28.             lilka::State state = lilka::controller.getState();
  29.             if (state.b.pressed) {
  30.                 return;
  31.             }
  32.         }
  33.     }
  34. }
  35.  
  36.  
  37.  
  38. #ifndef IPAPP_H
  39. #define IPAPP_H
  40.  
  41. #include <lilka.h>
  42. #include "app.h"
  43. #include "services/network.h"
  44.  
  45. class IPApp : public App {
  46. public:
  47.     IPApp();
  48. private:
  49.     void run() override;
  50. };
  51.  
  52. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement