From 22968ef6a43dc9b5832512e945aea789ef05e69e Mon Sep 17 00:00:00 2001 From: Arti Zirk Date: Wed, 2 Nov 2016 15:18:43 +0200 Subject: [PATCH] bla --- src/main.c | 8 ++++++-- src/print_helper.c | 14 +++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main.c b/src/main.c index 3d42587..9e8b82b 100644 --- a/src/main.c +++ b/src/main.c @@ -22,18 +22,19 @@ int main (void) stdout = stdin = &uart0_io; stderr = &uart3_out; fprintf_P(stderr, PSTR(VER_FW), - PSTR(GIT_DESCR), PSTR(__DATE__), PSTR(__TIME__)); + 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) { @@ -42,6 +43,7 @@ int main (void) 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])); @@ -49,9 +51,11 @@ int main (void) 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); diff --git a/src/print_helper.c b/src/print_helper.c index 995a47b..69f6d7f 100644 --- a/src/print_helper.c +++ b/src/print_helper.c @@ -1,27 +1,31 @@ #include #include "print_helper.h" -int print_ascii_tbl (FILE *stream) { +int print_ascii_tbl (FILE *stream) +{ for (char c = ' '; c <= '~'; c++) { - if(!fprintf(stream, "%c ", c)) { + if (!fprintf(stream, "%c ", c)) { return 0; } } + return fprintf(stream, "\n"); } -int print_for_human (FILE *stream, const unsigned char *array, const int len) { +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])) { + if (!fprintf(stream, "%c", array[i])) { return 0; } } else { - if(!fprintf(stream, "\"0x%02x\"", array[i])) { + if (!fprintf(stream, "\"0x%02x\"", array[i])) { return 0; } } } + return fprintf(stream, "\n");; }