Added the Matrix handling and clock/day wordmaps
Time and day display is functional again
This commit is contained in:
@@ -1,99 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// \file clock.h
|
||||
/// \brief File description
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// vbchaos software design
|
||||
//
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// $Revision: $
|
||||
/// $Author: $
|
||||
/// $Date: $
|
||||
// (c) 2023 vbchaos
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef MAIN_INC_CLOCK_H_
|
||||
#define MAIN_INC_CLOCK_H_
|
||||
|
||||
/**
|
||||
* clock implementation
|
||||
* \defgroup clock
|
||||
* \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
|
||||
#include "time.h"
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Clock
|
||||
{
|
||||
public:
|
||||
|
||||
enum mode
|
||||
{
|
||||
TEN_BEFORE_HALF,
|
||||
TWENTY_OVER
|
||||
};
|
||||
|
||||
Clock(Clock::mode mode);
|
||||
|
||||
void generateWordlist(list<string>* wordlist);
|
||||
|
||||
time_t getTime(void);
|
||||
|
||||
private:
|
||||
|
||||
Clock::mode clockmode;
|
||||
time_t currentTime;
|
||||
|
||||
|
||||
string toNumbers[20] {"zero", "one", "two", "three", "four",
|
||||
"five", "six", "seven", "eight",
|
||||
"nine", "ten", "eleven", "twelve",
|
||||
"thirteen", "fourteen", "fifteen",
|
||||
"sixteen", "seventeen", "eighteen",
|
||||
"nineteen"};
|
||||
|
||||
// void toString(TimeStructure* timestructure);
|
||||
int calculateHours(struct tm time);
|
||||
};
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* MAIN_INC_CLOCK_H_ */
|
||||
@@ -1,72 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// \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_ */
|
||||
@@ -1,72 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// \file daywordmap.h
|
||||
/// \brief File description
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// vbchaos software design
|
||||
//
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// $Revision: $
|
||||
/// $Author: $
|
||||
/// $Date: $
|
||||
// (c) 2023 vbchaos
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef MAIN_INC_DAYWORDMAP_H_
|
||||
#define MAIN_INC_DAYWORDMAP_H_
|
||||
|
||||
/**
|
||||
* daywordmap implementation
|
||||
* \defgroup daywordmap
|
||||
* \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 DayWordmap: public Wordmap
|
||||
{
|
||||
public:
|
||||
DayWordmap(LEDMatrix* matrix);
|
||||
protected:
|
||||
void createList_NL(void);
|
||||
// void createList_EN(void);
|
||||
};
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* MAIN_INC_DAYWORDMAP_H_ */
|
||||
@@ -1,156 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// \file ledmatrix.h
|
||||
/// \brief File description
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// vbchaos software design
|
||||
//
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// $Revision: $
|
||||
/// $Author: $
|
||||
/// $Date: $
|
||||
// (c) 2023 vbchaos
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef MAIN_INC_LEDMATRIX_H_
|
||||
#define MAIN_INC_LEDMATRIX_H_
|
||||
|
||||
/**
|
||||
* ledmatrix implementation
|
||||
* \defgroup ledmatrix
|
||||
* \brief {group_description}
|
||||
* \addtogroup {Layer}
|
||||
*
|
||||
* Detailed description
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Include files
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// CompilerIncludes
|
||||
// All include files that are provided by the compiler directly
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
// ProjectIncludes
|
||||
// All include files that are provided by the project
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#include "driver/rmt_tx.h"
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#define LEDMATRIX_RED_INDEX ((uint32_t)1)
|
||||
#define LEDMATRIX_GREEN_INDEX ((uint32_t)0)
|
||||
#define LEDMATRIX_BLUE_INDEX ((uint32_t)2)
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LEDMATRIX_ORIENTATION_ROW_LEFT_RIGHT,
|
||||
LEDMATRIX_ORIENTATION_ROW_RIGHT_LEFT
|
||||
} LEDMatrix_Orientation_Row_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LEDMATRIX_ORIENTATION_COLUM_UP_DOWN,
|
||||
LEDMATRIX_ORIENTATION_COLUM_DOWN_UP
|
||||
} LEDMatrix_Orientation_Colum_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LEDMATRIX_ORIENTATION_ROW,
|
||||
LEDMATRIX_ORIENTATION_COLUM
|
||||
}LEDMatrix_Orientation_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LEDMatrix_Orientation_Row_t rowOrientation;
|
||||
LEDMatrix_Orientation_Colum_t columOrientation;
|
||||
LEDMatrix_Orientation_t matrixOrientation;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
// RMT objects for transmission
|
||||
rmt_channel_handle_t* rmtChannel;
|
||||
rmt_encoder_handle_t* rmtEncoder;
|
||||
rmt_transmit_config_t* rmtConfig;
|
||||
} LEDMatrix_Parameters_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool on;
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
} LEDMatrix_Pixel_t;
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
class LEDMatrix
|
||||
{
|
||||
public:
|
||||
|
||||
struct coordinate
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
LEDMatrix(LEDMatrix_Parameters_t* parameters);
|
||||
|
||||
bool setPixelValue(unsigned int colum, unsigned int row, bool value);
|
||||
void setGlobalColour(uint8_t red, uint8_t green, uint8_t blue);
|
||||
void setPixelColour(unsigned int colum, unsigned int row, uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
||||
void clear(void);
|
||||
|
||||
BaseType_t tick(void);
|
||||
|
||||
protected:
|
||||
unsigned int findPixelIndexFromCoordinates(unsigned int colum, unsigned int row);
|
||||
|
||||
private:
|
||||
|
||||
LEDMatrix_Parameters_t parameters;
|
||||
LEDMatrix_Pixel_t* matrix;
|
||||
uint8_t* tx_matrix;
|
||||
unsigned int numberOfPixels;
|
||||
|
||||
static bool initialized;
|
||||
static TaskHandle_t matrixTaskHandle;
|
||||
static SemaphoreHandle_t taskSemaphore;
|
||||
static void matrixTask(void* parameters);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
inline BaseType_t LEDMatrix::tick(void)
|
||||
{
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
if (LEDMatrix::initialized)
|
||||
{
|
||||
xSemaphoreGiveFromISR(LEDMatrix::taskSemaphore, &xHigherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
return xHigherPriorityTaskWoken;
|
||||
}
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* MAIN_INC_LEDMATRIX_H_ */
|
||||
@@ -1,107 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// \file wordmap.h
|
||||
/// \brief File description
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// vbchaos software design
|
||||
//
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// $Revision: $
|
||||
/// $Author: $
|
||||
/// $Date: $
|
||||
// (c) 2023 vbchaos
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef MAIN_INC_WORDMAP_H_
|
||||
#define MAIN_INC_WORDMAP_H_
|
||||
|
||||
/**
|
||||
* wordmap implementation
|
||||
* \defgroup wordmap
|
||||
* \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
|
||||
#include "ledmatrix.h"
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Wordmap
|
||||
{
|
||||
public:
|
||||
|
||||
typedef enum language
|
||||
{
|
||||
NL = 0,
|
||||
EN,
|
||||
NumberOfLanguages
|
||||
} Language_t;
|
||||
|
||||
Wordmap(LEDMatrix* matrix);
|
||||
|
||||
bool setColour(uint8_t red, uint8_t green, uint8_t blue);
|
||||
bool setWord(Language_t lang, string identifier, bool value);
|
||||
|
||||
protected:
|
||||
|
||||
struct word
|
||||
{
|
||||
string identifier;
|
||||
list<LEDMatrix::coordinate> pixels;
|
||||
// LEDMatrix::coordinate position;
|
||||
// int length;
|
||||
};
|
||||
|
||||
LEDMatrix* matrix;
|
||||
language language;
|
||||
|
||||
list<struct word> wordlist[NumberOfLanguages];
|
||||
|
||||
void createList_NL(void);
|
||||
void createList_EN(void);
|
||||
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* MAIN_INC_WORDMAP_H_ */
|
||||
@@ -1,231 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// \file clock.cpp
|
||||
/// \brief Description
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// vbchaos software design
|
||||
//
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// $Revision: $
|
||||
/// $Author: $
|
||||
/// $Date: $
|
||||
// (c) 2023 vbchaos
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Include files
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#include "clock.h"
|
||||
|
||||
#include "esp_sntp.h"
|
||||
#include "esp_wifi.h"
|
||||
|
||||
#include "logger.h"
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
Clock::Clock(Clock::mode mode)
|
||||
{
|
||||
Clock::currentTime = 40000;
|
||||
|
||||
Clock::clockmode = mode;
|
||||
|
||||
// Start NTP
|
||||
setenv("TZ", "CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00", 1);
|
||||
tzset();
|
||||
esp_sntp_setoperatingmode(ESP_SNTP_OPMODE_POLL);
|
||||
esp_sntp_setservername(0, "pool.ntp.org");
|
||||
esp_sntp_init();
|
||||
}
|
||||
|
||||
void Clock::generateWordlist(list<string>* wordlist)
|
||||
{
|
||||
|
||||
struct tm tm;
|
||||
time(¤tTime);
|
||||
// currentTime += 100;
|
||||
localtime_r(¤tTime, &tm);
|
||||
|
||||
// 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");
|
||||
wordlist->push_back("is");
|
||||
wordlist->push_back(toNumbers[calculateHours(tm)]);
|
||||
|
||||
if (tm.tm_min < 4)
|
||||
{
|
||||
wordlist->push_back("hours");
|
||||
}
|
||||
else if (tm.tm_min < 9)
|
||||
{
|
||||
wordlist->push_back("ind_five");
|
||||
wordlist->push_back("after");
|
||||
}
|
||||
else if (tm.tm_min < 14)
|
||||
{
|
||||
wordlist->push_back("ind_ten");
|
||||
wordlist->push_back("after");
|
||||
}
|
||||
else if (tm.tm_min < 19)
|
||||
{
|
||||
wordlist->push_back("ind_quart");
|
||||
wordlist->push_back("after");
|
||||
}
|
||||
else if (tm.tm_min < 24)
|
||||
{
|
||||
wordlist->push_back("ind_ten");
|
||||
wordlist->push_back("before");
|
||||
wordlist->push_back("half");
|
||||
}
|
||||
else if (tm.tm_min < 28)
|
||||
{
|
||||
wordlist->push_back("ind_five");
|
||||
wordlist->push_back("before");
|
||||
wordlist->push_back("half");
|
||||
}
|
||||
else if (tm.tm_min < 30)
|
||||
{
|
||||
wordlist->push_back("almost");
|
||||
wordlist->push_back("half");
|
||||
}
|
||||
else if (tm.tm_min < 34)
|
||||
{
|
||||
wordlist->push_back("half");
|
||||
}
|
||||
else if (tm.tm_min < 39)
|
||||
{
|
||||
wordlist->push_back("ind_five");
|
||||
wordlist->push_back("after");
|
||||
wordlist->push_back("half");
|
||||
}
|
||||
else if (tm.tm_min < 44)
|
||||
{
|
||||
wordlist->push_back("ind_ten");
|
||||
wordlist->push_back("after");
|
||||
wordlist->push_back("half");
|
||||
}
|
||||
else if (tm.tm_min < 49)
|
||||
{
|
||||
wordlist->push_back("ind_quart");
|
||||
wordlist->push_back("before");
|
||||
}
|
||||
else if (tm.tm_min < 54)
|
||||
{
|
||||
wordlist->push_back("ind_ten");
|
||||
wordlist->push_back("before");
|
||||
}
|
||||
else if (tm.tm_min < 58)
|
||||
{
|
||||
wordlist->push_back("ind_five");
|
||||
wordlist->push_back("before");
|
||||
}
|
||||
else
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
time_t Clock::getTime(void)
|
||||
{
|
||||
// time(¤tTime);
|
||||
return currentTime;
|
||||
}
|
||||
|
||||
|
||||
int Clock::calculateHours(struct tm time)
|
||||
{
|
||||
int hours = time.tm_hour;
|
||||
// Add one hour in case the clock is heading towards half
|
||||
if (time.tm_min > 19)
|
||||
{
|
||||
hours = hours + 1;
|
||||
}
|
||||
|
||||
// Calculate hours to 12hour system
|
||||
if (hours > 12)
|
||||
{
|
||||
hours = hours - 12;
|
||||
}
|
||||
// Start at 1, not 0
|
||||
if (hours == 0)
|
||||
{
|
||||
hours++;
|
||||
}
|
||||
|
||||
return hours;
|
||||
}
|
||||
|
||||
//void Clock::toString(TimeStructure* timestructure)
|
||||
//{
|
||||
// LOGGER_SUCCESS("%s%s%s%s%d%s", timestructure->prefix ? "Het is " : "",
|
||||
// timestructure->fifths == Five ? "Vijf " :
|
||||
// timestructure->fifths == Ten ? "Tien " :
|
||||
// timestructure->fifths == Quarter ? "kwart ": "",
|
||||
// timestructure->beforeAfter == Before ? "voor " :
|
||||
// timestructure->beforeAfter == After ? "over " : "",
|
||||
// timestructure->half ? "half " : "",
|
||||
// timestructure->hours,
|
||||
// timestructure->hourPostfix ? " uur" : ""
|
||||
// );
|
||||
//}
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// \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,6}}});
|
||||
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", {{8,9},{9,9},{10,9}}});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// \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}}});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,259 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// \file ledmatrix.cpp
|
||||
/// \brief Description
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// vbchaos software design
|
||||
//
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// $Revision: $
|
||||
/// $Author: $
|
||||
/// $Date: $
|
||||
// (c) 2023 vbchaos
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Include files
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#include "ledmatrix.h"
|
||||
#include "logger.h"
|
||||
#include "string.h"
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
SemaphoreHandle_t LEDMatrix::taskSemaphore = 0;
|
||||
TaskHandle_t LEDMatrix::matrixTaskHandle = NULL;
|
||||
bool LEDMatrix::initialized = false;
|
||||
|
||||
LEDMatrix::LEDMatrix(LEDMatrix_Parameters_t* parameters)
|
||||
{
|
||||
// Take the parameters
|
||||
LEDMatrix::parameters = *parameters;
|
||||
// Calculate the total number of pixels
|
||||
LEDMatrix::numberOfPixels = parameters->width * parameters->height;
|
||||
// Create the matrix storage
|
||||
matrix = new LEDMatrix_Pixel_t[parameters->width * parameters->height];
|
||||
// Create the second matrix, that is actually transmitted to the periphery
|
||||
|
||||
// Create the task Semaphore
|
||||
vSemaphoreCreateBinary(LEDMatrix::taskSemaphore);
|
||||
// Take the semaphore immediately so the task cannot run
|
||||
xSemaphoreTake(LEDMatrix::taskSemaphore, 0);
|
||||
// Create the matrix task
|
||||
xTaskCreate(matrixTask, (const char*)"matrixTask", 4096, this, 3, &LEDMatrix::matrixTaskHandle);
|
||||
|
||||
// Clear the matrix initially
|
||||
LEDMatrix::clear();
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
bool LEDMatrix::setPixelValue(unsigned int colum, unsigned int row, bool value)
|
||||
{
|
||||
bool returnValue = true;
|
||||
|
||||
// unsigned int rowC = 0;
|
||||
// unsigned int colC = 0;
|
||||
unsigned int pixelAddress = 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)
|
||||
// {
|
||||
// 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
index = rowC + (colC * parameters.height);
|
||||
}
|
||||
else if (parameters.matrixOrientation == LEDMATRIX_ORIENTATION_ROW)
|
||||
{
|
||||
index = (rowC * parameters.width) + colC;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
void LEDMatrix::matrixTask(void* parameters)
|
||||
{
|
||||
LEDMatrix* ledmatrix = (LEDMatrix*)parameters;
|
||||
|
||||
uint8_t matrix[ledmatrix->numberOfPixels * 3];
|
||||
memset(&matrix, 0, sizeof(matrix));
|
||||
|
||||
while(1)
|
||||
{
|
||||
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;
|
||||
matrix[i * 3 + LEDMATRIX_GREEN_INDEX] = ledmatrix->matrix[i].green;
|
||||
matrix[i * 3 + LEDMATRIX_BLUE_INDEX] = ledmatrix->matrix[i].blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix[i * 3 + 0] = 0;
|
||||
matrix[i * 3 + 1] = 0;
|
||||
matrix[i * 3 + 2] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
rmt_transmit(*ledmatrix->parameters.rmtChannel, *ledmatrix->parameters.rmtEncoder, matrix, sizeof(matrix), ledmatrix->parameters.rmtConfig);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,131 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// \file wordmap.cpp
|
||||
/// \brief Description
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// vbchaos software design
|
||||
//
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// $Revision: $
|
||||
/// $Author: $
|
||||
/// $Date: $
|
||||
// (c) 2023 vbchaos
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Include files
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#include "wordmap.h"
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
#include <algorithm>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
bool returnValue;
|
||||
|
||||
auto _compare = [&](struct word currentword)
|
||||
{
|
||||
if (identifier.compare(currentword.identifier) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// Create a list Iterator
|
||||
std::list<struct word>::iterator it;
|
||||
// Fetch the iterator of element with value 'the'
|
||||
it = find_if(wordlist[lang].begin(), wordlist[lang].end(), _compare);
|
||||
// Check if iterator points to end or not
|
||||
|
||||
if(it != wordlist[lang].end())
|
||||
{
|
||||
returnValue = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = false;
|
||||
}
|
||||
|
||||
if (returnValue)
|
||||
{
|
||||
std::list<LEDMatrix::coordinate>::iterator pixel;
|
||||
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
|
||||
wordlist[NL].clear();
|
||||
}
|
||||
|
||||
void Wordmap::createList_EN(void)
|
||||
{
|
||||
// First, clear the list
|
||||
wordlist[EN].clear();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user