lab03.2
This commit is contained in:
parent
5d4b4a1e6d
commit
a61348e1c7
@ -1,12 +1,26 @@
|
|||||||
#ifndef _HMI_MSG_H_
|
#ifndef _HMI_MSG_H_
|
||||||
#define _HMI_MSG_H_
|
#define _HMI_MSG_H_
|
||||||
|
|
||||||
|
#define VER_FW "Version: %S built on: %S %S\n"
|
||||||
|
#define VER_LIBC "avr-libc version: %S\n"
|
||||||
|
#define UI_GET_MONTH_LETTER "Enter Month name first letter >"
|
||||||
|
|
||||||
#define STUD_NAME "Arti Zirk"
|
#define STUD_NAME "Arti Zirk"
|
||||||
const char *ENG_MONTH[6] = {"January",
|
const char string_1[] PROGMEM = "January";
|
||||||
"February",
|
const char string_2[] PROGMEM = "February";
|
||||||
"March",
|
const char string_3[] PROGMEM = "March";
|
||||||
"April",
|
const char string_4[] PROGMEM = "April";
|
||||||
"May",
|
const char string_5[] PROGMEM = "May";
|
||||||
"June",};
|
const char string_6[] PROGMEM = "June";
|
||||||
|
|
||||||
|
PGM_P const months_table[] PROGMEM =
|
||||||
|
{
|
||||||
|
string_1,
|
||||||
|
string_2,
|
||||||
|
string_3,
|
||||||
|
string_4,
|
||||||
|
string_5,
|
||||||
|
string_6
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* _HMI_MSG_H_ */
|
#endif /* _HMI_MSG_H_ */
|
||||||
|
26
src/main.c
26
src/main.c
@ -2,9 +2,11 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
#include "hmi_msg.h"
|
#include "hmi_msg.h"
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
#include "print_helper.h"
|
#include "print_helper.h"
|
||||||
|
#include "../lib/hd44780_111/hd44780.h"
|
||||||
|
|
||||||
#define BLINK_DELAY_MS 100
|
#define BLINK_DELAY_MS 100
|
||||||
|
|
||||||
@ -15,14 +17,17 @@ int main (void)
|
|||||||
/* Init stdio on UART0 and UART3 and print user code info */
|
/* Init stdio on UART0 and UART3 and print user code info */
|
||||||
uart0_init();
|
uart0_init();
|
||||||
uart3_init();
|
uart3_init();
|
||||||
|
lcd_init();
|
||||||
|
lcd_clrscr();
|
||||||
stdout = stdin = &uart0_io;
|
stdout = stdin = &uart0_io;
|
||||||
stderr = &uart3_out;
|
stderr = &uart3_out;
|
||||||
fprintf(stderr, "Version: %s built on: %s %s\n",
|
fprintf_P(stderr, PSTR(VER_FW),
|
||||||
GIT_DESCR, __DATE__, __TIME__);
|
PSTR(GIT_DESCR), PSTR(__DATE__), PSTR(__TIME__));
|
||||||
fprintf(stderr, "avr-libc version: %s\n", __AVR_LIBC_VERSION_STRING__);
|
fprintf_P(stderr, PSTR(VER_LIBC), PSTR(__AVR_LIBC_VERSION_STRING__));
|
||||||
/* End stdio init and info print */
|
/* End stdio init and info print */
|
||||||
|
|
||||||
fprintf(stdout, STUD_NAME "\n");
|
fprintf_P(stdout, PSTR(STUD_NAME "\n"));
|
||||||
|
lcd_puts_P(PSTR(STUD_NAME));
|
||||||
/* ASCII table print */
|
/* ASCII table print */
|
||||||
print_ascii_tbl(stdout);
|
print_ascii_tbl(stdout);
|
||||||
unsigned char ascii[128] = {0};
|
unsigned char ascii[128] = {0};
|
||||||
@ -33,15 +38,20 @@ int main (void)
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
char month_first_leter;
|
char month_first_leter;
|
||||||
fprintf(stdout, "Enter Month name first letter >");
|
fprintf_P(stdout, PSTR(UI_GET_MONTH_LETTER));
|
||||||
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);
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
if (!strncmp(strupr(&month_first_leter), ENG_MONTH[i], 1)) {
|
if (!strncmp_P(&month_first_leter, (PGM_P)pgm_read_word(&months_table[i]), 1)) {
|
||||||
fprintf(stdout, "%s\n", ENG_MONTH[i]);
|
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 */
|
/* set pin 3 high to turn led on */
|
||||||
PORTA |= _BV(PORTA3);
|
PORTA |= _BV(PORTA3);
|
||||||
_delay_ms(BLINK_DELAY_MS);
|
_delay_ms(BLINK_DELAY_MS);
|
||||||
|
Loading…
Reference in New Issue
Block a user