Ruengrid Witoonpan
/
UltraSonic1
Help me please
LiquidCrystal_I2C.h@0:b78e02ab7cde, 2020-01-15 (annotated)
- Committer:
- koko1121
- Date:
- Wed Jan 15 17:17:21 2020 +0000
- Revision:
- 0:b78e02ab7cde
Error: Too many arguments in function call in "main.cpp", Line: 27, Col: 28;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
koko1121 | 0:b78e02ab7cde | 1 | #ifndef FDB_LIQUID_CRYSTAL_I2C_H |
koko1121 | 0:b78e02ab7cde | 2 | #define FDB_LIQUID_CRYSTAL_I2C_H |
koko1121 | 0:b78e02ab7cde | 3 | |
koko1121 | 0:b78e02ab7cde | 4 | //#include <inttypes.h> |
koko1121 | 0:b78e02ab7cde | 5 | //#include <Print.h> |
koko1121 | 0:b78e02ab7cde | 6 | |
koko1121 | 0:b78e02ab7cde | 7 | // commands |
koko1121 | 0:b78e02ab7cde | 8 | #define LCD_CLEARDISPLAY 0x01 |
koko1121 | 0:b78e02ab7cde | 9 | #define LCD_RETURNHOME 0x02 |
koko1121 | 0:b78e02ab7cde | 10 | #define LCD_ENTRYMODESET 0x04 |
koko1121 | 0:b78e02ab7cde | 11 | #define LCD_DISPLAYCONTROL 0x08 |
koko1121 | 0:b78e02ab7cde | 12 | #define LCD_CURSORSHIFT 0x10 |
koko1121 | 0:b78e02ab7cde | 13 | #define LCD_FUNCTIONSET 0x20 |
koko1121 | 0:b78e02ab7cde | 14 | #define LCD_SETCGRAMADDR 0x40 |
koko1121 | 0:b78e02ab7cde | 15 | #define LCD_SETDDRAMADDR 0x80 |
koko1121 | 0:b78e02ab7cde | 16 | |
koko1121 | 0:b78e02ab7cde | 17 | // flags for display entry mode |
koko1121 | 0:b78e02ab7cde | 18 | #define LCD_ENTRYRIGHT 0x00 |
koko1121 | 0:b78e02ab7cde | 19 | #define LCD_ENTRYLEFT 0x02 |
koko1121 | 0:b78e02ab7cde | 20 | #define LCD_ENTRYSHIFTINCREMENT 0x01 |
koko1121 | 0:b78e02ab7cde | 21 | #define LCD_ENTRYSHIFTDECREMENT 0x00 |
koko1121 | 0:b78e02ab7cde | 22 | |
koko1121 | 0:b78e02ab7cde | 23 | // flags for display on/off control |
koko1121 | 0:b78e02ab7cde | 24 | #define LCD_DISPLAYON 0x04 |
koko1121 | 0:b78e02ab7cde | 25 | #define LCD_DISPLAYOFF 0x00 |
koko1121 | 0:b78e02ab7cde | 26 | #define LCD_CURSORON 0x02 |
koko1121 | 0:b78e02ab7cde | 27 | #define LCD_CURSOROFF 0x00 |
koko1121 | 0:b78e02ab7cde | 28 | #define LCD_BLINKON 0x01 |
koko1121 | 0:b78e02ab7cde | 29 | #define LCD_BLINKOFF 0x00 |
koko1121 | 0:b78e02ab7cde | 30 | |
koko1121 | 0:b78e02ab7cde | 31 | // flags for display/cursor shift |
koko1121 | 0:b78e02ab7cde | 32 | #define LCD_DISPLAYMOVE 0x08 |
koko1121 | 0:b78e02ab7cde | 33 | #define LCD_CURSORMOVE 0x00 |
koko1121 | 0:b78e02ab7cde | 34 | #define LCD_MOVERIGHT 0x04 |
koko1121 | 0:b78e02ab7cde | 35 | #define LCD_MOVELEFT 0x00 |
koko1121 | 0:b78e02ab7cde | 36 | |
koko1121 | 0:b78e02ab7cde | 37 | // flags for function set |
koko1121 | 0:b78e02ab7cde | 38 | #define LCD_8BITMODE 0x10 |
koko1121 | 0:b78e02ab7cde | 39 | #define LCD_4BITMODE 0x00 |
koko1121 | 0:b78e02ab7cde | 40 | #define LCD_2LINE 0x08 |
koko1121 | 0:b78e02ab7cde | 41 | #define LCD_1LINE 0x00 |
koko1121 | 0:b78e02ab7cde | 42 | #define LCD_5x10DOTS 0x04 |
koko1121 | 0:b78e02ab7cde | 43 | #define LCD_5x8DOTS 0x00 |
koko1121 | 0:b78e02ab7cde | 44 | |
koko1121 | 0:b78e02ab7cde | 45 | // flags for backlight control |
koko1121 | 0:b78e02ab7cde | 46 | #define LCD_BACKLIGHT 0x08 |
koko1121 | 0:b78e02ab7cde | 47 | #define LCD_NOBACKLIGHT 0x00 |
koko1121 | 0:b78e02ab7cde | 48 | |
koko1121 | 0:b78e02ab7cde | 49 | #define En 0x04//B00000100 // Enable bit |
koko1121 | 0:b78e02ab7cde | 50 | #define Rw 0x02 // B00000010 // Read/Write bit |
koko1121 | 0:b78e02ab7cde | 51 | #define Rs 0x01 //B00000001 // Register select bit |
koko1121 | 0:b78e02ab7cde | 52 | |
koko1121 | 0:b78e02ab7cde | 53 | /** |
koko1121 | 0:b78e02ab7cde | 54 | * This is the driver for the Liquid Crystal LCD displays that use the I2C bus. |
koko1121 | 0:b78e02ab7cde | 55 | * |
koko1121 | 0:b78e02ab7cde | 56 | * After creating an instance of this class, first call begin() before anything else. |
koko1121 | 0:b78e02ab7cde | 57 | * The backlight is on by default, since that is the most likely operating mode in |
koko1121 | 0:b78e02ab7cde | 58 | * most cases. |
koko1121 | 0:b78e02ab7cde | 59 | */ |
koko1121 | 0:b78e02ab7cde | 60 | class LiquidCrystal_I2C { |
koko1121 | 0:b78e02ab7cde | 61 | public: |
koko1121 | 0:b78e02ab7cde | 62 | /** |
koko1121 | 0:b78e02ab7cde | 63 | * Constructor |
koko1121 | 0:b78e02ab7cde | 64 | * |
koko1121 | 0:b78e02ab7cde | 65 | * @param lcd_addr I2C slave address of the LCD display. Most likely printed on the |
koko1121 | 0:b78e02ab7cde | 66 | * LCD circuit board, or look in the supplied LCD documentation. |
koko1121 | 0:b78e02ab7cde | 67 | * @param lcd_cols Number of columns your LCD display has. |
koko1121 | 0:b78e02ab7cde | 68 | * @param lcd_rows Number of rows your LCD display has. |
koko1121 | 0:b78e02ab7cde | 69 | * @param charsize The size in dots that the display has, use LCD_5x10DOTS or LCD_5x8DOTS. |
koko1121 | 0:b78e02ab7cde | 70 | */ |
koko1121 | 0:b78e02ab7cde | 71 | LiquidCrystal_I2C(unsigned char lcd_addr, unsigned char lcd_cols, unsigned char lcd_rows, unsigned char charsize = LCD_5x8DOTS); |
koko1121 | 0:b78e02ab7cde | 72 | |
koko1121 | 0:b78e02ab7cde | 73 | /** |
koko1121 | 0:b78e02ab7cde | 74 | * Set the LCD display in the correct begin state, must be called before anything else is done. |
koko1121 | 0:b78e02ab7cde | 75 | */ |
koko1121 | 0:b78e02ab7cde | 76 | void begin(); |
koko1121 | 0:b78e02ab7cde | 77 | |
koko1121 | 0:b78e02ab7cde | 78 | /** |
koko1121 | 0:b78e02ab7cde | 79 | * Remove all the characters currently shown. Next print/write operation will start |
koko1121 | 0:b78e02ab7cde | 80 | * from the first position on LCD display. |
koko1121 | 0:b78e02ab7cde | 81 | */ |
koko1121 | 0:b78e02ab7cde | 82 | void clear(); |
koko1121 | 0:b78e02ab7cde | 83 | |
koko1121 | 0:b78e02ab7cde | 84 | /** |
koko1121 | 0:b78e02ab7cde | 85 | * Next print/write operation will will start from the first position on the LCD display. |
koko1121 | 0:b78e02ab7cde | 86 | */ |
koko1121 | 0:b78e02ab7cde | 87 | void home(); |
koko1121 | 0:b78e02ab7cde | 88 | |
koko1121 | 0:b78e02ab7cde | 89 | /** |
koko1121 | 0:b78e02ab7cde | 90 | * Do not show any characters on the LCD display. Backlight state will remain unchanged. |
koko1121 | 0:b78e02ab7cde | 91 | * Also all characters written on the display will return, when the display in enabled again. |
koko1121 | 0:b78e02ab7cde | 92 | */ |
koko1121 | 0:b78e02ab7cde | 93 | void noDisplay(); |
koko1121 | 0:b78e02ab7cde | 94 | |
koko1121 | 0:b78e02ab7cde | 95 | /** |
koko1121 | 0:b78e02ab7cde | 96 | * Show the characters on the LCD display, this is the normal behaviour. This method should |
koko1121 | 0:b78e02ab7cde | 97 | * only be used after noDisplay() has been used. |
koko1121 | 0:b78e02ab7cde | 98 | */ |
koko1121 | 0:b78e02ab7cde | 99 | void display(); |
koko1121 | 0:b78e02ab7cde | 100 | |
koko1121 | 0:b78e02ab7cde | 101 | /** |
koko1121 | 0:b78e02ab7cde | 102 | * Do not blink the cursor indicator. |
koko1121 | 0:b78e02ab7cde | 103 | */ |
koko1121 | 0:b78e02ab7cde | 104 | void noBlink(); |
koko1121 | 0:b78e02ab7cde | 105 | |
koko1121 | 0:b78e02ab7cde | 106 | /** |
koko1121 | 0:b78e02ab7cde | 107 | * Start blinking the cursor indicator. |
koko1121 | 0:b78e02ab7cde | 108 | */ |
koko1121 | 0:b78e02ab7cde | 109 | void blink(); |
koko1121 | 0:b78e02ab7cde | 110 | |
koko1121 | 0:b78e02ab7cde | 111 | /** |
koko1121 | 0:b78e02ab7cde | 112 | * Do not show a cursor indicator. |
koko1121 | 0:b78e02ab7cde | 113 | */ |
koko1121 | 0:b78e02ab7cde | 114 | void noCursor(); |
koko1121 | 0:b78e02ab7cde | 115 | |
koko1121 | 0:b78e02ab7cde | 116 | /** |
koko1121 | 0:b78e02ab7cde | 117 | * Show a cursor indicator, cursor can blink on not blink. Use the |
koko1121 | 0:b78e02ab7cde | 118 | * methods blink() and noBlink() for changing cursor blink. |
koko1121 | 0:b78e02ab7cde | 119 | */ |
koko1121 | 0:b78e02ab7cde | 120 | void cursor(); |
koko1121 | 0:b78e02ab7cde | 121 | |
koko1121 | 0:b78e02ab7cde | 122 | void scrollDisplayLeft(); |
koko1121 | 0:b78e02ab7cde | 123 | void scrollDisplayRight(); |
koko1121 | 0:b78e02ab7cde | 124 | void printLeft(); |
koko1121 | 0:b78e02ab7cde | 125 | void printRight(); |
koko1121 | 0:b78e02ab7cde | 126 | void leftToRight(); |
koko1121 | 0:b78e02ab7cde | 127 | void rightToLeft(); |
koko1121 | 0:b78e02ab7cde | 128 | void shiftIncrement(); |
koko1121 | 0:b78e02ab7cde | 129 | void shiftDecrement(); |
koko1121 | 0:b78e02ab7cde | 130 | void noBacklight(); |
koko1121 | 0:b78e02ab7cde | 131 | void backlight(); |
koko1121 | 0:b78e02ab7cde | 132 | bool getBacklight(); |
koko1121 | 0:b78e02ab7cde | 133 | void autoscroll(); |
koko1121 | 0:b78e02ab7cde | 134 | void noAutoscroll(); |
koko1121 | 0:b78e02ab7cde | 135 | void createChar(unsigned char, unsigned char[]); |
koko1121 | 0:b78e02ab7cde | 136 | void setCursor(unsigned char, unsigned char); |
koko1121 | 0:b78e02ab7cde | 137 | virtual int write(unsigned char); |
koko1121 | 0:b78e02ab7cde | 138 | void command(unsigned char); |
koko1121 | 0:b78e02ab7cde | 139 | |
koko1121 | 0:b78e02ab7cde | 140 | inline void blink_on() { blink(); } |
koko1121 | 0:b78e02ab7cde | 141 | inline void blink_off() { noBlink(); } |
koko1121 | 0:b78e02ab7cde | 142 | inline void cursor_on() { cursor(); } |
koko1121 | 0:b78e02ab7cde | 143 | inline void cursor_off() { noCursor(); } |
koko1121 | 0:b78e02ab7cde | 144 | |
koko1121 | 0:b78e02ab7cde | 145 | // Compatibility API function aliases |
koko1121 | 0:b78e02ab7cde | 146 | void setBacklight(unsigned char new_val); // alias for backlight() and nobacklight() |
koko1121 | 0:b78e02ab7cde | 147 | void load_custom_character(unsigned char char_num, unsigned char *rows); // alias for createChar() |
koko1121 | 0:b78e02ab7cde | 148 | void printstr(const char[]); |
koko1121 | 0:b78e02ab7cde | 149 | int print(const char* text); |
koko1121 | 0:b78e02ab7cde | 150 | private: |
koko1121 | 0:b78e02ab7cde | 151 | void send(unsigned char, unsigned char); |
koko1121 | 0:b78e02ab7cde | 152 | void write4bits(unsigned char); |
koko1121 | 0:b78e02ab7cde | 153 | void expanderWrite(unsigned char); |
koko1121 | 0:b78e02ab7cde | 154 | void pulseEnable(unsigned char); |
koko1121 | 0:b78e02ab7cde | 155 | unsigned char _addr; |
koko1121 | 0:b78e02ab7cde | 156 | unsigned char _displayfunction; |
koko1121 | 0:b78e02ab7cde | 157 | unsigned char _displaycontrol; |
koko1121 | 0:b78e02ab7cde | 158 | unsigned char _displaymode; |
koko1121 | 0:b78e02ab7cde | 159 | unsigned char _cols; |
koko1121 | 0:b78e02ab7cde | 160 | unsigned char _rows; |
koko1121 | 0:b78e02ab7cde | 161 | unsigned char _charsize; |
koko1121 | 0:b78e02ab7cde | 162 | unsigned char _backlightval; |
koko1121 | 0:b78e02ab7cde | 163 | }; |
koko1121 | 0:b78e02ab7cde | 164 | |
koko1121 | 0:b78e02ab7cde | 165 | #endif // FDB_LIQUID_CRYSTAL_I2C_H |