forked from achamaikin/CCSModuleSW30Web
Expose charging session elapsed time in monitoring packet (v1.0.27).
CONN.ChargingTime ticks at 1 Hz during Charging; serial GET_STATUS reports elapsed min/sec instead of zero stubs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -13,6 +13,7 @@ void CONN_Init(){
|
||||
CONN.connControl = CMD_NONE;
|
||||
CONN.connState = Unknown;
|
||||
CONN.RequestedVoltage = PSU_MIN_VOLTAGE;
|
||||
CONN.ChargingTime = 0;
|
||||
CONN.hv_limit = 0u;
|
||||
CONN.hv_tick = 0u;
|
||||
CONN.hv_limit_count = 0u;
|
||||
@@ -20,6 +21,7 @@ void CONN_Init(){
|
||||
}
|
||||
|
||||
void CONN_Loop(){
|
||||
static uint32_t charging_time_tick = 0;
|
||||
static CONN_State_t last_connState = Unknown;
|
||||
if(last_connState != CONN.connState){
|
||||
last_connState = CONN.connState;
|
||||
@@ -40,6 +42,25 @@ void CONN_Loop(){
|
||||
log_printf(LOG_WARN, "CONN0 Error: %d\n", (int)CONN.chargingError);
|
||||
}
|
||||
|
||||
if (HAL_GetTick() - charging_time_tick >= 1000U) {
|
||||
charging_time_tick += 1000U;
|
||||
if (CONN.connState == Charging) {
|
||||
CONN.ChargingTime++;
|
||||
}
|
||||
if (CONN.connState == Unplugged) {
|
||||
CONN.ChargingTime = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CONN_GetElapsedForMonitoring(uint16_t *min, uint8_t *sec) {
|
||||
uint32_t elapsed_sec = CONN.ChargingTime;
|
||||
if (min != NULL) {
|
||||
*min = (uint16_t)(elapsed_sec / 60U);
|
||||
}
|
||||
if (sec != NULL) {
|
||||
*sec = (uint8_t)(elapsed_sec % 60U);
|
||||
}
|
||||
}
|
||||
|
||||
void CONN_SetState(CONN_State_t state){
|
||||
|
||||
Reference in New Issue
Block a user