Example code for the PT6312 VFD driver. Also supports the PT6312 in ASCII mode as used in the Philips DVP630 DVD player.
Diff: main.cpp
- Revision:
- 0:1d4ba8a2baa0
- Child:
- 1:0484256914b0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Aug 25 20:38:42 2015 +0000 @@ -0,0 +1,185 @@ +/* mbed PT6312 Test program, for Princeton PT6312 VFD controller + * Copyright (c) 2015, 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#if(1) +// DVD625 Display Test +#include "mbed.h" +#include "PT6312.h" +//#include "Font_16Seg.h" + +Serial pc(USBTX, USBRX); +DigitalOut myled(LED1); + +// DisplayData_t size is 8 bytes (4 digits max 16 segments) ... 22 bytes (11 digits at max 11 segments) +// DisplayData_t size default is 14 bytes (7 digits max 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,0x7F, 0xFF,0x7F, 0xFF,0x7F, 0xFF,0x7F, 0xFF,0x7F, 0xFF,0x7F, 0xFF,0x7F}; +//PT6312::DisplayData_t all_str = {0x0F,0x00, 0xF0,0x00, 0x00,0x0F, 0x00,0x70, 0x00,0x00, 0x00,0x00, 0x00,0x00}; + +//PT6312::DisplayData_t bye_str = {0x7C,0x00, 0xEC,0x00, 0x3C,0x01, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00}; +//PT6312::DisplayData_t hello_str = {0xDC,0x00, 0x3C,0x01, 0x38,0x00, 0x38,0x00, 0xF8,0x01, 0x00,0x00, 0x00,0x00}; + +//PT6312::DisplayData_t mbed_txt = {LO(C_D), HI(C_D), LO(C_E), HI(C_E), LO(C_B), HI(C_B), LO(C_M), HI(C_M)}; + +// KeyData_t size is 3 bytes +PT6312::KeyData_t keydata; + +// Switchdata is 1 byte +char switchdata; + +// PT6191 declaration, Default setting 7 Digits, 15 Segments +//PT6312 PT6312(p5,p6,p7, p8); +//PT6312 PT6312(p5,p6,p7, p8, PT6312::Dig4_Seg16); +PT6312_DVD625 DVD625(p5,p6,p7, p8); + +int main() { + + pc.printf("Hello World\r\n"); // + + DVD625.cls(); + DVD625.putc('A'); + wait(4); + + DVD625.setBrightness(PT6312_BRT7); + +//test to show all chars + wait(1); + DVD625.cls(); + + for (int i='A'; i<='Z'; i++) { + DVD625.putc(i); + wait(1); + } + +} + +#else +// Direct PT6312 Test +#include "mbed.h" +#include "PT6312.h" +#include "Font_16Seg.h" + +Serial pc(USBTX, USBRX); +DigitalOut myled(LED1); + +// DisplayData_t size is 8 bytes (4 digits max 16 segments) ... 22 bytes (11 digits at max 11 segments) +// DisplayData_t size default is 14 bytes (7 digits max 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,0x7F, 0xFF,0x7F, 0xFF,0x7F, 0xFF,0x7F, 0xFF,0x7F, 0xFF,0x7F, 0xFF,0x7F}; +//PT6312::DisplayData_t all_str = {0x0F,0x00, 0xF0,0x00, 0x00,0x0F, 0x00,0x70, 0x00,0x00, 0x00,0x00, 0x00,0x00}; + +PT6312::DisplayData_t bye_str = {0x7C,0x00, 0xEC,0x00, 0x3C,0x01, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00}; +PT6312::DisplayData_t hello_str = {0xDC,0x00, 0x3C,0x01, 0x38,0x00, 0x38,0x00, 0xF8,0x01, 0x00,0x00, 0x00,0x00}; + +PT6312::DisplayData_t mbed_txt = {LO(C_D), HI(C_D), LO(C_E), HI(C_E), LO(C_B), HI(C_B), LO(C_M), HI(C_M)}; + +// KeyData_t size is 3 bytes +PT6312::KeyData_t keydata; + +// Switchdata is 1 byte +char switchdata; + +// PT6191 declaration, Default setting 7 Digits, 15 Segments +PT6312 PT6312(p5,p6,p7, p8); +//PT6312 PT6312(p5,p6,p7, p8, PT6312::Dig4_Seg16); + +int main() { + + pc.printf("Hello World\r\n"); // + + PT6312.cls(); + PT6312.writeData(all_str); + wait(4); + PT6312.setBrightness(PT6312_BRT3); + PT6312.writeData(mbed_str); + wait(1); + PT6312.setBrightness(PT6312_BRT0); + wait(1); + PT6312.setBrightness(PT6312_BRT7); + + while (1) { + + // Check and read keydata + if (PT6312.getKeys(&keydata)) { + pc.printf("Keydata 0..2 = 0x%02x 0x%02x 0x%02x\r\n", keydata[0], keydata[1], keydata[2]); + + if (keydata[0] == 0x01) { //play + PT6312.cls(); + PT6312.writeData(all_str); + } + + if (keydata[0] == 0x02) { //stop + PT6312.cls(); + PT6312.writeData(hello_str); + } + + if (keydata[0] == 0x04) { //open/close + PT6312.cls(); +// PT6312.writeData(mbed_str); + PT6312.writeData(mbed_txt); + +#if(0) +//test to show all chars + wait(1); + PT6312.cls(); + + for (int i=0; i<26; i++) { + PT6312.writeData(0, font_16A[i][0]); + PT6312.writeData(1, font_16A[i][1]); + wait(1); + } +#endif + } + + } //if Key + + + // Check and read switch data + switchdata = PT6312.getSwitches(); + + if (switchdata != 0) { + pc.printf("Switchdata = 0x%02x\r\n", switchdata); + + if (switchdata == PT6312_SW1) { //S1 + PT6312.cls(); + PT6312.writeData(hello_str); + } + + if (switchdata == PT6312_SW2) { //S2 + PT6312.cls(); + PT6312.writeData(bye_str); + } + + if (switchdata == PT6312_SW3) { //S3 + PT6312.cls(); + PT6312.writeData(mbed_str); + } + + PT6312.setLED(switchdata); //write LEDs in same pattern + } //if Switch + + + myled = !myled; + wait(0.3); + } //while +} +#endif \ No newline at end of file