APPS calibration screen
This commit is contained in:
28
TouchGFX/gui/src/apps_screen/APPSPresenter.cpp
Normal file
28
TouchGFX/gui/src/apps_screen/APPSPresenter.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include "stm32h7xx_hal.h"
|
||||
|
||||
#include <gui/apps_screen/APPSPresenter.hpp>
|
||||
#include <gui/apps_screen/APPSView.hpp>
|
||||
|
||||
APPSPresenter::APPSPresenter(APPSView &v) : view(v) {}
|
||||
|
||||
void APPSPresenter::activate() {}
|
||||
|
||||
void APPSPresenter::deactivate() {}
|
||||
|
||||
void APPSPresenter::nextScreen() {
|
||||
static_cast<FrontendApplication *>(Application::getInstance())
|
||||
->gotoSDCScreenNoTransition();
|
||||
}
|
||||
|
||||
void APPSPresenter::vehicleStateUpdated() {
|
||||
static uint32_t last_graph_update = 0;
|
||||
view.updateFieldValues();
|
||||
if (HAL_GetTick() - last_graph_update > 100) {
|
||||
view.addGraphPoints(vehicle_state.apps0_out, vehicle_state.apps1_out);
|
||||
last_graph_update = HAL_GetTick();
|
||||
}
|
||||
}
|
||||
|
||||
void APPSPresenter::paramConfirmed() {
|
||||
view.abxParamConfirmed(vehicle_state.last_param_confirmed);
|
||||
}
|
||||
137
TouchGFX/gui/src/apps_screen/APPSView.cpp
Normal file
137
TouchGFX/gui/src/apps_screen/APPSView.cpp
Normal file
@ -0,0 +1,137 @@
|
||||
#include "params.h"
|
||||
#include "touchgfx/Color.hpp"
|
||||
#include "vehicle_state.h"
|
||||
#include <gui/apps_screen/APPSView.hpp>
|
||||
|
||||
APPSView::APPSView() : selectedField{-1} {
|
||||
for (size_t i = 0; i < FIELD_COUNT; i++) {
|
||||
fieldsDirty[i] = false;
|
||||
}
|
||||
fieldWidgets[0] = &apps0min;
|
||||
fieldWidgets[1] = &apps0max;
|
||||
fieldWidgets[2] = &apps1min;
|
||||
fieldWidgets[3] = &apps1max;
|
||||
fieldBackgrounds[0] = &apps0min_bg;
|
||||
fieldBackgrounds[1] = &apps0max_bg;
|
||||
fieldBackgrounds[2] = &apps1min_bg;
|
||||
fieldBackgrounds[3] = &apps1max_bg;
|
||||
params.apps0_min = vehicle_state.apps0_min;
|
||||
params.apps0_max = vehicle_state.apps0_max;
|
||||
params.apps1_min = vehicle_state.apps1_min;
|
||||
params.apps1_max = vehicle_state.apps1_max;
|
||||
}
|
||||
|
||||
void APPSView::setupScreen() { APPSViewBase::setupScreen(); }
|
||||
|
||||
void APPSView::tearDownScreen() { APPSViewBase::tearDownScreen(); }
|
||||
|
||||
void APPSView::selectPrevField() {
|
||||
if (selectedField != -1) {
|
||||
fieldBackgrounds[selectedField]->setVisible(false);
|
||||
fieldBackgrounds[selectedField]->invalidate();
|
||||
}
|
||||
|
||||
if (selectedField == -1) {
|
||||
selectedField = FIELD_COUNT - 1;
|
||||
} else {
|
||||
selectedField = (selectedField - 1) % FIELD_COUNT;
|
||||
}
|
||||
|
||||
fieldBackgrounds[selectedField]->setVisible(true);
|
||||
fieldBackgrounds[selectedField]->invalidate();
|
||||
}
|
||||
|
||||
void APPSView::selectNextField() {
|
||||
if (selectedField != -1) {
|
||||
fieldBackgrounds[selectedField]->setVisible(false);
|
||||
fieldBackgrounds[selectedField]->invalidate();
|
||||
}
|
||||
|
||||
selectedField = (selectedField + 1) % FIELD_COUNT;
|
||||
|
||||
fieldBackgrounds[selectedField]->setVisible(true);
|
||||
fieldBackgrounds[selectedField]->invalidate();
|
||||
}
|
||||
|
||||
void APPSView::decField() {
|
||||
if (selectedField == -1) {
|
||||
return;
|
||||
}
|
||||
fieldsDirty[selectedField] = true;
|
||||
params_dec(fieldParams[selectedField]);
|
||||
}
|
||||
|
||||
void APPSView::incField() {
|
||||
if (selectedField == -1) {
|
||||
return;
|
||||
}
|
||||
fieldsDirty[selectedField] = true;
|
||||
params_inc(fieldParams[selectedField]);
|
||||
}
|
||||
|
||||
void APPSView::confirmField() {
|
||||
if (selectedField == -1) {
|
||||
return;
|
||||
}
|
||||
params_broadcast(fieldParams[selectedField]);
|
||||
}
|
||||
|
||||
void APPSView::switchPrecision() {
|
||||
if (precision == 0.001f) {
|
||||
precision = 0.01f;
|
||||
} else {
|
||||
precision = 0.001f;
|
||||
}
|
||||
for (ParamType ¶m : fieldParams) {
|
||||
param_steps[param] = precision;
|
||||
}
|
||||
}
|
||||
|
||||
void APPSView::abxParamConfirmed(ParamType param) {
|
||||
for (size_t i = 0; i < FIELD_COUNT; i++) {
|
||||
if (fieldParams[i] == param) {
|
||||
fieldsDirty[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void APPSView::updateFieldValues() {
|
||||
float values[FIELD_COUNT];
|
||||
values[0] = vehicle_state.apps0_min;
|
||||
values[1] = vehicle_state.apps0_max;
|
||||
values[2] = vehicle_state.apps1_min;
|
||||
values[3] = vehicle_state.apps1_max;
|
||||
for (size_t i = 0; i < FIELD_COUNT; i++) {
|
||||
auto &buf = fieldBuffers[i];
|
||||
if (fieldsDirty[i]) {
|
||||
values[i] = params.valuesFloat[fieldParams[i]];
|
||||
fieldWidgets[i]->setColor(
|
||||
touchgfx::Color::getColorFromRGB(0xff, 0x00, 0x00));
|
||||
} else {
|
||||
fieldWidgets[i]->setColor(
|
||||
touchgfx::Color::getColorFromRGB(0xff, 0xff, 0xff));
|
||||
}
|
||||
touchgfx::Unicode::snprintfFloat(buf, sizeof(buf) / sizeof(*buf), "%5.3f",
|
||||
values[i]);
|
||||
fieldWidgets[i]->setWildcard(buf);
|
||||
fieldWidgets[i]->invalidate();
|
||||
}
|
||||
|
||||
touchgfx::Unicode::snprintfFloat(apps0Buffer,
|
||||
sizeof(apps0Buffer) / sizeof(*apps0Buffer),
|
||||
"%5.3f", vehicle_state.apps0_volt);
|
||||
apps0cur.setWildcard(apps0Buffer);
|
||||
apps0cur.invalidate();
|
||||
touchgfx::Unicode::snprintfFloat(apps1Buffer,
|
||||
sizeof(apps1Buffer) / sizeof(*apps1Buffer),
|
||||
"%5.3f", vehicle_state.apps1_volt);
|
||||
apps1cur.setWildcard(apps1Buffer);
|
||||
apps1cur.invalidate();
|
||||
}
|
||||
|
||||
void APPSView::addGraphPoints(float apps0, float apps1) {
|
||||
apps0Graph.addDataPoint(apps0 * 100);
|
||||
apps1Graph.addDataPoint(apps1 * 100);
|
||||
apps0Graph.invalidate();
|
||||
apps1Graph.invalidate();
|
||||
}
|
||||
@ -275,13 +275,30 @@ static_assert(sizeof(dataFieldDescs) / sizeof(dataFieldDescs[0]) ==
|
||||
|
||||
NamedFieldDescription paramFieldDescs[] = {
|
||||
[PF_BBAL] = {NamedFieldKind::Float, "BBAL", 2, 1, PARAM_FIELD(bbal)},
|
||||
[PF_SLIPREF] = {NamedFieldKind::Float, "SLIPREF", 2, 2,
|
||||
PARAM_FIELD(slipref)},
|
||||
[PF_MUMAX] = {NamedFieldKind::Float, "MUMAX", 2, 1, PARAM_FIELD(mumax)},
|
||||
[PF_ASRP] = {NamedFieldKind::Int, "ASR-P", 2, 0, PARAM_FIELD(asrp)},
|
||||
[PF_ASRON] = {NamedFieldKind::Int, "ASR-ON", 2, 0, PARAM_FIELD(asron)},
|
||||
[PF_ASRI] = {NamedFieldKind::Int, "ASR-I", 2, 0, PARAM_FIELD(asri)},
|
||||
[PF_PLIM] = {NamedFieldKind::Int, "PLIM", 2, 0, PARAM_FIELD(plim)},
|
||||
[PF_TORQUE] = {NamedFieldKind::Float, "TSCALE", 3, 1, PARAM_FIELD(torque)},
|
||||
[PF_SLIM] = {NamedFieldKind::Int, "SLIM", 2, 0, PARAM_FIELD(slim)},
|
||||
[PF_APPS0_MIN] = {NamedFieldKind::Float, "APPS0MIN", 3, 1,
|
||||
PARAM_FIELD(apps0_min)},
|
||||
[PF_APPS0_MAX] = {NamedFieldKind::Float, "APPS0MAX", 3, 1,
|
||||
PARAM_FIELD(apps0_max)},
|
||||
[PF_APPS1_MIN] = {NamedFieldKind::Float, "APPS1MIN", 3, 1,
|
||||
PARAM_FIELD(apps1_min)},
|
||||
[PF_APPS1_MAX] = {NamedFieldKind::Float, "APPS1MAX", 3, 1,
|
||||
PARAM_FIELD(apps1_max)},
|
||||
[PF_TV] = {NamedFieldKind::Int, "TV", 3, 0, PARAM_FIELD(tv)},
|
||||
[PF_TC] = {NamedFieldKind::Int, "TC", 3, 0, PARAM_FIELD(tc)},
|
||||
[PF_TC_SLIPREF] = {NamedFieldKind::Float, "TCSLIPREF", 3, 1,
|
||||
PARAM_FIELD(tc_slipref)},
|
||||
[PF_TC_MUMAX] = {NamedFieldKind::Float, "TCMUMAX", 3, 1,
|
||||
PARAM_FIELD(tc_mumax)},
|
||||
[PF_TC_P] = {NamedFieldKind::Float, "TCP", 3, 1, PARAM_FIELD(tc_p)},
|
||||
[PF_TC_I] = {NamedFieldKind::Float, "TCI", 3, 1, PARAM_FIELD(tc_i)},
|
||||
[PF_DRS_CLOSED] = {NamedFieldKind::Float, "DRSCLOSED", 3, 1,
|
||||
PARAM_FIELD(drs_closed)},
|
||||
[PF_DRS_OPEN] = {NamedFieldKind::Float, "DRSOPEN", 3, 1,
|
||||
PARAM_FIELD(drs_open)},
|
||||
[PF_MAP] = {NamedFieldKind::Int, "MAP", 3, 0, PARAM_FIELD(map)},
|
||||
};
|
||||
|
||||
static_assert(sizeof(paramFieldDescs) / sizeof(paramFieldDescs[0]) ==
|
||||
|
||||
@ -11,7 +11,7 @@ void VehicleConfigPresenter::deactivate() {}
|
||||
|
||||
void VehicleConfigPresenter::nextScreen() {
|
||||
static_cast<FrontendApplication *>(Application::getInstance())
|
||||
->gotoSDCScreenNoTransition();
|
||||
->gotoAPPSScreenNoTransition();
|
||||
}
|
||||
|
||||
void VehicleConfigPresenter::paramConfirmed() {
|
||||
|
||||
Reference in New Issue
Block a user