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:
- 1:0484256914b0
- Parent:
- 0:1d4ba8a2baa0
- Child:
- 2:0dd4c697fc31
--- a/main.cpp Tue Aug 25 20:38:42 2015 +0000 +++ b/main.cpp Thu Aug 27 21:22:51 2015 +0000 @@ -21,54 +21,100 @@ */ #if(1) -// DVD625 Display Test +// DVP630 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); +// PT6312_DVD declaration (7 Digits, 15 Segments) +PT6312_DVP630 DVP630(p5,p6,p7, p8); int main() { pc.printf("Hello World\r\n"); // - DVD625.cls(); - DVD625.putc('A'); - wait(4); + DVP630.cls(); + DVP630.putc('A'); + wait(1); - DVD625.setBrightness(PT6312_BRT7); + DVP630.setBrightness(PT6312_BRT7); //test to show all chars wait(1); - DVD625.cls(); + DVP630.cls(); - for (int i='A'; i<='Z'; i++) { - DVD625.putc(i); - wait(1); +// for (int i='A'; i<='Z'; i++) { +// DVP630.putc(i); +// wait(0.5); +// } + + for (int i=0x20; i<0x80; i++) { + DVP630.cls(); + DVP630.printf("0x%2X=%c", i, (char) i); + wait(0.1); + pc.getc(); } + + while (1) { + + // Check and read keydata + if (DVP630.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 + DVP630.cls(); + DVP630.printf("AAAAAAA"); + } + + if (keydata[0] == 0x02) { //stop + DVP630.cls(); + DVP630.printf("HELLO "); + } + + if (keydata[0] == 0x04) { //open/close + DVP630.cls(); + DVP630.printf("MBED "); + } + + } //if Key + + + // Check and read switch data + switchdata = DVP630.getSwitches(); + + if (switchdata != 0) { + pc.printf("Switchdata = 0x%02x\r\n", switchdata); + + if (switchdata == PT6312_SW1) { //S1 + DVP630.cls(); + DVP630.printf(" HELLO "); + } + + if (switchdata == PT6312_SW2) { //S2 + DVP630.cls(); + DVP630.printf("BYE "); + } + + if (switchdata == PT6312_SW3) { //S3 + DVP630.cls(); + DVP630.printf("HI MBED"); + } + + DVP630.setLED(switchdata); //write LEDs in same pattern + } //if Switch + + + myled = !myled; + wait(0.3); + } //while }