daily pastebin goal
77%
SHARE
TWEET

Untitled

a guest Jan 19th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #ifndef LCD_H_
  2. #define LCD_H_
  3.  
  4. #define RS_PIN      0
  5. #define RW_PIN      1
  6. #define EN_PIN      2
  7.  
  8. #define RS_PORT PORTC
  9. #define RW_PORT PORTC
  10. #define EN_PORT PORTC
  11.  
  12. #define RS_DDR      DDRC
  13. #define RW_DDR      DDRC
  14. #define EN_DDR      DDRC
  15.  
  16. #define LCD_1_LINE_ADDR 0x80
  17. #define LCD_2_LINE_ADDR 0xC0
  18. #define LCD_3_LINE_ADDR 0x94
  19. #define LCD_4_LINE_ADDR 0xD4
  20.  
  21. //if defined LCD4, use 4-bit interface, else use 8-bit interface
  22. #define LCD4
  23.  
  24. void LCDInit(void);
  25.  
  26. void LCDBusy(void);
  27. void LCDData(unsigned char data);
  28. void LCDCommand(unsigned char cmd);
  29.  
  30. inline void LCDSetPosition(unsigned char line, unsigned char col)
  31. {
  32.     LCDBusy();
  33.  
  34.     unsigned char addr;
  35.     switch(line)
  36.     {
  37.         case 1: addr=LCD_1_LINE_ADDR; break;
  38.         case 2: addr=LCD_2_LINE_ADDR; break;
  39.         case 3: addr=LCD_3_LINE_ADDR; break;
  40.         case 4: addr=LCD_4_LINE_ADDR; break;
  41.         default:    addr=LCD_1_LINE_ADDR;
  42.     }
  43.     addr+=col;
  44.     LCDCommand(addr);
  45. }
  46.  
  47. inline void LCDWriteChar(char ch)
  48. {
  49.     LCDBusy();
  50.     LCDData(ch);
  51. }
  52.  
  53. void LCDWriteString(char* str, unsigned char strLen);
  54. void LCDWriteStringZ(char* str);
  55.  
  56. #endif  LCD_H_
RAW Paste Data
Top