Example program for Heroic Robotics FastPixel LED strip driver.
Dependencies: FastPixelLPD8806 MODDMA mbed
main.cpp@0:01e1cefa76da, 2014-05-31 (annotated)
- Committer:
- heroic
- Date:
- Sat May 31 18:44:15 2014 +0000
- Revision:
- 0:01e1cefa76da
Example program for Heroic Robotics FastPixel driver library.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
heroic | 0:01e1cefa76da | 1 | #include "mbed.h" |
heroic | 0:01e1cefa76da | 2 | #include "MODDMA.h" |
heroic | 0:01e1cefa76da | 3 | |
heroic | 0:01e1cefa76da | 4 | #include "FastPixelLPD8806.h" |
heroic | 0:01e1cefa76da | 5 | |
heroic | 0:01e1cefa76da | 6 | |
heroic | 0:01e1cefa76da | 7 | MODDMA dma; |
heroic | 0:01e1cefa76da | 8 | int current_strip_fill; |
heroic | 0:01e1cefa76da | 9 | |
heroic | 0:01e1cefa76da | 10 | LedStrip *strips[2]; |
heroic | 0:01e1cefa76da | 11 | |
heroic | 0:01e1cefa76da | 12 | DigitalOut myled(LED1); |
heroic | 0:01e1cefa76da | 13 | |
heroic | 0:01e1cefa76da | 14 | int main() { |
heroic | 0:01e1cefa76da | 15 | |
heroic | 0:01e1cefa76da | 16 | // First, create the strip objects. |
heroic | 0:01e1cefa76da | 17 | // The global current_strip_fill variable is an unfortunate workaround for the |
heroic | 0:01e1cefa76da | 18 | // fact that we virtualize these strips but the DMA engine needs to know which |
heroic | 0:01e1cefa76da | 19 | // one just got filled. |
heroic | 0:01e1cefa76da | 20 | |
heroic | 0:01e1cefa76da | 21 | current_strip_fill = 0; |
heroic | 0:01e1cefa76da | 22 | strips[0] = new FastPixelLPD8806(p5, p7, 240); |
heroic | 0:01e1cefa76da | 23 | current_strip_fill = 1; |
heroic | 0:01e1cefa76da | 24 | strips[1] = new FastPixelLPD8806(p11, p13, 240); |
heroic | 0:01e1cefa76da | 25 | |
heroic | 0:01e1cefa76da | 26 | int j=0; |
heroic | 0:01e1cefa76da | 27 | |
heroic | 0:01e1cefa76da | 28 | while (1) { |
heroic | 0:01e1cefa76da | 29 | // then write something into the strips: |
heroic | 0:01e1cefa76da | 30 | for (int i=0; i<240; i++) { |
heroic | 0:01e1cefa76da | 31 | strips[0]->setPixelColor(i, (j++) % 256, (j++) % 256, (j++) % 256); |
heroic | 0:01e1cefa76da | 32 | strips[1]->setPixelColor(i, (j++) % 256, (j++) % 256, (j++) % 256); |
heroic | 0:01e1cefa76da | 33 | } |
heroic | 0:01e1cefa76da | 34 | // then show the strips: |
heroic | 0:01e1cefa76da | 35 | current_strip_fill = 0; |
heroic | 0:01e1cefa76da | 36 | strips[0]->show(); |
heroic | 0:01e1cefa76da | 37 | |
heroic | 0:01e1cefa76da | 38 | current_strip_fill = 1; |
heroic | 0:01e1cefa76da | 39 | strips[1]->show(); |
heroic | 0:01e1cefa76da | 40 | } |
heroic | 0:01e1cefa76da | 41 | } |