| 226 | } |
| 227 | |
| 228 | int16_t OLEDDisplayUi::update(){ |
| 229 | #ifdef ARDUINO |
| 230 | unsigned long frameStart = millis(); |
| 231 | #elif __MBED__ |
| 232 | Timer t; |
| 233 | t.start(); |
| 234 | unsigned long frameStart = t.read_ms(); |
| 235 | #else |
| 236 | #error "Unkown operating system" |
| 237 | #endif |
| 238 | int32_t timeBudget = this->updateInterval - (frameStart - this->state.lastUpdate); |
| 239 | if ( timeBudget <= 0) { |
| 240 | // Implement frame skipping to ensure time budget is kept |
| 241 | if (this->autoTransition && this->state.lastUpdate != 0) this->state.ticksSinceLastStateSwitch += ceil((double)-timeBudget / (double)this->updateInterval); |
| 242 | |
| 243 | this->state.lastUpdate = frameStart; |
| 244 | this->tick(); |
| 245 | } |
| 246 | #ifdef ARDUINO |
| 247 | return this->updateInterval - (millis() - frameStart); |
| 248 | #elif __MBED__ |
| 249 | return this->updateInterval - (t.read_ms() - frameStart); |
| 250 | #else |
| 251 | #error "Unkown operating system" |
| 252 | #endif |
| 253 | } |
| 254 | |
| 255 | |
| 256 | void OLEDDisplayUi::tick() { |