This commit is contained in:
Max Hunt 2019-12-20 16:58:06 +00:00
commit fa098fb381
2 changed files with 287 additions and 278 deletions

1
.gitignore vendored
View File

@ -47,3 +47,4 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk
Icon?

View File

@ -25,6 +25,11 @@ Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
int batteryPct = 0;
double battVoltage = 0.0;
static const double chargeModifier = -0.3;
static const double dischargeModifier = 0.3;
double voltageModifier = 0;
bool powerState = false;
bool screenOn = false;
bool charging_1 = false;
@ -83,19 +88,15 @@ static const unsigned char PROGMEM charge_logo[] = {
B01100000, B00000000
};
static const int PROGMEM dimmerVals[] = {
0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,2,2,2,2,3,3,4,
4,4,5,5,6,6,7,7,8,8,9,9,010,11,11,12,13,14,15,16,17,18,19,20,
21,22,24,25,26,28,29,30,32,33,35,37,38,40,42,44,46,48,49,52,54,56,58,60,
63,65,67,70,73,75,78,80,83,86,89,92,95,98,101,105,108,112,116,120,124,127,131,136,
139,144,148,152,156,160,164,168,172,177,181,185,189,192,196,200,204,208,211,215,218,221,224,227,
230,233,236,238,240,242,244,246,248,249,250,251,252,253,253,253,253,253,253,253,253,253,253,252,
252,251,249,248,247,245,243,241,239,236,234,231,228,225,222,219,216,212,208,205,201,197,194,190,
186,182,178,174,169,165,161,157,153,149,145,141,137,133,129,125,121,117,113,110,106,102,98,96,
93,89,87,84,81,78,76,73,71,68,65,63,61,58,56,54,52,50,48,46,44,42,40,39,
37,35,34,32,31,29,28,26,25,24,23,21,20,19,18,17,16,15,14,13,12,12,11,10,
9,9,8,8,7,7,6,6,5,5,4,4,4,3,3,2,2,2,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,0,0
static const int dimmerVals[] = {
0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,2,2,2,2,3,3,4,4,4,5,5,6,6,7,7,8,8,9,9,10,11,11,12,13,14,15,16,17,18,19,20,21,
22,24,25,26,28,29,30,32,33,35,37,38,40,42,44,46,48,49,52,54,56,58,60,63,65,67,70,73,75,78,80,83,86,89,92,95,98,
101,105,108,112,116,120,124,127,131,136,139,144,148,152,156,160,164,168,172,177,181,185,189,192,196,200,204,208,
211,215,218,221,224,227,230,233,236,238,240,242,244,246,248,249,250,251,252,253,253,253,253,253,253,253,253,253,
253,252,252,251,249,248,247,245,243,241,239,236,234,231,228,225,222,219,216,212,208,205,201,197,194,190,186,182,
178,174,169,165,161,157,153,149,145,141,137,133,129,125,121,117,113,110,106,102,98,96,93,89,87,84,81,78,76,73,71,
68,65,63,61,58,56,54,52,50,48,46,44,42,40,39,37,35,34,32,31,29,28,26,25,24,23,21,20,19,18,17,16,15,14,13,12,12,11,
10,9,9,8,8,7,7,6,6,5,5,4,4,4,3,3,2,2,2,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0
};
void setup() {
@ -262,6 +263,13 @@ double GetVoltage(){
delay(5);
}
voltage = (totalSamples / 10) * (5.00 / 1023.0);
if(charging_1 == true || charging_2 == true){voltageModifier = chargeModifier;}
else if(powerState == true){voltageModifier = dischargeModifier;}
else {voltageModifier = 0;}
voltage = voltage + voltageModifier;
if (voltage > (battVoltage-0.03) && voltage < (battVoltage+0.03)) {
return battVoltage;
}
@ -269,7 +277,7 @@ double GetVoltage(){
battVoltage = voltage;
return voltage;
}
}
}
void blinkLed(int ctrlLed) {
for(int i=0; i<DIMLEN; i++){