From bdd27a6bea18f2de2b715f4d1e20398817145c47 Mon Sep 17 00:00:00 2001 From: Arti Zirk Date: Mon, 26 Sep 2016 19:57:14 +0300 Subject: [PATCH] Add 0 to 127 ascii print out and month lookup --- src/hmi_msg.h | 6 ++++++ src/main.c | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/hmi_msg.h b/src/hmi_msg.h index f3b3a37..890169a 100644 --- a/src/hmi_msg.h +++ b/src/hmi_msg.h @@ -2,5 +2,11 @@ #define _HMI_MSG_H_ #define STUD_NAME "Arti Zirk" +const char *ENG_MONTH[6] = {"January", + "February", + "March", + "April", + "May", + "June",}; #endif /* _HMI_MSG_H_ */ diff --git a/src/main.c b/src/main.c index 9ecb26f..fce8a0e 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,8 @@ #include +#include #include #include +#include "hmi_msg.h" #include "uart.h" #include "print_helper.h" @@ -20,10 +22,26 @@ int main (void) fprintf(stderr, "avr-libc version: %s\n", __AVR_LIBC_VERSION_STRING__); /* End stdio init and info print */ + fprintf(stdout, STUD_NAME "\n"); /* ASCII table print */ - print_ascii_tbl(stderr); + 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(stdout, "Enter Month name first letter >"); + fscanf(stdin, "%c", &month_first_leter); + fprintf(stdout, "%c\n", month_first_leter); + for (int i = 0; i < 6; i++) { + if (!strncmp(strupr(&month_first_leter), ENG_MONTH[i], 1)) { + fprintf(stdout, "%s\n", ENG_MONTH[i]); + } + } + /* set pin 3 high to turn led on */ PORTA |= _BV(PORTA3); _delay_ms(BLINK_DELAY_MS);