mirror of
https://github.com/xoseperez/espurna.git
synced 2026-03-15 04:37:07 +01:00
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user