Add LV SoC field
This commit is contained in:
parent
0736955fd9
commit
990e176b71
|
@ -133,7 +133,8 @@ typedef struct {
|
||||||
|
|
||||||
float min_cell_volt;
|
float min_cell_volt;
|
||||||
float max_cell_temp;
|
float max_cell_temp;
|
||||||
int soc;
|
int soc_ts;
|
||||||
|
int soc_lv;
|
||||||
|
|
||||||
float ts_current;
|
float ts_current;
|
||||||
float ts_voltage_bat;
|
float ts_voltage_bat;
|
||||||
|
|
|
@ -85,7 +85,7 @@ void ftcan_msg_received_cb(uint16_t id, size_t datalen, const uint8_t *data) {
|
||||||
case CAN_ID_AMS_STATUS:
|
case CAN_ID_AMS_STATUS:
|
||||||
vehicle_state.ts_state = data[0] & 0x7F;
|
vehicle_state.ts_state = data[0] & 0x7F;
|
||||||
vehicle_state.sdc_closed = (data[0] & 0x80) >> 7;
|
vehicle_state.sdc_closed = (data[0] & 0x80) >> 7;
|
||||||
vehicle_state.soc = data[1];
|
vehicle_state.soc_ts = data[1];
|
||||||
ptr = &data[2];
|
ptr = &data[2];
|
||||||
vehicle_state.min_cell_volt =
|
vehicle_state.min_cell_volt =
|
||||||
ftcan_unmarshal_unsigned(&ptr, 2) * CAN_AMS_STATUS_VOLTAGE_FACTOR;
|
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:
|
case CAN_ID_ABX_MISC:
|
||||||
vehicle_state.distance_total =
|
vehicle_state.distance_total =
|
||||||
(data[3] | (data[4] << 8)) * CAN_ABX_MISC_DISTANCE_TOTAL_FACTOR;
|
(data[3] | (data[4] << 8)) * CAN_ABX_MISC_DISTANCE_TOTAL_FACTOR;
|
||||||
|
vehicle_state.soc_lv = data[5];
|
||||||
break;
|
break;
|
||||||
case CAN_ID_AS_MISSION_FB:
|
case CAN_ID_AS_MISSION_FB:
|
||||||
vehicle_state.active_mission = data[0] & 0b111;
|
vehicle_state.active_mission = data[0] & 0b111;
|
||||||
|
|
|
@ -264,8 +264,8 @@ NamedFieldDescription dataFieldDescs[] = {
|
||||||
VEH_FIELD(min_cell_volt)},
|
VEH_FIELD(min_cell_volt)},
|
||||||
[DF_MaxCellTemp] = {NamedFieldKind::Float, "TBAT", 2, 1,
|
[DF_MaxCellTemp] = {NamedFieldKind::Float, "TBAT", 2, 1,
|
||||||
VEH_FIELD(max_cell_temp)},
|
VEH_FIELD(max_cell_temp)},
|
||||||
[DF_TSSoC] = {NamedFieldKind::Int, "TSSOC", 3, 0, VEH_FIELD(soc)},
|
[DF_TSSoC] = {NamedFieldKind::Int, "TSSOC", 3, 0, VEH_FIELD(soc_ts)},
|
||||||
[DF_LVSoC] = {NamedFieldKind::Float, "LVSOC", 3, 0, get_zero},
|
[DF_LVSoC] = {NamedFieldKind::Int, "LVSOC", 3, 0, VEH_FIELD(soc_lv)},
|
||||||
[DF_TSCurrent] = {NamedFieldKind::Float, "ITS", 3, 0,
|
[DF_TSCurrent] = {NamedFieldKind::Float, "ITS", 3, 0,
|
||||||
VEH_FIELD(ts_current)},
|
VEH_FIELD(ts_current)},
|
||||||
[DF_TSVoltageBat] = {NamedFieldKind::Float, "TSVBAT", 3, 1,
|
[DF_TSVoltageBat] = {NamedFieldKind::Float, "TSVBAT", 3, 1,
|
||||||
|
|
|
@ -60,8 +60,13 @@ void DriverViewStatusItem::update() {
|
||||||
break;
|
break;
|
||||||
case DriverViewStatusType::LV:
|
case DriverViewStatusType::LV:
|
||||||
text.setTypedText(T_LV);
|
text.setTypedText(T_LV);
|
||||||
// TODO: Set color based on LV SoC
|
if (vehicle_state.soc_lv < 10) {
|
||||||
bg.setColor(COLOR_OFF);
|
bg.setColor(COLOR_ERROR);
|
||||||
|
} else if (vehicle_state.soc_lv < 30) {
|
||||||
|
bg.setColor(COLOR_WARNING);
|
||||||
|
} else {
|
||||||
|
bg.setColor(COLOR_OK);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
text.invalidate();
|
text.invalidate();
|
||||||
|
|
|
@ -23,7 +23,7 @@ void DriverViewPresenter::deactivate() {}
|
||||||
|
|
||||||
void DriverViewPresenter::vehicleStateUpdated() {
|
void DriverViewPresenter::vehicleStateUpdated() {
|
||||||
view.setTemps(vehicle_state.temps);
|
view.setTemps(vehicle_state.temps);
|
||||||
view.setTSSoC(vehicle_state.soc);
|
view.setTSSoC(vehicle_state.soc_ts);
|
||||||
updateProgress();
|
updateProgress();
|
||||||
updateErrorPopup();
|
updateErrorPopup();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue