diff --git a/include/ledmatrix.h b/include/led_matrix.h similarity index 100% rename from include/ledmatrix.h rename to include/led_matrix.h diff --git a/include/ota_functions.h b/include/ota_functions.h new file mode 100644 index 0000000..3940b06 --- /dev/null +++ b/include/ota_functions.h @@ -0,0 +1,9 @@ +#ifndef OTA_FUNCTIONS_H +#define OTA_FUNCTIONS_H + +#include + +void handleOTA(); +void setupOTA(String hostname); + +#endif /* OTA_FUNCTIONS_H */ diff --git a/include/otafunctions.h b/include/otafunctions.h deleted file mode 100644 index d0755e7..0000000 --- a/include/otafunctions.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef OTAFUNCTIONS_H -#define OTAFUNCTIONS_H - -#include - -void handleOTA(); -void setupOTA(String hostname); - -#endif /* OTAFUNCTIONS_H */ diff --git a/include/pong.h b/include/pong.h index 33710d9..d06f888 100644 --- a/include/pong.h +++ b/include/pong.h @@ -15,7 +15,7 @@ #define PONG_H #include -#include "ledmatrix.h" +#include "led_matrix.h" #include "udp_logger.h" #ifdef DEBOUNCE_TIME diff --git a/include/render_functions.h b/include/render_functions.h index 64d59a7..154e533 100644 --- a/include/render_functions.h +++ b/include/render_functions.h @@ -1,5 +1,5 @@ -#ifndef WORDCLOCK_FUNCTIONS_H -#define WORDCLOCK_FUNCTIONS_H +#ifndef RENDER_FUNCTIONS_H +#define RENDER_FUNCTIONS_H #include @@ -8,4 +8,4 @@ String split(String s, char parser, int index); String time_to_string(uint8_t hours, uint8_t minutes); void draw_minute_indicator(uint8_t minutes, uint32_t color); -#endif /* WORDCLOCK_FUNCTIONS_H */ +#endif /* RENDER_FUNCTIONS_H */ diff --git a/include/snake.h b/include/snake.h index b6509b8..f8dcd93 100644 --- a/include/snake.h +++ b/include/snake.h @@ -14,7 +14,7 @@ #define snake_h #include -#include "ledmatrix.h" +#include "led_matrix.h" #include "udp_logger.h" #ifdef DEBOUNCE_TIME diff --git a/include/tetris.h b/include/tetris.h index e6eb595..02e3aaa 100644 --- a/include/tetris.h +++ b/include/tetris.h @@ -14,7 +14,7 @@ #define TETRIS_H #include -#include "ledmatrix.h" +#include "led_matrix.h" #include "udp_logger.h" #ifdef DEBOUNCE_TIME diff --git a/include/wordclock_esp8266.h b/include/wordclock_esp8266.h index 64f8efd..83228ac 100644 --- a/include/wordclock_esp8266.h +++ b/include/wordclock_esp8266.h @@ -3,7 +3,7 @@ #include #include -#include "ledmatrix.h" +#include "led_matrix.h" #include "udp_logger.h" extern UDPLogger logger; diff --git a/src/connectivity/otafunctions.cpp b/src/connectivity/ota_functions.cpp similarity index 98% rename from src/connectivity/otafunctions.cpp rename to src/connectivity/ota_functions.cpp index 10dcda7..18120cd 100644 --- a/src/connectivity/otafunctions.cpp +++ b/src/connectivity/ota_functions.cpp @@ -1,6 +1,6 @@ #include #include -#include "otafunctions.h" +#include "ota_functions.h" // setup Arduino OTA void setupOTA(String hostname) diff --git a/src/matrix/animation_functions.cpp b/src/matrix/animation_functions.cpp index afdbd9e..67e9a1c 100644 --- a/src/matrix/animation_functions.cpp +++ b/src/matrix/animation_functions.cpp @@ -2,7 +2,7 @@ #include "animation_functions.h" #include "wordclock_constants.h" #include "udp_logger.h" -#include "ledmatrix.h" +#include "led_matrix.h" extern UDPLogger logger; extern LEDMatrix led_matrix; diff --git a/src/matrix/ledmatrix.cpp b/src/matrix/led_matrix.cpp similarity index 98% rename from src/matrix/ledmatrix.cpp rename to src/matrix/led_matrix.cpp index b63c4eb..b882882 100644 --- a/src/matrix/ledmatrix.cpp +++ b/src/matrix/led_matrix.cpp @@ -1,4 +1,4 @@ -#include "ledmatrix.h" +#include "led_matrix.h" #include "own_font.h" #include "wordclock_constants.h" @@ -21,7 +21,7 @@ const uint32_t colors_24bit[NUM_COLORS] = { * @param mybrightness the initial brightness of the leds * @param mylogger pointer to the UDPLogger object */ -LEDMatrix::LEDMatrix(Adafruit_NeoMatrix * matrix, uint8_t brightness, UDPLogger * logger) +LEDMatrix::LEDMatrix(Adafruit_NeoMatrix *matrix, uint8_t brightness, UDPLogger *logger) { _neomatrix = matrix; _brightness = brightness; diff --git a/src/matrix/render_functions.cpp b/src/matrix/render_functions.cpp index 9e0824a..9c5afef 100644 --- a/src/matrix/render_functions.cpp +++ b/src/matrix/render_functions.cpp @@ -1,6 +1,6 @@ #include #include "render_functions.h" -#include "ledmatrix.h" +#include "led_matrix.h" #include "udp_logger.h" extern LEDMatrix led_matrix; diff --git a/src/wordclock_esp8266.cpp b/src/wordclock_esp8266.cpp index f351c4e..4cc254a 100644 --- a/src/wordclock_esp8266.cpp +++ b/src/wordclock_esp8266.cpp @@ -37,11 +37,11 @@ #include "pong.h" #include "snake.h" #include "tetris.h" -#include "ledmatrix.h" +#include "led_matrix.h" #include "littlefs_wrapper.h" #include "base64_wrapper.h" // copied from https://github.com/Xander-Electronics/Base64 #include "ntp_client_plus.h" -#include "otafunctions.h" +#include "ota_functions.h" #include "udp_logger.h" #include "wordclock_constants.h" #include "render_functions.h" @@ -323,23 +323,23 @@ void loop() void update_state_machine() { - unsigned long current_time = millis(); + unsigned long current_time_ms = millis(); - if (state_auto_change && (current_time - last_state_change > PERIOD_STATE_CHANGE) && !night_mode) + if (state_auto_change && (current_time_ms - last_state_change > PERIOD_STATE_CHANGE) && !night_mode) { // increment state variable and trigger state change state_change((current_state + 1) % NUM_STATES); // save last automatic state change - last_state_change = current_time; + last_state_change = current_time_ms; } } void handle_current_state() { - unsigned long current_time = millis(); + unsigned long current_time_ms = millis(); // handle mode behaviours (trigger loopCycles of different modes depending on current mode) - if (!night_mode && ((current_time - last_step) > PERIODS[state_auto_change][current_state]) && ((current_time - last_led_direct) > TIMEOUT_LEDDIRECT)) + if (!night_mode && ((current_time_ms - last_step) > PERIODS[state_auto_change][current_state]) && ((current_time_ms - last_led_direct) > TIMEOUT_LEDDIRECT)) { switch (current_state) { @@ -428,13 +428,13 @@ void handle_current_state() */ void update_matrix() { - unsigned long current_time = millis(); + unsigned long current_time_ms = millis(); // periodically write colors to matrix - if ((current_time - last_animation_step) > PERIOD_MATRIX_UPDATE) + if ((current_time_ms - last_animation_step) > PERIOD_MATRIX_UPDATE) { led_matrix.draw_on_matrix_smooth(filter_factor); - last_animation_step = current_time; + last_animation_step = current_time_ms; } } @@ -445,13 +445,15 @@ void update_matrix() */ void send_heartbeat() { - unsigned long current_time = millis(); + unsigned long current_time_ms = millis(); // send regularly heartbeat messages via UDP multicast - if ((current_time - last_heartbeat) > PERIOD_HEARTBEAT) + if ((current_time_ms - last_heartbeat) > PERIOD_HEARTBEAT) { - logger.log_string("Heartbeat, state: " + state_names[current_state] + ", FreeHeap: " + ESP.getFreeHeap() + ", HeapFrag: " + ESP.getHeapFragmentation() + ", MaxFreeBlock: " + ESP.getMaxFreeBlockSize() + "\nCounter: " + dbg_counter + " , Hours: " + (float)(dbg_counter) / 3600.0 + "\n"); // TODO CHANGE - last_heartbeat = current_time; + logger.log_string("Heartbeat, state: " + state_names[current_state] + ", FreeHeap: " + ESP.getFreeHeap() + \ + ", HeapFrag: " + ESP.getHeapFragmentation() + ", MaxFreeBlock: " + ESP.getMaxFreeBlockSize() + "\nCounter: " + \ + dbg_counter + " , Hours: " + (float)(dbg_counter) / 3600.0 + "\n"); // TODO CHANGE + last_heartbeat = current_time_ms; // Check wifi status (only if no apmode) if (WiFi.status() != WL_CONNECTED) @@ -471,10 +473,10 @@ void send_heartbeat() */ void check_night_mode() { - unsigned long current_time = millis(); + unsigned long current_time_ms = millis(); // check if nightmode need to be activated - if ((current_time - last_nightmode_check) > PERIOD_NIGHTMODE_CHECK) + if ((current_time_ms - last_nightmode_check) > PERIOD_NIGHTMODE_CHECK) { int hours = ntp_client.getHours24(); int minutes = ntp_client.getMinutes(); @@ -487,7 +489,7 @@ void check_night_mode() { set_night_mode(false); } - last_nightmode_check = current_time; + last_nightmode_check = current_time_ms; } } @@ -498,10 +500,10 @@ void check_night_mode() */ void ntp_time_update() { - unsigned long current_time = millis(); + unsigned long current_time_ms = millis(); // NTP time update - if ((current_time - last_ntp_update) > PERIOD_NTP_UPDATE) + if ((current_time_ms - last_ntp_update) > PERIOD_NTP_UPDATE) { int ntp_retval = ntp_client.updateNTP(); switch (ntp_retval)