Many portation and conditional compilation directives added, Modbus refactored and moved to almost original lib, MQTT server,port,user,password configuration added to JSON

This commit is contained in:
2018-01-15 02:02:52 +03:00
parent d99c9948c9
commit 0553b1724f
14 changed files with 4311 additions and 3843 deletions

48
dmx.cpp
View File

@@ -19,14 +19,22 @@ e-mail anklimov@gmail.com
*/
#include "dmx.h"
//#include <DmxSimple.h>
//#include <Artnet.h>
//#include <DMXSerial.h>
#include "options.h"
#ifdef _dmxin
#include <DMXSerial.h>
#endif
uint8_t * DMXin = NULL;
int D_State=0;
unsigned long D_checkT=0;
#ifdef _artnet
#include <Artnet.h>
Artnet *artnet = NULL;
#endif
aJsonObject *dmxArr = NULL;
void DMXImmediateUpdate(short tch,short r, short g, short b, short w) {
@@ -57,7 +65,7 @@ for (short tch=0; tch<=3 ; tch++)
void DMXUpdate(void)
{
#if defined(__AVR_ATmega2560__)
#if defined(_dmxin)
int t;
for (short tch=0; tch<=3 ; tch++)
{
@@ -90,7 +98,7 @@ for (short tch=0; tch<=3 ; tch++)
{
// CHSV hsv;
// CRGB rgb;
#if defined(__AVR_ATmega2560__)
#if defined(_dmxin)
short t,tch;
//Here code for semi-immediate update
@@ -110,7 +118,9 @@ D_checkT=0;
// Here code for network update
//int ch = 0;
DMXput();
#ifdef _dmxout
for (int i=1; i<17; i++) {Serial.print(DMXSerial.read(i));Serial.print(";");}
#endif
Serial.println();
#endif
}
@@ -118,10 +128,12 @@ for (int i=1; i<17; i++) {Serial.print(DMXSerial.read(i));Serial.print(";");}
void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data)
{
#ifdef _dmxout
for (int i = 0 ; i < length && i<MAX_CHANNELS ; i++)
{
DmxSimple.write(i+1,data[i]);
DmxWrite(i+1,data[i]);
}
#endif
}
void DMXinSetup(int channels)
@@ -129,8 +141,8 @@ void DMXinSetup(int channels)
// //Use digital pin 3 for DMX output. Must be a PWM channel.
// DmxSimple.usePin(pin);
//DmxSimple.maxChannel(channels);
#if defined(__AVR_ATmega2560__)
#if defined(_dmxin)
DMXin = new uint8_t [channels];
DMXSerial.init(DMXReceiver,0,channels);
@@ -138,13 +150,37 @@ void DMXinSetup(int channels)
//DMXSerial.maxChannel(channels);
DMXSerial.attachOnUpdate(&DMXUpdate);
#endif
#ifdef _artnet
// this will be called for each packet received
if (artnet) artnet->setArtDmxCallback(onDmxFrame);
#endif
}
void DMXoutSetup(int channels,int pin)
{
#ifdef _dmxout
#if defined(__AVR__)
DmxSimple.usePin(pin);
DmxSimple.maxChannel(channels);
#endif
#if defined(__ESP__)
#endif
#if defined(__SAM3X8E__)
dmxout.setTxMaxChannels(channels);
dmxout.beginWrite();
#endif
#endif
}
void ArtnetSetup()
{
#ifdef _artnet
if (!artnet) artnet = new Artnet;
// this will be called for each packet received
if (artnet) artnet->setArtDmxCallback(onDmxFrame);
#endif
}