#include "led_clockelements.hpp" class led_clock : protected elements { private: static const unsigned int PIN_BUZZER = D0; static const int TICK_FREQ = 40; static const int TICK_DLY = 13; static const int TOCK_FREQ = 15; static const int TOCK_DLY = 35; bool tick_not_tock = true; static const uint8_t PIN_PIXELS = D3; //6; static const uint16_t NUM_RING_PIXELS = 180U; static const uint8_t NUM_SECONDS = 60U; static const uint16_t NUM_RING_SEC_PIXELS = NUM_RING_PIXELS/NUM_SECONDS; static const uint8_t NUM_MINUTES = 60U; static const uint16_t NUM_RING_MIN_PIXELS = 1; static const uint16_t NUM_POINTER_PIXELS = 6U; static const uint16_t NUM_POINTERS = 12U; static const uint16_t NUM_POINTERS_PIXELS = NUM_POINTER_PIXELS * NUM_POINTERS; static const int16_t NUM_NUMBERS = 12U; const uint16_t NUM_NUMBER_PIXELS[NUM_NUMBERS] = {2,4,4,4,4,4,4,4,4,5,3,5}; const uint16_t NUM_NUMBERS_PIXELS = NUM_NUMBER_PIXELS[0] + NUM_NUMBER_PIXELS[1] + NUM_NUMBER_PIXELS[2] + NUM_NUMBER_PIXELS[3] + NUM_NUMBER_PIXELS[4] + NUM_NUMBER_PIXELS[5] + NUM_NUMBER_PIXELS[6] + NUM_NUMBER_PIXELS[7] + NUM_NUMBER_PIXELS[8] + NUM_NUMBER_PIXELS[9] + NUM_NUMBER_PIXELS[10] + NUM_NUMBER_PIXELS[11]; const uint16_t NUM_ALL_PIXELS = NUM_RING_PIXELS + NUM_POINTERS_PIXELS + NUM_NUMBERS_PIXELS; static const uint16_t NUM_INNER_RINGS = NUM_POINTER_PIXELS; static const uint16_t NUM_INNER_RING_PIXELS = NUM_POINTERS; unsigned int prv_second = 0 ; unsigned int prv_millis = 0 ; const hue_color COLOR_SECS = {HUE_GREEN,255,128}; const hue_color COLOR_HOURS = {0,0,128}; const hue_color COLOR_MINS = {HUE_BLUE,255,128}; const hue_color COLOR_NUMS = {0,0,255}; const hue_color COLOR_SECS_NOSYNC = {HUE_RED,255,128}; const hue_color COLOR_SECS_NOWIFI = {HUE_ORANGE,255,128}; const hue_color COLOR_NOWIFI = {HUE_RED,255,128}; const hue_color COLOR_WIFI = {HUE_GREEN,255,128}; const hue_color COLOR_OFFHOURS = {HUE_GREEN,255,64}; const hue_color COLOR_OFFMINS = {HUE_RED,255,128}; const hue_color COLOR_ACTMIN = {0,0,128}; enum color_type {COL_SECOND = 0, COL_SECOND_NOWIFI, COL_SECONDS_NOSYNC, COL_MINUTE, COL_HOUR, COL_NUM, COL_WIFI, COL_NOWIFI, COL_OFFHOURS, COL_OFFMINS, COL_ACTMIN, COL_LAST}; hue_color color[COL_LAST] = {COLOR_SECS, COLOR_SECS_NOWIFI , COLOR_SECS_NOSYNC , COLOR_MINS, COLOR_HOURS, COLOR_NUMS, COLOR_WIFI, COLOR_NOWIFI, COLOR_OFFHOURS, COLOR_OFFMINS, COLOR_ACTMIN}; CRGB * pixels; elements number[NUM_NUMBERS]; elements pointer[NUM_POINTERS]; elements ringsecs[NUM_SECONDS]; elements ringmins[NUM_MINUTES]; elements actmins[NUM_MINUTES]; unsigned int pixels_test; bool timeissynced = false; bool isconnected = false; color_type colorsecs = COL_SECOND; void init_ringmins(void); void init_ringsecs(void); void init_numbers(void); void init_pointers(void); void init_test_pixel(void); uint8_t last_value( uint8_t value, uint8_t minvalue, uint8_t maxvalue); uint8_t next_value( uint8_t value, uint8_t minvalue, uint8_t maxvalue); void show_second( uint8_t second); void show_hour( uint8_t hour, uint8_t minute); void show_minute( uint8_t minute ); void animate_new_minute( uint8_t minute , uint8_t second, uint8_t hour); void animate_new_hour( uint8_t minute , uint8_t second, uint8_t hour); void draw_minute_ring(uint8_t minnr); void draw_unused_minute_ring(uint8_t minnr); void tick_tock(); public: enum test_type {TEST_NONE=0, TEST_PIXELS=1, TEST_SECS=2, TEST_MINS=4,TEST_PTRS=8,TEST_NUMS=16, TEST_ALL = 31}; void init(unsigned test_at_start = TEST_NONE); void showtime(uint8_t hour, uint8_t minute, uint8_t second, bool time_synced, bool is_connected); void init_show_ring_wifi(); void show_ring_wifi( bool wifi); };