Driver wishlist
This commit is contained in:
@ -60,6 +60,11 @@ public:
|
||||
void updateDetails();
|
||||
void updateProgress();
|
||||
|
||||
void decreasePowerLimit() override;
|
||||
void increasePowerLimit() override;
|
||||
void decreaseSpeedLimit() override;
|
||||
void increaseSpeedLimit() override;
|
||||
|
||||
protected:
|
||||
BatDelta lastLapDelta;
|
||||
BatDelta overallDelta;
|
||||
@ -67,6 +72,8 @@ protected:
|
||||
ValueBuffer slimBuffer;
|
||||
ValueBuffer socBuffer;
|
||||
ValueBuffer tbatBuffer;
|
||||
|
||||
bool limitsChangable();
|
||||
};
|
||||
|
||||
#endif // ENDURANCEVIEW_HPP
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "main.h"
|
||||
#include "touchgfx/Color.hpp"
|
||||
#include "touchgfx/Unicode.hpp"
|
||||
#include "vehicle_state.h"
|
||||
@ -5,6 +6,10 @@
|
||||
#include <cmath>
|
||||
#include <gui/endurance_screen/EnduranceView.hpp>
|
||||
|
||||
#ifndef SIMULATOR
|
||||
#include "stm32h7xx_hal_gpio.h"
|
||||
#endif
|
||||
|
||||
EnduranceView::EnduranceView()
|
||||
: lastLapDelta(lastLapBox, lastLapBat),
|
||||
overallDelta(overallBox, overallBat), plimBuffer(powerLimit, 2, 0),
|
||||
@ -39,6 +44,54 @@ void EnduranceView::updateDetails() {
|
||||
|
||||
void EnduranceView::updateProgress() { progressBar.update(); }
|
||||
|
||||
void EnduranceView::decreasePowerLimit() {
|
||||
if (!limitsChangable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (wishlist.power_limit > 15) {
|
||||
wishlist.power_limit--;
|
||||
}
|
||||
}
|
||||
|
||||
void EnduranceView::increasePowerLimit() {
|
||||
if (!limitsChangable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (wishlist.power_limit < 40) {
|
||||
wishlist.power_limit++;
|
||||
}
|
||||
}
|
||||
|
||||
void EnduranceView::decreaseSpeedLimit() {
|
||||
if (!limitsChangable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (wishlist.speed_limit > 40) {
|
||||
wishlist.speed_limit--;
|
||||
}
|
||||
}
|
||||
|
||||
void EnduranceView::increaseSpeedLimit() {
|
||||
if (!limitsChangable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (wishlist.speed_limit < 100) {
|
||||
wishlist.speed_limit++;
|
||||
}
|
||||
}
|
||||
|
||||
bool EnduranceView::limitsChangable() {
|
||||
#ifdef SIMULATOR
|
||||
return true;
|
||||
#else
|
||||
return HAL_GPIO_ReadPin(BTN3_GPIO_Port, BTN3_Pin) == GPIO_PIN_SET;
|
||||
#endif
|
||||
}
|
||||
|
||||
BatDelta::BatDelta(touchgfx::BoxWithBorder &box,
|
||||
touchgfx::TextAreaWithOneWildcard &field)
|
||||
: box(box), field(field), value(INT_MIN) {}
|
||||
|
||||
Reference in New Issue
Block a user