Advertisement
nene1234

ip not open ui component

Jul 3rd, 2025
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 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.a.pressed || 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.             // Додатково перевіряємо кнопки для виходу
  29.             lilka::State state = lilka::controller.getState();
  30.             if (state.a.pressed || state.b.pressed) {
  31.                 return;
  32.             }
  33.         }
  34.     }
  35. }
  36.  
  37.  
  38.  
  39.  
  40. #ifndef IPAPP_H
  41. #define IPAPP_H
  42.  
  43. #include <lilka.h>
  44. #include "app.h"
  45. #include "services/network.h"
  46.  
  47. class IPApp : public App {
  48. public:
  49.     IPApp();
  50. private:
  51.     void run() override;
  52. };
  53.  
  54. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement