Add progress bar to endurance view

This commit is contained in:
Jasper Blanckenburg 2024-06-11 22:34:36 +02:00
parent cb2f55be1b
commit f0db650c30
10 changed files with 40 additions and 26 deletions

View File

@ -12,6 +12,7 @@
#include <touchgfx/widgets/BoxWithBorder.hpp> #include <touchgfx/widgets/BoxWithBorder.hpp>
#include <touchgfx/widgets/TextArea.hpp> #include <touchgfx/widgets/TextArea.hpp>
#include <touchgfx/widgets/TextAreaWithWildcard.hpp> #include <touchgfx/widgets/TextAreaWithWildcard.hpp>
#include <gui/containers/ProgressBar.hpp>
class EnduranceViewBase : public touchgfx::View<EndurancePresenter> class EnduranceViewBase : public touchgfx::View<EndurancePresenter>
{ {
@ -69,6 +70,7 @@ protected:
touchgfx::BoxWithBorder lastLapBox; touchgfx::BoxWithBorder lastLapBox;
touchgfx::TextArea textArea1; touchgfx::TextArea textArea1;
touchgfx::TextAreaWithOneWildcard lastLapBat; touchgfx::TextAreaWithOneWildcard lastLapBat;
ProgressBar progressBar;
private: private:

View File

@ -115,6 +115,9 @@ EnduranceViewBase::EnduranceViewBase()
lastLapContainer.add(lastLapBat); lastLapContainer.add(lastLapBat);
add(lastLapContainer); add(lastLapContainer);
progressBar.setXY(12, 15);
add(progressBar);
} }
EnduranceViewBase::~EnduranceViewBase() EnduranceViewBase::~EnduranceViewBase()
@ -124,7 +127,7 @@ EnduranceViewBase::~EnduranceViewBase()
void EnduranceViewBase::setupScreen() void EnduranceViewBase::setupScreen()
{ {
progressBar.initialize();
} }
void EnduranceViewBase::handleKeyEvent(uint8_t key) void EnduranceViewBase::handleKeyEvent(uint8_t key)

View File

@ -12,12 +12,14 @@ public:
virtual void initialize(); virtual void initialize();
void setProgress(bool active, ProgressType type, float progress); void update();
protected: protected:
private: private:
touchgfx::Unicode::UnicodeChar r2dProgBuffer[16]; touchgfx::Unicode::UnicodeChar r2dProgBuffer[16];
touchgfx::Unicode::UnicodeChar socBuffer[4]; touchgfx::Unicode::UnicodeChar socBuffer[4];
void setProgress(bool active, ProgressType type, float progress);
}; };
#endif // PROGRESSBAR_HPP #endif // PROGRESSBAR_HPP

View File

@ -3,7 +3,6 @@
#include "gui/common/NamedField.hpp" #include "gui/common/NamedField.hpp"
#include "gui/containers/DriverViewFieldSelection.hpp" #include "gui/containers/DriverViewFieldSelection.hpp"
#include "gui/containers/ProgressBar.hpp"
#include <gui/driverview_screen/DriverViewPresenter.hpp> #include <gui/driverview_screen/DriverViewPresenter.hpp>
#include <gui_generated/driverview_screen/DriverViewViewBase.hpp> #include <gui_generated/driverview_screen/DriverViewViewBase.hpp>
@ -25,7 +24,7 @@ public:
void setTemps(const Temperatures &temps); void setTemps(const Temperatures &temps);
void setTSSoC(uint8_t soc); void setTSSoC(uint8_t soc);
void setProgress(bool active, ProgressType type, float progress); void updateProgress();
void showAMSError(); void showAMSError();
void clearErrorPopup(); void clearErrorPopup();

View File

@ -58,6 +58,7 @@ public:
void updateBatDelta(); void updateBatDelta();
void updateDetails(); void updateDetails();
void updateProgress();
protected: protected:
BatDelta lastLapDelta; BatDelta lastLapDelta;

View File

