//#include //#include // must be included here so that Arduino library object file references work //#include #include "led_clock.hpp" led_clock ledclock; //SoftwareWire myWire(A4, A5); //RtcDS3231 Rtc(myWire); const unsigned int PIN_BUZZER = 9; const int TICK_FREQ = 40; const int TICK_DLY = 13; const int TOCK_FREQ = 15; const int TOCK_DLY = 35; bool tick_not_tock = true; 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 /* void init_rtc() { Rtc.Begin(); RtcDateTime compiled = RtcDateTime(__DATE__, __TIME__); Serial.println(); if (!Rtc.IsDateTimeValid()) { if (Rtc.LastError() != 0) { Serial.print("RTC communications error = "); Serial.println(Rtc.LastError()); } else { Serial.println("RTC lost confidence in the DateTime!"); Rtc.SetDateTime(compiled); } } if (!Rtc.GetIsRunning()) { Serial.println("RTC was not actively running, starting now"); Rtc.SetIsRunning(true); } RtcDateTime now = Rtc.GetDateTime(); if (now < compiled) { Serial.println("RTC is older than compile time! (Updating DateTime)"); Rtc.SetDateTime(compiled); } else if (now > compiled) { Serial.println("RTC is newer than compile time. (this is expected)"); } else if (now == compiled) { Serial.println("RTC is the same as compile time! (not expected but all is fine)"); } Rtc.Enable32kHzPin(false); Rtc.SetSquareWavePin(DS3231SquareWavePin_ModeNone); } */ /* void tick_tock() { if(tick_not_tock == true) {tone(PIN_BUZZER, TICK_FREQ, TICK_DLY);} else { tone(PIN_BUZZER, TOCK_FREQ, TOCK_DLY);} tick_not_tock = !tick_not_tock; } */ void setup() { ESP.wdtEnable(5000); Serial.begin(115200); Serial.println("Lets tick ... tock ... tick ... tock ... "); ledclock.init(COLOR_SECS, COLOR_MINS, COLOR_HOURS, COLOR_NUMS, ledclock.TEST_NONE ); //init_rtc(); } unsigned int hour = 0; unsigned int minute = 0; unsigned int second = 0; void loop() { /* RtcDateTime now = Rtc.GetDateTime(); if(now.Second() != second) { pixels.clear(); //tick_tock(); hour = now.Hour(); minute = now.Minute(); second = now.Second(); pointer[hour].fill(color_pointers_hour); //pointer[hour].ffill(color_pointers_hour, minute/(60/NUM_POINTER_PIXELS)); pixels.show(); Serial.print(hour); Serial.print(":"); Serial.print(minute); Serial.print(":"); Serial.println(second); } */ while (0 == 0) { second = second + 1; if(second > 59) { second = 0; minute++; if(minute > 59) { minute = 0; hour++; if(hour > 11) { hour = 0; } } } ledclock.showtime(hour,minute,second); //Serial.printf("%02d : %02d : %02d \n" , hour, minute, second); } }