DUE DMX-IN fix

This commit is contained in:
2018-04-17 23:24:29 +03:00
parent 4f340d780f
commit 3a66d916dd
2 changed files with 58 additions and 50 deletions

View File

@@ -49,6 +49,7 @@ extern aJsonObject *dmxArr;
int itemCtrl2(char* name,int r,int g, int b, int w) int itemCtrl2(char* name,int r,int g, int b, int w)
{ {
if (!items) return 0;
aJsonObject *itemArr= aJson.getObjectItem(items, name); aJsonObject *itemArr= aJson.getObjectItem(items, name);
if (itemArr && (itemArr->type==aJson_Array)) if (itemArr && (itemArr->type==aJson_Array))
@@ -88,6 +89,7 @@ int itemCtrl2(char* name,int r,int g, int b, int w)
} //itemtype } //itemtype
// break; // break;
} //if have correct array } //if have correct array
return 1;
} }
@@ -97,7 +99,7 @@ void DMXImmediateUpdate(short tch,short r, short g, short b, short w) {
{ {
char* itemname = aJson.getArrayItem(dmxArr,tch)->valuestring; char* itemname = aJson.getArrayItem(dmxArr,tch)->valuestring;
itemCtrl2(itemname,r,g,b,w); if (itemname) itemCtrl2(itemname,r,g,b,w);
} }
} }
@@ -121,6 +123,10 @@ void DMXUpdate(void)
{ {
#if defined(_dmxin) #if defined(_dmxin)
int t; int t;
if(!DMXin) return;
#if defined(__SAM3X8E__)
if (dmxin.getRxLength()<16) return;
#endif
for (short tch=0; tch<=3 ; tch++) for (short tch=0; tch<=3 ; tch++)
{ {
short base = tch*4; short base = tch*4;
@@ -207,9 +213,8 @@ void DMXinSetup(int channels)
#endif #endif
#if defined(__SAM3X8E__) #if defined(__SAM3X8E__)
dmxin.begin();
dmxin.setRxEvent(DMXUpdate); dmxin.setRxEvent(DMXUpdate);
dmxin.begin();
#endif #endif
#endif #endif

View File

@@ -1,3 +1,8 @@
/* Copyright © 2017-2018 Andrey Klimov. All rights reserved. /* Copyright © 2017-2018 Andrey Klimov. All rights reserved.
* *
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
@@ -550,7 +555,6 @@ void applyConfig() {
Serial.println(maxChannels); Serial.println(maxChannels);
} }
#endif #endif
#ifdef _dmxin #ifdef _dmxin
int itemsCount; int itemsCount;
dmxArr = aJson.getObjectItem(root, "dmxin"); dmxArr = aJson.getObjectItem(root, "dmxin");
@@ -560,7 +564,6 @@ void applyConfig() {
Serial.println(itemsCount * 4); Serial.println(itemsCount * 4);
} }
#endif #endif
#ifdef _modbus #ifdef _modbus
modbusArr = aJson.getObjectItem(root, "modbus"); modbusArr = aJson.getObjectItem(root, "modbus");
#endif #endif