Skip to content

Commit

Permalink
Added Option for 7 Pixels for displaying 4 Minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
dbambus committed Feb 22, 2023
1 parent e7ea9ef commit 710a1f8
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 39 deletions.
7 changes: 5 additions & 2 deletions include/Animation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,15 @@ void Animation::analyzeColors(RgbfColor **dest, RgbfColor **source,

uint8_t Animation::determineWhichMinuteVariant() {
switch (G.minuteVariant) {
case MinuteVariant::Row:
case MinuteVariant::LED4x:
return 0;
break;
case MinuteVariant::Corners:
case MinuteVariant::LED7x:
return 1;
break;
case MinuteVariant::Corners:
return 2;
break;
default:
Serial.println("[ERROR] G.minuteVariant undefined");
return 0;
Expand Down
7 changes: 4 additions & 3 deletions include/Uhr.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ struct OpenWeatherMapData {

enum class MinuteVariant {
Off = 0,
Corners = 1,
Row = 2,
InWords = 3,
LED4x = 1,
LED7x = 2,
Corners = 3,
InWords = 4,
};

enum class SecondVariant {
Expand Down
7 changes: 5 additions & 2 deletions include/Uhrtypes/DE10x11.alternative.frame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ class De10x11AlternativeFrame_t : public De10x11Alternative_t {
return 114 + index;
};

virtual const void getMinuteArray(uint16_t *returnArr, uint8_t col) override {
//------------------------------------------------------------------------------

virtual const void getMinuteArray(uint16_t *returnArr,
uint8_t col) override {
for (uint8_t i = 0; i < 4; i++) {
returnArr[i] = 114 - (4 - i);
returnArr[i] = 110 + i;
}
};
};
Expand Down
30 changes: 22 additions & 8 deletions include/Uhrtypes/DE11x11.frame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,30 @@ class De11x11frame_t : public iUhrType {

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

const uint16_t minArr[2][4] = {
{0, 12, 168, 156}, // LEDs for "Normal" minute display
{152, 150, 148, 146} // LEDs für "Row" type minute display
};

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

virtual const void getMinuteArray(uint16_t *returnArr, uint8_t col) {
const uint8_t corner[4] = {152, 150, 148, 146};

for (uint8_t i = 0; i < 4; i++) {
returnArr[i] = minArr[col][i];
switch (col) {
case 0:
// LEDs for "LED4x" minute display
// {150, 149, 148, 147}
returnArr[i] = 150 - i;
break;
case 1:
// LEDs for "LED7x" minute display
// {152, 150, 148, 146}
returnArr[i] = 152 - (i * 2);
break;
case 2:
// LEDs for "Corners" minute display
// {0, 12, 168, 156}
returnArr[i] = corner[i];
break;

default:
break;
}
}
};

Expand Down
27 changes: 17 additions & 10 deletions include/Uhrtypes/DE11x11.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,29 @@ class De11x11_t : public iUhrType {

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

const uint16_t minArr[2][4] = {
{121, 122, 123, 124}, // LEDs for "Normal" minute display
{110, 111, 112, 113} // LEDs für "Row" type minute display
};

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

virtual const void getMinuteArray(uint16_t *returnArr, uint8_t col) {
virtual const void getMinuteArray(uint16_t *returnArr,
uint8_t col) override {
for (uint8_t i = 0; i < 4; i++) {
returnArr[i] = minArr[col][i];
switch (col) {
case 0: // LEDs for "LED4x" minute display
returnArr[i] = numPixels() - (7 - i);
break;
case 1: // LEDs for "LED7x" minute display
returnArr[i] = numPixels() - (7 - (i * 2));
break;
case 2: // LEDs für "Corners" type minute display
returnArr[i] = 110 + i;
break;

default:
break;
}
}
};

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

virtual const uint16_t numPixels() override { return 125; };
virtual const uint16_t numPixels() override { return 128; };

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

Expand Down
17 changes: 17 additions & 0 deletions include/Uhrtypes/DE21x11.weather.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,23 @@ class De21x11Weather_t : public iUhrType {
for (uint8_t i = 0; i < 4; i++) {
returnArr[i] = minArr[i];
}
for (uint8_t i = 0; i < 4; i++) {
switch (col) {
case 0:
// LEDs for "LED4x" minute display
// {112, 114, 116, 118}
returnArr[i] = 113 + i;
break;
case 1:
// LEDs for "LED7x" minute display
// {112, 114, 116, 118}
returnArr[i] = 112 + (i * 2);
break;

default:
break;
}
}
};

//------------------------------------------------------------------------------
Expand Down
14 changes: 12 additions & 2 deletions include/Uhrtypes/Uhrtype.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class iUhrType {

virtual LanguageAbbreviation usedLang() = 0;

virtual inline const uint16_t numPixels() { return 114; }
virtual inline const uint16_t numPixels() { return 117; }

virtual inline const uint16_t numPixelsWordMatrix() {
return rowsWordMatrix() * colsWordMatrix();
Expand Down Expand Up @@ -141,7 +141,17 @@ class iUhrType {

virtual const void getMinuteArray(uint16_t *returnArr, uint8_t col) {
for (uint8_t i = 0; i < 4; i++) {
returnArr[i] = numPixels() - (4 - i);
switch (col) {
case 0: // LEDs for "LED4x" minute display
returnArr[i] = numPixels() - (7 - i);
break;
case 1: // LEDs for "LED7x" minute display
returnArr[i] = numPixels() - (7 - (i * 2));
break;

default:
break;
}
}
};
};
14 changes: 9 additions & 5 deletions include/clockWork.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,15 @@ void ClockWork::setHour(const uint8_t hour, const bool fullHour) {

uint8_t ClockWork::determineWhichMinuteVariant() {
switch (G.minuteVariant) {
case MinuteVariant::Row:
case MinuteVariant::LED4x:
return 0;
break;
case MinuteVariant::Corners:
case MinuteVariant::LED7x:
return 1;
break;
case MinuteVariant::Corners:
return 2;
break;
default:
Serial.println("[ERROR] G.minuteVariant undefined");
return 0;
Expand Down Expand Up @@ -718,9 +721,9 @@ void ClockWork::initLedStrip(uint8_t num) {
void resetMinVariantIfNotAvailable() {
if (G.UhrtypeDef != Nl10x11 && G.minuteVariant == MinuteVariant::InWords) {
G.minuteVariant = MinuteVariant::Off;
} else if (G.UhrtypeDef != Ger11x11Frame &&
G.minuteVariant == MinuteVariant::Row) {
G.minuteVariant = MinuteVariant::Off;
} else if (usedUhrType->rowsWordMatrix() != 11 &&
G.minuteVariant == MinuteVariant::Corners) {
G.minuteVariant = MinuteVariant::LED4x;
}
}

Expand Down Expand Up @@ -849,6 +852,7 @@ void ClockWork::loop(struct tm &tm) {
config["hasZwanzig"] = usedUhrType->hasZwanzig();
config["hasWeatherLayout"] = usedUhrType->hasWeatherLayout();
config["hasSecondsFrame"] = usedUhrType->hasSecondsFrame();
config["numOfRows"] = usedUhrType->rowsWordMatrix();
serializeJson(config, str);
Serial.print("Sending Payload:");
Serial.println(str);
Expand Down
13 changes: 12 additions & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,15 @@
* Valid values BOOT_LEDSWEEP [true, false]
*/
#define BOOT_SHOWIP true
#define BOOT_LEDSWEEP false
#define BOOT_LEDSWEEP false

//--------------------------------------------------------------------------
// Displaying Option for Minutes
//--------------------------------------------------------------------------
/*
*
* Valid values [only one #define option]
*/
//#define MINUTE_Off
#define MINUTE_LED4x
//#define MINUTE_LED7x
11 changes: 10 additions & 1 deletion src/Wortuhr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,16 @@ void setup() {
G.effectSpeed = 10;
G.client_nr = 0;
G.secondVariant = SecondVariant::Off;
G.minuteVariant = MinuteVariant::Corners;
// C++23 #elifdef doesn't work yet
#ifdef MINUTE_Off
G.minuteVariant = MinuteVariant::Off;
#endif
#ifdef MINUTE_4xLED
G.minuteVariant = MinuteVariant::LED7x;
#endif
#ifdef MINUTE_7xLED
G.minuteVariant = MinuteVariant::LED7x;
#endif
G.ldr = 0;
G.ldrCal = 0;
strcpy(G.openWeatherMap.cityid, "");
Expand Down
7 changes: 4 additions & 3 deletions webpage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,10 @@ <h2>Minuten</h2>
<div class="pure-control-group">
<label for="show-minutes">Minuten Anzeigemodus</label><select name="show-minutes" id="show-minutes" size="1">
<option value="0" selected>Aus</option>
<option value="1">Normal</option>
<option value="2">Reihe</option>
<option value="3">In Worten</option>
<option value="1">Normal (4xLED)</option>
<option value="2">Normal (7xLED)</option>
<option value="3">Ecken</option>
<option value="4">In Worten</option>
</select>
</div>
</fieldset>
Expand Down
4 changes: 2 additions & 2 deletions webpage/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ function initWebsocket() {
enableSpecific("specific-layout-5", data.hasWeatherLayout);
enableSpecific("specific-layout-6", data.UhrtypeDef === 10); // EN10x11
enableSpecific("specific-colortype-4", data.colortype === 4);
removeSpecificOption("show-minutes", "2", data.UhrtypeDef !== 4); // MinuteVariant "Row"
removeSpecificOption("show-minutes", "3", data.UhrtypeDef !== 9); // MinuteVariant "In Words"
removeSpecificOption("show-minutes", "3", data.numOfRows !== 11); // MinuteVariant "Corners" only for DE11x11 Variants
removeSpecificOption("show-minutes", "4", data.UhrtypeDef !== 9); // MinuteVariant "In Words"

autoLdrEnabled = data.autoLdrEnabled;
$("#auto-ldr-enabled").set("value", autoLdrEnabled);
Expand Down

0 comments on commit 710a1f8

Please sign in to comment.