Update
This commit is contained in:
parent
88b44de1ce
commit
06b7e5d84a
@ -1,7 +1,11 @@
|
|||||||
|
#include <MAX17043.h>
|
||||||
|
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <Adafruit_GFX.h>
|
#include <Adafruit_GFX.h>
|
||||||
#include <Adafruit_SSD1306.h>
|
#include <Adafruit_SSD1306.h>
|
||||||
|
|
||||||
|
#include "Arduino.h"
|
||||||
|
|
||||||
#include "LowPower.h"
|
#include "LowPower.h"
|
||||||
#include <avr/wdt.h>
|
#include <avr/wdt.h>
|
||||||
|
|
||||||
@ -123,6 +127,7 @@ void setup() {
|
|||||||
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
|
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setTextColor(WHITE);
|
display.setTextColor(WHITE);
|
||||||
|
Wire.begin();
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
pinMode(VBAT, INPUT);
|
pinMode(VBAT, INPUT);
|
||||||
pinMode(CSTAT1, INPUT);
|
pinMode(CSTAT1, INPUT);
|
||||||
@ -136,6 +141,11 @@ void setup() {
|
|||||||
battVoltage = GetVoltage();
|
battVoltage = GetVoltage();
|
||||||
initScreen();
|
initScreen();
|
||||||
delay(200);
|
delay(200);
|
||||||
|
/*
|
||||||
|
FuelGauge.begin();
|
||||||
|
FuelGauge.reset(); //<== Might cause problems
|
||||||
|
FuelGauge.quickstart();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
@ -146,7 +156,7 @@ void loop() {
|
|||||||
safetyCheck();
|
safetyCheck();
|
||||||
if (screenState != 0 && isSafe == true) {updateScreen();}
|
if (screenState != 0 && isSafe == true) {updateScreen();}
|
||||||
if (powerState == false && screenState == 0) {
|
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(){
|
void checkPresses(){
|
||||||
if (digitalRead(PWRBTN) == 0) {
|
if (digitalRead(PWRBTN) == 0) {
|
||||||
@ -328,6 +342,10 @@ double GetVoltage(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double _GetVoltage(){
|
||||||
|
return (FuelGauge.voltage());
|
||||||
|
}
|
||||||
|
|
||||||
void safetyCheck(){
|
void safetyCheck(){
|
||||||
double currentVoltage = 0;
|
double currentVoltage = 0;
|
||||||
currentVoltage = GetVoltage();
|
currentVoltage = GetVoltage();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user