mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
Critical potential memory violation fixed. Ventilation set termopreset and overheat control fixed
This commit is contained in:
@@ -20,6 +20,7 @@ e-mail anklimov@gmail.com
|
|||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "aJSON.h"
|
#include "aJSON.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#ifdef _dmxout
|
#ifdef _dmxout
|
||||||
|
|
||||||
@@ -197,21 +198,18 @@ boolean Item::getEnableCMD(int delta) {
|
|||||||
return ((millis() - lastctrl > (unsigned long) delta));// || ((void *)itemArr != (void *) lastobj));
|
return ((millis() - lastctrl > (unsigned long) delta));// || ((void *)itemArr != (void *) lastobj));
|
||||||
}
|
}
|
||||||
|
|
||||||
int Item::Ctrl(short cmd, short n, int *Par, boolean send) {
|
#define MAXCTRLPAR 3
|
||||||
|
int Item::Ctrl(short cmd, short n, int *Parameters, boolean send) {
|
||||||
|
|
||||||
Serial.print(F("Cmd="));
|
|
||||||
Serial.println(cmd);
|
|
||||||
//va_list vl;
|
|
||||||
|
|
||||||
int _Par[3] = {0, 0, 0};
|
Serial.print(F("Cmd="));Serial.print(cmd);Serial.print(F(" MEM="));Serial.println(freeRam());
|
||||||
if (Par == NULL) Par = _Par;
|
|
||||||
|
int Par[MAXCTRLPAR] = {0, 0, 0};
|
||||||
|
if (Parameters)
|
||||||
|
for (short i=0;i<n && i<MAXCTRLPAR;i++) Par[i] = Parameters[i];
|
||||||
|
|
||||||
int iaddr = getArg();
|
int iaddr = getArg();
|
||||||
HSVstore st;
|
HSVstore st;
|
||||||
//Store Parameter(s) into json VAL
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
int t;
|
int t;
|
||||||
case CMD_TOGGLE:
|
case CMD_TOGGLE:
|
||||||
@@ -254,9 +252,9 @@ int Item::Ctrl(short cmd, short n, int *Par, boolean send) {
|
|||||||
case CH_VC:
|
case CH_VC:
|
||||||
case CH_DIMMER:
|
case CH_DIMMER:
|
||||||
case CH_MODBUS:
|
case CH_MODBUS:
|
||||||
|
case CH_VCTEMP:
|
||||||
if (send) SendStatus(0, 1, Par,true); // Send back parameter for channel above this line
|
if (send) SendStatus(0, 1, Par,true); // Send back parameter for channel above this line
|
||||||
case CH_THERMO:
|
case CH_THERMO:
|
||||||
case CH_VCTEMP:
|
|
||||||
setVal(Par[0]); // Store value
|
setVal(Par[0]); // Store value
|
||||||
|
|
||||||
}//itemtype
|
}//itemtype
|
||||||
@@ -269,6 +267,7 @@ int Item::Ctrl(short cmd, short n, int *Par, boolean send) {
|
|||||||
case CMD_ON:
|
case CMD_ON:
|
||||||
if (itemType!=CH_RGBW || getCmd() != CMD_ON) {
|
if (itemType!=CH_RGBW || getCmd() != CMD_ON) {
|
||||||
short params = 0;
|
short params = 0;
|
||||||
|
setCmd(cmd);
|
||||||
//retrive stored values
|
//retrive stored values
|
||||||
st.aslong = getVal();
|
st.aslong = getVal();
|
||||||
if (st.aslong > 0) //Stored smthng
|
if (st.aslong > 0) //Stored smthng
|
||||||
@@ -311,25 +310,31 @@ int Item::Ctrl(short cmd, short n, int *Par, boolean send) {
|
|||||||
|
|
||||||
switch (itemType) {
|
switch (itemType) {
|
||||||
case CH_VCTEMP:
|
case CH_VCTEMP:
|
||||||
Par[0] = 20;
|
case CH_THERMO:
|
||||||
|
Par[0] = 20; //20 degrees celsium - safe temperature
|
||||||
|
params = 1;
|
||||||
|
SendStatus(0, params, Par);
|
||||||
break;
|
break;
|
||||||
default:
|
case CH_RGBW:
|
||||||
|
case CH_RGB:
|
||||||
Par[0] = 100;
|
Par[0] = 100;
|
||||||
Par[1] = 0;
|
Par[1] = 0;
|
||||||
Par[2] = 100;
|
Par[2] = 100;
|
||||||
|
params = 3;
|
||||||
|
SendStatus(0, params, Par,true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Par[0] = 100;
|
||||||
|
params = 1;
|
||||||
|
SendStatus(0, params, Par);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (short i = 0; i < params; i++) {
|
for (short i = 0; i < params; i++) {
|
||||||
Serial.print(F("Restored: "));
|
Serial.print(F("Restored: "));
|
||||||
Serial.print(i);
|
Serial.print(i);
|
||||||
Serial.print(F("="));
|
Serial.print(F("="));
|
||||||
Serial.println(Par[i]);
|
Serial.println(Par[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (send) setCmd(cmd);
|
|
||||||
} else { //Double ON - apply special preset - clean white full power
|
} else { //Double ON - apply special preset - clean white full power
|
||||||
if (getEnableCMD(500)) switch (itemType) {
|
if (getEnableCMD(500)) switch (itemType) {
|
||||||
case CH_RGBW:
|
case CH_RGBW:
|
||||||
@@ -730,7 +735,7 @@ int Item::VacomSetHeat(int addr, int8_t val, int8_t cmd) {
|
|||||||
regval = round(((float) val - b) * 10 / a);
|
regval = round(((float) val - b) * 10 / a);
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println(regval);
|
//Serial.println(regval);
|
||||||
node.writeSingleRegister(2004 - 1, regval);
|
node.writeSingleRegister(2004 - 1, regval);
|
||||||
modbusBusy = 0;
|
modbusBusy = 0;
|
||||||
}
|
}
|
||||||
@@ -913,7 +918,7 @@ int Item::checkFM() {
|
|||||||
int pwr = node.getResponseBuffer(3);
|
int pwr = node.getResponseBuffer(3);
|
||||||
if (pwr > 0) aJson.addNumberToObject(out, "pwr", pwr / 10.); else aJson.addNumberToObject(out, "pwr", 0);
|
if (pwr > 0) aJson.addNumberToObject(out, "pwr", pwr / 10.); else aJson.addNumberToObject(out, "pwr", 0);
|
||||||
|
|
||||||
if (ftemp>fset+FM_OVERHEAT_CELSIUS)
|
if (ftemp>fset+FM_OVERHEAT_CELSIUS && set)
|
||||||
{
|
{
|
||||||
mqttClient.publish("/alarm/ovrht", itemArr->name);
|
mqttClient.publish("/alarm/ovrht", itemArr->name);
|
||||||
Ctrl(CMD_OFF); //Shut down
|
Ctrl(CMD_OFF); //Shut down
|
||||||
@@ -1025,12 +1030,15 @@ int Item::Poll() {
|
|||||||
break;
|
break;
|
||||||
case CH_VC:
|
case CH_VC:
|
||||||
checkFM();
|
checkFM();
|
||||||
|
sendDelayedStatus();
|
||||||
return INTERVAL_CHECK_MODBUS;
|
return INTERVAL_CHECK_MODBUS;
|
||||||
break;
|
break;
|
||||||
case CH_RGB: //All channels with slider generate too many updates
|
case CH_RGB: //All channels with slider generate too many updates
|
||||||
case CH_RGBW:
|
case CH_RGBW:
|
||||||
case CH_DIMMER:
|
case CH_DIMMER:
|
||||||
case CH_PWM:
|
case CH_PWM:
|
||||||
|
case CH_VCTEMP:
|
||||||
|
case CH_THERMO:
|
||||||
sendDelayedStatus();
|
sendDelayedStatus();
|
||||||
}
|
}
|
||||||
return INTERVAL_POLLING;
|
return INTERVAL_POLLING;
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class Item
|
|||||||
Item(char * name);
|
Item(char * name);
|
||||||
Item(aJsonObject * obj);
|
Item(aJsonObject * obj);
|
||||||
boolean isValid ();
|
boolean isValid ();
|
||||||
virtual int Ctrl(short cmd, short n=0, int * Par=NULL, boolean send=true);
|
virtual int Ctrl(short cmd, short n=0, int * Parameters=NULL, boolean send=true);
|
||||||
int getArg(short n=0);
|
int getArg(short n=0);
|
||||||
boolean getEnableCMD(int delta);
|
boolean getEnableCMD(int delta);
|
||||||
//int getVal(short n); //From VAL array. Negative if no array
|
//int getVal(short n); //From VAL array. Negative if no array
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/* 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");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
@@ -33,27 +34,35 @@ e-mail anklimov@gmail.com
|
|||||||
* 1-w relay out
|
* 1-w relay out
|
||||||
* Termostat out
|
* Termostat out
|
||||||
|
|
||||||
Todo
|
Todo (backlog)
|
||||||
===
|
===
|
||||||
A/C control/Dimmer ?
|
rotary encoder local ctrl ?
|
||||||
rotary encoder local ctrl
|
|
||||||
analog in local ctrl
|
analog in local ctrl
|
||||||
Smooth regulation/fading
|
Smooth regulation/fading
|
||||||
PID Termostat out
|
PID Termostat out ?
|
||||||
dmx relay out
|
dmx relay out
|
||||||
Relay array channel
|
Relay array channel
|
||||||
Relay DMX array channel
|
Relay DMX array channel
|
||||||
Config URL configuration
|
Config URL & MQTT password commandline configuration
|
||||||
|
1-wire Update refactoring (save memory)
|
||||||
|
Static IP
|
||||||
|
Topic configuration
|
||||||
|
Timer
|
||||||
|
Modbus response check
|
||||||
|
control/debug (Commandline) over MQTT
|
||||||
|
more Modbus dimmers
|
||||||
|
|
||||||
todo DUE related:
|
todo DUE related:
|
||||||
HTTP
|
|
||||||
PWM freq fix
|
PWM freq fix
|
||||||
Config webserver
|
Config webserver
|
||||||
|
SSL
|
||||||
|
|
||||||
todo ESP:
|
todo ESP:
|
||||||
Ethernet - to wifi portation
|
|
||||||
DMX-OUT deploy on USART1
|
|
||||||
Config webserver
|
Config webserver
|
||||||
|
SSL
|
||||||
|
|
||||||
|
ESP32
|
||||||
|
PWM Out
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Configuration of drivers enabled
|
// Configuration of drivers enabled
|
||||||
#ifndef PIO_SRC_REV
|
#ifndef PIO_SRC_REV
|
||||||
#define PIO_SRC_REV v0.993
|
#define PIO_SRC_REV v0.994
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TXEnablePin 13
|
#define TXEnablePin 13
|
||||||
|
|||||||
Reference in New Issue
Block a user