Test program for SB1602E class library

Dependencies:   SB1602E mbed

Fork of TextLCD_SB1602E by Tedd OKANO

Test 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

http://mbed.org/media/uploads/okano/lcd.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.

Revision:
2:a936348ea09e
Parent:
1:816068edd3c3
--- a/main.cpp	Mon Oct 20 13:03:46 2014 +0000
+++ b/main.cpp	Thu Jul 23 10:05:24 2015 +0000
@@ -31,8 +31,8 @@
 //#define     ICON_TEST  (This has not been tested by Okano, sorry)
 
 Serial  pc( USBTX, USBRX ); // tx, rx
-SB1602E lcd( p9, p10 );     //  SDA, SCL
-//SB1602E lcd( p28, p27 );  //  SDA, SCL
+//SB1602E lcd( p9, p10 );     //  SDA, SCL
+SB1602E lcd( p28, p27 );  //  SDA, SCL
 
 static char    cg[8][8]        =    {// I hope I can improve this bitmap sometime in future (^^;
     { 0x1E, 0x1F, 0x1F, 0x1D, 0x1C, 0x1C, 0x1C, 0x1C },
@@ -53,8 +53,8 @@
 int main() {
     lcd.puts( 0, "TextLCD SB1602E \r" );
 
-    for ( int i = 10; i > 0; i-- ) {
-        lcd.printf( 1, "  count down: %2d\r", i );
+    for ( int i = 5; i > 0; i-- ) {
+        lcd.printf( 1, "      %2d\r", i );
         wait( 1.0 );
     }
 
@@ -73,22 +73,22 @@
 #ifdef CONTRAST_ADJUST_TEST
     pc.printf( "  CONTRAST_ADJUST_TEST\n" );
     lcd.clear();
-    lcd.puts( 1, "\x07\x07\x07\x07\x07 contrast()\r" );
+    lcd.puts( 0, "test\r" );
+    lcd.puts( 1, "contrast\r" );
     wait( DEFAULT_TIME_INTERVAL );
 
-    lcd.puts( 0, "ABCDEFGHIJKLMNOP\r" );
+    lcd.puts( 0, "ABCDEFGH\r" );
 
     for ( int t = 0; t < 2; t++ ) {
         for ( i = 0; i <= 0x3F; i++ ) {
 
-            lcd.printf( 1, "  cntrst = 0x%02X\r", i );
+            lcd.printf( 1, "    0x%02X\r", i );
             lcd.contrast( i );
             wait ( 0.02 );
         }
 
         for ( i = 0x3E; i > 0 ; i-- ) {
-            sprintf( s, "  cntrst = 0x%02X\r", i );
-            lcd.puts( 1, s );
+            lcd.printf( 1, "    0x%02X\r", i );
             lcd.contrast( i );
             wait ( 0.02 );
         }
@@ -101,12 +101,13 @@
 
     pc.printf( "  PRINTF_TEST\n" );
     lcd.clear();
-    lcd.puts( 1, "\x07\x07\x07\x07\x07\x07\x07 printf()\r" );
+    lcd.puts( 0, "test\r" );
+    lcd.puts( 1, "printf\r" );
     wait( DEFAULT_TIME_INTERVAL );
 
-    lcd.printf( 0, "%%6.4f, %%c, %%X\"\r" );
+    lcd.printf( 0, "\"%%6.4f\"\r" );
     for ( i = -37; i < 37; i++ ) {
-        lcd.printf( 1, "%6.4f, %c, %x\r", (float)i / 37.0, 'a' + i, i + 37 );
+        lcd.printf( 1, "%6.4f\r", (float)i / 37.0 );
         wait ( 0.1 );
     }
 
@@ -114,7 +115,8 @@
 #ifdef CGRAM_FUNCTION_TEST
     pc.printf( "  CGRAM_FUNCTION_TEST\n" );
     lcd.clear();
-    lcd.puts( 1, "\x07\x07\x07\x07 set_CGRAM()\r" );
+    lcd.puts( 0, "test\r" );
+    lcd.puts( 1, "setCGRAM\r" );
     wait( DEFAULT_TIME_INTERVAL );
 
     for ( i = 0; i < 8; i++ )
@@ -150,17 +152,18 @@
 #ifdef PUTS_TEST_WITH_ESCAPE
     pc.printf( "  PUTS_TEST_WITH_ESCAPE\n" );
     lcd.clear();
-    lcd.puts( 1, "\x07\x07\x07 puts(\"..\\r\")\r" );
+    lcd.puts( 0, "test\r" );
+    lcd.puts( 1, "puts(\"..\\r\")\r" );
     wait( DEFAULT_TIME_INTERVAL );
 
-    lcd.puts( 0, "\rWelcome to mbed!\r" );
-    lcd.puts( 1, "\rwww.mbed.com\r" );
+    lcd.puts( 0, "\rWelcome\r" );
+    lcd.puts( 1, "\rmbed\r" );
     wait( DEFAULT_TIME_INTERVAL );
-    lcd.puts( 0, "       This is a\r" );
-    lcd.puts( 1, "        LCD test\r" );
+    lcd.puts( 0, "This is \r" );
+    lcd.puts( 1, "LCD test\r" );
     wait( DEFAULT_TIME_INTERVAL );
-    lcd.puts( 0, "  22-Jan-2010\r" );
-    lcd.puts( 1, "  Hello world!\r" );
+    lcd.puts( 0, "23-Jul\r" );
+    lcd.puts( 1, "    2015\r" );
     wait( DEFAULT_TIME_INTERVAL );
 
 #endif
@@ -168,7 +171,8 @@
     pc.printf( "  PUTS_TEST_WITHOUT_ESCAPE\n" );
     lcd.clear();
     lcd.puts( 0, "\r" );
-    lcd.puts( 1, "\x07\x07\x07\x07\x07 puts(\"..\")\r" );
+    lcd.puts( 0, "test\r" );
+    lcd.puts( 1, "puts(\"..\")\r" );
     wait( DEFAULT_TIME_INTERVAL );
 
     lcd.puts( 0, "0" );
@@ -197,27 +201,16 @@
     wait( DEFAULT_TIME_INTERVAL_PUTx );
     lcd.puts( 0, "9" );
     wait( DEFAULT_TIME_INTERVAL_PUTx );
-    lcd.puts( 0, "A" );
-    wait( DEFAULT_TIME_INTERVAL_PUTx );
-    lcd.puts( 0, "B" );
-    wait( DEFAULT_TIME_INTERVAL_PUTx );
-    lcd.puts( 0, "C" );
-    wait( DEFAULT_TIME_INTERVAL_PUTx );
-    lcd.puts( 0, "D" );
-    wait( DEFAULT_TIME_INTERVAL_PUTx );
-    lcd.puts( 0, "E" );
-    wait( DEFAULT_TIME_INTERVAL_PUTx );
-    lcd.puts( 0, "F" );
-    wait( DEFAULT_TIME_INTERVAL_PUTx );
 
 #endif
 #ifdef PUTC_TEST
     pc.printf( "  PUTC_TEST\n" );
     lcd.clear();
-    lcd.puts( 1, "\x07\x07\x07\x07\x07\x07\x07\x07\x07 putc()\r" );
+    lcd.puts( 0, "test\r" );
+    lcd.puts( 1, "putc\r" );
     wait( DEFAULT_TIME_INTERVAL );
 
-    for ( i = 0; i < 16; i++ ) {
+    for ( i = 0; i < 8; i++ ) {
         lcd.putc( 0, '0' + i );
         lcd.putc( 1, 'A' + i );
         wait( DEFAULT_TIME_INTERVAL_PUTx );