@ -5,6 +5,22 @@ ProgressBar::ProgressBar() {}
void ProgressBar::initialize() { ProgressBarBase::initialize(); } void ProgressBar::initialize() { ProgressBarBase::initialize(); }
void ProgressBar::update() {
if (vehicle_state.ts_state == TS_PRECHARGE) {
float progress = 0;
if (vehicle_state.ts_voltage_bat != 0) {
progress =
vehicle_state.ts_voltage_veh / vehicle_state.ts_voltage_bat * 100;
}
setProgress(true, ProgressType::PRECHARGE, progress);
} else if (vehicle_state.r2d_progress > R2D_TSACTIVE &&
vehicle_state.r2d_progress < R2D_INIT_SUCCESS) {
setProgress(true, ProgressType::R2D, vehicle_state.r2d_progress);
} else {
setProgress(false, ProgressType::PRECHARGE, 0);
}
}
void ProgressBar::setProgress(bool active, ProgressType type, float progress) { void ProgressBar::setProgress(bool active, ProgressType type, float progress) {
if (active) { if (active) {
switch (type) { switch (type) {

View File

@ -25,7 +25,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_ts); view.setTSSoC(vehicle_state.soc_ts);
updateProgress(); view.updateProgress();
updateErrorPopup(); updateErrorPopup();
view.updateFieldValues(); view.updateFieldValues();
@ -42,22 +42,6 @@ void DriverViewPresenter::setFieldType(size_t i, DataFieldType type) {
view.setFieldType(i, type); view.setFieldType(i, type);
} }
void DriverViewPresenter::updateProgress() {
if (vehicle_state.ts_state == TS_PRECHARGE) {
float progress = 0;
if (vehicle_state.ts_voltage_bat != 0) {
progress =
vehicle_state.ts_voltage_veh / vehicle_state.ts_voltage_bat * 100;
}
view.setProgress(true, ProgressType::PRECHARGE, progress);
} else if (vehicle_state.r2d_progress > R2D_TSACTIVE &&
vehicle_state.r2d_progress < R2D_INIT_SUCCESS) {
view.setProgress(true, ProgressType::R2D, vehicle_state.r2d_progress);
} else {
view.setProgress(false, ProgressType::PRECHARGE, 0);
}
}
void DriverViewPresenter::updateErrorPopup() { void DriverViewPresenter::updateErrorPopup() {
static uint32_t last_error = 0; static uint32_t last_error = 0;
if (vehicle_state.ts_state == TS_ERROR) { if (vehicle_state.ts_state == TS_ERROR) {

View File

@ -3,7 +3,6 @@
#include "gui/containers/DriverViewStatusItem.hpp" #include "gui/containers/DriverViewStatusItem.hpp"
#include "gui/containers/ProgressBar.hpp" #include "gui/containers/ProgressBar.hpp"
#include "gui/driverview_screen/DriverViewPresenter.hpp" #include "gui/driverview_screen/DriverViewPresenter.hpp"
#include "texts/TextKeysAndLanguages.hpp"
#include "touchgfx/Callback.hpp" #include "touchgfx/Callback.hpp"
#include "touchgfx/Drawable.hpp" #include "touchgfx/Drawable.hpp"
#include "touchgfx/Unicode.hpp" #include "touchgfx/Unicode.hpp"
@ -97,10 +96,7 @@ void DriverViewView::setTSSoC(uint8_t value) {
socLabel.invalidate(); socLabel.invalidate();
} }
void DriverViewView::setProgress(bool active, ProgressType type, void DriverViewView::updateProgress() { progressBar.update(); }
float progress) {
progressBar.setProgress(active, type, progress);
}
void DriverViewView::showAMSError() { void DriverViewView::showAMSError() {
errorPopup.setVisible(true); errorPopup.setVisible(true);

View File

@ -37,6 +37,8 @@ void EnduranceView::updateDetails() {
tbatBuffer.setFloatValue(vehicle_state.max_cell_temp); tbatBuffer.setFloatValue(vehicle_state.max_cell_temp);
} }
void EnduranceView::updateProgress() { progressBar.update(); }
BatDelta::BatDelta(touchgfx::BoxWithBorder &box, BatDelta::BatDelta(touchgfx::BoxWithBorder &box,
touchgfx::TextAreaWithOneWildcard &field) touchgfx::TextAreaWithOneWildcard &field)
: box(box), field(field), value(INT_MIN) {} : box(box), field(field), value(INT_MIN) {}

View File

@ -1848,6 +1848,15 @@
"Wildcard1": {} "Wildcard1": {}
} }
] ]
},
{
"Type": "CustomContainerInstance",
"Name": "progressBar",
"X": 12,
"Y": 15,
"Width": 456,
"Height": 33,
"CustomContainerDefinitionName": "ProgressBar"
} }
], ],
"Interactions": [ "Interactions": [