Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * LCD.c
- *
- * Created: 2019-10-19 12:58:07
- * Author : oem1
- */
- #define F_CPU (16000000UL)
- #include <avr/io.h>
- #include "HD44780.h"
- #define LINE_LENGTH 16
- #define SI 0
- typedef struct text_struct{
- char *text;
- uint8_t length;
- uint8_t line;
- uint8_t position;
- uint8_t counter;
- }textStruct_t;
- void wyswietldlugi(textStruct_t* text_s);
- int main(void)
- {
- textStruct_t text_s1 = {"Wydzial Automatyki Elektroniki i Informatyki",45,0,0,0};
- textStruct_t text_s2 = {"Politechnika Slaska", 19,1,0,0};
- LCD_Initalize();
- LCD_Clear();
- LCD_GoTo(0,0);
- LCD_Clear();
- /* Replace with your application code */
- while (1)
- {
- wyswietldlugi(&text_s1);
- wyswietldlugi(&text_s2);
- _delay_ms(500);
- }
- }
- void wyswietldlugi(textStruct_t* text_s)
- {
- LCD_GoTo(0,text_s->line);
- LCD_WriteText(&(text_s->text[text_s->position]));
- if (text_s -> position == 0)
- {
- if (text_s -> counter ++ == 4)
- {
- text_s -> counter=0;
- }
- }
- if (text_s -> counter == 0)
- {
- text_s -> position++;
- }
- if (text_s -> position > (text_s -> length-LINE_LENGTH-1))
- {
- if (text_s -> counter++ == 4)
- {
- text_s -> counter = 0;
- text_s -> position = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement