diff --git a/Platformio/include/OmoteUI/OmoteUI.hpp b/Platformio/include/OmoteUI/OmoteUI.hpp index 9e80a95b..fdfaf299 100644 --- a/Platformio/include/OmoteUI/OmoteUI.hpp +++ b/Platformio/include/OmoteUI/OmoteUI.hpp @@ -49,6 +49,8 @@ class OmoteUI { // Use LVGL to layout the ui and register the callbacks void layout_UI(); + void loopHandler(); + private: static std::shared_ptr mInstance; std::shared_ptr mHardware; diff --git a/Platformio/src/HardwareRevX.cpp b/Platformio/src/HardwareRevX.cpp index 82df3e34..dd30db41 100644 --- a/Platformio/src/HardwareRevX.cpp +++ b/Platformio/src/HardwareRevX.cpp @@ -408,9 +408,6 @@ void HardwareRevX::loopHandler(){ ledcWrite(5, backlight_brightness); // Backlight on } - // Update LVGL UI - lv_timer_handler(); - // Blink debug LED at 1 Hz digitalWrite(USER_LED, millis() % 1000 > 500); @@ -425,6 +422,7 @@ void HardwareRevX::loopHandler(){ IMUTaskTimer = millis(); } + // TODO Convert to free RTOS task // Update battery stats at 1Hz static unsigned long batteryTaskTimer = millis() + 1000; // add 1s to start immediately @@ -437,7 +435,7 @@ void HardwareRevX::loopHandler(){ battery_ischarging = !digitalRead(CRG_STAT); // Check if battery is charging, fully charged or disconnected } - // TODO Create batter change notification for UI + // TODO Create batter change notification for UI // if (battery_ischarging || (!battery_ischarging && battery_voltage > 4350)) { // lv_label_set_text(objBattPercentage, ""); @@ -476,4 +474,11 @@ void HardwareRevX::loopHandler(){ } } } + // IR Test + // tft.drawString("IR Command: ", 10, 90, 1); + // decode_results results; + // if (IrReceiver.decode(&results)) { + // IrReceiver.resume(); // Enable receiving of the next value + //} //tft.drawString(String(results.command) + " ", 80, 90, 1); + // } \ No newline at end of file diff --git a/Platformio/src/OmoteUI.cpp b/Platformio/src/OmoteUI.cpp index b2f9e0f8..939e1554 100644 --- a/Platformio/src/OmoteUI.cpp +++ b/Platformio/src/OmoteUI.cpp @@ -82,6 +82,10 @@ void OmoteUI::virtualKeypad_event_cb(lv_event_t *e) { mHardware->debugPrint(buffer); } +void OmoteUI::loopHandler(){ + lv_timer_handler(); +} + void OmoteUI::layout_UI() { // --- LVGL UI Configuration --- diff --git a/Platformio/src/main.cpp b/Platformio/src/main.cpp index aa4110d8..5875d9f4 100644 --- a/Platformio/src/main.cpp +++ b/Platformio/src/main.cpp @@ -10,29 +10,16 @@ std::shared_ptr hal = nullptr; void setup() { - hal = HardwareRevX::getInstance(); hal->init(); auto ui = OmoteUI::getInstance(hal); ui->layout_UI(); - lv_timer_handler(); // Run the LVGL UI once before the loop takes over - - Serial.print("Setup finised in "); - Serial.print(millis()); - Serial.println("ms."); } void loop() { - HardwareRevX::getInstance()->loopHandler(); - // IR Test - // tft.drawString("IR Command: ", 10, 90, 1); - // decode_results results; - // if (IrReceiver.decode(&results)) { - // IrReceiver.resume(); // Enable receiving of the next value - //} //tft.drawString(String(results.command) + " ", 80, 90, 1); - // + OmoteUI::getInstance()->loopHandler(); } \ No newline at end of file