From 1fad6de2e18479c49c24d22cb7069bb56e426c83 Mon Sep 17 00:00:00 2001 From: Arti Zirk Date: Sun, 23 Oct 2016 22:11:20 +0300 Subject: [PATCH] Even lower memory usage --- src/hmi_msg.h | 9 +++++---- src/main.c | 14 +++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/hmi_msg.h b/src/hmi_msg.h index 393b0f9..3261d63 100644 --- a/src/hmi_msg.h +++ b/src/hmi_msg.h @@ -2,10 +2,10 @@ #ifndef _HMI_MSG_H_ #define _HMI_MSG_H_ -const char PROG_VERSION[] PROGMEM = "Version: %s built on: %s %s\n"; -const char LIBC_VERSION[] PROGMEM = "avr-libc version: %s\n"; -const char STUD_NAME[] PROGMEM = "Arti Zirk"; -const char GET_MONTH_MSG[] PROGMEM = "Enter Month name first letter >"; +#define PROG_VERSION "Version: "GIT_DESCR" built on: "__DATE__" "__TIME__"\n" +#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", @@ -15,4 +15,5 @@ const char ENG_MONTH[6][9] PROGMEM = { "June", }; + };*/ #endif /* _HMI_MSG_H_ */ diff --git a/src/main.c b/src/main.c index af0fdf2..6ccc273 100644 --- a/src/main.c +++ b/src/main.c @@ -23,14 +23,13 @@ int main (void) /* End init */ /* Print version info to stderr */ - fprintf_P(stderr, PROG_VERSION, GIT_DESCR, __DATE__, __TIME__); - fprintf_P(stderr, LIBC_VERSION, __AVR_LIBC_VERSION_STRING__); + fprintf_P(stderr, PSTR(PROG_VERSION)); + fprintf_P(stderr, PSTR(LIBC_VERSION)); /* End version print */ - fprintf_P(stdout, STUD_NAME); + fprintf_P(stdout, PSTR(STUD_NAME)); fputc('\n', stdout); /* Add a new line to the uart printout */ - lcd_puts_P(STUD_NAME); - lcd_goto(0x40); /* Got to the beginning of the next line */ + lcd_puts_P(PSTR(STUD_NAME)); /* ASCII table print */ print_ascii_tbl(stdout); @@ -47,9 +46,10 @@ int main (void) /* Month search and print */ char month_first_leter; - fprintf_P(stdout, GET_MONTH_MSG); + fprintf_P(stdout, PSTR(GET_MONTH_MSG)); fscanf(stdin, "%c", &month_first_leter); 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]); @@ -60,7 +60,7 @@ int main (void) } lcd_puts_P(PSTR(" ")); /* Clear the end of the line */ - lcd_goto(0x40); /* Got to the beginning of the next line */ + /* set pin 3 low to turn led off */ PORTA &= ~_BV(PORTA3);