character LCD module to I2C adapter Reference http://mbed.org/users/okini3939/notebook/i2c-lcd-library/

Dependents:   JRO_CR2 frdm_test JRO_DDSv2 JRO_DDSv2_rev2019

Fork of I2CLCD by Suga koubou

Committer:
miguelcordero191
Date:
Mon Feb 23 20:37:14 2015 +0000
Revision:
3:0c291dbc7acc
Parent:
2:bc4583ce560e
Some comments were added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okini3939 0:b069b7027af2 1 /*
okini3939 1:bf21aa3f7cdc 2 * mbed library for I2C LCD
okini3939 2:bc4583ce560e 3 * Copyright (c) 2011 Hiroshi Suga
okini3939 0:b069b7027af2 4 * Released under the MIT License: http://mbed.org/license/mit
okini3939 1:bf21aa3f7cdc 5 *
okini3939 2:bc4583ce560e 6 * This product includes:
okini3939 1:bf21aa3f7cdc 7 * mbed TextLCD Library, for a 4-bit LCD based on HD44780
okini3939 1:bf21aa3f7cdc 8 * Copyright (c) 2007-2010, sford
okini3939 0:b069b7027af2 9 */
okini3939 2:bc4583ce560e 10
okini3939 2:bc4583ce560e 11 /** @file I2CLCD.h
okini3939 2:bc4583ce560e 12 * @brief I2C LCD library (mbed Phone Platform)
okini3939 2:bc4583ce560e 13 */
okini3939 0:b069b7027af2 14
okini3939 0:b069b7027af2 15 #ifndef I2CLCD_H
okini3939 0:b069b7027af2 16 #define I2CLCD_H
okini3939 0:b069b7027af2 17
okini3939 0:b069b7027af2 18 #include "mbed.h"
okini3939 0:b069b7027af2 19
miguelcordero191 3:0c291dbc7acc 20 #define LCD_NHD_C022BiZ
okini3939 2:bc4583ce560e 21 /**
okini3939 2:bc4583ce560e 22 * @brief default I2C address
okini3939 2:bc4583ce560e 23 */
miguelcordero191 3:0c291dbc7acc 24
miguelcordero191 3:0c291dbc7acc 25 #ifdef LCD_NHD_C022BiZ
miguelcordero191 3:0c291dbc7acc 26
miguelcordero191 3:0c291dbc7acc 27 #define I2CLCD_ADDR 0x7c
miguelcordero191 3:0c291dbc7acc 28 #define INST_FUNC 0x38
miguelcordero191 3:0c291dbc7acc 29 #define INST_SHIFT 0x10
miguelcordero191 3:0c291dbc7acc 30 #define INST_DISPLAY 0x0f
miguelcordero191 3:0c291dbc7acc 31 #define INST_CLEAR 0x01
miguelcordero191 3:0c291dbc7acc 32 #define INST_ENTRY_MODE 0x06
miguelcordero191 3:0c291dbc7acc 33
miguelcordero191 3:0c291dbc7acc 34 #else
miguelcordero191 3:0c291dbc7acc 35
miguelcordero191 3:0c291dbc7acc 36 #define I2CLCD_ADDR 0x7c
miguelcordero191 3:0c291dbc7acc 37 #define INST_FUNC 0x38
miguelcordero191 3:0c291dbc7acc 38 #define INST_SHIFT 0x10
miguelcordero191 3:0c291dbc7acc 39 #define INST_DISPLAY 0x0c
miguelcordero191 3:0c291dbc7acc 40 #define INST_CLEAR 0x01
miguelcordero191 3:0c291dbc7acc 41 #define INST_ENTRY_MODE 0x06
miguelcordero191 3:0c291dbc7acc 42
miguelcordero191 3:0c291dbc7acc 43 #endif
miguelcordero191 3:0c291dbc7acc 44
okini3939 2:bc4583ce560e 45
okini3939 2:bc4583ce560e 46 /**
okini3939 2:bc4583ce560e 47 * @brief LCD type
okini3939 2:bc4583ce560e 48 */
okini3939 0:b069b7027af2 49 enum I2CLCDType {
okini3939 0:b069b7027af2 50 LCD8x2,
okini3939 0:b069b7027af2 51 LCD16x1,
okini3939 0:b069b7027af2 52 LCD16x2,
okini3939 0:b069b7027af2 53 LCD16x2B,
okini3939 0:b069b7027af2 54 LCD16x4,
okini3939 0:b069b7027af2 55 LCD20x2,
okini3939 0:b069b7027af2 56 LCD20x4
okini3939 0:b069b7027af2 57 };
okini3939 0:b069b7027af2 58
okini3939 2:bc4583ce560e 59 /**
okini3939 2:bc4583ce560e 60 * @brief LCD config
okini3939 2:bc4583ce560e 61 */
okini3939 0:b069b7027af2 62 enum I2CLCDConfig {
okini3939 0:b069b7027af2 63 LCDCFG_ENABLE = 0x20,
okini3939 0:b069b7027af2 64 LCDCFG_PWMCOUNT = 0x10,
okini3939 0:b069b7027af2 65 LCDCFG_LED = 0x08,
okini3939 0:b069b7027af2 66 LCDCFG_3V = 0x04,
okini3939 0:b069b7027af2 67 LCDCFG_ADDR = 0x02,
okini3939 0:b069b7027af2 68 LCDCFG_INIT = 0x01
okini3939 0:b069b7027af2 69 };
okini3939 0:b069b7027af2 70
okini3939 2:bc4583ce560e 71 /**
okini3939 2:bc4583ce560e 72 * @brief I2CLCD class
okini3939 2:bc4583ce560e 73 */
okini3939 0:b069b7027af2 74 class I2CLCD : public Stream {
okini3939 0:b069b7027af2 75 public:
okini3939 2:bc4583ce560e 76 I2CLCD (PinName p_sda, PinName p_scl, int p_i2caddr = I2CLCD_ADDR, I2CLCDType p_type = LCD16x2, I2CLCDConfig p_config = LCDCFG_3V);
okini3939 2:bc4583ce560e 77 I2CLCD (I2C& p_i2c, int p_i2caddr = I2CLCD_ADDR, I2CLCDType p_type = LCD16x2, I2CLCDConfig p_config = LCDCFG_3V);
okini3939 0:b069b7027af2 78
okini3939 0:b069b7027af2 79 void locate (int, int);
okini3939 0:b069b7027af2 80 void cls ();
okini3939 0:b069b7027af2 81 void lcd_cfg (I2CLCDConfig);
miguelcordero191 3:0c291dbc7acc 82 void printf ( const char* text, int x=0, int y=0);
miguelcordero191 3:0c291dbc7acc 83
okini3939 0:b069b7027af2 84 protected:
okini3939 0:b069b7027af2 85 virtual int _putc (int);
okini3939 0:b069b7027af2 86 virtual int _getc ();
miguelcordero191 3:0c291dbc7acc 87
okini3939 0:b069b7027af2 88 int address (int, int);
okini3939 0:b069b7027af2 89 int rows ();
okini3939 0:b069b7027af2 90 int cols ();
okini3939 2:bc4583ce560e 91 void init (int, I2CLCDType, I2CLCDConfig);
miguelcordero191 3:0c291dbc7acc 92 void lcd_out (char, char = 0);
okini3939 2:bc4583ce560e 93 char lcd_in (char);
okini3939 0:b069b7027af2 94
okini3939 0:b069b7027af2 95 I2C i2c;
okini3939 2:bc4583ce560e 96 int i2caddr;
okini3939 0:b069b7027af2 97 I2CLCDType type;
okini3939 0:b069b7027af2 98 int x, y;
okini3939 0:b069b7027af2 99 };
okini3939 0:b069b7027af2 100
okini3939 0:b069b7027af2 101 #endif