WordClock-Program to display time in words on WS2812B-LED-Stripe. With DS3231 RTC
Dependencies: PixelArray WordClock_de ds3231 mbed
Fork of mbed_ws2812b by
WordClock
Yet another wordclock...
Program for displaying time in (german) words on WS2812B LED-Matrix. Uses DS3231 RTC .
More fotos see:
https://photos.app.goo.gl/mSN6G145IdupbKv13
Diff: main.cpp
- Revision:
- 1:23535cfbf924
- Parent:
- 0:afb6ebe20c1f
- Child:
- 2:d39f37d64441
--- a/main.cpp Sat Dec 13 06:58:47 2014 +0000 +++ b/main.cpp Thu Nov 02 20:32:09 2017 +0000 @@ -1,64 +1,54 @@ +// Wordclock with WS2812-LED-Stripe +// with 11x10 LED-Matrix and 4 minute-LEDS /* - Neopixel LED controller for mbed LPC1114 (RAMdaccha) - - 2014/12/13 by morecat_lab +ESKISTLFÜNF +ZEHNZWANZIG +DREIVIERTEL +TGNACHVORJM +HALBXZWÖLFP +ZWEINSIEBEN +KDREIRHFÜNF +ELFNEUNVIER +WACHTZEHNRS +BSECHSFMUHR + **** +*/ - This program depends on neopixel library. - http://developer.mbed.org/users/JacobBramley/code/PixelArray/ -*/ #include "mbed.h" #include "neopixel.h" -#include "LAMd.h" +#include "WordClock.h" -neopixel::Pixel pattern[] = { - {0x55, 0, 0xff}, // magenta - {0, 0, 0xff}, // blue - {0xaf, 0xaf, 0xaf}, // white - {0, 0xff, 0xff}, // cyan - {0xaf, 0xaf, 0}, // yellow - {0, 0xff, 0}, // greem - {0x2f, 0, 0}, // red -}; - -#define MAX_PATTERN (sizeof pattern / sizeof (struct neopixel::Pixel)) -#define MAX_INDEX (MAX_PATTERN *256) -#define NLED (4) -#define ONE_COLOR - void generate(neopixel::Pixel * out, uint32_t index, uintptr_t val) { -#ifdef ONE_COLOR - uint32_t pat1 = val / 256; -#else - uint32_t pat1 = val / 256 + index; -#endif - uint32_t pat2; - uint32_t seq = val % 256; - - if (pat1 >= MAX_PATTERN) { - pat1 = 0; - } - pat2 = pat1 + 1; - if (pat2 >= MAX_PATTERN) { - pat2 = 0; - } - out->red = (pattern[pat1].red * (256-seq) + pattern[pat2].red * seq) /256; - out->green = (pattern[pat1].green * (256-seq) + pattern[pat2].green * seq) /256; - out->blue = (pattern[pat1].blue * (256-seq) + pattern[pat2].blue * seq) /256; - } +// brigtness beween 0 and 1.0 +#define BRIGHTNESS 0.5 int main() { - DigitalIn(D3, PullDown); - neopixel::PixelArray array(D3); + + // WordClock object with leds connected to p5 (MOSI) + WordClock clock(p5); + + Timer timer; + + time_t now; + +{ + + timer.start(); - uint32_t val = 0; - while (1) { - if ((++val) >= MAX_INDEX) { - val = 0; - } - array.update(generate, NLED, val); - wait_ms(10); + while(1) + { + // Update the colors array. + uint32_t time = timer.read_ms(); + for(int i = 0; i < NUMLEDS; i++) + { + uint8_t phase = (time >> 4) - (i << 2); + //ledstripe[i] = hsvToRgb(phase / 256.0, 1.0, BRIGHTNESS); + } + clock.display_time(now); } } + +}