Add Loop Handler that updates UI
This commit is contained in:
parent
e29e2aa7e9
commit
064d442a97
4 changed files with 16 additions and 18 deletions
|
@ -49,6 +49,8 @@ public:
|
|||
// Use LVGL to layout the ui and register the callbacks
|
||||
void layout_UI();
|
||||
|
||||
void loopHandler();
|
||||
|
||||
private:
|
||||
static std::shared_ptr<OmoteUI> mInstance;
|
||||
std::shared_ptr<HardwareAbstractionInterface> mHardware;
|
||||
|
|
|
@ -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);
|
||||
//
|
||||
}
|
|
@ -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 ---
|
||||
|
|
|
@ -10,29 +10,16 @@
|
|||
std::shared_ptr<HardwareRevX> 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();
|
||||
}
|
Loading…
Add table
Reference in a new issue