forked from letscontrolit/ESPEasy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_P026_Sysinfo.ino
118 lines (108 loc) · 3.07 KB
/
_P026_Sysinfo.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//#######################################################################################################
//#################################### Plugin 026: Analog ###############################################
//#######################################################################################################
#define PLUGIN_026
#define PLUGIN_ID_026 26
#define PLUGIN_NAME_026 "System Info"
#define PLUGIN_VALUENAME1_026 ""
boolean Plugin_026(byte function, struct EventStruct *event, String& string)
{
boolean success = false;
switch (function)
{
case PLUGIN_DEVICE_ADD:
{
Device[++deviceCount].Number = PLUGIN_ID_026;
Device[deviceCount].VType = SENSOR_TYPE_SINGLE;
Device[deviceCount].ValueCount = 1;
Device[deviceCount].SendDataOption = true;
Device[deviceCount].TimerOption = true;
Device[deviceCount].FormulaOption = true;
break;
}
case PLUGIN_GET_DEVICENAME:
{
string = F(PLUGIN_NAME_026);
break;
}
case PLUGIN_GET_DEVICEVALUENAMES:
{
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_026));
break;
}
case PLUGIN_WEBFORM_LOAD:
{
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
String options[4];
options[0] = F("Uptime");
options[1] = F("Free RAM");
options[2] = F("Wifi RSSI");
options[3] = F("Input VCC");
int optionValues[4];
optionValues[0] = 0;
optionValues[1] = 1;
optionValues[2] = 2;
optionValues[3] = 3;
string += F("<TR><TD>Indicator:<TD><select name='plugin_026'>");
for (byte x = 0; x < 4; 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_026");
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
success = true;
break;
}
case PLUGIN_READ:
{
float value = 0;
switch(Settings.TaskDevicePluginConfig[event->TaskIndex][0])
{
case 0:
{
value = (wdcounter /2);
break;
}
case 1:
{
value = ESP.getFreeHeap();
break;
}
case 2:
{
value = WiFi.RSSI();
break;
}
case 3:
{
#if FEATURE_ADC_VCC
value = vcc;
#else
value = -1.0;
#endif
break;
}
}
UserVar[event->BaseVarIndex] = value;
String log = F("SYS : ");
log += value;
addLog(LOG_LEVEL_INFO,log);
success = true;
break;
}
}
return success;
}