You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

142 lines
2.5 KiB

#ifndef ViewState_h
#define ViewState_h
#include <States.h>
#include <DS3231.h>
#include <AT24C32.h>
using namespace std;
// I2C address
#define TEXT_INTERVAL 1000
#define CONTROL_BLINK_INTERVAL 250
/**
led matrix entry
*/
struct matrix_entry
{
uint8_t row;
uint8_t columnFrom;
uint8_t columnTo;
bool notNull;
};
/**
abstract view state
*/
class ViewState
{
public:
virtual void render(uint8_t matrix[121], ControlStates controlState) = 0;
void setColor(uint8_t _color);
protected:
void renderBinaryClock(uint8_t matrix[121], DS3231 &ds3231);
uint8_t color = 0xFF;
};
/**
view time state
*/
class ViewTimeState : public ViewState
{
public:
ViewTimeState(DS3231 &_ds3231, AT24C32 &_at24c32);
void render(uint8_t matrix[121], ControlStates controlState);
protected:
DS3231 ds3231;
AT24C32 at24c32;
matrix_entry text[2];
matrix_entry hours[12][2];
matrix_entry minutes[12][3];
uint8_t increment;
uint8_t mode = 0;
void init();
void setWord(uint8_t matrix[121], matrix_entry word);
void setWessi();
void setOssi();
};
/**
view text state
*/
class ViewTextState : public ViewState
{
public:
ViewTextState(AT24C32 &_at24c32);
void render(uint8_t matrix[121], ControlStates controlState);
protected:
void writeText(uint8_t matrix[121]);
void writeChars(uint8_t matrix[121]);
AT24C32 at24c32;
uint8_t text[0xFF];
uint8_t length = 0;
uint8_t position = 0;
uint8_t v_offset = 1;
long renderOffset;
};
/**
view seconds state
*/
class ViewSecondsState : public ViewTextState
{
public:
ViewSecondsState(DS3231 &_ds3231, AT24C32 &_at24c32);
void render(uint8_t matrix[121], ControlStates controlState);
protected:
DS3231 ds3231;
};
/**
view temperature state
*/
class ViewTemperatureState : public ViewTextState
{
public:
ViewTemperatureState(DS3231 &_ds3231, AT24C32 &_at24c32);
void render(uint8_t matrix[121], ControlStates controlState);
protected:
DS3231 ds3231;
};
/**
view date state
*/
class ViewDateState : public ViewTextState
{
public:
ViewDateState(DS3231 &_ds3231, AT24C32 &_at24c32, char _delimiter);
void render(uint8_t matrix[121], ControlStates controlState);
protected:
DS3231 ds3231;
char delimiter;
};
/**
view LED demo state
*/
class ViewLEDState : public ViewState
{
public:
ViewLEDState();
void render(uint8_t matrix[121], ControlStates controlState);
};
/**
view Remote demo state
*/
class ViewRemoteState : public ViewState
{
public:
ViewRemoteState();
void render(uint8_t matrix[121], ControlStates controlState);
};
#endif