From 9c5f4e0c7e5dae641326a1a8e9ad79598e979b11 Mon Sep 17 00:00:00 2001 From: Arturo Silvelo Date: Fri, 19 Jul 2024 14:15:40 +0200 Subject: [PATCH] fix: show pixel logs --- include/LedManager.h | 25 +++++++++++++++++++------ include/TimeManager.h | 1 + src/LedManager.cpp | 16 ++++++++++++++++ src/SleepManager.cpp | 3 +++ src/TimeManager.cpp | 5 +++++ src/main.cpp | 3 ++- 6 files changed, 46 insertions(+), 7 deletions(-) diff --git a/include/LedManager.h b/include/LedManager.h index 9e57516..e5695ba 100644 --- a/include/LedManager.h +++ b/include/LedManager.h @@ -54,17 +54,30 @@ class LedManager { {true, true, true, true, true, true, false}, }; + /* bool minuteSegments[10][7] = { + {true, true, true, false, true, true, true}, + {false, false, true, false, false, false, true}, + {true, true, false, true, false, true, true}, + {false, true, true, true, false, true, true}, + {false, false, true, true, true, false, true}, + {false, true, true, true, true, true, false}, + {true, true, true, true, true, true, false}, + {false, false, true, false, false, true, true}, + {true, true, true, true, true, true, true}, + {false, true, true, true, true, true, true}, + }; */ + bool minuteSegments[10][7] = { {true, true, true, false, true, true, true}, {false, false, true, false, false, false, true}, - {true, true, false, true, false, true, true}, - {false, true, true, true, false, true, true}, - {false, false, true, true, true, false, true}, {false, true, true, true, true, true, false}, - {true, true, true, true, true, true, false}, - {false, false, true, false, false, true, true}, + {false, true, true, true, false, true, true}, + {true, false, true, true, false, true, true}, + {true, true, false, true, false, true, true}, + {true, true, false, true, true, true, true}, + {false, true, true, false, false, false, true}, {true, true, true, true, true, true, true}, - {false, true, true, true, true, true, true}, + {true, true, true, true, false, true, true}, }; }; diff --git a/include/TimeManager.h b/include/TimeManager.h index 6c39b95..35d2f55 100644 --- a/include/TimeManager.h +++ b/include/TimeManager.h @@ -13,6 +13,7 @@ class TimeManager { void update(); int getHours(); int getMinutes(); + int getSeconds(); String getFormattedTime(); void setTimeOffset(int offset); diff --git a/src/LedManager.cpp b/src/LedManager.cpp index 409651d..b9821a5 100644 --- a/src/LedManager.cpp +++ b/src/LedManager.cpp @@ -90,10 +90,25 @@ void LedManager::showHourDigit(int number, int startPixel, uint32_t color) { } void LedManager::showMinuteDigit(int number, int startPixel, uint32_t color) { + Serial.println("Number " + String(number)); for (int i = 0; i < MINUTE_SEGMENT; i++) { + Serial.println("Segment number " + String(i)); if (minuteSegments[number][i]) { + Serial.println("Power On pixels:"); for (int j = 0; j < ledsPerSegment; j++) { + Serial.print("["); + Serial.print(" Start Pixel: "); + Serial.print(startPixel); + Serial.print(" i: "); + Serial.print(i); + Serial.print(" ledsPerSegment: "); + Serial.print(ledsPerSegment); + Serial.print(" j: "); + Serial.print(j); + Serial.print("] - "); + Serial.print(startPixel + (i * ledsPerSegment) + j); minutesStrip.setPixelColor(startPixel + (i * ledsPerSegment) + j, color); + Serial.println(); } } else { for (int j = 0; j < ledsPerSegment; j++) { @@ -101,5 +116,6 @@ void LedManager::showMinuteDigit(int number, int startPixel, uint32_t color) { minutesStrip.Color(0, 0, 0)); } } + Serial.println(); } } diff --git a/src/SleepManager.cpp b/src/SleepManager.cpp index 998785d..d9b8926 100644 --- a/src/SleepManager.cpp +++ b/src/SleepManager.cpp @@ -22,6 +22,9 @@ void SleepManager::setHours() { } bool SleepManager::update(String actualDate) { + if (startHour == "" || endHour == "") { + return false; + } std::pair result = isCurrentTimeBetween(actualDate, startHour, endHour); return result.first; } diff --git a/src/TimeManager.cpp b/src/TimeManager.cpp index eb58462..acba9d5 100644 --- a/src/TimeManager.cpp +++ b/src/TimeManager.cpp @@ -37,6 +37,11 @@ int TimeManager::getMinutes() { return timeClient->getMinutes(); } +int TimeManager::getSeconds() { + Serial.println("Get Seconds"); + return timeClient->getSeconds(); +} + void TimeManager::setTimeOffset(int offset) { Serial.println("Change Time Offset"); timeClient->setTimeOffset(offset * 3600); diff --git a/src/main.cpp b/src/main.cpp index 6381b64..771e077 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -62,12 +62,13 @@ void loop() { timeManager.update(); bool isSleep = sleepManager.update(timeManager.getFormattedTime()); - Serial.println("Is Sleep:" + String(isSleep)); if (isSleep) { + Serial.println("Is Sleep:" + String(isSleep)); ledManager.end(); } else { int hours = timeManager.getHours(); int minutes = timeManager.getMinutes(); + // int minutes = timeManager.getSeconds(); Serial.println(timeManager.getFormattedTime());