Hello!
What the Hardware is:
Arduino Mega 2560
I use WS2812 LED Strips (260, 124) to visualize Seconds, Minutes and Hour.
There is a 4 Digit 7 Segment Display for the Time too.
Also an DS3231 AT24C32 I2C Real Time Clock
What the code should do:
Show the Time, a Scale for every 10 Seconds and Minutes, Minute Color depending on Time, 24 Hour view with visualizing Night- and Daytime and the Hour of Sunrise and Sunset.
There is a 30 Minute Dawntime before Sunrise and Sunset where I use gradient Colors for the transition form Night to Day and Day to Night.
The First Strip show the seconds, the second the minutes and the 3rd the hours.
When Starting the Program will set Variables for the Unixtime of the different Timestamps to make it easy to calculate the Color of the Minutes.
Then it calculate which colorsheme is to use, generate the scale-Dots and set the Leds.
My problem is, that my tests worked fine last night (after sunset) but not in the Morning before Sunrise or now on Daytime.
I have the Problem that the variable UNIXSUNRISE losing its Value when the second reaches 59.
This result in a wrong coloring of the minutes because the value is not a valid Unix Timestamp.
But I never set or Change the Variable after SETUP.
I guess that there is an overflow of another Variable which interfere with them.
So I tried the “dirty” solution to set the Variables each time the Minute changes.
This solved the color-Problem but then the Code resets every few Minutes.
So I have to find the source of the problem but I don’t know how because I can’t find any problem in the code.
Maybe I use a wrong declaration format of some Variables?
The code is attached because it was to big.
I'm using Atom with PlatformIO in case that information is relevant.
Here is the part from Serial Monitor when the change happens:
Today is 28-02-2019 15:08:00
UNIXACTHOURBEGIN: 1551362400
UNIXACTHOUREND: 1551365999
UNIXDAYBEGIN: 1551312000
UNIXDAYEND: 1551398399
UNIXSUNRISE-DAWNTIME: 1551330524
UNIXSUNRISE: 1551332324
UNIXSUNSET-DAWNTIME: 1551369989
UNIXSUNSET: 1551371789
DAWNTIME: 1800
FADE in: 20
XX: 0
FADE in: 30
XX: 1
FADE in: 40
XX: 2
FADE in: 50
XX: 3
FADE in: 60
XX: 4
FADE in: 70
XX: 5
FADE in: 80
XX: 6
FADE in: 90
XX: 7
FADE in: 100
XX: 8
FADE in: 110
XX: 9
FADE in: 120
XX: 10
FADE out: 110
XX: 10
FADE out: 100
XX: 9
FADE out: 90
XX: 8
FADE out: 80
XX: 7
FADE out: 70
XX: 6
FADE out: 60
XX: 5
FADE out: 50
XX: 4
FADE out: 40
XX: 3
FADE out: 30
XX: 2
FADE out: 20
XX: 1
FADE out: 10
XX: 0
******
MINUTESAT: 255
MINUTECOLOR: 60
DOTSAT: 10
DOTCOL: 160
LEDBRIGHTNESS: 100
MINCOLSELECT: 1
MINOFFSET: 60
MINUTESAT: 255
MINUTECOLOR: 60
DOTSAT: 10
DOTCOL: 160
LEDBRIGHTNESS: 100
MINCOLSELECT: 0
MINOFFSET: 60
******
Today is 28-02-2019 15:08:01
UNIXACTHOURBEGIN: 1551362400
UNIXACTHOUREND: 1551365999
UNIXDAYBEGIN: 1551312000
UNIXDAYEND: 1551398399
UNIXSUNRISE-DAWNTIME: 4294965724
UNIXSUNRISE: 228
UNIXSUNSET-DAWNTIME: 1551369989
UNIXSUNSET: 1551371789
DAWNTIME: 1800
I'v tried to check all that my knowledge allow me but I'm now at a dead End or my Mind is blocked ^^.
This is still a Work in progress so there a some code areas which do not make sense yet but they should not have an impact on the Problem.
Can you please give me a hint where to search or what I should try?
Thank you very much!
And if you have inputs or advises which have nothing to do with the actual problem please feel free to tell me because I'm allways happy to learn!
main clean.cpp (18 KB)
Serial Monitor.txt (1.2 KB)