Arduino DUE (SAM3X8E) DMX in and out deployed on hardware USART (updated DmxDue required)

This commit is contained in:
2018-01-21 03:43:08 +03:00
parent 97fbe269c9
commit 37b042e39e
4 changed files with 25 additions and 13 deletions

View File

@@ -21,9 +21,12 @@ e-mail anklimov@gmail.com
//#include <DmxSimple.h>
//#include <DMXSerial.h>
#include "options.h"
#ifdef _dmxin
#if defined(__AVR__)
#include <DMXSerial.h>
#endif
#endif
uint8_t * DMXin = NULL;
int D_State=0;
@@ -120,7 +123,7 @@ for (short tch=0; tch<=3 ; tch++)
bool updated = 0;
for (short trh=0; trh<4 ; trh++)
if ((t=DMXSerial.read(base+trh+1)) != DMXin[base+trh])
if ((t=dmxin.read(base+trh+1)) != DMXin[base+trh])
{
D_State |= (1<<tch);
updated=1;
@@ -166,7 +169,7 @@ D_checkT=0;
//int ch = 0;
DMXput();
#ifdef _dmxout
for (int i=1; i<17; i++) {Serial.print(DMXSerial.read(i));Serial.print(";");}
for (int i=1; i<17; i++) {Serial.print(dmxin.read(i));Serial.print(";");}
#endif
Serial.println();
#endif
@@ -189,14 +192,22 @@ void DMXinSetup(int channels)
// DmxSimple.usePin(pin);
//DmxSimple.maxChannel(channels);
#if defined(_dmxin)
#if defined(_dmxin)
DMXin = new uint8_t [channels];
#if defined(__AVR__)
DMXSerial.init(DMXReceiver,0,channels);
if (DMXSerial.getBuffer()) {Serial.print(F("Init in ch:"));Serial.println(channels);} else Serial.println(F("DMXin Buffer alloc err"));
//DMXSerial.maxChannel(channels);
DMXSerial.attachOnUpdate(&DMXUpdate);
#endif
#endif
#if defined(__SAM3X8E__)
dmxin.begin();
dmxin.setRxEvent(DMXUpdate);
#endif
#endif
#ifdef _artnet
// this will be called for each packet received
@@ -217,8 +228,8 @@ void DMXoutSetup(int channels,int pin)
#endif
#if defined(__SAM3X8E__)
dmxout.begin();
dmxout.setTxMaxChannels(channels);
dmxout.beginWrite();
#endif
#endif
}

View File

@@ -54,8 +54,10 @@ extern Artnet *artnet;
#endif
#ifdef _dmxin
#if defined(__AVR__)
#include <DMXSerial.h>
#endif
#endif
#include "aJSON.h"

View File

@@ -47,7 +47,6 @@ Relay DMX array channel
Config URL configuration
todo DUE related:
DMX in (new lib) - to do
HTTP
PWM freq fix
Config webserver
@@ -857,7 +856,7 @@ void setup() {
cmdInit(115200);
Serial.println(F("\nLazyhome.ru LightHub controller v0.95"));
Serial.println(F("\nLazyhome.ru LightHub controller v0.96"));
short macvalid=0;
byte defmac[6]={0xDE,0xAD,0xBE,0xEF,0xFE,0};
@@ -936,7 +935,7 @@ if (owReady && owArr) owLoop();
#endif
#ifdef _dmxin
unsigned long lastpacket = DMXSerial.noDataSince();
// unsigned long lastpacket = DMXSerial.noDataSince();
DMXCheck();
#endif
// if (lastpacket && (lastpacket%10==0)) Serial.println(lastpacket);

View File

@@ -9,13 +9,13 @@
#if defined(__AVR__)
//All options available
#define modbusSerial Serial2
#define dmxin DMXSerial
#define dmxout DmxSimple
#endif
#if defined(__SAM3X8E__)
/// DMX not deployed yet
#undef _dmxin
#define modbusSerial Serial2
#define dmxout DmxDue4
#define dmxout DmxDue1
#define dmxin DmxDue1
#endif