mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
[Cleanup] Direct initialise selection options where possible
This commit is contained in:
@@ -106,10 +106,11 @@ boolean Plugin_020(uint8_t function, struct EventStruct *event, String& string)
|
||||
serialHelper_serialconfig_webformLoad(event, serialConfChoice);
|
||||
{
|
||||
uint8_t choice = P020_SERIAL_PROCESSING;
|
||||
const __FlashStringHelper * options[3];
|
||||
options[0] = F("None");
|
||||
options[1] = F("Generic");
|
||||
options[2] = F("RFLink");
|
||||
const __FlashStringHelper * options[3] = {
|
||||
F("None"),
|
||||
F("Generic"),
|
||||
F("RFLink")
|
||||
};
|
||||
addFormSelector(F("Event processing"), F("p020_events"), 3, options, NULL, choice);
|
||||
}
|
||||
addFormNumericBox(F("RX Receive Timeout (mSec)"), F("p020_rxwait"), P020_RX_WAIT, 0, 20);
|
||||
|
||||
@@ -61,12 +61,14 @@ boolean Plugin_024(uint8_t function, struct EventStruct *event, String& string)
|
||||
#define MLX90614_OPTION 2
|
||||
|
||||
uint8_t choice = PCONFIG(0);
|
||||
const __FlashStringHelper * options[MLX90614_OPTION];
|
||||
int optionValues[MLX90614_OPTION];
|
||||
optionValues[0] = (0x07);
|
||||
options[0] = F("IR object temperature");
|
||||
optionValues[1] = (0x06);
|
||||
options[1] = F("Ambient temperature");
|
||||
const __FlashStringHelper * options[MLX90614_OPTION] = {
|
||||
F("IR object temperature"),
|
||||
F("Ambient temperature")
|
||||
};
|
||||
const int optionValues[MLX90614_OPTION] = {
|
||||
(0x07),
|
||||
(0x06)
|
||||
};
|
||||
addFormSelector(F("Option"), F("p024_option"), MLX90614_OPTION, options, optionValues, choice);
|
||||
|
||||
success = true;
|
||||
|
||||
+10
-8
@@ -283,14 +283,16 @@ boolean Plugin_036(uint8_t function, struct EventStruct *event, String& string)
|
||||
uint8_t choice = P036_CONTRAST;
|
||||
|
||||
if (choice == 0) { choice = P36_CONTRAST_HIGH; }
|
||||
const __FlashStringHelper * options[3];
|
||||
options[0] = F("Low");
|
||||
options[1] = F("Medium");
|
||||
options[2] = F("High");
|
||||
int optionValues[3];
|
||||
optionValues[0] = P36_CONTRAST_LOW;
|
||||
optionValues[1] = P36_CONTRAST_MED;
|
||||
optionValues[2] = P36_CONTRAST_HIGH;
|
||||
const __FlashStringHelper * options[3] = {
|
||||
F("Low"),
|
||||
F("Medium"),
|
||||
F("High")
|
||||
};
|
||||
const int optionValues[3] = {
|
||||
P36_CONTRAST_LOW,
|
||||
P36_CONTRAST_MED,
|
||||
P36_CONTRAST_HIGH
|
||||
};
|
||||
addFormSelector(F("Contrast"), F("p036_contrast"), 3, options, optionValues, choice);
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -146,18 +146,18 @@ boolean Plugin_042(uint8_t function, struct EventStruct *event, String& string)
|
||||
addHtml(F("<script src=\"jscolor.min.js\"></script>\n"));
|
||||
|
||||
{
|
||||
const __FlashStringHelper * options[8];
|
||||
const __FlashStringHelper * options[8] = {
|
||||
F("Off"),
|
||||
F("Static Light"),
|
||||
F("Simple Candle"),
|
||||
F("Advanced Candle"),
|
||||
F("Police"),
|
||||
F("Blink"),
|
||||
F("Strobe"),
|
||||
F("Color Fader")
|
||||
};
|
||||
// int optionValues[8];
|
||||
|
||||
options[0] = F("Off");
|
||||
options[1] = F("Static Light");
|
||||
options[2] = F("Simple Candle");
|
||||
options[3] = F("Advanced Candle");
|
||||
options[4] = F("Police");
|
||||
options[5] = F("Blink");
|
||||
options[6] = F("Strobe");
|
||||
options[7] = F("Color Fader");
|
||||
|
||||
uint8_t choice = PCONFIG(4);
|
||||
if (choice > sizeof(options) - 1)
|
||||
{
|
||||
|
||||
+12
-11
@@ -119,17 +119,18 @@ boolean Plugin_045(uint8_t function, struct EventStruct *event, String& string)
|
||||
{
|
||||
uint8_t choice = PCONFIG(1);
|
||||
{
|
||||
const __FlashStringHelper * options[10];
|
||||
options[0] = F("Movement detection");
|
||||
options[1] = F("Range acceleration X");
|
||||
options[2] = F("Range acceleration Y");
|
||||
options[3] = F("Range acceleration Z");
|
||||
options[4] = F("Acceleration X");
|
||||
options[5] = F("Acceleration Y");
|
||||
options[6] = F("Acceleration Z");
|
||||
options[7] = F("G-force X");
|
||||
options[8] = F("G-force Y");
|
||||
options[9] = F("G-force Z");
|
||||
const __FlashStringHelper * options[10] = {
|
||||
F("Movement detection"),
|
||||
F("Range acceleration X"),
|
||||
F("Range acceleration Y"),
|
||||
F("Range acceleration Z"),
|
||||
F("Acceleration X"),
|
||||
F("Acceleration Y"),
|
||||
F("Acceleration Z"),
|
||||
F("G-force X"),
|
||||
F("G-force Y"),
|
||||
F("G-force Z")
|
||||
};
|
||||
addFormSelector(F("Function"), F("p045_function"), 10, options, NULL, choice);
|
||||
}
|
||||
|
||||
|
||||
+11
-10
@@ -155,17 +155,18 @@ boolean Plugin_046(uint8_t function, struct EventStruct *event, String& string)
|
||||
uint8_t choice = PCONFIG(0);
|
||||
{
|
||||
const uint8_t nrchoices = 9;
|
||||
const __FlashStringHelper * options[nrchoices];
|
||||
options[0] = F("Main + Temp/Hygro");
|
||||
options[1] = F("Wind");
|
||||
options[2] = F("Rain");
|
||||
options[3] = F("UV");
|
||||
options[4] = F("Lightning strikes");
|
||||
options[5] = F("Lightning distance");
|
||||
const __FlashStringHelper * options[nrchoices] = {
|
||||
F("Main + Temp/Hygro"),
|
||||
F("Wind"),
|
||||
F("Rain"),
|
||||
F("UV"),
|
||||
F("Lightning strikes"),
|
||||
F("Lightning distance"),
|
||||
|
||||
options[6] = F("Unknown 1, uint8_t 6");
|
||||
options[7] = F("Unknown 2, uint8_t 16");
|
||||
options[8] = F("Unknown 3, uint8_t 19");
|
||||
F("Unknown 1, uint8_t 6"),
|
||||
F("Unknown 2, uint8_t 16"),
|
||||
F("Unknown 3, uint8_t 19"),
|
||||
};
|
||||
|
||||
addFormSelector(F("Plugin function"), F("p046"), nrchoices, options, NULL, choice);
|
||||
}
|
||||
|
||||
@@ -156,11 +156,12 @@ boolean Plugin_075(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
case PLUGIN_WEBFORM_SHOW_SERIAL_PARAMS:
|
||||
{
|
||||
const __FlashStringHelper * options[4];
|
||||
options[0] = F("9600");
|
||||
options[1] = F("38400");
|
||||
options[2] = F("57600");
|
||||
options[3] = F("115200");
|
||||
const __FlashStringHelper * options[4] = {
|
||||
F("9600"),
|
||||
F("38400"),
|
||||
F("57600"),
|
||||
F("115200")
|
||||
};
|
||||
|
||||
addFormSelector(F("Baud Rate"), F("p075_baud"), 4, options, nullptr, P075_BaudRate);
|
||||
addUnit(F("baud"));
|
||||
|
||||
+18
-16
@@ -76,22 +76,24 @@ boolean Plugin_086(uint8_t function, struct EventStruct *event, String& string)
|
||||
uint8_t choice = 0;
|
||||
String labelText;
|
||||
String keyName;
|
||||
const __FlashStringHelper * options[PLUGIN_086_VALUE_TYPES];
|
||||
options[0] = F("integer");
|
||||
options[1] = F("float");
|
||||
options[2] = F("boolean");
|
||||
options[3] = F("string");
|
||||
options[4] = F("enum");
|
||||
options[5] = F("rgb");
|
||||
options[6] = F("hsv");
|
||||
int optionValues[PLUGIN_086_VALUE_TYPES];
|
||||
optionValues[0] = PLUGIN_086_VALUE_INTEGER;
|
||||
optionValues[1] = PLUGIN_086_VALUE_FLOAT;
|
||||
optionValues[2] = PLUGIN_086_VALUE_BOOLEAN;
|
||||
optionValues[3] = PLUGIN_086_VALUE_STRING;
|
||||
optionValues[4] = PLUGIN_086_VALUE_ENUM;
|
||||
optionValues[5] = PLUGIN_086_VALUE_RGB;
|
||||
optionValues[6] = PLUGIN_086_VALUE_HSV;
|
||||
const __FlashStringHelper * options[PLUGIN_086_VALUE_TYPES] = {
|
||||
F("integer"),
|
||||
F("float"),
|
||||
F("boolean"),
|
||||
F("string"),
|
||||
F("enum"),
|
||||
F("rgb"),
|
||||
F("hsv")
|
||||
};
|
||||
const int optionValues[PLUGIN_086_VALUE_TYPES] = {
|
||||
PLUGIN_086_VALUE_INTEGER,
|
||||
PLUGIN_086_VALUE_FLOAT,
|
||||
PLUGIN_086_VALUE_BOOLEAN,
|
||||
PLUGIN_086_VALUE_STRING,
|
||||
PLUGIN_086_VALUE_ENUM,
|
||||
PLUGIN_086_VALUE_RGB,
|
||||
PLUGIN_086_VALUE_HSV
|
||||
};
|
||||
for (int i=0;i<PLUGIN_086_VALUE_MAX;i++) {
|
||||
labelText = F("Function #");
|
||||
labelText += (i+1);
|
||||
|
||||
@@ -121,12 +121,13 @@ boolean Plugin_091(uint8_t function, struct EventStruct *event, String& string)
|
||||
{
|
||||
{
|
||||
uint8_t choice = PCONFIG(0);
|
||||
const __FlashStringHelper * options[4];
|
||||
options[0] = F("Yewelink/TUYA");
|
||||
options[1] = F("Sonoff Dual");
|
||||
options[2] = F("LC TECH");
|
||||
options[3] = F("Moes Wifi Dimmer");
|
||||
int optionValues[4] = { SER_SWITCH_YEWE, SER_SWITCH_SONOFFDUAL, SER_SWITCH_LCTECH, SER_SWITCH_WIFIDIMMER };
|
||||
const __FlashStringHelper * options[4] = {
|
||||
F("Yewelink/TUYA"),
|
||||
F("Sonoff Dual"),
|
||||
F("LC TECH"),
|
||||
F("Moes Wifi Dimmer")
|
||||
};
|
||||
const int optionValues[4] = { SER_SWITCH_YEWE, SER_SWITCH_SONOFFDUAL, SER_SWITCH_LCTECH, SER_SWITCH_WIFIDIMMER };
|
||||
addFormSelector(F("Switch Type"), F("plugin_091_type"), 4, options, optionValues, choice);
|
||||
}
|
||||
|
||||
|
||||
@@ -102,12 +102,13 @@ boolean Plugin_115(uint8_t function, struct EventStruct *event, String& string)
|
||||
{
|
||||
{
|
||||
unsigned int choice = P115_DEVICESELECTOR;
|
||||
const __FlashStringHelper * options[4];
|
||||
options[0] = F("MAX17043");
|
||||
options[1] = F("MAX17044 (2S)"); // 2-cell version of the MAX17043 (full-scale range of 10V)
|
||||
options[2] = F("MAX17048");
|
||||
options[3] = F("MAX17049 (2S)"); // 2-cell version of the MAX17048
|
||||
int optionValues[4] = {
|
||||
const __FlashStringHelper * options[4] = {
|
||||
F("MAX17043"),
|
||||
F("MAX17044 (2S)"), // 2-cell version of the MAX17043 (full-scale range of 10V)
|
||||
F("MAX17048"),
|
||||
F("MAX17049 (2S)") // 2-cell version of the MAX17048
|
||||
};
|
||||
const int optionValues[4] = {
|
||||
MAX1704X_MAX17043,
|
||||
MAX1704X_MAX17044,
|
||||
MAX1704X_MAX17048,
|
||||
|
||||
@@ -131,9 +131,10 @@ void addControllerParameterForm(const ControllerSettingsStruct& ControllerSettin
|
||||
case ControllerSettingsStruct::CONTROLLER_USE_DNS:
|
||||
{
|
||||
uint8_t choice = ControllerSettings.UseDNS;
|
||||
const __FlashStringHelper * options[2];
|
||||
options[0] = F("Use IP address");
|
||||
options[1] = F("Use Hostname");
|
||||
const __FlashStringHelper * options[2] = {
|
||||
F("Use IP address"),
|
||||
F("Use Hostname")
|
||||
};
|
||||
addFormSelector(displayName, internalName, 2, options, NULL, NULL, choice, true);
|
||||
break;
|
||||
}
|
||||
@@ -195,9 +196,10 @@ void addControllerParameterForm(const ControllerSettingsStruct& ControllerSettin
|
||||
}
|
||||
case ControllerSettingsStruct::CONTROLLER_FULL_QUEUE_ACTION:
|
||||
{
|
||||
const __FlashStringHelper * options[2];
|
||||
options[0] = F("Ignore New");
|
||||
options[1] = F("Delete Oldest");
|
||||
const __FlashStringHelper * options[2] {
|
||||
F("Ignore New"),
|
||||
F("Delete Oldest")
|
||||
};
|
||||
addFormSelector(displayName, internalName, 2, options, NULL, NULL, ControllerSettings.DeleteOldest, false);
|
||||
break;
|
||||
}
|
||||
@@ -212,9 +214,10 @@ void addControllerParameterForm(const ControllerSettingsStruct& ControllerSettin
|
||||
break;
|
||||
case ControllerSettingsStruct::CONTROLLER_CHECK_REPLY:
|
||||
{
|
||||
const __FlashStringHelper * options[2];
|
||||
options[0] = F("Ignore Acknowledgement");
|
||||
options[1] = F("Check Acknowledgement");
|
||||
const __FlashStringHelper * options[2] = {
|
||||
F("Ignore Acknowledgement"),
|
||||
F("Check Acknowledgement")
|
||||
};
|
||||
addFormSelector(displayName, internalName, 2, options, NULL, NULL, ControllerSettings.MustCheckReply, false);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ void addFormExtTimeSourceSelect(const __FlashStringHelper * label, const __Flash
|
||||
addRowLabel(label);
|
||||
const __FlashStringHelper * options[5] =
|
||||
{ F("None"), F("DS1307"), F("DS3231"), F("PCF8523"), F("PCF8563")};
|
||||
int optionValues[5] = {
|
||||
const int optionValues[5] = {
|
||||
static_cast<int>(ExtTimeSource_e::None),
|
||||
static_cast<int>(ExtTimeSource_e::DS1307),
|
||||
static_cast<int>(ExtTimeSource_e::DS3231),
|
||||
@@ -381,7 +381,7 @@ void addFormLogFacilitySelect(const __FlashStringHelper * label, const __FlashSt
|
||||
const __FlashStringHelper * options[12] =
|
||||
{ F("Kernel"), F("User"), F("Daemon"), F("Message"), F("Local0"), F("Local1"),
|
||||
F("Local2"), F("Local3"), F("Local4"), F("Local5"), F("Local6"), F("Local7") };
|
||||
int optionValues[12] = { 0, 1, 3, 5, 16, 17, 18, 19, 20, 21, 22, 23 };
|
||||
const int optionValues[12] = { 0, 1, 3, 5, 16, 17, 18, 19, 20, 21, 22, 23 };
|
||||
|
||||
addSelector(id, 12, options, optionValues, NULL, choice);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user