Library for the Princeton PT6312 Vacuum Fluorescent Display (VFD) driver.

Dependents:   mbed_PT6312

This library is documented here.

Files at this revision

API Documentation at this revision

Comitter:
wim
Date:
Wed Jan 20 18:50:50 2016 +0000
Parent:
5:be9ec73af639
Commit message:
Rename Digit/Grid, added DVD462 code, added C2233 code, added fonts.

Changed in this revision

Font_7Seg.h Show annotated file Show diff for this revision Revisions of this file
PT6312.cpp Show annotated file Show diff for this revision Revisions of this file
PT6312.h Show annotated file Show diff for this revision Revisions of this file
PT6312_Config.h Show annotated file Show diff for this revision Revisions of this file
diff -r be9ec73af639 -r d3dc313a6840 Font_7Seg.h
--- a/Font_7Seg.h	Sun Dec 20 14:41:58 2015 +0000
+++ b/Font_7Seg.h	Wed Jan 20 18:50:50 2016 +0000
@@ -1,5 +1,6 @@
 /* mbed VFD Font Library, for Princeton PT6312 VFD controller as used in Cyberhome DVD462 and C2233
  * Copyright (c) 2015, v01: WH, Initial version, Test DVD462 and C2233
+ *               2015, v02: WH, Added symbols
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -169,6 +170,9 @@
 
 // ASCII Font definitions for segments in each character
 //
+//32 0x20  Symbols
+#define C7_SPC  ()
+
 //48 0x30  Digits
 #define C7_0    (S7_A | S7_B | S7_C | S7_D | S7_E | S7_F)
 #define C7_1    (S7_B | S7_C)
@@ -188,10 +192,10 @@
 #define C7_E    (S7_A | S7_D | S7_E | S7_F | S7_G)
 #define C7_F    (S7_A | S7_E | S7_F | S7_G)
 
-#define C7_G    (S7_A | S7_B | S7_C | S7_F | S7_G)
+#define C7_G    (S7_A | S7_C | S7_D | S7_E | S7_F)
 #define C7_H    (S7_B | S7_C | S7_E | S7_F | S7_G)
 #define C7_I    (S7_B | S7_C)
-#define C7_J    (S7_B | S7_C | S7_D)
+#define C7_J    (S7_B | S7_C | S7_D | S7_E)
 #define C7_L    (S7_D | S7_E | S7_F)
 #define C7_M    (S7_C | S7_E | S7_G)
 #define C7_N    (S7_C | S7_E | S7_G)
diff -r be9ec73af639 -r d3dc313a6840 PT6312.cpp
--- a/PT6312.cpp	Sun Dec 20 14:41:58 2015 +0000
+++ b/PT6312.cpp	Wed Jan 20 18:50:50 2016 +0000
@@ -1,6 +1,7 @@
 /* mbed PT6312 Library, for Princeton PT6312 VFD controller
  * Copyright (c) 2015, v01: WH, Initial version
  *               2015, v02: WH, rename Digit/Grid, added DVD462 code, added C2233 code
+ *               2016, v03: WH, refactored display and keyboard defines  
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -168,8 +169,9 @@
   for (int idx=0; idx < PT6312_KEY_MEM; idx++) {
     data = _flip(_spi.write(0xFF));    // read keys and correct bitorder
 
+    data = data & PT6312_KEY_MSK; // Mask valid bits
     if (data != 0) {  // Check for any pressed key
-      for (int bit=0; bit < PT6312_KEY_BITS; bit++) {
+      for (int bit=0; bit < 8; bit++) {
         if (data & (1 << bit)) {keypress++;} // Test all significant bits
       }
     }  
@@ -342,7 +344,7 @@
   
   if (clrAll) {
     //clear local buffer (including Icons)
-    for (int idx=0; idx < (DVP630_NR_GRIDS*2); idx++) {
+    for (int idx=0; idx < (DVP630_NR_GRIDS * PT6312_BYTES_PER_GRID); idx++) {
       _displaybuffer[idx] = 0x00;  
     }
   }  
@@ -369,12 +371,12 @@
 
    icn =        icon  & 0xFFFF;
   addr = (icon >> 24) & 0xFF; 
-  addr = (addr - 1) << 1;   
+  addr = (addr - 1) << 1;   // * PT6312_BYTES_PER_GRID
     
   //Save char...and set bits for icon to write
   _displaybuffer[addr]   = _displaybuffer[addr]   | LO(icn);      
   _displaybuffer[addr+1] = _displaybuffer[addr+1] | HI(icn);      
-  writeData(_displaybuffer, (DVP630_NR_GRIDS*2));
+  writeData(_displaybuffer, (DVP630_NR_GRIDS * PT6312_BYTES_PER_GRID));
 }
 
 /** Clr Icon
@@ -387,12 +389,12 @@
 
    icn =        icon  & 0xFFFF;
   addr = (icon >> 24) & 0xFF; 
-  addr = (addr - 1) << 1;   
+  addr = (addr - 1) << 1;   // * PT6312_BYTES_PER_GRID
     
   //Save char...and clr bits for icon to write
   _displaybuffer[addr]   = _displaybuffer[addr]   & ~LO(icn);      
   _displaybuffer[addr+1] = _displaybuffer[addr+1] & ~HI(icn);      
-  writeData(_displaybuffer, (DVP630_NR_GRIDS*2));
+  writeData(_displaybuffer, (DVP630_NR_GRIDS * PT6312_BYTES_PER_GRID));
 }
 
 
@@ -426,12 +428,12 @@
     }
     else if ((value >= 0) && (value < DVP630_NR_UDC)) {
       //Character to write
-      addr = ((DVP630_NR_DIGITS - 1) - _column) * 2; 
+      addr = ((DVP630_NR_DIGITS - 1) - _column) * PT6312_BYTES_PER_GRID; 
       
       //Save icons...and set bits for character to write
       _displaybuffer[addr]   = (_displaybuffer[addr]   & LO(S_ICON_MSK)) | _UDC_16S[value][0];      
       _displaybuffer[addr+1] = (_displaybuffer[addr+1] & HI(S_ICON_MSK)) | _UDC_16S[value][1];      
-      writeData(_displaybuffer, (DVP630_NR_DIGITS*2));
+      writeData(_displaybuffer, (DVP630_NR_DIGITS * PT6312_BYTES_PER_GRID));
                
       //Update Cursor
       _column++;
@@ -442,12 +444,12 @@
     else if ((value >= FONT_16S_START) && (value <= FONT_16S_END)) {   
       //Character to write
       value = value - FONT_16S_START;
-      addr = ((DVP630_NR_DIGITS - 1) - _column) * 2; 
+      addr = ((DVP630_NR_DIGITS - 1) - _column) * PT6312_BYTES_PER_GRID; 
       
       //Save icons...and set bits for character to write
       _displaybuffer[addr]   = (_displaybuffer[addr]   & LO(S_ICON_MSK)) | FONT_16S[value][0];      
       _displaybuffer[addr+1] = (_displaybuffer[addr+1] & HI(S_ICON_MSK)) | FONT_16S[value][1];      
-      writeData(_displaybuffer, (DVP630_NR_DIGITS*2));
+      writeData(_displaybuffer, (DVP630_NR_DIGITS * PT6312_BYTES_PER_GRID));
                
       //Update Cursor
       _column++;
@@ -526,7 +528,7 @@
 
   if (clrAll) {
     //clear local buffer (including Icons)
-    for (int idx=0; idx < (DVD462_NR_GRIDS << 1); idx++) {
+    for (int idx=0; idx < (DVD462_NR_GRIDS << 1); idx++) { // * PT6312_BYTES_PER_GRID
       _displaybuffer[idx] = 0x00;  
     }
   }  
@@ -538,7 +540,7 @@
     }  
   }
 
-  writeData(_displaybuffer, (DVD462_NR_GRIDS*2));
+  writeData(_displaybuffer, (DVD462_NR_GRIDS * PT6312_BYTES_PER_GRID));
 
   _column = 0;   
 }    
@@ -553,12 +555,12 @@
 
    icn =        icon  & 0xFFFF;
   addr = (icon >> 24) & 0xFF; 
-  addr = (addr - 1) << 1;   
+  addr = (addr - 1) << 1;   // * PT6312_BYTES_PER_GRID
     
   //Save char...and set bits for icon to write
   _displaybuffer[addr]   = _displaybuffer[addr]   | LO(icn);      
   _displaybuffer[addr+1] = _displaybuffer[addr+1] | HI(icn);      
-  writeData(_displaybuffer, (DVD462_NR_GRIDS*2));
+  writeData(_displaybuffer, (DVD462_NR_GRIDS * PT6312_BYTES_PER_GRID));
 }
 
 /** Clr Icon
@@ -571,12 +573,12 @@
 
    icn =        icon  & 0xFFFF;
   addr = (icon >> 24) & 0xFF; 
-  addr = (addr -1 ) << 1;   
+  addr = (addr -1 ) << 1;   // * PT6312_BYTES_PER_GRID
     
   //Save char...and clr bits for icon to write
   _displaybuffer[addr]   = _displaybuffer[addr]   & ~LO(icn);      
   _displaybuffer[addr+1] = _displaybuffer[addr+1] & ~HI(icn);      
-  writeData(_displaybuffer, (DVD462_NR_GRIDS*2));
+  writeData(_displaybuffer, (DVD462_NR_GRIDS * PT6312_BYTES_PER_GRID));
 }
 
 
@@ -670,7 +672,7 @@
                   _displaybuffer[2] = (_displaybuffer[2] & 0x80) | (pattern & 0x7F);                 
                   break;
       }      
-      writeData(_displaybuffer, (DVD462_NR_GRIDS*2));
+      writeData(_displaybuffer, (DVD462_NR_GRIDS * PT6312_BYTES_PER_GRID));
                                 
       //Update Cursor
       _column++;
@@ -760,7 +762,7 @@
     }  
   }
 
-  writeData(_displaybuffer, (C2233_NR_GRIDS*2));
+  writeData(_displaybuffer, (C2233_NR_GRIDS * PT6312_BYTES_PER_GRID));
 
   _column = 0;   
 }    
@@ -775,12 +777,12 @@
 
    icn =        icon  & 0xFFFF;
   addr = (icon >> 24) & 0xFF; 
-  addr = (addr - 1) << 1;   
+  addr = (addr - 1) << 1;   // * PT6312_BYTES_PER_GRID
     
   //Save char...and set bits for icon to write
   _displaybuffer[addr]   = _displaybuffer[addr]   | LO(icn);      
   _displaybuffer[addr+1] = _displaybuffer[addr+1] | HI(icn);      
-  writeData(_displaybuffer, (C2233_NR_GRIDS*2));
+  writeData(_displaybuffer, (C2233_NR_GRIDS * PT6312_BYTES_PER_GRID));
 }
 
 /** Clr Icon
@@ -793,12 +795,12 @@
 
    icn =        icon  & 0xFFFF;
   addr = (icon >> 24) & 0xFF; 
-  addr = (addr -1 ) << 1;   
+  addr = (addr -1 ) << 1;   // * PT6312_BYTES_PER_GRID
     
   //Save char...and clr bits for icon to write
   _displaybuffer[addr]   = _displaybuffer[addr]   & ~LO(icn);      
   _displaybuffer[addr+1] = _displaybuffer[addr+1] & ~HI(icn);      
-  writeData(_displaybuffer, (C2233_NR_GRIDS*2));
+  writeData(_displaybuffer, (C2233_NR_GRIDS * PT6312_BYTES_PER_GRID));
 }
 
 
@@ -892,7 +894,7 @@
                   _displaybuffer[2] = (_displaybuffer[2] & 0x80) | (pattern & 0x7F);                 
                   break;
       }      
-      writeData(_displaybuffer, (C2233_NR_GRIDS*2));
+      writeData(_displaybuffer, (C2233_NR_GRIDS * PT6312_BYTES_PER_GRID));
                                 
       //Update Cursor
       _column++;
diff -r be9ec73af639 -r d3dc313a6840 PT6312.h
--- a/PT6312.h	Sun Dec 20 14:41:58 2015 +0000
+++ b/PT6312.h	Wed Jan 20 18:50:50 2016 +0000
@@ -1,6 +1,7 @@
 /* mbed PT6312 Library, for Princeton PT6312 VFD controller
  * Copyright (c) 2015, v01: WH, Initial version
  *               2015, v02: WH, rename Digit/Grid, added DVD462 code, added C2233 code
+ *               2016, v03: WH, refactored display and keyboard defines 
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -104,11 +105,16 @@
  * @endcode
  */
 
