Demonstration of SSD1308 OLED driver library

Dependencies:   mbed SSD1308_128x64_I2C

Files at this revision

API Documentation at this revision

Comitter:
wim
Date:
Tue Jan 29 21:17:34 2013 +0000
Parent:
5:dff410a009c5
Child:
7:ae282775cbcc
Commit message:
Updated progress scales

Changed in this revision

SSD1308_128x64_I2C.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/SSD1308_128x64_I2C.lib	Sat Jul 21 12:50:23 2012 +0000
+++ b/SSD1308_128x64_I2C.lib	Tue Jan 29 21:17:34 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/wim/code/SSD1308_128x64_I2C/#b7e8f5139026
+http://mbed.org/users/wim/code/SSD1308_128x64_I2C/#fa18169dd7e6
--- a/main.cpp	Sat Jul 21 12:50:23 2012 +0000
+++ b/main.cpp	Tue Jan 29 21:17:34 2013 +0000
@@ -51,6 +51,9 @@
     pc.printf("D: Blink\r");   
     pc.printf("E: Big Chars\r");                       
     pc.printf("F: Progress Scale\r");    
+    pc.printf("G: Scroll\r");        
+    pc.printf("H: Hor Scroll\r");    
+    pc.printf("V: Ver and Hor Scroll\r");    
 //    pc.printf("\n\r");                
      
 }
@@ -59,39 +62,42 @@
 void oled_Test() {
   pc.printf("OLED test start\r");  
   
-  oled.writeString(0, 0, 13, "Hello World !");
-  pc.printf("Printed something\r\n");    
+//  oled.writeString(0, 0, 13, "Hello World !");
+  oled.writeString(0, 0, "Hello World !");  
+  pc.printf("Printed something\r");    
   wait(3);
     
-  oled.writeString(1, 0, 8, "baz quux");
-  pc.printf("Printed something\r\n");  
+//  oled.writeString(1, 0, 8, "baz quux");
+  oled.writeString(1, 0, "baz quux");  
+  pc.printf("Printed something\r");  
   wait(3);
     
 //  oled.writeString(4, 0, 272, "a long, rather lengthy, extended string passage thing, eh, that just goes on, and on, and on, and on, and on, and on, and on, yes, further, continuing, extending, expanding beyond all reason or sanity!!!!! and yet, there's more!  so much more!  for ever and ever, oh yeah");
-//  pc.printf("Printed something\r\n");
+//  pc.printf("Printed something\r");
 //  wait(3);
 
   oled.fillDisplay(0xAA);
-  pc.printf("Display filled\r\n");      
+  pc.printf("Display filled\r");      
   wait(3);
 
   oled.setDisplayOff();
-  pc.printf("Display off\r\n");          
+  pc.printf("Display off\r");          
   wait(0.5);
 
   oled.setDisplayOn();
-  pc.printf("Display on\r\n");          
+  pc.printf("Display on\r");          
   wait(0.5);  
 
   oled.clearDisplay();
-  pc.printf("Display cleared\r\n");        
+  pc.printf("Display cleared\r");        
   wait(0.5);
 
-  oled.writeString(0, 0, 11, "Bye World !");
-  pc.printf("Printed something\r\n");    
+//  oled.writeString(0, 0, 11, "Bye World !");
+  oled.writeString(0, 0, "Bye World !");  
+  pc.printf("Printed something\r");    
   wait(3);
 
-  pc.printf("OLED test done\r\n");  
+  pc.printf("OLED test done\r");  
 }
 
 // Variables for Heartbeat and Status monitoring
@@ -143,7 +149,7 @@
           
     clear_screen(); 
   
-    pc.printf("Hello World!\n\r");
+    pc.printf("Hello World!\r");
 
 #if(0)
 // Quick test
