Version 2.0 of TextLCD_SB1602E. The old class driver has been rewritten in more common manner of I2C devices.

Dependents:   SB1602E_Hello BME280_LCD PreHeater PreHeater ... more

Hello program for the text LCD module "SB1602E" class library

This is the version 2.0 of the TextLCD_SB1602E. /media/uploads/okano/dsc_0744.jpg

https://developer.mbed.org/media/components/pinouts/lcd2.png

The "Hello" program is available

Import programSB1602E_Hello

A Hello program for the text LCD module SB1602E class driver. The SB1602E's old class driver (TextLCD_SB1602B) has been rewritten in more common manner of I2C devices.

And the "Test" program is available also.
The test program can demonstrate full functionalities of this library.

Import programSB1602E_test

Test program for SB1602E class library

Revision:
2:baf578069dfc
Parent:
1:fce3e353410c
--- a/SB1602E.cpp	Mon Jan 05 05:19:43 2015 +0000
+++ b/SB1602E.cpp	Tue Apr 07 05:03:44 2015 +0000
@@ -1,8 +1,8 @@
 /** Text LCD module "SB1602E" class library
  *
- *  @author  Tedd OKANO & Masato YAMANISHI
- *  @version 2.01
- *  @date    05-Jan-2015
+ *  @author  Tedd OKANO, Masato YAMANISHI & Toyomasa Watarai
+ *  @version 2.1
+ *  @date    07-April-2015
  *
  *  SB1602E is an I2C based low voltage text LCD panel (based Sitronix ST7032 chip)
  *  The module by StrawberryLinux
@@ -21,6 +21,8 @@
  *    revision 1.3  02-May-2014   a. puticon() added (for SB1602B) by Masato YAMANISHI san
  *    revision 2.0  20-Oct-2014   a. class name is changed and published as "SB1602E"
  *                                b. re-written for better usability
+ *    revision 2.1  07-Apl-2015   a. add printf() with X and Y position
+ *                                b. add setter for number of chars in a line (e.g. 8x2 LCD support)
  */
 
 #include    <stdarg.h>
@@ -28,12 +30,12 @@
 #include    "SB1602E.h"
 
 
-SB1602E::SB1602E( PinName I2C_sda, PinName I2C_scl, char *init_massage ) : i2c_p( new I2C( I2C_sda, I2C_scl ) ), i2c( *i2c_p )
+SB1602E::SB1602E( PinName I2C_sda, PinName I2C_scl, char *init_massage ) : i2c_p( new I2C( I2C_sda, I2C_scl ) ), i2c( *i2c_p ), charsInLine( MaxCharsInALine )
 {
     init( init_massage );
 }
 
-SB1602E::SB1602E( I2C &i2c_, char *init_massage ) : i2c_p( NULL ), i2c( i2c_ )
+SB1602E::SB1602E( I2C &i2c_, char *init_massage ) : i2c_p( NULL ), i2c( i2c_ ), charsInLine( MaxCharsInALine )
 {
     init( init_massage );
 }
@@ -103,6 +105,19 @@
     puts( line, s );
 }
 
+void SB1602E::printf( char x, char y, char *format, ... )
+{
+    char    s[ 32 ];
+    va_list args;
+
+    va_start( args, format );
+    vsnprintf( s, 32, format, args );
+    va_end( args );
+
+    curs[ y ] = x;
+    puts( y, s );
+}
+
 void SB1602E::putc( char line, char c )
 {
     if ( (c == '\n') || (c == '\r') ) {
@@ -125,7 +140,7 @@
     const char    Comm_SetDDRAMAddress        = 0x80;
     const char    DDRAMAddress_Ofst[]         = { 0x00, 0x40 };
 
-    if ( (x >= MaxCharsInALine) || (y >= 2) )
+    if ( (x >= charsInLine) || (y >= 2) )
         return;
 
     lcd_command( (Comm_SetDDRAMAddress | DDRAMAddress_Ofst[ y ]) + x );
@@ -176,7 +191,7 @@
 
 void SB1602E::clear_lest_of_line( char line )
 {
-    for ( int i = curs[ line ]; i < MaxCharsInALine; i++ )
+    for ( int i = curs[ line ]; i < charsInLine; i++ )
         putcxy( ' ', i, line );
 }