Little improvements

This commit is contained in:
2022-03-04 18:41:58 +01:00
parent bfa571898f
commit 8f3091e8b1
4 changed files with 17 additions and 3 deletions
+1 -1
View File
@@ -27,7 +27,7 @@
#define PID_OUT_MAX 100
#define PID_SAMPLETIME 30
// Left PID
#define PID_LEFT_P 85
#define PID_LEFT_P 75
#define PID_LEFT_I 0
#define PID_LEFT_D 0
// Right PID
+1
View File
@@ -51,6 +51,7 @@ void Battery::calculateBatteryPercent() {
break;
}
if (i == 0) {
if (this->batteryVoltage > 6)
std::cout << "Critical low battery!" << std::endl;
} else if (i == size - 1) {
+1 -1
View File
@@ -80,7 +80,7 @@ class Battery {
uint8_t pin;
uint8_t batteryPercent;
uint16_t delay = 5000;
uint16_t delay = 20000;
uint32_t r1;
uint32_t r2;
uint64_t lastMillis = 0;
+13
View File
@@ -51,6 +51,7 @@ bool wifiIsActive;
void callbackControllerAction(void);
void callbackControllerConnect(void);
void callbackControllerDisconnect(void);
void i2cScanner(void);
void makeMenu(void);
@@ -87,6 +88,7 @@ void setup() {
Ps3.attach(callbackControllerAction);
Ps3.attachOnConnect(callbackControllerConnect);
Ps3.attachOnDisconnect(callbackControllerDisconnect);
std::cout << "\nReady to connect a PS3 Controller... \n";
// Need to be connected befor an other device connect
@@ -168,6 +170,11 @@ void callbackControllerConnect() {
main_m->printMenu();
}
void callbackControllerDisconnect() {
std::cout << "Controller disconnected..." << std::endl;
// Ps3.end();
}
void i2cScanner() {
std::cout << "\nI2C Scanner" << std::endl;
@@ -210,6 +217,10 @@ void makeMenu() {
ESP.restart();
};
auto disconnectController = [&]() {
Ps3.end();
};
// Create Menu
main_m = new Menu();
Menu* mode_m = new Menu();
@@ -241,10 +252,12 @@ void makeMenu() {
MenuAction* pid_e = new MenuAction("PID", pid_m);
MenuAction* restart_e = new MenuAction("Restart", restart);
MenuAction* akku_e = new MenuAction("Akku", akku_m);
MenuAction* contr_e = new MenuAction("Remove PS3", disconnectController);
main_m->addEntry(mode_e);
main_m->addEntry(gps_e);
main_m->addEntry(pid_e);
main_m->addEntry(akku_e);
main_m->addEntry(contr_e);
main_m->addEntry(restart_e);
// Entry for the mode Menu