refactor, added akku menu, finished autopilot menu
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @file menuAkku.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2022-02-05
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#include "menuAkku.h"
|
||||
|
||||
MenuAkku::MenuAkku() {
|
||||
|
||||
}
|
||||
|
||||
void MenuAkku::right() {
|
||||
this->printMenu();
|
||||
}
|
||||
|
||||
void MenuAkku::left() {
|
||||
if (this->parentMenu)
|
||||
this->parentMenu->printMenu();
|
||||
}
|
||||
|
||||
void MenuAkku::no() {
|
||||
this->left();
|
||||
}
|
||||
|
||||
void MenuAkku::yes() {
|
||||
this->right();
|
||||
}
|
||||
|
||||
void MenuAkku::printMenu() {
|
||||
char buf[17];
|
||||
uint8_t controllerBattery = -1;
|
||||
uint8_t mainBattery = 77;
|
||||
|
||||
if( controllerBattery != Ps3.data.status.battery ){
|
||||
controllerBattery = Ps3.data.status.battery;
|
||||
}
|
||||
|
||||
if( controllerBattery == ps3_status_battery_charging ) sprintf(buf, "LOAD");
|
||||
else if( controllerBattery == ps3_status_battery_full ) sprintf(buf, "FULL");
|
||||
else if( controllerBattery == ps3_status_battery_high ) sprintf(buf, "HIGH");
|
||||
else if( controllerBattery == ps3_status_battery_low) sprintf(buf, "LOW");
|
||||
else if( controllerBattery == ps3_status_battery_dying ) sprintf(buf, "BAD");
|
||||
else if( controllerBattery == ps3_status_battery_shutdown ) sprintf(buf, "OFF");
|
||||
else sprintf(buf, "UNDEF");
|
||||
|
||||
if (this->lcd) {
|
||||
|
||||
} else {
|
||||
lcd->clear();
|
||||
lcd->setCursor(0, 0);
|
||||
lcd->printf("Controller: %s", buf);
|
||||
lcd->setCursor(0, 1);
|
||||
lcd->printf("Main: %u%%", mainBattery);
|
||||
}
|
||||
}
|
||||
|
||||
void MenuAkku::update() {
|
||||
if (millis() - this->last_millis < this->delay) {
|
||||
return;
|
||||
}
|
||||
this->printMenu();
|
||||
this->last_millis = millis();
|
||||
}
|
||||
Reference in New Issue
Block a user