DMX512, RDM send/recv library http://mbed.org/users/okini3939/notebook/dmx512

Dependents:   dmx_test ArtNodeLED SPK-DVIMXR SPK-DMXer ... more

DMX512 send/recv library

DMX512 is protocol for lighting.

調光プロトコル DMX512 を送受信するライブラリです。

see: http://mbed.org/users/okini3939/notebook/dmx512/

LPC1114 support is thanks to Stanly Chen

Files at this revision

API Documentation at this revision

Comitter:
okini3939
Date:
Wed Nov 21 01:44:21 2012 +0000
Parent:
3:2eb66b4d99bd
Child:
5:72039cd4c874
Commit message:
add start(), stop()

Changed in this revision

DMX.cpp Show annotated file Show diff for this revision Revisions of this file
DMX.h Show annotated file Show diff for this revision Revisions of this file
--- a/DMX.cpp	Fri Sep 28 03:31:02 2012 +0000
+++ b/DMX.cpp	Wed Nov 21 01:44:21 2012 +0000
@@ -18,7 +18,8 @@
         data_tx[i] = 0;
         data_rx[i] = 0;
     }
-    mode_tx = DMX_MODE_BEGIN;
+//    mode_tx = DMX_MODE_BEGIN;
+    mode_tx = DMX_MODE_STOP;
     mode_rx = DMX_MODE_BEGIN;
     is_recived = 0;
     is_sent = 0;
@@ -55,7 +56,7 @@
     dmx.format(8, Serial::None, 2);
     dmx.attach(this, &DMX::int_rx, Serial::RxIrq);
 
-    timeout01.attach_us(this, &DMX::int_timer, DMX_TIME_BETWEEN);
+//    timeout01.attach_us(this, &DMX::int_timer, DMX_TIME_BETWEEN);
 }
 
 void DMX::put (int ch, int data) {
@@ -162,12 +163,16 @@
     }
 }
 
-void DMX::reset () {
+void DMX::start () {
+    if (mode_tx == DMX_MODE_STOP) {
+        mode_tx = DMX_MODE_BEGIN;
+        is_sent = 0;
+        timeout01.attach_us(this, &DMX::int_timer, DMX_TIME_BETWEEN);
+    }
+}
+
+void DMX::stop () {
     dmx.attach(0, Serial::TxIrq);
     timeout01.detach();
-    mode_tx = DMX_MODE_BEGIN;
-//    mode_rx = DMX_MODE_BEGIN;
-//    is_recived = 0;
-    is_sent = 0;
-    timeout01.attach_us(this, &DMX::int_timer, DMX_TIME_BETWEEN);
+    mode_tx = DMX_MODE_STOP;
 }
--- a/DMX.h	Fri Sep 28 03:31:02 2012 +0000
+++ b/DMX.h	Wed Nov 21 01:44:21 2012 +0000
@@ -27,6 +27,7 @@
     DMX_MODE_MAB,
     DMX_MODE_DATA,
     DMX_MODE_ERROR,
+    DMX_MODE_STOP,
 };
 
 /** DMX512 class (sender/client)
@@ -51,7 +52,12 @@
      */
     int get (int ch);
 
-    void reset ();
+    /** Start DMX send
+     */
+    void start ();
+    /** Stop DMX send
+     */
+    void stop ();
 
     volatile int is_recived, is_sent;