fixed colour maps and some matrix misalignments# Please enter the commit message for your changes. Lines starting

This commit is contained in:
Matthias Mitscherlich
2023-11-26 09:22:16 +01:00
parent d990b0563d
commit 29e2e14850
9 changed files with 1213 additions and 938 deletions
+9 -4
View File
@@ -101,16 +101,16 @@ bool BMP280::initialize(void)
bool BMP280::setSensorMode(BMP280_Mode_t mode)
{
bool returnValue = true;
memorymap.config.mode = mode;
setSensorConfiguration();
memorymap.ctrl_meas.mode = mode;
setSensorControlMeasurement();
return returnValue;
}
bool BMP280::setSensorTemperatureOversampling(BMP280_Oversampling_t oversampling)
{
bool returnValue = true;
memorymap.config.oversampling_temp = oversampling;
setSensorConfiguration();
memorymap.ctrl_meas.oversampling_temp = oversampling;
setSensorControlMeasurement();
return returnValue;
}
@@ -149,6 +149,11 @@ void BMP280::resetDevice(void)
bus->write_register(slaveAddress, ADDRESS_REG_RESET, &resetValue, 1);
}
void BMP280::setSensorControlMeasurement(void)
{
bus->write_register(slaveAddress, ADDRESS_REG_CTRL_MEAS, (uint8_t*)&memorymap.ctrl_meas, 1);
}
void BMP280::setSensorConfiguration(void)
{
bus->write_register(slaveAddress, ADDRESS_REG_CONFIG, (uint8_t*)&memorymap.config, 1);
+51 -4
View File
@@ -19,6 +19,8 @@
#include "temperature.h"
#include "logger.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
@@ -49,7 +51,8 @@
Temperature::Temperature()
{
Temperature::minTemperature = 14;
Temperature::maxTemperature = 29;
};
@@ -63,14 +66,58 @@ void Temperature::generateWordlist(int temperature, list<string>* wordlist)
wordlist->push_back("is");
// Temperature value to string
wordlist->push_back(to_string(temperature));
if (temperature < minTemperature)
{
wordlist->push_back("below");
wordlist->push_back(to_string(minTemperature));
}
else if (temperature > maxTemperature)
{
wordlist->push_back("above");
wordlist->push_back(to_string(maxTemperature));
}
else
{
wordlist->push_back(to_string(temperature));
}
// Add fixed postamble
wordlist->push_back("degrees");
}
void Temperature::calculateRGB(int temperature, uint8_t* red, uint8_t* green, uint8_t* blue)
{
int calcBlue = 0;
int calcRed = 0;
int factor = 100 / (maxTemperature - minTemperature);
LOGGER_INFO("Incoming Temperature is: %i (min: %i, max: %i", temperature, minTemperature, maxTemperature);
if (temperature < minTemperature)
{
calcBlue = 0xFF;
calcRed = 0x00;
}
else if (temperature > maxTemperature)
{
calcBlue = 0x00;
calcRed = 0xFF;
}
else
{
calcBlue = (((maxTemperature - temperature) * factor) * 0xFF) / 100;
calcRed = (((temperature - minTemperature) * factor) * 0xFF) / 100;
}
LOGGER_PRINT("\n\rRed %i %x (%i)", calcRed, calcRed, (temperature - minTemperature) * factor);
LOGGER_PRINT("\n\rGreen %i %x", 0, 0);
LOGGER_PRINT("\n\rBlue %i %x (%i)", calcBlue, calcBlue, (maxTemperature - temperature) * factor);
*red = calcRed & 0xFF;
*green = 0x00;
*blue = calcBlue & 0xFF;
}
+4 -3
View File
@@ -71,7 +71,7 @@ void TemperatureWordmap::createList_NL(void)
wordlist[NL].push_back((struct word){"14", {{11,4},{12,4},{13,4},{14,4},{16,7},{17,7},{18,7},{19,7}}});
wordlist[NL].push_back((struct word){"15", {{15,4},{16,4},{17,4},{18,4},{16,7},{17,7},{18,7},{19,7}}});
wordlist[NL].push_back((struct word){"16", {{11,5},{12,5},{13,5},{16,7},{17,7},{18,7},{19,7}}});
wordlist[NL].push_back((struct word){"17", {{14,4},{15,4},{16,4},{17,4},{18,4},{16,7},{17,7},{18,7},{19,7}}});
wordlist[NL].push_back((struct word){"17", {{14,5},{15,5},{16,5},{17,5},{18,5},{16,7},{17,7},{18,7},{19,7}}});
wordlist[NL].push_back((struct word){"18", {{11,6},{12,6},{13,6},{14,6},{16,7},{17,7},{18,7},{19,7}}});
wordlist[NL].push_back((struct word){"19", {{15,6},{16,6},{17,6},{18,6},{19,6},{16,7},{17,7},{18,7},{19,7}}});
@@ -79,11 +79,11 @@ void TemperatureWordmap::createList_NL(void)
wordlist[NL].push_back((struct word){"20", {{11,8},{12,8},{13,8},{14,8},{15,8},{16,8},{17,8}}});
wordlist[NL].push_back((struct word){"21", {{13,3},{14,3},{15,3},{12,7},{13,7},{11,8},{12,8},{13,8},{14,8},{15,8},{16,8},{17,8}}});
wordlist[NL].push_back((struct word){"22", {{11,3},{12,3},{13,3},{14,3},{12,7},{13,7},{11,8},{12,8},{13,8},{14,8},{15,8},{16,8},{17,8}}});
wordlist[NL].push_back((struct word){"23", {{16,3},{17,3},{18,3},{19,7},{13,7},{11,8},{12,8},{13,8},{14,8},{15,8},{16,8},{17,8}}});
wordlist[NL].push_back((struct word){"23", {{16,3},{17,3},{18,3},{19,3},{12,7},{13,7},{11,8},{12,8},{13,8},{14,8},{15,8},{16,8},{17,8}}});
wordlist[NL].push_back((struct word){"24", {{11,4},{12,4},{13,4},{14,4},{12,7},{13,7},{11,8},{12,8},{13,8},{14,8},{15,8},{16,8},{17,8}}});
wordlist[NL].push_back((struct word){"25", {{15,4},{16,4},{17,4},{18,4},{12,7},{13,7},{11,8},{12,8},{13,8},{14,8},{15,8},{16,8},{17,8}}});
wordlist[NL].push_back((struct word){"26", {{11,5},{12,5},{13,5},{12,7},{13,7},{11,8},{12,8},{13,8},{14,8},{15,8},{16,8},{17,8}}});
wordlist[NL].push_back((struct word){"27", {{14,4},{15,4},{16,4},{17,4},{18,4},{12,7},{13,7},{11,8},{12,8},{13,8},{14,8},{15,8},{16,8},{17,8}}});
wordlist[NL].push_back((struct word){"27", {{14,5},{15,5},{16,5},{17,5},{18,5},{12,7},{13,7},{11,8},{12,8},{13,8},{14,8},{15,8},{16,8},{17,8}}});
wordlist[NL].push_back((struct word){"28", {{11,6},{12,6},{13,6},{14,6},{12,7},{13,7},{11,8},{12,8},{13,8},{14,8},{15,8},{16,8},{17,8}}});
wordlist[NL].push_back((struct word){"29", {{15,6},{16,6},{17,6},{18,6},{19,6},{12,7},{13,7},{11,8},{12,8},{13,8},{14,8},{15,8},{16,8},{17,8}}});
@@ -93,3 +93,4 @@ void TemperatureWordmap::createList_NL(void)