Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <lilka.h>
- #include "ipapp.h"
- #include "servicemanager.h"
- #include "services/network.h"
- IPApp::IPApp() : App("IP Address") {}
- void IPApp::run() {
- while (true) {
- NetworkService* networkService = static_cast<NetworkService*>(ServiceManager::getInstance()->getService<NetworkService>("network"));
- String ipAddress = networkService ? networkService->getIpAddr().c_str() : "Не підключено";
- // Читаємо стан кнопок
- lilka::State state = lilka::controller.getState();
- if (state.b.pressed) {
- return;
- }
- // Використовуємо готовий UI-компонент
- lilka::Alert alert("IP Адреса", ipAddress);
- alert.draw(canvas);
- queueDraw();
- // Можна додати очікування, поки користувач не натисне кнопку для виходу
- while (!alert.isFinished()) {
- alert.update();
- vTaskDelay(LILKA_UI_UPDATE_DELAY_MS / portTICK_PERIOD_MS);
- lilka::State state = lilka::controller.getState();
- if (state.b.pressed) {
- return;
- }
- }
- }
- }
- #ifndef IPAPP_H
- #define IPAPP_H
- #include <lilka.h>
- #include "app.h"
- #include "services/network.h"
- class IPApp : public App {
- public:
- IPApp();
- private:
- void run() override;
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement