Updated the matrix to the real size

Fixed orientation missings
added the temperature wordmap
This commit is contained in:
Matthias Mitscherlich
2023-11-25 15:24:51 +01:00
parent edeaedeb07
commit 7c2b0d8d24
17 changed files with 723 additions and 48 deletions
+20
View File
@@ -114,6 +114,16 @@ bool BMP280::setSensorTemperatureOversampling(BMP280_Oversampling_t oversampling
return returnValue;
}
int BMP280::getTemperature(void)
{
// Get latest raw values from device
BMP280::getTemperatureValues();
// Calculate temperature
BMP280::compensateTemperature();
// return the value
return temperature;
}
void BMP280::resetDriver(void)
{
@@ -150,6 +160,16 @@ void BMP280::getCompensationValues(void)
LOGGER_DEBUG("Got compensation values: %04X %04X %04X", compensationParameters.dig_T1, compensationParameters.dig_T2, compensationParameters.dig_T3);
}
void BMP280::getPreasureValues(void)
{
bus->read_register(slaveAddress, ADDRESS_REG_PRESSURE_LSB, (uint8_t*)&memorymap.pressure_raw, sizeof(memorymap.pressure_raw));
}
void BMP280::getTemperatureValues(void)
{
bus->read_register(slaveAddress, ADDRESS_REG_TEMPERATURE_MSB, (uint8_t*)&memorymap.temperature_raw, sizeof(memorymap.temperature_raw));
}
void BMP280::compensateTemperature(void)
{
int adc_T = 0;
+30 -2
View File
@@ -74,8 +74,8 @@ void Clock::generateWordlist(list<string>* wordlist)
// currentTime += 100;
localtime_r(&currentTime, &tm);
LOGGER_INFO("%lld\n\r", currentTime);
LOGGER_INFO("%02i:%02i:%02i\n\r", tm.tm_hour, tm.tm_min, tm.tm_sec);
// LOGGER_INFO("%lld\n\r", currentTime);
// LOGGER_INFO("%02i:%02i:%02i\n\r", tm.tm_hour, tm.tm_min, tm.tm_sec);
wordlist->clear();
wordlist->push_back("it");
@@ -154,6 +154,34 @@ void Clock::generateWordlist(list<string>* wordlist)
wordlist->push_back("almost");
wordlist->push_back("hours");
}
// Attach the day as a word, too
switch (tm.tm_wday)
{
case 0:
wordlist->push_back("sunday");
break;
case 1:
wordlist->push_back("monday");
break;
case 2:
wordlist->push_back("tuesday");
break;
case 3:
wordlist->push_back("wednesday");
break;
case 4:
wordlist->push_back("thursday");
break;
case 5:
wordlist->push_back("friday");
break;
case 6:
wordlist->push_back("saturday");
break;
default:
wordlist->push_back("sunday");
}
}
+1 -1
View File
@@ -89,7 +89,7 @@ void ClockWordmap::createList_NL(void)
wordlist[NL].push_back((struct word){"eleven", {{8,8},{9,8},{10,8}}});
wordlist[NL].push_back((struct word){"twelve", {{0,9},{1,9},{2,9},{3,9},{4,9},{5,9}}});
wordlist[NL].push_back((struct word){"hours", {{7,9},{8,9},{9,9}}});
wordlist[NL].push_back((struct word){"hours", {{8,9},{9,9},{10,9}}});
}
+76
View File
@@ -0,0 +1,76 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file daywordmap.cpp
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include "daywordmap.h"
#include "logger.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
DayWordmap::DayWordmap(LEDMatrix* matrix) : Wordmap(matrix)
{
createList_NL();
createList_EN();
}
void DayWordmap::createList_NL(void)
{
// First, clear the list
wordlist[NL].clear();
// Now lets add all relevant words
wordlist[NL].push_back((struct word){"monday", {{0,12},{1,12},{2,12},{3,12},{4,12},{5,12},{6,12}}});
wordlist[NL].push_back((struct word){"tuesday", {{13,12},{14,12},{15,12},{16,12},{17,12},{18,12},{19,12}}});
wordlist[NL].push_back((struct word){"wednesday", {{11,10},{12,10},{13,10},{14,10},{15,10},{16,10},{17,10},{18,10}}});
wordlist[NL].push_back((struct word){"thursday", {{2,11},{3,11},{4,11},{5,11},{6,11},{7,11},{8,11},{9,11},{10,11}}});
wordlist[NL].push_back((struct word){"friday", {{12,11},{13,11},{14,11},{15,11},{16,11},{17,11},{18,11}}});
wordlist[NL].push_back((struct word){"saturday", {{0,10},{1,10},{2,10},{3,10},{4,10},{5,10},{6,10},{7,10}}});
wordlist[NL].push_back((struct word){"sunday", {{7,12},{8,12},{9,12},{10,12},{11,12},{12,12}}});
}
+104 -29
View File
@@ -79,8 +79,8 @@ bool LEDMatrix::setPixelValue(unsigned int colum, unsigned int row, bool value)
{
bool returnValue = true;
unsigned int rowC = 0;
unsigned int colC = 0;
// unsigned int rowC = 0;
// unsigned int colC = 0;
unsigned int pixelAddress = 0;
if ((row < parameters.height) && (colum < parameters.width))
@@ -95,6 +95,101 @@ bool LEDMatrix::setPixelValue(unsigned int colum, unsigned int row, bool value)
if (returnValue)
{
// // Determine the actual row coordinate based on the matrix orientation
// if (parameters.columOrientation == LEDMATRIX_ORIENTATION_COLUM_UP_DOWN)
// {
// rowC = row;
// }
// else if (parameters.columOrientation == LEDMATRIX_ORIENTATION_COLUM_DOWN_UP)
// {
// rowC = (parameters.height - 1) - row;
// }
//
// // Determine the actual row coordinate based on the matrix orientation
// if (parameters.rowOrientation == LEDMATRIX_ORIENTATION_ROW_LEFT_RIGHT)
// {
// colC = colum;
// }
// else if (parameters.rowOrientation == LEDMATRIX_ORIENTATION_ROW_RIGHT_LEFT)
// {
// colC = (parameters.width - 1) - colum;
// }
//
// // Calculate the pixel address in the pixel array based on the previous information
// if (parameters.matrixOrientation == LEDMATRIX_ORIENTATION_COLUM)
// {
// pixelAddress = rowC + (colC * parameters.height);
// }
// else if (parameters.matrixOrientation == LEDMATRIX_ORIENTATION_ROW)
// {
// pixelAddress = (rowC * parameters.width) + colC;
// }
pixelAddress = LEDMatrix::findPixelIndexFromCoordinates(colum, row);
// Update the pixel value
matrix[pixelAddress].on = value;
}
return returnValue;
}
void LEDMatrix::setGlobalColour(uint8_t red, uint8_t green, uint8_t blue)
{
for (int i = 0; i < numberOfPixels; i++)
{
matrix[i].red = red;
matrix[i].green = green;
matrix[i].blue = blue;
}
}
void LEDMatrix::setPixelColour(unsigned int colum, unsigned int row, uint8_t red, uint8_t green, uint8_t blue)
{
unsigned int index;
index = LEDMatrix::findPixelIndexFromCoordinates(colum, row);
matrix[index].red = red;
matrix[index].green = green;
matrix[index].blue = blue;
}
void LEDMatrix::clear(void)
{
for (int i = 0; i < numberOfPixels; i++)
{
matrix[i].on = false;
}
}
unsigned int LEDMatrix::findPixelIndexFromCoordinates(unsigned int colum, unsigned int row)
{
bool returnValue = true;
unsigned int index = 0;
unsigned int rowC = 0;
unsigned int colC = 0;
if ((row < parameters.height) && (colum < parameters.width))
{
returnValue = true;
}
else
{
returnValue = false;
}
if (returnValue)
{
// Determine the actual row coordinate based on the matrix orientation
if (parameters.columOrientation == LEDMATRIX_ORIENTATION_COLUM_UP_DOWN)
{
@@ -118,35 +213,14 @@ bool LEDMatrix::setPixelValue(unsigned int colum, unsigned int row, bool value)
// Calculate the pixel address in the pixel array based on the previous information
if (parameters.matrixOrientation == LEDMATRIX_ORIENTATION_COLUM)
{
pixelAddress = rowC + (colC * parameters.height);
index = rowC + (colC * parameters.height);
}
else if (parameters.matrixOrientation == LEDMATRIX_ORIENTATION_ROW)
{
index = (rowC * parameters.width) + colC;
}
// Update the pixel value
matrix[pixelAddress].on = value;
}
return returnValue;
}
void LEDMatrix::setGlobalColour(uint8_t red, uint8_t green, uint8_t blue)
{
for (int i = 0; i < numberOfPixels; i++)
{
matrix[i].red = red;
matrix[i].green = green;
matrix[i].blue = blue;
}
}
void LEDMatrix::clear(void)
{
for (int i = 0; i < numberOfPixels; i++)
{
matrix[i].on = false;
}
return index;
}
@@ -178,6 +252,7 @@ void LEDMatrix::matrixTask(void* parameters)
}
rmt_transmit(*ledmatrix->parameters.rmtChannel, *ledmatrix->parameters.rmtEncoder, matrix, sizeof(matrix), ledmatrix->parameters.rmtConfig);
}
}
+76
View File
@@ -0,0 +1,76 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file temperature.cpp
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include "temperature.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
Temperature::Temperature()
{
};
void Temperature::generateWordlist(int temperature, list<string>* wordlist)
{
// Clear the list
wordlist->clear();
// Add fixed preamble
wordlist->push_back("it");
wordlist->push_back("is");
// Temperature value to string
wordlist->push_back(to_string(temperature));
// Add fixed postamble
wordlist->push_back("degrees");
}
+95
View File
@@ -0,0 +1,95 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file temperaturewordmap.cpp
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include "temperaturewordmap.h"
#include "logger.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
TemperatureWordmap::TemperatureWordmap(LEDMatrix* matrix) : Wordmap(matrix)
{
createList_NL();
createList_EN();
}
void TemperatureWordmap::createList_NL(void)
{
// First, clear the list
wordlist[NL].clear();
// Now lets add all relevant words
wordlist[NL].push_back((struct word){"it", {{14,0},{15,0},{16,0}}});
wordlist[NL].push_back((struct word){"is", {{18,0},{19,0}}});
wordlist[NL].push_back((struct word){"above", {{11,1},{12,1},{13,1},{14,1},{15,1},{18,2},{19,2}}});
wordlist[NL].push_back((struct word){"below", {{12,2},{13,2},{14,2},{15,2},{16,2},{18,2},{19,2}}});
// Tenth
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){"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}}});
// Twentieth
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){"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){"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}}});
wordlist[NL].push_back((struct word){"degrees", {{14,9},{15,9},{16,9},{17,9},{18,9},{19,9}}});
}
+17
View File
@@ -52,6 +52,9 @@ Wordmap::Wordmap(LEDMatrix* matrix)
{
Wordmap::matrix = matrix;
Wordmap::language = NL;
Wordmap::red = 0xFF;
Wordmap::green = 0xFF;
Wordmap::blue = 0xFF;
}
bool Wordmap::setWord(Language_t lang, string identifier, bool value)
@@ -91,12 +94,26 @@ bool Wordmap::setWord(Language_t lang, string identifier, bool value)
for (pixel = it->pixels.begin(); pixel != it->pixels.end(); pixel++)
{
matrix->setPixelValue(pixel->x, pixel->y, value);
matrix->setPixelColour(pixel->x, pixel->y, Wordmap::red, Wordmap::green, Wordmap::blue);
}
}
return returnValue;
}
bool Wordmap::setColour(uint8_t red, uint8_t green, uint8_t blue)
{
bool returnValue = true;
Wordmap::red = red;
Wordmap::green = green;
Wordmap::blue = blue;
return returnValue;
}
void Wordmap::createList_NL(void)
{
// First, clear the list