I have a countdown timer that counts down the hours, minutes and seconds to zero calculated from a decrementing total seconds value.
int h = 0;
int m = 0;
int s = 0;
long unsigned int remainingSeconds = 122600;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop(){
TimeCalc(remainingSeconds);
Serial.print(h); Serial.print(" ");Serial.print(m); Serial.print(" ");Serial.println(s);
remainingSeconds --;
}
void TimeCalc( long unsigned int seconds ) {
uint32_t t = seconds;
s = t % 60;
t = (t - s) / 60;
m = t % 60;
t = (t - m) / 60;
h = t;
}
The code above works fine - the serial monitor.. however I am getting garbage writing to the OLED screen when I start the countdown above 9 hours and 6 minutes.
changing the int variables to uint16_t I'm able to get to 18 hours 12 minutes.. above that, the garbage starts again. Going to uint32_t makes no difference...
anyone know what might be going on here?

