Skip to content

Commit 58d80c3

Browse files
authored
Merge pull request #247 from dbambus/main
Small changes in the behaviour of the Change mode
2 parents a4c88f8 + 62b14f9 commit 58d80c3

File tree

4 files changed

+31
-31
lines changed

4 files changed

+31
-31
lines changed

include/clockWork.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class ClockWork {
4343
bool changesInClockface();
4444
void calcClockface();
4545
void setClock();
46+
void clearClockByProgInit();
4647

4748
public:
4849
ClockWork() = default;

include/clockWork.hpp

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,16 @@ void ClockWork::calcClockface() {
740740
}
741741
}
742742

743+
//------------------------------------------------------------------------------
744+
745+
void ClockWork::clearClockByProgInit() {
746+
if (G.progInit) {
747+
G.progInit = false;
748+
led.clear();
749+
led.show();
750+
}
751+
}
752+
743753
//------------------------------------------------------------------------------
744754
// Loop Functions
745755
//------------------------------------------------------------------------------
@@ -823,7 +833,6 @@ void ClockWork::loop(struct tm &tm) {
823833
Serial.print("Sending Payload:");
824834
Serial.println(str);
825835
webSocket.sendTXT(G.client_nr, str, strlen(str));
826-
G.conf = COMMAND_IDLE;
827836
break;
828837
}
829838

@@ -878,7 +887,6 @@ void ClockWork::loop(struct tm &tm) {
878887
Serial.print("Sending Payload:");
879888
Serial.println(str);
880889
webSocket.sendTXT(G.client_nr, str, strlen(str));
881-
G.conf = COMMAND_IDLE;
882890
break;
883891
}
884892

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

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

@@ -945,7 +951,6 @@ void ClockWork::loop(struct tm &tm) {
945951
types.add("zufällig");
946952
serializeJson(config, str);
947953
webSocket.sendTXT(G.client_nr, str, strlen(str));
948-
G.conf = COMMAND_IDLE;
949954
break;
950955
}
951956

@@ -956,7 +961,6 @@ void ClockWork::loop(struct tm &tm) {
956961
case COMMAND_SET_BOOT: {
957962
eeprom::write();
958963
delay(100);
959-
G.conf = COMMAND_IDLE;
960964
break;
961965
}
962966

@@ -971,7 +975,6 @@ void ClockWork::loop(struct tm &tm) {
971975
led.clear();
972976
frameArray = 0;
973977
parametersChanged = true;
974-
G.conf = COMMAND_IDLE;
975978
break;
976979
}
977980

@@ -981,7 +984,6 @@ void ClockWork::loop(struct tm &tm) {
981984
frameArray = 0;
982985
G.progInit = true;
983986
parametersChanged = true;
984-
G.conf = COMMAND_IDLE;
985987
break;
986988
}
987989

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

9991001
eeprom::write();
1000-
G.conf = COMMAND_IDLE;
10011002
break;
10021003
}
10031004

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

1008-
// if ((G.param1 != G.Colortype) && ((G.param1 == Grbw) ||
1009-
// (G.Colortype == Grbw))) {
1010-
// G.conf = COMMAND_RESET;
1011-
// } else {
1012-
G.conf = COMMAND_IDLE;
1013-
// }
1014-
10151009
// the G.Colortype must be called at the same time as initLedStrip,
10161010
// otherwise it is referenced via a null-pointer.
10171011
G.Colortype = G.param1;
10181012
eeprom::write();
10191013
initLedStrip(G.Colortype);
1014+
1015+
clearClockByProgInit();
1016+
parametersChanged = true;
10201017
break;
10211018
}
10221019

@@ -1034,7 +1031,6 @@ void ClockWork::loop(struct tm &tm) {
10341031
new SecondsFrame(usedUhrType->numPixelsFrameMatrix());
10351032
G.progInit = true;
10361033
}
1037-
G.conf = COMMAND_IDLE;
10381034
break;
10391035
}
10401036

