Display inverter & motor temperatures

This commit is contained in:
2023-05-05 14:50:10 +02:00
parent 24be6312c8
commit a097d2b3aa
26 changed files with 431 additions and 212 deletions

View File

@ -1,12 +1,17 @@
#include <gui/containers/Temperature.hpp>
#include <cstring>
#include "touchgfx/Color.hpp"
#include "touchgfx/Unicode.hpp"
#include <gui/containers/TireTemp.hpp>
TireTemp::TireTemp() : temp{0} { updateValueBuffer(); }
Temperature::Temperature() : temp{0}, tempThresholds{0, 0, 0, 0} {
updateValueBuffer();
}
void TireTemp::initialize() { TireTempBase::initialize(); }
void Temperature::initialize() { TemperatureBase::initialize(); }
void TireTemp::setTemp(int temp_in_celsius) {
void Temperature::setTemp(int temp_in_celsius) {
if (temp_in_celsius < 0) {
// No space for displaying negative values
temp_in_celsius = 0;
@ -18,13 +23,13 @@ void TireTemp::setTemp(int temp_in_celsius) {
temp = temp_in_celsius;
updateValueBuffer();
if (temp < 35) {
if (temp < tempThresholds[0]) {
bg.setColor(touchgfx::Color::getColorFromRGB(0x05, 0x76, 0xb7));
} else if (temp < 40) {
} else if (temp < tempThresholds[1]) {
bg.setColor(touchgfx::Color::getColorFromRGB(0x05, 0x76, 0x64));
} else if (temp < 50) {
} else if (temp < tempThresholds[2]) {
bg.setColor(touchgfx::Color::getColorFromRGB(0x05, 0x95, 0x38));
} else if (temp < 60) {
} else if (temp < tempThresholds[3]) {
bg.setColor(touchgfx::Color::getColorFromRGB(0xdd, 0x6e, 0x22));
} else {
bg.setColor(touchgfx::Color::getColorFromRGB(0xdd, 0x2f, 0x22));
@ -33,7 +38,11 @@ void TireTemp::setTemp(int temp_in_celsius) {
bg.invalidate(); // TODO: Only invalidate if color changed
}
void TireTemp::updateValueBuffer() {
void Temperature::setTempThresholds(int *thresholds) {
memcpy(tempThresholds, thresholds, sizeof(tempThresholds));
}
void Temperature::updateValueBuffer() {
// Unicode::utoa(temp, valueBuffer, 3, 10);
Unicode::snprintf(valueBuffer,
sizeof(valueBuffer) / sizeof(Unicode::UnicodeChar), "%02d",