Load ratios after boot + show pwr defaults with get (#2241)

* emon: configure ratios without reboot

* settings: serialize() support

* debug: use vsnprintf from newlib, not from sdk

* settings/experimental: show defaults via `get`

* emon: override base methods, fix defaults

* sensor/emon: expose internal index calculation

- refactor configuration to use the correct index when accessing indexed
  sensor methods. store index value on magnitude, refactor loops to
  accomodate this new functionality
- rename slot(index) -> description(index), since we use 'slot' as
  numeric value
This commit is contained in:
Max Prokhorov
2020-05-12 21:17:01 +03:00
committed by GitHub
parent a2a44c28d4
commit 025e8c82ab
53 changed files with 562 additions and 245 deletions

View File

@@ -42,6 +42,21 @@ debounce_event::types::Mode convert(const String& value) {
}
}
template<>
String serialize(const debounce_event::types::Mode& value) {
String result;
switch (value) {
case debounce_event::types::Mode::Switch:
result = "1";
break;
case debounce_event::types::Mode::Pushbutton:
default:
result = "0";
break;
}
return result;
}
template<>
debounce_event::types::PinValue convert(const String& value) {
switch (value.toInt()) {
@@ -53,6 +68,21 @@ debounce_event::types::PinValue convert(const String& value) {
}
}
template<>
String serialize(const debounce_event::types::PinValue& value) {
String result;
switch (value) {
case debounce_event::types::PinValue::Low:
result = "0";
break;
case debounce_event::types::PinValue::High:
default:
result = "1";
break;
}
return result;
}
template<>
debounce_event::types::PinMode convert(const String& value) {
switch (value.toInt()) {
@@ -66,6 +96,24 @@ debounce_event::types::PinMode convert(const String& value) {
}
}
template<>
String serialize(const debounce_event::types::PinMode& mode) {
String result;
switch (mode) {
case debounce_event::types::PinMode::InputPullup:
result = "1";
break;
case debounce_event::types::PinMode::InputPulldown:
result = "2";
break;
case debounce_event::types::PinMode::Input:
default:
result = "0";
break;
}
return result;
}
} // namespace settings::internal
} // namespace settings