![](/media/cache/profiles/f095cedd23b99f1696fc8caecbcf257e.jpg.50x50_q85.jpg)
DMX512 library test http://mbed.org/users/okini3939/notebook/dmx512
main.cpp@5:d3b2ebcd5c25, 2013-09-02 (annotated)
- Committer:
- okini3939
- Date:
- Mon Sep 02 08:16:32 2013 +0000
- Revision:
- 5:d3b2ebcd5c25
- Parent:
- 4:4a566dc74bfb
fix library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
okini3939 | 0:ac66b38a42e3 | 1 | #include "mbed.h" |
okini3939 | 0:ac66b38a42e3 | 2 | #include "DMX.h" |
okini3939 | 0:ac66b38a42e3 | 3 | |
okini3939 | 3:f8a105b2daf3 | 4 | //DMX dmx0(p9, p10); |
okini3939 | 3:f8a105b2daf3 | 5 | DMX dmx1(p13, p14); |
okini3939 | 3:f8a105b2daf3 | 6 | DMX dmx2(p28, p27); |
okini3939 | 0:ac66b38a42e3 | 7 | |
okini3939 | 2:eeb225671cac | 8 | AnalogIn adc(p15); |
okini3939 | 0:ac66b38a42e3 | 9 | Serial pc(USBTX, USBRX); |
okini3939 | 3:f8a105b2daf3 | 10 | PwmOut led_r(p22), led_y(p23); |
okini3939 | 0:ac66b38a42e3 | 11 | |
okini3939 | 0:ac66b38a42e3 | 12 | int main() { |
okini3939 | 2:eeb225671cac | 13 | int i, n; |
okini3939 | 0:ac66b38a42e3 | 14 | |
okini3939 | 4:4a566dc74bfb | 15 | dmx1.start(); |
okini3939 | 4:4a566dc74bfb | 16 | dmx2.start(); |
okini3939 | 4:4a566dc74bfb | 17 | |
okini3939 | 4:4a566dc74bfb | 18 | for (i = 0; i < 512; i ++) { |
okini3939 | 4:4a566dc74bfb | 19 | dmx1.put(i, i & 0xff); |
okini3939 | 4:4a566dc74bfb | 20 | dmx2.put(i, 255 - (i & 0xff)); |
okini3939 | 3:f8a105b2daf3 | 21 | } |
okini3939 | 4:4a566dc74bfb | 22 | |
okini3939 | 4:4a566dc74bfb | 23 | while(1) { |
okini3939 | 4:4a566dc74bfb | 24 | n = 1; |
okini3939 | 3:f8a105b2daf3 | 25 | for (i = 0; i < 512; i ++) { |
okini3939 | 4:4a566dc74bfb | 26 | if (dmx1.get(i) != (i & 0xff)) { |
okini3939 | 4:4a566dc74bfb | 27 | n = 0; |
okini3939 | 4:4a566dc74bfb | 28 | } |
okini3939 | 3:f8a105b2daf3 | 29 | } |
okini3939 | 4:4a566dc74bfb | 30 | led_y = n; |
okini3939 | 4:4a566dc74bfb | 31 | |
okini3939 | 4:4a566dc74bfb | 32 | n = 1; |
okini3939 | 4:4a566dc74bfb | 33 | for (i = 0; i < 512; i ++) { |
okini3939 | 4:4a566dc74bfb | 34 | if (dmx2.get(i) != 255 - (i & 0xff)) { |
okini3939 | 4:4a566dc74bfb | 35 | n = 0; |
okini3939 | 4:4a566dc74bfb | 36 | } |
okini3939 | 4:4a566dc74bfb | 37 | } |
okini3939 | 4:4a566dc74bfb | 38 | led_r = n; |
okini3939 | 0:ac66b38a42e3 | 39 | } |
okini3939 | 4:4a566dc74bfb | 40 | } |