Library for Princeton PT6961 LED driver. Supports 6 digits @ 12 segments or 7 digits @ 11 segments. Also supports keyboard scanning of upto 30 keys. SPI interface.

Dependents:   mbed_PT6961

This LED driver is found in frontpanel controllers of consumer electronics such as DVD players. The added features such as the matrix keyboard scanning are useful in these applications.

Additional information is available on the component page here

Files at this revision

API Documentation at this revision

Comitter:
wim
Date:
Thu Jan 14 20:03:13 2016 +0000
Parent:
1:eb4758bba68a
Commit message:
Refactored display and keyboard defines

Changed in this revision

Font_7Seg.cpp Show annotated file Show diff for this revision Revisions of this file
Font_7Seg.h Show annotated file Show diff for this revision Revisions of this file
PT6961.cpp Show annotated file Show diff for this revision Revisions of this file
PT6961.h Show annotated file Show diff for this revision Revisions of this file
diff -r eb4758bba68a -r c6883ede8d8b Font_7Seg.cpp
--- a/Font_7Seg.cpp	Thu Jan 07 20:57:00 2016 +0000
+++ b/Font_7Seg.cpp	Thu Jan 14 20:03:13 2016 +0000
@@ -37,7 +37,7 @@
                                  };
 
 
-// ASCII Font definition table for transmission to PT6312
+// ASCII Font definition table for transmission to PT6961
 //
 //#define FONT_7S_START     0x20
 //#define FONT_7S_END       0x7F
@@ -60,7 +60,7 @@
                          C7_D,
                          C7_E,
                          C7_F
-                             };// 127                             
+                        };// 127                             
   
 #endif 
 
@@ -78,7 +78,7 @@
                                  };
 
 
-// ASCII Font definition table for transmission to PT6312
+// ASCII Font definition table for transmission to PT6961
 //
 //#define FONT_7S_START     0x20
 //#define FONT_7S_END       0x7F
@@ -101,6 +101,6 @@
                          C7_D,
                          C7_E,
                          C7_F
-                             };// 127                             
+                        };// 127                             
   
 #endif 
\ No newline at end of file
diff -r eb4758bba68a -r c6883ede8d8b Font_7Seg.h
--- a/Font_7Seg.h	Thu Jan 07 20:57:00 2016 +0000
+++ b/Font_7Seg.h	Thu Jan 14 20:03:13 2016 +0000
@@ -22,7 +22,7 @@
 #ifndef MBED_FONT_7SEG_H
 #define MBED_FONT_7SEG_H
 
-// Select one of the testboards for Princeton PT6312 VFD controller
+// Select one of the testboards for Princeton PT6961 LED controller
 #include "PT6961_Config.h"
 
 #if (HR734_TEST == 1) 
@@ -233,7 +233,7 @@
 
 //User Defined Characters (some examples)
                                                                           
-// Font data selection for transmission to PT6512 memory
+// Font data selection for transmission to PT6961 memory
 #define LO(x)  ( x & 0xFF)
 #define HI(x)  ((x >> 8) & 0xFF)
 
