Add Loop Handler that updates UI

This commit is contained in:
Matthew Colvin 2023-07-29 17:54:02 -05:00
parent e29e2aa7e9
commit 064d442a97
4 changed files with 16 additions and 18 deletions

View file

@ -49,6 +49,8 @@ public:
// Use LVGL to layout the ui and register the callbacks // Use LVGL to layout the ui and register the callbacks
void layout_UI(); void layout_UI();
void loopHandler();
private: private:
static std::shared_ptr<OmoteUI> mInstance; static std::shared_ptr<OmoteUI> mInstance;
std::shared_ptr<HardwareAbstractionInterface> mHardware; std::shared_ptr<HardwareAbstractionInterface> mHardware;

View file

@ -408,9 +408,6 @@ void HardwareRevX::loopHandler(){
ledcWrite(5, backlight_brightness); // Backlight on ledcWrite(5, backlight_brightness); // Backlight on
} }
// Update LVGL UI
lv_timer_handler();
// Blink debug LED at 1 Hz // Blink debug LED at 1 Hz
digitalWrite(USER_LED, millis() % 1000 > 500); digitalWrite(USER_LED, millis() % 1000 > 500);
@ -425,6 +422,7 @@ void HardwareRevX::loopHandler(){
IMUTaskTimer = millis(); IMUTaskTimer = millis();
} }
// TODO Convert to free RTOS task
// Update battery stats at 1Hz // Update battery stats at 1Hz
static unsigned long batteryTaskTimer = static unsigned long batteryTaskTimer =
millis() + 1000; // add 1s to start immediately millis() + 1000; // add 1s to start immediately
@ -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);
//
} }

View file

@ -82,6 +82,10 @@ void OmoteUI::virtualKeypad_event_cb(lv_event_t *e) {
mHardware->debugPrint(buffer); mHardware->debugPrint(buffer);
} }
void OmoteUI::loopHandler(){
lv_timer_handler();
}
void OmoteUI::layout_UI() { void OmoteUI::layout_UI() {
// --- LVGL UI Configuration --- // --- LVGL UI Configuration ---

View file

@ -10,29 +10,16 @@
std::shared_ptr<HardwareRevX> hal = nullptr; std::shared_ptr<HardwareRevX> hal = nullptr;
void setup() { void setup() {
hal = HardwareRevX::getInstance(); hal = HardwareRevX::getInstance();
hal->init(); hal->init();
auto ui = OmoteUI::getInstance(hal); auto ui = OmoteUI::getInstance(hal);
ui->layout_UI(); ui->layout_UI();
lv_timer_handler(); // Run the LVGL UI once before the loop takes over 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() { void loop() {
HardwareRevX::getInstance()->loopHandler(); HardwareRevX::getInstance()->loopHandler();
// IR Test OmoteUI::getInstance()->loopHandler();
// 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);
//
} }