update battery.h

This commit is contained in:
2022-03-21 09:10:35 +01:00
parent 8f3091e8b1
commit ece89eba60
5 changed files with 11 additions and 8 deletions
Binary file not shown.
+2 -2
View File
@@ -89,8 +89,8 @@ class Battery {
const float capacityVoltages[21] = {9.82, 10.83, 11.06, 11.12, const float capacityVoltages[21] = {9.82, 10.83, 11.06, 11.12,
11.18, 11.24, 11.3, 11.36, 11.18, 11.24, 11.3, 11.36,
11.39, 11.45, 11.51, 11.56, 11.39, 11.45, 11.51, 11.56,
11.62, 11.74, 11.86, 11.95, 11.62, 11.74, 11.86, 11.95, // 60 65 70 75
12.07, 12.25, 12.33, 12.45, 12.07, 12.25, 12.33, 12.45, // 80 85 90 95
12.6 }; 12.6 };
}; };
+1
View File
@@ -14,6 +14,7 @@
#include <TinyGPS++.h> #include <TinyGPS++.h>
#include <Arduino.h> #include <Arduino.h>
#include <Wire.h>
#include <iostream> #include <iostream>
#include "route.h" #include "route.h"
+3 -2
View File
@@ -36,6 +36,7 @@ void MenuAkku::printMenu() {
char buf[17]; char buf[17];
uint8_t controllerBattery = -1; uint8_t controllerBattery = -1;
uint8_t mainBattery = this->mainBattery->getBatteryPercent(); uint8_t mainBattery = this->mainBattery->getBatteryPercent();
double mainBatteryVolt = this->mainBattery->getBatteryVoltage();
if( controllerBattery != Ps3.data.status.battery ){ if( controllerBattery != Ps3.data.status.battery ){
controllerBattery = Ps3.data.status.battery; controllerBattery = Ps3.data.status.battery;
@@ -54,9 +55,9 @@ void MenuAkku::printMenu() {
lcd->setCursor(0, 0); lcd->setCursor(0, 0);
lcd->printf("Controller: %s", buf); lcd->printf("Controller: %s", buf);
lcd->setCursor(0, 1); lcd->setCursor(0, 1);
lcd->printf("Main: %u%%", mainBattery); lcd->printf("Main: %u%% %4.2fV", mainBattery, mainBatteryVolt);
} }
std::cout << "Controller: " << buf << " Main: " << (int) mainBattery << "%" << std::endl; std::cout << "Controller: " << buf << " Main: " << (int) mainBattery << "% " << mainBatteryVolt << "V" << std::endl;
} }
void MenuAkku::update() { void MenuAkku::update() {
+5 -4
View File
@@ -60,10 +60,10 @@ void setup() {
Serial.begin(115200); Serial.begin(115200);
char wifiIndicator = 'X'; char wifiIndicator = 'X';
mainBattery = new Battery(35, 690000, 220000); mainBattery = new Battery(35, 692000, 218500);
Wire.begin(21, 19); Wire.begin(21, 19);
// i2cScanner(); i2cScanner();
lcd = new LiquidCrystal_I2C(0x3F,16,2); lcd = new LiquidCrystal_I2C(0x3F,16,2);
lcd->init(); lcd->init();
lcd->clear(); lcd->clear();
@@ -189,14 +189,15 @@ void i2cScanner() {
std::cout << "I2C device found at address 0x"; std::cout << "I2C device found at address 0x";
if (address<16) if (address<16)
std::cout << "0"; std::cout << "0";
std::cout << std::hex << address << std::endl; std::cout << std::hex << (int) address << std::endl;
// std::cout << (int) address << std::endl;
nDevices++; nDevices++;
} }
else if (error==4) { else if (error==4) {
std::cout << "Unknow error at address 0x"; std::cout << "Unknow error at address 0x";
if (address<16) if (address<16)
std::cout << "0"; std::cout << "0";
std::cout << std::hex << address << std::endl; std::cout << std::hex << (int) address << std::endl;
} }
} }
if (nDevices == 0) if (nDevices == 0)