Hi people, I know I'm boring sometimes but I have a big problem and I'm stopped near the solution.
I've post the full code of this famous clock.
I would like to add a little funzion: add second near the minute.
This is the code that I added
void invaders()
{
cls();
byte hours = rtc[DS1307_HR];
byte mins = rtc[DS1307_MIN];
byte second = rtc[DS1307_SEC];
//loop to display the clock for a set duration of SHOWCLOCK
for (int show = 0; show < SHOWCLOCK ; show++) {
gettime(); //get the time from the clock chip
flash_seconds();
if (button_checks())
{
return;
}
//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[1] ) ) {
//udate mins and hours with the new time
mins = rtc[1];
hours = rtc[2];
second = rtc[3]; [color=red]<== I THINK HERE IS THE PROBLEM !![/color]
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]);
}
so the problem is that the second remain stopped and never change. I would like that every one second it change !!!
if I change :
second = rtc[DS1307_SEC];
second change when the minute is update.
I become crazy
Why it doesn't change every time that the buffer change ?
What is rtc[1] or rtc[2] ?
Thanks in advance
Daniel
(this version is with INVADERS )
invaders with second.txt (53 KB)