diff -r eb4758bba68a -r c6883ede8d8b PT6961.cpp
--- a/PT6961.cpp	Thu Jan 07 20:57:00 2016 +0000
+++ b/PT6961.cpp	Thu Jan 14 20:03:13 2016 +0000
@@ -1,6 +1,7 @@
 /* mbed PT6961 Library, for Princeton PT6961 LED controller
  * Copyright (c) 2015, v01: WH, Initial version (HR734)
  *               2016, v02: WH, Added V56S, Added Stream support
+ *               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
@@ -162,8 +163,9 @@
   for (int idx=0; idx < PT6961_KEY_MEM; idx++) {
     data = _flip(_spi.write(0xFF));    // read keys and correct bitorder
 
+    data = data & PT6961_KEY_MSK; // Mask valid bits
     if (data != 0) {  // Check for any pressed key
-      for (int bit=0; bit < PT6961_KEY_BITS; bit++) {
+      for (int bit=0; bit < 8; bit++) {
         if (data & (1 << bit)) {keypress++;} // Test all significant bits
       }
     }  
@@ -287,7 +289,7 @@
 
   if (clrAll) {
     //clear local buffer (including Icons)
-    for (int idx=0; idx < (HR734_NR_GRIDS << 1); idx++) {
+    for (int idx=0; idx < (HR734_NR_GRIDS << 1); idx++) { // * PT6961_BYTES_PER_GRID
       _displaybuffer[idx] = 0x00;  
     }
   }  
@@ -299,7 +301,7 @@
     }  
   }
 
-  writeData(_displaybuffer, (HR734_NR_GRIDS*2));
+  writeData(_displaybuffer, (HR734_NR_GRIDS * PT6961_BYTES_PER_GRID));
 
   _column = 0;   
 }     
@@ -314,12 +316,12 @@
 
    icn =        icon  & 0xFFFF;
   addr = (icon >> 24) & 0xFF; 
-  addr = (addr - 1) << 1;   
+  addr = (addr - 1) << 1;   // * PT6961_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, (HR734_NR_GRIDS*2));
+  writeData(_displaybuffer, (HR734_NR_GRIDS * PT6961_BYTES_PER_GRID));
 }
 
 /** Clr Icon
@@ -332,12 +334,12 @@
 
    icn =        icon  & 0xFFFF;
   addr = (icon >> 24) & 0xFF; 
-  addr = (addr - 1) << 1;   
+  addr = (addr - 1) << 1;   // * PT6961_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, (HR734_NR_GRIDS*2));
+  writeData(_displaybuffer, (HR734_NR_GRIDS * PT6961_BYTES_PER_GRID));
 }
 
 
@@ -402,13 +404,13 @@
       //Character to write
  
       //Translate between _column and displaybuffer entries
-      addr = _column << 1;
+      addr = _column << 1; // * PT6961_BYTES_PER_GRID
 
       //Save icons...and set bits for character to write
       _displaybuffer[addr]   = (_displaybuffer[addr]   & MASK_ICON_GRID[_column][0]) | LO(pattern);
       _displaybuffer[addr+1] = (_displaybuffer[addr+1] & MASK_ICON_GRID[_column][1]) | HI(pattern);
 
-      writeData(_displaybuffer, (HR734_NR_GRIDS*2));
+      writeData(_displaybuffer, (HR734_NR_GRIDS * PT6961_BYTES_PER_GRID));
                                 
       //Update Cursor
       _column++;
@@ -494,7 +496,7 @@
 
   if (clrAll) {
     //clear local buffer (including Icons)
-    for (int idx=0; idx < (V56S_NR_GRIDS << 1); idx++) {
+    for (int idx=0; idx < (V56S_NR_GRIDS << 1); idx++) {  // * PT6961_BYTES_PER_GRID
       _displaybuffer[idx] = 0x00;  
     }
   }  
@@ -506,7 +508,7 @@
     }  
   }
 
-  writeData(_displaybuffer, (V56S_NR_GRIDS*2));
+  writeData(_displaybuffer, (V56S_NR_GRIDS * PT6961_BYTES_PER_GRID));
 
   _column = 0;   
 }     
@@ -521,12 +523,12 @@
 
    icn =        icon  & 0xFFFF;
   addr = (icon >> 24) & 0xFF; 
-  addr = (addr - 1) << 1;   
+  addr = (addr - 1) << 1;   // * PT6961_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, (V56S_NR_GRIDS*2));
+  writeData(_displaybuffer, (V56S_NR_GRIDS * PT6961_BYTES_PER_GRID));
 }
 
 /** Clr Icon
@@ -539,12 +541,12 @@
 
    icn =        icon  & 0xFFFF;
   addr = (icon >> 24) & 0xFF; 
-  addr = (addr - 1) << 1;   
+  addr = (addr - 1) << 1;   // * PT6961_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, (V56S_NR_GRIDS*2));
+  writeData(_displaybuffer, (V56S_NR_GRIDS * PT6961_BYTES_PER_GRID));
 }
 
 
@@ -609,13 +611,13 @@
       //Character to write
  
       //Translate between _column and displaybuffer entries
-      addr = _column << 1;
+      addr = _column << 1;  // * PT6961_BYTES_PER_GRID
 
       //Save icons...and set bits for character to write
       _displaybuffer[addr]   = (_displaybuffer[addr]   & MASK_ICON_GRID[_column][0]) | LO(pattern);
       _displaybuffer[addr+1] = (_displaybuffer[addr+1] & MASK_ICON_GRID[_column][1]) | HI(pattern);
 
-      writeData(_displaybuffer, (V56S_NR_GRIDS*2));
+      writeData(_displaybuffer, (V56S_NR_GRIDS * PT6961_BYTES_PER_GRID));
                                 
       //Update Cursor
       _column++;
diff -r eb4758bba68a -r c6883ede8d8b PT6961.h
--- a/PT6961.h	Thu Jan 07 20:57:00 2016 +0000
+++ b/PT6961.h	Thu Jan 14 20:03:13 2016 +0000
@@ -2,6 +2,7 @@
  * Copyright (c) 2015, v01: WH, Initial version (HR734)
  *               2015, v02: WH, rename Digit/Grid
  *               2016, v02: WH, Added V56S, Added Stream support
+ *               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
@@ -70,11 +71,17 @@
  * @endcode
  */
 
+
+//PT6961 Display and Keymatrix data
+#define PT6961_MAX_NR_GRIDS    7
+#define PT6961_BYTES_PER_GRID  2
+//Significant bits Keymatrix data
+#define PT6961_KEY_MSK      0x3F 
+
 //Memory size in bytes for Display and Keymatrix
-#define PT6961_DISPLAY_MEM    14
+#define PT6961_DISPLAY_MEM  (PT6961_MAX_NR_GRIDS * PT6961_BYTES_PER_GRID)
 #define PT6961_KEY_MEM         5
-//Significant bits Keymatrix data
-#define PT6961_KEY_BITS        6 
+
 
 //Reserved bits for commands
 #define PT6961_CMD_MSK      0xE0