Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of I2CLCD by
I2CLCD.h@1:bf21aa3f7cdc, 2010-10-19 (annotated)
- Committer:
- okini3939
- Date:
- Tue Oct 19 07:08:54 2010 +0000
- Revision:
- 1:bf21aa3f7cdc
- Parent:
- 0:b069b7027af2
- Child:
- 2:bc4583ce560e
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
okini3939 | 0:b069b7027af2 | 1 | /* |
okini3939 | 1:bf21aa3f7cdc | 2 | * mbed library for I2C LCD |
okini3939 | 0:b069b7027af2 | 3 | * Copyright (c) 2010 Hiroshi Suga |
okini3939 | 0:b069b7027af2 | 4 | * Released under the MIT License: http://mbed.org/license/mit |
okini3939 | 1:bf21aa3f7cdc | 5 | * |
okini3939 | 1:bf21aa3f7cdc | 6 | * Using some of the source code: |
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 | 0:b069b7027af2 | 10 | |
okini3939 | 0:b069b7027af2 | 11 | #ifndef I2CLCD_H |
okini3939 | 0:b069b7027af2 | 12 | #define I2CLCD_H |
okini3939 | 0:b069b7027af2 | 13 | |
okini3939 | 0:b069b7027af2 | 14 | #include "mbed.h" |
okini3939 | 0:b069b7027af2 | 15 | |
okini3939 | 0:b069b7027af2 | 16 | enum I2CLCDType { |
okini3939 | 0:b069b7027af2 | 17 | LCD8x2, |
okini3939 | 0:b069b7027af2 | 18 | LCD16x1, |
okini3939 | 0:b069b7027af2 | 19 | LCD16x2, |
okini3939 | 0:b069b7027af2 | 20 | LCD16x2B, |
okini3939 | 0:b069b7027af2 | 21 | LCD16x4, |
okini3939 | 0:b069b7027af2 | 22 | LCD20x2, |
okini3939 | 0:b069b7027af2 | 23 | LCD20x4 |
okini3939 | 0:b069b7027af2 | 24 | }; |
okini3939 | 0:b069b7027af2 | 25 | |
okini3939 | 0:b069b7027af2 | 26 | enum I2CLCDConfig { |
okini3939 | 0:b069b7027af2 | 27 | LCDCFG_ENABLE = 0x20, |
okini3939 | 0:b069b7027af2 | 28 | LCDCFG_PWMCOUNT = 0x10, |
okini3939 | 0:b069b7027af2 | 29 | LCDCFG_LED = 0x08, |
okini3939 | 0:b069b7027af2 | 30 | LCDCFG_3V = 0x04, |
okini3939 | 0:b069b7027af2 | 31 | LCDCFG_ADDR = 0x02, |
okini3939 | 0:b069b7027af2 | 32 | LCDCFG_INIT = 0x01 |
okini3939 | 0:b069b7027af2 | 33 | }; |
okini3939 | 0:b069b7027af2 | 34 | |
okini3939 | 0:b069b7027af2 | 35 | class I2CLCD : public Stream { |
okini3939 | 0:b069b7027af2 | 36 | public: |
okini3939 | 0:b069b7027af2 | 37 | I2CLCD (PinName p_sda, PinName p_scl, I2CLCDType p_type = LCD16x2, I2CLCDConfig p_config = LCDCFG_3V); |
okini3939 | 0:b069b7027af2 | 38 | I2CLCD (I2C& p_i2c, I2CLCDType p_type = LCD16x2, I2CLCDConfig p_config = LCDCFG_3V); |
okini3939 | 0:b069b7027af2 | 39 | |
okini3939 | 0:b069b7027af2 | 40 | void locate (int, int); |
okini3939 | 0:b069b7027af2 | 41 | void cls (); |
okini3939 | 0:b069b7027af2 | 42 | void lcd_cfg (I2CLCDConfig); |
okini3939 | 0:b069b7027af2 | 43 | |
okini3939 | 0:b069b7027af2 | 44 | protected: |
okini3939 | 0:b069b7027af2 | 45 | virtual int _putc (int); |
okini3939 | 0:b069b7027af2 | 46 | virtual int _getc (); |
okini3939 | 0:b069b7027af2 | 47 | |
okini3939 | 0:b069b7027af2 | 48 | int address (int, int); |
okini3939 | 0:b069b7027af2 | 49 | int rows (); |
okini3939 | 0:b069b7027af2 | 50 | int cols (); |
okini3939 | 0:b069b7027af2 | 51 | void init (I2CLCDType, I2CLCDConfig); |
okini3939 | 0:b069b7027af2 | 52 | void lcd_out (int, int); |
okini3939 | 0:b069b7027af2 | 53 | int lcd_in (int); |
okini3939 | 0:b069b7027af2 | 54 | |
okini3939 | 0:b069b7027af2 | 55 | I2C i2c; |
okini3939 | 0:b069b7027af2 | 56 | I2CLCDType type; |
okini3939 | 0:b069b7027af2 | 57 | int x, y; |
okini3939 | 0:b069b7027af2 | 58 | }; |
okini3939 | 0:b069b7027af2 | 59 | |
okini3939 | 0:b069b7027af2 | 60 | #endif |