Merged Pro Mini Extender plugins

Merged Pro Mini Extender plugins
This commit is contained in:
mvdbro
2015-10-03 08:40:45 +02:00
parent 11b306f681
commit 95978f32b0
7 changed files with 69 additions and 104 deletions
-1
View File
@@ -1 +0,0 @@
// obsolete, all code moved to plugins
+1 -1
View File
@@ -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
-5
View File
@@ -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)
{
+1 -1
View File
@@ -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;
}
+64 -6
View File
@@ -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("<TR><TD>Port Type:<TD><select name='plugin_011'>");
for (byte x = 0; x < 2; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
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("<BR>");
}
}
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("<BR>");
}
}
break;
}
}
return success;
}
}
-90
View File
@@ -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("<BR>");
}
}
break;
}
}
return success;
}
+3
View File
@@ -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