Add LV SoC field

This commit is contained in:
Jasper Blanckenburg 2023-07-24 18:15:24 +02:00
parent 0736955fd9
commit 990e176b71
5 changed files with 14 additions and 7 deletions

View File

@ -133,7 +133,8 @@ typedef struct {
float min_cell_volt;
float max_cell_temp;
int soc;
int soc_ts;
int soc_lv;
float ts_current;
float ts_voltage_bat;

View File

@ -85,7 +85,7 @@ void ftcan_msg_received_cb(uint16_t id, size_t datalen, const uint8_t *data) {
case CAN_ID_AMS_STATUS:
vehicle_state.ts_state = data[0] & 0x7F;
vehicle_state.sdc_closed = (data[0] & 0x80) >> 7;
vehicle_state.soc = data[1];
vehicle_state.soc_ts = data[1];
ptr = &data[2];
vehicle_state.min_cell_volt =
ftcan_unmarshal_unsigned(&ptr, 2) * CAN_AMS_STATUS_VOLTAGE_FACTOR;
@ -123,6 +123,7 @@ void ftcan_msg_received_cb(uint16_t id, size_t datalen, const uint8_t *data) {
case CAN_ID_ABX_MISC:
vehicle_state.distance_total =
(data[3] | (data[4] << 8)) * CAN_ABX_MISC_DISTANCE_TOTAL_FACTOR;
vehicle_state.soc_lv = data[5];
break;
case CAN_ID_AS_MISSION_FB:
vehicle_state.active_mission = data[0] & 0b111;

View File

@ -264,8 +264,8 @@ NamedFieldDescription dataFieldDescs[] = {
VEH_FIELD(min_cell_volt)},
[DF_MaxCellTemp] = {NamedFieldKind::Float, "TBAT", 2, 1,
VEH_FIELD(max_cell_temp)},
[DF_TSSoC] = {NamedFieldKind::Int, "TSSOC", 3, 0, VEH_FIELD(soc)},
[DF_LVSoC] = {NamedFieldKind::Float, "LVSOC", 3, 0, get_zero},
[DF_TSSoC] = {NamedFieldKind::Int, "TSSOC", 3, 0, VEH_FIELD(soc_ts)},
[DF_LVSoC] = {NamedFieldKind::Int, "LVSOC", 3, 0, VEH_FIELD(soc_lv)},
[DF_TSCurrent] = {NamedFieldKind::Float, "ITS", 3, 0,
VEH_FIELD(ts_current)},
[DF_TSVoltageBat] = {NamedFieldKind::Float, "TSVBAT", 3, 1,

View File

@ -60,8 +60,13 @@ void DriverViewStatusItem::update() {
break;
case DriverViewStatusType::LV:
text.setTypedText(T_LV);
// TODO: Set color based on LV SoC
bg.setColor(COLOR_OFF);
if (vehicle_state.soc_lv < 10) {
bg.setColor(COLOR_ERROR);
} else if (vehicle_state.soc_lv < 30) {
bg.setColor(COLOR_WARNING);
} else {
bg.setColor(COLOR_OK);
}
break;
}
text.invalidate();

View File

@ -23,7 +23,7 @@ void DriverViewPresenter::deactivate() {}
void DriverViewPresenter::vehicleStateUpdated() {
view.setTemps(vehicle_state.temps);
view.setTSSoC(vehicle_state.soc);
view.setTSSoC(vehicle_state.soc_ts);
updateProgress();
updateErrorPopup();