Renaming, refactoring.
This commit is contained in:
9
include/ota_functions.h
Normal file
9
include/ota_functions.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef OTA_FUNCTIONS_H
|
||||
#define OTA_FUNCTIONS_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
void handleOTA();
|
||||
void setupOTA(String hostname);
|
||||
|
||||
#endif /* OTA_FUNCTIONS_H */
|
||||
@@ -1,9 +0,0 @@
|
||||
#ifndef OTAFUNCTIONS_H
|
||||
#define OTAFUNCTIONS_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
void handleOTA();
|
||||
void setupOTA(String hostname);
|
||||
|
||||
#endif /* OTAFUNCTIONS_H */
|
||||
@@ -15,7 +15,7 @@
|
||||
#define PONG_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "ledmatrix.h"
|
||||
#include "led_matrix.h"
|
||||
#include "udp_logger.h"
|
||||
|
||||
#ifdef DEBOUNCE_TIME
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef WORDCLOCK_FUNCTIONS_H
|
||||
#define WORDCLOCK_FUNCTIONS_H
|
||||
#ifndef RENDER_FUNCTIONS_H
|
||||
#define RENDER_FUNCTIONS_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#define snake_h
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "ledmatrix.h"
|
||||
#include "led_matrix.h"
|
||||
#include "udp_logger.h"
|
||||
|
||||
#ifdef DEBOUNCE_TIME
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#define TETRIS_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "ledmatrix.h"
|
||||
#include "led_matrix.h"
|
||||
#include "udp_logger.h"
|
||||
|
||||
#ifdef DEBOUNCE_TIME
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include "ledmatrix.h"
|
||||
#include "led_matrix.h"
|
||||
#include "udp_logger.h"
|
||||
|
||||
extern UDPLogger logger;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <Arduino.h>
|
||||
#include <ArduinoOTA.h>
|
||||
#include "otafunctions.h"
|
||||
#include "ota_functions.h"
|
||||
|
||||
// setup Arduino OTA
|
||||
void setupOTA(String hostname)
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <Arduino.h>
|
||||
#include "render_functions.h"
|
||||
#include "ledmatrix.h"
|
||||
#include "led_matrix.h"
|
||||
#include "udp_logger.h"
|
||||
|
||||
extern LEDMatrix led_matrix;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user