lots of stuff

This commit is contained in:
2025-08-26 16:10:47 -05:00
parent 372e4941a2
commit bbc9d6ae91
27 changed files with 1193 additions and 147 deletions

View File

@@ -55,43 +55,40 @@ bool result;
void battery_checkId(void)
{
}
void Check_Bat_Id(void)
{
float32_t Battery;
float32_t Bat_Mid_Point;
float32_t Battery;
float32_t Bat_Mid_Point;
if(sys.adc.V_BID > LITHIUM_MID_POINT) // BAT_ID = 0V for lithium, mid point for Alkaline
{
if(Compare_With_Limit(sys.adc.V_BID,sys.adc.V_BAT,5.0))
{
Bat_Type = EXT_DC;
sys.batteryType = EXT_DC;
sys.maxPowerLimit = POWER_LIMIT_EXT_DC; // Limit max power to 5W.
}
else
{
Bat_Type = ALKALINE;
sys.batteryType = ALKALINE;
sys.maxPowerLimit = POWER_LIMIT_ALKALINE; // Limit max power to 5W.
Battery = sys.adc.V_BAT; // Calculate mid-point for alkaline
Bat_Mid_Point = Battery / 2;
if ((sys.adc.V_BID > (Bat_Mid_Point * 1.1)) || (sys.adc.V_BID < (Bat_Mid_Point * 0.9)) ) // Check if not at mid-point
Bat_Type = BAT_ERROR; // indicate battery insertion error
sys.batteryType = BAT_ERROR; // indicate battery insertion error
}
}
else
{
Bat_Type = LITHIUM;
sys.batteryType = LITHIUM;
sys.maxPowerLimit = POWER_LIMIT_LITHIUM; // Limit max power to 5W. 1.7 = 10.0 1.7X = 25.0
}
if(Bat_Type == BAT_ERROR)
if(sys.batteryType == BAT_ERROR)
{
LCD_Clear();
Task=BAT_INSERTION_ERROR;