CPP   7

SerialLCD.h

Guest on 2nd August 2021 03:17:46 PM

  1. /*
  2.   SerialLCD.h - Serial LCD driver Library
  3.   2011 Copyright (c) Seeed Technology Inc.  All right reserved.
  4.   For Serial LCD v1.0b firmware.
  5.  
  6.   Original Author: Jimbo.We
  7.   Contribution: Visweswara R
  8.  
  9.   This library is free software; you can redistribute it and/or
  10.   modify it under the terms of the GNU Lesser General Public
  11.   License as published by the Free Software Foundation; either
  12.   version 2.1 of the License, or (at your option) any later version.
  13.  
  14.   This library is distributed in the hope that it will be useful,
  15.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17.   Lesser General Public License for more details.
  18.  
  19.   You should have received a copy of the GNU Lesser General Public
  20.   License along with this library; if not, write to the Free Software
  21.   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  22. */
  23.  
  24. #ifndef SERIAL_LCD_H
  25. #define SERIAL_LCD_H
  26.  
  27. #include <inttypes.h>
  28. #include "WProgram.h"
  29. #include <NewSoftSerial.h>
  30.  
  31. //Initialization Commands or Responses
  32.  
  33. #define UART_READY      0xA3
  34. #define SLCD_INIT_ACK   0xA5
  35. #define SLCD_INIT_DONE  0xAA
  36.  
  37. //WorkingMode Commands or Responses
  38. #define SLCD_CONTROL_HEADER     0x9F
  39. #define SLCD_CHAR_HEADER        0xFE
  40. #define SLCD_CURSOR_HEADER      0xFF
  41. #define SLCD_CURSOR_ACK         0x5A
  42.  
  43. #define SLCD_RETURN_HOME        0x61
  44. #define SLCD_DISPLAY_OFF        0x63
  45. #define SLCD_DISPLAY_ON         0x64
  46. #define SLCD_CLEAR_DISPLAY      0x65
  47. #define SLCD_CURSOR_OFF         0x66
  48. #define SLCD_CURSOR_ON          0x67
  49. #define SLCD_BLINK_OFF          0x68
  50. #define SLCD_BLINK_ON           0x69
  51. #define SLCD_SCROLL_LEFT        0x6C
  52. #define SLCD_SCROLL_RIGHT       0x72
  53. #define SLCD_NO_AUTO_SCROLL     0x6A
  54. #define SLCD_AUTO_SCROLL        0x6D
  55. #define SLCD_LEFT_TO_RIGHT      0x70
  56. #define SLCD_RIGHT_TO_LEFT      0x71
  57.  
  58. #define SLCD_BACKLIGHT_ON       0x81
  59. #define SLCD_BACKLIGHT_OFF      0x80
  60. #define SLCD_POWER_ON           0x83
  61. #define SLCD_POWER_OFF          0x82
  62.  
  63. #define SLCD_INVALIDCOMMAND     0x46
  64.  
  65.  
  66. class SerialLCD : public NewSoftSerial{
  67. public:
  68.  
  69.     SerialLCD(uint8_t, uint8_t);
  70.     void begin();
  71.     void clear();
  72.     void home();
  73.    
  74.     void noPower();        
  75.     void power();  
  76.     void noBacklight();
  77.     void backlight();    
  78.     void noDisplay();
  79.     void display();
  80.     void noBlink();
  81.     void blink();
  82.     void noCursor();
  83.     void cursor();
  84.     void scrollDisplayLeft();
  85.     void scrollDisplayRight();
  86.     void leftToRight();
  87.     void rightToLeft();
  88.     void autoscroll();
  89.     void noAutoscroll();
  90.  
  91.     void setCursor(uint8_t, uint8_t);
  92.  
  93.     void print(uint8_t b);
  94.     void print(const char[]);
  95.     void print(unsigned long n, uint8_t base);
  96.  
  97. };
  98.  
  99. #endif

Raw Paste


Login or Register to edit or fork this paste. It's free.