12-Channel LED Driver With Gray scale Adaptive Pulse Density Modulation Control IC maker MY-Semi

Dependencies:   MY9221 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /**
00002  * @section DESCRIPTION
00003  * maker http://www.my-semi.com/content/products/product_mean.aspx?id=9
00004  * shop  http://akizukidenshi.com/catalog/g/gI-09678/
00005  *
00006  * sample program schematic
00007  *
00008  *                VOUT(3.3V)           VOUT                     VOUT  
00009  *                 |                   |VDD                      |VDD     
00010  *          --------------            -------------            --------------- 
00011  *          mbed(LPC1768)|            |MY9221(2)  |            |MY9221(1)    |
00012  *                    p5 |------------|DI     DO  | ---------- |DI           |
00013  *                    p10|------------|DCKI   DCKO| ---------- |DCKI         | 
00014  *                       |            |           |            |             |  
00015  *                       |  22kOhme --|REXT-C     |  22kOhme --|REXT-C       |  
00016  *                       |  22kOhme --|REXT-B     |  22kOhme --|REXT-B       |  
00017  *                       |  22kOhme --|REXT-A     |  22kOhme --|REXT-A       |  
00018  *          -------------             -------------            --------------  
00019  *                                     |.........|              |...........|
00020  *                                     LED1   LED12             LED1    LED12                            
00021  */
00022 
00023 /*
00024 MY9366
00025 http://www.my-semi.com/content/products/product_mean.aspx?id=28
00026 */
00027 
00028 #include "mbed.h"
00029 #include "MY9221.h"
00030 MY9221 MY9221(p5, p10, 2);  // di, clk, number
00031 
00032 uint16_t D_gray[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
00033 float D_gray2[12] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
00034 
00035 int main()
00036 {
00037 
00038     MY9221.commandSet(MY9221::fast, MY9221::bit16, MY9221::freq1, MY9221::waveApdm, MY9221::internal, MY9221::workLed, MY9221::free, MY9221::repeat);
00039 
00040 
00041     while(1) {
00042 
00043         for(int i=0; i < 12; i++) {
00044             D_gray[i] += 0x100;
00045             D_gray2[i] += 0.01;
00046             if(D_gray2[i] > 1)D_gray2[i] = 0;
00047         }
00048         MY9221.dataRawSet(D_gray, 1);
00049         MY9221.dataSet(D_gray2, 2);
00050         wait_ms(20);                            // Image refresh Rate [s] < led gray data update cycle [s]
00051         MY9221.refresh();
00052 
00053     }
00054 }