Test for PT6301 VFD. First release.

Dependencies:   mbed PT6302

Revision:
1:73833adc27b1
Parent:
0:a99bfc8384e4
--- a/main.cpp	Sun Dec 03 18:03:51 2017 +0000
+++ b/main.cpp	Sun Jun 13 13:15:06 2021 +0000
@@ -1,7 +1,7 @@
-/* mbed PT6302 Test program, for Princeton PT6302 VFD controller
- * Note the PT6302 is identical to the OKI ML9208 
+/* mbed PT6301 Test program, for Princeton PT6301 VFD controller
+ *             The controller is used by Futaba 'Chip In Glass' (CIG) VFD tubes. 
  *
- * Copyright (c) 2017, v01: WH, Initial version
+ * Copyright (c) 2021, v01: WH, Initial version
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -22,22 +22,77 @@
  * THE SOFTWARE.
  */
 #include "mbed.h"
-#include "PT6302.h"
-
-// Select one of the testboards for Princeton PT6302 VFD controller
-#include "PT6302_Config.h"
+#include "PT6301.h"
 
-#if (HANNSTAR_TEST == 1)
+// Select one of the testboards for Princeton PT6301 VFD controller
+#include "PT6301_Config.h"
 
-// PT6302 Test
-#include "mbed.h"
-#include "PT6302.h"
+
+#if (SMTG7400_TEST == 1)
 
 DigitalOut myled(LED1);
 Serial pc(USBTX, USBRX);
 
