diff --git a/src/hmi_msg.h b/src/hmi_msg.h index 3261d63..eb15a51 100644 --- a/src/hmi_msg.h +++ b/src/hmi_msg.h @@ -6,14 +6,20 @@ #define LIBC_VERSION "avr-libc version: "__AVR_LIBC_VERSION_STRING__"\n" #define STUD_NAME "Arti Zirk" #define GET_MONTH_MSG "Enter Month name first letter >" -const char ENG_MONTH[6][9] PROGMEM = { - "January", - "February", - "March", - "April", - "May", - "June", - }; - };*/ +const char JANUARY[] PROGMEM = "January"; +const char FEBRUARY[] PROGMEM = "February"; +const char MARCH[] PROGMEM = "March"; +const char APRIL[] PROGMEM = "April"; +const char MAY[] PROGMEM = "May"; +const char JUNE[] PROGMEM = "June"; + +PGM_P const ENG_MONTH[] PROGMEM = { + JANUARY, + FEBRUARY, + MARCH, + APRIL, + MAY, + JUNE, + }; #endif /* _HMI_MSG_H_ */ diff --git a/src/main.c b/src/main.c index 6ccc273..c18e39e 100644 --- a/src/main.c +++ b/src/main.c @@ -33,7 +33,7 @@ int main (void) /* ASCII table print */ print_ascii_tbl(stdout); - unsigned char ascii[128] = {0}; + unsigned char ascii[128]; for (unsigned char i = 0; i < sizeof(ascii); i++) { ascii[i] = i; } @@ -51,10 +51,10 @@ int main (void) fprintf(stdout, "%c\n", month_first_leter); lcd_goto(0x40); /* Got to the beginning of the next line */ for (int i = 0; i < 6; i++) { - if (!strncmp_P(&month_first_leter, ENG_MONTH[i], 1)) { - fprintf_P(stdout, ENG_MONTH[i]); + if (!strncmp_P(&month_first_leter, (PGM_P)pgm_read_word(&ENG_MONTH[i]), 1)) { + fprintf_P(stdout, (PGM_P)pgm_read_word(&ENG_MONTH[i])); fputc('\n', stdout); - lcd_puts_P(ENG_MONTH[i]); + lcd_puts_P((PGM_P)pgm_read_word(&ENG_MONTH[i])); lcd_putc(' '); } } diff --git a/src/print_helper.c b/src/print_helper.c index 69f6d7f..8d1ff5b 100644 --- a/src/print_helper.c +++ b/src/print_helper.c @@ -1,4 +1,5 @@ #include +#include #include "print_helper.h" int print_ascii_tbl (FILE *stream) @@ -16,16 +17,17 @@ int print_ascii_tbl (FILE *stream) int print_for_human (FILE *stream, const unsigned char *array, const int len) { for (int i = 0; i < len; i++) { - if (array[i] >= ' ' && array[i] <= '~') { - if (!fprintf(stream, "%c", array[i])) { + unsigned char c = array[i]; + if (c >= ' ' && c <= '~') { + if (!fprintf(stream, "%c", c)) { return 0; } } else { - if (!fprintf(stream, "\"0x%02x\"", array[i])) { + if (!fprintf(stream, "\"0x%02x\"", c)) { return 0; } } } - return fprintf(stream, "\n");; + return fprintf(stream, "\n"); }