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

I2CLCD.h

Committer:
okini3939
Date:
2010-10-14
Revision:
0:b069b7027af2
Child:
1:bf21aa3f7cdc

File content as of revision 0:b069b7027af2:

/*
 * mbed library to use a I2C LCD
 * Copyright (c) 2010 Hiroshi Suga
 * Released under the MIT License: http://mbed.org/license/mit
 */
 
#ifndef I2CLCD_H
#define I2CLCD_H

#include "mbed.h"

enum I2CLCDType {
    LCD8x2,
    LCD16x1,
    LCD16x2,
    LCD16x2B,
    LCD16x4,
    LCD20x2,
    LCD20x4
};

enum I2CLCDConfig {
    LCDCFG_ENABLE   = 0x20,
    LCDCFG_PWMCOUNT = 0x10,
    LCDCFG_LED      = 0x08,
    LCDCFG_3V       = 0x04,
    LCDCFG_ADDR     = 0x02,
    LCDCFG_INIT     = 0x01
};

class I2CLCD : public Stream {
public:
    I2CLCD (PinName p_sda, PinName p_scl, I2CLCDType p_type = LCD16x2, I2CLCDConfig p_config = LCDCFG_3V);
    I2CLCD (I2C& p_i2c, I2CLCDType p_type = LCD16x2, I2CLCDConfig p_config = LCDCFG_3V);

    void locate (int, int);
    void cls ();
    void lcd_cfg (I2CLCDConfig);

protected:
    virtual int _putc (int);
    virtual int _getc ();

    int address (int, int);
    int rows ();
    int cols ();
    void init (I2CLCDType, I2CLCDConfig);
    void lcd_out (int, int);
    int lcd_in (int);

    I2C i2c;
    I2CLCDType type;
    int x, y;
};

#endif