From 0952be3141fb5bf6fabee9cdd30ae624caf475ee Mon Sep 17 00:00:00 2001 From: Emanuele Trabattoni Date: Sat, 30 Aug 2025 10:55:40 +0200 Subject: [PATCH] fix HPlimits pin ordering and introduce pin naming map --- include/pinlist.h | 52 +++++++++++++++++++++++++++++++++++++++++------ src/commands.cpp | 6 ++---- src/commands.h | 2 +- 3 files changed, 49 insertions(+), 11 deletions(-) diff --git a/include/pinlist.h b/include/pinlist.h index eba9118..d2e0054 100644 --- a/include/pinlist.h +++ b/include/pinlist.h @@ -2,10 +2,10 @@ enum RO // relay output channels { - P1 = 0, - P2 = 1, - P3 = 2, - P4 = 3, + P4 = 0, + P3 = 1, + P2 = 2, + P1 = 3, RO_4 = 4, FST_FLOOR = 5, GND_FLOOR = 6, @@ -21,6 +21,25 @@ enum RO // relay output channels RO_MAX = 16 // unused to detect invalid values }; +static const std::map RO_2str = { + {RO::P1, "HPLimite1"}, + {RO::P2, "HPLimite2"}, + {RO::P3, "HPLimite3"}, + {RO::P4, "HPLimite4"}, + {RO::RO_4, "Out4"}, + {RO::FST_FLOOR, "PianoPrimo"}, + {RO::GND_FLOOR, "PianoTerra"}, + {RO::PUMP_HT, "PompaRisc"}, + {RO::PUMP_IRR, "PompaIrr"}, + {RO::RETURN, "Ricircolo"}, + {RO::ZONE1, "IrrZona1"}, + {RO::ZONE2, "IrrZona2"}, + {RO::ZONE3, "IrrZona3"}, + {RO::DRIP, "IrrDrip"}, + {RO::RO_14, "Out14"}, + {RO::RO_15, "Out15"}, + {RO::RO_MAX, "Invalid"}}; + enum DI // digital input channels { CONFRESET = 0, @@ -28,6 +47,7 @@ enum DI // digital input channels DI_2 = 2, DI_3 = 3, DI_4 = 4, + DI_5 = 5, DI_6 = 6, OTAENABLE = 7, PUMP_PRESSURE = 8, @@ -38,5 +58,25 @@ enum DI // digital input channels DI_13 = 13, DI_14 = 14, DI_15 = 15, - DI_MAX = 16 -}; // unused to detect invalid values + DI_MAX = 16 // unused to detect invalid values +}; + +static const std::map DI_2str = + { + {DI::CONFRESET, "ConfigReset"}, + {DI::RESTART, "Restart"}, + {DI::DI_2, "In2"}, + {DI::DI_3, "In3"}, + {DI::DI_4, "In4"}, + {DI::DI_5, "In5"}, + {DI::DI_6, "In6"}, + {DI::OTAENABLE, "OtaEnable"}, + {DI::PUMP_PRESSURE, "IrrPumpPressure"}, + {DI::RAIN, "IrrRainSensor"}, + {DI::IRR_OVERRIDE, "IrrRainOverride"}, + {DI::DI_11, "In11"}, + {DI::DI_12, "In12"}, + {DI::DI_13, "In13"}, + {DI::DI_14, "In14"}, + {DI::DI_15, "In15"}, + {DI::DI_MAX, "Invalid"}}; diff --git a/src/commands.cpp b/src/commands.cpp index 99e4a32..9399476 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -457,8 +457,7 @@ namespace commands uint8_t i(0); for (auto s : inStatus) { - const std::string k("DI" + std::to_string(i)); - response["values"][k.c_str()] = s; + response["values"][DI_2str.at(i++)] = s; } LOG_INFO("getInputStatus ->", printBoolVec(inStatus).c_str()); return response; @@ -476,8 +475,7 @@ namespace commands uint8_t i(0); for (auto s : inStatus) { - const std::string k("DO" + std::to_string(i)); - response["values"][k.c_str()] = s; + response["values"][RO_2str.at(i++)] = s; } LOG_INFO("getOutputStatus ->", printBoolVec(inStatus).c_str()); return response; diff --git a/src/commands.h b/src/commands.h index cd5c876..f617a6f 100644 --- a/src/commands.h +++ b/src/commands.h @@ -109,4 +109,4 @@ namespace commands {"setTimeNTP", Commands::setTimeNTP}, }; -} \ No newline at end of file +}