File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -159,8 +159,11 @@ void DisplayApp::InitHw() {
159159TickType_t DisplayApp::CalculateSleepTime () {
160160 TickType_t ticksElapsed = xTaskGetTickCount () - alwaysOnStartTime;
161161 // Divide both the numerator and denominator by 8 to increase the number of ticks (frames) before the overflow tick is reached
162- TickType_t elapsedTarget = ROUNDED_DIV ((configTICK_RATE_HZ / 8 ) * alwaysOnTickCount * alwaysOnRefreshPeriod, 1000 / 8 );
163- // ROUNDED_DIV overflows when numerator + (denominator floordiv 2) > uint32 max
162+ auto RoundedDiv = [](uint32_t a, uint32_t b) {
163+ return ((a + (b / 2 )) / b);
164+ };
165+ TickType_t elapsedTarget = RoundedDiv ((configTICK_RATE_HZ / 8 ) * alwaysOnTickCount * alwaysOnRefreshPeriod, 1000 / 8 );
166+ // RoundedDiv overflows when numerator + (denominator floordiv 2) > uint32 max
164167 // in this case around 9 hours
165168 constexpr TickType_t overflowTick = (UINT32_MAX - (1000 / 16 )) / ((configTICK_RATE_HZ / 8 ) * alwaysOnRefreshPeriod);
166169
You can’t perform that action at this time.
0 commit comments