Advertisement
nene1234

ip+Mac work

Jul 3rd, 2025
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 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.         String ipAddress = WiFi.localIP().toString();
  11.         String macStr = WiFi.macAddress();
  12.         String info = "IP: " + ipAddress + "\nMAC: " + macStr;
  13.  
  14.         // Читаємо стан кнопок
  15.         lilka::State state = lilka::controller.getState();
  16.         if (state.b.pressed) {
  17.             return;
  18.         }
  19.  
  20.         // Використовуємо готовий UI-компонент
  21.         lilka::Alert alert("Мережа", info);
  22.         alert.draw(canvas);
  23.         queueDraw();
  24.  
  25.         // Можна додати очікування, поки користувач не натисне кнопку для виходу
  26.         while (!alert.isFinished()) {
  27.             alert.update();
  28.             vTaskDelay(LILKA_UI_UPDATE_DELAY_MS / portTICK_PERIOD_MS);
  29.             lilka::State state = lilka::controller.getState();
  30.             if (state.b.pressed) {
  31.                 return;
  32.             }
  33.         }
  34.     }
  35. }
  36.  
  37.  
  38.  
  39. #ifndef IPAPP_H
  40. #define IPAPP_H
  41.  
  42. #include <lilka.h>
  43. #include "app.h"
  44. #include "services/network.h"
  45.  
  46. class IPApp : public App {
  47. public:
  48.     IPApp();
  49. private:
  50.     void run() override;
  51. };
  52.  
  53. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement