add basic system overview screen with can watchdogs and brake pressure
This commit is contained in:
@ -27,5 +27,5 @@ void AMIPresenter::vehicleStateUpdated() {
|
||||
|
||||
void AMIPresenter::nextScreen() {
|
||||
FrontendApplication *app = static_cast<FrontendApplication *>(FrontendApplication::getInstance());
|
||||
app->gotoSDCScreenNoTransition();
|
||||
app->gotoVehicleConfigScreenNoTransition();
|
||||
}
|
||||
|
||||
@ -8,7 +8,13 @@ DriverViewStatusItem::DriverViewStatusItem() {}
|
||||
|
||||
void DriverViewStatusItem::initialize() { DriverViewStatusItemBase::initialize(); }
|
||||
|
||||
void DriverViewStatusItem::setType(DriverViewStatusType type) { this->type = type; }
|
||||
void DriverViewStatusItem::setType(DriverViewStatusType type) { //
|
||||
this->type = type;
|
||||
|
||||
if (type == DriverViewStatusType::LV || type == DriverViewStatusType::BPF || type == DriverViewStatusType::BPR) {
|
||||
text.setTypedText(T_STATUSWILDCARD); // TODO rename wildcard typed text to more general name
|
||||
}
|
||||
}
|
||||
|
||||
void DriverViewStatusItem::update() {
|
||||
switch (type) {
|
||||
@ -27,22 +33,28 @@ void DriverViewStatusItem::update() {
|
||||
bg.setColor(COLOR_TS);
|
||||
}
|
||||
break;
|
||||
|
||||
case DriverViewStatusType::AMS:
|
||||
text.setTypedText(T_AMS);
|
||||
bg.setColor(vehicle_state.ts_state == TS_ERROR ? COLOR_ERROR : COLOR_OK);
|
||||
bg.setColor(vehicle_state.watchdog_timeout.ams ? COLOR_ERROR : COLOR_OK);
|
||||
break;
|
||||
|
||||
case DriverViewStatusType::SDC:
|
||||
text.setTypedText(T_SDC);
|
||||
bg.setColor(vehicle_state.sdc_closed ? COLOR_OK : COLOR_WARNING);
|
||||
break;
|
||||
|
||||
case DriverViewStatusType::SCS:
|
||||
text.setTypedText(T_SCS);
|
||||
bg.setColor(vehicle_state.errors.err_scs ? COLOR_ERROR : COLOR_OK);
|
||||
break;
|
||||
|
||||
case DriverViewStatusType::PDU:
|
||||
text.setTypedText(T_PDU);
|
||||
bg.setColor(vehicle_state.errors.err_pdu ? COLOR_ERROR : COLOR_OK);
|
||||
// bg.setColor(vehicle_state.errors.err_pdu ? COLOR_ERROR : COLOR_OK);
|
||||
bg.setColor(vehicle_state.watchdog_timeout.pdu ? COLOR_ERROR : COLOR_OK);
|
||||
break;
|
||||
|
||||
case DriverViewStatusType::INV:
|
||||
text.setTypedText(T_INV);
|
||||
if (vehicle_state.errors.err_inv_1 || vehicle_state.errors.err_inv_2) {
|
||||
@ -53,17 +65,61 @@ void DriverViewStatusItem::update() {
|
||||
bg.setColor(COLOR_OFF);
|
||||
}
|
||||
break;
|
||||
|
||||
case DriverViewStatusType::LV:
|
||||
text.setTypedText(T_LV);
|
||||
// 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);
|
||||
// }
|
||||
// TODO
|
||||
bg.setColor(COLOR_OK);
|
||||
Unicode::snprintf(valueBuffer, 8, "LV:%d%%", (int)(vehicle_state.lv_soc));
|
||||
text.setWildcard(valueBuffer);
|
||||
if (vehicle_state.lv_soc < 20) {
|
||||
bg.setColor(COLOR_ERROR);
|
||||
} else if (vehicle_state.lv_soc < 40) {
|
||||
bg.setColor(COLOR_WARNING);
|
||||
} else {
|
||||
bg.setColor(COLOR_OK);
|
||||
}
|
||||
break;
|
||||
|
||||
case DriverViewStatusType::SNF:
|
||||
text.setTypedText(T_SNF);
|
||||
bg.setColor(vehicle_state.watchdog_timeout.snf ? COLOR_ERROR : COLOR_OK);
|
||||
break;
|
||||
|
||||
case DriverViewStatusType::DB:
|
||||
text.setTypedText(T_DB);
|
||||
bg.setColor(vehicle_state.watchdog_timeout.db ? COLOR_ERROR : COLOR_OK);
|
||||
break;
|
||||
|
||||
case DriverViewStatusType::FTCU:
|
||||
text.setTypedText(T_FTCU);
|
||||
bg.setColor(vehicle_state.watchdog_timeout.ftcu ? COLOR_ERROR : COLOR_OK);
|
||||
break;
|
||||
|
||||
case DriverViewStatusType::SNR:
|
||||
text.setTypedText(T_SNR);
|
||||
bg.setColor(vehicle_state.watchdog_timeout.snr ? COLOR_ERROR : COLOR_OK);
|
||||
break;
|
||||
|
||||
case DriverViewStatusType::Shunt:
|
||||
text.setTypedText(T_SHUNT);
|
||||
bg.setColor(vehicle_state.watchdog_timeout.shunt ? COLOR_ERROR : COLOR_OK);
|
||||
break;
|
||||
|
||||
case DriverViewStatusType::BPF: {
|
||||
float params[3] = {5.0, 1.0, vehicle_state.brake_pressure_f};
|
||||
Unicode::snprintfFloats(valueBuffer, 10, "F:%*.*f", params);
|
||||
text.setWildcard(valueBuffer);
|
||||
bg.setColor(vehicle_state.brake_pressure_f >= 30 ? COLOR_BLUE : COLOR_OFF);
|
||||
break;
|
||||
}
|
||||
|
||||
case DriverViewStatusType::BPR: {
|
||||
float params[3] = {5.0, 1.0, vehicle_state.brake_pressure_r};
|
||||
Unicode::snprintfFloats(valueBuffer, 10, "R:%*.*f", params);
|
||||
text.setWildcard(valueBuffer);
|
||||
bg.setColor(vehicle_state.brake_pressure_r >= 30 ? COLOR_BLUE : COLOR_OFF);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
text.invalidate();
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
#include <gui/systemoverview_screen/SystemOverviewPresenter.hpp>
|
||||
#include <gui/systemoverview_screen/SystemOverviewView.hpp>
|
||||
|
||||
SystemOverviewPresenter::SystemOverviewPresenter(SystemOverviewView &v) : view(v) {}
|
||||
|
||||
void SystemOverviewPresenter::activate() {}
|
||||
|
||||
void SystemOverviewPresenter::deactivate() {}
|
||||
|
||||
void SystemOverviewPresenter::vehicleStateUpdated() { //
|
||||
view.updateItems();
|
||||
}
|
||||
|
||||
void SystemOverviewPresenter::nextScreen() {
|
||||
static_cast<FrontendApplication *>(Application::getInstance())->gotoSDCScreenNoTransition();
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
#include <gui/systemoverview_screen/SystemOverviewView.hpp>
|
||||
|
||||
SystemOverviewView::SystemOverviewView() {}
|
||||
|
||||
void SystemOverviewView::setupScreen() {
|
||||
SystemOverviewViewBase::setupScreen();
|
||||
|
||||
statusTS_R2D.setType(DriverViewStatusType::TS_R2D);
|
||||
statusAMS.setType(DriverViewStatusType::AMS);
|
||||
statusSDC.setType(DriverViewStatusType::SDC);
|
||||
statusSCS.setType(DriverViewStatusType::SCS);
|
||||
statusPDU.setType(DriverViewStatusType::PDU);
|
||||
statusINV.setType(DriverViewStatusType::INV);
|
||||
statusLV.setType(DriverViewStatusType::LV);
|
||||
statusDB.setType(DriverViewStatusType::DB);
|
||||
statusFTCU.setType(DriverViewStatusType::FTCU);
|
||||
statusSNF.setType(DriverViewStatusType::SNF);
|
||||
statusSNR.setType(DriverViewStatusType::SNR);
|
||||
statusShunt.setType(DriverViewStatusType::Shunt);
|
||||
statusBPF.setType(DriverViewStatusType::BPF);
|
||||
statusBPR.setType(DriverViewStatusType::BPR);
|
||||
status1.setVisible(false);
|
||||
status2.setVisible(false);
|
||||
status3.setVisible(false);
|
||||
status4.setVisible(false);
|
||||
}
|
||||
|
||||
class StatusItemUpdateCallback : public touchgfx::GenericCallback<touchgfx::Drawable &> {
|
||||
virtual void execute(Drawable &item) override {
|
||||
DriverViewStatusItem &statusItem = static_cast<DriverViewStatusItem &>(item);
|
||||
statusItem.update();
|
||||
}
|
||||
|
||||
virtual bool isValid() const override { return true; }
|
||||
};
|
||||
|
||||
void SystemOverviewView::updateItems() {
|
||||
StatusItemUpdateCallback cb;
|
||||
statusItems.forEachChild(&cb);
|
||||
}
|
||||
|
||||
void SystemOverviewView::tearDownScreen() { SystemOverviewViewBase::tearDownScreen(); }
|
||||
@ -2,18 +2,14 @@
|
||||
#include <gui/vehicleconfig_screen/VehicleConfigPresenter.hpp>
|
||||
#include <gui/vehicleconfig_screen/VehicleConfigView.hpp>
|
||||
|
||||
VehicleConfigPresenter::VehicleConfigPresenter(VehicleConfigView &v)
|
||||
: view(v) {}
|
||||
VehicleConfigPresenter::VehicleConfigPresenter(VehicleConfigView &v) : view(v) {}
|
||||
|
||||
void VehicleConfigPresenter::activate() {}
|
||||
|
||||
void VehicleConfigPresenter::deactivate() {}
|
||||
|
||||
void VehicleConfigPresenter::nextScreen() {
|
||||
static_cast<FrontendApplication *>(Application::getInstance())
|
||||
->gotoSDCScreenNoTransition();
|
||||
static_cast<FrontendApplication *>(Application::getInstance())->gotoSystemOverviewScreenNoTransition();
|
||||
}
|
||||
|
||||
void VehicleConfigPresenter::paramConfirmed() {
|
||||
view.abxParamConfirmed(vehicle_state.last_param_confirmed);
|
||||
}
|
||||
void VehicleConfigPresenter::paramConfirmed() { view.abxParamConfirmed(vehicle_state.last_param_confirmed); }
|
||||
|
||||
Reference in New Issue
Block a user