Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. uint8_t yPosition = LCD_LINE1;
  2. uint8_t xPosition = 0;
  3.  
  4.  
  5. void LCD_Locate(uint8_t x, uint8_t y)
  6. {
  7. switch (y)
  8. {
  9. case 0:
  10. y = LCD_LINE1;
  11. break;
  12. case 1:
  13. y = LCD_LINE2;
  14. break;
  15. }
  16. xPosition = x;
  17. yPosition = y;
  18. LCD_WriteCmd((LCDC_SET_DDRAM | (y + x)));
  19. }
  20.  
  21.  
  22.  
  23. void LCD_Char(char c)
  24. {
  25. xPosition++;
  26. LCD_WriteData(((c >= 0x80) && (c <= 0x87)) ? (c & 0x07) : c);
  27. }
  28.  
  29.  
  30.  
  31. void LCD_String(char *str)
  32. {
  33. char c;
  34. while ((c = *(str++)))
  35. {
  36. LCD_Position();
  37. LCD_Char(c);
  38. }
  39. }
  40.  
  41.  
  42. void LCD_Position(){
  43. if (xPosition > 15 && yPosition == LCD_LINE1)
  44. {
  45. yPosition = LCD_LINE2;
  46. LCD_Locate(0, 1);
  47. }
  48. else if (xPosition > 15 && yPosition == LCD_LINE2)
  49. {
  50. yPosition = LCD_LINE1;
  51. LCD_Locate(0, 0);
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement