Added temperature handling and temperature wordmap. Also removed to old versions. Integrated and functional

This commit is contained in:
Matthias Mitscherlich
2024-03-25 15:34:16 +01:00
parent e7dd0ea1f6
commit 39dcb7cf80
7 changed files with 154 additions and 4052 deletions
+90
View File
@@ -0,0 +1,90 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file temperature.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_APPLICATION_INC_TEMPERATURE_H_
#define MAIN_APPLICATION_INC_TEMPERATURE_H_
/**
* temperature implementation
* \defgroup temperature
* \brief {group_description}
* \addtogroup {Layer}
*
* Detailed description
* @{
*/
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
#include <stdint.h>
#include <string>
#include <list>
// ProjectIncludes
// All include files that are provided by the project
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class temperature
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
// Class Constructor
temperature();
void generateWordlist(int temperature, std::list<std::string>* wordlist);
void calculateRGB(int temperature, uint8_t* red, uint8_t* green, uint8_t* blue);
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
int minTemperature;
int maxTemperature;
};
/** @} */
#endif /* MAIN_APPLICATION_INC_TEMPERATURE_H_ */
@@ -0,0 +1,87 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file temperaturewordmap.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_APPLICATION_INC_TEMPERATUREWORDMAP_H_
#define MAIN_APPLICATION_INC_TEMPERATUREWORDMAP_H_
/**
* temperaturewordmap implementation
* \defgroup temperaturewordmap
* \brief {group_description}
* \addtogroup {Layer}
*
* Detailed description
* @{
*/
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
// ProjectIncludes
// All include files that are provided by the project
#include "wordmap.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class temperaturewordmap: public wordmap
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
// Class Constructor
temperaturewordmap(ledmatrix* matrix);
~temperaturewordmap();
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
void createList_NL(void);
void createList_EN(void);
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
};
/** @} */
#endif /* MAIN_APPLICATION_INC_TEMPERATUREWORDMAP_H_ */
+122
View File
@@ -0,0 +1,122 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file temperature.cpp
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include <temperature.h>
#include "logger.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
temperature::temperature()
{
this->minTemperature = 14;
this->maxTemperature = 29;
};
void temperature::generateWordlist(int temperature, std::list<std::string>* wordlist)
{
// Clear the list
wordlist->clear();
// Add fixed preamble
wordlist->push_back("it");
wordlist->push_back("is");
// Temperature value to string
if (temperature < minTemperature)
{
wordlist->push_back("below");
wordlist->push_back(std::to_string(minTemperature));
}
else if (temperature > maxTemperature)
{
wordlist->push_back("above");
wordlist->push_back(std::to_string(maxTemperature));
}
else
{
wordlist->push_back(std::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;
}
@@ -0,0 +1,98 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file temperaturewordmap.cpp
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include <temperaturewordmap.h>
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
temperaturewordmap::temperaturewordmap(ledmatrix* matrix) : wordmap(matrix)
{
createList_NL();
createList_EN();
}
temperaturewordmap::~temperaturewordmap()
{
}
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,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}}});
// 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,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,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}}});
wordlist[NL].push_back((struct word){"degrees", {{14,9},{15,9},{16,9},{17,9},{18,9},{19,9}}});
}
void temperaturewordmap::createList_EN(void)
{
}