add basic system overview screen with can watchdogs and brake pressure
This commit is contained in:
@ -5,7 +5,22 @@
|
||||
#include "touchgfx/hal/Types.hpp"
|
||||
#include <gui_generated/containers/DriverViewStatusItemBase.hpp>
|
||||
|
||||
enum class DriverViewStatusType { TS_R2D, AMS, SDC, SCS, PDU, INV, LV };
|
||||
enum class DriverViewStatusType {
|
||||
TS_R2D,
|
||||
AMS,
|
||||
SDC,
|
||||
SCS,
|
||||
PDU,
|
||||
INV,
|
||||
LV,
|
||||
SNF,
|
||||
DB,
|
||||
FTCU,
|
||||
SNR,
|
||||
Shunt,
|
||||
BPR,
|
||||
BPF,
|
||||
};
|
||||
|
||||
class DriverViewStatusItem : public DriverViewStatusItemBase {
|
||||
public:
|
||||
@ -18,20 +33,17 @@ public:
|
||||
|
||||
void update();
|
||||
|
||||
static inline colortype COLOR_OFF =
|
||||
touchgfx::Color::getColorFromRGB(0x00, 0x00, 0x00);
|
||||
static inline colortype COLOR_OK =
|
||||
touchgfx::Color::getColorFromRGB(0x0D, 0xBF, 0x00);
|
||||
static inline colortype COLOR_WARNING =
|
||||
touchgfx::Color::getColorFromRGB(0xEB, 0xC4, 0x00);
|
||||
static inline colortype COLOR_ERROR =
|
||||
touchgfx::Color::getColorFromRGB(0xC5, 0x0E, 0x1F);
|
||||
static inline colortype COLOR_TS =
|
||||
touchgfx::Color::getColorFromRGB(0xEB, 0x7D, 0x00);
|
||||
static inline colortype COLOR_OFF = touchgfx::Color::getColorFromRGB(0x00, 0x00, 0x00); // #000000
|
||||
static inline colortype COLOR_OK = touchgfx::Color::getColorFromRGB(0x0D, 0xBF, 0x00); // #0DBF00
|
||||
static inline colortype COLOR_WARNING = touchgfx::Color::getColorFromRGB(0xEB, 0xC4, 0x00); // #EBC400
|
||||
static inline colortype COLOR_ERROR = touchgfx::Color::getColorFromRGB(0xC5, 0x0E, 0x1F); // #C50E1F
|
||||
static inline colortype COLOR_TS = touchgfx::Color::getColorFromRGB(0xEB, 0x7D, 0x00); // #EB7D00
|
||||
static inline colortype COLOR_BLUE = touchgfx::Color::getColorFromRGB(0x00, 0x8F, 0xEE); // #008FEE
|
||||
|
||||
protected:
|
||||
private:
|
||||
DriverViewStatusType type;
|
||||
touchgfx::Unicode::UnicodeChar valueBuffer[16];
|
||||
};
|
||||
|
||||
#endif // DRIVERVIEWSTATUSITEM_HPP
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
#ifndef SYSTEMOVERVIEWPRESENTER_HPP
|
||||
#define SYSTEMOVERVIEWPRESENTER_HPP
|
||||
|
||||
#include <gui/model/ModelListener.hpp>
|
||||
#include <mvp/Presenter.hpp>
|
||||
|
||||
using namespace touchgfx;
|
||||
|
||||
class SystemOverviewView;
|
||||
|
||||
class SystemOverviewPresenter : public touchgfx::Presenter, public ModelListener {
|
||||
public:
|
||||
SystemOverviewPresenter(SystemOverviewView &v);
|
||||
|
||||
/**
|
||||
* The activate function is called automatically when this screen is "switched in"
|
||||
* (ie. made active). Initialization logic can be placed here.
|
||||
*/
|
||||
virtual void activate();
|
||||
|
||||
/**
|
||||
* The deactivate function is called automatically when this screen is "switched out"
|
||||
* (ie. made inactive). Teardown functionality can be placed here.
|
||||
*/
|
||||
virtual void deactivate();
|
||||
|
||||
virtual ~SystemOverviewPresenter() {}
|
||||
|
||||
void vehicleStateUpdated() override;
|
||||
void nextScreen() override;
|
||||
|
||||
private:
|
||||
SystemOverviewPresenter();
|
||||
|
||||
SystemOverviewView &view;
|
||||
};
|
||||
|
||||
#endif // SYSTEMOVERVIEWPRESENTER_HPP
|
||||
@ -0,0 +1,19 @@
|
||||
#ifndef SYSTEMOVERVIEWVIEW_HPP
|
||||
#define SYSTEMOVERVIEWVIEW_HPP
|
||||
|
||||
#include <gui/systemoverview_screen/SystemOverviewPresenter.hpp>
|
||||
#include <gui_generated/systemoverview_screen/SystemOverviewViewBase.hpp>
|
||||
|
||||
class SystemOverviewView : public SystemOverviewViewBase {
|
||||
public:
|
||||
SystemOverviewView();
|
||||
virtual ~SystemOverviewView() {}
|
||||
virtual void setupScreen();
|
||||
virtual void tearDownScreen();
|
||||
|
||||
void updateItems();
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
#endif // SYSTEMOVERVIEWVIEW_HPP
|
||||
@ -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