MCPcopy Create free account
hub / github.com/PricelessToolkit/MailBoxGuard / drawFrame

Method drawFrame

Code/Arduino_libraries/SSD1306/OLEDDisplayUi.cpp:300–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298}
299
300void OLEDDisplayUi::drawFrame(){
301 switch (this->state.frameState){
302 case IN_TRANSITION: {
303 float progress = 0.f;
304 if (this->ticksPerTransition > 0u) {
305 progress = (float) this->state.ticksSinceLastStateSwitch / (float) this->ticksPerTransition;
306 }
307 int16_t x = 0, y = 0, x1 = 0, y1 = 0;
308 switch(this->frameAnimationDirection){
309 case SLIDE_LEFT:
310 x = -this->display->width() * progress;
311 y = 0;
312 x1 = x + this->display->width();
313 y1 = 0;
314 break;
315 case SLIDE_RIGHT:
316 x = this->display->width() * progress;
317 y = 0;
318 x1 = x - this->display->width();
319 y1 = 0;
320 break;
321 case SLIDE_UP:
322 x = 0;
323 y = -this->display->height() * progress;
324 x1 = 0;
325 y1 = y + this->display->height();
326 break;
327 case SLIDE_DOWN:
328 default:
329 x = 0;
330 y = this->display->height() * progress;
331 x1 = 0;
332 y1 = y - this->display->height();
333 break;
334 }
335
336 // Invert animation if direction is reversed.
337 int8_t dir = this->state.frameTransitionDirection >= 0 ? 1 : -1;
338 x *= dir; y *= dir; x1 *= dir; y1 *= dir;
339
340 bool drawnCurrentFrame;
341
342
343 // Probe each frameFunction for the indicator drawn state
344 this->enableIndicator();
345 (this->frameFunctions[this->state.currentFrame])(this->display, &this->state, x, y);
346 drawnCurrentFrame = this->state.isIndicatorDrawn;
347
348 this->enableIndicator();
349 (this->frameFunctions[this->getNextFrameNumber()])(this->display, &this->state, x1, y1);
350
351 // Build up the indicatorDrawState
352 if (drawnCurrentFrame && !this->state.isIndicatorDrawn) {
353 // Drawn now but not next
354 this->indicatorDrawState = 2;
355 } else if (!drawnCurrentFrame && this->state.isIndicatorDrawn) {
356 // Not drawn now but next
357 this->indicatorDrawState = 1;

Callers 1

tickMethod · 0.95

Calls 4

enableIndicatorMethod · 0.95
getNextFrameNumberMethod · 0.95
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected