1
0
Fork 0

Even lower memory usage

This commit is contained in:
Arti Zirk 2016-10-23 22:11:20 +03:00
parent 14a6e4ff91
commit 1fad6de2e1
2 changed files with 12 additions and 11 deletions

View File

@ -2,10 +2,10 @@
#ifndef _HMI_MSG_H_ #ifndef _HMI_MSG_H_
#define _HMI_MSG_H_ #define _HMI_MSG_H_
const char PROG_VERSION[] PROGMEM = "Version: %s built on: %s %s\n"; #define PROG_VERSION "Version: "GIT_DESCR" built on: "__DATE__" "__TIME__"\n"
const char LIBC_VERSION[] PROGMEM = "avr-libc version: %s\n"; #define LIBC_VERSION "avr-libc version: "__AVR_LIBC_VERSION_STRING__"\n"
const char STUD_NAME[] PROGMEM = "Arti Zirk"; #define STUD_NAME "Arti Zirk"
const char GET_MONTH_MSG[] PROGMEM = "Enter Month name first letter >"; #define GET_MONTH_MSG "Enter Month name first letter >"
const char ENG_MONTH[6][9] PROGMEM = { const char ENG_MONTH[6][9] PROGMEM = {
"January", "January",
"February", "February",
@ -15,4 +15,5 @@ const char ENG_MONTH[6][9] PROGMEM = {
"June", "June",
}; };
};*/
#endif /* _HMI_MSG_H_ */ #endif /* _HMI_MSG_H_ */

View File

@ -23,14 +23,13 @@ int main (void)
/* End init */ /* End init */
/* Print version info to stderr */ /* Print version info to stderr */
fprintf_P(stderr, PROG_VERSION, GIT_DESCR, __DATE__, __TIME__); fprintf_P(stderr, PSTR(PROG_VERSION));
fprintf_P(stderr, LIBC_VERSION, __AVR_LIBC_VERSION_STRING__); fprintf_P(stderr, PSTR(LIBC_VERSION));
/* End version print */ /* 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 */ fputc('\n', stdout); /* Add a new line to the uart printout */
lcd_puts_P(STUD_NAME); lcd_puts_P(PSTR(STUD_NAME));
lcd_goto(0x40); /* Got to the beginning of the next line */
/* ASCII table print */ /* ASCII table print */
print_ascii_tbl(stdout); print_ascii_tbl(stdout);
@ -47,9 +46,10 @@ int main (void)
/* Month search and print */ /* Month search and print */
char month_first_leter; char month_first_leter;
fprintf_P(stdout, GET_MONTH_MSG); fprintf_P(stdout, PSTR(GET_MONTH_MSG));
fscanf(stdin, "%c", &month_first_leter); fscanf(stdin, "%c", &month_first_leter);
fprintf(stdout, "%c\n", 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++) { for (int i = 0; i < 6; i++) {
if (!strncmp_P(&month_first_leter, ENG_MONTH[i], 1)) { if (!strncmp_P(&month_first_leter, ENG_MONTH[i], 1)) {
fprintf_P(stdout, ENG_MONTH[i]); fprintf_P(stdout, ENG_MONTH[i]);
@ -60,7 +60,7 @@ int main (void)
} }
lcd_puts_P(PSTR(" ")); /* Clear the end of the line */ 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 */ /* set pin 3 low to turn led off */
PORTA &= ~_BV(PORTA3); PORTA &= ~_BV(PORTA3);