Added temperature handling and temperature wordmap. Also removed to old versions. Integrated and functional
This commit is contained in:
@@ -1,80 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// \file temperature.h
|
||||
/// \brief File description
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// vbchaos software design
|
||||
//
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// $Revision: $
|
||||
/// $Author: $
|
||||
/// $Date: $
|
||||
// (c) 2023 vbchaos
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef MAIN_INC_TEMPERATURE_H_
|
||||
#define MAIN_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 <string>
|
||||
#include <list>
|
||||
|
||||
|
||||
|
||||
// ProjectIncludes
|
||||
// All include files that are provided by the project
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Temperature
|
||||
{
|
||||
public:
|
||||
Temperature(void);
|
||||
|
||||
void generateWordlist(int temperature, list<string>* wordlist);
|
||||
|
||||
void calculateRGB(int temperature, uint8_t* red, uint8_t* green, uint8_t* blue);
|
||||
|
||||
private:
|
||||
int minTemperature;
|
||||
int maxTemperature;
|
||||
};
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* MAIN_INC_TEMPERATURE_H_ */
|
||||
@@ -1,73 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// \file TemperatureWordmap.h
|
||||
/// \brief File description
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// vbchaos software design
|
||||
//
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// $Revision: $
|
||||
/// $Author: $
|
||||
/// $Date: $
|
||||
// (c) 2023 vbchaos
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef MAIN_INC_TEMPERATUREWORDMAP_H_
|
||||
#define MAIN_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:
|
||||
TemperatureWordmap(LEDMatrix* matrix);
|
||||
|
||||
protected:
|
||||
void createList_NL(void);
|
||||
// void createList_EN(void);
|
||||
};
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* MAIN_INC_TEMPERATUREWORDMAP_H_ */
|
||||
@@ -1,123 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// \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()
|
||||
{
|
||||
Temperature::minTemperature = 14;
|
||||
Temperature::maxTemperature = 29;
|
||||
};
|
||||
|
||||
|
||||
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
|
||||
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;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// \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,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}}});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user