mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 19:59:50 +03:00
Arduino DUE (SAM3X8E) DMX in and out deployed on hardware USART (updated DmxDue required)
This commit is contained in:
@@ -21,9 +21,12 @@ e-mail anklimov@gmail.com
|
|||||||
//#include <DmxSimple.h>
|
//#include <DmxSimple.h>
|
||||||
//#include <DMXSerial.h>
|
//#include <DMXSerial.h>
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
#ifdef _dmxin
|
#ifdef _dmxin
|
||||||
|
#if defined(__AVR__)
|
||||||
#include <DMXSerial.h>
|
#include <DMXSerial.h>
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
uint8_t * DMXin = NULL;
|
uint8_t * DMXin = NULL;
|
||||||
int D_State=0;
|
int D_State=0;
|
||||||
@@ -120,7 +123,7 @@ for (short tch=0; tch<=3 ; tch++)
|
|||||||
bool updated = 0;
|
bool updated = 0;
|
||||||
|
|
||||||
for (short trh=0; trh<4 ; trh++)
|
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);
|
D_State |= (1<<tch);
|
||||||
updated=1;
|
updated=1;
|
||||||
@@ -166,7 +169,7 @@ D_checkT=0;
|
|||||||
//int ch = 0;
|
//int ch = 0;
|
||||||
DMXput();
|
DMXput();
|
||||||
#ifdef _dmxout
|
#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
|
#endif
|
||||||
Serial.println();
|
Serial.println();
|
||||||
#endif
|
#endif
|
||||||
@@ -189,14 +192,22 @@ void DMXinSetup(int channels)
|
|||||||
// DmxSimple.usePin(pin);
|
// DmxSimple.usePin(pin);
|
||||||
//DmxSimple.maxChannel(channels);
|
//DmxSimple.maxChannel(channels);
|
||||||
|
|
||||||
#if defined(_dmxin)
|
#if defined(_dmxin)
|
||||||
DMXin = new uint8_t [channels];
|
DMXin = new uint8_t [channels];
|
||||||
|
#if defined(__AVR__)
|
||||||
DMXSerial.init(DMXReceiver,0,channels);
|
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"));
|
if (DMXSerial.getBuffer()) {Serial.print(F("Init in ch:"));Serial.println(channels);} else Serial.println(F("DMXin Buffer alloc err"));
|
||||||
//DMXSerial.maxChannel(channels);
|
//DMXSerial.maxChannel(channels);
|
||||||
DMXSerial.attachOnUpdate(&DMXUpdate);
|
DMXSerial.attachOnUpdate(&DMXUpdate);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__SAM3X8E__)
|
||||||
|
dmxin.begin();
|
||||||
|
dmxin.setRxEvent(DMXUpdate);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _artnet
|
#ifdef _artnet
|
||||||
// this will be called for each packet received
|
// this will be called for each packet received
|
||||||
@@ -217,8 +228,8 @@ void DMXoutSetup(int channels,int pin)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__SAM3X8E__)
|
#if defined(__SAM3X8E__)
|
||||||
|
dmxout.begin();
|
||||||
dmxout.setTxMaxChannels(channels);
|
dmxout.setTxMaxChannels(channels);
|
||||||
dmxout.beginWrite();
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,8 +54,10 @@ extern Artnet *artnet;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _dmxin
|
#ifdef _dmxin
|
||||||
|
#if defined(__AVR__)
|
||||||
#include <DMXSerial.h>
|
#include <DMXSerial.h>
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "aJSON.h"
|
#include "aJSON.h"
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ Relay DMX array channel
|
|||||||
Config URL configuration
|
Config URL configuration
|
||||||
|
|
||||||
todo DUE related:
|
todo DUE related:
|
||||||
DMX in (new lib) - to do
|
|
||||||
HTTP
|
HTTP
|
||||||
PWM freq fix
|
PWM freq fix
|
||||||
Config webserver
|
Config webserver
|
||||||
@@ -857,7 +856,7 @@ void setup() {
|
|||||||
|
|
||||||
cmdInit(115200);
|
cmdInit(115200);
|
||||||
|
|
||||||
Serial.println(F("\nLazyhome.ru LightHub controller v0.95"));
|
Serial.println(F("\nLazyhome.ru LightHub controller v0.96"));
|
||||||
|
|
||||||
short macvalid=0;
|
short macvalid=0;
|
||||||
byte defmac[6]={0xDE,0xAD,0xBE,0xEF,0xFE,0};
|
byte defmac[6]={0xDE,0xAD,0xBE,0xEF,0xFE,0};
|
||||||
@@ -936,7 +935,7 @@ if (owReady && owArr) owLoop();
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _dmxin
|
#ifdef _dmxin
|
||||||
unsigned long lastpacket = DMXSerial.noDataSince();
|
// unsigned long lastpacket = DMXSerial.noDataSince();
|
||||||
DMXCheck();
|
DMXCheck();
|
||||||
#endif
|
#endif
|
||||||
// if (lastpacket && (lastpacket%10==0)) Serial.println(lastpacket);
|
// if (lastpacket && (lastpacket%10==0)) Serial.println(lastpacket);
|
||||||
|
|||||||
@@ -9,13 +9,13 @@
|
|||||||
#if defined(__AVR__)
|
#if defined(__AVR__)
|
||||||
//All options available
|
//All options available
|
||||||
#define modbusSerial Serial2
|
#define modbusSerial Serial2
|
||||||
|
#define dmxin DMXSerial
|
||||||
|
#define dmxout DmxSimple
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__SAM3X8E__)
|
#if defined(__SAM3X8E__)
|
||||||
/// DMX not deployed yet
|
|
||||||
#undef _dmxin
|
|
||||||
#define modbusSerial Serial2
|
#define modbusSerial Serial2
|
||||||
#define dmxout DmxDue4
|
#define dmxout DmxDue1
|
||||||
#define dmxin DmxDue1
|
#define dmxin DmxDue1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user