Grove LCD Library
Grove_LCD_RGB_Backlight.h@0:253885b1f364, 2016-03-15 (annotated)
- Committer:
- cmatz3
- Date:
- Tue Mar 15 17:19:39 2016 +0000
- Revision:
- 0:253885b1f364
- Child:
- 1:40a3b6506c9f
Initial Commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cmatz3 | 0:253885b1f364 | 1 | #include "mbed.h" |
cmatz3 | 0:253885b1f364 | 2 | |
cmatz3 | 0:253885b1f364 | 3 | // I2C addresses for LCD and RGB |
cmatz3 | 0:253885b1f364 | 4 | #define LCD_ADDRESS (0x7c) |
cmatz3 | 0:253885b1f364 | 5 | #define RGB_ADDRESS (0xc4) |
cmatz3 | 0:253885b1f364 | 6 | |
cmatz3 | 0:253885b1f364 | 7 | #define RED_REG 0x04 |
cmatz3 | 0:253885b1f364 | 8 | #define GREEN_REG 0x03 |
cmatz3 | 0:253885b1f364 | 9 | #define BLUE_REG 0x02 |
cmatz3 | 0:253885b1f364 | 10 | |
cmatz3 | 0:253885b1f364 | 11 | // commands |
cmatz3 | 0:253885b1f364 | 12 | #define LCD_CLEARDISPLAY 0x01 |
cmatz3 | 0:253885b1f364 | 13 | #define LCD_DISPLAYCONTROL 0x08 |
cmatz3 | 0:253885b1f364 | 14 | #define LCD_FUNCTIONSET 0x20 |
cmatz3 | 0:253885b1f364 | 15 | |
cmatz3 | 0:253885b1f364 | 16 | // flags for display on/off control |
cmatz3 | 0:253885b1f364 | 17 | #define LCD_DISPLAYON 0x04 |
cmatz3 | 0:253885b1f364 | 18 | #define LCD_DISPLAYOFF 0x00 |
cmatz3 | 0:253885b1f364 | 19 | |
cmatz3 | 0:253885b1f364 | 20 | // flag for entry mode |
cmatz3 | 0:253885b1f364 | 21 | #define LCD_ENTRYLEFT 0x02 |
cmatz3 | 0:253885b1f364 | 22 | |
cmatz3 | 0:253885b1f364 | 23 | // flags for function set |
cmatz3 | 0:253885b1f364 | 24 | #define LCD_8BITMODE 0x10 |
cmatz3 | 0:253885b1f364 | 25 | #define LCD_2LINE 0x08 |
cmatz3 | 0:253885b1f364 | 26 | #define LCD_5x10DOTS 0x04 |
cmatz3 | 0:253885b1f364 | 27 | |
cmatz3 | 0:253885b1f364 | 28 | |
cmatz3 | 0:253885b1f364 | 29 | class Grove_LCD_RGB_Backlight |
cmatz3 | 0:253885b1f364 | 30 | { |
cmatz3 | 0:253885b1f364 | 31 | public: |
cmatz3 | 0:253885b1f364 | 32 | |
cmatz3 | 0:253885b1f364 | 33 | //Contructor |
cmatz3 | 0:253885b1f364 | 34 | Grove_LCD_RGB_Backlight(PinName sda, PinName scl); |
cmatz3 | 0:253885b1f364 | 35 | |
cmatz3 | 0:253885b1f364 | 36 | |
cmatz3 | 0:253885b1f364 | 37 | |
cmatz3 | 0:253885b1f364 | 38 | //Set RGB Color of backglight |
cmatz3 | 0:253885b1f364 | 39 | void setRGB(char r, char g, char b); |
cmatz3 | 0:253885b1f364 | 40 | |
cmatz3 | 0:253885b1f364 | 41 | //Initialize device |
cmatz3 | 0:253885b1f364 | 42 | void init(); |
cmatz3 | 0:253885b1f364 | 43 | |
cmatz3 | 0:253885b1f364 | 44 | //Turn on display |
cmatz3 | 0:253885b1f364 | 45 | void displayOn(); |
cmatz3 | 0:253885b1f364 | 46 | |
cmatz3 | 0:253885b1f364 | 47 | //Clear all text from display |
cmatz3 | 0:253885b1f364 | 48 | void clear(); |
cmatz3 | 0:253885b1f364 | 49 | |
cmatz3 | 0:253885b1f364 | 50 | //Print text to the lcd screen |
cmatz3 | 0:253885b1f364 | 51 | void print(char *str); |
cmatz3 | 0:253885b1f364 | 52 | |
cmatz3 | 0:253885b1f364 | 53 | //Move cursor to specified location |
cmatz3 | 0:253885b1f364 | 54 | void locate(char col, char row); |
cmatz3 | 0:253885b1f364 | 55 | |
cmatz3 | 0:253885b1f364 | 56 | |
cmatz3 | 0:253885b1f364 | 57 | private: |
cmatz3 | 0:253885b1f364 | 58 | |
cmatz3 | 0:253885b1f364 | 59 | //Send command to display |
cmatz3 | 0:253885b1f364 | 60 | void sendCommand(char value); |
cmatz3 | 0:253885b1f364 | 61 | |
cmatz3 | 0:253885b1f364 | 62 | //Set register value |
cmatz3 | 0:253885b1f364 | 63 | void setReg(char addr, char val); |
cmatz3 | 0:253885b1f364 | 64 | |
cmatz3 | 0:253885b1f364 | 65 | //MBED I2C object used to transfer data to LCD |
cmatz3 | 0:253885b1f364 | 66 | I2C i2c; |
cmatz3 | 0:253885b1f364 | 67 | |
cmatz3 | 0:253885b1f364 | 68 | }; |