From 95978f32b0d90f3de81f98ccbd853478daeead70 Mon Sep 17 00:00:00 2001 From: mvdbro Date: Sat, 3 Oct 2015 08:40:45 +0200 Subject: [PATCH] Merged Pro Mini Extender plugins Merged Pro Mini Extender plugins --- Devices.ino | 1 - ESPEasy.ino | 2 +- Serial.ino | 5 -- _P009_MCP.ino | 2 +- _P011_PMD.ino => _P011_PME.ino | 70 +++++++++++++++++++++++--- _P012_PMA.ino | 90 ---------------------------------- __ReleaseNotes.ino | 3 ++ 7 files changed, 69 insertions(+), 104 deletions(-) delete mode 100644 Devices.ino rename _P011_PMD.ino => _P011_PME.ino (54%) delete mode 100644 _P012_PMA.ino diff --git a/Devices.ino b/Devices.ino deleted file mode 100644 index 4e2f074778..0000000000 --- a/Devices.ino +++ /dev/null @@ -1 +0,0 @@ -// obsolete, all code moved to plugins diff --git a/ESPEasy.ino b/ESPEasy.ino index 061e117be6..350eeb0f42 100644 --- a/ESPEasy.ino +++ b/ESPEasy.ino @@ -79,7 +79,7 @@ #define ESP_PROJECT_PID 2015050101L #define ESP_EASY #define VERSION 9 -#define BUILD 27 +#define BUILD 28 #define REBOOT_ON_MAX_CONNECTION_FAILURES 30 #define FEATURE_SPIFFS false diff --git a/Serial.ino b/Serial.ino index dd84db0e79..3daa8d0718 100644 --- a/Serial.ino +++ b/Serial.ino @@ -20,11 +20,6 @@ void ExecuteCommand(char *Line) // commands for debugging // **************************************** - if (strcasecmp_P(Command, PSTR("Pullup")) == 0) - { - Plugin_009_Config(18, 1); - } - #if FEATURE_SPIFFS if (strcasecmp_P(Command, PSTR("format")) == 0) { diff --git a/_P009_MCP.ino b/_P009_MCP.ino index 3d6c64f71c..420066c837 100644 --- a/_P009_MCP.ino +++ b/_P009_MCP.ino @@ -23,7 +23,7 @@ boolean Plugin_009(byte function, struct EventStruct *event, String& string) Device[deviceCount].Ports = 16; Device[deviceCount].PullUpOption = false; Device[deviceCount].InverseLogicOption = false; - Device[deviceCount].FormulaOption = true; + Device[deviceCount].FormulaOption = false; Device[deviceCount].ValueCount = 1; break; } diff --git a/_P011_PMD.ino b/_P011_PME.ino similarity index 54% rename from _P011_PMD.ino rename to _P011_PME.ino index 85c545a4e3..f6fb0c3444 100644 --- a/_P011_PMD.ino +++ b/_P011_PME.ino @@ -1,11 +1,11 @@ //####################################################################################################### -//#################################### Plugin 011: Pro Mini Digital ##################################### +//#################################### Plugin 011: Pro Mini Extender #################################### //####################################################################################################### #define PLUGIN_011 #define PLUGIN_ID_011 11 -#define PLUGIN_NAME_011 "ProMini Extender Digital" -#define PLUGIN_VALUENAME1_011 "Switch" +#define PLUGIN_NAME_011 "ProMini Extender" +#define PLUGIN_VALUENAME1_011 "Value" boolean Plugin_011(byte function, struct EventStruct *event, String& string) { @@ -38,11 +38,49 @@ boolean Plugin_011(byte function, struct EventStruct *event, String& string) break; } + case PLUGIN_WEBFORM_LOAD: + { + byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][0]; + String options[2]; + options[0] = F("Digital"); + options[1] = F("Analog"); + int optionValues[2]; + optionValues[0] = 0; + optionValues[1] = 1; + string += F("Port Type:"); + + success = true; + break; + } + + case PLUGIN_WEBFORM_SAVE: + { + String plugin1 = WebServer.arg("plugin_011"); + Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt(); + success = true; + break; + } + case PLUGIN_READ: { uint8_t address = 0x7f; Wire.beginTransmission(address); - Wire.write(2); // Digital Read + if (Settings.TaskDevicePluginConfig[event->TaskIndex][0] == 0) + Wire.write(2); // Digital Read + else + Wire.write(4); // Analog Read Wire.write(Settings.TaskDevicePort[event->TaskIndex]); Wire.write(0); Wire.write(0); @@ -51,7 +89,7 @@ boolean Plugin_011(byte function, struct EventStruct *event, String& string) Wire.requestFrom(address, (uint8_t)0x1); if (Wire.available()) UserVar[event->BaseVarIndex] = Wire.read(); - Serial.print(F("PMD : Digital: ")); + Serial.print(F("PMini: PortValue: ")); Serial.println(UserVar[event->BaseVarIndex]); success = true; break; @@ -82,8 +120,28 @@ boolean Plugin_011(byte function, struct EventStruct *event, String& string) printWebString += F("
"); } } + + if (tmpString.equalsIgnoreCase("EXTPWM")) + { + success = true; + uint8_t address = 0x7f; + Wire.beginTransmission(address); + Wire.write(3); + Wire.write(event->Par1); + Wire.write(event->Par2 & 0xff); + Wire.write((event->Par2 >> 8)); + Wire.endTransmission(); + if (printToWeb) + { + printWebString += F("EXTPWM "); + printWebString += event->Par1; + printWebString += F(" Set to "); + printWebString += event->Par2; + printWebString += F("
"); + } + } break; } } return success; -} +} diff --git a/_P012_PMA.ino b/_P012_PMA.ino deleted file mode 100644 index a3dabcd5cc..0000000000 --- a/_P012_PMA.ino +++ /dev/null @@ -1,90 +0,0 @@ -//####################################################################################################### -//#################################### Plugin 012: Pro Mini Analog ###################################### -//####################################################################################################### - -#define PLUGIN_012 -#define PLUGIN_ID_012 12 -#define PLUGIN_NAME_012 "ProMini Extender Analog" -#define PLUGIN_VALUENAME1_012 "Analog" - -boolean Plugin_012(byte function, struct EventStruct *event, String& string) -{ - boolean success = false; - - switch (function) - { - - case PLUGIN_DEVICE_ADD: - { - Device[++deviceCount].Number = PLUGIN_ID_012; - Device[deviceCount].Type = DEVICE_TYPE_I2C; - Device[deviceCount].VType = SENSOR_TYPE_SINGLE; - Device[deviceCount].Ports = 6; - Device[deviceCount].PullUpOption = false; - Device[deviceCount].InverseLogicOption = false; - Device[deviceCount].FormulaOption = true; - Device[deviceCount].ValueCount = 1; - break; - } - - case PLUGIN_GET_DEVICENAME: - { - string = F(PLUGIN_NAME_012); - break; - } - - case PLUGIN_GET_DEVICEVALUENAMES: - { - strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_012)); - break; - } - - case PLUGIN_READ: - { - uint8_t address = 0x7f; - Wire.beginTransmission(address); - Wire.write(4); // ADC Read - Wire.write(Settings.TaskDevicePort[event->TaskIndex]); - Wire.write(0); - Wire.write(0); - Wire.endTransmission(); - delay(1); // remote unit needs some time to do the adc stuff - Wire.requestFrom(address, (uint8_t)0x1); - if (Wire.available()) - UserVar[event->BaseVarIndex] = Wire.read(); - Serial.print(F("PMADC: Analog: ")); - Serial.println(UserVar[event->BaseVarIndex]); - success = true; - break; - } - - case PLUGIN_WRITE: - { - String tmpString = string; - int argIndex = tmpString.indexOf(','); - if (argIndex) - tmpString = tmpString.substring(0, argIndex); - if (tmpString.equalsIgnoreCase("EXTPWM")) - { - success = true; - uint8_t address = 0x7f; - Wire.beginTransmission(address); - Wire.write(3); - Wire.write(event->Par1); - Wire.write(event->Par2 & 0xff); - Wire.write((event->Par2 >> 8)); - Wire.endTransmission(); - if (printToWeb) - { - printWebString += F("EXTPWM "); - printWebString += event->Par1; - printWebString += F(" Set to "); - printWebString += event->Par2; - printWebString += F("
"); - } - } - break; - } - } - return success; -} diff --git a/__ReleaseNotes.ino b/__ReleaseNotes.ino index cfcdfd27ed..92b3f10a09 100644 --- a/__ReleaseNotes.ino +++ b/__ReleaseNotes.ino @@ -1,3 +1,6 @@ +// R28 03-10-2015 +// Merged Pro Mini extender plugins into one single plugin + // R27 02-10-2015 // Changed MCP23017 plugin to scan inputs realtime instead of using the system timer mechanism // Changed MCP23017 default pullup resistors on input pins