-//PT6302_HANNSTAR PT6302(p5, p7, p8);
-PT6302_HANNSTAR PT6302(p11, p13, p14);
+// PT6301_SMTG7400 declaration, Default setting 16 Grids @ 5x7 Segments, with 4 additional Icons and 1 Row
+PT6301_SMTG7400 PT6301(p5, p7, p8, p9); // DI, CLK, CS, RST
+
+int main() {
+  pc.printf("Hello World: PT6301_SMTG7400 test\n\r");
+
+//  PT6301.printf("Hello World");
+  PT6301.printf("Hello World %1.2f", 1.23);  
+  PT6301.refresh();
+
+  PT6301.setBrightness(PT6301_BRT_6);
+  wait(1);  
+  PT6301.setBrightness(PT6301_BRT_DEF);                      
+  wait(1);
+
+  PT6301.setIcon(SMTG7400_ICON_OFFLINE);
+  PT6301.setIcon(SMTG7400_ICON_WIFI);
+  PT6301.setIcon(SMTG7400_ICON_PHONE);
+  PT6301.setIcon(SMTG7400_ICON_REC);
+  PT6301.refresh();  
+  wait(1);
+  
+  PT6301.cls();
+//  PT6301.locate(0, 0);
+  PT6301.setUDC(0, (char*) udc_LAR);
+  PT6301.setUDC(1, (char*) udc_RAR);  
+  PT6301.putc(char(0));
+  PT6301.putc(char(1));
+  PT6301.refresh();
+  wait(1); 
+  
+  while(1) {
+    myled = !myled;
+    PT6301.clrIcon(SMTG7400_ICON_OFFLINE);    
+    PT6301.refresh();
+    wait(1);
+
+    myled = !myled;    
+    PT6301.setIcon(SMTG7400_ICON_OFFLINE);    
+    PT6301.refresh();
+    wait(1);    
+  }
+}
+#endif
+
+
+
+
+
+#if (SMTC7140_TEST == 1)
+
+// PT6301 Test
+#include "mbed.h"
+#include "PT6301.h"
+
+DigitalOut myled(LED1);
+Serial pc(USBTX, USBRX);
+
+// PT6301_SMTC7140 declaration, Default setting 12 Grids @ 5x7 Segments, without additional Icons, 2 Rows. Separate Grid13 for Icons
+PT6301_SMTC7140 PT6301(p5, p7, p8, p9);
 
 void show_menu() {
 //    pc.printf("0:   Exit\n\r");
@@ -45,28 +100,30 @@
     pc.printf("2:   Show UDC chars\n\r");    
     pc.printf("3:   Show all chars\n\r");
     pc.printf("4:   Show all digits\n\r");    
-//    pc.printf("5:   Show all icons\n\r");
+    pc.printf("5:   Show all icons\n\r");
     pc.printf("6:   Counter\n\r");
     pc.printf("7:   Floats\n\r");
     pc.printf("8:   Kitt\n\r");
-    pc.printf("9:   Cls\n\r");    
-    pc.printf("A/B: LED On/Off\n\r");
+    pc.printf("9:   Cls\n\r");
+    pc.printf("A:   Display All Off / Normal\n\r");        
+    pc.printf("B:   Display All On / Normal\n\r");
     pc.printf("C:   Bye\n\r");    
 }
 
 
 int main() {
-  pc.printf("Hello World: PT6302 Hannstar test\n\r");
-
-  PT6302.locate(0);    
-  PT6302.printf("Hello mbed");    
+  pc.printf("Hello World: PT6301 SMTC7140 test\n\r");
 
-  PT6302.setBrightness(PT6302_BRT_7);
+  PT6301.locate(0, 0);    
+  PT6301.printf("Hello mbed");
+  PT6301.refresh();      
   wait(1);  
-  PT6302.setBrightness(PT6302_BRT_0);
+  
+  PT6301.setBrightness(PT6301_BRT_7);
   wait(1);  
-  PT6302.setBrightness(PT6302_BRT_DEF);
-  wait(1);
+//  PT6301.setBrightness(PT6301_BRT_0);
+//  wait(1);  
+  PT6301.setBrightness(PT6301_BRT_DEF);
 
     char cmd, cmd2 = '0';
     while (1) {
@@ -77,25 +134,30 @@
       switch (cmd2) {
         case '1' : {
                       pc.printf("all\r\n");
-                      PT6302.cls(); 
-                      PT6302.printf("Hello mbed");
+                      PT6301.cls(); 
+                      PT6301.printf("Hello mbed");
+                      PT6301.refresh();
                       break;
         }
 
 
         case '2' : {
                       pc.printf("UDC\r\n");
-                      PT6302.cls();
-                     
-                      // Store UDC_idx=0, 1 
-                      PT6302.setUDC(0, (char *) udc_LAR); // Left Arrow
-                      PT6302.setUDC(1, (char *) udc_RAR); // Right Arrow                      
+                      PT6301.cls();
+                      PT6301.refresh();                      
+
+                      // Store UDC_idx=0, reserved for Icons on SMTC7140
 
-                      // Show UDC_idx=0, 1 
-                      PT6302.locate(0);
-                      PT6302.putc((char) 0);
-                      PT6302.putc((char) 1);                      
-                    
+                      // Store UDC_idx=1, 2 
+                      PT6301.setUDC(1, (char *) udc_LAR); // Left Arrow
+                      PT6301.setUDC(2, (char *) udc_RAR); // Right Arrow                      
+                                            
+                      // Show UDC_idx=1, 2 
+                      PT6301.locate(0,0);
+                      PT6301.putc((char) 1);
+                      PT6301.putc((char) 2);                      
+                      PT6301.refresh();                    
+                      pc.printf("\r\nShow all UDC done\r\n");
                       break;
         }
 
@@ -104,11 +166,12 @@
 //test to show all chars
           pc.printf("Show all alpha chars\r\n");
           wait(1);          
-          PT6302.cls(); 
+          PT6301.cls(); 
          
           for (int i=0; i<26; i++) {
-            PT6302.printf("%c", char(i + 'A'));
-            PT6302.printf("%c", char(i + 'a'));            
+            PT6301.printf("%c", char(i + 'A'));
+            PT6301.printf("%c", char(i + 'a'));
+            PT6301.refresh();                        
             wait(0.25);                      
           }
           pc.printf("Show all alpha chars done\r\n");                    
@@ -121,13 +184,14 @@
 //test to show all digits (base is 10)
           pc.printf("Show all digits\r\n");
           wait(1);          
-          PT6302.cls(); 
+          PT6301.cls(); 
 
-          for (int i=0; i<PT6302_NR_DIGITS; i++) {
+          for (int i=0; i<SMTC7140_NR_COLS; i++) {
 
             for (int cnt=0; cnt<10; cnt++) {
-              PT6302.locate(i);
-              PT6302.printf("%0d", cnt);
+              PT6301.locate(0, i);
+              PT6301.printf("%0d", cnt);
+              PT6301.refresh();              
 
 //              wait(0.5);
               cmd = pc.getc(); // wait for key
@@ -140,19 +204,22 @@
 //test to show all digits (base is 0x10)
           pc.printf("Show all hex digits\r\n");
           wait(1);          
-          PT6302.cls(); 
+          PT6301.cls(); 
 
-          PT6302.printf("%010X", 0x0123ABCDEF);
+          PT6301.printf("%010X", 0x0123ABCDEF);
+          PT6301.refresh();          
           cmd = pc.getc(); // wait for key
-          PT6302.locate(0);          
-          PT6302.printf("%016X", 0x0);
+          PT6301.locate(0,0);          
+          PT6301.printf("%012X", 0x0);
+          PT6301.refresh();          
                     
-          for (int i=0; i<HANNSTAR_NR_DIGITS; i++) {
+          for (int i=0; i<SMTC7140_NR_COLS; i++) {
 //          for (int i=0; i<1; i++) {
 
             for (int cnt=0; cnt<0x10; cnt++) {
-              PT6302.locate(i);
-              PT6302.printf("%0X", cnt);
+              PT6301.locate(0, i);
+              PT6301.printf("%0X", cnt);
+              PT6301.refresh();              
 //              pc.printf("%0X", cnt);              
 //              wait(0.5);
               cmd = pc.getc(); // wait for key
@@ -164,19 +231,70 @@
         }
         
         case '5':  { 
+                      pc.printf("\r\nShow all icon bits\r\n");        
+//                      PT6301.cls();
+//                      PT6301.refresh();                      
+        
+                      // Store UDC_idx=0, reserved for Icons on SMTC7140                                         
+                      // Show UDC_idx=0 on Position (0, 12), ie Grid13 
+#if(0)
+                      //Test version to check all bits
+                      for (int i=0; i<5; i++) {
+                        char bits = 0x40;
+            
+                        for (int cnt=0; cnt<7; cnt++) {
+                          PT6301.setIconGrid13( (i << 8) | bits); // Test
+                          pc.printf("Showing icon [%d] => bits 0x%0X\r\n", i, bits);                                              
+                          bits = bits >> 1;
+                          cmd = pc.getc(); // wait for key
+                        }  
+                      }
+                      pc.printf("\r\nShow all icon bits done\r\n");
+#else
+                      pc.printf("\r\nShow all icon bits\r\n");
+                      cmd = pc.getc(); // wait for key                      
+                      PT6301.setIconGrid13(SMTC7140_ICON_DOLBY);
+                      cmd = pc.getc(); // wait for key
+                      PT6301.setIconGrid13(SMTC7140_ICON_PLUS);
+                      cmd = pc.getc(); // wait for key
+                      PT6301.setIconGrid13(SMTC7140_ICON_HD);
+                      cmd = pc.getc(); // wait for key
+                      PT6301.setIconGrid13(SMTC7140_ICON_CLOCK);
+                      cmd = pc.getc(); // wait for key
+                      PT6301.setIconGrid13(SMTC7140_ICON_REC);
+                      cmd = pc.getc(); // wait for key
+                      PT6301.setIconGrid13(SMTC7140_ICON_MAIL);
+                      cmd = pc.getc(); // wait for key
+                      
+                      PT6301.clrIconGrid13(SMTC7140_ICON_DOLBY);
+                      cmd = pc.getc(); // wait for key
+                      PT6301.clrIconGrid13(SMTC7140_ICON_PLUS);
+                      cmd = pc.getc(); // wait for key
+                      PT6301.clrIconGrid13(SMTC7140_ICON_HD);
+                      cmd = pc.getc(); // wait for key
+                      PT6301.clrIconGrid13(SMTC7140_ICON_CLOCK);
+                      cmd = pc.getc(); // wait for key
+                      PT6301.clrIconGrid13(SMTC7140_ICON_REC);
+                      cmd = pc.getc(); // wait for key
+                      PT6301.clrIconGrid13(SMTC7140_ICON_MAIL);
+                      cmd = pc.getc(); // wait for key
+                      
+                      pc.printf("\r\nShow all icon bits done\r\n");
+#endif        
           break;
         }                          
 
         case '6': {
           pc.printf("Show counter\r\n");          
-          PT6302.cls(); // clear all, preserve Icons
+          PT6301.cls(false); // clear all, preserve Icons
 
 #if(1)
-          PT6302.locate(0);
-          PT6302.printf("Cnt=");
+          PT6301.locate(0, 0);
+          PT6301.printf("Cnt=");
           for (int cnt=0; cnt<=0xFF; cnt++) {
-            PT6302.locate(8);
-            PT6302.printf("%02X", cnt);           
+            PT6301.locate(0, 8);
+            PT6301.printf("%02X", cnt);
+            PT6301.refresh();                       
             wait(0.2);
           }  
 #endif
@@ -186,11 +304,13 @@
         case '7': {
           pc.printf("Show floats\r\n");
           
-          PT6302.cls(); // clear all, preserve Icons
-          PT6302.printf("%1.7f", -0.1234567);  // test decimal point display
+          PT6301.cls(false); // clear all, preserve Icons
+          PT6301.printf("%1.7f", -0.1234567);  // test decimal point display
+          PT6301.refresh();          
           wait(0.5);
-          PT6302.cls(); // clear all, preserve Icons          
-          PT6302.printf("%3.6f", 123.456789);  // test decimal point display
+          PT6301.cls(false); // clear all, preserve Icons          
+          PT6301.printf("%3.6f", 123.456789);  // test decimal point display
+          PT6301.refresh();          
           break;          
         }
 
@@ -227,12 +347,13 @@
                           {"          "}
                         };     
          
-          PT6302.cls(); // clear all, preserve Icons
+          PT6301.cls(false); // clear all, preserve Icons
           
           while (!pc.readable()) { // wait for key            
             for (int i=0; i < (sizeof(KITT) / 11) ; i++) {
-              PT6302.locate(0);
-              PT6302.printf("%s", KITT[i]);
+              PT6301.locate(0,0);
+              PT6301.printf("%s", KITT[i]);
+              PT6301.refresh();              
               wait(0.1);
             }
           }
@@ -242,28 +363,37 @@
           break;
         }  
 
-
         case '9': {
-          PT6302.cls(true); // clear all, including Icons      
+          PT6301.cls(true); // clear all, including Icons
+          PT6301.refresh();
           break;
         }  
 
         case 'A': {
-          pc.printf("LED On\r\n");
-          PT6302.setPort(0x02);          
+          pc.printf("Display All Off / Normal\n\r");                    
+          PT6301.setDisplay(false);
+          wait(1.0);
+          PT6301.setDisplay(true);
+          wait(1.0);
           break;
         } 
 
         case 'B': {
-          pc.printf("LED Off\r\n");
-          PT6302.setPort(0x00);          
+          pc.printf("Display All On / Normal\n\r");          
+          PT6301.setDisplayTest(true);
+          wait(1.0);
+          PT6301.setDisplayTest(false);
+          wait(1.0);
           break;
         } 
 
         case 'C': {
-          PT6302.cls(); // clear all, preserve Icons
-          PT6302.printf("Bye");          
-       
+          PT6301.cls(false); // clear all, preserve Icons
+//          PT6301.printf("Bye");    
+//                      "0123456789AB");      
+          PT6301.printf("Stack...\r\n");
+          PT6301.printf("  ..Overflow");                    
+          PT6301.refresh();
           break;
         } 
 
@@ -280,29 +410,29 @@
 #endif
 
 
-#if (PT6302_TEST == 1)
+#if (PT6301_TEST == 1)
 
-// PT6302 Bare Metal Test
+// PT6301 Bare Metal Test
 #include "mbed.h"
-#include "PT6302.h"
+#include "PT6301.h"
 
 DigitalOut myled(LED1);
 Serial pc(USBTX, USBRX);
 
-// PT6302 declaration, Default setting 16 Grids @ 35 Segments
-PT6302 PT6302(p5, p7, p8); // DI, CLK, CS
+// PT6301 declaration, Default setting 20 Grids @ 5x7 Segments for 2 rows of characters
+PT6301 PT6301(p5, p7, p8, p9); // DI, CLK, CS, RST
 
 int main() {
-  pc.printf("Hello World: PT6302 test\n\r");
+  pc.printf("Hello World: PT6301 test\n\r");
 
-  PT6302.writeData((char)'H', 9);
-  PT6302.writeData((char)'e', 8);
-  PT6302.writeData((char)'l', 7);
-  PT6302.writeData((char)'l', 6);
-  PT6302.writeData((char)'o', 5);
-
-  PT6302.setBlink(true, (PT6302_GR10 | PT6302_GR9 | PT6302_GR8 | PT6302_GR7 | PT6302_GR6) );
-                      
+//  PT6301.writeData((char)'H', 0, 0);
+//  PT6301.writeData((char)'e', 0, 1);
+//  PT6301.writeData((char)'l', 0, 2);
+//  PT6301.writeData((char)'l', 0, 3);
+//  PT6301.writeData((char)'o', 0, 4);
+  PT6301.printf("Hello World");
+  PT6301.refresh();  
+                     
   while(1) {
     myled = !myled;
     wait(1);