From 06b7e5d84a51b00219953e823bd0a72260247177 Mon Sep 17 00:00:00 2001 From: Max Hunt Date: Fri, 20 Dec 2019 22:43:54 +0000 Subject: [PATCH] Update --- UPGRADE/Code/v2/v2.ino | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/UPGRADE/Code/v2/v2.ino b/UPGRADE/Code/v2/v2.ino index ba8befb..2bb151a 100644 --- a/UPGRADE/Code/v2/v2.ino +++ b/UPGRADE/Code/v2/v2.ino @@ -1,7 +1,11 @@ +#include + #include #include #include +#include "Arduino.h" + #include "LowPower.h" #include @@ -123,6 +127,7 @@ void setup() { display.begin(SSD1306_SWITCHCAPVCC, 0x3C); display.clearDisplay(); display.setTextColor(WHITE); + Wire.begin(); Serial.begin(9600); pinMode(VBAT, INPUT); pinMode(CSTAT1, INPUT); @@ -136,6 +141,11 @@ void setup() { battVoltage = GetVoltage(); initScreen(); delay(200); + /* + FuelGauge.begin(); + FuelGauge.reset(); //<== Might cause problems + FuelGauge.quickstart(); + */ } void loop() { @@ -146,7 +156,7 @@ void loop() { safetyCheck(); if (screenState != 0 && isSafe == true) {updateScreen();} if (powerState == false && screenState == 0) { - LowPower.powerDown(SLEEP_2S, ADC_OFF, BOD_OFF); + LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF); } } @@ -180,6 +190,10 @@ void getBatteryCharge(){ } +void _getBatteryCharge(){ + batteryPct = FuelGauge.percent(); +} + void checkPresses(){ if (digitalRead(PWRBTN) == 0) { @@ -328,6 +342,10 @@ double GetVoltage(){ } } +double _GetVoltage(){ + return (FuelGauge.voltage()); +} + void safetyCheck(){ double currentVoltage = 0; currentVoltage = GetVoltage();