Miguel Urco / I2CLCD

Dependents:   JRO_CR2 frdm_test JRO_DDSv2 JRO_DDSv2_rev2019

Fork of I2CLCD by Suga koubou

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers I2CLCD.h Source File

I2CLCD.h

Go to the documentation of this file.
00001 /*
00002  * mbed library for I2C LCD
00003  * Copyright (c) 2011 Hiroshi Suga
00004  * Released under the MIT License: http://mbed.org/license/mit
00005  *
00006  * This product includes:
00007  * mbed TextLCD Library, for a 4-bit LCD based on HD44780
00008  * Copyright (c) 2007-2010, sford
00009  */
00010 
00011 /** @file I2CLCD.h
00012  * @brief I2C LCD library (mbed Phone Platform)
00013  */
00014  
00015 #ifndef I2CLCD_H
00016 #define I2CLCD_H
00017 
00018 #include "mbed.h"
00019 
00020 #define LCD_NHD_C022BiZ
00021 /**
00022  * @brief default I2C address
00023  */
00024 
00025 #ifdef LCD_NHD_C022BiZ
00026 
00027 #define I2CLCD_ADDR         0x7c
00028 #define INST_FUNC           0x38
00029 #define INST_SHIFT          0x10
00030 #define INST_DISPLAY        0x0f
00031 #define INST_CLEAR          0x01
00032 #define INST_ENTRY_MODE     0x06
00033 
00034 #else
00035 
00036 #define I2CLCD_ADDR         0x7c
00037 #define INST_FUNC           0x38
00038 #define INST_SHIFT          0x10
00039 #define INST_DISPLAY        0x0c
00040 #define INST_CLEAR          0x01
00041 #define INST_ENTRY_MODE     0x06
00042 
00043 #endif
00044 
00045 
00046 /**
00047  * @brief LCD type
00048  */
00049 enum I2CLCDType {
00050     LCD8x2,
00051     LCD16x1,
00052     LCD16x2,
00053     LCD16x2B,
00054     LCD16x4,
00055     LCD20x2,
00056     LCD20x4
00057 };
00058 
00059 /**
00060  * @brief LCD config
00061  */
00062 enum I2CLCDConfig {
00063     LCDCFG_ENABLE   = 0x20,
00064     LCDCFG_PWMCOUNT = 0x10,
00065     LCDCFG_LED      = 0x08,
00066     LCDCFG_3V       = 0x04,
00067     LCDCFG_ADDR     = 0x02,
00068     LCDCFG_INIT     = 0x01
00069 };
00070 
00071 /**
00072  * @brief I2CLCD class
00073  */
00074 class I2CLCD : public Stream {
00075 public:
00076     I2CLCD (PinName p_sda, PinName p_scl, int p_i2caddr = I2CLCD_ADDR, I2CLCDType p_type = LCD16x2, I2CLCDConfig p_config = LCDCFG_3V);
00077     I2CLCD (I2C& p_i2c, int p_i2caddr = I2CLCD_ADDR, I2CLCDType p_type = LCD16x2, I2CLCDConfig p_config = LCDCFG_3V);
00078 
00079     void locate (int, int);
00080     void cls ();
00081     void lcd_cfg (I2CLCDConfig);
00082     void printf ( const char* text, int x=0, int y=0);
00083     
00084 protected:
00085     virtual int _putc (int);
00086     virtual int _getc ();
00087     
00088     int address (int, int);
00089     int rows ();
00090     int cols ();
00091     void init (int, I2CLCDType, I2CLCDConfig);
00092     void lcd_out (char, char = 0);
00093     char lcd_in (char);
00094 
00095     I2C i2c;
00096     int i2caddr;
00097     I2CLCDType type;
00098     int x, y;
00099 };
00100 
00101 #endif