Call SunPosition.isDayPeriod() once

This commit is contained in:
Stefan Oberhumer 2024-01-23 09:31:05 +01:00
parent a5cc0a424f
commit 7aece2e143

View File

@ -106,6 +106,7 @@ void InverterSettingsClass::init(Scheduler& scheduler)
void InverterSettingsClass::settingsLoop() void InverterSettingsClass::settingsLoop()
{ {
const CONFIG_T& config = Configuration.get(); const CONFIG_T& config = Configuration.get();
const bool isDayPeriod = SunPosition.isDayPeriod();
for (uint8_t i = 0; i < INV_MAX_COUNT; i++) { for (uint8_t i = 0; i < INV_MAX_COUNT; i++) {
auto const& inv_cfg = config.Inverter[i]; auto const& inv_cfg = config.Inverter[i];
@ -117,8 +118,8 @@ void InverterSettingsClass::settingsLoop()
continue; continue;
} }
inv->setEnablePolling(inv_cfg.Poll_Enable && (SunPosition.isDayPeriod() || inv_cfg.Poll_Enable_Night)); inv->setEnablePolling(inv_cfg.Poll_Enable && (isDayPeriod || inv_cfg.Poll_Enable_Night));
inv->setEnableCommands(inv_cfg.Command_Enable && (SunPosition.isDayPeriod() || inv_cfg.Command_Enable_Night)); inv->setEnableCommands(inv_cfg.Command_Enable && (isDayPeriod || inv_cfg.Command_Enable_Night));
} }
} }