easier to disable PID_USE_TIMPROP

This commit is contained in:
Barbudor 2021-09-25 17:20:36 +00:00
parent 1a53f9a757
commit 7c8d966206
3 changed files with 20 additions and 16 deletions

View File

@ -160,7 +160,7 @@ String EthernetMacAddress(void);
* Fallback parameters * Fallback parameters
\*********************************************************************************************/ \*********************************************************************************************/
#ifdef USE_PID #if defined(USE_PID) && (!defined(PID_USE_TIMPROP) || (PID_USE_TIMPROP > 0))
#define USE_TIMEPROP #define USE_TIMEPROP
#endif #endif
// See https://github.com/esp8266/Arduino/pull/4889 // See https://github.com/esp8266/Arduino/pull/4889

View File

@ -93,11 +93,6 @@
enum TimepropCommands { CMND_TIMEPROP_SETPOWER }; enum TimepropCommands { CMND_TIMEPROP_SETPOWER };
const char kTimepropCommands[] PROGMEM = D_CMND_TIMEPROP_SETPOWER; const char kTimepropCommands[] PROGMEM = D_CMND_TIMEPROP_SETPOWER;
static Timeprop timeprops[TIMEPROP_NUM_OUTPUTS];
static int relayNos[TIMEPROP_NUM_OUTPUTS] = {TIMEPROP_RELAYS};
static long currentRelayStates = 0; // current actual relay states. Bit 0 first relay
#ifndef TIMEPROP_NUM_OUTPUTS #ifndef TIMEPROP_NUM_OUTPUTS
#define TIMEPROP_NUM_OUTPUTS 1 // how many outputs to control (with separate alogorithm for each) #define TIMEPROP_NUM_OUTPUTS 1 // how many outputs to control (with separate alogorithm for each)
#endif #endif
@ -120,6 +115,10 @@ static long currentRelayStates = 0; // current actual relay states. Bit 0 first
#define TIMEPROP_RELAYS 1 // which relay to control 1:8 #define TIMEPROP_RELAYS 1 // which relay to control 1:8
#endif #endif
static Timeprop timeprops[TIMEPROP_NUM_OUTPUTS];
static int relayNos[TIMEPROP_NUM_OUTPUTS] = {TIMEPROP_RELAYS};
static long currentRelayStates = 0; // current actual relay states. Bit 0 first relay
struct { struct {
Timeprop timeprops[TIMEPROP_NUM_OUTPUTS]; Timeprop timeprops[TIMEPROP_NUM_OUTPUTS];
int relay_nos[TIMEPROP_NUM_OUTPUTS] = {TIMEPROP_RELAYS}; int relay_nos[TIMEPROP_NUM_OUTPUTS] = {TIMEPROP_RELAYS};

View File

@ -103,20 +103,21 @@
#define PID_USE_TIMPROP 1 // To use an internal relay for a time proportioned output to drive the #define PID_USE_TIMPROP 1 // To use an internal relay for a time proportioned output to drive the
// process, set this to indicate which timeprop output to use. For a device // process, set this to indicate which timeprop output to use. For a device
// with just one relay then this will be 1. // with just one relay then this will be 1.
// It is then also necessary to define USE_TIMEPROP and set the output up as // USE_TIMEPROP will be automativally included. You must set the output as
// explained in xdrv_49_timeprop.ino // explained in xdrv_48_timeprop.ino
// To disable this feature leave this undefined (undefined, not defined to nothing). // To disable, override to false in user_config_override.h. If USE_TIMEPROP is
// not explicitly defined, then it will not be added by default.
#define PID_USE_LOCAL_SENSOR // If defined then the local sensor will be used for pv. Leave undefined if #define PID_USE_LOCAL_SENSOR // If defined then the local sensor will be used for pv. Leave undefined if
// this is not required. The rate that the sensor is read is defined by TELE_PERIOD // this is not required. The rate that the sensor is read is defined by TELE_PERIOD
// If not using the sensor then you can supply process values via MQTT using // If not using the sensor then you can supply process values via MQTT using
// cmnd PidPv // cmnd PidPv
#define PID_SHUTTER 1 // if using the PID to control a 3-way valve, create Tasmota Shutter and define the #define PID_SHUTTER 1 // if using the PID to control a 3-way valve, create Tasmota Shutter and define the
// number of the shutter here. Otherwise leave this commented out // number of the shutter here. Otherwise leave this commented out
#define PID_REPORT_MORE_SETTINGS // If defined, the SENSOR output will provide more extensive json #define PID_REPORT_MORE_SETTINGS true // If defined to true, the SENSOR output will provide more extensive json
// output in the PID section // output in the PID section. Override to false to reduce json output
* Help with using the PID algorithm and with loop tuning can be found at * Help with using the PID algorithm and with loop tuning can be found at
* http://blog.clanlaw.org.uk/2018/01/09/PID-tuning-with-node-red-contrib-pid.html * http://blog.clanlaw.org.uk/2018/01/09/PID-tuning-with-node-red-contrib-pid.html
@ -155,10 +156,14 @@
#define PID_UPDATE_SECS 0 // [PidUpdateSecs] How often to run the pid algorithm #define PID_UPDATE_SECS 0 // [PidUpdateSecs] How often to run the pid algorithm
#endif #endif
#define PID_USE_TIMPROP 1 // To disable this feature leave this undefined #ifndef PID_USE_TIMPROP
#define PID_USE_TIMPROP 1 // To disable this feature define as false in user_config_override
#endif
//#define PID_USE_LOCAL_SENSOR // [PidPv] If defined then the local sensor will be used for pv. //#define PID_USE_LOCAL_SENSOR // [PidPv] If defined then the local sensor will be used for pv.
//#define PID_SHUTTER 1 // Number of the shutter here. Otherwise leave this commented out //#define PID_SHUTTER 1 // Number of the shutter here. Otherwise leave this commented out
#define PID_REPORT_MORE_SETTINGS // If defined, the SENSOR output will provide more extensive json #ifndef PID_REPORT_MORE_SETTINGS
#define PID_REPORT_MORE_SETTINGS true // Override to false if less details are required in SENSOR JSON
#endif
#include "PID.h" #include "PID.h"
@ -342,7 +347,7 @@ void PIDShowValues(void) {
dtostrfd(d_buf, 2, str_buf); dtostrfd(d_buf, 2, str_buf);
ResponseAppend_P(PSTR("\"PidSp\":%s,"), str_buf); ResponseAppend_P(PSTR("\"PidSp\":%s,"), str_buf);
#ifdef PID_REPORT_MORE_SETTINGS #if PID_REPORT_MORE_SETTINGS
// #define D_CMND_PID_SETPROPBAND "Pb" // #define D_CMND_PID_SETPROPBAND "Pb"
d_buf = Pid.pid.getPb(); d_buf = Pid.pid.getPb();
dtostrfd(d_buf, 2, str_buf); dtostrfd(d_buf, 2, str_buf);
@ -403,7 +408,7 @@ void PIDRun(void) {
ShutterSetPosition(PID_SHUTTER, pos); ShutterSetPosition(PID_SHUTTER, pos);
#endif //PID_SHUTTER #endif //PID_SHUTTER
#if defined PID_USE_TIMPROP #if defined(PID_USE_TIMPROP) && (PID_USE_TIMPROP > 0)
// send power to appropriate timeprop output // send power to appropriate timeprop output
TimepropSetPower( PID_USE_TIMPROP-1, power ); TimepropSetPower( PID_USE_TIMPROP-1, power );
#endif // PID_USE_TIMPROP #endif // PID_USE_TIMPROP