Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

max_LCD.h 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
  2. This software may be distributed and modified under the terms of the GNU
  3. General Public License version 2 (GPL2) as published by the Free Software
  4. Foundation and appearing in the file GPL2.TXT included in the packaging of
  5. this file. Please note that GPL2 Section 2[b] requires that all works based
  6. on this software must also be made publicly available under the terms of
  7. the GPL2 ("Copyleft").
  8. Contact information
  9. -------------------
  10. Circuits At Home, LTD
  11. Web : http://www.circuitsathome.com
  12. e-mail : [email protected]
  13. */
  14. //HD44780 compatible LCD display via MAX3421E GPOUT support header
  15. //pinout: D[4-7] -> GPOUT[4-7], RS-> GPOUT[2], E ->GPOUT[3]
  16. //
  17. #ifndef _Max_LCD_h_
  18. #define _Max_LCD_h_
  19. #include "Usb.h"
  20. #include "Print.h"
  21. // commands
  22. #define LCD_CLEARDISPLAY 0x01
  23. #define LCD_RETURNHOME 0x02
  24. #define LCD_ENTRYMODESET 0x04
  25. #define LCD_DISPLAYCONTROL 0x08
  26. #define LCD_CURSORSHIFT 0x10
  27. #define LCD_FUNCTIONSET 0x20
  28. #define LCD_SETCGRAMADDR 0x40
  29. #define LCD_SETDDRAMADDR 0x80
  30. // flags for display entry mode
  31. #define LCD_ENTRYRIGHT 0x00
  32. #define LCD_ENTRYLEFT 0x02
  33. #define LCD_ENTRYSHIFTINCREMENT 0x01
  34. #define LCD_ENTRYSHIFTDECREMENT 0x00
  35. // flags for display on/off control
  36. #define LCD_DISPLAYON 0x04
  37. #define LCD_DISPLAYOFF 0x00
  38. #define LCD_CURSORON 0x02
  39. #define LCD_CURSOROFF 0x00
  40. #define LCD_BLINKON 0x01
  41. #define LCD_BLINKOFF 0x00
  42. // flags for display/cursor shift
  43. #define LCD_DISPLAYMOVE 0x08
  44. #define LCD_CURSORMOVE 0x00
  45. #define LCD_MOVERIGHT 0x04
  46. #define LCD_MOVELEFT 0x00
  47. // flags for function set
  48. #define LCD_8BITMODE 0x10
  49. #define LCD_4BITMODE 0x00
  50. #define LCD_2LINE 0x08
  51. #define LCD_1LINE 0x00
  52. #define LCD_5x10DOTS 0x04
  53. #define LCD_5x8DOTS 0x00
  54. class Max_LCD : public Print {
  55. USB *pUsb;
  56. public:
  57. Max_LCD(USB *pusb);
  58. void init();
  59. void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
  60. void clear();
  61. void home();
  62. void noDisplay();
  63. void display();
  64. void noBlink();
  65. void blink();
  66. void noCursor();
  67. void cursor();
  68. void scrollDisplayLeft();
  69. void scrollDisplayRight();
  70. void leftToRight();
  71. void rightToLeft();
  72. void autoscroll();
  73. void noAutoscroll();
  74. void createChar(uint8_t, uint8_t[]);
  75. void setCursor(uint8_t, uint8_t);
  76. void command(uint8_t);
  77. #if defined(ARDUINO) && ARDUINO >=100
  78. size_t write(uint8_t);
  79. using Print::write;
  80. #else
  81. void write(uint8_t);
  82. #endif
  83. private:
  84. void sendbyte(uint8_t val);
  85. uint8_t _displayfunction; //tokill
  86. uint8_t _displaycontrol;
  87. uint8_t _displaymode;
  88. uint8_t _initialized;
  89. uint8_t _numlines, _currline;
  90. };
  91. #endif