added clock wordmap and made wordmap a baseclass

This commit is contained in:
Matthias Mitscherlich
2023-02-07 13:38:23 +01:00
parent 2e8aa31cbf
commit 35c940ca5b
7 changed files with 206 additions and 70 deletions
+1
View File
@@ -13,6 +13,7 @@ idf_component_register(
"src/ledmatrix.cpp"
"src/clock.cpp"
"src/wordmap.cpp"
"src/clockwordmap.cpp"
INCLUDE_DIRS # optional, add here public include directories
"inc"
PRIV_INCLUDE_DIRS # optional, add here private include directories
+72
View File
@@ -0,0 +1,72 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file clockwordmap.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_INC_CLOCKWORDMAP_H_
#define MAIN_INC_CLOCKWORDMAP_H_
/**
* clockwordmap implementation
* \defgroup clockwordmap
* \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 ClockWordmap: public Wordmap
{
public:
ClockWordmap(LEDMatrix* matrix);
protected:
void createList_NL(void);
// void createList_EN(void);
};
/** @} */
#endif /* MAIN_INC_CLOCKWORDMAP_H_ */
+4 -4
View File
@@ -75,14 +75,14 @@ class Wordmap
bool setWord(Language_t lang, string identifier, bool value);
private:
protected:
struct word
{
string identifier;
// list<LEDMatrix::coordinate> pixels;
LEDMatrix::coordinate position;
int length;
list<LEDMatrix::coordinate> pixels;
// LEDMatrix::coordinate position;
// int length;
};
LEDMatrix* matrix;
+26 -26
View File
@@ -42,7 +42,7 @@
#include "inc/wifi.h"
#include "clock.h"
#include "wordmap.h"
#include "clockwordmap.h"
// --------------------------------------------------------------------------------------------------------------------
@@ -80,9 +80,9 @@ static rmt_encoder_handle_t led_encoder = NULL;
static LEDMatrix_Parameters_t ledmatrix_parameters =
{
LEDMATRIX_ORIENTATION_ROW_LEFT_RIGHT,
LEDMATRIX_ORIENTATION_COLUM_DOWN_UP,
LEDMATRIX_ORIENTATION_ROW,
LEDMATRIX_ORIENTATION_ROW_RIGHT_LEFT,
LEDMATRIX_ORIENTATION_COLUM_UP_DOWN,
LEDMATRIX_ORIENTATION_COLUM,
11,
10,
&led_chan,
@@ -92,7 +92,7 @@ static LEDMatrix_Parameters_t ledmatrix_parameters =
static LEDMatrix matrix(&ledmatrix_parameters);
static Wordmap map(&matrix);
static ClockWordmap clockWordmap(&matrix);
static gptimer_handle_t matrixRefreshTimer = NULL;
@@ -279,7 +279,7 @@ extern "C" void app_main(void)
std::list<string>::iterator it;
for(it = wordlist.begin(); it != wordlist.end(); it++)
{
map.setWord(Wordmap::Language_t::NL, *it, true);
clockWordmap.setWord(Wordmap::Language_t::NL, *it, true);
}
// Add a seconds indicator
@@ -341,36 +341,36 @@ static void colourMapTask(void* parameters)
static void countdown(int delay)
{
map.setWord(Wordmap::Language_t::NL, "ten", true);
clockWordmap.setWord(Wordmap::Language_t::NL, "ten", true);
vTaskDelay(delay);
map.setWord(Wordmap::Language_t::NL, "ten", false);
map.setWord(Wordmap::Language_t::NL, "nine", true);
clockWordmap.setWord(Wordmap::Language_t::NL, "ten", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "nine", true);
vTaskDelay(delay);
map.setWord(Wordmap::Language_t::NL, "nine", false);
map.setWord(Wordmap::Language_t::NL, "eight", true);
clockWordmap.setWord(Wordmap::Language_t::NL, "nine", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "eight", true);
vTaskDelay(delay);
map.setWord(Wordmap::Language_t::NL, "eight", false);
map.setWord(Wordmap::Language_t::NL, "seven", true);
clockWordmap.setWord(Wordmap::Language_t::NL, "eight", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "seven", true);
vTaskDelay(delay);
map.setWord(Wordmap::Language_t::NL, "seven", false);
map.setWord(Wordmap::Language_t::NL, "six", true);
clockWordmap.setWord(Wordmap::Language_t::NL, "seven", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "six", true);
vTaskDelay(delay);
map.setWord(Wordmap::Language_t::NL, "six", false);
map.setWord(Wordmap::Language_t::NL, "five", true);
clockWordmap.setWord(Wordmap::Language_t::NL, "six", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "five", true);
vTaskDelay(delay);
map.setWord(Wordmap::Language_t::NL, "five", false);
map.setWord(Wordmap::Language_t::NL, "four", true);
clockWordmap.setWord(Wordmap::Language_t::NL, "five", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "four", true);
vTaskDelay(delay);
map.setWord(Wordmap::Language_t::NL, "four", false);
map.setWord(Wordmap::Language_t::NL, "three", true);
clockWordmap.setWord(Wordmap::Language_t::NL, "four", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "three", true);
vTaskDelay(delay);
map.setWord(Wordmap::Language_t::NL, "three", false);
map.setWord(Wordmap::Language_t::NL, "two", true);
clockWordmap.setWord(Wordmap::Language_t::NL, "three", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "two", true);
vTaskDelay(delay);
map.setWord(Wordmap::Language_t::NL, "two", false);
map.setWord(Wordmap::Language_t::NL, "one", true);
clockWordmap.setWord(Wordmap::Language_t::NL, "two", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "one", true);
vTaskDelay(delay);
map.setWord(Wordmap::Language_t::NL, "one", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "one", false);
}
static bool IRAM_ATTR timerCallback(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *user_data)
+95
View File
@@ -0,0 +1,95 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file clockwordmap.cpp
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include "clockwordmap.h"
#include "logger.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
ClockWordmap::ClockWordmap(LEDMatrix* matrix) : Wordmap(matrix)
{
createList_NL();
createList_EN();
}
void ClockWordmap::createList_NL(void)
{
// First, clear the list
wordlist[NL].clear();
// Now lets add all relevant words
wordlist[NL].push_back((struct word){"it", {{0,0},{1,0},{2,0}}});
wordlist[NL].push_back((struct word){"is", {{4,0},{5,0}}});
wordlist[NL].push_back((struct word){"ind_five", {{7,0},{8,0},{9,0},{10,0}}});
wordlist[NL].push_back((struct word){"ind_ten", {{1,1},{2,1},{3,1},{4,1}}});
wordlist[NL].push_back((struct word){"ind_quart", {{6,1},{7,1},{8,1},{9,1},{10,1}}});
wordlist[NL].push_back((struct word){"ind_twenty", {{0,2},{1,2},{2,2},{3,2},{4,2},{5,2},{6,2}}});
wordlist[NL].push_back((struct word){"before", {{6,3},{7,3},{8,3},{9,3}}});
wordlist[NL].push_back((struct word){"after", {{1,3},{2,3},{3,3},{4,3}}});
wordlist[NL].push_back((struct word){"almost", {{0,4},{1,4},{2,4},{3,4},{4,4}}});
wordlist[NL].push_back((struct word){"half", {{7,4},{8,4},{9,4},{10,4}}});
wordlist[NL].push_back((struct word){"one", {{3,5},{4,5},{5,5}}});
wordlist[NL].push_back((struct word){"two", {{1,5},{2,5},{3,5},{4,5}}});
wordlist[NL].push_back((struct word){"three", {{6,5},{7,5},{8,5},{9,5}}});
wordlist[NL].push_back((struct word){"four", {{7,6},{8,6},{9,6},{10,5}}});
wordlist[NL].push_back((struct word){"five", {{0,6},{1,6},{2,6},{3,6}}});
wordlist[NL].push_back((struct word){"six", {{4,6},{5,6},{6,6}}});
wordlist[NL].push_back((struct word){"seven", {{0,7},{1,7},{2,7},{3,7},{4,7}}});
wordlist[NL].push_back((struct word){"eight", {{0,8},{1,8},{2,8},{3,8}}});
wordlist[NL].push_back((struct word){"nine", {{6,7},{7,7},{8,7},{9,7},{10,7}}});
wordlist[NL].push_back((struct word){"ten", {{4,8},{5,8},{6,8},{7,8}}});
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}}});
}
-1
View File
@@ -162,7 +162,6 @@ void LEDMatrix::matrixTask(void* parameters)
xSemaphoreTake(ledmatrix->taskSemaphore, portMAX_DELAY);
for (int i = 0; i < ledmatrix->numberOfPixels; i++)
{
if (ledmatrix->matrix[i].on)
{
matrix[i * 3 + LEDMATRIX_RED_INDEX] = ledmatrix->matrix[i].red;
+8 -39
View File
@@ -52,8 +52,6 @@ Wordmap::Wordmap(LEDMatrix* matrix)
{
Wordmap::matrix = matrix;
Wordmap::language = NL;
createList_NL();
}
bool Wordmap::setWord(Language_t lang, string identifier, bool value)
@@ -89,12 +87,10 @@ bool Wordmap::setWord(Language_t lang, string identifier, bool value)
if (returnValue)
{
if (it->length > 0)
std::list<LEDMatrix::coordinate>::iterator pixel;
for (pixel = it->pixels.begin(); pixel != it->pixels.end(); pixel++)
{
for (int i = 0; i < it->length; i++)
{
matrix->setPixelValue(it->position.x + i, it->position.y, value);
}
matrix->setPixelValue(pixel->x, pixel->y, value);
}
}
@@ -105,39 +101,12 @@ void Wordmap::createList_NL(void)
{
// First, clear the list
wordlist[NL].clear();
}
// Now lets add all relevant words
wordlist[NL].push_back((struct word){"it", {0,0}, 3});
wordlist[NL].push_back((struct word){"is", {4,0}, 2});
wordlist[NL].push_back((struct word){"ind_five", {7,0}, 4});
wordlist[NL].push_back((struct word){"ind_ten", {1,1}, 4});
wordlist[NL].push_back((struct word){"ind_quart", {6,1}, 5});
wordlist[NL].push_back((struct word){"ind_twenty", {0,2}, 7});
wordlist[NL].push_back((struct word){"before", {6,3}, 4});
wordlist[NL].push_back((struct word){"after", {1,3}, 4});
wordlist[NL].push_back((struct word){"almost", {1,4}, 5}),
wordlist[NL].push_back((struct word){"half", {7,4}, 4});
wordlist[NL].push_back((struct word){"one", {3,5}, 3});
wordlist[NL].push_back((struct word){"two", {1,5}, 4});
wordlist[NL].push_back((struct word){"three", {6,5}, 4});
wordlist[NL].push_back((struct word){"four", {7,6}, 4});
wordlist[NL].push_back((struct word){"five", {0,6}, 4});
wordlist[NL].push_back((struct word){"six", {4,6}, 3});
wordlist[NL].push_back((struct word){"seven", {0,7}, 5});
wordlist[NL].push_back((struct word){"eight", {0,8}, 4});
wordlist[NL].push_back((struct word){"nine", {6,7}, 5});
wordlist[NL].push_back((struct word){"ten", {4,8}, 4});
wordlist[NL].push_back((struct word){"eleven", {8,8}, 3});
wordlist[NL].push_back((struct word){"twelve", {0,9}, 6});
wordlist[NL].push_back((struct word){"hours", {7,9}, 3});
void Wordmap::createList_EN(void)
{
// First, clear the list
wordlist[EN].clear();
}