An I2C text LCD library for Displaytronic ACM1602NI-FLW-FBW-M01
Dependents: ACM1602NI_Demo ROBOT_v01 ROBOT_v02 Boku-Transmit ... more
Revision 5:c1dbbc2af9dd, committed 2014-01-14
- Comitter:
- takuo
- Date:
- Tue Jan 14 02:16:15 2014 +0000
- Parent:
- 4:33a8ca14e0e0
- Child:
- 6:55b648ec5216
- Commit message:
- Added a constructor that takes I2C pins instead of I2C object.; The init() method is now public.
Changed in this revision
ACM1602NI.cpp | Show annotated file Show diff for this revision Revisions of this file |
ACM1602NI.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/ACM1602NI.cpp Sat Dec 14 14:45:38 2013 +0000 +++ b/ACM1602NI.cpp Tue Jan 14 02:16:15 2014 +0000 @@ -20,7 +20,12 @@ #define I2C_SUCCESS 0 #define I2C_FAILURE 1 -ACM1602NI::ACM1602NI(I2C &i2c): _i2c(i2c) +ACM1602NI::ACM1602NI(PinName sda, PinName scl) : _i2c(sda, scl) +{ + init(); +} + +ACM1602NI::ACM1602NI(I2C &i2c) : _i2c(i2c) { init(); }
--- a/ACM1602NI.h Sat Dec 14 14:45:38 2013 +0000 +++ b/ACM1602NI.h Tue Jan 14 02:16:15 2014 +0000 @@ -29,8 +29,7 @@ * #include "ACM1602NI.h" * * // p9: sda, p10: scl - * I2C i2c(p9, p10); - * ACM1602NI lcd(i2c); + * ACM1602NI lcd(p9, p10); * * int main() { * lcd.printf("Hello, World!\n"); @@ -41,19 +40,30 @@ class ACM1602NI : public Stream { public: + /** Create an ACM1602NI object connected to the specified I2C pins. + * + * @parem sda The I2C data pin + * @param scl The I2C clock pin + */ + ACM1602NI(PinName sda, PinName scl); + /** Create an ACM1602NI object connected to the specified I2C port. * - * @param i2c The I2C port to connect to + * @param i2c The I2C port to connect to */ ACM1602NI(I2C &i2c); + /** Initialize the device and clear screen + */ + void init(); + /** Locate to a screen column and row * * @param column The horizontal position from the left, indexed from 0 * @param row The vertical position from the top, indexed from 0 */ void locate(int column, int row); - + /** Clear the screen and locate to 0,0 */ void cls(); @@ -64,7 +74,6 @@ virtual int _putc(int value); virtual int _getc(); - void init(); int address(int column, int raw); void character(int column, int row, int c); int writeBytes(const char *data, int length, bool repeated = false); @@ -78,7 +87,7 @@ static const int display_columns = 16; static const int display_rows = 2; - I2C &_i2c; + I2C _i2c; int _column, _row; };