60 lines
No EOL
2.5 KiB
C++
60 lines
No EOL
2.5 KiB
C++
|
|
#include "led_clockelements.hpp"
|
|
|
|
|
|
|
|
class led_clock : protected elements
|
|
{
|
|
private:
|
|
|
|
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;
|
|
|
|
const hue_color COLOR_SECS = {HUE_GREEN,255,128}; // green
|
|
const hue_color COLOR_HOURS = {HUE_RED,255,128}; // red
|
|
const hue_color COLOR_MINS = {HUE_BLUE,255,128}; // blue
|
|
const hue_color COLOR_NUMS = {0,0,255}; // white
|
|
enum color_type {COL_SECOND = 0, COL_MINUTE, COL_HOUR, COL_NUM, COL_LAST};
|
|
hue_color color[COL_LAST] = {COLOR_SECS, COLOR_MINS, COLOR_HOURS, COLOR_NUMS};
|
|
|
|
|
|
CRGB * pixels;
|
|
|
|
elements number[NUM_NUMBERS];
|
|
elements pointer[NUM_POINTERS];
|
|
elements ringsecs[NUM_SECONDS];
|
|
elements ringmins[NUM_MINUTES];
|
|
|
|
unsigned int pixels_test;
|
|
|
|
void init_ringmins(void);
|
|
void init_ringsecs(void);
|
|
void init_numbers(void);
|
|
void init_pointers(void);
|
|
void init_test_pixel(void);
|
|
|
|
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);
|
|
|
|
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 init(hue_color color_secs, hue_color color_mins, hue_color color_hours, hue_color color_nums, unsigned test_at_start);
|
|
void showtime(uint8_t hour, uint8_t minute, uint8_t second);
|
|
|
|
}; |