Suga koubou
/
dmx_test
DMX512 library test http://mbed.org/users/okini3939/notebook/dmx512
Diff: main.cpp
- Revision:
- 3:f8a105b2daf3
- Parent:
- 2:eeb225671cac
- Child:
- 4:4a566dc74bfb
diff -r eeb225671cac -r f8a105b2daf3 main.cpp --- a/main.cpp Sun May 08 14:50:41 2011 +0000 +++ b/main.cpp Fri Jun 03 13:20:01 2011 +0000 @@ -1,32 +1,40 @@ #include "mbed.h" #include "DMX.h" -DMX dmx(p9, p10); -//DMX dmx(p13, p14); -//DMX dmx(p28, p27); +//DMX dmx0(p9, p10); +DMX dmx1(p13, p14); +DMX dmx2(p28, p27); AnalogIn adc(p15); -PwmOut led[] = {(LED1), (LED2), (LED3), (LED4)}; Serial pc(USBTX, USBRX); +PwmOut led_r(p22), led_y(p23); int main() { int i, n; + // OUTPUT1: fade in / OUTPUT2: fade out while(1) { + for (n = 0; n < 256; n ++) { + dmx1.put(0, n); + dmx2.put(0, 255 - n); + led_r = (float)n / 255; + led_y = (float)(255 - n) / 255; + wait(0.02); + } + } + +/* + // INPUT1 -> OUTPUT2 / INPUT2 -> OUTPUT1 + while (1) { + for (i = 0; i < 512; i ++) { + n = dmx1.get(i); + dmx2.put(i, n); + n = dmx2.get(i); + dmx1.put(i, n); + } + led_r = (float)dmx1.get(0) / 255; + led_y = (float)dmx2.get(0) / 255; wait(0.1); - - n = adc.read_u16() >> 8; - dmx.put(0, n); - - pc.printf("tx: %d / ", n); - - pc.printf("rx: ", dmx.get(0)); - for (i = 0; i < 4; i ++) { - n = dmx.get(i); - led[i] = (float)n / 255.0; - pc.printf("%d ", n); - } - - pc.printf("\r\n"); } +*/ }