Skip to content

Commit

Permalink
Merge pull request #247 from dbambus/main
Browse files Browse the repository at this point in the history
Small changes in the behaviour of the Change mode
  • Loading branch information
dbambus committed Apr 30, 2023
2 parents a4c88f8 + 62b14f9 commit 58d80c3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
1 change: 1 addition & 0 deletions include/clockWork.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ClockWork {
bool changesInClockface();
void calcClockface();
void setClock();
void clearClockByProgInit();

public:
ClockWork() = default;
Expand Down
52 changes: 23 additions & 29 deletions include/clockWork.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,16 @@ void ClockWork::calcClockface() {
}
}

//------------------------------------------------------------------------------

void ClockWork::clearClockByProgInit() {
if (G.progInit) {
G.progInit = false;
led.clear();
led.show();
}
}

//------------------------------------------------------------------------------
// Loop Functions
//------------------------------------------------------------------------------
Expand Down Expand Up @@ -823,7 +833,6 @@ void ClockWork::loop(struct tm &tm) {
Serial.print("Sending Payload:");
Serial.println(str);
webSocket.sendTXT(G.client_nr, str, strlen(str));
G.conf = COMMAND_IDLE;
break;
}

Expand Down Expand Up @@ -878,7 +887,6 @@ void ClockWork::loop(struct tm &tm) {
Serial.print("Sending Payload:");
Serial.println(str);
webSocket.sendTXT(G.client_nr, str, strlen(str));
G.conf = COMMAND_IDLE;
break;
}

Expand All @@ -902,7 +910,6 @@ void ClockWork::loop(struct tm &tm) {
config["prog"] = G.prog;
serializeJson(config, str);
webSocket.sendTXT(G.client_nr, str, strlen(str));
G.conf = COMMAND_IDLE;
break;
}

Expand All @@ -917,7 +924,6 @@ void ClockWork::loop(struct tm &tm) {
config["autoLdrValue"] = map(analogRead(A0), 0, 1023, 0, 255);
serializeJson(config, str);
webSocket.sendTXT(G.client_nr, str, strlen(str));
G.conf = COMMAND_IDLE;
break;
}

Expand Down Expand Up @@ -945,7 +951,6 @@ void ClockWork::loop(struct tm &tm) {
types.add("zufällig");
serializeJson(config, str);
webSocket.sendTXT(G.client_nr, str, strlen(str));
G.conf = COMMAND_IDLE;
break;
}

Expand All @@ -956,7 +961,6 @@ void ClockWork::loop(struct tm &tm) {
case COMMAND_SET_BOOT: {
eeprom::write();
delay(100);
G.conf = COMMAND_IDLE;
break;
}

Expand All @@ -971,7 +975,6 @@ void ClockWork::loop(struct tm &tm) {
led.clear();
frameArray = 0;
parametersChanged = true;
G.conf = COMMAND_IDLE;
break;
}

Expand All @@ -981,7 +984,6 @@ void ClockWork::loop(struct tm &tm) {
frameArray = 0;
G.progInit = true;
parametersChanged = true;
G.conf = COMMAND_IDLE;
break;
}

Expand All @@ -997,26 +999,21 @@ void ClockWork::loop(struct tm &tm) {
}

eeprom::write();
G.conf = COMMAND_IDLE;
break;
}

case COMMAND_SET_COLORTYPE: {
// G.param1 sets new Colortype
Serial.printf("LED Colortype: %u\n", G.param1);

// if ((G.param1 != G.Colortype) && ((G.param1 == Grbw) ||
// (G.Colortype == Grbw))) {
// G.conf = COMMAND_RESET;
// } else {
G.conf = COMMAND_IDLE;
// }

// the G.Colortype must be called at the same time as initLedStrip,
// otherwise it is referenced via a null-pointer.
G.Colortype = G.param1;
eeprom::write();
initLedStrip(G.Colortype);

clearClockByProgInit();
parametersChanged = true;
break;
}

