Add progress bar to endurance view
This commit is contained in:
parent
cb2f55be1b
commit
f0db650c30
|
@ -12,6 +12,7 @@
|
|||
#include <touchgfx/widgets/BoxWithBorder.hpp>
|
||||
#include <touchgfx/widgets/TextArea.hpp>
|
||||
#include <touchgfx/widgets/TextAreaWithWildcard.hpp>
|
||||
#include <gui/containers/ProgressBar.hpp>
|
||||
|
||||
class EnduranceViewBase : public touchgfx::View<EndurancePresenter>
|
||||
{
|
||||
|
@ -69,6 +70,7 @@ protected:
|
|||
touchgfx::BoxWithBorder lastLapBox;
|
||||
touchgfx::TextArea textArea1;
|
||||
touchgfx::TextAreaWithOneWildcard lastLapBat;
|
||||
ProgressBar progressBar;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -115,6 +115,9 @@ EnduranceViewBase::EnduranceViewBase()
|
|||
lastLapContainer.add(lastLapBat);
|
||||
|
||||
add(lastLapContainer);
|
||||
|
||||
progressBar.setXY(12, 15);
|
||||
add(progressBar);
|
||||
}
|
||||
|
||||
EnduranceViewBase::~EnduranceViewBase()
|
||||
|
@ -124,7 +127,7 @@ EnduranceViewBase::~EnduranceViewBase()
|
|||
|
||||
void EnduranceViewBase::setupScreen()
|
||||
{
|
||||
|
||||
progressBar.initialize();
|
||||
}
|
||||
|
||||
void EnduranceViewBase::handleKeyEvent(uint8_t key)
|
||||
|
|
|
@ -12,12 +12,14 @@ public:
|
|||
|
||||
virtual void initialize();
|
||||
|
||||
void setProgress(bool active, ProgressType type, float progress);
|
||||
void update();
|
||||
|
||||
protected:
|
||||
private:
|
||||
touchgfx::Unicode::UnicodeChar r2dProgBuffer[16];
|
||||
touchgfx::Unicode::UnicodeChar socBuffer[4];
|
||||
|
||||
void setProgress(bool active, ProgressType type, float progress);
|
||||
};
|
||||
|
||||
#endif // PROGRESSBAR_HPP
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include "gui/common/NamedField.hpp"
|
||||
#include "gui/containers/DriverViewFieldSelection.hpp"
|
||||
#include "gui/containers/ProgressBar.hpp"
|
||||
#include <gui/driverview_screen/DriverViewPresenter.hpp>
|
||||
#include <gui_generated/driverview_screen/DriverViewViewBase.hpp>
|
||||
|
||||
|
@ -25,7 +24,7 @@ public:
|
|||
|
||||
void setTemps(const Temperatures &temps);
|
||||
void setTSSoC(uint8_t soc);
|
||||
void setProgress(bool active, ProgressType type, float progress);
|
||||
void updateProgress();
|
||||
|
||||
void showAMSError();
|
||||
void clearErrorPopup();
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
|
||||
void updateBatDelta();
|
||||
void updateDetails();
|
||||
void updateProgress();
|
||||
|
||||
protected:
|
||||
BatDelta lastLapDelta;
|
||||
|
|
|
@ -5,6 +5,22 @@ ProgressBar::ProgressBar() {}
|
|||
|
||||
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) {
|
||||
if (active) {
|
||||
switch (type) {
|
||||
|
|
|
@ -25,7 +25,7 @@ void DriverViewPresenter::deactivate() {}
|
|||
void DriverViewPresenter::vehicleStateUpdated() {
|
||||
view.setTemps(vehicle_state.temps);
|
||||
view.setTSSoC(vehicle_state.soc_ts);
|
||||
updateProgress();
|
||||
view.updateProgress();
|
||||
updateErrorPopup();
|
||||
|
||||
view.updateFieldValues();
|
||||
|
@ -42,22 +42,6 @@ void DriverViewPresenter::setFieldType(size_t i, DataFieldType 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() {
|
||||
static uint32_t last_error = 0;
|
||||
if (vehicle_state.ts_state == TS_ERROR) {
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include "gui/containers/DriverViewStatusItem.hpp"
|
||||
#include "gui/containers/ProgressBar.hpp"
|
||||
#include "gui/driverview_screen/DriverViewPresenter.hpp"
|
||||
#include "texts/TextKeysAndLanguages.hpp"
|
||||
#include "touchgfx/Callback.hpp"
|
||||
#include "touchgfx/Drawable.hpp"
|
||||
#include "touchgfx/Unicode.hpp"
|
||||
|
@ -97,10 +96,7 @@ void DriverViewView::setTSSoC(uint8_t value) {
|
|||
socLabel.invalidate();
|
||||
}
|
||||
|
||||
void DriverViewView::setProgress(bool active, ProgressType type,
|
||||
float progress) {
|
||||
progressBar.setProgress(active, type, progress);
|
||||
}
|
||||
void DriverViewView::updateProgress() { progressBar.update(); }
|
||||
|
||||
void DriverViewView::showAMSError() {
|
||||
errorPopup.setVisible(true);
|
||||
|
|
|
@ -37,6 +37,8 @@ void EnduranceView::updateDetails() {
|
|||
tbatBuffer.setFloatValue(vehicle_state.max_cell_temp);
|
||||
}
|
||||
|
||||
void EnduranceView::updateProgress() { progressBar.update(); }
|
||||
|
||||
BatDelta::BatDelta(touchgfx::BoxWithBorder &box,
|
||||
touchgfx::TextAreaWithOneWildcard &field)
|
||||
: box(box), field(field), value(INT_MIN) {}
|
||||
|
|
|
@ -1848,6 +1848,15 @@
|
|||
"Wildcard1": {}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Type": "CustomContainerInstance",
|
||||
"Name": "progressBar",
|
||||
"X": 12,
|
||||
"Y": 15,
|
||||
"Width": 456,
|
||||
"Height": 33,
|
||||
"CustomContainerDefinitionName": "ProgressBar"
|
||||
}
|
||||
],
|
||||
"Interactions": [
|
||||
|
|
Loading…
Reference in New Issue