From 04031523d40c0bbaa1e84adeec70c80ebcf2ec50 Mon Sep 17 00:00:00 2001 From: Arti Zirk Date: Sun, 20 Nov 2016 00:51:04 +0200 Subject: [PATCH] Style fixes and added some comments --- src/hmi_msg.h | 14 +++++++------- src/main.c | 10 +++++++--- src/uart_wrap.c | 4 ++++ src/uart_wrap.h | 6 +++--- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/hmi_msg.h b/src/hmi_msg.h index 5aa820b..f3818fd 100644 --- a/src/hmi_msg.h +++ b/src/hmi_msg.h @@ -2,18 +2,18 @@ #ifndef _HMI_MSG_H_ #define _HMI_MSG_H_ -#define PROG_VERSION "Version: %S built on: %S %S\n" -#define LIBC_VERSION "avr-libc version: %S\n" +#define PROG_VERSION "Version: %S built on: %S %S" +#define LIBC_VERSION "avr-libc version: %S" #define STUD_NAME "Arti Zirk" #define GET_MONTH_MSG "Enter Month name first letter >" #define UPTIME_MSG "Uptime: %lu s" -const char m1[] PROGMEM = "January"; +const char m1[] PROGMEM = "January"; const char m2[] PROGMEM = "February"; -const char m3[] PROGMEM = "March"; -const char m4[] PROGMEM = "April"; -const char m5[] PROGMEM = "May"; -const char m6[] PROGMEM = "June"; +const char m3[] PROGMEM = "March"; +const char m4[] PROGMEM = "April"; +const char m5[] PROGMEM = "May"; +const char m6[] PROGMEM = "June"; PGM_P const months[] PROGMEM = {m1,m2,m3,m4,m5,m6}; #endif /* _HMI_MSG_H_ */ diff --git a/src/main.c b/src/main.c index 3b5d52d..77f756c 100644 --- a/src/main.c +++ b/src/main.c @@ -52,9 +52,9 @@ static inline void init_hw (void) static inline void start_ui (void) { // Print program and libc versions - fprintf_P(stderr, PSTR(PROG_VERSION), + fprintf_P(stderr, PSTR(PROG_VERSION "\n"), PSTR(GIT_DESCR), PSTR(__DATE__), PSTR(__TIME__)); - fprintf_P(stderr, PSTR(LIBC_VERSION), PSTR(__AVR_LIBC_VERSION_STRING__)); + fprintf_P(stderr, PSTR(LIBC_VERSION "\n"), PSTR(__AVR_LIBC_VERSION_STRING__)); // print student name fprintf_P(stdout, PSTR(STUD_NAME)); @@ -89,11 +89,15 @@ static inline void search_month (void) } } + // this is fine because even when the hd44780 address counter goes over 0xf4 + // we still have quite a few addresses left until address counter overflow + // and we also dont care about the data that is at the end of the ddram lcd_puts_P(PSTR(" ")); // Clear the end of the line fprintf_P(stdout, PSTR(GET_MONTH_MSG)); } -static inline void heartbeat (void) { +static inline void heartbeat (void) +{ static time_t time_prev; time_t time_cur = time(NULL); if (time_cur <= time_prev) { diff --git a/src/uart_wrap.c b/src/uart_wrap.c index b4a3b39..05aea02 100644 --- a/src/uart_wrap.c +++ b/src/uart_wrap.c @@ -17,6 +17,10 @@ int uart0_putc_wrap(char c, FILE *stream) int uart0_getc_wrap(FILE *stream) { (void) stream; + // Probabbly should add some error checking in here but because + // this function is only called out when there is at least one character + // available in the input buffer (see main.c line 114) then error checking + // is not currently necessary. return (char)uart0_getc(); } diff --git a/src/uart_wrap.h b/src/uart_wrap.h index 5981314..c5c9227 100644 --- a/src/uart_wrap.h +++ b/src/uart_wrap.h @@ -1,5 +1,5 @@ -#ifndef _UART_H_ -#define _UART_H_ +#ifndef _UART_WRAP_H_ +#define _UART_WRAP_H_ int uart0_putc_wrap(char c, FILE *stream); int uart0_getc_wrap(FILE *stream); @@ -12,4 +12,4 @@ int uart3_putc_wrap(char c, FILE *stream); FILE uart0_io = FDEV_SETUP_STREAM(uart0_putc_wrap, uart0_getc_wrap, _FDEV_SETUP_RW); FILE uart3_out = FDEV_SETUP_STREAM(uart3_putc_wrap, NULL, _FDEV_SETUP_WRITE); -#endif /* _UART_H_ */ +#endif /* _UART_WRAP_H_ */