mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
DMX flickering bug fixed, RGB on PWM
This commit is contained in:
@@ -22,6 +22,7 @@ e-mail anklimov@gmail.com
|
||||
//#include <DMXSerial.h>
|
||||
#include "options.h"
|
||||
#include "item.h"
|
||||
#include "main.h"
|
||||
|
||||
#ifdef _dmxin
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
@@ -277,17 +278,17 @@ void DMXOUT_propagate()
|
||||
for(int i=1;i<=DMXOUT_Channels;i++)
|
||||
{
|
||||
uint8_t currLevel=dmxout.getTx(i);
|
||||
uint16_t delta = currLevel-DMXinterimBuf[i-1];
|
||||
int32_t delta = currLevel-DMXinterimBuf[i-1];
|
||||
if (delta)
|
||||
{
|
||||
uint16_t step = abs(delta) >> 4;
|
||||
if (!step) step=1;
|
||||
|
||||
if (delta<0)
|
||||
DmxWrite2(i,currLevel+step);
|
||||
{DmxWrite2(i,currLevel+step);debugSerial<<"<";}
|
||||
|
||||
if (delta>0)
|
||||
DmxWrite2(i,currLevel-step);
|
||||
{DmxWrite2(i,currLevel-step);debugSerial<<">";}
|
||||
}
|
||||
}
|
||||
checkTimestamp=now+DMX_SMOOTH_DELAY;
|
||||
|
||||
@@ -712,7 +712,7 @@ void ip_ready_config_loaded_connecting_to_broker() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mqttArr || (n = aJson.getArraySize(mqttArr) < 2)) //At least device name and broker IP must be configured
|
||||
if (!mqttArr || ((n = aJson.getArraySize(mqttArr)) < 2)) //At least device name and broker IP must be configured
|
||||
{
|
||||
lanStatus = READ_RE_CONFIG;
|
||||
return;
|
||||
@@ -721,7 +721,7 @@ void ip_ready_config_loaded_connecting_to_broker() {
|
||||
|
||||
deviceName = getStringFromConfig(mqttArr, 0);
|
||||
infoSerial<<F("Device Name:")<<deviceName<<endl;
|
||||
|
||||
debugSerial<<F("N:")<<n<<endl;
|
||||
|
||||
char *servername = getStringFromConfig(mqttArr, 1);
|
||||
if (n >= 3) port = aJson.getArrayItem(mqttArr, 2)->valueint;
|
||||
@@ -729,7 +729,7 @@ void ip_ready_config_loaded_connecting_to_broker() {
|
||||
if (!loadFlash(OFFSET_MQTT_PWD, passwordBuf, sizeof(passwordBuf)) && (n >= 5))
|
||||
{
|
||||
password = getStringFromConfig(mqttArr, 4);
|
||||
infoSerial<<F("Using MQTT password from config");
|
||||
infoSerial<<F("Using MQTT password from config")<<endl;
|
||||
}
|
||||
|
||||
mqttClient.setServer(servername, port);
|
||||
|
||||
@@ -358,8 +358,8 @@ if (store->pollingRegisters && !modbusBusy && (Status() == CST_INITIALIZED) && i
|
||||
debugSerial<<F("endPoll ")<< item->itemArr->name << endl;
|
||||
|
||||
//Non blocking waiting to release line
|
||||
uint32_t time = millis()+50;
|
||||
while (millis()<time)
|
||||
uint32_t time = millis();
|
||||
while (!isTimeOver(time,millis(),50))
|
||||
modbusIdle();
|
||||
|
||||
modbusBusy =0;
|
||||
|
||||
@@ -102,10 +102,14 @@ int out_pwm::getChanType()
|
||||
switch (numArgs)
|
||||
{
|
||||
case 3:
|
||||
debugSerial<<F("RGB PWM")<<endl;
|
||||
return CH_RGB;
|
||||
|
||||
case 4:
|
||||
debugSerial<<F("RGBW PWM")<<endl;
|
||||
return CH_RGBW;
|
||||
default:
|
||||
debugSerial<<item->itemType<<F(" PWM")<<endl;
|
||||
return item->itemType;
|
||||
}
|
||||
}
|
||||
@@ -118,6 +122,7 @@ if (!item || !iaddr || !show) return 0;
|
||||
|
||||
bool inverse = (item->getArg()<0);
|
||||
short cType = getChanType();
|
||||
uint8_t storageType;
|
||||
|
||||
switch (cmd.getCmd()){
|
||||
case CMD_OFF:
|
||||
@@ -125,14 +130,27 @@ switch (cmd.getCmd()){
|
||||
break;
|
||||
}
|
||||
|
||||
if (cType=CH_PWM)
|
||||
|
||||
switch (cType)
|
||||
{
|
||||
case CH_PWM:
|
||||
{ short k;
|
||||
analogWrite(iaddr, k=cmd.getPercents255(inverse));
|
||||
debugSerial<<F("Pin:")<<iaddr<<F("=")<<k<<endl;
|
||||
return 1;
|
||||
}
|
||||
case CH_RGB:
|
||||
storageType=ST_RGB;
|
||||
break;
|
||||
case CH_RGBW:
|
||||
storageType=ST_RGBW;
|
||||
break;
|
||||
default:
|
||||
storageType=ST_PERCENTS;
|
||||
}
|
||||
|
||||
itemCmd st(storageType,CMD_VOID);
|
||||
|
||||
itemCmd st(ST_RGB,CMD_VOID);
|
||||
st.assignFrom(cmd);
|
||||
|
||||
switch (cType)
|
||||
|
||||
Reference in New Issue
Block a user