12 .bits = powerConfigBits
15void Power_Control_Load_Configuration() {
19void Power_Control_Save_Configuration() {
23void Power_Control_Charge(
bool charge) {
24 FOSSASAT_VERBOSE_PRINT(
F(
"MPPT "));
25 FOSSASAT_VERBOSE_PRINTLN(
charge);
27 Power_Control_Load_Configuration();
28 if(powerConfig.bits.mpptKeepAliveEnabled) {
30 FOSSASAT_VERBOSE_PRINTLN(
'K');
34 FOSSASAT_VERBOSE_PRINTLN(
'L');
51 #ifdef ENABLE_INTERVAL_CONTROL
53 float batt = Power_Control_Get_Battery_Voltage();
57 }
else if(
batt > 4.0f) {
59 }
else if(
batt > 3.9f) {
61 }
else if(
batt > 3.8f) {
63 }
else if(
batt > 3.7f) {
93 Pin_Interface_Watchdog_Heartbeat();
108void Power_Control_Setup_INA226() {
114bool Power_Control_INA226_Check() {
118 Wire.endTransmission();
123 if(
Wire.available() != 2) {
139float Power_Control_Get_Battery_Voltage() {
141 Power_Control_Charge(
false);
145 if(Power_Control_INA226_Check()) {
146 val =
ina.readBusVoltage();
150 Power_Control_Charge(
true);
155float Power_Control_Get_Charging_Voltage() {
156 if(!Power_Control_INA226_Check()) {
159 return(
ina.readBusVoltage());
162float Power_Control_Get_Charging_Current() {
163 if(!Power_Control_INA226_Check()) {
166 return(
ina.readShuntCurrent());
169bool Power_Control_Check_Battery_Limit() {
171 Power_Control_Load_Configuration();
175 if((Power_Control_Get_Battery_Voltage() <=
BATTERY_VOLTAGE_LIMIT) && powerConfig.bits.lowPowerModeEnabled) {
177 powerConfig.bits.lowPowerModeActive = 1;
181 powerConfig.bits.lowPowerModeActive = 0;
186 Power_Control_Save_Configuration();
#define MPPT_KEEP_ALIVE_ENABLED
#define LOW_POWER_MODE_ENABLED
#define MPPT_TEMP_SWITCH_ENABLED
#define LOW_POWER_MODE_ACTIVE
#define EEPROM_POWER_CONFIG_ADDR
#define INA_REG_MANUFACTURER_ID
#define INA_MANUFACTURER_ID
#define DIGITAL_OUT_MPPT_PIN
#define BATTERY_VOLTAGE_LIMIT
#define BATTERY_TEMPERATURE_LIMIT
#define BATTERY_TEMP_SENSOR_ADDR
T Persistent_Storage_Read(uint16_t addr)
This function reads a value of type T from EEPROM.
Power configuration strutcture, each entry is one bit long. Total 1 byte, lowPowerModeActive is the l...
Union to quickly access power configuration bits or the entire single-byte value.