show received DCF77 time

This commit is contained in:
King Kévin 2016-05-05 23:30:25 +02:00
parent 4493f34d22
commit 37af736ca6
1 changed files with 12 additions and 4 deletions

16
main.c
View File

@ -132,10 +132,10 @@ int _write(int file, char *ptr, int len)
return -1;
}
char* b2s(uint32_t binary, uint8_t rjust)
char* b2s(uint64_t binary, uint8_t rjust)
{
static char string[32+1] = {0}; // the string representation to return
int16_t bit = LENGTH(string)-1; // the index of the bit to print
static char string[64+1] = {0}; // the string representation to return
int8_t bit = LENGTH(string)-1; // the index of the bit to print
string[bit--] = 0; // terminate string
while (binary) {
@ -147,7 +147,7 @@ char* b2s(uint32_t binary, uint8_t rjust)
binary >>= 1;
}
while (32-bit-1<rjust && bit>=0) {
while (64-bit-1<rjust && bit>=0) {
string[bit--] = '0';
}
@ -505,6 +505,14 @@ int main(void)
}
clock_set_time(rtc_ds1307_ticks); // set time
}
while (rtc_dcf77_time_flag) { // the DCF77 module received a new time
rtc_dcf77_time_flag = false; // reset flag
action = true; // action has been performed
uint8_t* dcf77_time = rtc_dcf77_time(); // get time
if (dcf77_time) { // ensure it's valid
printf("DCF77 time: 20%02u-%02u-%02u %02u:%02u:00\n", dcf77_time[5], dcf77_time[4], dcf77_time[3], dcf77_time[1], dcf77_time[0]); // display time
}
}
while (photoresistor_flag) { // new photo-resistor value has been measured
photoresistor_flag = false; // reset flag
action = true; // action has been performed