Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- wim
- Date:
- 2015-11-21
- Revision:
- 1:f60466cbc186
- Parent:
- 0:58787244fcec
- Child:
- 2:c6897ab055a2
File content as of revision 1:f60466cbc186:
/* mbed PT6964 Test program, for PT6964 LED 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.
*/
#include "mbed.h"
#include "PT6964.h"
Serial pc(USBTX, USBRX);
DigitalOut myled(LED1);
#if(1)
//High level Control PT9664 for DVD538
PT6964_DVD538A::DisplayData_t all_str = {0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F};
// KeyData_t size is 5 bytes
PT6964_DVD538A::KeyData_t keydata;
// PT6964 declaration, Default setting 7 Grids @ 10 Segments
PT6964_DVD538A PT6964_dvd538a(p5,p6,p7, p8);
int main() {
pc.printf("Hello World\r\n"); //
PT6964_dvd538a.cls();
PT6964_dvd538a.writeData(all_str);
wait(4);
PT6964_dvd538a.setBrightness(PT6964_BRT3);
wait(1);
PT6964_dvd538a.setBrightness(PT6964_BRT0);
wait(1);
PT6964_dvd538a.setBrightness(PT6964_BRT3);
while (1) {
// Check and read keydata
if (PT6964_dvd538a.getKeys(&keydata)) {
pc.printf("Keydata 0..4 = 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\r\n", keydata[0], keydata[1], keydata[2], keydata[3], keydata[4]);
if (keydata[0] == 0x01) { //sw1 L/R
// PT6964_dvd538a.cls();
PT6964_dvd538a.setIcon(PT6964_DVD538A::Grid1_LD1);
PT6964_dvd538a.setIcon(PT6964_DVD538A::Grid1_LD2);
PT6964_dvd538a.setIcon(PT6964_DVD538A::Grid1_CD);
PT6964_dvd538a.setIcon(PT6964_DVD538A::Grid1_DVD);
PT6964_dvd538a.setIcon(PT6964_DVD538A::Grid1_PSE);
PT6964_dvd538a.setIcon(PT6964_DVD538A::Grid1_PLY);
PT6964_dvd538a.setIcon(PT6964_DVD538A::Grid1_COL);
PT6964_dvd538a.setIcon(PT6964_DVD538A::Grid1_MP4);
PT6964_dvd538a.setIcon(PT6964_DVD538A::Grid1_MP3);
}
if (keydata[0] == 0x02) { //sw2 Stop
PT6964_dvd538a.cls();
}
if (keydata[0] == 0x08) { //sw4 Play
PT6964_dvd538a.cls();
// for (int i=0; i<16; i++) {
for (int i=0x00; i<=0xFF; i++) {
PT6964_dvd538a.locate(0);
PT6964_dvd538a.printf("%04x", i);
// PT6964_dvd538a.printf("%04X", i);
wait(0.2);
}
}
if (keydata[0] == 0x10) { //sw3 Open
// PT6964_dvd538a.cls();
PT6964_dvd538a.clrIcon(PT6964_DVD538A::Grid1_LD1);
PT6964_dvd538a.clrIcon(PT6964_DVD538A::Grid1_MP3);
}
} //if
myled = !myled;
wait(0.3);
} //while
}
#else
//Direct control of PT9664 for DVD538
// DisplayData_t size is 8 bytes (4 digits @ 13 segments) OR 10 bytes (5 digits @ 12 segments) OR
// 12 bytes (6 digits @ 11 segments) OR 14 bytes (7 digits @ 10 segments)
PT6964::DisplayData_t mbed_str = {0xDA,0x00, 0x7C,0x00, 0x3C,0x01, 0xF6,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00};
PT6964::DisplayData_t all_str = {0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F};
PT6964::DisplayData_t bye_str = {0x7C,0x00, 0xEC,0x00, 0x3C,0x01, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00};
PT6964::DisplayData_t hello_str = {0xDC,0x00, 0x3C,0x01, 0x38,0x00, 0x38,0x00, 0xF8,0x01, 0x00,0x00, 0x00,0x00};
PT6964::DisplayData_t tst_str;
#if(0)
PT6964::DisplayData_t hello1_str = {0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0xF8,0x03, 0x00,0x00, 0x00,0x00};
PT6964::DisplayData_t hello2_str = {0x00,0x00, 0x00,0x00, 0x00,0x00, 0xF8,0x03, 0x00,0x00, 0x00,0x00, 0x00,0x00};
PT6964::DisplayData_t hello3_str = {0x00,0x00, 0x00,0x00, 0xF8,0x03, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00};
PT6964::DisplayData_t hello4_str = {0x00,0x00, 0xF8,0x03, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00};
#endif
PT6964::DisplayData_t hello1_str = {0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x30,0x00, 0x00,0x00, 0x00,0x00};
PT6964::DisplayData_t hello2_str = {0x00,0x00, 0x00,0x00, 0x00,0x00, 0xE8,0x02, 0x00,0x00, 0x00,0x00, 0x00,0x00};
PT6964::DisplayData_t hello3_str = {0x00,0x00, 0x00,0x00, 0x78,0x02, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00};
PT6964::DisplayData_t hello4_str = {0x00,0x00, 0x30,0x03, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00};
// KeyData_t size is 5 bytes
PT6964::KeyData_t keydata;
// PT6964 declaration, Default setting 7 Grids @ 10 Segments
PT6964 PT6964(p5,p6,p7, p8);
int main() {
pc.printf("Hello World\r\n"); //
PT6964.cls();
PT6964.writeData(all_str);
wait(4);
PT6964.setBrightness(PT6964_BRT3);
PT6964.writeData(mbed_str);
wait(1);
PT6964.setBrightness(PT6964_BRT0);
wait(1);
PT6964.setBrightness(PT6964_BRT3);
while (1) {
// Check and read keydata
if (PT6964.getKeys(&keydata)) {
pc.printf("Keydata 0..4 = 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\r\n", keydata[0], keydata[1], keydata[2], keydata[3], keydata[4]);
if (keydata[0] == 0x01) { //sw1 L/R
PT6964.cls();
PT6964.writeData(hello1_str);
#if(0)
for (int idx=0; idx < PT6964_DISPLAY_MEM;idx++){
tst_str[idx]=0x00;
}
// tst_str[0]=0x01; //LD2
// tst_str[0]=0x10; //DVD
// tst_str[1]=0x01; // MP4
// tst_str[2]=0x08; // D4
tst_str[2]=0x80; // E4
PT6964.writeData(tst_str);
#endif
}
if (keydata[0] == 0x02) { //sw2 Stop
PT6964.cls();
PT6964.writeData(hello2_str);
#if(0)
for (int idx=0; idx < PT6964_DISPLAY_MEM;idx++){
tst_str[idx]=0x00;
}
// tst_str[0]=0x02; //LD1
// tst_str[0]=0x20; // pause
// tst_str[1]=0x02; // MP3
// tst_str[2]=0x10; // C4
tst_str[3]=0x01; // F4
PT6964.writeData(tst_str);
#endif
}
if (keydata[0] == 0x08) { //sw4 Play
PT6964.cls();
PT6964.writeData(hello3_str);
#if(0)
for (int idx=0; idx < PT6964_DISPLAY_MEM;idx++){
tst_str[idx]=0x00;
}
// tst_str[0]=0x04; // nc
// tst_str[0]=0x40; // Play arrow
// tst_str[2]=0x01; // nc
// tst_str[2]=0x20; // B4
tst_str[3]=0x02; // G4
PT6964.writeData(tst_str);
#endif
}
if (keydata[0] == 0x10) { //sw3 Open
PT6964.cls();
PT6964.writeData(hello4_str);
#if(0)
for (int idx=0; idx < PT6964_DISPLAY_MEM;idx++){
tst_str[idx]=0x00;
}
// tst_str[0]=0x08; //CD
// tst_str[0]=0x80; // colon
// tst_str[2]=0x02; // nc
// tst_str[2]=0x40; // A4
tst_str[3]=0x04; // nc
PT6964.writeData(tst_str);
#endif
}
} //if
myled = !myled;
wait(0.3);
} //while
}
#endif
PT6964 LED controller (70 LEDs max), Keyboard scan (20 keys max)