Library for the Princeton PT6312 Vacuum Fluorescent Display (VFD) driver.
This library is documented here.
Diff: PT6312.h
- Revision:
- 5:be9ec73af639
- Parent:
- 4:6ecb924fa0b5
- Child:
- 6:d3dc313a6840
--- a/PT6312.h Fri Sep 11 19:32:17 2015 +0000 +++ b/PT6312.h Sun Dec 20 14:41:58 2015 +0000 @@ -1,5 +1,6 @@ /* 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 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,27 +24,28 @@ #ifndef PT6312_H #define PT6312_H -#include "Font_16Seg.h" +// Select one of the testboards for Princeton PT6312 VFD controller +#include "PT6312_Config.h" /** An interface for driving Princeton PT6312 VFD controller * * @code * - * #if(1) + * #if (PT6312_TEST == 1) * // Direct driving of PT6312 Test * * #include "mbed.h" * #include "PT6312.h" * - * DisplayData_t size is 8 bytes (4 digits @ segments) ... 22 bytes (11 digits @ 11 segments) - * DisplayData_t size default is 14 bytes (7 digits @ 15 segments) + * DisplayData_t size is 8 bytes (4 Grids @ 16 Segments) ... 22 bytes (11 Grids @ 11 Segments) + * DisplayData_t size default is 14 bytes (7 Grids @ 15 Segments) * PT6312::DisplayData_t mbed_str = {0xDA,0x00, 0x7C,0x00, 0x3C,0x01, 0xF6,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00}; * PT6312::DisplayData_t all_str = {0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F}; * * // KeyData_t size is 3 bytes * PT6312::KeyData_t keydata; * - * // PT6191 declaration, Default setting 7 Digits @ 15 Segments + * // PT6191 declaration, Default setting 7 Grids @ 15 Segments * PT6312 PT6312(p5,p6,p7, p8); * * int main() { @@ -68,9 +70,9 @@ * } * } * } + * #endif * - * #else - * + * #if (DVP630_TEST == 1) * //Philips DVP630 Display Test * * #include "mbed.h" @@ -79,7 +81,7 @@ * // KeyData_t size is 3 bytes * PT6312::KeyData_t keydata; * - * // PT6312_DVD declaration (7 Digits @ 15 Segments) + * // PT6312_DVD declaration (7 Grids @ 15 Segments) * PT6312_DVP630 DVP630(p5,p6,p7, p8); * * int main() { @@ -113,14 +115,14 @@ //Mode setting command #define PT6312_MODE_SET_CMD 0x00 -#define PT6312_DIG4_SEG16 0x00 -#define PT6312_DIG5_SEG16 0x01 -#define PT6312_DIG6_SEG16 0x02 -#define PT6312_DIG7_SEG15 0x03 //default -#define PT6312_DIG8_SEG14 0x04 -#define PT6312_DIG9_SEG13 0x05 -#define PT6312_DIG10_SEG12 0x06 -#define PT6312_DIG11_SEG11 0x07 +#define PT6312_GR4_SEG16 0x00 +#define PT6312_GR5_SEG16 0x01 +#define PT6312_GR6_SEG16 0x02 +#define PT6312_GR7_SEG15 0x03 //default +#define PT6312_GR8_SEG14 0x04 +#define PT6312_GR9_SEG13 0x05 +#define PT6312_GR10_SEG12 0x06 +#define PT6312_GR11_SEG11 0x07 //Data setting commands @@ -172,7 +174,7 @@ /** A class for driving Princeton PT6312 VFD controller * - * @brief Supports 4 Digits of 16 Segments upto 11 Digits of 11 Segments. Also supports a scanned keyboard of upto 24 keys, 4 switches and 4 LEDs. + * @brief Supports 4 Grids of 16 Segments upto 11 Grids of 11 Segments. Also supports a scanned keyboard of upto 24 keys, 4 switches and 4 LEDs. * SPI bus interface device. */ class PT6312 { @@ -180,14 +182,14 @@ /** Enums for display mode */ enum Mode { - Dig4_Seg16 = PT6312_DIG4_SEG16, - Dig5_Seg16 = PT6312_DIG5_SEG16, - Dig6_Seg16 = PT6312_DIG6_SEG16, - Dig7_Seg15 = PT6312_DIG7_SEG15, - Dig8_Seg14 = PT6312_DIG8_SEG14, - Dig9_Seg13 = PT6312_DIG9_SEG13, - Dig10_Seg12 = PT6312_DIG10_SEG12, - Dig11_Seg11 = PT6312_DIG11_SEG11 + Grid4_Seg16 = PT6312_GR4_SEG16, + Grid5_Seg16 = PT6312_GR5_SEG16, + Grid6_Seg16 = PT6312_GR6_SEG16, + Grid7_Seg15 = PT6312_GR7_SEG15, + Grid8_Seg14 = PT6312_GR8_SEG14, + Grid9_Seg13 = PT6312_GR9_SEG13, + Grid10_Seg12 = PT6312_GR10_SEG12, + Grid11_Seg11 = PT6312_GR11_SEG11 }; /** Datatypes for display and keymatrix data */ @@ -196,12 +198,12 @@ /** Constructor for class for driving Princeton PT6312 VFD controller * - * @brief Supports 4 Digits of 16 Segments upto 11 Digits of 11 Segments. Also supports a scanned keyboard of upto 24 keys, 4 switches and 4 LEDs. + * @brief Supports 4 Grids of 16 Segments upto 11 Grids of 11 Segments. Also supports a scanned keyboard of upto 24 keys, 4 switches and 4 LEDs. * SPI bus interface device. * @param PinName mosi, miso, sclk, cs SPI bus pins - * @param Mode selects either number of Digits and 12 Segments (default 7 Digits, 15 Segments) + * @param Mode selects either number of Grids and Segments (default 7 Grids, 15 Segments) */ - PT6312(PinName mosi, PinName miso, PinName sclk, PinName cs, Mode mode=Dig7_Seg15); + PT6312(PinName mosi, PinName miso, PinName sclk, PinName cs, Mode mode=Grid7_Seg15); /** Clear the screen and locate to 0 */ @@ -289,10 +291,15 @@ }; + +#if (DVP630_TEST == 1) // Derived class for PT6312 used in Philips DVP630 front display unit // +#include "Font_16Seg.h" +#define DVP630_NR_GRIDS 7 #define DVP630_NR_DIGITS 7 +#define DVP630_DIG1_IDX 1 #define DVP630_NR_UDC 8 /** Constructor for class for driving Princeton PT6312 VFD controller as used in Philips DVP630 @@ -305,10 +312,10 @@ public: /** Enums for Icons */ - // Digit encoded in 16 MSBs, Icon pattern encoded in 16 LSBs + // Grid encoded in 8 MSBs, Icon pattern encoded in 24 LSBs enum Icon { - Dig2_Col = (2<<16) | S_COL, - Dig4_Col = (4<<16) | S_COL + COL3 = (5<<24) | S_COL3, + COL5 = (3<<24) | S_COL5 }; typedef char UDCData_t[DVP630_NR_UDC][2]; @@ -322,13 +329,13 @@ PT6312_DVP630(PinName mosi, PinName miso, PinName sclk, PinName cs); #if DOXYGEN_ONLY - /** Write a character to the LCD + /** Write a character to the Display * * @param c The character to write to the display */ int putc(int c); - /** Write a formatted string to the LCD + /** Write a formatted string to the Display * * @param format A printf-style format string, followed by the * variables to use in formatting the string. @@ -343,19 +350,176 @@ void locate(int column); /** Clear the screen and locate to 0 + * @param bool clrAll Clear Icons also (default = false) */ - void cls(); + void cls(bool clrAll = false); /** Set Icon * - * @param Icon icon Enums Icon has Digit position encoded in 16 MSBs, Icon pattern encoded in 16 LSBs + * @param Icon icon Enums Icon has Digit position encoded in 8 MSBs, Icon pattern encoded in 16 LSBs * @return none */ void setIcon(Icon icon); /** Clr Icon * - * @param Icon icon Enums Icon has Digit position encoded in 16 MSBs, Icon pattern encoded in 16 LSBs + * @param Icon icon Enums Icon has Digit position encoded in 8 MSBs, Icon pattern encoded in 16 LSBs + * @return none + */ + void clrIcon(Icon icon); + + /** Set User Defined Characters (UDC) + * + * @param unsigned char udc_idx The Index of the UDC (0..7) + * @param int udc_data The bitpattern for the UDC (16 bits) + */ + void setUDC(unsigned char udc_idx, int udc_data); + + + /** Number of screen columns + * + * @param none + * @return columns + */ + int columns(); + + /** Write databyte to PT6312 + * @param int address display memory location to write byte + * @param char data byte written at given address + * @return none + */ + void writeData(int address, char data){ + PT6312::writeData(address, data); + } + + /** Write Display datablock to PT6312 + * @param DisplayData_t data Array of PT6312_DISPLAY_MEM (=22) bytes for displaydata (starting at address 0) + * @param length number bytes to write (valid range 0..(DVP630_NR_GRIDS*2) (=14), starting at address 0) + * @return none + */ + void writeData(DisplayData_t data, int length = (DVP630_NR_GRIDS*2)) { + PT6312::writeData(data, length); + } + +protected: + // Stream implementation functions + virtual int _putc(int value); + virtual int _getc(); + +private: + int _column; // Current cursor location + int _columns; // Max number of columns + + DisplayData_t _displaybuffer; // Local mirror for all chars and icons + UDCData_t _UDC_16S; // User Defined Character pattterns (UDC) +}; +#endif + +#if (DVD462_TEST == 1) +// Derived class for DVD462 in Cyberhome DVD462 front display unit +// Grids 2-4 each display two 7-Segment digits, Grid 5 displays one 7-Segment digit. +// Several Icons are also available. +// +#include "Font_7Seg.h" + +#define DVD462_NR_GRIDS 6 +#define DVD462_NR_DIGITS 7 +//#define DVD462_DIG1_IDX 1 +#define DVD462_NR_UDC 8 + +/** Constructor for class for driving Princeton PT6312 VFD controller as used in DVD462 + * + * @brief Supports 7 Digits of 7 Segments and icons. Also supports a scanned keyboard of 7 keys and 1 LED. + * + * @param PinName mosi, miso, sclk, cs SPI bus pins + */ +class PT6312_DVD462 : public PT6312, public Stream { + public: + + /** Enums for Icons */ + // Grid encoded in 8 MSBs, Icon pattern encoded in 24 LSBs + enum Icon { + MP3 = (1<<24) | S7_MP3, + CD = (1<<24) | S7_CD, + V = (1<<24) | S7_V, + S = (1<<24) | S7_S, + DVD = (1<<24) | S7_DVD, + + DDD = (2<<24) | S7_DDD, + DTS = (2<<24) | S7_DTS, + + COL5 = (3<<24) | S7_COL5, + + COL3 = (4<<24) | S7_COL3, + + ARW = (5<<24) | S7_ARW, + ALL = (5<<24) | S7_ALL, + PSE = (5<<24) | S7_PSE, + PLY = (5<<24) | S7_PLY, + PBC = (5<<24) | S7_PBC, + + P1 = (6<<24) | S7_P1, + P2 = (6<<24) | S7_P2, + P3 = (6<<24) | S7_P3, + P4 = (6<<24) | S7_P4, + P5 = (6<<24) | S7_P5, + P6 = (6<<24) | S7_P6, + P7 = (6<<24) | S7_P7, + P8 = (6<<24) | S7_P8, + P9 = (6<<24) | S7_P9, + P10 = (6<<24) | S7_P10, + P11 = (6<<24) | S7_P11, + P12 = (6<<24) | S7_P12, + P13 = (6<<24) | S7_P13 + + }; + + typedef char UDCData_t[DVD462_NR_UDC]; + + /** Constructor for class for driving Princeton PT6312 VFD controller as used in DVD462 + * + * @brief Supports 7 Digits of 7 Segments and Icons. Also supports a scanned keyboard of 7 keys and 1 LED. + * + * @param PinName mosi, miso, sclk, cs SPI bus pins + */ + PT6312_DVD462(PinName mosi, PinName miso, PinName sclk, PinName cs); + +#if DOXYGEN_ONLY + /** Write a character to the Display + * + * @param c The character to write to the display + */ + int putc(int c); + + /** Write a formatted string to the Display + * + * @param format A printf-style format string, followed by the + * variables to use in formatting the string. + */ + int printf(const char* format, ...); +#endif + + /** Locate cursor to a screen column + * + * @param column The horizontal position from the left, indexed from 0 + */ + void locate(int column); + + /** Clear the screen and locate to 0 + * @param bool clrAll Clear Icons also (default = false) + */ + void cls(bool clrAll = false); + + /** Set Icon + * + * @param Icon icon Enums Icon has Grid position encoded in 8 MSBs, Icon pattern encoded in 16 LSBs + * @return none + */ + void setIcon(Icon icon); + + /** Clr Icon + * + * @param Icon icon Enums Icon has Grid position encoded in 8 MSBs, Icon pattern encoded in 16 LSBs * @return none */ void clrIcon(Icon icon); @@ -375,12 +539,21 @@ */ int columns(); + /** Write databyte to PT6312 + * @param int address display memory location to write byte + * @param char data byte written at given address + * @return none + */ + void writeData(int address, char data){ + PT6312::writeData(address, data); + } + /** Write Display datablock to PT6312 * @param DisplayData_t data Array of PT6312_DISPLAY_MEM (=22) bytes for displaydata (starting at address 0) - * @param length number bytes to write (valid range 0..(DVP630_NR_DIGITS*2) (=14), starting at address 0) + * @param length number bytes to write (valid range 0..(DVD462_NR_GRIDS*2) (=14), starting at address 0) * @return none */ - void writeData(DisplayData_t data, int length = (DVP630_NR_DIGITS*2)) { + void writeData(DisplayData_t data, int length = (DVD462_NR_GRIDS*2)) { PT6312::writeData(data, length); } @@ -390,11 +563,168 @@ virtual int _getc(); private: - int _column; - int _columns; + int _column; // Current cursor location + int _columns; // Max number of columns + + DisplayData_t _displaybuffer; // Local mirror for all chars and icons + UDCData_t _UDC_7S; // User Defined Character pattterns (UDC) +}; +#endif + +#if (C2233_TEST == 1) +// Derived class for C2233 front display unit +// Grids 2-4 each display two 7-Segment digits, Grid 5 displays one 7-Segment digit. +// Several Icons are also available. +// +#include "Font_7Seg.h" + +#define C2233_NR_GRIDS 6 +#define C2233_NR_DIGITS 7 +//#define C2233_DIG1_IDX 1 +#define C2233_NR_UDC 8 + +/** Constructor for class for driving Princeton PT6312 VFD controller as used in C2233 + * + * @brief Supports 7 Digits of 7 Segments and icons. Also supports a scanned keyboard of 7 keys. + * + * @param PinName mosi, miso, sclk, cs SPI bus pins + */ +class PT6312_C2233 : public PT6312, public Stream { + public: + + /** Enums for Icons */ + // Grid encoded in 8 MSBs, Icon pattern encoded in 24 LSBs + enum Icon { + MP3 = (2<<24) | S7_MP3, + PBC = (2<<24) | S7_PBC, + + COL5 = (3<<24) | S7_COL5, + CAM = (3<<24) | S7_CAM, + + COL3 = (4<<24) | S7_COL3, + DDD = (4<<24) | S7_DDD, - DisplayData_t _displaybuffer; - UDCData_t _UDC_16S; + ARW = (5<<24) | S7_ARW, + ALL = (5<<24) | S7_ALL, + PSE = (5<<24) | S7_PSE, + PLY = (5<<24) | S7_PLY, + CD = (5<<24) | S7_CD, + V = (5<<24) | S7_V, + S = (5<<24) | S7_S, + DTS = (5<<24) | S7_DTS, + + P1 = (6<<24) | S7_P1, + P2 = (6<<24) | S7_P2, + P3 = (6<<24) | S7_P3, + P4 = (6<<24) | S7_P4, + P5 = (6<<24) | S7_P5, + P6 = (6<<24) | S7_P6, + P7 = (6<<24) | S7_P7, + P8 = (6<<24) | S7_P8, + P9 = (6<<24) | S7_P9, + P10 = (6<<24) | S7_P10, + P11 = (6<<24) | S7_P11, + P12 = (6<<24) | S7_P12, + P13 = (6<<24) | S7_P13, + + DVD = (6<<24) | S7_DVD + }; + + typedef char UDCData_t[C2233_NR_UDC]; + + /** Constructor for class for driving Princeton PT6312 VFD controller as used in C2233 + * + * @brief Supports 7 Digits of 7 Segments and Icons. Also supports a scanned keyboard of 7 keys. + * + * @param PinName mosi, miso, sclk, cs SPI bus pins + */ + PT6312_C2233(PinName mosi, PinName miso, PinName sclk, PinName cs); + +#if DOXYGEN_ONLY + /** Write a character to the Display + * + * @param c The character to write to the display + */ + int putc(int c); + + /** Write a formatted string to the Display + * + * @param format A printf-style format string, followed by the + * variables to use in formatting the string. + */ + int printf(const char* format, ...); +#endif + + /** Locate cursor to a screen column + * + * @param column The horizontal position from the left, indexed from 0 + */ + void locate(int column); + + /** Clear the screen and locate to 0 + * @param bool clrAll Clear Icons also (default = false) + */ + void cls(bool clrAll = false); + + /** Set Icon + * + * @param Icon icon Enums Icon has Grid position encoded in 8 MSBs, Icon pattern encoded in 16 LSBs + * @return none + */ + void setIcon(Icon icon); + + /** Clr Icon + * + * @param Icon icon Enums Icon has Grid position encoded in 8 MSBs, Icon pattern encoded in 16 LSBs + * @return none + */ + void clrIcon(Icon icon); + + /** Set User Defined Characters (UDC) + * + * @param unsigned char udc_idx The Index of the UDC (0..7) + * @param int udc_data The bitpattern for the UDC (16 bits) + */ + void setUDC(unsigned char udc_idx, int udc_data); + + + /** Number of screen columns + * + * @param none + * @return columns + */ + int columns(); + + /** Write databyte to PT6312 + * @param int address display memory location to write byte + * @param char data byte written at given address + * @return none + */ + void writeData(int address, char data){ + PT6312::writeData(address, data); + } + + /** Write Display datablock to PT6312 + * @param DisplayData_t data Array of PT6312_DISPLAY_MEM (=22) bytes for displaydata (starting at address 0) + * @param length number bytes to write (valid range 0..(DVD462_NR_GRIDS*2) (=14), starting at address 0) + * @return none + */ + void writeData(DisplayData_t data, int length = (C2233_NR_GRIDS*2)) { + PT6312::writeData(data, length); + } + +protected: + // Stream implementation functions + virtual int _putc(int value); + virtual int _getc(); + +private: + int _column; // Current cursor location + int _columns; // Max number of columns + + DisplayData_t _displaybuffer; // Local mirror for all chars and icons + UDCData_t _UDC_7S; // User Defined Character pattterns (UDC) }; +#endif -#endif \ No newline at end of file +#endif