Added clock and wordclock - functional

the matrix needs an update, though. Not all words are well put
This commit is contained in:
Matthias Mitscherlich
2023-01-18 14:54:23 +01:00
parent 1ae7d6ec5a
commit 7cb84d1660
8 changed files with 667 additions and 25 deletions
+105
View File
@@ -0,0 +1,105 @@
// --------------------------------------------------------------------------------------------------------------------
/// \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
// ProjectIncludes
// All include files that are provided by the project
#include "time.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class Clock
{
public:
enum FifthsIndication
{
None_FifthIndication = 0,
Five,
Ten,
Quarter
};
enum BeforeAfterIndication
{
None_BeforeAfter = 0,
Before,
After
};
struct TimeStructure
{
bool prefix;
bool almost;
FifthsIndication fifths;
BeforeAfterIndication beforeAfter;
bool half;
int hours;
bool hourPostfix;
};
Clock();
TimeStructure updateTime(void);
private:
time_t currentTime;
void toString(TimeStructure* timestructure);
int calculateHours(int hour);
};
/** @} */
#endif /* MAIN_INC_CLOCK_H_ */
+8 -1
View File
@@ -103,9 +103,16 @@ typedef struct
class LEDMatrix
{
public:
struct coordinate
{
int x;
int y;
};
LEDMatrix(LEDMatrix_Parameters_t* parameters);
bool setPixelValue(unsigned int row, unsigned int colum, bool value);
bool setPixelValue(unsigned int colum, unsigned int row, bool value);
void setGlobalColour(uint8_t red, uint8_t green, uint8_t blue);
void clear(void);
+130
View File
@@ -0,0 +1,130 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file wordclock.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_INC_WORDCLOCK_H_
#define MAIN_INC_WORDCLOCK_H_
/**
* wordclock implementation
* \defgroup wordclock
* \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 "ledmatrix.h"
#include "clock.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class Wordclock
{
public:
enum language
{
NL = 0,
EN,
NumberOfLanguages
};
Wordclock(LEDMatrix* matrix);
void update(Clock::TimeStructure* timestructure);
private:
LEDMatrix* matrix;
language language;
struct word
{
LEDMatrix::coordinate position;
int length;
};
struct wordmap
{
struct word prefix;
struct word prefix_additional;
struct word almost;
struct word five;
struct word ten;
struct word quarter;
struct word before;
struct word after;
struct word half;
struct word hour[12];
struct word hourPostfix;
};
struct wordmap languagemaps[NumberOfLanguages]
{
{
// prefix
{0,0,3}, {4,0,2},
// almost
{0,0,0},
// five/ten/quarter
{7,0,4}, {0,1,4}, {6,2,5},
// before/after
{7,1,4}, {0,2,4},
// {0,4,4}, {7,3,4},
// half
{0,3,4},
// hours
{{7,4,3},{0,5,4},{7,5,4},{0,6,4},{4,6,4},{6,8,3},{0,7,5},{0,8,4},{6,7,5},{4,8,4},{8,8,3},{0,9,6}},
// hour postfix
{8,9,3}
}
};
};
/** @} */
#endif /* MAIN_INC_WORDCLOCK_H_ */