From the repository of Chandler Matz, I add a fix to be compliant with mbed6 (wait_ms doesn't exist any more)

Committer:
Sebastien Prouff
Date:
Wed Nov 10 18:47:43 2021 +0100
Revision:
0:86fab34f85f1
initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sebastien Prouff 0:86fab34f85f1 1 #include "mbed.h"
Sebastien Prouff 0:86fab34f85f1 2
Sebastien Prouff 0:86fab34f85f1 3 // I2C addresses for LCD and RGB
Sebastien Prouff 0:86fab34f85f1 4 #define LCD_ADDRESS (0x7c)
Sebastien Prouff 0:86fab34f85f1 5 #define RGB_ADDRESS (0xc4)
Sebastien Prouff 0:86fab34f85f1 6
Sebastien Prouff 0:86fab34f85f1 7 #define RED_REG 0x04
Sebastien Prouff 0:86fab34f85f1 8 #define GREEN_REG 0x03
Sebastien Prouff 0:86fab34f85f1 9 #define BLUE_REG 0x02
Sebastien Prouff 0:86fab34f85f1 10
Sebastien Prouff 0:86fab34f85f1 11 // commands
Sebastien Prouff 0:86fab34f85f1 12 #define LCD_CLEARDISPLAY 0x01
Sebastien Prouff 0:86fab34f85f1 13 #define LCD_DISPLAYCONTROL 0x08
Sebastien Prouff 0:86fab34f85f1 14 #define LCD_FUNCTIONSET 0x20
Sebastien Prouff 0:86fab34f85f1 15
Sebastien Prouff 0:86fab34f85f1 16 // flags for display on/off control
Sebastien Prouff 0:86fab34f85f1 17 #define LCD_DISPLAYON 0x04
Sebastien Prouff 0:86fab34f85f1 18 #define LCD_DISPLAYOFF 0x00
Sebastien Prouff 0:86fab34f85f1 19
Sebastien Prouff 0:86fab34f85f1 20 // flag for entry mode
Sebastien Prouff 0:86fab34f85f1 21 #define LCD_ENTRYLEFT 0x02
Sebastien Prouff 0:86fab34f85f1 22
Sebastien Prouff 0:86fab34f85f1 23 // flags for function set
Sebastien Prouff 0:86fab34f85f1 24 #define LCD_8BITMODE 0x10
Sebastien Prouff 0:86fab34f85f1 25 #define LCD_2LINE 0x08
Sebastien Prouff 0:86fab34f85f1 26 #define LCD_5x10DOTS 0x04
Sebastien Prouff 0:86fab34f85f1 27
Sebastien Prouff 0:86fab34f85f1 28 /** Grove_LCD_RGB_Backlight Class.
Sebastien Prouff 0:86fab34f85f1 29 * Used for connecting a Grove LCD RGB Backlit display
Sebastien Prouff 0:86fab34f85f1 30 * to an mbed microcontroller via an I2C interface.
Sebastien Prouff 0:86fab34f85f1 31 */
Sebastien Prouff 0:86fab34f85f1 32 class Grove_LCD_RGB_Backlight
Sebastien Prouff 0:86fab34f85f1 33 {
Sebastien Prouff 0:86fab34f85f1 34 public:
Sebastien Prouff 0:86fab34f85f1 35
Sebastien Prouff 0:86fab34f85f1 36 /** Contructor. Creates an instance of the Grove_LCD_RGB_Backlight class.
Sebastien Prouff 0:86fab34f85f1 37 * @param sda SDA pin on the mbed microcontroller which will be used to communicate with the display.
Sebastien Prouff 0:86fab34f85f1 38 * @param scl SCL pin on the mbed microcontroller which will be used to communicate with the display.
Sebastien Prouff 0:86fab34f85f1 39 */
Sebastien Prouff 0:86fab34f85f1 40 Grove_LCD_RGB_Backlight(PinName sda, PinName scl);
Sebastien Prouff 0:86fab34f85f1 41
Sebastien Prouff 0:86fab34f85f1 42
Sebastien Prouff 0:86fab34f85f1 43
Sebastien Prouff 0:86fab34f85f1 44 /** Set RGB color of backlight
Sebastien Prouff 0:86fab34f85f1 45 * @param r Value for the red component of the RGB backlight (Between 0 and 255).
Sebastien Prouff 0:86fab34f85f1 46 * @param g Value for the green component of the RGB backlight (Between 0 and 255).
Sebastien Prouff 0:86fab34f85f1 47 * @param b Value for the blue component of the RGB backlight (Between 0 and 255).
Sebastien Prouff 0:86fab34f85f1 48 */
Sebastien Prouff 0:86fab34f85f1 49 void setRGB(char r, char g, char b);
Sebastien Prouff 0:86fab34f85f1 50
Sebastien Prouff 0:86fab34f85f1 51
Sebastien Prouff 0:86fab34f85f1 52 /** Removes all of the text from the display.
Sebastien Prouff 0:86fab34f85f1 53 */
Sebastien Prouff 0:86fab34f85f1 54 void clear();
Sebastien Prouff 0:86fab34f85f1 55
Sebastien Prouff 0:86fab34f85f1 56 /**Prints text to the LCD display.
Sebastien Prouff 0:86fab34f85f1 57 * @param *str Pointer to an array of characters which will be printed to the LCD screen.
Sebastien Prouff 0:86fab34f85f1 58 */
Sebastien Prouff 0:86fab34f85f1 59 void print(char *str);
Sebastien Prouff 0:86fab34f85f1 60
Sebastien Prouff 0:86fab34f85f1 61 /**Move cursor to specified location on the LCD screen.
Sebastien Prouff 0:86fab34f85f1 62 * @param col Value for which column on the display the next text being printed will start at.
Sebastien Prouff 0:86fab34f85f1 63 * @param row Value for which row on the display the next text being printed will be printed on.
Sebastien Prouff 0:86fab34f85f1 64 */
Sebastien Prouff 0:86fab34f85f1 65 void locate(char col, char row);
Sebastien Prouff 0:86fab34f85f1 66
Sebastien Prouff 0:86fab34f85f1 67
Sebastien Prouff 0:86fab34f85f1 68 private:
Sebastien Prouff 0:86fab34f85f1 69
Sebastien Prouff 0:86fab34f85f1 70 //Initialize device
Sebastien Prouff 0:86fab34f85f1 71 void init();
Sebastien Prouff 0:86fab34f85f1 72
Sebastien Prouff 0:86fab34f85f1 73 //Turn on display
Sebastien Prouff 0:86fab34f85f1 74 void displayOn();
Sebastien Prouff 0:86fab34f85f1 75
Sebastien Prouff 0:86fab34f85f1 76 //Send command to display
Sebastien Prouff 0:86fab34f85f1 77 void sendCommand(char value);
Sebastien Prouff 0:86fab34f85f1 78
Sebastien Prouff 0:86fab34f85f1 79 //Set register value
Sebastien Prouff 0:86fab34f85f1 80 void setReg(char addr, char val);
Sebastien Prouff 0:86fab34f85f1 81
Sebastien Prouff 0:86fab34f85f1 82 //MBED I2C object used to transfer data to LCD
Sebastien Prouff 0:86fab34f85f1 83 I2C i2c;
Sebastien Prouff 0:86fab34f85f1 84
Sebastien Prouff 0:86fab34f85f1 85 };