fix(ui,cpn): Error in value conversion when loading LS data (#3026)

* Fix error in value conversion when loading logical switch data from YAML files (for 'Edge' and 'Timer' functions).

* Remove debug print.

* Fix handling of telemetry sensors in Companion.
This commit is contained in:
philmoz
2023-01-17 14:35:13 +10:00
committed by GitHub
parent 0610449c82
commit 7dc2f89917
3 changed files with 4 additions and 4 deletions
@@ -47,7 +47,7 @@ static int timerValue2lsw(uint32_t t)
{
if (t < 20) {
return t - 129;
} else if (600) {
} else if (t < 600) {
return t / 5 - 113;
} else {
return t / 10 - 53;
@@ -71,7 +71,7 @@ std::string YamlRawSwitchEncode(const RawSwitch& rhs)
case SWITCH_TYPE_SENSOR:
sw_str += "T";
sw_str += std::to_string(sval + 1);
sw_str += std::to_string(sval);
break;
default:
@@ -131,7 +131,7 @@ RawSwitch YamlRawSwitchDecode(const std::string& sw_str)
// starts at T1
int sensor_idx = std::stoi(sw_str_tmp.substr(1, val_len - 1));
if ((sensor_idx > 0) && (sensor_idx <= CPN_MAX_SENSORS)) {
rhs = RawSwitch(SWITCH_TYPE_SENSOR, sensor_idx - 1);
rhs = RawSwitch(SWITCH_TYPE_SENSOR, sensor_idx);
}
} else if (sw_str_tmp.substr(0, 4) == std::string("Trim")) {
@@ -1647,7 +1647,7 @@ static delayval_t timerValue2lsw(uint32_t t)
{
if (t < 20) {
return t - 129;
} else if (600) {
} else if (t < 600) {
return t / 5 - 113;
} else {
return t / 10 - 53;