Advertisement
nene1234

ip not open

Jul 3rd, 2025
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.30 KB | None | 0 0
  1. #include "ipapp.h"
  2. #include "servicemanager.h"
  3. #include "services/network.h"
  4.  
  5. IPApp::IPApp() : App("IP Address") {
  6. }
  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.        
  16.         // Якщо натиснуто кнопку A або B - виходимо з програми
  17.         if (state.a.pressed || state.b.pressed) {
  18.             return;
  19.         }
  20.         // Заповнюємо екран чорним кольором
  21.         canvas->fillScreen(lilka::colors::Black);
  22.        
  23.         // Виводимо заголовок
  24.         canvas->setTextColor(lilka::colors::White);
  25.         canvas->setTextSize(1);
  26.         canvas->setCursor(10, 30);
  27.         canvas->print("IP Адреса:");
  28.        
  29.         // Виводимо IP адресу
  30.         canvas->setTextSize(1);
  31.         canvas->setCursor(10, 80);
  32.         if (ipAddress.length() > 0 && ipAddress != "0.0.0.0") {
  33.             canvas->setTextColor(lilka::colors::Green); // Зелений колір
  34.             canvas->print(ipAddress);
  35.         } else {
  36.             canvas->setTextColor(lilka::colors::Red); // Червоний колір
  37.             canvas->print("Не підключено");
  38.         }
  39.        
  40.         // Виводимо інструкцію для виходу
  41.         canvas->setTextSize(1);
  42.         canvas->setTextColor(lilka::colors::Silver); // якщо є
  43.         canvas->setCursor(10, canvas->height() - 20);
  44.         canvas->print("Натисніть A або B для виходу");
  45.        
  46.         // Повідомляємо Keira про оновлення буфера
  47.         queueDraw();
  48.  
  49.         // Невелика затримка для зменшення навантаження
  50.         vTaskDelay(LILKA_UI_UPDATE_DELAY_MS / portTICK_PERIOD_MS);
  51.     }
  52. }
  53.  
  54.  
  55.  
  56.  
  57. #ifndef IPAPP_H
  58. #define IPAPP_H
  59.  
  60. #include <lilka.h>
  61. #include "app.h"
  62. #include "services/network.h"
  63.  
  64. class IPApp : public App {
  65. public:
  66.     IPApp();
  67. private:
  68.     void run() override;
  69. };
  70.  
  71. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement