Libraries and Example of mbed parallel bus using I2C port expanders

Dependencies:   HDSP253X mbed PCF8574_Bus

Revision:
1:e180256ba6fb
Parent:
0:2467aed99127
--- a/main.cpp	Wed Aug 31 19:45:31 2011 +0000
+++ b/main.cpp	Sat Sep 17 15:35:39 2011 +0000
@@ -11,6 +11,7 @@
 #include "PCF8574_AddressBus.h"
 #include "PCF8574_EnableBus.h"
 #include "MBED_ControlBus.h"
+#include "HDSP253X_Display.h"
   
 // Debug stuff
 #define __DEBUG  
@@ -34,6 +35,9 @@
 PCF8574_EnableBus  enablebus = PCF8574_EnableBus(i2c, D_I2C_ENA_BUS);
 MBED_ControlBus  controlbus = MBED_ControlBus(D_WR, D_RD, D_DTR, D_CDBUF, D_CDINT);
 
+// Display Hardware definitions
+HDSP253X_Display LED_display = HDSP253X_Display(databus, addressbus, enablebus, controlbus);
+
 // Dummy delay
 #define DEVICE_WAIT_MS   0
 
@@ -64,7 +68,7 @@
   
     //Done, Tell me about it
     myled1 = 1;
-    DBG("Init Interfaces Done\r");    
+//    DBG("Init Interfaces Done\r");    
 }
       
 
@@ -235,6 +239,62 @@
     return data;
 }
 
+
+void HDSP_BITE() {
+  int count;
+    
+    for (count=0; count<5; count++) {
+      LED_display.locate(0);
+      LED_display.printf("BITE  - ");
+      wait(0.05);                    
+      LED_display.locate(0);         
+      LED_display.printf("BITE  \\ ");
+      wait(0.05);                              
+      LED_display.locate(0);        
+      LED_display.printf("BITE  | ");
+      wait(0.05);              
+      LED_display.locate(0);    
+      LED_display.printf("BITE  / ");    
+      wait(0.05);      
+      LED_display.locate(0);    
+      LED_display.printf("BITE  - ");                
+      wait(0.05);      
+    };
+
+    LED_display.locate(0);    
+    LED_display.printf("BITE  OK"); 
+
+    LED_display.set_blink_mode(true);            
+    wait(2.0);          
+    LED_display.set_blink_mode(false);
+                    
+    LED_display.cls();  
+
+    //Done, Tell me about it                        
+//    DBG("BITE Done, Main, Step = %d\r", 30);    
+}
+
+void HDSP_Init_UDC() {
+
+// batt empty
+  LED_display.define_user_char(0, 0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1F);
+// batt full  
+  LED_display.define_user_char(1, 0x0E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F);  
+}  
+  
+
+void HDSP_Show_UDC() {
+ 
+  LED_display.locate(0);    
+  LED_display.printf("Batt "); 
+//  LED_display.putc(HDSP253X_ASCII_UDC_CHARS + 0); 
+//  LED_display.putc(HDSP253X_ASCII_UDC_CHARS + 1); 
+  LED_display.putudc(0); 
+  LED_display.putudc(1); 
+    
+  wait(2.0);          
+}
+
 int main() {
     int address, result;
     uint8_t data, dummy;
@@ -244,15 +304,20 @@
     heartbeat_start();
           
     clear_screen(); 
-        
-    DBG("Start Main Loop\r");    
+    
+    HDSP_Init_UDC();
+            
+//    DBG("Start Main Loop\r");    
 
 //Testing stuff
         
     //Test cycletime
     cycletimer.start();      
     cycletimer.reset();
-    
+
+
+#if (0)
+// Bus test
     while (1) {
       for (address=0; address<256; address++) {
         //data = read(address, CS_SWITCH);
@@ -272,7 +337,27 @@
       
       show_LEDS ();      
     }
+#else
+// LED Display test
+    while (1) {
+      HDSP_BITE();   
 
+      cyclecount++;
+      if (cyclecount == 10) {
+        cyclecount = 0;
+//        LED_display.printf ("Restart ");
+        HDSP_Show_UDC();         
+      }       
+      else {
+        LED_display.printf ("Cnt=  %2d", cyclecount);      
+      }
+      wait(2.0);
+      pc.printf ("."); 
+                     
+      show_LEDS ();      
+    }
+
+#endif
       
     DBG("I'll be back...\r\r");
 }