Wim Huiskamp / PT6301
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PT6301.h Source File

PT6301.h

00001 /* mbed PT6301 Library, for Princeton PT6301 VFD controller
00002  *             The controller is used by Futaba 'Chip In Glass' (CIG) VFD tubes. 
00003  *
00004  * Copyright (c) 2021, v01: WH, Initial version
00005  *
00006  * Permission is hereby granted, free of charge, to any person obtaining a copy
00007  * of this software and associated documentation files (the "Software"), to deal
00008  * in the Software without restriction, including without limitation the rights
00009  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00010  * copies of the Software, and to permit persons to whom the Software is
00011  * furnished to do so, subject to the following conditions:
00012  *
00013  * The above copyright notice and this permission notice shall be included in
00014  * all copies or substantial portions of the Software.
00015  *
00016  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00019  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00020  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00021  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00022  * THE SOFTWARE.
00023  */
00024 
00025 #ifndef PT6301_H
00026 #define PT6301_H
00027 
00028 // Select one of the testboards for Princeton PT6301 VFD controller
00029 #include "PT6301_Config.h"
00030 #include "PT6301_UDC.h"
00031 
00032 /** An interface for driving Princeton PT6301 VFD controller
00033  *
00034  * @code
00035  *
00036  * #if (PT6301_TEST == 1)  
00037  * // Direct driving of PT6301 Test
00038  *
00039  * #include "mbed.h"
00040  * #include "PT6301.h" 
00041  *
00042  * DigitalOut myled(LED1);
00043  * Serial pc(USBTX, USBRX);
00044  * 
00045  * // PT6301 declaration, Default setting 2x20 Grids @ 5x7 Segments, 2 Icon segments for each Grid
00046  * PT6301 PT6301(p5, p7, p8, p9); // DI, CLK, CS, RST
00047  *
00048  * int main() {
00049  *   pc.printf("Hello World: PT6301 test\n\r");
00050  *
00051  *   PT6301.cls(); 
00052  *
00053  * //  PT6301.writeData((char)'H',0,0);
00054  * //  PT6301.writeData((char)'e',0,1);
00055  * //  PT6301.writeData((char)'l',0,2);
00056  * //  PT6301.writeData((char)'l',0,3);
00057  * //  PT6301.writeData((char)'o',0,4);
00058  *   PT6301.printf("Hello World");
00059  *   PT6301.refresh();  
00060  *   wait(2);
00061  *
00062  *   PT6301.setBrightness(PT6301_BRT0);
00063  *   wait(2);
00064  *   PT6301.setBrightness(PT6301_BRT3);
00065  *           
00066  *   while(1) {
00067  *     myled = !myled;
00068  *     wait(1);
00069  *   }
00070  * }
00071  * #endif
00072  *
00073  * @endcode
00074  */
00075 
00076 
00077 //PT6301 Display and Annunciator data
00078 #define PT6301_MAX_NR_GRIDS   20
00079 #define PT6301_MAX_NR_ROWS     2
00080 #define PT6301_BYTES_PER_GRID  1
00081 
00082 
00083 //The PT6301 has internal memory for all characters and icons. The content is automatically displayed on the tube.
00084 //The memory consists of two banks (row A and row B) for character memory and two banks (row A and row B) for icon memory. 
00085 //Each of those banks is accessed by separate commands.
00086 //However, these command do not support addressing individual locations in the memory. Memory updates always start at
00087 //address 0 in the selected row A or B. Consequently, the whole displaymemory needs to be rewritten when any 
00088 //location (except for 0) is to be updated. 
00089 //The library therefor uses a local mirror memory to store the display content, update one or more characters in
00090 //the mirrormemory as needed, and rewrite the whole displaymemory from the mirrorcontent. 
00091 //The write-back is performed by calling the 'refresh' method.
00092 //Additional advantage of the mirror-memory is that we can also implement wrap-around and scrolling from row A to B for multi-line displays.
00093    
00094 //Memory size in bytes for Display and Annunciators in total
00095 //#define PT6301_DSP_MEM        (PT6301_MAX_NR_ROWS * PT6301_MAX_NR_GRIDS * PT6301_BYTES_PER_GRID)
00096 //#define PT6301_ADD_MEM        (PT6301_MAX_NR_ROWS * PT6301_MAX_NR_GRIDS)
00097 //Memory size in bytes for Display and Annunciators per Row
00098 #define PT6301_DSP_MEM        (PT6301_MAX_NR_GRIDS * PT6301_BYTES_PER_GRID)
00099 #define PT6301_ADD_MEM        (PT6301_MAX_NR_GRIDS * PT6301_BYTES_PER_GRID)
00100 
00101 //User Defined Characters
00102 //Note that the PT6301 actually has two separate UDC banks for row A and B. 
00103 //In this lib both UDC memories are always identical.
00104 #define PT6301_UDC_MEM        16
00105 
00106 //SPI Serial control data consists of an 8-bit command and one or more data bytes.
00107 //Command and data are sent LSB first and latched on rising edge of CLK. Idle CLK is high.
00108 //Data address is auto incremented.
00109 //The commands and data are transmitted during CE low and latched on rising CE edge.
00110 //Multiple PT6301 devices on the same bus can only be distinguised by the CE control.
00111 //Normal SPI methods send data MSB first. This lib uses a helper method to flip the bits before transmission.
00112 
00113 //Command delay in us
00114 #define PT6301_CMD_DLY         8
00115 #define PT6301_CS_DLY         16
00116 //Reset delay in ms
00117 #define PT6301_RST_DLY        10
00118 
00119 //
00120 //Set Char data command (DCRAM_A)
00121 // 0 0 0 1 x x x x
00122 #define PT6301_DATA_A_REG     0x10
00123 //Set Char data command (DCRAM_B)
00124 // 1 0 0 1 x x x x
00125 #define PT6301_DATA_B_REG     0x90
00126 
00127 
00128 //Note: The PT6301 does not support address selection. The commandformat allows 
00129 //only 4bits for the address anyhow and this would be insufficient for a display
00130 //controller that can support upto 20 Grids.
00131 //Some other controllers with very similar commandsets and a max of 16 Grids do use the available 4 addressbits.
00132 //
00133 //No DCRAM Address Support, Always starts at address 0x00
00134 #define PT6301_DADR_MSK       0x0F
00135 
00136 //Char data (2nd byte, 3rd byte ...)
00137 //DA7..DA0 Character Data
00138 #define PT6301_DATA_MSK       0xFF
00139 
00140 //Note: The PT6301 supports separate UDCs banks for both rows A and B.
00141 //However, this lib always keeps both UDC banks identical.
00142 
00143 //Set UDC data command (CGRAM_A)
00144 // 0 0 1 0 UA3 UA2 UA1 UA0
00145 #define PT6301_UDC_A_REG      0x20
00146 //Set UDC data command (CGRAM_B)
00147 // 1 0 1 0 UA3 UA2 UA1 UA0
00148 #define PT6301_UDC_B_REG      0xA0
00149 
00150 //UA3..UA0 CGRAM Address (UDC RAM address)
00151 #define PT6301_UADR_MSK       0x0F
00152 #define PT6301_NR_UDC           16
00153 
00154 //User Defined Characters (UDCs) consist of 5x7 dots and are defined by a 5 byte bitpattern.
00155 //UDC data (2nd byte .. 6th byte)
00156 //    D7 D6   D5   D4.. D1 D0 
00157 // 0  *  CD30 CD25 ......  CD0
00158 // 1  *  CD31 CD26 ......  CD1
00159 // 2  *  CD32 CD27 ......  CD2
00160 // 3  *  CD33 CD28 ......  CD3
00161 // 4  *  CD34 CD29 ......  CD4
00162 //
00163 #define PT6301_UDC_MSK        0x7F
00164 
00165 //CD34..CD0 UDC Data
00166 //UDC is a 5x7 Matrix pattern that will show on the VFD as
00167 // 0   C0  C1  C2  C3  C4
00168 // 1   C5  C6 .......  C9
00169 // .    .............
00170 // .    .............
00171 // .    .............
00172 // 6   C30 C31 ...     C34
00173 //
00174 
00175 //UDCs are defined by a 5x7 matrix and stored as 5 bytes
00176 typedef char UDCData_t[5];
00177 
00178 
00179 //Set Additional data command (ADRAM_A), Used for annunciators etc
00180 // 0 0 1 1 x x x x
00181 #define PT6301_ADAT_A_REG     0x30
00182 //Set Additional data command (ADRAM_B), Used for annunciators etc
00183 // 1 0 1 1 x x x x
00184 #define PT6301_ADAT_B_REG     0xB0
00185 
00186 //Note: The PT6301 does not support address selection for icons. The commandformat allows 
00187 //only 4bits for the address anyhow and this would be insufficient for a display with upto 20 Grids
00188 //
00189 //No ADRAM Address (Additional data), always starts at 0x00
00190 #define PT6301_AADR_MSK       0x0F
00191 
00192 //* * * * * * * AD0 Additional Data (2nd byte, 3rd byte, ..)
00193 #define PT6301_ADAT_MSK       0x01
00194 
00195 //
00196 //Set Brightness command
00197 // 0 1 0 1 * * DC1 DC0
00198 #define PT6301_BRT_REG        0x50
00199 #define PT6301_BRT_MSK        0x03
00200 
00201 //Set Brightness command (2nd Byte)
00202 // DC9 DC8 DC7 DC6 DC5 DC4 DC3 DC2
00203 
00204 
00205 //Brightness Level (0..7), mapped onto Brightness command 2nd databyte
00206 //Note Brightness relationship between the number of active Grids (period) and the BRT value (duty cycle)
00207 #define PT6301_BRT_0          0x00   //Duty  0/1024 (Default)
00208 #define PT6301_BRT_1          0x20
00209 #define PT6301_BRT_2          0x40
00210 #define PT6301_BRT_3          0x80
00211 #define PT6301_BRT_4          0xA0
00212 #define PT6301_BRT_5          0xB0
00213 #define PT6301_BRT_6          0xD0
00214 #define PT6301_BRT_7          0xFF   //Duty 960/1024
00215 
00216 #define PT6301_BRT_DEF       (PT6301_BRT_2)
00217 
00218 
00219 //
00220 //Grid control command
00221 // 0 1 1 0 GN3 GN2 GN1 GN0
00222 #define PT6301_GRID_REG       0x60
00223 #define PT6301_GRID_MSK       0x0F
00224 
00225 //Grids. Each Grid controls 2 characters (A and B) and 2 icons (A and B)
00226 //
00227 // GN3 GN2 GN1 GN0
00228 //  0   0   0   0 G1 to G20  // Default
00229 //  0   0   0   1 G1 to G5
00230 //  0   0   1   0 G1 to G6
00231 //  0   0   1   1 G1 to G7
00232 //...
00233 //  1   0   0   0 G1 to G12
00234 //  1   0   0   1 G1 to G13
00235 //  1   0   1   0 G1 to G14
00236 //...
00237 //  1   1   1   1 G1 to G19
00238 //
00239 #define PT6301_GR1_GR5        0x01
00240 #define PT6301_GR1_GR6        0x02
00241 #define PT6301_GR1_GR7        0x03
00242 #define PT6301_GR1_GR8        0x04
00243 #define PT6301_GR1_GR9        0x05
00244 #define PT6301_GR1_GR10       0x06
00245 #define PT6301_GR1_GR11       0x07
00246 #define PT6301_GR1_GR12       0x08
00247 #define PT6301_GR1_GR13       0x09
00248 #define PT6301_GR1_GR14       0x0A
00249 #define PT6301_GR1_GR15       0x0B
00250 #define PT6301_GR1_GR16       0x0C
00251 #define PT6301_GR1_GR17       0x0D
00252 #define PT6301_GR1_GR18       0x0E
00253 #define PT6301_GR1_GR19       0x0F
00254 #define PT6301_GR1_GR20       0x00
00255 
00256 //
00257 //Display On/Off command
00258 // 0 1 1 1 * * H L
00259 #define PT6301_DSPL_REG       0x70
00260 #define PT6301_DSPL_MSK       0x03
00261 
00262 //Display Mode
00263 // H L Display operating state
00264 // 0 0 Normal display (default)
00265 // 0 1 Off
00266 // 1 0 All Segments and Additional Segments On
00267 // 1 1 All Segments and Additional Segments On
00268 #define PT6301_DSPL_NRM       0x00
00269 #define PT6301_DSPL_OFF       0x01
00270 #define PT6301_DSPL_ON        0x02
00271 
00272 
00273 /** A class for driving Princeton PT6301 VFD controller
00274  *
00275  *  @brief Supports upto 20 Grids of 5x7 matrix segments for 2 rows of characters (A and B). 
00276  *         Also supports               1 additional segment for 2 rows (A and B).
00277  *         SPI bus interface device (LSB first). 
00278  */
00279 class PT6301 : public Stream {
00280  public:
00281 
00282   /** Enums for display mode */
00283   enum Mode {
00284     Grid5  = PT6301_GR1_GR5,
00285     Grid6  = PT6301_GR1_GR6,
00286     Grid7  = PT6301_GR1_GR7,
00287     Grid8  = PT6301_GR1_GR8,
00288     Grid9  = PT6301_GR1_GR9,
00289     Grid10 = PT6301_GR1_GR10,
00290     Grid11 = PT6301_GR1_GR11,
00291     Grid12 = PT6301_GR1_GR12,
00292     Grid13 = PT6301_GR1_GR13,
00293     Grid14 = PT6301_GR1_GR14,
00294     Grid15 = PT6301_GR1_GR15,
00295     Grid16 = PT6301_GR1_GR16,
00296     Grid17 = PT6301_GR1_GR17,
00297     Grid18 = PT6301_GR1_GR18,
00298     Grid19 = PT6301_GR1_GR19,
00299     Grid20 = PT6301_GR1_GR20
00300   };
00301  
00302  /** Datatypes for display data */
00303 typedef char DisplayData_t[PT6301_MAX_NR_ROWS][PT6301_DSP_MEM];
00304 typedef char DisplayAdd_t[PT6301_MAX_NR_ROWS][PT6301_ADD_MEM];  
00305     
00306  /** Constructor for class for driving Princeton PT6301 VFD controller
00307   *
00308   *  @brief Supports upto 20 Grids of 5x7 matrix segments for 2 rows of characters (row A and B). 
00309   *         Also supports               1 additional segment for 2 rows of characters (row A and B).  
00310   *         SPI bus interface device. 
00311   *  @param  PinName mosi, sclk, cs SPI bus pins
00312   *  @param  PinName rst reset pin
00313   *  @param  Mode selects number of Grids and Segments (default 20 Grids, 5x7 matrix segments + 1 additional segment for 2 rows)
00314   *  @param  bool inverted_rows selects mapping of Data onto Display layout (default false)
00315   *  @param  Columns selects number of characters per row (default 20, same as Grids)
00316   *  @param  Rows selects number of rows (default 2)
00317   */
00318   PT6301(PinName mosi, PinName sclk, PinName cs, PinName rst, Mode mode = Grid20, bool inverted_rows = false, int columns = PT6301_MAX_NR_GRIDS, int rows = PT6301_MAX_NR_ROWS);
00319       
00320   /** Set Brightness
00321     *
00322     * @param  char brightness (3 significant bits, valid range 0..7 (dutycycle linked to number of grids)  
00323     * @return none
00324     */    
00325   void setBrightness(char brightness = PT6301_BRT_DEF);
00326   
00327   /** Set the Display mode On/off
00328     *
00329     * @param bool display mode
00330     * @return none    
00331     */
00332   void setDisplay(bool on);
00333 
00334   /** Set the Display test mode On/off
00335     *
00336     * @param bool display test mode
00337     * @return none    
00338     */
00339   void setDisplayTest(bool on);
00340 
00341   /** Set User Defined Characters (UDC) for A and B row
00342     *
00343     * @param unsigned char udc_idx   The Index of the UDC (0..15)
00344     * @param UDCData_t udc_data      The bitpattern for the UDC (5 bytes)
00345     * @return none    
00346     */
00347   void setUDC(unsigned char udc_idx, UDCData_t udc_data);
00348 
00349   /** Set Icon
00350     *
00351     * @param int row    The row of the icon (0..(rows-1))
00352     * @param int column The column of the icon (0..(cols-1))    
00353     * @return none    
00354     */
00355   void setIcon(int row, int column);
00356 
00357   /** Clr Icon
00358     *
00359     * @param int row    The row of the icon (0..(rows-1))
00360     * @param int column The column of the icon (0..(cols-1))    
00361     * @return none    
00362     */
00363   void clrIcon(int row, int column);
00364 
00365   /** Locate cursor to a screen row, column
00366     *
00367     * @param row     The vertical position from the top, indexed from 0     
00368     * @param column  The horizontal position from the left, indexed from 0
00369     * @return none     
00370     */
00371   void locate(int row, int column);
00372     
00373   /** Clear the screen and locate to (0,0)
00374     *
00375     * @param bool clrAll Clear Icons also (default = true)
00376     */
00377   void cls(bool clrAll = true);
00378   
00379   /** Refresh screen and show data in local mirrors on the display
00380     *
00381     * @param bool copyAll Copy Icons in Adat local mirror also (default = true)       
00382     * @return none
00383     */
00384   void refresh(bool copyAll = true);  
00385   
00386 
00387   /** Number of screen columns
00388     *
00389     * @param none
00390     * @return columns
00391     */
00392   int columns();  
00393 
00394   /** Number of screen rows
00395     *
00396     * @param none
00397     * @return rows
00398     */
00399   int rows();  
00400 
00401   /** Write Data to local mirror
00402     *
00403     * @param char data The databyte        
00404     * @param row       The vertical position from the top, indexed from 0     
00405     * @param column    The horizontal position from the left, indexed from 0
00406     * @return none     
00407     */
00408   void setData(char data, int row, int column);
00409 
00410   /** Read Data from local mirror
00411     *
00412     * @param row       The vertical position from the top, indexed from 0     
00413     * @param column    The horizontal position from the left, indexed from 0
00414     * @return char     The databyte        
00415     */
00416   char getData(int row, int column);
00417 
00418   /** Write AData to local mirror
00419     *
00420     * @param char data The symbol databyte        
00421     * @param row       The vertical position from the top, indexed from 0     
00422     * @param column    The horizontal position from the left, indexed from 0
00423     * @return none     
00424     */
00425   void setAData(char data, int row, int column);
00426 
00427   /** Read AData from local mirror
00428     *
00429     * @param row       The vertical position from the top, indexed from 0     
00430     * @param column    The horizontal position from the left, indexed from 0
00431     * @return char     The symbol databyte        
00432     */
00433   char getAData(int row, int column);
00434 
00435   
00436  protected:  
00437 
00438   /** Write Command byte to PT6301
00439     *
00440     *  @param char cmd Command byte
00441     *  @return none
00442     */  
00443   void _writeCmd(char cmd);
00444 
00445   /** Write Command and Data byte to PT6301
00446     *
00447     *  @param char cmd Command byte
00448     *  @param char data Parameter for Command byte    
00449     *  @return none
00450     */  
00451   void _writeCmd(char cmd, char data);
00452   
00453 
00454   /** Helper to reverse all command or databits. The PT6301 expects LSB first, whereas SPI is MSB first
00455     *
00456     *  @param  char data
00457     *  @return bitreversed data
00458     */ 
00459   char _flip(char data);
00460 
00461 /** Helper to reverse row idx depending on VFD layout
00462   *
00463   *  @param  int row_idx
00464   *  @return adjusted row_idx
00465   */ 
00466 int _row_flip(int row_idx);
00467 
00468 
00469 #if DOXYGEN_ONLY
00470     /** Write a character to the Display
00471      *
00472      * @param c The character to write to the display RAM
00473      * @return char written
00474      */
00475     int putc(int c);
00476 
00477     /** Write a formatted string to the Display
00478      *
00479      * @param format A printf-style format string, followed by the
00480      *               variables to use in formatting the string.
00481      */
00482     int printf(const char* format, ...);   
00483 #endif
00484 
00485     // Stream implementation functions
00486     virtual int _putc(int value);
00487     virtual int _getc();
00488 
00489 
00490  private:  
00491   SPI _spi;
00492   DigitalOut _cs;
00493   DigitalOut _rst;  
00494   Mode _mode;                      // Number of Grids
00495   bool _inverted_rows;             // Mapping of Rows to VFD layout
00496 
00497   int _column;                     // Current cursor location
00498   int _columns;                    // Max number of columns
00499   int _row;                        // Current cursor location
00500   int _rows;                       // Max number of rows
00501     
00502   DisplayData_t _displaybuffer;    // Local mirror for all chars
00503   DisplayAdd_t _addbuffer;         // Local mirror for all icons    
00504 
00505   /** Init the SPI interface and the controller
00506     *
00507     * @param  none
00508     * @return none
00509     */ 
00510   void _init();
00511 
00512 };
00513 
00514 
00515 #if (SMTG7400_TEST == 1)
00516 // Derived class for SMTG7400 display unit
00517 //   Grids 1-16, 1 row of 16 matrix characters (5x7 segments), 4 Additional segments in use.
00518 //
00519 
00520 //SMTG7400 Display data
00521 #define SMTG7400_NR_GRIDS 16
00522 #define SMTG7400_NR_COLS  16
00523 #define SMTG7400_NR_ROWS   1
00524 
00525 //#define SMTG7400_NR_UDC   16
00526 
00527 //SMTG7400 Icon data,
00528 //#defines encode the row and position in the row for each icon
00529 #define SMTG7400_ICON_ROW_SHFT  8
00530 #define SMTG7400_ICON_ROW_0    (0x00 << SMTG7400_ICON_ROW_SHFT)
00531 #define SMTG7400_ICON_ROW_1    (0x01 << SMTG7400_ICON_ROW_SHFT)
00532 #define SMTG7400_ICON_COL_MSK  (0x00FF)
00533 //
00534 #define SMTG7400_ICON_OFFLINE  (SMTG7400_ICON_ROW_0 | 1)
00535 #define SMTG7400_ICON_WIFI     (SMTG7400_ICON_ROW_0 | 2)
00536 #define SMTG7400_ICON_PHONE    (SMTG7400_ICON_ROW_0 | 3)
00537 #define SMTG7400_ICON_REC      (SMTG7400_ICON_ROW_0 | 8)
00538 
00539 /** Constructor for class for driving Princeton PT6301 VFD controller as used in SMTG7400
00540   *
00541   *  @brief Supports 16 Grids of 5x7 Segments with 4 additional Segments in use.
00542   *  
00543   *  @param  PinName mosi, sclk, cs SPI bus pins
00544   *  @param  PinName rst reset pin  
00545   */
00546 class PT6301_SMTG7400 : public PT6301{
00547  public:
00548 
00549 /** Constructor for class for driving Princeton PT6301 VFD controller as used in SMTG7400
00550   *
00551   *  @brief Supports 16 Grids of 5x7 Segments with 4 additional Segments in use.
00552   *  
00553   *  @param  PinName mosi, sclk, cs SPI bus pins
00554   *  @param  PinName rst reset pin  
00555   */
00556   PT6301_SMTG7400(PinName mosi, PinName sclk, PinName cs, PinName rst);
00557 
00558  /** Set Icon
00559     *
00560     * @param int icon   The icon ID
00561     * @return none    
00562     */
00563   void setIcon(int icon);
00564 
00565   /** Clr Icon
00566     *
00567     * @param int icon   The icon ID
00568     * @return none    
00569     */
00570   void clrIcon(int icon);
00571 
00572 protected:  
00573 
00574 private:
00575 
00576 };
00577 #endif
00578 
00579 #if (SMTC7140_TEST == 1)
00580 // Derived class for SMTC7140 display unit
00581 //   Grids 1-12, with 2 rows of 12 matrix characters (35 segments), no Additional segments.
00582 //   Grid    13 is used for icons displayed as a UDC symbol.
00583 //
00584 
00585 //SMTC7140 Display data
00586 #define SMTC7140_NR_GRIDS  13
00587 #define SMTC7140_NR_COLS   12
00588 #define SMTC7140_NR_ROWS    2
00589 
00590 //#define SMTC7140_NR_UDC    16
00591 #define SMTC7140_ICON_DOLBY     (1)
00592 #define SMTC7140_ICON_PLUS      (2)
00593 #define SMTC7140_ICON_HD        (3)
00594 #define SMTC7140_ICON_CLOCK     (4)
00595 #define SMTC7140_ICON_REC       (5)
00596 #define SMTC7140_ICON_MAIL      (6)
00597 
00598 const char SMTC7140_ICONS[][5] = {{0x7F, 0x7F, 0x7F, 0x7F, 0x7F},   // All On
00599                                   {0x00, 0x00, 0x08, 0x00, 0x00},   // Dolby
00600                                   {0x00, 0x04, 0x00, 0x00, 0x00},   // +
00601                                   {0x00, 0x00, 0x00, 0x08, 0x00},   // HD
00602                                   {0x00, 0x00, 0x00, 0x00, 0x10},   // Clock
00603                                   {0x20, 0x00, 0x00, 0x00, 0x00},   // Rec
00604                                   {0x00, 0x00, 0x00, 0x00, 0x40},   // Mail
00605                                   {0x00, 0x00, 0x00, 0x00, 0x00},   // 
00606                                 }; 
00607                                 
00608 /** Constructor for class for driving Princeton PT6301 VFD controller as used in SMTC7140
00609   *
00610   *  @brief Supports 12 Grids of 5x7 Segments without additional Icon Segments, for 2 Rows.
00611   *                  Grid13 is used for icons displayed by a UDC symbol. 
00612   *  
00613   *  @param  PinName mosi, sclk, cs SPI bus pins
00614   *  @param  PinName rst reset pin  
00615   */
00616 class PT6301_SMTC7140 : public PT6301 {
00617  public:
00618 
00619 /** Constructor for class for driving Princeton PT6301 VFD controller as used in SMTC7140
00620   *
00621   *  @brief Supports 12 Grids with 2 rows of 12 matrix characters (35 Segments), without additional Segments.
00622   *                  Grid 13 is used for icons displayed by a UDC symbol.
00623   *  
00624   *  @param  PinName mosi, sclk, cs SPI bus pins
00625   *  @param  PinName rst reset pin  
00626   */
00627   PT6301_SMTC7140(PinName mosi, PinName sclk, PinName cs, PinName rst);
00628 
00629 
00630 /** Set VFD VGen
00631   *
00632   * @param  bool on
00633   * @return none
00634   */
00635   void setVGen (bool on = true);     
00636 
00637 /** Set IconGrid13
00638   * Icons are shown on Grid13 using the UDC at index=0. The UDC char=0 is stored in _displaybuffer[0][12] at reset.
00639   * This method will set the correct segment in the UDC for each icon.
00640   *
00641   * @param int icon   The icon ID
00642   * @return none    
00643   */
00644   void setIconGrid13(int icon);
00645 
00646 /** Clr IconGrid13
00647   * Icons are shown on Grid13 using the UDC at index=0. The UDC char=0 is stored in _displaybuffer[0][12] at reset.
00648   * This method will clr the correct segment in the UDC for each icon. 
00649   *
00650   * @param int icon   The icon ID
00651   * @return none    
00652   */
00653   void clrIconGrid13(int icon);
00654 
00655 protected:  
00656 
00657 private:
00658   UDCData_t _icon_data; // Icon data is stored as UDC_idx=0 and displayed on position (0, 12)
00659 
00660 };
00661 #endif
00662 
00663 #endif