I watch in my project with a clock that the ad occasionally - I mean every few days - freezes and either does nothing more or displays the ad over a few hours correctly again.
The symptom shows, even if I do not change values via Blynk.
I would look at the random element you use to decide when to sync to cloud time. Can you set that to a known time and see if the bug happens at that time?
I would also comment out the Blynk stuff and try that version to separate the problem into parts.
// Pick a random time to synchronize the time from the cloud
// time_sync_time = random(0, 2399);
// https://docs.particle.io/reference/firmware/photon/#particle-synctimedone-
Particle.syncTime();
waitFor(Particle.syncTimeDone, 5000); // works with v0.6.1 with Photon & Electron
Your random number generator will generate a lot of âtimesâ that are not valid (the 99 part), and thus Particle.syncTime() will never run. Syncâing at midnight, or every millis() of 86400 would be fine as well. But also your the_time = Time.hour()*100+Time.minute(); is not an atomic operation, so it could generate an invalid time due to rollover. You can fix many ways, but a simple one is to read the minute first, hour second, minute again, if minute is the same⌠continue, if not, read the hour again and continue. Look in your libraries for while loops that can get stuck and add timeouts. Good luck!
Garrett I see the following points:
a.) I would like to have a leading 0 at midnight â0:04â instead of "_: _4"
b.) the freezing of the photon disturbs me and the time is connected - so it is not a reliable companion in everyday life.
c.) otherwise it would still be great to have a Blync integration: I tried to adjust the time zone, the brightness of the display and the blinking colon
Although the original code does not use Blync, my photon hangs after 2-3 days and freezes the time. Sometimes it syncs after 3-4 hours and runs for some time, sometimes a restart is necessary.
Both versions are basically the same and cause difficulties. I could not completely follow the suggestions so far and have therefore flashed the original version.
In order to have a leading zero you just change this
// Display the time in 24 hour format
if(TWENTYFOUR_HOUR==1) {
matrix.print(the_time);
if (Time.hour() < 10) // leading zero?
matrix.writeDigitalNum(0, 0);
if (Time.hour() == 0)
matrix.writeDigitNum(1, 0); // = first value = number of digit - in this case = second digit, starts with 0 to 4; second value = value to display
if (Time.minute() <= 9)
matrix.writeDigitNum(3, 0); // = first value = number of digit - in this case = third digit, starts with 0 to 4; second value = value to display
colonDisplay(colon_display, false);
// We have to do some mangling to do 12-hour time
} else {
// Calculate 12-hour time
uint16_t new_time = the_time;
if(new_time>=1200)
new_time = new_time-1200;
matrix.print(new_time);
if (new_time < 1000) // leading zero?
matrix.writeDigitalNum(0, 0);
// Show PM dot
if(the_time>=1200)
colonDisplay(colon_display, true);
else
colonDisplay(colon_display, false);
}
However, I think the 12-hour display isnât quite right for the times 12:00 to 12:59 am/pm as they would be printed as 00:00 to 00:59 am/pm which isnât the common way of displaying these times.
Got an error ScruffR during flashing:
mybigclock_original.ino:69:18: error: âclass Adafruit_7segmentâ has no member named 'writeDigitalNumâ
mybigclock_original.ino:89:18: error: âclass Adafruit_7segmentâ has no member named âwriteDigitalNumâ
Adafruit_7segment matrix = Adafruit_7segment(); is defined at start.
The option with 24 hour format is my favorite version.
Sorry, this was a typo, but minimal investigation of that message may have revealed the error.
Your original code was already using the function I intendet to use but just wrote slightly different.
if (Time.hour() < 10) // leading zero?
matrix.writeDigitalNum(0, 0); // <-- error here
if (Time.hour() == 0)
matrix.writeDigitNum(1, 0); // <-- working here
Update: 28.08.2018
the freezing of the display has been attributed to a jittering contact of the jumper cables to the photon. It struck me as odd that despite the freezing, the photon was quite responsive. So I wobbled on the DIY box and lo and behold, the display came back and updated. This could be reproduced several times and so Iâll probably solder the jumpers on the Photon.