Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. /*
  2. * LCD.c
  3. *
  4. * Created: 2019-10-19 12:58:07
  5. * Author : oem1
  6. */
  7. #define F_CPU (16000000UL)
  8. #include <avr/io.h>
  9. #include "HD44780.h"
  10.  
  11. #define LINE_LENGTH 16
  12. #define SI 0
  13.  
  14. typedef struct text_struct{
  15. char *text;
  16. uint8_t length;
  17. uint8_t line;
  18. uint8_t position;
  19. uint8_t counter;
  20. }textStruct_t;
  21.  
  22.  
  23.  
  24.  
  25. void wyswietldlugi(textStruct_t* text_s);
  26.  
  27. int main(void)
  28. {
  29.  
  30. textStruct_t text_s1 = {"Wydzial Automatyki Elektroniki i Informatyki",45,0,0,0};
  31. textStruct_t text_s2 = {"Politechnika Slaska", 19,1,0,0};
  32. LCD_Initalize();
  33. LCD_Clear();
  34. LCD_GoTo(0,0);
  35. LCD_Clear();
  36.  
  37.  
  38. /* Replace with your application code */
  39. while (1)
  40. {
  41. wyswietldlugi(&text_s1);
  42. wyswietldlugi(&text_s2);
  43.  
  44. _delay_ms(500);
  45. }
  46. }
  47.  
  48. void wyswietldlugi(textStruct_t* text_s)
  49. {
  50. LCD_GoTo(0,text_s->line);
  51. LCD_WriteText(&(text_s->text[text_s->position]));
  52. if (text_s -> position == 0)
  53. {
  54. if (text_s -> counter ++ == 4)
  55. {
  56. text_s -> counter=0;
  57. }
  58. }
  59. if (text_s -> counter == 0)
  60. {
  61. text_s -> position++;
  62. }
  63. if (text_s -> position > (text_s -> length-LINE_LENGTH-1))
  64. {
  65. if (text_s -> counter++ == 4)
  66. {
  67. text_s -> counter = 0;
  68. text_s -> position = 0;
  69. }
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement