fix potential overflow on uptime 2nd try (#21966)

* fix potential overflow

* fix potential overflow

* fix overflow on millis()

* fix overflow on millis()

* Update xdrv_27_shutter.ino

---------

Co-authored-by: Theo Arends <11044339+arendst@users.noreply.github.com>
This commit is contained in:
stefanbode 2024-08-15 14:28:10 +02:00 committed by GitHub
parent 1b24378da5
commit 6d2647fd5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -1383,7 +1383,8 @@ void ShutterUpdateVelocity(uint8_t i)
void ShutterWaitForMotorStart(uint8_t i) void ShutterWaitForMotorStart(uint8_t i)
{ {
while (millis() < Shutter[i].last_stop_time + ShutterSettings.shutter_motorstop) { uint32_t start_time = Shutter[i].last_stop_time;
while (TimePassedSince(start_time) < ShutterSettings.shutter_motorstop && TimePassedSince(start_time) > 0) {
loop(); loop();
} }
//AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Stoptime done")); //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Stoptime done"));

View File

@ -654,7 +654,8 @@ void ShutterWaitForMotorStop(uint8_t i)
void ShutterWaitForMotorStart(uint8_t i) void ShutterWaitForMotorStart(uint8_t i)
{ {
while (millis() < Shutter[i].last_stop_time + Settings->shutter_motorstop) { uint32_t start_time = Shutter[i].last_stop_time;
while (TimePassedSince(start_time) < Settings->shutter_motorstop && TimePassedSince(start_time) > 0) {
loop(); loop();
} }
//AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Stoptime done")); //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Stoptime done"));