Expand All @@ -1034,7 +1031,6 @@ void ClockWork::loop(struct tm &tm) {
new SecondsFrame(usedUhrType->numPixelsFrameMatrix());
G.progInit = true;
}
G.conf = COMMAND_IDLE;
break;
}

Expand All @@ -1043,7 +1039,6 @@ void ClockWork::loop(struct tm &tm) {
Serial.println(G.hostname);
eeprom::write();
network.reboot();
G.conf = COMMAND_IDLE;
break;
}

Expand All @@ -1052,28 +1047,26 @@ void ClockWork::loop(struct tm &tm) {
delay(100);
Serial.println("Conf: WLAN off");
network.disable();
G.conf = COMMAND_IDLE;
break;
}

case COMMAND_SET_WIFI_AND_RESTART: {
Serial.println("Conf: new Wifi Config");
network.resetSettings();
G.conf = COMMAND_IDLE;
break;
}

default:
break;
}

G.conf = COMMAND_IDLE;

switch (G.prog) {

case COMMAND_MODE_SECONDS: {
if (G.progInit) {
led.clear();
G.progInit = false;
}
clearClockByProgInit();

char d1[5];
char d2[5];
sprintf(d1, "%d", (int)(_second / 10));
Expand All @@ -1084,9 +1077,9 @@ void ClockWork::loop(struct tm &tm) {

case COMMAND_MODE_DIGITAL_CLOCK: {
if (G.progInit) {
led.clear();
G.progInit = false;
led.show();
clearClockByProgInit();
led.showDigitalClock(_minute % 10, _minute / 10, _hour % 10,
_hour / 10);
}
break;
}
Expand All @@ -1095,10 +1088,10 @@ void ClockWork::loop(struct tm &tm) {
case COMMAND_MODE_RAINBOWCYCLE:
case COMMAND_MODE_RAINBOW: {
if (G.progInit) {
G.progInit = false;
led.clear();
countMillisSpeed = (11u - G.effectSpeed) * 30u;
}
clearClockByProgInit();

if (countMillisSpeed >= (11u - G.effectSpeed) * 30u) {
switch (G.prog) {
case COMMAND_MODE_SCROLLINGTEXT: {
Expand Down Expand Up @@ -1144,6 +1137,7 @@ void ClockWork::loop(struct tm &tm) {
}

case COMMAND_MODE_WORD_CLOCK: {
clearClockByProgInit();
calcClockface();

if (G.layoutVariant[ReverseMinDirection]) {
Expand Down
2 changes: 1 addition & 1 deletion include/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ const PROGMEM uint8_t font_7x5[256][5] = {

const PROGMEM uint8_t font_5x3[10][3] = {
{0x1F, 0x11, 0x1F}, // 0
{0x00, 0x00, 0x1F}, // 1
{0x00, 0x1F, 0x00}, // 1
{0x1D, 0x15, 0x17}, // 2
{0x15, 0x15, 0x1F}, // 3
{0x07, 0x04, 0x1F}, // 4
Expand Down
7 changes: 6 additions & 1 deletion include/webPageAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,12 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload,

switch (command) {
case COMMAND_MODE_WORD_CLOCK: {
if (G.prog != COMMAND_IDLE && G.prog != COMMAND_MODE_WORD_CLOCK) {
G.progInit = true;
}
G.prog = COMMAND_MODE_WORD_CLOCK;
parametersChanged = true;

parametersChanged = true;
parseMainColor(payload, Foreground);

G.color[Background] = {HsbColor(split(payload, 15) / 360.f,
Expand Down Expand Up @@ -436,6 +439,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload,

case COMMAND_SET_COLORTYPE: {
G.conf = COMMAND_SET_COLORTYPE;
G.progInit = true;

G.param1 = split(payload, 3);
break;
}
Expand Down

0 comments on commit 58d80c3

Please sign in to comment.