#include #define PIN 4 Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800); uint32_t milli_color = strip.Color ( 0, 0, 8); //here are the colors in Red Blue Green change them to whatever u think looks nice uint32_t second_color = strip.Color ( 8, 8, 8); uint32_t hour_color = strip.Color ( 0, 0, 24); uint32_t minute_color = strip.Color ( 4, 4, 16); uint32_t off_color = strip.Color ( 0, 0, 0); class ClockPositions { public: uint8_t milli; uint8_t second; uint8_t minute; uint8_t hour; ClockPositions (); void update (); }; ClockPositions::ClockPositions() { milli = second = minute = hour = 0; //DateTime(__DATE__, __TIME__); } void ClockPositions::update() { second = map ((millis() % 60000), 0, 60000, 0, 12); milli = map ((millis() % 1000), 0, 1000, 0, 12); hour = map (10 % 12, 0, 12, 0, 12); minute = map (31 % 60, 0, 60, 0, 12); } class ClockSegments { public: ClockPositions &positions; Adafruit_NeoPixel &strip; ClockSegments (Adafruit_NeoPixel&, ClockPositions&); void draw (); void clear (); void add_color (uint8_t position, uint32_t color); uint32_t blend (uint32_t color1, uint32_t color2); }; ClockSegments::ClockSegments (Adafruit_NeoPixel& n_strip, ClockPositions& n_positions): strip (n_strip), positions (n_positions) { } void ClockSegments::draw() { clear(); add_color (positions.minute % 12, minute_color); add_color (positions.hour % 12, hour_color ); add_color (positions.second % 12, second_color); add_color (positions.milli % 12, milli_color); strip.show (); } void ClockSegments::add_color (uint8_t position, uint32_t color) { uint32_t blended_color = blend (strip.getPixelColor (position), color); /* Gamma mapping */ uint8_t r,b,g; r = (uint8_t)(blended_color >> 16), g = (uint8_t)(blended_color >> 8), b = (uint8_t)(blended_color >> 0); strip.setPixelColor (position, blended_color); } uint32_t ClockSegments::blend (uint32_t color1, uint32_t color2) { uint8_t r1,g1,b1; uint8_t r2,g2,b2; uint8_t r3,g3,b3; r1 = (uint8_t)(color1 >> 16), g1 = (uint8_t)(color1 >> 8), b1 = (uint8_t)(color1 >> 0); r2 = (uint8_t)(color2 >> 16), g2 = (uint8_t)(color2 >> 8), b2 = (uint8_t)(color2 >> 0); return strip.Color (constrain (r1+r2, 0, 255), constrain (g1+g2, 0, 255), constrain (b1+b2, 0, 255)); } void ClockSegments::clear () { for(uint16_t i=0; i