84 lines
2.2 KiB
C
84 lines
2.2 KiB
C
#ifndef WORDCLOCK_ESP8266_H
|
|
#define WORDCLOCK_ESP8266_H
|
|
|
|
#include <Arduino.h>
|
|
#include <ESP8266WebServer.h>
|
|
#include "led_matrix.h"
|
|
#include "udp_logger.h"
|
|
|
|
#define RANGE_LIMIT(X, MIN, MAX) (((X) < (MIN)) ? (MIN) : (((X) > (MAX)) ? (MAX) : (X)))
|
|
#define RANGE_LIMIT_SUB(X, MIN, MAX, SUB) (((X) < (MIN)) ? (SUB) : (((X) > (MAX)) ? (SUB) : (X)))
|
|
|
|
#define EEPROM_SIZE (sizeof(EepromLayout_st) / sizeof(uint8_t))
|
|
|
|
typedef struct
|
|
{
|
|
int start_hour;
|
|
int start_min;
|
|
int end_hour;
|
|
int end_min;
|
|
} NightModeTimes_st;
|
|
|
|
typedef struct
|
|
{
|
|
uint8_t red;
|
|
uint8_t green;
|
|
uint8_t blue;
|
|
uint8_t alpha;
|
|
} Color_st;
|
|
|
|
typedef struct
|
|
{
|
|
uint8_t static_brightness; // user-controlled static brightness of LEDs
|
|
uint8_t dyn_brightness_min; // user-controlled min brightness of LEDs
|
|
uint8_t dyn_brightness_max; // user-controlled max brightness of LEDs
|
|
bool flg_dynamic_brightness; // flag if user wants to use daytime dynamic brightness
|
|
} Brightness_st;
|
|
|
|
typedef struct
|
|
{
|
|
NightModeTimes_st night_mode_times;
|
|
Brightness_st brightness_values;
|
|
Color_st color_values;
|
|
} EepromLayout_st;
|
|
|
|
typedef enum
|
|
{
|
|
ST_CLOCK,
|
|
ST_DICLOCK,
|
|
ST_SPIRAL,
|
|
ST_TETRIS,
|
|
ST_SNAKE,
|
|
ST_PINGPONG,
|
|
ST_HEARTS,
|
|
NUM_STATES
|
|
} ClockState_en;
|
|
|
|
String leading_zero2digit(int value);
|
|
uint8_t calculate_dynamic_brightness(uint8_t min_brightness, uint8_t max_brightness, int hours, int minutes, bool summertime);
|
|
uint8_t update_brightness(void);
|
|
void check_night_mode(void);
|
|
void check_wifi_status(void);
|
|
void draw_main_color(void);
|
|
void handle_button(void);
|
|
void handle_command(void);
|
|
void handle_current_state(void);
|
|
void handle_data_request(void);
|
|
void handle_led_direct(void);
|
|
void limit_value_ranges(void);
|
|
void log_time(tm local_time);
|
|
void ntp_time_update(uint32 *last_ntp_update_us);
|
|
void ntp_time_update(uint32 *last_ntp_update_us);
|
|
void on_state_entry(uint8_t state);
|
|
void read_settings_from_EEPROM(void);
|
|
void reset_wifi_credentials(void);
|
|
void send_heartbeat(void);
|
|
void set_dynamic_brightness(bool state);
|
|
void set_main_color(uint8_t red, uint8_t green, uint8_t blue);
|
|
void set_night_mode(bool on);
|
|
void state_change(uint8_t newState);
|
|
void update_matrix(void);
|
|
void write_settings_to_EEPROM(void);
|
|
|
|
#endif /* WORDCLOCK_ESP8266_H */
|