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 Yoshitaka Kuwata

WordClock

Yet another wordclock...

Program for displaying time in (german) words on WS2812B LED-Matrix. Uses DS3231 RTC .

/media/uploads/charly/20171105_220942.jpg

/media/uploads/charly/20171101_112354.jpg

More fotos see:

https://photos.app.goo.gl/mSN6G145IdupbKv13

main.cpp

Committer:
charly
Date:
2017-11-05
Revision:
4:ed0ac1dd6ae4
Parent:
3:ebe0c4fa97b8
Child:
7:10b0f6ee5047

File content as of revision 4:ed0ac1dd6ae4:

// Wordclock with WS2812-LED-Stripe
// with 11x10 LED-Matrix and 4 minute-LEDS
// and DS3231 RTC
/*

ESKISTLFÜNF
ZEHNZWANZIG
DREIVIERTEL
TGNACHVORJM
HALBXZWÖLFP
ZWEINSIEBEN
KDREIRHFÜNF
ELFNEUNVIER
WACHTZEHNRS
BSECHSFMUHR
   ****
*/


#include "mbed.h"
#include "neopixel.h"
#include "WordClock.h"
#include "ds3231.h"


// brigtness beween 0 and 1.0
#define BRIGHTNESS 0.5


int main()
{

    // WordClock object with leds connected to p5 (MOSI)
    WordClock clock(p5);

    //RTC with DS3231 : sda, scl
    Ds3231 rtc(p9, p10);

    Timer timer;

    {
        // set time and date
        //time and calendar variables
        ds3231_time_t time = {0, 47, 20, 0, 0};      //sec, min, hour, am/pm(1=pm), mode(1=12h)
        ds3231_calendar_t calendar = {7, 5, 11, 2017};  //day(1=mon), date, month, year
        uint16_t rtn_val;
        // only set RTC when required!
        //rtn_val = rtc.set_time(time);
        //rtn_val = rtc.set_calendar(calendar);

        while (1) {
            //read time an show on LED
            rtn_val = rtc.get_time(&time);
            clock.display_time(time.hours,time.minutes,time.seconds);
            wait_ms(10);
        }

        //testprograms from here on

        timer.start();

        while(1) {
            // time fast forward
            for (int h=0; h<=23; h++) {
                for (int m=0; m<=59; m++) {
                    for (int s=0;s<=59;s++){
                        clock.display_time(h,m,s);
                        wait_ms(5);
                    }
                }
            }

            // all words
            for (int i=1; i<=NUMWORDS; i++) {
                clock.test_display(3,i);
                wait_ms(800);
            }
            //all leds on with rainbow colors
            while ( int(timer.read()/10.0) %2 == 0) {
                clock.test_display(1);
                wait_ms(100);
            }
            // every led on for 250ms
            for (int i=0; i<NUMLEDS; i++) {
                clock.test_display(2,i);
                wait_ms(250);
            }
            timer.reset();
        }
    }

}