Skip to content

Commit

Permalink
Update RTC before rebooting when MQTT is enabled - Fixes #45
Browse files Browse the repository at this point in the history
  • Loading branch information
t0mg committed Oct 2, 2024
1 parent 2921dac commit b31e9b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions software/wordclock/src/src/Iot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,12 @@ void Iot::updateClockFromParams_()
parseColorValue(color_value_, RgbColor(255, 255, 255)));
display_->setShowAmPm(parseBooleanValue(show_ampm_value_));
display_->setSensorSentivity(parseNumberValue(ldr_sensitivity_value_, 0, 10, 5));

updateClockRTCFromParams_();
}

void Iot::updateClockRTCFromParams_()
{
if (parseBooleanValue(ntp_enabled_value_))
{
maybeSetRTCfromNTP_();
Expand Down Expand Up @@ -610,6 +615,7 @@ void Iot::handleConfigSaved_()
DLOGLN("Configuration was updated.");
if (parseBooleanValue(mqtt_enabled_value_))
{
updateClockRTCFromParams_();
needs_reboot_ = true;
}
else
Expand Down
2 changes: 2 additions & 0 deletions software/wordclock/src/src/Iot.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class Iot
void clearTransientParams_();
// Updates word clock's state to match the current configuration values.
void updateClockFromParams_();
// Updates the RTC based on current configuration
void updateClockRTCFromParams_();
// Checks for NTP setting and if enabled, attempts to update the RTC.
void maybeSetRTCfromNTP_();
// Sets the RTC from manual input
Expand Down

0 comments on commit b31e9b5

Please sign in to comment.