#include #include #include #include #include #include "hmi_msg.h" #include "uart.h" #include "print_helper.h" #include "../lib/hd44780_111/hd44780.h" #define BLINK_DELAY_MS 100 int main (void) { /* set pin 3 of PORTA for output*/ DDRA |= _BV(DDA3); /* Init stdio on UART0 and UART3 and print user code info */ uart0_init(); uart3_init(); lcd_init(); lcd_clrscr(); stdout = stdin = &uart0_io; stderr = &uart3_out; fprintf_P(stderr, PSTR(VER_FW), PSTR(GIT_DESCR), PSTR(__DATE__), PSTR(__TIME__)); fprintf_P(stderr, PSTR(VER_LIBC), PSTR(__AVR_LIBC_VERSION_STRING__)); /* End stdio init and info print */ fprintf_P(stdout, PSTR(STUD_NAME "\n")); lcd_puts_P(PSTR(STUD_NAME)); /* ASCII table print */ print_ascii_tbl(stdout); unsigned char ascii[128] = {0}; for (unsigned char i = 0; i < sizeof(ascii); i++) { ascii[i] = i; } print_for_human(stdout, ascii, sizeof(ascii)); while (1) { char month_first_leter; fprintf_P(stdout, PSTR(UI_GET_MONTH_LETTER)); fscanf(stdin, "%c", &month_first_leter); fprintf(stdout, "%c\n", month_first_leter); lcd_goto(0x40); for (int i = 0; i < 6; i++) { if (!strncmp_P(&month_first_leter, (PGM_P)pgm_read_word(&months_table[i]), 1)) { fprintf_P(stdout, PSTR("%S\n"), (PGM_P)pgm_read_word(&months_table[i])); lcd_puts_P((PGM_P)pgm_read_word(&months_table[i])); lcd_putc(' '); } } for (int i = 0; i < 16; i++) { lcd_putc(' '); } /* set pin 3 high to turn led on */ PORTA |= _BV(PORTA3); _delay_ms(BLINK_DELAY_MS); /* set pin 3 low to turn led off */ PORTA &= ~_BV(PORTA3); _delay_ms(BLINK_DELAY_MS); } }