Display inverter & motor temperatures
This commit is contained in:
@ -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",
|
||||
Reference in New Issue
Block a user