| "));
+ addButton(F("'control?cmd=chimeplay,hours'"), F("Test 1…12"));
+
+ if (PCONFIG(2) && !(Settings.UseNTP())) {
+ addFormNote(F("Enable and configure NTP!"));
}
+ success = true;
+ break;
+ }
+
case PLUGIN_WEBFORM_SAVE:
- {
- Settings.TaskDevicePin[3][event->TaskIndex] = (int8_t)getFormItemInt(F("TDP4"));
+ {
+ Settings.TaskDevicePin[3][event->TaskIndex] = (int8_t)getFormItemInt(F("TDP4"));
- PCONFIG(0) = getFormItemInt(F("chimetime"));
- PCONFIG(1) = getFormItemInt(F("pausetime"));
- PCONFIG(2) = isFormItemChecked(F("chimeclock"));
+ PCONFIG(0) = getFormItemInt(F("chimetime"));
+ PCONFIG(1) = getFormItemInt(F("pausetime"));
+ PCONFIG(2) = isFormItemChecked(F("chimeclock"));
- success = true;
- break;
- }
+ success = true;
+ break;
+ }
case PLUGIN_INIT:
- {
- if (!Plugin_055_Data)
- Plugin_055_Data = new (std::nothrow) CPlugin_055_Data();
+ {
+ if (!Plugin_055_Data) {
+ Plugin_055_Data = new (std::nothrow) CPlugin_055_Data();
+ }
- if (Plugin_055_Data != nullptr) {
- Plugin_055_Data->lowActive = Settings.TaskDevicePin1Inversed[event->TaskIndex];
- Plugin_055_Data->millisChimeTime = PCONFIG(0);
- Plugin_055_Data->millisPauseTime = PCONFIG(1);
- Plugin_055_Data->chimeClock = PCONFIG(2);
+ if (Plugin_055_Data != nullptr) {
+ Plugin_055_Data->lowActive = Settings.TaskDevicePin1Inversed[event->TaskIndex];
+ Plugin_055_Data->millisChimeTime = PCONFIG(0);
+ Plugin_055_Data->millisPauseTime = PCONFIG(1);
+ Plugin_055_Data->chimeClock = PCONFIG(2);
- String log = F("Chime: GPIO: ");
- for (uint8_t i = 0; i < 4; ++i)
+ String log = F("Chime: GPIO: ");
+
+ for (uint8_t i = 0; i < 4; ++i)
+ {
+ int pin = Settings.TaskDevicePin[i][event->TaskIndex];
+ Plugin_055_Data->pin[i] = pin;
+
+ if (pin >= 0)
{
- int pin = Settings.TaskDevicePin[i][event->TaskIndex];
- Plugin_055_Data->pin[i] = pin;
- if (pin >= 0)
- {
- pinMode(pin, OUTPUT);
- digitalWrite(pin, Plugin_055_Data->lowActive);
- }
- log += pin;
- log += ' ';
+ pinMode(pin, OUTPUT);
+ digitalWrite(pin, Plugin_055_Data->lowActive);
}
- if (Plugin_055_Data->lowActive)
- log += F("!");
- addLogMove(LOG_LEVEL_INFO, log);
- success = true;
+ log += pin;
+ log += ' ';
}
- break;
+ if (Plugin_055_Data->lowActive) {
+ log += F("!");
+ }
+ addLogMove(LOG_LEVEL_INFO, log);
+ success = true;
}
+ break;
+ }
+
case PLUGIN_EXIT:
- {
- if (Plugin_055_Data != nullptr) {
- delete Plugin_055_Data;
- Plugin_055_Data = nullptr;
- }
- break;
+ {
+ if (Plugin_055_Data != nullptr) {
+ delete Plugin_055_Data;
+ Plugin_055_Data = nullptr;
}
+ break;
+ }
case PLUGIN_WRITE:
- {
- if (!Plugin_055_Data)
- break;
+ {
+ if (!Plugin_055_Data) {
+ break;
+ }
- String command = parseString(string, 1);
+ String command = parseString(string, 1);
- if (equals(command, F("chime")))
- {
- String param = parseStringToEndKeepCase(string, 2);
- if (param.length() > 0) {
- Plugin_055_AddStringFIFO(param);
- }
- success = true;
+ if (equals(command, F("chime")))
+ {
+ String param = parseStringToEndKeepCase(string, 2);
+
+ if (param.length() > 0) {
+ Plugin_055_AddStringFIFO(param);
}
- if (equals(command, F("chimeplay")))
- {
- String name = parseString(string, 2);
- if (name.length() > 0) {
- String param;
- Plugin_055_ReadChime(name, param);
- Plugin_055_AddStringFIFO(param);
- }
- success = true;
+ success = true;
+ }
+
+ if (equals(command, F("chimeplay")))
+ {
+ String name = parseString(string, 2);
+
+ if (name.length() > 0) {
+ String param;
+ Plugin_055_ReadChime(name, param);
+ Plugin_055_AddStringFIFO(param);
}
- if (equals(command, F("chimesave")))
- {
- String name = parseString(string, 2);
- String param = parseStringToEndKeepCase(string, 3);
- if (name.length() > 0 && param.length() > 0) {
- Plugin_055_WriteChime(name, param);
- Plugin_055_AddStringFIFO("1");
- }
- success = true;
+ success = true;
+ }
+
+ if (equals(command, F("chimesave")))
+ {
+ String name = parseString(string, 2);
+ String param = parseStringToEndKeepCase(string, 3);
+
+ if ((name.length() > 0) && (param.length() > 0)) {
+ Plugin_055_WriteChime(name, param);
+ Plugin_055_AddStringFIFO("1");
}
+ success = true;
+ }
+ break;
+ }
+
+ case PLUGIN_CLOCK_IN:
+ {
+ if (!Plugin_055_Data) {
break;
}
- case PLUGIN_CLOCK_IN:
- {
- if (!Plugin_055_Data)
- break;
+ String tokens;
+ uint8_t hours = node_time.hour();
+ const uint8_t minutes = node_time.minute();
- String tokens;
- uint8_t hours = node_time.hour();
- const uint8_t minutes = node_time.minute();
+ if (Plugin_055_Data->chimeClock)
+ {
+ const String tmpString = strformat(F("%02d%02d"), hours, minutes);
- if (Plugin_055_Data->chimeClock)
- {
- const String tmpString = strformat(F("%02d%02d"), hours, minutes);
- if (Plugin_055_ReadChime(tmpString, tokens))
- Plugin_055_AddStringFIFO(tokens);
+ if (Plugin_055_ReadChime(tmpString, tokens)) {
+ Plugin_055_AddStringFIFO(tokens);
+ }
- if (minutes == 0)
- {
- if (Plugin_055_ReadChime("hours", tokens) == 0)
- tokens = F("1111!,111!1,111!1!,11!11,11!11!,11!1!1,11!1!1!,1!111,1!111!,1!11!1,1!11!1!,1!1!11"); //1..12
+ if (minutes == 0)
+ {
+ if (Plugin_055_ReadChime("hours", tokens) == 0) {
+ tokens = F("1111!,111!1,111!1!,11!11,11!11!,11!1!1,11!1!1!,1!111,1!111!,1!11!1,1!11!1!,1!1!11"); // 1..12
+ }
- // hours 0..23 -> 1..12
- hours = hours % 12;
- if (hours == 0)
- hours = 12;
+ // hours 0..23 -> 1..12
+ hours = hours % 12;
- tokens = parseString(tokens, hours);
- Plugin_055_AddStringFIFO(tokens);
- }
+ if (hours == 0) {
+ hours = 12;
}
- success = true;
- break;
+ tokens = parseString(tokens, hours);
+ Plugin_055_AddStringFIFO(tokens);
}
+ }
+
+ success = true;
+ break;
+ }
case PLUGIN_FIFTY_PER_SECOND:
- //case PLUGIN_TEN_PER_SECOND:
- {
- if (!Plugin_055_Data)
- break;
+ // case PLUGIN_TEN_PER_SECOND:
+ {
+ if (!Plugin_055_Data) {
+ break;
+ }
- long millisAct = millis();
+ long millisAct = millis();
- if (Plugin_055_Data->millisStateEnd > 0) // just striking?
+ if (Plugin_055_Data->millisStateEnd > 0) // just striking?
+ {
+ if (timeDiff(millisAct, Plugin_055_Data->millisStateEnd) <= 0) // end reached?
{
- if (timeDiff(millisAct, Plugin_055_Data->millisStateEnd) <= 0) // end reached?
+ for (uint8_t i = 0; i < 4; ++i)
{
- for (uint8_t i = 0; i < 4; ++i)
- {
- if (Plugin_055_Data->pin[i] >= 0)
- digitalWrite(Plugin_055_Data->pin[i], Plugin_055_Data->lowActive);
+ if (Plugin_055_Data->pin[i] >= 0) {
+ digitalWrite(Plugin_055_Data->pin[i], Plugin_055_Data->lowActive);
}
- Plugin_055_Data->millisStateEnd = 0;
}
+ Plugin_055_Data->millisStateEnd = 0;
}
+ }
- if (Plugin_055_Data->millisStateEnd == 0) // just finished?
+ if (Plugin_055_Data->millisStateEnd == 0) // just finished?
+ {
+ if (!Plugin_055_IsEmptyFIFO())
{
- if (! Plugin_055_IsEmptyFIFO())
- {
- char c = Plugin_055_ReadFIFO();
+ char c = Plugin_055_ReadFIFO();
# ifndef BUILD_NO_DEBUG
- if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
- addLog(LOG_LEVEL_DEBUG, strformat(F("Chime: Process '%c'"), c));
- }
- #endif
- switch (c)
+ if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
+ addLog(LOG_LEVEL_DEBUG, strformat(F("Chime: Process '%c'"), c));
+ }
+ # endif // ifndef BUILD_NO_DEBUG
+
+ switch (c)
+ {
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ c -= 'A' - '0' - 10;
+
+ // vvv
+
+ case '0': // strikes 1=1st bell, 2=2nd bell, 4=3rd bell, 8=4rd bell
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
{
- case 'a':
- case 'b':
- case 'c':
- case 'd':
- case 'e':
- case 'f':
- case 'A':
- case 'B':
- case 'C':
- case 'D':
- case 'E':
- case 'F':
- c -= 'A' - '0' - 10;
- //vvv
-
- case '0': //strikes 1=1st bell, 2=2nd bell, 4=3rd bell, 8=4rd bell
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
+ uint8_t mask = 1;
+
+ for (uint8_t i = 0; i < 4; ++i)
{
- uint8_t mask = 1;
- for (uint8_t i = 0; i < 4; ++i)
- {
- if (Plugin_055_Data->pin[i] >= 0)
- if (c & mask)
- digitalWrite(Plugin_055_Data->pin[i], !Plugin_055_Data->lowActive);
- mask <<= 1;
+ if (Plugin_055_Data->pin[i] >= 0) {
+ if (c & mask) {
+ digitalWrite(Plugin_055_Data->pin[i], !Plugin_055_Data->lowActive);
+ }
}
- Plugin_055_Data->millisStateEnd = millisAct + Plugin_055_Data->millisChimeTime;
- break;
+ mask <<= 1;
}
- case '=': //long pause
- case ' ':
- case ',':
- Plugin_055_Data->millisStateEnd = millisAct + Plugin_055_Data->millisPauseTime*3;
- break;
- case '-': //single pause
- Plugin_055_Data->millisStateEnd = millisAct + Plugin_055_Data->millisPauseTime;
- break;
- case '.': //short pause
- Plugin_055_Data->millisStateEnd = millisAct + Plugin_055_Data->millisPauseTime/3;
- break;
- case '|': //shortest pause
- Plugin_055_Data->millisStateEnd = millisAct + Plugin_055_Data->millisChimeTime/2;
- break;
- case '#': //comment -> eat till FIFO is empty
- while (Plugin_055_ReadFIFO());
- break;
- default: //unknown char -> do nothing
- break;
+ Plugin_055_Data->millisStateEnd = millisAct + Plugin_055_Data->millisChimeTime;
+ break;
}
+ case '=': // long pause
+ case ' ':
+ case ',':
+ Plugin_055_Data->millisStateEnd = millisAct + Plugin_055_Data->millisPauseTime * 3;
+ break;
+ case '-': // single pause
+ Plugin_055_Data->millisStateEnd = millisAct + Plugin_055_Data->millisPauseTime;
+ break;
+ case '.': // short pause
+ Plugin_055_Data->millisStateEnd = millisAct + Plugin_055_Data->millisPauseTime / 3;
+ break;
+ case '|': // shortest pause
+ Plugin_055_Data->millisStateEnd = millisAct + Plugin_055_Data->millisChimeTime / 2;
+ break;
+ case '#': // comment -> eat till FIFO is empty
+
+ while (Plugin_055_ReadFIFO()) {}
+ break;
+ default: // unknown char -> do nothing
+ break;
}
-
}
- success = true;
- break;
}
-
+ success = true;
+ break;
+ }
}
return success;
}
@@ -391,8 +421,9 @@ boolean Plugin_055(uint8_t function, struct EventStruct *event, String& string)
void Plugin_055_WriteFIFO(char c)
{
- if (Plugin_055_Data->FIFO_IndexR == ((Plugin_055_Data->FIFO_IndexW+1) & PLUGIN_055_FIFO_MASK)) // FIFO full?
+ if (Plugin_055_Data->FIFO_IndexR == ((Plugin_055_Data->FIFO_IndexW + 1) & PLUGIN_055_FIFO_MASK)) { // FIFO full?
return;
+ }
Plugin_055_Data->FIFO[Plugin_055_Data->FIFO_IndexW] = c;
Plugin_055_Data->FIFO_IndexW++;
@@ -401,10 +432,12 @@ void Plugin_055_WriteFIFO(char c)
char Plugin_055_ReadFIFO()
{
- if (Plugin_055_IsEmptyFIFO())
+ if (Plugin_055_IsEmptyFIFO()) {
return '\0';
+ }
char c = Plugin_055_Data->FIFO[Plugin_055_Data->FIFO_IndexR];
+
Plugin_055_Data->FIFO_IndexR++;
Plugin_055_Data->FIFO_IndexR &= PLUGIN_055_FIFO_MASK;
@@ -413,31 +446,35 @@ char Plugin_055_ReadFIFO()
char Plugin_055_PeekFIFO()
{
- if (Plugin_055_IsEmptyFIFO())
+ if (Plugin_055_IsEmptyFIFO()) {
return '\0';
+ }
return Plugin_055_Data->FIFO[Plugin_055_Data->FIFO_IndexR];
}
boolean Plugin_055_IsEmptyFIFO()
{
- return (Plugin_055_Data->FIFO_IndexR == Plugin_055_Data->FIFO_IndexW);
+ return Plugin_055_Data->FIFO_IndexR == Plugin_055_Data->FIFO_IndexW;
}
void Plugin_055_AddStringFIFO(const String& param)
{
- if (param.isEmpty())
+ if (param.isEmpty()) {
return;
+ }
- uint8_t i = 0;
- char c = param[i];
- char c_last = '\0';
+ uint8_t i = 0;
+ char c = param[i];
+ char c_last = '\0';
while (c != 0)
{
- if (isDigit(c) && isDigit(c_last)) // "11" is shortcut for "1-1" -> add pause
+ if (isDigit(c) && isDigit(c_last)) { // "11" is shortcut for "1-1" -> add pause
Plugin_055_WriteFIFO('-');
- if (c == '!') //double strike -> add shortest pause and repeat last strike
+ }
+
+ if (c == '!') // double strike -> add shortest pause and repeat last strike
{
Plugin_055_WriteFIFO('|');
c = c_last;
@@ -451,24 +488,29 @@ void Plugin_055_AddStringFIFO(const String& param)
Plugin_055_WriteFIFO('=');
}
-//File I/O functions
+// File I/O functions
void Plugin_055_WriteChime(const String& name, const String& tokens)
{
const String fileName = strformat(F("chime_%s.txt"), name.c_str());
String log;
- if (loglevelActiveFor(LOG_LEVEL_INFO))
+
+ if (loglevelActiveFor(LOG_LEVEL_INFO)) {
log = strformat(F("Chime: write %s "), fileName.c_str());
+ }
fs::File f = tryOpenFile(fileName, "w");
+
if (f)
{
f.print(tokens);
f.close();
- //flashCount();
- if (loglevelActiveFor(LOG_LEVEL_INFO))
+
+ // flashCount();
+ if (loglevelActiveFor(LOG_LEVEL_INFO)) {
log += tokens;
+ }
}
addLogMove(LOG_LEVEL_INFO, log);
@@ -479,23 +521,29 @@ uint8_t Plugin_055_ReadChime(const String& name, String& tokens)
const String fileName = strformat(F("chime_%s.txt"), name.c_str());
String log;
- if (loglevelActiveFor(LOG_LEVEL_INFO))
+
+ if (loglevelActiveFor(LOG_LEVEL_INFO)) {
log = strformat(F("Chime: read %s "), fileName.c_str());
+ }
tokens = String();
fs::File f = tryOpenFile(fileName, "r");
+
if (f)
{
tokens.reserve(f.size());
char c;
+
while (f.available())
{
- c = f.read();
+ c = f.read();
tokens += c;
}
f.close();
- if (loglevelActiveFor(LOG_LEVEL_INFO))
+
+ if (loglevelActiveFor(LOG_LEVEL_INFO)) {
log += tokens;
+ }
}
addLogMove(LOG_LEVEL_INFO, log);
diff --git a/src/_P063_TTP229_KeyPad.ino b/src/_P063_TTP229_KeyPad.ino
index 9d5f1a2523..b33599a3ab 100644
--- a/src/_P063_TTP229_KeyPad.ino
+++ b/src/_P063_TTP229_KeyPad.ino
@@ -1,14 +1,17 @@
#include "_Plugin_Helper.h"
#ifdef USES_P063
-//#######################################################################################################
-//#################################### Plugin 063: TTP229 KeyPad ########################################
-//#######################################################################################################
+
+// #######################################################################################################
+// #################################### Plugin 063: TTP229 KeyPad ########################################
+// #######################################################################################################
// ESPEasy Plugin to scan a 16 key touch pad chip TTP229
// written by Jochen Krapf (jk@nerd2nerd.org)
-// Important: There are several types of TTP299 chips with different features available. They are named all TTP229 but differ in the letter(s) followed.
-// On the china boards (found on eBay and AliExpress) the TTP229-B is used which has NO! I2C-interface. It uses a proprietary serial protocol with clock (SCL) and bidirectional data (SDO)
+// Important: There are several types of TTP299 chips with different features available. They are named all TTP229 but differ in the
+// letter(s) followed.
+// On the china boards (found on eBay and AliExpress) the TTP229-B is used which has NO! I2C-interface. It uses a proprietary serial
+// protocol with clock (SCL) and bidirectional data (SDO)
// ScanCode;
// Value 1...16 for the key number
@@ -24,17 +27,16 @@
// Schematics: https://www.openimpulse.com/blog/wp-content/uploads/wpsc/downloadables/TTP229B-Schematic-Diagram.pdf
// Datasheet: http://www.datasheet4u.com/download_new.php?id=996751
-#define PLUGIN_063
-#define PLUGIN_ID_063 63
-#define PLUGIN_NAME_063 "Keypad - TTP229 Touch"
-#define PLUGIN_VALUENAME1_063 "ScanCode"
-
+# define PLUGIN_063
+# define PLUGIN_ID_063 63
+# define PLUGIN_NAME_063 "Keypad - TTP229 Touch"
+# define PLUGIN_VALUENAME1_063 "ScanCode"
uint16_t readTTP229(int16_t pinSCL, int16_t pinSDO)
{
uint16_t value = 0;
- uint16_t mask = 1;
+ uint16_t mask = 1;
pinMode(pinSDO, OUTPUT);
digitalWrite(pinSDO, HIGH);
@@ -44,11 +46,13 @@ uint16_t readTTP229(int16_t pinSCL, int16_t pinSDO)
delayMicroseconds(10);
pinMode(pinSDO, INPUT);
+
for (uint8_t i = 0; i < 16; ++i)
{
digitalWrite(pinSCL, HIGH);
delayMicroseconds(1);
digitalWrite(pinSCL, LOW);
+
if (!digitalRead(pinSDO)) {
value |= mask;
}
@@ -59,7 +63,6 @@ uint16_t readTTP229(int16_t pinSCL, int16_t pinSDO)
return value;
}
-
boolean Plugin_063(uint8_t function, struct EventStruct *event, String& string)
{
boolean success = false;
@@ -67,153 +70,159 @@ boolean Plugin_063(uint8_t function, struct EventStruct *event, String& string)
switch (function)
{
case PLUGIN_DEVICE_ADD:
- {
- Device[++deviceCount].Number = PLUGIN_ID_063;
- Device[deviceCount].Type = DEVICE_TYPE_DUAL;
- Device[deviceCount].Ports = 0;
- Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_SWITCH;
- Device[deviceCount].PullUpOption = false;
- Device[deviceCount].InverseLogicOption = false;
- Device[deviceCount].FormulaOption = false;
- Device[deviceCount].ValueCount = 1;
- Device[deviceCount].SendDataOption = true;
- Device[deviceCount].TimerOption = true;
- Device[deviceCount].TimerOptional = true;
- Device[deviceCount].GlobalSyncOption = true;
- break;
- }
+ {
+ Device[++deviceCount].Number = PLUGIN_ID_063;
+ Device[deviceCount].Type = DEVICE_TYPE_DUAL;
+ Device[deviceCount].Ports = 0;
+ Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_SWITCH;
+ Device[deviceCount].ValueCount = 1;
+ Device[deviceCount].SendDataOption = true;
+ Device[deviceCount].TimerOption = true;
+ Device[deviceCount].TimerOptional = true;
+ Device[deviceCount].GlobalSyncOption = true;
+ Device[deviceCount].Pin1Direction = gpio_direction::gpio_output;
+ break;
+ }
case PLUGIN_GET_DEVICENAME:
- {
- string = F(PLUGIN_NAME_063);
- break;
- }
+ {
+ string = F(PLUGIN_NAME_063);
+ break;
+ }
case PLUGIN_GET_DEVICEVALUENAMES:
- {
- strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_063));
- break;
- }
+ {
+ strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_063));
+ break;
+ }
case PLUGIN_GET_DEVICEGPIONAMES:
- {
- event->String1 = formatGpioName_output(F("SCL"));
- event->String2 = formatGpioName_bidirectional(F("SDO"));
- break;
- }
+ {
+ event->String1 = formatGpioName_output(F("SCL"));
+ event->String2 = formatGpioName_bidirectional(F("SDO"));
+ break;
+ }
case PLUGIN_WEBFORM_LOAD:
- {
- addFormCheckBox(F("ScanCode"), F("scancode"), PCONFIG(1));
+ {
+ addFormCheckBox(F("ScanCode"), F("scancode"), PCONFIG(1));
- success = true;
- break;
- }
+ success = true;
+ break;
+ }
case PLUGIN_WEBFORM_SAVE:
- {
- PCONFIG(1) = isFormItemChecked(F("scancode"));
+ {
+ PCONFIG(1) = isFormItemChecked(F("scancode"));
- success = true;
- break;
- }
+ success = true;
+ break;
+ }
case PLUGIN_INIT:
+ {
+ portStatusStruct newStatus;
+
+ int16_t pinSCL = CONFIG_PIN1;
+ int16_t pinSDO = CONFIG_PIN2;
+
+ if (loglevelActiveFor(LOG_LEVEL_INFO)) {
+ addLog(LOG_LEVEL_INFO, strformat(F("Tkey : GPIO: %d %d"), pinSCL, pinSDO));
+ }
+
+ if (validGpio(pinSCL) && validGpio(pinSDO))
{
- portStatusStruct newStatus;
+ pinMode(pinSCL, OUTPUT);
+ digitalWrite(pinSCL, LOW);
- int16_t pinSCL = CONFIG_PIN1;
- int16_t pinSDO = CONFIG_PIN2;
+ constexpr pluginID_t P063_PLUGIN_ID{ PLUGIN_ID_063 };
- if (loglevelActiveFor(LOG_LEVEL_INFO)) {
- addLog(LOG_LEVEL_INFO, strformat(F("Tkey : GPIO: %d %d"), pinSCL, pinSDO));
- }
+ uint32_t key = createKey(P063_PLUGIN_ID, pinSCL);
- if (validGpio(pinSCL) && validGpio(pinSDO))
- {
- pinMode(pinSCL, OUTPUT);
- digitalWrite(pinSCL, LOW);
-
- constexpr pluginID_t P063_PLUGIN_ID{PLUGIN_ID_063};
-
- uint32_t key = createKey(P063_PLUGIN_ID, pinSCL);
- // WARNING: operator [] creates an entry in the map if key does not exist
- newStatus = globalMapPortStatus[key];
- newStatus.task++; // add this GPIO/port as a task
- newStatus.mode = PIN_MODE_OUTPUT;
- newStatus.state = 0;
- savePortStatus(key,newStatus);
- //setPinState(PLUGIN_ID_063, pinSCL, PIN_MODE_OUTPUT, 0);
-
- pinMode(pinSDO, OUTPUT);
- digitalWrite(pinSDO, LOW);
- key = createKey(P063_PLUGIN_ID, pinSDO);
- // WARNING: operator [] creates an entry in the map if key does not exist
- newStatus = globalMapPortStatus[key];
- newStatus.task++; // add this GPIO/port as a task
- newStatus.mode = PIN_MODE_INPUT;
- newStatus.state = 0;
- savePortStatus(key,newStatus);
- //setPinState(PLUGIN_ID_063, pinSDO, PIN_MODE_INPUT, 0);
- success = true;
- }
+ // WARNING: operator [] creates an entry in the map if key does not exist
+ newStatus = globalMapPortStatus[key];
+ newStatus.task++; // add this GPIO/port as a task
+ newStatus.mode = PIN_MODE_OUTPUT;
+ newStatus.state = 0;
+ savePortStatus(key, newStatus);
+
+ // setPinState(PLUGIN_ID_063, pinSCL, PIN_MODE_OUTPUT, 0);
- break;
+ pinMode(pinSDO, OUTPUT);
+ digitalWrite(pinSDO, LOW);
+ key = createKey(P063_PLUGIN_ID, pinSDO);
+
+ // WARNING: operator [] creates an entry in the map if key does not exist
+ newStatus = globalMapPortStatus[key];
+ newStatus.task++; // add this GPIO/port as a task
+ newStatus.mode = PIN_MODE_INPUT;
+ newStatus.state = 0;
+ savePortStatus(key, newStatus);
+
+ // setPinState(PLUGIN_ID_063, pinSDO, PIN_MODE_INPUT, 0);
+ success = true;
}
+ break;
+ }
+
case PLUGIN_TEN_PER_SECOND:
- {
- static uint16_t keyLast = 0;
- int16_t pinSCL = CONFIG_PIN1;
- int16_t pinSDO = CONFIG_PIN2;
+ {
+ static uint16_t keyLast = 0;
+ int16_t pinSCL = CONFIG_PIN1;
+ int16_t pinSDO = CONFIG_PIN2;
- uint16_t key = readTTP229(pinSCL, pinSDO);
+ uint16_t key = readTTP229(pinSCL, pinSDO);
+
+ if (key && PCONFIG(1))
+ {
+ uint16_t colMask = 0x01;
- if (key && PCONFIG(1))
+ for (uint8_t col = 1; col <= 16; ++col)
{
- uint16_t colMask = 0x01;
- for (uint8_t col = 1; col <= 16; ++col)
+ if (key & colMask) // this key pressed?
{
- if (key & colMask) // this key pressed?
- {
- key = col;
- break;
- }
- colMask <<= 1;
+ key = col;
+ break;
}
+ colMask <<= 1;
}
+ }
- if (keyLast != key)
- {
- keyLast = key;
- UserVar.setFloat(event->TaskIndex, 0, key);
- event->sensorType = Sensor_VType::SENSOR_TYPE_SWITCH;
-
- if (loglevelActiveFor(LOG_LEVEL_INFO)) {
- String log = F("Tkey : ");
- if (PCONFIG(1))
- log = F("ScanCode=");
- else
- log = F("KeyMap=");
- log += formatToHex(key);
- addLogMove(LOG_LEVEL_INFO, log);
- }
+ if (keyLast != key)
+ {
+ keyLast = key;
+ UserVar.setFloat(event->TaskIndex, 0, key);
+ event->sensorType = Sensor_VType::SENSOR_TYPE_SWITCH;
+
+ if (loglevelActiveFor(LOG_LEVEL_INFO)) {
+ String log = F("Tkey : ");
- sendData(event);
+ if (PCONFIG(1)) {
+ log = F("ScanCode=");
+ }
+ else {
+ log = F("KeyMap=");
+ }
+ log += formatToHex(key);
+ addLogMove(LOG_LEVEL_INFO, log);
}
- success = true;
- break;
+ sendData(event);
}
- case PLUGIN_READ:
- {
- // work is done in PLUGIN_TEN_PER_SECOND
- success = true;
- break;
- }
+ success = true;
+ break;
+ }
+ case PLUGIN_READ:
+ {
+ // work is done in PLUGIN_TEN_PER_SECOND
+ success = true;
+ break;
+ }
}
return success;
}
+
#endif // USES_P063
diff --git a/src/_P067_HX711_Load_Cell.ino b/src/_P067_HX711_Load_Cell.ino
index af4fa2c52b..9452f1efdd 100644
--- a/src/_P067_HX711_Load_Cell.ino
+++ b/src/_P067_HX711_Load_Cell.ino
@@ -42,19 +42,16 @@ boolean Plugin_067(uint8_t function, struct EventStruct *event, String& string)
{
case PLUGIN_DEVICE_ADD:
{
- Device[++deviceCount].Number = PLUGIN_ID_067;
- Device[deviceCount].Type = DEVICE_TYPE_DUAL;
- Device[deviceCount].Ports = 0;
- Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_DUAL;
- Device[deviceCount].PullUpOption = false;
- Device[deviceCount].InverseLogicOption = false;
- Device[deviceCount].FormulaOption = true;
- Device[deviceCount].ValueCount = 2;
- Device[deviceCount].SendDataOption = true;
- Device[deviceCount].TimerOption = true;
- Device[deviceCount].TimerOptional = false;
- Device[deviceCount].GlobalSyncOption = true;
- Device[deviceCount].PluginStats = true;
+ Device[++deviceCount].Number = PLUGIN_ID_067;
+ Device[deviceCount].Type = DEVICE_TYPE_DUAL;
+ Device[deviceCount].Ports = 0;
+ Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_DUAL;
+ Device[deviceCount].FormulaOption = true;
+ Device[deviceCount].ValueCount = 2;
+ Device[deviceCount].SendDataOption = true;
+ Device[deviceCount].TimerOption = true;
+ Device[deviceCount].PluginStats = true;
+ Device[deviceCount].Pin1Direction = gpio_direction::gpio_output;
break;
}
diff --git a/src/_P070_NeoPixel_Clock.ino b/src/_P070_NeoPixel_Clock.ino
index 1c1a8381f8..2de1610378 100644
--- a/src/_P070_NeoPixel_Clock.ino
+++ b/src/_P070_NeoPixel_Clock.ino
@@ -36,17 +36,12 @@ boolean Plugin_070(uint8_t function, struct EventStruct *event, String& string)
{
case PLUGIN_DEVICE_ADD:
{
- Device[++deviceCount].Number = PLUGIN_ID_070;
- Device[deviceCount].Type = DEVICE_TYPE_SINGLE;
- Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_TRIPLE;
- Device[deviceCount].Ports = 0;
- Device[deviceCount].PullUpOption = false;
- Device[deviceCount].InverseLogicOption = false;
- Device[deviceCount].FormulaOption = false;
- Device[deviceCount].ValueCount = 3;
- Device[deviceCount].SendDataOption = false;
- Device[deviceCount].TimerOption = false;
- Device[deviceCount].GlobalSyncOption = false;
+ Device[++deviceCount].Number = PLUGIN_ID_070;
+ Device[deviceCount].Type = DEVICE_TYPE_SINGLE;
+ Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_TRIPLE;
+ Device[deviceCount].Ports = 0;
+ Device[deviceCount].ValueCount = 3;
+ Device[deviceCount].Pin1Direction = gpio_direction::gpio_output;
// FIXME TD-er: Not sure if access to any existing task data is needed when saving
Device[deviceCount].ExitTaskBeforeSave = false;
diff --git a/src/_P073_7DGT.ino b/src/_P073_7DGT.ino
index 1e3102f1b7..d0f07b42de 100644
--- a/src/_P073_7DGT.ino
+++ b/src/_P073_7DGT.ino
@@ -87,18 +87,14 @@ boolean Plugin_073(uint8_t function, struct EventStruct *event, String& string)
switch (function) {
case PLUGIN_DEVICE_ADD: {
- Device[++deviceCount].Number = PLUGIN_ID_073;
- Device[deviceCount].Type = DEVICE_TYPE_TRIPLE;
- Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_NONE;
- Device[deviceCount].Ports = 0;
- Device[deviceCount].PullUpOption = false;
- Device[deviceCount].InverseLogicOption = false;
- Device[deviceCount].FormulaOption = false;
- Device[deviceCount].ValueCount = 0;
- Device[deviceCount].SendDataOption = false;
- Device[deviceCount].TimerOption = false;
- Device[deviceCount].TimerOptional = false;
- Device[deviceCount].GlobalSyncOption = true;
+ Device[++deviceCount].Number = PLUGIN_ID_073;
+ Device[deviceCount].Type = DEVICE_TYPE_TRIPLE;
+ Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_NONE;
+ Device[deviceCount].Ports = 0;
+ Device[deviceCount].ValueCount = 0;
+ Device[deviceCount].Pin1Direction = gpio_direction::gpio_output;
+ Device[deviceCount].Pin2Direction = gpio_direction::gpio_output;
+ Device[deviceCount].Pin3Direction = gpio_direction::gpio_output;
break;
}
@@ -868,7 +864,7 @@ bool p073_plugin_write_7dfont(struct EventStruct *event,
}
if (!text.isEmpty()) {
- String fontArg = parseString(text, 1);
+ String fontArg = parseString(text, 1);
int32_t fontNr = -1;
if ((equals(fontArg, F("default"))) || (equals(fontArg, F("7dgt")))) {
@@ -912,10 +908,10 @@ bool p073_plugin_write_7dbin(struct EventStruct *event,
}
if (!text.isEmpty()) {
- String data;
+ String data;
int32_t byteValue{};
- int arg = 1;
- String argValue = parseString(text, arg);
+ int arg = 1;
+ String argValue = parseString(text, arg);
while (!argValue.isEmpty()) {
if (validIntFromString(argValue, byteValue) && (byteValue < 256) && (byteValue > -1)) {
@@ -1297,10 +1293,10 @@ void tm1637_ShowBuffer(struct EventStruct *event,
# define OP_SHUTDOWN 12
# define OP_DISPLAYTEST 15
-void max7219_spiTransfer(struct EventStruct *event,
- uint8_t din_pin,
- uint8_t clk_pin,
- uint8_t cs_pin,
+void max7219_spiTransfer(struct EventStruct *event,
+ uint8_t din_pin,
+ uint8_t clk_pin,
+ uint8_t cs_pin,
ESPEASY_VOLATILE(uint8_t) opcode,
ESPEASY_VOLATILE(uint8_t) data) {
P073_data_struct *P073_data =
diff --git a/src/_P076_HLW8012.ino b/src/_P076_HLW8012.ino
index 041dcd285e..58c90e0c55 100644
--- a/src/_P076_HLW8012.ino
+++ b/src/_P076_HLW8012.ino
@@ -109,18 +109,16 @@ boolean Plugin_076(uint8_t function, struct EventStruct *event, String& string)
switch (function) {
case PLUGIN_DEVICE_ADD: {
- Device[++deviceCount].Number = PLUGIN_ID_076;
- Device[deviceCount].Type = DEVICE_TYPE_TRIPLE;
- Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_QUAD;
- Device[deviceCount].Ports = 0;
- Device[deviceCount].PullUpOption = false;
- Device[deviceCount].InverseLogicOption = false;
- Device[deviceCount].FormulaOption = true;
- Device[deviceCount].ValueCount = 4;
- Device[deviceCount].SendDataOption = true;
- Device[deviceCount].TimerOption = true;
- Device[deviceCount].GlobalSyncOption = false;
- Device[deviceCount].PluginStats = true;
+ Device[++deviceCount].Number = PLUGIN_ID_076;
+ Device[deviceCount].Type = DEVICE_TYPE_TRIPLE;
+ Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_QUAD;
+ Device[deviceCount].Ports = 0;
+ Device[deviceCount].FormulaOption = true;
+ Device[deviceCount].ValueCount = 4;
+ Device[deviceCount].SendDataOption = true;
+ Device[deviceCount].TimerOption = true;
+ Device[deviceCount].PluginStats = true;
+ Device[deviceCount].Pin1Direction = gpio_direction::gpio_output;
break;
}
diff --git a/src/_P088_HeatpumpIR.ino b/src/_P088_HeatpumpIR.ino
index 66155b16f8..0696c9cef9 100644
--- a/src/_P088_HeatpumpIR.ino
+++ b/src/_P088_HeatpumpIR.ino
@@ -1,12 +1,13 @@
#include "_Plugin_Helper.h"
#ifdef USES_P088
-//#######################################################################################################
-//#################################### Plugin 088: Heatpump IR ##########################################
-//#######################################################################################################
-#define PLUGIN_088
-#define PLUGIN_ID_088 88
-#define PLUGIN_NAME_088 "Energy (Heat) - Heatpump IR transmitter"
+// #######################################################################################################
+// #################################### Plugin 088: Heatpump IR ##########################################
+// #######################################################################################################
+
+# define PLUGIN_088
+# define PLUGIN_ID_088 88
+# define PLUGIN_NAME_088 "Energy (Heat) - Heatpump IR transmitter"
/*
@@ -32,7 +33,8 @@
* Take a look at https://github.com/ToniA/cabin-village-project/blob/eventscripts/script_device_hp.lua for Domoticz event examples
*
* The parameters are (in this order)
- * * The type of the heatpump as a string, see the implementations of different models, like https://github.com/ToniA/arduino-heatpumpir/blob/master/MitsubishiHeatpumpIR.cpp
+ * * The type of the heatpump as a string, see the implementations of different models, like
+ *https://github.com/ToniA/arduino-heatpumpir/blob/master/MitsubishiHeatpumpIR.cpp
* * power state (see https://github.com/ToniA/arduino-heatpumpir/blob/master/HeatpumpIR.h for modes)
* * operating mode
* * fan speed
@@ -44,12 +46,12 @@
*
*/
-#include
+# include
-#include "ESPEasy-Globals.h"
+# include "ESPEasy-Globals.h"
IRSenderIRremoteESP8266 *Plugin_088_irSender = nullptr;
-int panasonicCKPTimer = 0;
+int panasonicCKPTimer = 0;
boolean Plugin_088(uint8_t function, struct EventStruct *event, String& string)
{
@@ -58,197 +60,206 @@ boolean Plugin_088(uint8_t function, struct EventStruct *event, String& string)
switch (function)
{
case PLUGIN_DEVICE_ADD:
- {
- Device[++deviceCount].Number = PLUGIN_ID_088;
- Device[deviceCount].Type = DEVICE_TYPE_SINGLE;
- Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_NONE;
- Device[deviceCount].Ports = 0;
- Device[deviceCount].PullUpOption = false;
- Device[deviceCount].InverseLogicOption = false;
- Device[deviceCount].FormulaOption = false;
- Device[deviceCount].ValueCount = 0;
- Device[deviceCount].SendDataOption = false;
- Device[deviceCount].TimerOption = false;
- Device[deviceCount].TimerOptional = false;
- Device[deviceCount].GlobalSyncOption = false;
- Device[deviceCount].DecimalsOnly = false;
-
- break;
- }
+ {
+ Device[++deviceCount].Number = PLUGIN_ID_088;
+ Device[deviceCount].Type = DEVICE_TYPE_SINGLE;
+ Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_NONE;
+ Device[deviceCount].Ports = 0;
+ Device[deviceCount].ValueCount = 0;
+ Device[deviceCount].Pin1Direction = gpio_direction::gpio_output;
+
+ break;
+ }
case PLUGIN_GET_DEVICENAME:
- {
- string = F(PLUGIN_NAME_088);
- break;
- }
+ {
+ string = F(PLUGIN_NAME_088);
+ break;
+ }
case PLUGIN_GET_DEVICEVALUENAMES:
- {
- break;
- }
+ {
+ break;
+ }
case PLUGIN_WEBFORM_LOAD:
- {
- // We need the index of the controller we are: 0-CONTROLLER_MAX
- // FIXME TD-er: Why looking for Domoticz MQTT? Other plugins also support IDX values.
- controllerIndex_t controllerNr = 0;
- for (controllerIndex_t i=0; i < CONTROLLER_MAX; i++)
- {
- if (Settings.Protocol[i] == 2) { controllerNr = i; }
- }
+ {
+ // We need the index of the controller we are: 0-CONTROLLER_MAX
+ // FIXME TD-er: Why looking for Domoticz MQTT? Other plugins also support IDX values.
+ controllerIndex_t controllerNr = 0;
- if (Settings.ControllerEnabled[controllerNr])
- {
- addRowLabel(F("IDX"));
- String id = F("TDID"); //="taskdeviceid"
- id += controllerNr + 1;
- addNumericBox(id, Settings.TaskDeviceID[controllerNr][event->TaskIndex], 0, 9999);
- }
- success = true;
- break;
+ for (controllerIndex_t i = 0; i < CONTROLLER_MAX; i++)
+ {
+ if (Settings.Protocol[i] == 2) { controllerNr = i; }
}
- case PLUGIN_WEBFORM_SAVE:
+ if (Settings.ControllerEnabled[controllerNr])
{
- success = true;
- break;
+ addRowLabel(F("IDX"));
+ String id = F("TDID"); // ="taskdeviceid"
+ id += controllerNr + 1;
+ addNumericBox(id, Settings.TaskDeviceID[controllerNr][event->TaskIndex], 0, 9999);
}
+ success = true;
+ break;
+ }
+
+ case PLUGIN_WEBFORM_SAVE:
+ {
+ success = true;
+ break;
+ }
case PLUGIN_INIT:
+ {
+ int irPin = CONFIG_PIN1;
+
+ if (validGpio(irPin))
{
- int irPin = CONFIG_PIN1;
- if (validGpio(irPin))
- {
- addLog(LOG_LEVEL_INFO, F("P088: Heatpump IR transmitter activated"));
- if (Plugin_088_irSender != nullptr)
- {
- delete Plugin_088_irSender;
- }
- Plugin_088_irSender = new (std::nothrow) IRSenderIRremoteESP8266(irPin);
- }
- if (Plugin_088_irSender != nullptr && irPin == -1)
+ addLog(LOG_LEVEL_INFO, F("P088: Heatpump IR transmitter activated"));
+
+ if (Plugin_088_irSender != nullptr)
{
- addLog(LOG_LEVEL_INFO, F("P088: Heatpump IR transmitter deactivated"));
delete Plugin_088_irSender;
- Plugin_088_irSender = nullptr;
}
- success = true;
- break;
+ Plugin_088_irSender = new (std::nothrow) IRSenderIRremoteESP8266(irPin);
}
- case PLUGIN_READ:
+ if ((Plugin_088_irSender != nullptr) && (irPin == -1))
{
- success = true;
- break;
+ addLog(LOG_LEVEL_INFO, F("P088: Heatpump IR transmitter deactivated"));
+ delete Plugin_088_irSender;
+ Plugin_088_irSender = nullptr;
}
+ success = true;
+ break;
+ }
+
+ case PLUGIN_READ:
+ {
+ success = true;
+ break;
+ }
case PLUGIN_WRITE:
+ {
+ String heatpumpModel;
+ unsigned int powerMode = POWER_ON;
+ unsigned int operatingMode = MODE_HEAT;
+ unsigned int fanSpeed = FAN_2;
+ unsigned int temperature = 22;
+ unsigned int vDir = VDIR_UP;
+ unsigned int hDir = HDIR_AUTO;
+
+ String cmd = parseString(string, 1);
+
+ if (cmd.equalsIgnoreCase(F("HEATPUMPIR")) && (Plugin_088_irSender != nullptr))
{
- String heatpumpModel;
- unsigned int powerMode = POWER_ON;
- unsigned int operatingMode = MODE_HEAT;
- unsigned int fanSpeed = FAN_2;
- unsigned int temperature = 22;
- unsigned int vDir = VDIR_UP;
- unsigned int hDir = HDIR_AUTO;
-
- String cmd = parseString(string, 1);
- if (cmd.equalsIgnoreCase(F("HEATPUMPIR")) && Plugin_088_irSender != nullptr)
- {
- String TmpStr1;
- if (GetArgv(string.c_str(), TmpStr1, 2)) heatpumpModel = TmpStr1;
- if (GetArgv(string.c_str(), TmpStr1, 3)) powerMode = str2int(TmpStr1.c_str());
- if (GetArgv(string.c_str(), TmpStr1, 4)) operatingMode = str2int(TmpStr1.c_str());
- if (GetArgv(string.c_str(), TmpStr1, 5)) fanSpeed = str2int(TmpStr1.c_str());
- if (GetArgv(string.c_str(), TmpStr1, 6)) temperature = str2int(TmpStr1.c_str());
- if (GetArgv(string.c_str(), TmpStr1, 7)) vDir = str2int(TmpStr1.c_str());
- if (GetArgv(string.c_str(), TmpStr1, 8)) hDir = str2int(TmpStr1.c_str());
-#ifdef IR_SEND_TIME
- sendHour = node_time.hour();
- sendMinute = node_time.minute();
- sendWeekday = node_time.weekday();
-#endif
- HeatpumpIR *heatpumpIR = HeatpumpIRFactory::create(heatpumpModel.c_str());
-
- if (heatpumpIR != nullptr) {
- enableIR_RX(false);
- heatpumpIR->send(*Plugin_088_irSender, powerMode, operatingMode, fanSpeed, temperature, vDir, hDir);
- enableIR_RX(true);
+ String TmpStr1;
+
+ if (GetArgv(string.c_str(), TmpStr1, 2)) { heatpumpModel = TmpStr1; }
+
+ if (GetArgv(string.c_str(), TmpStr1, 3)) { powerMode = str2int(TmpStr1.c_str()); }
+
+ if (GetArgv(string.c_str(), TmpStr1, 4)) { operatingMode = str2int(TmpStr1.c_str()); }
+
+ if (GetArgv(string.c_str(), TmpStr1, 5)) { fanSpeed = str2int(TmpStr1.c_str()); }
+
+ if (GetArgv(string.c_str(), TmpStr1, 6)) { temperature = str2int(TmpStr1.c_str()); }
+
+ if (GetArgv(string.c_str(), TmpStr1, 7)) { vDir = str2int(TmpStr1.c_str()); }
+
+ if (GetArgv(string.c_str(), TmpStr1, 8)) { hDir = str2int(TmpStr1.c_str()); }
+# ifdef IR_SEND_TIME
+ sendHour = node_time.hour();
+ sendMinute = node_time.minute();
+ sendWeekday = node_time.weekday();
+# endif // ifdef IR_SEND_TIME
+ HeatpumpIR *heatpumpIR = HeatpumpIRFactory::create(heatpumpModel.c_str());
- delete heatpumpIR;
- heatpumpIR = nullptr;
-
- addLog(LOG_LEVEL_INFO, F("P088: Heatpump IR code transmitted"));
-#ifdef IR_DEBUG_PACKET
-# ifndef BUILD_NO_DEBUG
- addLog(LOG_LEVEL_DEBUG, IRPacket);
-#endif
-#endif
- if (printToWeb)
- {
- printWebString += F("P088: Heatpump IR code transmitted");
-#ifdef IR_DEBUG_PACKET
- printWebString += F(" \n"); // do both and \n to break line both in browser and curl -s
- printWebString += IRPacket;
- printWebString += F("\n");
-#endif
- }
-
- // Panasonic CKP can only be turned ON/OFF by using the timer,
- // so cancel the timer in 2 minutes, after the heatpump has turned on or off
- if (strcmp_P(heatpumpModel.c_str(), PSTR("panasonic_ckp")) == 0)
- {
- panasonicCKPTimer = 120;
- }
-
- success = true;
+ if (heatpumpIR != nullptr) {
+ enableIR_RX(false);
+ heatpumpIR->send(*Plugin_088_irSender, powerMode, operatingMode, fanSpeed, temperature, vDir, hDir);
+ enableIR_RX(true);
+
+ delete heatpumpIR;
+ heatpumpIR = nullptr;
+
+ addLog(LOG_LEVEL_INFO, F("P088: Heatpump IR code transmitted"));
+# ifdef IR_DEBUG_PACKET
+# ifndef BUILD_NO_DEBUG
+ addLog(LOG_LEVEL_DEBUG, IRPacket);
+# endif // ifndef BUILD_NO_DEBUG
+# endif // ifdef IR_DEBUG_PACKET
+
+ if (printToWeb)
+ {
+ printWebString += F("P088: Heatpump IR code transmitted");
+# ifdef IR_DEBUG_PACKET
+ printWebString += F(" \n"); // do both and \n to break line both in browser and curl -s
+ printWebString += IRPacket;
+ printWebString += F("\n");
+# endif // ifdef IR_DEBUG_PACKET
}
+
+ // Panasonic CKP can only be turned ON/OFF by using the timer,
+ // so cancel the timer in 2 minutes, after the heatpump has turned on or off
+ if (strcmp_P(heatpumpModel.c_str(), PSTR("panasonic_ckp")) == 0)
+ {
+ panasonicCKPTimer = 120;
+ }
+
+ success = true;
}
- break;
}
+ break;
+ }
case PLUGIN_EXIT:
- {
- addLog(LOG_LEVEL_INFO, F("P088: Heatpump IR transmitter deactivated"));
+ {
+ addLog(LOG_LEVEL_INFO, F("P088: Heatpump IR transmitter deactivated"));
- if (Plugin_088_irSender != nullptr)
- {
- delete Plugin_088_irSender;
- Plugin_088_irSender = nullptr;
- }
+ if (Plugin_088_irSender != nullptr)
+ {
+ delete Plugin_088_irSender;
+ Plugin_088_irSender = nullptr;
+ }
- break;
- }
+ break;
+ }
case PLUGIN_ONCE_A_SECOND:
+ {
+ if (panasonicCKPTimer > 0)
{
- if (panasonicCKPTimer > 0)
+ panasonicCKPTimer--;
+
+ if (panasonicCKPTimer == 0)
{
- panasonicCKPTimer--;
- if (panasonicCKPTimer == 0)
- {
- PanasonicCKPHeatpumpIR *panasonicHeatpumpIR = new (std::nothrow) PanasonicCKPHeatpumpIR();
- if (panasonicHeatpumpIR != nullptr) {
- enableIR_RX(false);
- panasonicHeatpumpIR->sendPanasonicCKPCancelTimer(*Plugin_088_irSender);
- enableIR_RX(true);
-
- delete panasonicHeatpumpIR;
- addLog(LOG_LEVEL_INFO, F("P088: The TIMER led on Panasonic CKP should now be OFF"));
- }
+ PanasonicCKPHeatpumpIR *panasonicHeatpumpIR = new (std::nothrow) PanasonicCKPHeatpumpIR();
+
+ if (panasonicHeatpumpIR != nullptr) {
+ enableIR_RX(false);
+ panasonicHeatpumpIR->sendPanasonicCKPCancelTimer(*Plugin_088_irSender);
+ enableIR_RX(true);
+
+ delete panasonicHeatpumpIR;
+ addLog(LOG_LEVEL_INFO, F("P088: The TIMER led on Panasonic CKP should now be OFF"));
}
}
- success = true;
- break;
}
+ success = true;
+ break;
+ }
case PLUGIN_TEN_PER_SECOND:
- {
- success = true;
- break;
- }
+ {
+ success = true;
+ break;
+ }
}
return success;
}
+
#endif // USES_P088
diff --git a/src/_P126_74HC595.ino b/src/_P126_74HC595.ino
index 5a16874dbd..8178ce0934 100644
--- a/src/_P126_74HC595.ino
+++ b/src/_P126_74HC595.ino
@@ -79,15 +79,11 @@ boolean Plugin_126(uint8_t function, struct EventStruct *event, String& string)
{
case PLUGIN_DEVICE_ADD:
{
- Device[++deviceCount].Number = PLUGIN_ID_126;
- Device[deviceCount].Type = DEVICE_TYPE_TRIPLE;
- Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_QUAD;
- Device[deviceCount].Ports = 0;
- Device[deviceCount].PullUpOption = false;
- Device[deviceCount].InverseLogicOption = false;
- Device[deviceCount].FormulaOption = false;
- Device[deviceCount].DecimalsOnly = false;
- Device[deviceCount].ValueCount =
+ Device[++deviceCount].Number = PLUGIN_ID_126;
+ Device[deviceCount].Type = DEVICE_TYPE_TRIPLE;
+ Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_QUAD;
+ Device[deviceCount].Ports = 0;
+ Device[deviceCount].ValueCount =
# if P126_MAX_CHIP_COUNT <= 4
1
# elif P126_MAX_CHIP_COUNT <= 8
@@ -98,10 +94,13 @@ boolean Plugin_126(uint8_t function, struct EventStruct *event, String& string)
4
# endif // if P126_MAX_CHIP_COUNT <= 4
;
- Device[deviceCount].SendDataOption = true;
- Device[deviceCount].TimerOption = true;
- Device[deviceCount].TimerOptional = true;
+ Device[deviceCount].SendDataOption = true;
+ Device[deviceCount].TimerOption = true;
+ Device[deviceCount].TimerOptional = true;
Device[deviceCount].HasFormatUserVar = true;
+ Device[deviceCount].Pin1Direction = gpio_direction::gpio_output;
+ Device[deviceCount].Pin2Direction = gpio_direction::gpio_output;
+ Device[deviceCount].Pin3Direction = gpio_direction::gpio_output;
break;
}
diff --git a/src/_P128_NeoPixelBusFX.ino b/src/_P128_NeoPixelBusFX.ino
index 38a18dcd26..89c31bbd81 100644
--- a/src/_P128_NeoPixelBusFX.ino
+++ b/src/_P128_NeoPixelBusFX.ino
@@ -154,18 +154,14 @@ boolean Plugin_128(uint8_t function, struct EventStruct *event, String& string)
# if defined(ESP8266)
Device[deviceCount].Type = DEVICE_TYPE_DUMMY;
# endif // if defined(ESP8266)
- Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_QUAD;
- Device[deviceCount].Custom = true;
- Device[deviceCount].Ports = 0;
- Device[deviceCount].PullUpOption = false;
- Device[deviceCount].InverseLogicOption = false;
- Device[deviceCount].FormulaOption = false;
- Device[deviceCount].ValueCount = 4;
- Device[deviceCount].SendDataOption = true;
- Device[deviceCount].TimerOption = true;
- Device[deviceCount].TimerOptional = true;
- Device[deviceCount].GlobalSyncOption = true;
- Device[deviceCount].DecimalsOnly = false;
+ Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_QUAD;
+ Device[deviceCount].Custom = true;
+ Device[deviceCount].Ports = 0;
+ Device[deviceCount].ValueCount = 4;
+ Device[deviceCount].SendDataOption = true;
+ Device[deviceCount].TimerOption = true;
+ Device[deviceCount].TimerOptional = true;
+ Device[deviceCount].Pin1Direction = gpio_direction::gpio_output;
break;
}
@@ -237,7 +233,8 @@ boolean Plugin_128(uint8_t function, struct EventStruct *event, String& string)
}
if (P128_CONFIG_MAX_BRIGHT == 0) { P128_CONFIG_MAX_BRIGHT = 255; } // Set to default for existing installations
- success = initPluginTaskData(event->TaskIndex, new (std::nothrow) P128_data_struct(PIN(0), P128_CONFIG_LED_COUNT, P128_CONFIG_MAX_BRIGHT));
+ success = initPluginTaskData(event->TaskIndex,
+ new (std::nothrow) P128_data_struct(PIN(0), P128_CONFIG_LED_COUNT, P128_CONFIG_MAX_BRIGHT));
break;
}
diff --git a/src/_P129_74HC165.ino b/src/_P129_74HC165.ino
index 063be7cfbc..3be2e36005 100644
--- a/src/_P129_74HC165.ino
+++ b/src/_P129_74HC165.ino
@@ -62,15 +62,11 @@ boolean Plugin_129(uint8_t function, struct EventStruct *event, String& string)
{
case PLUGIN_DEVICE_ADD:
{
- Device[++deviceCount].Number = PLUGIN_ID_129;
- Device[deviceCount].Type = DEVICE_TYPE_TRIPLE;
- Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_QUAD;
- Device[deviceCount].Ports = 0;
- Device[deviceCount].PullUpOption = false;
- Device[deviceCount].InverseLogicOption = false;
- Device[deviceCount].FormulaOption = false;
- Device[deviceCount].DecimalsOnly = false;
- Device[deviceCount].ValueCount =
+ Device[++deviceCount].Number = PLUGIN_ID_129;
+ Device[deviceCount].Type = DEVICE_TYPE_TRIPLE;
+ Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_QUAD;
+ Device[deviceCount].Ports = 0;
+ Device[deviceCount].ValueCount =
# if P129_MAX_CHIP_COUNT <= 4
1
# elif P129_MAX_CHIP_COUNT <= 8
@@ -81,10 +77,12 @@ boolean Plugin_129(uint8_t function, struct EventStruct *event, String& string)
4
# endif // if P129_MAX_CHIP_COUNT <= 4
;
- Device[deviceCount].SendDataOption = true; // No use in sending the Values to a controller
- Device[deviceCount].TimerOption = true; // Used to update the Devices page
- Device[deviceCount].TimerOptional = true;
+ Device[deviceCount].SendDataOption = true; // No use in sending the Values to a controller
+ Device[deviceCount].TimerOption = true; // Used to update the Devices page
+ Device[deviceCount].TimerOptional = true;
Device[deviceCount].HasFormatUserVar = true;
+ Device[deviceCount].Pin2Direction = gpio_direction::gpio_output;
+ Device[deviceCount].Pin3Direction = gpio_direction::gpio_output;
break;
}
diff --git a/src/_P131_NeoPixelMatrix.ino b/src/_P131_NeoPixelMatrix.ino
index f9e77e0fd4..6b6b564f2d 100644
--- a/src/_P131_NeoPixelMatrix.ino
+++ b/src/_P131_NeoPixelMatrix.ino
@@ -42,17 +42,14 @@ boolean Plugin_131(uint8_t function, struct EventStruct *event, String& string)
{
case PLUGIN_DEVICE_ADD:
{
- Device[++deviceCount].Number = PLUGIN_ID_131;
- Device[deviceCount].Type = DEVICE_TYPE_SINGLE;
- Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_NONE;
- Device[deviceCount].Ports = 0;
- Device[deviceCount].PullUpOption = false;
- Device[deviceCount].InverseLogicOption = false;
- Device[deviceCount].FormulaOption = false;
- Device[deviceCount].ValueCount = 0;
- Device[deviceCount].SendDataOption = false;
- Device[deviceCount].TimerOption = true;
- Device[deviceCount].TimerOptional = true;
+ Device[++deviceCount].Number = PLUGIN_ID_131;
+ Device[deviceCount].Type = DEVICE_TYPE_SINGLE;
+ Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_NONE;
+ Device[deviceCount].Ports = 0;
+ Device[deviceCount].ValueCount = 0;
+ Device[deviceCount].TimerOption = true;
+ Device[deviceCount].TimerOptional = true;
+ Device[deviceCount].Pin1Direction = gpio_direction::gpio_output;
break;
}
|