http://uk.farnell.com/batron/bthq21605v-cog-fsre-i2c/lcd-module-alphanumeric-2x16/dp/1220409

Dependents:   PCF2119_16X2_LCD_test LPC1768BagSensor

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PC2119_16X2_LCD.h Source File

PC2119_16X2_LCD.h

00001 #ifndef PCF2119_16X2_LCD_H
00002 #define PCF2119_16X2_LCD_H
00003 
00004 #include "mbed.h"
00005 
00006 
00007 #define ASCII_OFFSET 0x80
00008 
00009 // Define LCD parameters
00010 #define LCD_I2C_ADR          0x76  // address + W
00011 
00012 #define FUNCTION_SET 0x34 //Function_set - 2 lines x 16, 1:18 Multiplex drive mode, 8 bits, basic instr. set
00013 #define DISPLAY_CTL 0x0C // Cursor off / Blink off / Character blink off
00014 
00015 #define INSTRUCTION_CTRL_BYTE 0x00
00016 #define DATA_CTRL_BYTE 0x40
00017 
00018 #define VLCD_MULTIPLIER 0x90
00019 #define VLCD_CONTRAST 0xA8
00020 #define ENTRY_MODE 0x06 // DDRAM or CGRAM address increments by 1, cursor moves to the right / Display does not shift
00021 #define CURSOR_DISLPAY_SHIFT 0x04 // cursor moves to the right (no display shift)
00022 #define ICON_CTRL 0x08 // direct mode off / icon blink disabled / character mode full display
00023 
00024 #define CLEAR_DISPLAY 0x01
00025 
00026 #define BLANK_CHAR ' '
00027 
00028 class PC2119_16X2_LCD {
00029 public:
00030     PC2119_16X2_LCD(PinName p_sda, PinName p_scl, PinName p_reset);
00031     PC2119_16X2_LCD(I2C& p_i2c, PinName p_reset);
00032     void Init();
00033     void flip_display();
00034     void unflip_display();
00035     void clear_display();
00036     void clear_line(char row);
00037     void write_xy(char ddram_byte, char row, char column, bool raw = false);
00038     void write(char *b);
00039     void printf(const char * format, ... );
00040 protected:    
00041 
00042 private:
00043     I2C _i2c;
00044     DigitalOut _reset;
00045     
00046     char ascii_to_lcd(char ch);
00047 
00048 };
00049 
00050 #endif