Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several improvements to SecondsFrame #514

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion include/Uhr.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ uint32_t lastFrontMatrix[MAX_ROW_SIZE] = {0};
uint8_t minuteArray = 0; /* Using a byte as a per bit array */
uint8_t lastMinuteArray = 0;
uint16_t minutePixelArray[4] = {0};
uint64_t frameArray = 0;
bool frameArray[200] = {false};
bool parametersChanged = false;
bool layoutChanged = false;
bool colorChangedByWebsite = false;
Expand Down Expand Up @@ -270,6 +270,7 @@ enum ClockType {
Ger10x11Clock = 6,
Ger10x11schwaebisch = 20,
Ger10x11Nero = 11,
Ger10x11NeroFrame = 24,
Ger11x11 = 3,
Ger11x11V2 = 8,
Ger11x11V3 = 14,
Expand Down
46 changes: 46 additions & 0 deletions include/Uhrtypes/DE10x11.nero.frame.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#pragma once

#include "DE10x11.nero.hpp"

/*
* Layout Front
* COL
* X 9 8 7 6 5 4 3 2 1 0
* ROW + - - - - - - - - - - -
* 0 | E S J I S T L F Ü N F
* 1 | Z E H N Z W A N Z I G
* 2 | D R E I V I E R T E L
* 3 | T F N A C H V O R J M
* 4 | H A L B X Z W Ö L F T
* 5 | Z W E I N S I E B E N
* 6 | L D R E I C I F Ü N F
* 7 | E L F N E U N V I E R
* 8 | U A C H T Z E H N S I
* 9 | C S E C H S T L U H R
*/

class De10x11NeroFrame_t : public De10x11Nero_t {
public:
virtual inline const uint8_t numPixelsFrameMatrix() { return 120; }

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

virtual const bool hasSecondsFrame() override { return true; }

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

virtual const uint16_t getFrameMatrixIndex(uint16_t index) override {
return 114 + index;
};

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

virtual const void getMinuteArray(uint16_t *returnArr,
uint8_t col) override {
for (uint8_t i = 0; i < 4; i++) {
returnArr[i] = 110 + i;
}
};
};

De10x11NeroFrame_t _de10x11NeroFrame;
8 changes: 5 additions & 3 deletions include/clockWork.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ iUhrType *ClockWork::getPointer(uint8_t type) {
return &_de10x11Clock;
case Ger10x11Nero:
return &_de10x11Nero;
case Ger10x11NeroFrame:
return &_de10x11NeroFrame;
case Nl10x11:
return &_nl10x11;
case Ger11x11:
Expand Down Expand Up @@ -1236,23 +1238,23 @@ void ClockWork::loop(struct tm &tm) {
case COMMAND_SET_TIME_MANUAL: {
eeprom::write();
led.clear();
frameArray = 0;
memset(frameArray, false, sizeof(frameArray));
parametersChanged = true;
break;
}

case COMMAND_SET_LAYOUT_VARIANT: {
eeprom::write();
led.clear();
frameArray = 0;
memset(frameArray, false, sizeof(frameArray));
layoutChanged = true;
break;
}

case COMMAND_SET_SETTING_SECOND: {
eeprom::write();
led.clear();
frameArray = 0;
memset(frameArray, false, sizeof(frameArray));
G.progInit = true;
parametersChanged = true;
break;
Expand Down
18 changes: 6 additions & 12 deletions include/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,14 @@ SecondsFrame::SecondsFrame(const uint8_t num) {

void SecondsFrame::setInitFrameSector() {
switch (G.secondVariant) {

case SecondVariant::FrameSectorToggle:
if (_minute % 2 == 1) {
for (uint8_t i = 0; i <= numFramePixels; i++) {
frameArray |= 1ULL << i; // Setting Bits
}
memset(frameArray, true, sizeof(numFramePixels));
}
/* intentianally no break */
case SecondVariant::FrameSector:
for (uint8_t i = 0; i <= _secondFrame; i++) {
frameArray ^= 1ULL << i; // Toggling Bits
frameArray[i] = !frameArray[i];
}
break;
default:
Expand All @@ -81,36 +78,33 @@ void SecondsFrame::frameLogic() {
/*Every full minute */
if (_secondFrame == numFramePixels) {
led.clearFrame();
frameArray = 0;
memset(frameArray, false, sizeof(frameArray));
setInitFrameSector();
_secondFrame = 0;
}

/*Every (Frame-)Second*/
if (lastSecondFrame != _secondFrame) {

switch (G.secondVariant) {
case SecondVariant::FrameDot:
frameArray |= 1ULL << _secondFrame; // Setting Bit to 1
frameArray[_secondFrame] = true;
if (_secondFrame != 0) {
frameArray &= ~(1ULL << (_secondFrame - 1)); // Setting Bit to 0
frameArray[_secondFrame - 1] = false;
}
break;
case SecondVariant::FrameSector:
case SecondVariant::FrameSectorToggle:
frameArray ^= 1ULL << _secondFrame; // Toggle Bit
frameArray[_secondFrame] = !frameArray[_secondFrame];
break;
default:
break;
}

lastSecondFrame = _secondFrame;
}

/*Update LEDs corrosponding with mode Clockwork*/
if (G.prog == 0 && G.conf == 0) {
led.clear();
parametersChanged = true;
G.prog = COMMAND_MODE_WORD_CLOCK;
}
}
Expand Down
5 changes: 3 additions & 2 deletions include/led.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,11 @@ void Led::setbyMinuteArray(ColorPosition colorPosition) {
void Led::setbySecondArray(ColorPosition colorPosition) {
HsbColor displayedColor;
getColorbyPositionWithAppliedBrightness(displayedColor, colorPosition);
const uint8_t offesetSecondsFrame =
(usedUhrType->numPixelsFrameMatrix() / 8);

const uint8_t offesetSecondsFrame = 5;
for (uint8_t i = 0; i < usedUhrType->numPixelsFrameMatrix(); i++) {
if ((frameArray >> i) & 1U) {
if (frameArray[i]) {
if (i < usedUhrType->numPixelsFrameMatrix() - offesetSecondsFrame) {
setPixel(usedUhrType->getFrameMatrixIndex(i) +
offesetSecondsFrame,
Expand Down
4 changes: 2 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ lib_deps =
makuna/NeoPixelBus@^2.7.6
bblanchon/ArduinoJson@^6.17.2
links2004/WebSockets@^2.4.1
adafruit/RTClib@^1.11.2
adafruit/RTClib@^1.11.2
knolleary/PubSubClient@^2.8.0
https://github.com/tzapu/WiFiManager#v2.0.17
claws/BH1750@^1.3.0
Expand All @@ -71,4 +71,4 @@ lib_deps =
knolleary/PubSubClient@^2.8.0
https://github.com/tzapu/WiFiManager#v2.0.17
claws/BH1750@^1.3.0
extra_scripts = pre:extra_scripts.py
extra_scripts = pre:extra_scripts.py
1 change: 1 addition & 0 deletions webpage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ <h2 data-i18next="view.front.h2"></h2>
<option value="6" data-i18next="view.front.de-10-11-clock"></option>
<option value="20" data-i18next="view.front.de-10-11-schwaebisch"></option>
<option value="11" data-i18next="view.front.de-10-11-nero"></option>
<option value="24" data-i18next="view.front.de-10-11-nero-frame"></option>
<option value="3" data-i18next="view.front.de-11-11"></option>
<option value="8" data-i18next="view.front.de-11-11-v2"></option>
<option value="14" data-i18next="view.front.de-11-11-v3"></option>
Expand Down
1 change: 1 addition & 0 deletions webpage/language/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ let TRANSLATION_DE_DE = {
"de-10-11-vertical": "🇩🇪 10 × 11 Vertikal",
"de-10-11-clock": "🇩🇪 10 × 11 Uhr",
"de-10-11-nero": "🇩🇪 10 × 11 Nero",
"de-10-11-nero-frame": "🇩🇪 10 × 11 Nero Rahmen",
"de-10-11-schwaebisch": "🇩🇪 10 × 11 Schwäbisch",
"de-11-11": "🇩🇪 11 × 11",
"de-11-11-v2": "🇩🇪 11 × 11 Version 2",
Expand Down
1 change: 1 addition & 0 deletions webpage/language/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ let TRANSLATION_EN_US = {
"de-10-11-vertical": "🇩🇪 10 × 11 Vertical",
"de-10-11-clock": "🇩🇪 10 × 11 Clock",
"de-10-11-nero": "🇩🇪 10 × 11 Nero",
"de-10-11-nero-frame": "🇩🇪 10 × 11 Nero Frame",
"de-10-11-schwaebisch": "🇩🇪 10 × 11 Swabian Style",
"de-11-11": "🇩🇪 11 × 11",
"de-11-11-v2": "🇩🇪 11 × 11 Version 2",
Expand Down
1 change: 1 addition & 0 deletions webpage/language/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ let TRANSLATION_ES = {
"de-10-11-vertical": "🇩🇪 10 × 11 Vertikal",
"de-10-11-clock": "🇩🇪 10 × 11 Uhr",
"de-10-11-nero": "🇩🇪 10 × 11 Nero",
"de-10-11-nero-frame": "🇩🇪 10 × 11 Nero Rahmen",
"de-10-11-schwaebisch": "🇩🇪 10 × 11 Estilo suabo",
"de-11-11": "🇩🇪 11 × 11",
"de-11-11-v2": "🇩🇪 11 × 11 Version 2",
Expand Down
1 change: 1 addition & 0 deletions webpage/language/hu.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ let TRANSLATION_HU = {
"de-10-11-vertical": "🇩🇪 10 × 11 függőleges",
"de-10-11-clock": "🇩🇪 10 × 11 óra",
"de-10-11-nero": "🇩🇪 10 × 11 Nero",
"de-10-11-nero-frame": "🇩🇪 10 × 11 Nero keretek",
"de-10-11-schwaebisch": "🇩🇪 10 × 11 sváb stílus",
"de-11-11": "🇩🇪 11 × 11",
"de-11-11-v2": "🇩🇪 11 × 11 verzió 2",
Expand Down
1 change: 1 addition & 0 deletions webpage/language/it.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ let TRANSLATION_IT = {
"de-10-11-vertical": "🇩🇪 10 × 11 Vertikal",
"de-10-11-clock": "🇩🇪 10 × 11 Uhr",
"de-10-11-nero": "🇩🇪 10 × 11 Nero",
"de-10-11-nero-frame": "🇩🇪 10 × 11 Nero Rahmen",
"de-10-11-schwaebisch": "🇩🇪 10 × 11 Stile svevo",
"de-11-11": "🇩🇪 11 × 11",
"de-11-11-v2": "🇩🇪 11 × 11 Version 2",
Expand Down
1 change: 1 addition & 0 deletions webpage/language/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ let TRANSLATION_NL = {
"de-10-11-vertical": "🇩🇪 10 × 11 Verticaal",
"de-10-11-clock": "🇩🇪 10 × 11 Clock",
"de-10-11-nero": "🇩🇪 10 × 11 Nero",
"de-10-11-nero-frame": "🇩🇪 10 × 11 Nero Frame",
"de-10-11-schwaebisch": "🇩🇪 10 × 11 Zwabische stijl",
"de-11-11": "🇩🇪 11 × 11",
"de-11-11-v2": "🇩🇪 11 × 11 Versie 2",
Expand Down
1 change: 1 addition & 0 deletions webpage/language/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ let TRANSLATION_RU = {
"de-10-11-vertical": "🇩🇪 10 × 11 Вертикальный",
"de-10-11-clock": "🇩🇪 10 × 11 Часы",
"de-10-11-nero": "🇩🇪 10 × 11 Nero",
"de-10-11-nero-frame": "🇩🇪 10 × 11 Nero Rahmen",
"de-10-11-schwaebisch": "🇩🇪 10 × 11 Швабия",
"de-11-11": "🇩🇪 11 × 11",
"de-11-11-v2": "🇩🇪 11 × 11 V2",
Expand Down