@@ -170,7 +176,7 @@
          
          switch (command) {
           case '0' :
-                     pc.printf("Done\n\r");                    
+                     pc.printf("Done\r");                    
                      running = false;  
                      break;
           
@@ -179,50 +185,49 @@
                      break;
                     
           case '2' :
-                     pc.printf("Hello World!\n\r");  
-                     oled.writeString(0, 0, 13, "Hello World !");                            
+                     pc.printf("Hello World!\r");  
+                     oled.writeString(0, 0, "Hello World !");                                                 
                      break;
           
           case '3' :
-                     pc.printf("Fill part of Display 0xA5\n\r");            
+                     pc.printf("Fill part of Display 0xA5\r");            
 //                     oled.fillDisplay(0xA5);
                      
                      oled.fillDisplay(0xA5, 2, 5, 0, 63);                     
                      break;
 
           case '4' :
-                     pc.printf("Display cleared\r\n");                  
+                     pc.printf("Display cleared\r");                  
                      oled.clearDisplay();
                      break;
 
           case '5' :
-                     pc.printf("Display off\r\n");                
+                     pc.printf("Display off\r");                
                      oled.setDisplayOff();                  
                      break;
           case '6' :
-                     pc.printf("Display on\r\n");          
+                     pc.printf("Display on\r");          
                      oled.setDisplayOn();                     
                      break;
 
           case '7' :
-                     pc.printf("Display Invert\r\n");          
+                     pc.printf("Display Invert\r");          
                      oled.setDisplayInverse();
                      break;
 
           case '8' :
-                     pc.printf("Display Normal\r\n");
+                     pc.printf("Display Normal\r");
                      oled.setDisplayNormal();                                         
                      break;
 
           case '9' :
-                     pc.printf("Display bitmap\r\n");          
+                     pc.printf("Display bitmap\r");          
                      oled.writeBitmap((uint8_t*) mbed_logo);
                                         
                      break;
 
           case 'A' :
-
-                     pc.printf("Brightness Ramp Down\r\n");          
+                     pc.printf("Brightness Ramp Down\r");          
                      for (int contrast=0x7F; contrast >= 0x10; contrast--) { 
                         oled.setContrastControl(contrast);
                         wait(0.05);
@@ -230,20 +235,21 @@
                      
                      wait(1);
 
-                     pc.printf("Brightness Ramp Up\r\n");          
+                     pc.printf("Brightness Ramp Up\r");          
                      for (int contrast=0x10; contrast <= 0x7F; contrast++) { 
                         oled.setContrastControl(contrast);
                         wait(0.05);
                      }                   
 
-                     pc.printf("Brightness Ramp Done\r\n");                              
+                     pc.printf("Brightness Ramp Done\r");                              
                      
                      break;
 
           case 'B' :
-                     pc.printf("Send Inverted Message\n\r");
+                     pc.printf("Send Inverted Message\r");
                      oled.setInverted(true);                     
-                     oled.writeString(0, 0, 13, "Hello World !");                                                 
+//                     oled.writeString(0, 0, 13, "Hello World !");                                                 
+                     oled.writeString(0, 0, "Hello World !");                                                                      
                      oled.setInverted(false);                                          
 
                      oled.printf(" Result is %d", 12345);                                                 
@@ -251,14 +257,14 @@
                      break;
                      
           case 'C' :
-                     pc.printf("Flip and Mirror (Rewrite display to show horizontal effect)\n\r");
+                     pc.printf("Flip and Mirror (Rewrite display to show horizontal effect)\r");
                      left = !left;
                      down = !down;
                      oled.setDisplayFlip(left, down);                     
                      break;
           
           case 'D' :                     
-                     pc.printf("D: Blink and Fade (not supported) \n\r");
+                     pc.printf("D: Blink and Fade (not supported)\r");
 
 //                     oled.setDisplayBlink(true);
 //                     wait(4);
@@ -268,39 +274,86 @@
                      wait(4);
                      oled.setDisplayFade(false);
                      
-                     pc.printf("D: Blink done\n\r");
-                     break;   
-                    
+                     pc.printf("D: Blink done\r");
+                     break;                       
                      
           case 'E' :                     
-                     pc.printf("E: Big Chars\n\r");
+                     pc.printf("E: Big Chars\r");
                      
                      oled.writeBigChar(0,  0, '+');
                      oled.writeBigChar(0, 16, '7');
                      oled.writeBigChar(0, 32, '8');
                      oled.writeBigChar(0, 48, '9');                                          
                      
-                     pc.printf("E: Big Chars done\n\r");
+                     pc.printf("E: Big Chars done\r");
                      break;   
                      
           case 'F' :                     
-                     pc.printf("F: Progress Scale\n\r");
+                     pc.printf("F: Progress Scale\r");
 
                      for (int percentage=0; percentage <= 100; percentage++) { 
                        oled.writeProgressBar(2, 0, percentage); 
-                       oled.printf(" %3d %%", percentage);                                           
+                       oled.printf(" %3d%%", percentage);                                           
                        
                        oled.writeProgressBar(4, 0, 100 - percentage);                        
-                       oled.printf(" %3d %%", 100 - percentage);                                                                  
+                       oled.printf(" %3d%%", 100 - percentage);                                                                  
+
+                       oled.writeLevelBar(6, 0, percentage);                        
+                       oled.printf(" %3dmV", percentage);                                                                  
+                       
                        wait(0.05);
                      }                   
+                    
+                     pc.printf("F: Progress Scale done\r");                   
+                     break;   
+                     
+          case 'G' :                     
+                     pc.printf("G: Scroll\r");
 
-                    
-                     pc.printf("F: Progress Scale done\n\r");                   
+                     for (int line=0; line < ROWS; line++) { 
+                       oled.setDisplayStartLine(line);                        
+                       wait(0.05);
+                     }                   
+                       
+                     oled.setDisplayStartLine(0);                                            
+                     
+                     pc.printf("G: Scroll done\r");                   
                      break;   
                      
 
-                                                                                       
+          case 'H' :                     
+//                     pc.printf("H: Hor Scroll\r");
+                     pc.printf("H: Hor Scroll (Page 0-3)\r");
+//                     oled.setContinuousHorizontalScroll(true, PAGE0, PAGE7, SCROLL_INTERVAL_25_FRAMES);                     
+                     oled.setContinuousHorizontalScroll(true, PAGE0, PAGE3, SCROLL_INTERVAL_25_FRAMES);                                          
+                     oled.setDisplayScroll(true);
+                       
+                     wait(5);                     
+                     
+                     oled.setDisplayScroll(false);
+                     
+                     pc.printf("H: Hor Scroll done\r");                   
+                     break;   
+
+
+          case 'V' :                     
+                     pc.printf("V: Ver and Hor Scroll (Page 0-7)\r");
+
+
+                     oled.setContinuousVerticalAndHorizontalScroll(true, PAGE0, PAGE7, 0x01, SCROLL_INTERVAL_25_FRAMES);
+                     oled.setVerticalScrollArea(20, 20); 
+
+                     oled.setDisplayScroll(true);
+
+                       
+                     wait(5);                     
+                     
+                     oled.setDisplayScroll(false);
+                     
+                     pc.printf("V: Ver and Hor Scroll done\r");                   
+                     break;   
+
+                                                                                                         
         } //switch
       }//if
     }//while
--- a/mbed.bld	Sat Jul 21 12:50:23 2012 +0000
+++ b/mbed.bld	Tue Jan 29 21:17:34 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/737756e0b479
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/0954ebd79f59
\ No newline at end of file