Print (dis)charge FSM state changes
This commit is contained in:
parent
6b070bbf86
commit
1ad35dae2b
|
@ -5,10 +5,27 @@
|
||||||
#include "power_switch.h"
|
#include "power_switch.h"
|
||||||
#include "measurement.h"
|
#include "measurement.h"
|
||||||
#include "charge_pump.h"
|
#include "charge_pump.h"
|
||||||
|
#include "rs485.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "charge_control.h"
|
#include "charge_control.h"
|
||||||
|
|
||||||
|
static const char *CHARGE_STATE_TEXT[] = {
|
||||||
|
"WAIT_CHARGEPUMP",
|
||||||
|
"INITIAL",
|
||||||
|
"TRANSITION",
|
||||||
|
"FLOAT",
|
||||||
|
"SLEEP",
|
||||||
|
"HIGH_TEMPERATURE"
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char *DISCHARGE_STATE_TEXT[] = {
|
||||||
|
"WAIT_CHARGEPUMP",
|
||||||
|
"OK",
|
||||||
|
"VOLTAGE_LOW",
|
||||||
|
"OVERCURRENT"
|
||||||
|
};
|
||||||
|
|
||||||
static enum ChargeState charge_state;
|
static enum ChargeState charge_state;
|
||||||
static enum DischargeState discharge_state;
|
static enum DischargeState discharge_state;
|
||||||
|
|
||||||
|
@ -91,10 +108,16 @@ void charge_control_update(uint64_t uptime_ms, struct MeasurementResult *meas)
|
||||||
enum DischargeState last_discharge_state = discharge_state;
|
enum DischargeState last_discharge_state = discharge_state;
|
||||||
|
|
||||||
if(charge_state_entered) {
|
if(charge_state_entered) {
|
||||||
|
rs485_enqueue("STATE:CHARGE:");
|
||||||
|
rs485_enqueue(CHARGE_STATE_TEXT[charge_state]);
|
||||||
|
rs485_enqueue("\n");
|
||||||
charge_state_entered_timestamp = uptime_ms;
|
charge_state_entered_timestamp = uptime_ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(discharge_state_entered) {
|
if(discharge_state_entered) {
|
||||||
|
rs485_enqueue("STATE:DISCHG:");
|
||||||
|
rs485_enqueue(DISCHARGE_STATE_TEXT[discharge_state]);
|
||||||
|
rs485_enqueue("\n");
|
||||||
discharge_state_entered_timestamp = uptime_ms;
|
discharge_state_entered_timestamp = uptime_ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue