feat(F-040,F-041,F-042): relay.set_config, output numbering fix, clock batch commands

Enforce 1-based output numbering throughout the entire stack. Stored values,
MQTT wire format, and console UI are all 1-based; the single 0-based conversion
happens only in OutputManager::getPhysicalOutput(). Fixed createDefaultBellConfig
(was setting identity 0-based map instead of 0=disabled), updateBellDurations and
updateBellOutputs (support both v2 0/1 and v1 b1/b2 keys), all call
sites that bypassed getPhysicalOutput, and fireClockOutput conversion.

New commands:
- relay.set_config: combined durations + outputs in one round trip (F-040)
- clock.set_config: enabled/c1/c2/pulse_duration/pause_duration in one call (F-042)
- clock.set_alerts_config: alert type, bells, and silence windows in one call (F-042)

Feature catalog updated with F-040, F-041, F-042 detail sections.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-07-12 18:44:52 +03:00
co-authored by Claude Sonnet 4.6
parent a5395b0de7
commit 0ac63e82ed
8 changed files with 241 additions and 68 deletions
+40
View File
@@ -49,6 +49,9 @@ Every feature — user-facing or significant internal mechanism — is listed he
| F-037 | Network status extended (SSID + MAC in `network.status`) | v2.1.0 | Stable |
| F-038 | Bell test fire commands (`relay.test_bell` / `relay.test_batch`) | v2.1.0 | Stable |
| F-039 | Clock output test fire commands (`clock.test_c1` / `clock.test_c2`) | v2.1.0 | Stable |
| F-040 | Combined relay config command (`relay.set_config`) | v2.1.1 | Stable |
| F-041 | Output numbering convention enforced — 1-based everywhere except raw chip pin | v2.1.1 | Stable |
| F-042 | Combined clock config commands (`clock.set_config` / `clock.set_alerts_config`) | v2.1.1 | Stable |
---
@@ -526,3 +529,40 @@ Both use `OutputManager::fireClockOutput()` which resolves the physical pin from
`ClockHandler` constructor now accepts an optional `OutputManager*` (defaults to `nullptr`); the router passes `_outputManager` so the test commands are live when the output manager is registered.
Subsystem: `src/Communication/Handlers/ClockHandler/ClockHandler.cpp`
---
### F-040 — Combined relay config command (`relay.set_config`)
Single command that sets bell durations and/or output assignments in one round trip, replacing the need to send `relay.set_durations` + `relay.set_outputs` separately. Both `durations` and `outputs` fields are optional — at least one must be present. Partial updates accepted (only the fields provided are changed).
Subsystem: `src/Communication/Handlers/RelayHandler/RelayHandler.cpp`
---
### F-041 — Output numbering convention enforced — 1-based everywhere except raw chip pin
Bell outputs are stored and communicated as **1-based numbers** throughout the entire stack (config, MQTT protocol, console UI). The single conversion to 0-based chip pin index happens only in `OutputManager::getPhysicalOutput()`, which subtracts 1 immediately before calling the hardware driver.
`0` = disabled. `255` = unconfigured sentinel (internal only, never sent over wire).
All call sites (BellEngine, RelayHandler test commands, TimeKeeper alerts) now go through `getPhysicalOutput()` rather than calling `fireOutputForDuration()` with a raw stored value. `relay.test_output` is the sole exception — it is a raw hardware diagnostic that intentionally takes a 0-based chip pin directly, and is documented as such.
`createDefaultBellConfig()` initialised outputs to `i` (0-based identity map) — corrected to `0` (all disabled).
Subsystems: `src/OutputManager/OutputManager.cpp`, `src/ConfigManager/ConfigManager.cpp`, `src/Communication/Handlers/RelayHandler/RelayHandler.cpp`, `src/TimeKeeper/TimeKeeper.cpp`
---
### F-042 — Combined clock config commands (`clock.set_config` / `clock.set_alerts_config`)
Two batch commands that each collapse multiple individual clock commands into one round trip:
| Command | Replaces |
|---|---|
| `clock.set_config` | `clock.enable/disable` + `clock.set_outputs` + `clock.set_timings` |
| `clock.set_alerts_config` | `clock.set_alerts` + `clock.set_silence` |
All fields optional — at least one required. Single `saveClockConfig()` call per command regardless of how many fields are set.
Subsystem: `src/Communication/Handlers/ClockHandler/ClockHandler.cpp`
@@ -14,6 +14,7 @@ std::vector<String> ClockHandler::commands() const {
return {
"clock.set_outputs", "clock.set_timings", "clock.set_alerts",
"clock.set_backlight", "clock.set_silence",
"clock.set_config", "clock.set_alerts_config",
"clock.set_time", "clock.set_face",
"clock.set_timezone", "clock.get_timezone", "clock.sync_ntp",
"clock.enable", "clock.disable",
@@ -24,9 +25,11 @@ std::vector<String> ClockHandler::commands() const {
}
CommandResult ClockHandler::execute(const CommandEnvelope& envelope) {
if (envelope.command == "clock.set_outputs") return handleSetOutputs(envelope);
if (envelope.command == "clock.set_timings") return handleSetTimings(envelope);
if (envelope.command == "clock.set_alerts") return handleSetAlerts(envelope);
if (envelope.command == "clock.set_outputs") return handleSetOutputs(envelope);
if (envelope.command == "clock.set_timings") return handleSetTimings(envelope);
if (envelope.command == "clock.set_alerts") return handleSetAlerts(envelope);
if (envelope.command == "clock.set_config") return handleSetConfig(envelope);
if (envelope.command == "clock.set_alerts_config") return handleSetAlertsConfig(envelope);
if (envelope.command == "clock.set_backlight") return handleSetBacklight(envelope);
if (envelope.command == "clock.set_silence") return handleSetSilence(envelope);
if (envelope.command == "clock.set_time") return handleSetTime(envelope);
@@ -277,4 +280,92 @@ CommandResult ClockHandler::handleTestC2(const CommandEnvelope& e) {
return CommandResult::ok("clock.test_c2", doc);
}
CommandResult ClockHandler::handleSetConfig(const CommandEnvelope& e) {
JsonVariantConst c = e.contents.as<JsonVariantConst>();
bool hasEnabled = c["enabled"].is<bool>();
bool hasC1 = c["c1"].is<int>();
bool hasC2 = c["c2"].is<int>();
bool hasPulseDuration = c["pulse_duration"].is<int>();
bool hasPauseDuration = c["pause_duration"].is<int>();
if (!hasEnabled && !hasC1 && !hasC2 && !hasPulseDuration && !hasPauseDuration) {
return CommandResult::err("clock.set_config",
"Provide at least one field: enabled, c1, c2, pulse_duration, pause_duration");
}
if (hasEnabled) _configManager.setClockEnabled(c["enabled"].as<bool>());
if (hasC1 || hasC2) {
JsonDocument tmp;
if (hasC1) tmp["c1output"] = c["c1"].as<int>();
if (hasC2) tmp["c2output"] = c["c2"].as<int>();
_configManager.updateClockOutputs(tmp.as<JsonVariant>());
}
if (hasPulseDuration) _configManager.setClockPulseDuration(c["pulse_duration"].as<uint16_t>());
if (hasPauseDuration) _configManager.setClockPauseDuration(c["pause_duration"].as<uint16_t>());
if (!_configManager.saveClockConfig()) {
return CommandResult::err("clock.set_config", "Settings applied but failed to save to SD");
}
LOG_INFO(TAG, "clock.set_config applied");
return CommandResult::ok("clock.set_config", "Clock configuration updated and saved");
}
CommandResult ClockHandler::handleSetAlertsConfig(const CommandEnvelope& e) {
JsonVariantConst c = e.contents.as<JsonVariantConst>();
bool hasAlerts = c["alert_type"].is<JsonVariantConst>() ||
c["alert_interval"].is<JsonVariantConst>() ||
c["hour_bell"].is<JsonVariantConst>() ||
c["half_bell"].is<JsonVariantConst>() ||
c["quarter_bell"].is<JsonVariantConst>();
bool hasSilence = c["daytime_silence"].is<JsonVariantConst>() ||
c["daytime_on"].is<JsonVariantConst>() ||
c["daytime_off"].is<JsonVariantConst>() ||
c["night_silence"].is<JsonVariantConst>() ||
c["night_on"].is<JsonVariantConst>() ||
c["night_off"].is<JsonVariantConst>();
if (!hasAlerts && !hasSilence) {
return CommandResult::err("clock.set_alerts_config",
"Provide at least one of: alert_type, alert_interval, hour_bell, half_bell, quarter_bell, "
"daytime_silence, daytime_on, daytime_off, night_silence, night_on, night_off");
}
if (hasAlerts) {
// Map wire-format snake_case keys to what updateClockAlerts expects (camelCase)
JsonDocument alertsDoc;
if (c["alert_type"].is<JsonVariantConst>()) alertsDoc["alertType"] = c["alert_type"];
if (c["alert_interval"].is<JsonVariantConst>()) alertsDoc["alertRingInterval"] = c["alert_interval"];
if (c["hour_bell"].is<JsonVariantConst>()) alertsDoc["hourBell"] = c["hour_bell"];
if (c["half_bell"].is<JsonVariantConst>()) alertsDoc["halfBell"] = c["half_bell"];
if (c["quarter_bell"].is<JsonVariantConst>()) alertsDoc["quarterBell"] = c["quarter_bell"];
_configManager.updateClockAlerts(alertsDoc.as<JsonVariant>());
}
if (hasSilence) {
// Map wire-format flat keys to nested structure that updateClockSilence expects
JsonDocument silenceDoc;
if (c["daytime_silence"].is<JsonVariantConst>() || c["daytime_on"].is<JsonVariantConst>() || c["daytime_off"].is<JsonVariantConst>()) {
JsonObject dt = silenceDoc["daytime"].to<JsonObject>();
if (c["daytime_silence"].is<JsonVariantConst>()) dt["enabled"] = c["daytime_silence"];
if (c["daytime_on"].is<JsonVariantConst>()) dt["onTime"] = c["daytime_on"];
if (c["daytime_off"].is<JsonVariantConst>()) dt["offTime"] = c["daytime_off"];
}
if (c["night_silence"].is<JsonVariantConst>() || c["night_on"].is<JsonVariantConst>() || c["night_off"].is<JsonVariantConst>()) {
JsonObject nt = silenceDoc["nighttime"].to<JsonObject>();
if (c["night_silence"].is<JsonVariantConst>()) nt["enabled"] = c["night_silence"];
if (c["night_on"].is<JsonVariantConst>()) nt["onTime"] = c["night_on"];
if (c["night_off"].is<JsonVariantConst>()) nt["offTime"] = c["night_off"];
}
_configManager.updateClockSilence(silenceDoc.as<JsonVariant>());
}
if (!_configManager.saveClockConfig()) {
return CommandResult::err("clock.set_alerts_config", "Settings applied but failed to save to SD");
}
LOG_INFO(TAG, "clock.set_alerts_config applied");
return CommandResult::ok("clock.set_alerts_config", "Clock alerts and silence configuration updated and saved");
}
#endif // HAS_RTC
@@ -39,6 +39,8 @@ private:
CommandResult handleGetConfig(const CommandEnvelope& e);
CommandResult handleTestC1(const CommandEnvelope& e);
CommandResult handleTestC2(const CommandEnvelope& e);
CommandResult handleSetConfig(const CommandEnvelope& e);
CommandResult handleSetAlertsConfig(const CommandEnvelope& e);
};
#endif // HAS_RTC
@@ -11,7 +11,7 @@ RelayHandler::RelayHandler(ConfigManager& configManager, OutputManager& outputMa
std::vector<String> RelayHandler::commands() const {
return {
"relay.set_durations", "relay.set_outputs", "relay.get_config",
"relay.set_durations", "relay.set_outputs", "relay.set_config", "relay.get_config",
"relay.test_output", "relay.test_bell", "relay.test_batch"
};
}
@@ -19,6 +19,7 @@ std::vector<String> RelayHandler::commands() const {
CommandResult RelayHandler::execute(const CommandEnvelope& envelope) {
if (envelope.command == "relay.set_durations") return handleSetDurations(envelope);
if (envelope.command == "relay.set_outputs") return handleSetOutputs(envelope);
if (envelope.command == "relay.set_config") return handleSetConfig(envelope);
if (envelope.command == "relay.get_config") return handleGetConfig(envelope);
if (envelope.command == "relay.test_output") return handleTestOutput(envelope);
if (envelope.command == "relay.test_bell") return handleTestBell(envelope);
@@ -56,6 +57,34 @@ CommandResult RelayHandler::handleSetOutputs(const CommandEnvelope& e) {
return CommandResult::ok("relay.set_outputs", "Bell outputs updated and saved");
}
CommandResult RelayHandler::handleSetConfig(const CommandEnvelope& e) {
JsonVariant contents = const_cast<JsonDocument&>(e.contents).as<JsonVariant>();
bool hasDurations = contents["durations"].is<JsonObject>();
bool hasOutputs = contents["outputs"].is<JsonObject>();
if (!hasDurations && !hasOutputs) {
return CommandResult::err("relay.set_config", "Provide 'durations' and/or 'outputs' objects");
}
if (hasDurations) {
_configManager.updateBellDurations(contents["durations"].as<JsonVariant>());
if (!_configManager.saveBellDurations()) {
return CommandResult::err("relay.set_config", "Durations applied but failed to save to SD");
}
}
if (hasOutputs) {
_configManager.updateBellOutputs(contents["outputs"].as<JsonVariant>());
if (!_configManager.saveBellOutputs()) {
return CommandResult::err("relay.set_config", "Outputs applied but failed to save to SD");
}
}
LOG_INFO(TAG, "relay.config applied (durations=%d outputs=%d)", hasDurations, hasOutputs);
return CommandResult::ok("relay.set_config", "Bell configuration updated and saved");
}
CommandResult RelayHandler::handleGetConfig(const CommandEnvelope& e) {
JsonDocument doc;
JsonObject durations = doc["durations"].to<JsonObject>();
@@ -104,15 +133,19 @@ CommandResult RelayHandler::handleTestBell(const CommandEnvelope& e) {
return CommandResult::err("relay.test_bell", "bell must be 0-15");
}
uint8_t output = (uint8_t)_configManager.getBellOutput(bell);
uint8_t output = _outputManager.getPhysicalOutput((uint8_t)bell);
uint16_t durationMs = _configManager.getBellDuration(bell);
if (output == 255) {
return CommandResult::err("relay.test_bell", "Bell " + String(bell) + " is disabled or unconfigured");
}
_outputManager.fireOutputForDuration(output, durationMs);
LOG_INFO(TAG, "Test bell %d → output %d for %d ms", bell, output, durationMs);
LOG_INFO(TAG, "Test bell %d → chip pin %d for %d ms", bell, output, durationMs);
JsonDocument doc;
doc["bell"] = bell;
doc["output"] = output;
doc["output"] = output + 1; // 1-based for human readability
doc["duration_ms"] = durationMs;
return CommandResult::ok("relay.test_bell", doc);
}
@@ -134,8 +167,9 @@ CommandResult RelayHandler::handleTestBatch(const CommandEnvelope& e) {
if (!v.is<int>()) continue;
int bell = v.as<int>();
if (bell < 0 || bell > 15) continue;
uint8_t output = (uint8_t)_configManager.getBellOutput((uint8_t)bell);
uint8_t output = _outputManager.getPhysicalOutput((uint8_t)bell);
uint16_t durationMs = _configManager.getBellDuration((uint8_t)bell);
if (output == 255) continue; // disabled/unconfigured — skip silently
_outputManager.fireOutputForDuration(output, durationMs);
fired++;
}
@@ -21,6 +21,7 @@ private:
CommandResult handleSetDurations(const CommandEnvelope& e);
CommandResult handleSetOutputs(const CommandEnvelope& e);
CommandResult handleSetConfig(const CommandEnvelope& e);
CommandResult handleGetConfig(const CommandEnvelope& e);
CommandResult handleTestOutput(const CommandEnvelope& e);
CommandResult handleTestBell(const CommandEnvelope& e);
+15 -11
View File
@@ -54,10 +54,9 @@ void ConfigManager::generateNetworkIdentifiers() {
}
void ConfigManager::createDefaultBellConfig() {
// Initialize default durations (90ms for all bells)
for (uint8_t i = 0; i < 16; i++) {
bellConfig.durations[i] = 90;
bellConfig.outputs[i] = i; // 0-indexed mapping
bellConfig.outputs[i] = 0; // 0 = disabled (1-based scheme: 1=first relay, 0=none)
}
}
@@ -433,7 +432,7 @@ bool ConfigManager::loadBellOutputs() {
for (uint8_t i = 0; i < 16; i++) {
String key = String("b") + (i + 1);
if (doc.containsKey(key)) {
bellConfig.outputs[i] = doc[key].as<uint16_t>(); // Already 0-indexed in file
bellConfig.outputs[i] = doc[key].as<uint16_t>(); // 1-based: 1=first relay, 0=disabled
}
}
@@ -450,7 +449,7 @@ bool ConfigManager::saveBellOutputs() {
StaticJsonDocument<512> doc;
for (uint8_t i = 0; i < 16; i++) {
String key = String("b") + (i + 1);
doc[key] = bellConfig.outputs[i]; // Save 0-indexed outputs
doc[key] = bellConfig.outputs[i]; // 1-based: 1=first relay, 0=disabled
}
char buffer[512];
@@ -510,9 +509,12 @@ bool ConfigManager::saveBellConfigToNVS() {
void ConfigManager::updateBellDurations(JsonVariant doc) {
for (uint8_t i = 0; i < 16; i++) {
String key = String("b") + (i + 1);
if (doc.containsKey(key)) {
bellConfig.durations[i] = doc[key].as<uint16_t>();
String v2key = String(i); // v2: "0", "1", ...
String v1key = String("b") + (i + 1); // v1: "b1", "b2", ...
if (doc.containsKey(v2key)) {
bellConfig.durations[i] = doc[v2key].as<uint16_t>();
} else if (doc.containsKey(v1key)) {
bellConfig.durations[i] = doc[v1key].as<uint16_t>();
}
}
LOG_DEBUG(TAG, "ConfigManager - Updated bell durations");
@@ -520,10 +522,12 @@ void ConfigManager::updateBellDurations(JsonVariant doc) {
void ConfigManager::updateBellOutputs(JsonVariant doc) {
for (uint8_t i = 0; i < 16; i++) {
String key = String("b") + (i + 1);
if (doc.containsKey(key)) {
bellConfig.outputs[i] = doc[key].as<uint16_t>() - 1;
LOG_DEBUG(TAG, "ConfigManager - Bell %d output set to %d", i + 1, bellConfig.outputs[i]);
String v2key = String(i); // v2: "0", "1", ...
String v1key = String("b") + (i + 1); // v1: "b1", "b2", ...
if (doc.containsKey(v2key)) {
bellConfig.outputs[i] = doc[v2key].as<uint16_t>();
} else if (doc.containsKey(v1key)) {
bellConfig.outputs[i] = doc[v1key].as<uint16_t>();
}
}
LOG_DEBUG(TAG, "ConfigManager - Updated bell outputs");
+46 -47
View File
@@ -77,21 +77,20 @@ uint8_t OutputManager::getPhysicalOutput(uint8_t virtualOutput) const {
return virtualOutput;
}
// Get 0-indexed bell output from config
// Config stores 1-based output numbers (1=first relay, 0=disabled, 255=unconfigured).
// Convert to 0-based chip index here — this is the single conversion point.
uint16_t bellOutput = _configManager->getBellOutput(virtualOutput);
// Handle unconfigured bells (255 = disabled)
if (bellOutput == 255) {
LOG_WARNING(TAG, "⚠️ Bell %d not configured (255)", virtualOutput);
return 255; // Return invalid to prevent firing
if (bellOutput == 0 || bellOutput == 255) {
LOG_WARNING(TAG, "⚠️ Bell %d is disabled or unconfigured (stored=%d)", virtualOutput, bellOutput);
return 255;
}
// Physical output is already 0-indexed from config
uint8_t physicalOutput = (uint8_t)bellOutput;
LOG_DEBUG(TAG, "🔗 Bell %d → 0-indexed output %d",
virtualOutput, physicalOutput);
uint8_t physicalOutput = (uint8_t)(bellOutput - 1);
LOG_DEBUG(TAG, "🔗 Bell %d → Output %d → chip pin %d",
virtualOutput + 1, bellOutput, physicalOutput);
return physicalOutput;
}
@@ -115,28 +114,25 @@ void OutputManager::fireClockOutput(uint8_t virtualOutput, uint16_t durationMs)
return;
}
// Map virtual clock output to physical output using clock configuration
uint8_t physicalOutput;
// Map virtual clock output to physical output using clock configuration.
// Config stores 1-based output numbers — convert to 0-based chip index here.
uint8_t storedOutput;
if (virtualOutput == 0) {
// Virtual clock output 0 = C1
physicalOutput = _configManager->getClockOutput1();
if (physicalOutput == 255) {
LOG_WARNING(TAG, "⚠️ Clock C1 not configured (255)");
return;
}
storedOutput = _configManager->getClockOutput1();
} else if (virtualOutput == 1) {
// Virtual clock output 1 = C2
physicalOutput = _configManager->getClockOutput2();
if (physicalOutput == 255) {
LOG_WARNING(TAG, "⚠️ Clock C2 not configured (255)");
return;
}
storedOutput = _configManager->getClockOutput2();
} else {
LOG_ERROR(TAG, "❌ Invalid virtual clock output: %d (only 0=C1, 1=C2 supported)", virtualOutput);
return;
}
// Physical output is already 0-indexed from config
if (storedOutput == 0 || storedOutput == 255) {
LOG_WARNING(TAG, "⚠️ Clock C%d is disabled or unconfigured (stored=%d)", virtualOutput + 1, storedOutput);
return;
}
uint8_t physicalOutput = storedOutput - 1;
if (!isValidPhysicalOutput(physicalOutput)) {
LOG_ERROR(TAG, "❌ Invalid physical output for clock: %d (max outputs: %d)",
physicalOutput, getMaxOutputs());
@@ -146,8 +142,8 @@ void OutputManager::fireClockOutput(uint8_t virtualOutput, uint16_t durationMs)
// Fire the physical output directly
fireOutputForDuration(physicalOutput, durationMs);
LOG_DEBUG(TAG, "🕐 FIRE Clock Virtual %d (C%d) → 0-indexed output %d for %dms",
virtualOutput, virtualOutput + 1, physicalOutput, durationMs);
LOG_DEBUG(TAG, "🕐 FIRE Clock C%d → Output %d → chip pin %d for %dms",
virtualOutput + 1, storedOutput, physicalOutput, durationMs);
}
// ==================== PCF8574/PCF8575 MULTI-CHIP IMPLEMENTATION ====================
@@ -203,32 +199,35 @@ bool PCF8574OutputManager::initialize() {
if (_configManager) {
LOG_INFO(TAG, "📋 Virtual Output Configuration Mappings:");
for (uint8_t i = 0; i < min(16, (int)_totalOutputs); i++) { // Check virtual outputs
uint16_t configOutput = _configManager->getBellOutput(i);
if (configOutput < _totalOutputs) {
VirtualOutputInfo info = getVirtualOutputInfo(configOutput);
LOG_DEBUG(TAG, " Bell %d → Virtual Output %d → %s[%d] Pin %d", i, configOutput, info.chipType, info.chipIndex, info.localPin);
} else if (configOutput == 255) {
LOG_DEBUG(TAG, " Bell %d → Not configured (255)", i);
for (uint8_t i = 0; i < min(16, (int)_totalOutputs); i++) {
uint16_t configOutput = _configManager->getBellOutput(i); // 1-based
if (configOutput == 0 || configOutput == 255) {
LOG_DEBUG(TAG, " Bell %d → Disabled/unconfigured", i + 1);
} else {
LOG_WARNING(TAG, "⚠️ Bell %d mapped to invalid virtual output %d (max: %d)", i, configOutput, _totalOutputs - 1);
uint8_t chipPin = (uint8_t)(configOutput - 1); // convert to 0-based
if (chipPin < _totalOutputs) {
VirtualOutputInfo info = getVirtualOutputInfo(chipPin);
LOG_DEBUG(TAG, " Bell %d → Output %d → %s[%d] Pin %d", i + 1, configOutput, info.chipType, info.chipIndex, info.localPin);
} else {
LOG_WARNING(TAG, "⚠️ Bell %d mapped to invalid output %d (max: %d)", i + 1, configOutput, _totalOutputs);
}
}
}
uint8_t c1 = _configManager->getClockOutput1();
uint8_t c2 = _configManager->getClockOutput2();
uint8_t c1 = _configManager->getClockOutput1(); // 1-based
uint8_t c2 = _configManager->getClockOutput2(); // 1-based
LOG_INFO(TAG, "🕐 Clock Virtual Output Mappings:");
if (c1 != 255 && c1 < _totalOutputs) {
VirtualOutputInfo info = getVirtualOutputInfo(c1);
LOG_DEBUG(TAG, " Clock C1 → Virtual Output %d → %s[%d] Pin %d", c1, info.chipType, info.chipIndex, info.localPin);
if (c1 > 0 && c1 != 255 && (uint8_t)(c1 - 1) < _totalOutputs) {
VirtualOutputInfo info = getVirtualOutputInfo(c1 - 1);
LOG_DEBUG(TAG, " Clock C1 → Output %d → %s[%d] Pin %d", c1, info.chipType, info.chipIndex, info.localPin);
} else {
LOG_DEBUG(TAG, " Clock C1 → Not configured");
}
if (c2 != 255 && c2 < _totalOutputs) {
VirtualOutputInfo info = getVirtualOutputInfo(c2);
LOG_DEBUG(TAG, " Clock C2 → Virtual Output %d → %s[%d] Pin %d", c2, info.chipType, info.chipIndex, info.localPin);
if (c2 > 0 && c2 != 255 && (uint8_t)(c2 - 1) < _totalOutputs) {
VirtualOutputInfo info = getVirtualOutputInfo(c2 - 1);
LOG_DEBUG(TAG, " Clock C2 → Output %d → %s[%d] Pin %d", c2, info.chipType, info.chipIndex, info.localPin);
} else {
LOG_DEBUG(TAG, " Clock C2 → Not configured");
}
+4 -2
View File
@@ -693,8 +693,10 @@ void Timekeeper::fireAlertBell(uint8_t bellNumber, int count) {
LOG_DEBUG(TAG, "🔔 Alert bell #%d ring %d/%d (duration: %dms)",
bellNumber + 1, i + 1, count, bellDuration);
// Fire the bell using OutputManager
_outputManager->fireOutputForDuration(bellNumber, bellDuration);
// bellNumber is a 0-based bell index — resolve to chip pin through the single conversion point
uint8_t chipPin = _outputManager->getPhysicalOutput(bellNumber);
if (chipPin == 255) return; // bell disabled or unconfigured
_outputManager->fireOutputForDuration(chipPin, bellDuration);
// Wait between rings (only if there's more than one ring)
if (i < count - 1) {