LiquidCrystal_Prusa.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #ifndef LiquidCrystal_Prusa_h
  2. #define LiquidCrystal_Prusa_h
  3. #include <inttypes.h>
  4. #include <stddef.h>
  5. //#include "Print.h"
  6. // commands
  7. #define LCD_CLEARDISPLAY 0x01
  8. #define LCD_RETURNHOME 0x02
  9. #define LCD_ENTRYMODESET 0x04
  10. #define LCD_DISPLAYCONTROL 0x08
  11. #define LCD_CURSORSHIFT 0x10
  12. #define LCD_FUNCTIONSET 0x20
  13. #define LCD_SETCGRAMADDR 0x40
  14. #define LCD_SETDDRAMADDR 0x80
  15. // flags for display entry mode
  16. #define LCD_ENTRYRIGHT 0x00
  17. #define LCD_ENTRYLEFT 0x02
  18. #define LCD_ENTRYSHIFTINCREMENT 0x01
  19. #define LCD_ENTRYSHIFTDECREMENT 0x00
  20. // flags for display on/off control
  21. #define LCD_DISPLAYON 0x04
  22. #define LCD_DISPLAYOFF 0x00
  23. #define LCD_CURSORON 0x02
  24. #define LCD_CURSOROFF 0x00
  25. #define LCD_BLINKON 0x01
  26. #define LCD_BLINKOFF 0x00
  27. // flags for display/cursor shift
  28. #define LCD_DISPLAYMOVE 0x08
  29. #define LCD_CURSORMOVE 0x00
  30. #define LCD_MOVERIGHT 0x04
  31. #define LCD_MOVELEFT 0x00
  32. // flags for function set
  33. #define LCD_8BITMODE 0x10
  34. #define LCD_4BITMODE 0x00
  35. #define LCD_2LINE 0x08
  36. #define LCD_1LINE 0x00
  37. #define LCD_5x10DOTS 0x04
  38. #define LCD_5x8DOTS 0x00
  39. class LiquidCrystal_Prusa/* : public Print */{
  40. public:
  41. LiquidCrystal_Prusa(uint8_t rs, uint8_t enable,
  42. uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
  43. uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
  44. LiquidCrystal_Prusa(uint8_t rs, uint8_t rw, uint8_t enable,
  45. uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
  46. uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
  47. LiquidCrystal_Prusa(uint8_t rs, uint8_t rw, uint8_t enable,
  48. uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);
  49. LiquidCrystal_Prusa(uint8_t rs, uint8_t enable,
  50. uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);
  51. void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable,
  52. uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
  53. uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
  54. void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
  55. void begin_noclear(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
  56. void clear();
  57. void home();
  58. void noDisplay();
  59. void display();
  60. void noBlink();
  61. void blink();
  62. void noCursor();
  63. void cursor();
  64. void scrollDisplayLeft();
  65. void scrollDisplayRight();
  66. void leftToRight();
  67. void rightToLeft();
  68. void autoscroll();
  69. void noAutoscroll();
  70. void createChar(uint8_t, uint8_t[]);
  71. void setCursor(uint8_t, uint8_t);
  72. // virtual size_t write(uint8_t);
  73. size_t write(uint8_t);
  74. void command(uint8_t);
  75. void print(const char*);
  76. void print(char, int = 0);
  77. void print(unsigned char, int = 0);
  78. void print(int, int = 10);
  79. void print(unsigned int, int = 10);
  80. void print(long, int = 10);
  81. void print(unsigned long, int = 10);
  82. void print(double, int = 2);
  83. // void println(const String &s);
  84. void println(const char[]);
  85. void println(char, int = 0);
  86. void println(unsigned char, int = 0);
  87. void println(int, int = 10);
  88. void println(unsigned int, int = 10);
  89. void println(long, int = 10);
  90. void println(unsigned long, int = 10);
  91. void println(double, int = 2);
  92. void println(void);
  93. void printNumber(unsigned long n, uint8_t base);
  94. void printFloat(double number, uint8_t digits);
  95. // using Print::write;
  96. private:
  97. void send(uint8_t, uint8_t);
  98. void write4bits(uint8_t);
  99. void write8bits(uint8_t);
  100. void pulseEnable();
  101. uint8_t _rs_pin; // LOW: command. HIGH: character.
  102. uint8_t _rw_pin; // LOW: write to LCD. HIGH: read from LCD.
  103. uint8_t _enable_pin; // activated by a HIGH pulse.
  104. uint8_t _data_pins[8];
  105. uint8_t _displayfunction;
  106. uint8_t _displaycontrol;
  107. uint8_t _displaymode;
  108. uint8_t _initialized;
  109. uint8_t _numlines,_currline;
  110. uint8_t _escape[8];
  111. size_t escape_write(uint8_t value);
  112. };
  113. #define ESC_2J "\x1b[2J"
  114. #define ESC_25h "\x1b[?25h"
  115. #define ESC_25l "\x1b[?25l"
  116. #define ESC_H(c,r) "\x1b["#r";"#c"H"
  117. #endif