ERC1602-4 i2c Text LCD library for East Rising COG display in i2c mode using the ST7032i controller IC.
Diff: I2cBusDevice.h
- Revision:
- 0:5b8f0de660ec
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/I2cBusDevice.h Sun May 04 11:31:31 2014 +0000 @@ -0,0 +1,36 @@ +#include "mbed.h" + +class I2cBusDevice { +public: + + I2cBusDevice( I2C *LCD, char dev_address ) { + bus = LCD; + device = dev_address; + } + + ~I2cBusDevice() { + } + + int write( char *data, int length ) { + return ( bus->write( device, data, length) ); + } + + int read( char *data, int length ) { + return ( bus->read( device, data, length) ); + } + + int read( char reg_ptr, char *data, int length ) { + if ( bus->write( device, ®_ptr, 1 ) ) + return ( 1 ); + if ( bus->read( device, data, length ) ) + return ( 1 ); + return ( 0 ); + } + +protected: + I2C *bus; + char device; +} +; + +