Major refactoring of EEPROM r/w. Add dynamic brightness functionality.

This commit is contained in:
2023-10-31 16:17:27 +01:00
parent c2b8cc46a3
commit e8168ad40f
5 changed files with 421 additions and 314 deletions

View File

@@ -10,34 +10,29 @@
#define NTP_SERVER_URL "de.pool.ntp.org" // NTP server address
#define HOSTNAME (String("wordclock")) // Local hostname
#define LOGGER_MULTICAST_IP (IPAddress(230, 120, 10, 2)) // IP for UDP server
#define LOGGER_MULTICAST_PORT 8123 // Port for UDP server
#define HTTP_PORT 80 // Standard HTTP port
#define LOGGER_MULTICAST_PORT (8123) // Port for UDP server
#define HTTP_PORT (80) // Standard HTTP port
// EEPROM layout
typedef enum
{
ADR_NM_START_H = 0,
ADR_NM_END_H = 4,
ADR_NM_START_M = 8,
ADR_NM_END_M = 12,
ADR_BRIGHTNESS = 16,
ADR_MC_RED = 20,
ADR_MC_GREEN = 22,
ADR_MC_BLUE = 24,
EEPROM_SIZE = 30
} EepromLayout_en;
// ESP8266 Pins
#define NEOPIXEL_PIN (14) // pin to which the NeoPixels are attached
#define BUTTON_PIN (5) // pin to which the button is attached
#define NEOPIXEL_PIN 14 // pin to which the NeoPixels are attached
#define BUTTON_PIN 5 // pin to which the button is attached
// Time limits
#define HOUR_MAX (23)
#define MINUTE_MAX (59)
#define MINUTES_IN_HOUR (60)
#define HOURS_IN_DAY (24)
// Night mode
#define NIGHTMODE_START_HR 23
#define NIGHTMODE_START_MIN 0
#define NIGHTMODE_END_HR 7
#define NIGHTMODE_END_MIN 0
#define NIGHTMODE_START_HR (23)
#define NIGHTMODE_START_MIN (0)
#define NIGHTMODE_END_HR (7)
#define NIGHTMODE_END_MIN (0)
// Timings in us
#define PERIOD_ANIMATION_US (200 * 1000) // 200ms
#define PERIOD_CLOCK_UPDATE_US (1 * 1000 * 1000) // 1s
#define PERIOD_HEARTBEAT_US (1 * 1000 * 1000) // 1s
#define PERIOD_MATRIX_UPDATE_US (100 * 1000) // 100ms
#define PERIOD_NIGHTMODE_CHECK_US (20 * 1000 * 1000) // 20s
@@ -46,7 +41,6 @@ typedef enum
#define PERIOD_SNAKE_US (50 * 1000) // 50ms
#define PERIOD_STATE_CHANGE_US (10 * 1000 * 1000) // 10s
#define PERIOD_TETRIS_US (50 * 1000) // 50ms
#define PERIOD_TIME_VISU_UPDATE_US (1 * 1000 * 1000) // 1s
#define TIMEOUT_LEDDIRECT_US (5 * 1000 * 1000) // 5s
#define SHORT_PRESS_US (100 * 1000) // 100ms
@@ -54,16 +48,21 @@ typedef enum
#define VERY_LONG_PRESS_US (10 * 1000 * 1000) // 10s
// Current limit
#define CURRENT_LIMIT_LED 2500 // limit the total current consumed by LEDs (mA)
#define CURRENT_LIMIT_LED (2500) // limit the total current consumed by LEDs (mA)
// Brightness ranges range: 0 - 255
#define DEFAULT_BRIGHTNESS (40)
#define MIN_BRIGHTNESS (10)
#define MAX_BRIGHTNESS UINT8_MAX
// LED smoothing
#define DEFAULT_SMOOTHING_FACTOR 0.5
#define DEFAULT_SMOOTHING_FACTOR (0.5f)
// Number of colors in colors array
#define NUM_COLORS 7
#define NUM_COLORS (7)
// LED matrix size
#define MATRIX_WIDTH 11
#define MATRIX_HEIGHT 11
#define MATRIX_WIDTH (11)
#define MATRIX_HEIGHT (11)
#endif /* WORDCLOCK_CONSTANTS_H */