//update the clock if this is the first run of the show clock loop, or if the time has changed from
//what we had stored in mins and hours vars.
if ( show == 0 || (mins != rtc[DS1307_MIN] || (second != rtc[DS1307_SEC]) ) ) {
//udate mins and hours with the new time
mins = rtc[DS1307_MIN];
hours = rtc[DS1307_HR];
second = rtc[DS1307_SEC];
char buffer[8];
itoa(hours,buffer,10);
//fix - as otherwise if num has leading zero, e.g. "03" hours, itoa coverts this to chars with space "3 ".
if (hours < 10) {
buffer[1] = buffer[0];
buffer[0] = '0';
}
//update the display
ht1632_putchar(9, 1, buffer[0]);
ht1632_putchar(15, 1, buffer[1]);
plot (21,3,1); //top point
plot (21,5,1); //bottom point
itoa (mins, buffer, 10);
if (mins < 10) {
buffer[1] = buffer[0];
buffer[0] = '0';
}
ht1632_putchar(23, 1, buffer[0]);
ht1632_putchar(29, 1, buffer[1]);
itoa(second,buffer,10);
//fix - as otherwise if num has leading zero, e.g. "03" hours, itoa coverts this to chars with space "3 ".
if (second < 10) {
buffer[1] = buffer[0];
buffer[0] = '0';
}
ht1632_puttinychar(36, 3, buffer[0]);
ht1632_puttinychar(40, 3, buffer[1]);
}
// if (scroll_invader (9,-11,49,random(1,4))) {
// return;
// }
// if (scroll_invader (9,49,-11,random(1,4))) {
// return;
// }
delay(500);
}
fade_down();
}
NOW WORKS !! ( and now I have understand the problem )
the only thing I must comment the code after the clock becouse the refresh was not every 1 second.
no problem becouse I don't want this code.
Many thanks
Daniel