+//PT6312 Display and Keymatrix data
+#define PT6312_MAX_NR_GRIDS   11
+#define PT6312_BYTES_PER_GRID  2
+//Significant bits Keymatrix data
+#define PT6312_KEY_MSK      0xFF 
+
 //Memory size in bytes for Display and Keymatrix
-#define PT6312_DISPLAY_MEM    22
+#define PT6312_DISPLAY_MEM  (PT6312_MAX_NR_GRIDS * PT6312_BYTES_PER_GRID)
 #define PT6312_KEY_MEM         3
-//Significant bits Keymatrix data
-#define PT6312_KEY_BITS        8 
+
 
 //Reserved bits for commands
 #define PT6312_CMD_MSK      0xE0
diff -r be9ec73af639 -r d3dc313a6840 PT6312_Config.h
--- a/PT6312_Config.h	Sun Dec 20 14:41:58 2015 +0000
+++ b/PT6312_Config.h	Wed Jan 20 18:50:50 2016 +0000
@@ -26,7 +26,7 @@
 // Select one of the testboards for Princeton PT6312 VFD controller
 #define PT6312_TEST  0 
 #define DVP630_TEST  0 
-#define DVD462_TEST  0 
-#define C2233_TEST   1 
+#define DVD462_TEST  1 
+#define C2233_TEST   0 
 
 #endif
\ No newline at end of file