Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 2 additions & 22 deletions ledmatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,10 @@ class LEDMatrix{
uint16_t currentLimit;

// target representation of matrix as 2D array
uint32_t targetgrid[HEIGHT][WIDTH] = {{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0}};
uint32_t targetgrid[HEIGHT][WIDTH] = {0};

// current representation of matrix as 2D array
uint32_t currentgrid[HEIGHT][WIDTH] = {{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0}};
uint32_t currentgrid[HEIGHT][WIDTH] = {0};

// target representation of minutes indicator leds
uint32_t targetindicators[4] = {0, 0, 0, 0};
Expand Down
39 changes: 37 additions & 2 deletions wordclock_esp8266.ino
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@
// CONSTANTS
// ----------------------------------------------------------------------------------

#define EEPROM_SIZE 20 // size of EEPROM to save persistent variables
#define EEPROM_SIZE 30 // size of EEPROM to save persistent variables
#define ADR_NM_START_H 0
#define ADR_NM_END_H 4
#define ADR_NM_START_M 8
#define ADR_NM_END_M 12
#define ADR_BRIGHTNESS 16
#define ADR_MC_RED 20
#define ADR_MC_GREEN 22
#define ADR_MC_BLUE 24


#define NEOPIXELPIN 5 // pin to which the NeoPixels are attached
Expand Down Expand Up @@ -212,6 +215,9 @@ void setup() {
//Init EEPROM
EEPROM.begin(EEPROM_SIZE);

// Load color for clock from EEPROM
loadMainColor();

// configure button pin as input
pinMode(BUTTONPIN, INPUT_PULLUP);

Expand Down Expand Up @@ -718,6 +724,35 @@ void handleButton(){
lastButtonState = buttonPressed;
}

/**
* @brief Set main color
*
*/

void setMainColor(uint8_t red, uint8_t green, uint8_t blue){
maincolor_clock = LEDMatrix::Color24bit(red, green, blue);
EEPROM.put(ADR_MC_RED, red);
EEPROM.put(ADR_MC_GREEN, green);
EEPROM.put(ADR_MC_BLUE, blue);
EEPROM.commit();
}

/**
* @brief Load maincolor from EEPROM
*
*/

void loadMainColor(){
uint8_t red = EEPROM.read(ADR_MC_RED);
uint8_t green = EEPROM.read(ADR_MC_GREEN);
uint8_t blue = EEPROM.read(ADR_MC_BLUE);
if(int(red) + int(green) + int(blue) < 50){
maincolor_clock = colors24bit[2];
}else{
maincolor_clock = LEDMatrix::Color24bit(red, green, blue);
}
}

/**
* @brief Handler for handling commands sent to "/cmd" url
*
Expand All @@ -741,7 +776,7 @@ void handleCommand() {
logger.logString("g: " + String(greenstr.toInt()));
logger.logString("b: " + String(bluestr.toInt()));
// set new main color
maincolor_clock = LEDMatrix::Color24bit(redstr.toInt(), greenstr.toInt(), bluestr.toInt());
setMainColor(redstr.toInt(), greenstr.toInt(), bluestr.toInt());
}
else if (server.argName(0) == "mode") // the parameter which was sent to this server is mode change
{
Expand Down