Show if parameter change has been confirmed by ABX
This commit is contained in:
@ -14,6 +14,7 @@ public:
|
||||
virtual void initialize() override;
|
||||
|
||||
void setSelected(int selected);
|
||||
void setDirty(bool dirty);
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
@ -15,6 +15,7 @@ public:
|
||||
|
||||
virtual void vehicleStateUpdated(){};
|
||||
virtual void nextScreen(){};
|
||||
virtual void paramConfirmed(){};
|
||||
|
||||
protected:
|
||||
Model *model;
|
||||
|
||||
@ -17,18 +17,19 @@ public:
|
||||
* The activate function is called automatically when this screen is "switched
|
||||
* in" (ie. made active). Initialization logic can be placed here.
|
||||
*/
|
||||
virtual void activate();
|
||||
virtual void activate() override;
|
||||
|
||||
/**
|
||||
* 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 void deactivate() override;
|
||||
|
||||
virtual ~VehicleConfigPresenter(){};
|
||||
|
||||
void nextScreen() override;
|
||||
void paramConfirmed() override;
|
||||
|
||||
private:
|
||||
VehicleConfigPresenter();
|
||||
|
||||
@ -19,10 +19,14 @@ public:
|
||||
void incParam() override;
|
||||
void confirmParam() override;
|
||||
|
||||
void abxParamConfirmed(ParamType param);
|
||||
|
||||
protected:
|
||||
private:
|
||||
int selectedParam;
|
||||
|
||||
bool paramsDirty[ParamType_COUNT] = {false};
|
||||
|
||||
void updateSelectedParam(int select);
|
||||
};
|
||||
|
||||
|
||||
@ -13,6 +13,14 @@ void ConfigItem::setSelected(int selected) {
|
||||
bg.invalidate();
|
||||
}
|
||||
|
||||
void ConfigItem::setDirty(bool dirty) {
|
||||
if (dirty) {
|
||||
value.setColor(touchgfx::Color::getColorFromRGB(0xFF, 0x00, 0x00));
|
||||
} else {
|
||||
value.setColor(touchgfx::Color::getColorFromRGB(0xFF, 0xFF, 0xFF));
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigItem::typeUpdated() {
|
||||
switch (desc->kind) {
|
||||
case NamedFieldKind::Float:
|
||||
|
||||
@ -17,9 +17,8 @@ void Model::tick() { modelListener->vehicleStateUpdated(); }
|
||||
|
||||
void Model::tick() {
|
||||
ULONG events;
|
||||
if (tx_event_flags_get(&gui_update_events,
|
||||
GUI_UPDATE_VEHICLE_STATE | GUI_UPDATE_NEXT_SCREEN,
|
||||
TX_OR_CLEAR, &events, TX_NO_WAIT) != TX_SUCCESS) {
|
||||
if (tx_event_flags_get(&gui_update_events, GUI_UPDATE_ALL, TX_OR_CLEAR,
|
||||
&events, TX_NO_WAIT) != TX_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
if (events & GUI_UPDATE_NEXT_SCREEN) {
|
||||
@ -28,6 +27,9 @@ void Model::tick() {
|
||||
if (events & GUI_UPDATE_VEHICLE_STATE) {
|
||||
modelListener->vehicleStateUpdated();
|
||||
}
|
||||
if (events & GUI_UPDATE_PARAM_CONFIRMED) {
|
||||
modelListener->paramConfirmed();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SIMULATOR
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "vehicle_state.h"
|
||||
#include <gui/vehicleconfig_screen/VehicleConfigPresenter.hpp>
|
||||
#include <gui/vehicleconfig_screen/VehicleConfigView.hpp>
|
||||
|
||||
@ -12,3 +13,7 @@ void VehicleConfigPresenter::nextScreen() {
|
||||
static_cast<FrontendApplication *>(Application::getInstance())
|
||||
->gotoDebugViewScreenNoTransition();
|
||||
}
|
||||
|
||||
void VehicleConfigPresenter::paramConfirmed() {
|
||||
view.abxParamConfirmed(vehicle_state.last_param_confirmed);
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ void VehicleConfigView::tearDownScreen() {
|
||||
void VehicleConfigView::paramsUpdateItem(ConfigItem &item, int16_t itemIndex) {
|
||||
item.setType(static_cast<ParamType>(itemIndex));
|
||||
item.setSelected(itemIndex == selectedParam);
|
||||
item.setDirty(paramsDirty[itemIndex]);
|
||||
}
|
||||
|
||||
void VehicleConfigView::selectPrevParam() {
|
||||
@ -34,10 +35,12 @@ void VehicleConfigView::selectNextParam() {
|
||||
|
||||
void VehicleConfigView::decParam() {
|
||||
params_dec(static_cast<ParamType>(selectedParam));
|
||||
paramsDirty[selectedParam] = true;
|
||||
params.itemChanged(selectedParam);
|
||||
}
|
||||
void VehicleConfigView::incParam() {
|
||||
params_inc(static_cast<ParamType>(selectedParam));
|
||||
paramsDirty[selectedParam] = true;
|
||||
params.itemChanged(selectedParam);
|
||||
}
|
||||
|
||||
@ -45,6 +48,11 @@ void VehicleConfigView::confirmParam() {
|
||||
params_broadcast(static_cast<ParamType>(selectedParam));
|
||||
}
|
||||
|
||||
void VehicleConfigView::abxParamConfirmed(ParamType param) {
|
||||
paramsDirty[param] = false;
|
||||
params.itemChanged(param);
|
||||
}
|
||||
|
||||
void VehicleConfigView::updateSelectedParam(int select) {
|
||||
int previousSelected = selectedParam;
|
||||
selectedParam = select;
|
||||
|
||||
Reference in New Issue
Block a user