moved battery information in systeminformation
This commit is contained in:
@@ -1,70 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file menuAkku.cpp
|
|
||||||
* @author Alexander Klein (alex@kleiax.de)
|
|
||||||
* @brief Contains a implementation of the class MenuAkku
|
|
||||||
* @version 0.1
|
|
||||||
* @date 2022-02-05
|
|
||||||
*
|
|
||||||
* @copyright Copyright (c) 2022
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "menuAkku.h"
|
|
||||||
|
|
||||||
MenuAkku::MenuAkku(Battery* mainBattery, Ps3Controller* gamepad) {
|
|
||||||
this->mainBattery = mainBattery;
|
|
||||||
this->gamepad = gamepad;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 = this->mainBattery->getBatteryPercent();
|
|
||||||
double mainBatteryVolt = this->mainBattery->getBatteryVoltage();
|
|
||||||
|
|
||||||
if( controllerBattery != this->gamepad->data.status.battery ){
|
|
||||||
controllerBattery = this->gamepad->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) {
|
|
||||||
lcd->clear();
|
|
||||||
lcd->setCursor(0, 0);
|
|
||||||
lcd->printf("Controller: %s", buf);
|
|
||||||
lcd->setCursor(0, 1);
|
|
||||||
lcd->printf("Main: %u%% %4.2fV", mainBattery, mainBatteryVolt);
|
|
||||||
}
|
|
||||||
std::cout << "Controller: " << buf << " Main: " << (int) mainBattery << "% " << mainBatteryVolt << "V" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MenuAkku::update() {
|
|
||||||
if (millis() - this->lastMillis < this->delay) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this->printMenu();
|
|
||||||
this->lastMillis = millis();
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file menuAkku.h
|
|
||||||
* @author Alexander Klein (alex@kleiax.de)
|
|
||||||
* @brief Contains a Menu class to show battery pack informations
|
|
||||||
* @version 0.1
|
|
||||||
* @date 2022-02-05
|
|
||||||
*
|
|
||||||
* @copyright Copyright (c) 2022
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MENU_AKKU_H
|
|
||||||
#define MENU_AKKU_H
|
|
||||||
|
|
||||||
#include <Ps3Controller.h>
|
|
||||||
|
|
||||||
#include "menuControl.h"
|
|
||||||
#include "battery.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This class shows battery informations
|
|
||||||
*
|
|
||||||
* Provide information for main battery pack and
|
|
||||||
* PS3-Controller battery pack
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class MenuAkku : public MenuControl {
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Construct a new Menu Akku object
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
MenuAkku(Battery* mainBattery, Ps3Controller* gamepad);
|
|
||||||
|
|
||||||
void down() override {}
|
|
||||||
void up() override {}
|
|
||||||
void right() override;
|
|
||||||
void left() override;
|
|
||||||
void no() override;
|
|
||||||
void yes() override;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Prints the Information to display and console
|
|
||||||
*
|
|
||||||
* The informations are only printed to the display if it
|
|
||||||
* set.
|
|
||||||
*/
|
|
||||||
void printMenu() override;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Renew the informations and print them
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void update() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const uint16_t delay = 15000;
|
|
||||||
uint32_t lastMillis = 0;
|
|
||||||
|
|
||||||
Battery* mainBattery;
|
|
||||||
Ps3Controller* gamepad;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // MENU_AKKU_H
|
|
||||||
@@ -11,6 +11,12 @@
|
|||||||
|
|
||||||
#include "menuSysteminformation.h"
|
#include "menuSysteminformation.h"
|
||||||
|
|
||||||
|
MenuSysteminformation::MenuSysteminformation(Battery* mainBattery, Ps3Controller* gamepad)
|
||||||
|
: MenuInformationSites(5) {
|
||||||
|
this->mainBattery = mainBattery;
|
||||||
|
this->gamepad = gamepad;
|
||||||
|
}
|
||||||
|
|
||||||
void MenuSysteminformation::printPage() const {
|
void MenuSysteminformation::printPage() const {
|
||||||
String lineOne = "";
|
String lineOne = "";
|
||||||
String lineTwo = "";
|
String lineTwo = "";
|
||||||
@@ -25,6 +31,20 @@ void MenuSysteminformation::printPage() const {
|
|||||||
lineTwo.concat((millis() / 1000));
|
lineTwo.concat((millis() / 1000));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
lineOne = "Main battery:";
|
||||||
|
lineTwo = "";
|
||||||
|
lineTwo.concat(this->mainBattery->getBatteryPercent());
|
||||||
|
lineTwo.concat("% V=");
|
||||||
|
lineTwo.concat(this->mainBattery->getBatteryVoltage());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
lineOne = "PS3 battery";
|
||||||
|
lineTwo = "is ";
|
||||||
|
MenuSysteminformation::ps3ToString(this->gamepad->data.status.battery);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
this->printDefault();
|
this->printDefault();
|
||||||
return;
|
return;
|
||||||
@@ -32,3 +52,13 @@ void MenuSysteminformation::printPage() const {
|
|||||||
|
|
||||||
this->print(lineOne, lineTwo);
|
this->print(lineOne, lineTwo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String MenuSysteminformation::ps3ToString(uint8_t battery) {
|
||||||
|
if( battery == ps3_status_battery_charging ) return "LOAD";
|
||||||
|
else if( battery == ps3_status_battery_full ) return "FULL";
|
||||||
|
else if( battery == ps3_status_battery_high ) return "HIGH";
|
||||||
|
else if( battery == ps3_status_battery_low) return "LOW";
|
||||||
|
else if( battery == ps3_status_battery_dying ) return "BAD";
|
||||||
|
else if( battery == ps3_status_battery_shutdown ) return "OFF";
|
||||||
|
else return "UNDEF";
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,15 +13,21 @@
|
|||||||
#define MENU_SYSTEMINFORMATION_H
|
#define MENU_SYSTEMINFORMATION_H
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <Ps3Controller.h>
|
||||||
|
|
||||||
#include "menuInformationSites.h"
|
#include "menuInformationSites.h"
|
||||||
|
#include "battery.h"
|
||||||
|
|
||||||
class MenuSysteminformation : public MenuInformationSites {
|
class MenuSysteminformation : public MenuInformationSites {
|
||||||
public:
|
public:
|
||||||
MenuSysteminformation() : MenuInformationSites(5) {}
|
MenuSysteminformation(Battery* mainBattery, Ps3Controller* gamepad);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void printPage() const override;
|
void printPage() const override;
|
||||||
|
static String ps3ToString(uint8_t battery);
|
||||||
|
|
||||||
|
Battery* mainBattery;
|
||||||
|
Ps3Controller* gamepad;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MENU_SYSTEMINFORMATION_H
|
#endif // MENU_SYSTEMINFORMATION_H
|
||||||
|
|||||||
+1
-6
@@ -41,7 +41,6 @@
|
|||||||
#include "SpecialMenus/driveModi/TestMode/menuTestMode.h"
|
#include "SpecialMenus/driveModi/TestMode/menuTestMode.h"
|
||||||
#include "SpecialMenus/PID/menuPidSettings.h"
|
#include "SpecialMenus/PID/menuPidSettings.h"
|
||||||
#include "SpecialMenus/GPS/menuGPS.h"
|
#include "SpecialMenus/GPS/menuGPS.h"
|
||||||
#include "SpecialMenus/Akku/menuAkku.h"
|
|
||||||
#include "SpecialMenus/Systeminformation/menuSysteminformation.h"
|
#include "SpecialMenus/Systeminformation/menuSysteminformation.h"
|
||||||
|
|
||||||
MoveControl moveController;
|
MoveControl moveController;
|
||||||
@@ -281,8 +280,7 @@ void makeMenu() {
|
|||||||
MenuAutopilot* auto_m = new MenuAutopilot(driveManager);
|
MenuAutopilot* auto_m = new MenuAutopilot(driveManager);
|
||||||
MenuTestMode* test_m = new MenuTestMode(driveManager);
|
MenuTestMode* test_m = new MenuTestMode(driveManager);
|
||||||
MenuGPS* gps_m = new MenuGPS(driveManager);
|
MenuGPS* gps_m = new MenuGPS(driveManager);
|
||||||
MenuAkku* akku_m = new MenuAkku(mainBattery, gamepad);
|
MenuSysteminformation* sys_m = new MenuSysteminformation(mainBattery, gamepad);
|
||||||
MenuSysteminformation* sys_m = new MenuSysteminformation();
|
|
||||||
|
|
||||||
// Set Menus on LCD
|
// Set Menus on LCD
|
||||||
main_m->setLcd(lcd);
|
main_m->setLcd(lcd);
|
||||||
@@ -295,7 +293,6 @@ void makeMenu() {
|
|||||||
auto_m->setLcd(lcd);
|
auto_m->setLcd(lcd);
|
||||||
test_m->setLcd(lcd);
|
test_m->setLcd(lcd);
|
||||||
gps_m->setLcd(lcd);
|
gps_m->setLcd(lcd);
|
||||||
akku_m->setLcd(lcd);
|
|
||||||
sys_m->setLcd(lcd);
|
sys_m->setLcd(lcd);
|
||||||
|
|
||||||
|
|
||||||
@@ -304,13 +301,11 @@ void makeMenu() {
|
|||||||
MenuAction* gps_e = new MenuAction("GPS", gps_m);
|
MenuAction* gps_e = new MenuAction("GPS", gps_m);
|
||||||
MenuAction* pid_e = new MenuAction("PID", pid_m);
|
MenuAction* pid_e = new MenuAction("PID", pid_m);
|
||||||
MenuAction* restart_e = new MenuAction("Restart", restart);
|
MenuAction* restart_e = new MenuAction("Restart", restart);
|
||||||
MenuAction* akku_e = new MenuAction("Battery", akku_m);
|
|
||||||
MenuAction* contr_e = new MenuAction("Remove PS3", disconnectController);
|
MenuAction* contr_e = new MenuAction("Remove PS3", disconnectController);
|
||||||
MenuAction* sys_e = new MenuAction("Systeminfo", sys_m);
|
MenuAction* sys_e = new MenuAction("Systeminfo", sys_m);
|
||||||
main_m->addEntry(mode_e);
|
main_m->addEntry(mode_e);
|
||||||
main_m->addEntry(gps_e);
|
main_m->addEntry(gps_e);
|
||||||
main_m->addEntry(pid_e);
|
main_m->addEntry(pid_e);
|
||||||
main_m->addEntry(akku_e);
|
|
||||||
main_m->addEntry(sys_e);
|
main_m->addEntry(sys_e);
|
||||||
main_m->addEntry(contr_e);
|
main_m->addEntry(contr_e);
|
||||||
main_m->addEntry(restart_e);
|
main_m->addEntry(restart_e);
|
||||||
|
|||||||
Reference in New Issue
Block a user