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

Revision:
4:ed0ac1dd6ae4
Parent:
3:ebe0c4fa97b8
Child:
7:10b0f6ee5047
diff -r ebe0c4fa97b8 -r ed0ac1dd6ae4 main.cpp
--- a/main.cpp	Sun Nov 05 18:25:59 2017 +0000
+++ b/main.cpp	Sun Nov 05 20:22:15 2017 +0000
@@ -1,5 +1,6 @@
 // Wordclock with WS2812-LED-Stripe
 // with 11x10 LED-Matrix and 4 minute-LEDS
+// and DS3231 RTC
 /*
 
 ESKISTLFÜNF
@@ -19,6 +20,7 @@
 #include "mbed.h"
 #include "neopixel.h"
 #include "WordClock.h"
+#include "ds3231.h"
 
 
 // brigtness beween 0 and 1.0
@@ -31,11 +33,29 @@
     // WordClock object with leds connected to p5 (MOSI)
     WordClock clock(p5);
 
+    //RTC with DS3231 : sda, scl
+    Ds3231 rtc(p9, p10);
+
     Timer timer;
 
-    time_t now;
+    {
+        // 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();
 
@@ -43,8 +63,10 @@
             // time fast forward
             for (int h=0; h<=23; h++) {
                 for (int m=0; m<=59; m++) {
-                    clock.display_time(h,m);
-                    wait_ms(500);
+                    for (int s=0;s<=59;s++){
+                        clock.display_time(h,m,s);
+                        wait_ms(5);
+                    }
                 }
             }