todos and i2c scanner modified

This commit is contained in:
2022-02-22 08:37:08 +01:00
parent 89fa4a7efd
commit d97be897c1
3 changed files with 20 additions and 17 deletions
+2
View File
@@ -87,6 +87,8 @@
"Keine", "Keine",
"kleiax", "kleiax",
"Lebennig", "Lebennig",
"pidl",
"pidr",
"Punica", "Punica",
"RHEDE", "RHEDE",
"TPMOBIL", "TPMOBIL",
+2 -1
View File
@@ -1,3 +1,4 @@
-> Document the Akku lib -> Document the battery pack lib
-> Program underfloorLighting -> Program underfloorLighting
-> Program battery pack tracking
+16 -16
View File
@@ -46,7 +46,6 @@ DebugMqtt* debugMqtt;
void callbackControllerAction(void); void callbackControllerAction(void);
void callbackControllerConnect(void); void callbackControllerConnect(void);
void i2cScanner(void); void i2cScanner(void);
void restart(void);
void makeMenu(void); void makeMenu(void);
@@ -65,7 +64,7 @@ void setup() {
std::cout.rdbuf(bufMqtt); std::cout.rdbuf(bufMqtt);
std::cout << "Welcome to Kleiax-Rover" << std::endl; std::cout << "Welcome to Kleiax-Rover" << std::endl;
std::cout << "All actions from the main programm run on Core -> " << xPortGetCoreID() << std::endl; std::cout << "All actions from the main program run on Core -> " << xPortGetCoreID() << std::endl;
Ps3.attach(callbackControllerAction); Ps3.attach(callbackControllerAction);
Ps3.attachOnConnect(callbackControllerConnect); Ps3.attachOnConnect(callbackControllerConnect);
@@ -130,7 +129,8 @@ void callbackControllerConnect() {
std::cout << "Controller connected to ESP32" << std::endl; std::cout << "Controller connected to ESP32" << std::endl;
std::cout << "All actions from the Controller run on Core -> " << xPortGetCoreID() << std::endl; std::cout << "All actions from the Controller run on Core -> " << xPortGetCoreID() << std::endl;
// TODO: Display is not functional without this seconde init, first init is in setup() // Display is not functional without this seconde init, first init is in setup(),
// because after the setup the other core control the display.
lcd->init(); lcd->init();
main_m->printMenu(); main_m->printMenu();
} }
@@ -140,33 +140,29 @@ void i2cScanner() {
byte error, address; byte error, address;
int nDevices; int nDevices;
Serial.println("Scanning..."); std::cout << "Scanning..." << std::endl;
nDevices = 0; nDevices = 0;
for(address = 1; address < 127; address++ ) { for(address = 1; address < 127; address++ ) {
Wire.beginTransmission(address); Wire.beginTransmission(address);
error = Wire.endTransmission(); error = Wire.endTransmission();
if (error == 0) { if (error == 0) {
Serial.print("I2C device found at address 0x"); std::cout << "I2C device found at address 0x";
if (address<16) if (address<16)
Serial.print("0"); std::cout << "0";
Serial.println(address,HEX); std::cout << std::hex << address << std::endl;
nDevices++; nDevices++;
} }
else if (error==4) { else if (error==4) {
Serial.print("Unknow error at address 0x"); std::cout << "Unknow error at address 0x";
if (address<16) if (address<16)
Serial.print("0"); std::cout << "0";
Serial.println(address,HEX); std::cout << std::hex << address << std::endl;
} }
} }
if (nDevices == 0) if (nDevices == 0)
Serial.println("No I2C devices found\n"); std::cout << "No I2C devices found\n" << std::endl;
else else
Serial.println("done\n"); std::cout << "done\n" << std::endl;
}
void restart() {
ESP.restart();
} }
void makeMenu() { void makeMenu() {
@@ -174,6 +170,10 @@ void makeMenu() {
std::cout << "Dummy in Action" <<std::endl; std::cout << "Dummy in Action" <<std::endl;
}; };
auto restart = []() {
ESP.restart();
};
// Create Menu // Create Menu
main_m = new Menu(); main_m = new Menu();
Menu* mode_m = new Menu(); Menu* mode_m = new Menu();