Test program for Princeton PT6961 LED controller library.

Dependencies:   PT6961 mbed

See here for more information.

main.cpp

Committer:
wim
Date:
2015-08-23
Revision:
1:59c864633347
Parent:
0:c77f1ad8d993
Child:
2:3bc72b8f5481

File content as of revision 1:59c864633347:

/* mbed PT6961 Test program, for Princeton PT6961 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 "PT6961.h"

Serial pc(USBTX, USBRX);
DigitalOut myled(LED1);

// DisplayData_t size is 12 bytes (6 digits max 12 segments) OR 14 bytes (7 digits at max 11 segments) 
PT6961::DisplayData_t mbed_str = {0xDA,0x00, 0x7C,0x00, 0x3C,0x01, 0xF6,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00};  
PT6961::DisplayData_t all_str  = {0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F};  
PT6961::DisplayData_t bye_str = {0x7C,0x00, 0xEC,0x00, 0x3C,0x01, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00};  
PT6961::DisplayData_t hello_str = {0xDC,0x00, 0x3C,0x01, 0x38,0x00, 0x38,0x00, 0xF8,0x01, 0x00,0x00, 0x00,0x00};  

// KeyData_t size is 5 bytes  
PT6961::KeyData_t keydata; 

// PT6191 declaration, Default setting 7 Digits, 11 Segments
PT6961 pt6961(p5,p6,p7, p8);

int main() {
    
    pc.printf("Hello World\r\n"); //    
    
    pt6961.cls(); 
    pt6961.writeData(all_str);
    wait(4);
    pt6961.setBrightness(PT6961_BRT3);    
    pt6961.writeData(mbed_str);    
    wait(1);
    pt6961.setBrightness(PT6961_BRT0);        
    wait(1);
    pt6961.setBrightness(PT6961_BRT3);            
    
    while (1) {
     
      // Check and read keydata
      if (pt6961.readKeys(&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] == 0x10) { //sw2   
          pt6961.cls(); 
          pt6961.writeData(all_str);
        }  

        if (keydata[0] == 0x02) { //sw8   
          pt6961.cls(); 
          pt6961.writeData(hello_str);
        }  

        if (keydata[0] == 0x20) { //sw6   
          pt6961.cls(); 
          pt6961.writeData(mbed_str);
        }       

        if (keydata[1] == 0x02) { //sw4   
          pt6961.cls(); 
          pt6961.writeData(bye_str);
        }       
        
      } //if

      myled = !myled;
      wait(0.3);      
    } //while
}