@@ -1043,7 +1039,6 @@ void ClockWork::loop(struct tm &tm) {
10431039
Serial.println(G.hostname);
10441040
eeprom::write();
10451041
network.reboot();
1046-
G.conf = COMMAND_IDLE;
10471042
break;
10481043
}
10491044

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

10591053
case COMMAND_SET_WIFI_AND_RESTART: {
10601054
Serial.println("Conf: new Wifi Config");
10611055
network.resetSettings();
1062-
G.conf = COMMAND_IDLE;
10631056
break;
10641057
}
10651058

10661059
default:
10671060
break;
10681061
}
10691062

1063+
G.conf = COMMAND_IDLE;
1064+
10701065
switch (G.prog) {
10711066

10721067
case COMMAND_MODE_SECONDS: {
1073-
if (G.progInit) {
1074-
led.clear();
1075-
G.progInit = false;
1076-
}
1068+
clearClockByProgInit();
1069+
10771070
char d1[5];
10781071
char d2[5];
10791072
sprintf(d1, "%d", (int)(_second / 10));
@@ -1084,9 +1077,9 @@ void ClockWork::loop(struct tm &tm) {
10841077

10851078
case COMMAND_MODE_DIGITAL_CLOCK: {
10861079
if (G.progInit) {
1087-
led.clear();
1088-
G.progInit = false;
1089-
led.show();
1080+
clearClockByProgInit();
1081+
led.showDigitalClock(_minute % 10, _minute / 10, _hour % 10,
1082+
_hour / 10);
10901083
}
10911084
break;
10921085
}
@@ -1095,10 +1088,10 @@ void ClockWork::loop(struct tm &tm) {
10951088
case COMMAND_MODE_RAINBOWCYCLE:
10961089
case COMMAND_MODE_RAINBOW: {
10971090
if (G.progInit) {
1098-
G.progInit = false;
1099-
led.clear();
11001091
countMillisSpeed = (11u - G.effectSpeed) * 30u;
11011092
}
1093+
clearClockByProgInit();
1094+
11021095
if (countMillisSpeed >= (11u - G.effectSpeed) * 30u) {
11031096
switch (G.prog) {
11041097
case COMMAND_MODE_SCROLLINGTEXT: {
@@ -1144,6 +1137,7 @@ void ClockWork::loop(struct tm &tm) {
11441137
}
11451138

11461139
case COMMAND_MODE_WORD_CLOCK: {
1140+
clearClockByProgInit();
11471141
calcClockface();
11481142

11491143
if (G.layoutVariant[ReverseMinDirection]) {

include/font.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ const PROGMEM uint8_t font_7x5[256][5] = {
266266

267267
const PROGMEM uint8_t font_5x3[10][3] = {
268268
{0x1F, 0x11, 0x1F}, // 0
269-
{0x00, 0x00, 0x1F}, // 1
269+
{0x00, 0x1F, 0x00}, // 1
270270
{0x1D, 0x15, 0x17}, // 2
271271
{0x15, 0x15, 0x1F}, // 3
272272
{0x07, 0x04, 0x1F}, // 4

include/webPageAdapter.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,12 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload,
184184

185185
switch (command) {
186186
case COMMAND_MODE_WORD_CLOCK: {
187+
if (G.prog != COMMAND_IDLE && G.prog != COMMAND_MODE_WORD_CLOCK) {
188+
G.progInit = true;
189+
}
187190
G.prog = COMMAND_MODE_WORD_CLOCK;
188-
parametersChanged = true;
189191

192+
parametersChanged = true;
190193
parseMainColor(payload, Foreground);
191194

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

437440
case COMMAND_SET_COLORTYPE: {
438441
G.conf = COMMAND_SET_COLORTYPE;
442+
G.progInit = true;
443+
439444
G.param1 = split(payload, 3);
440445
break;
441446
}

0 commit comments

Comments
 (0)