void dashboardInit(void) { static busDevice_t dashBoardBus; dashBoardBus.i2c.device = I2C_CFG_TO_DEV(dashboardConfig()->device); dashBoardBus.i2c.address = dashboardConfig()->address; bus = &dashBoardBus; delay(200); resetDisplay(); delay(200); displayPort = displayPortOledInit(bus); #if defined(CMS) if (dashboardPresent) { cmsDisplayPortRegister(displayPort); } #endif memset(&pageState, 0, sizeof(pageState)); dashboardSetPage(PAGE_WELCOME); uint32_t now = micros(); dashboardUpdate(now); dashboardSetNextPageChangeAt(now + PAGE_CYCLE_FREQUENCY); }
void dashboardInit(void) { delay(200); resetDisplay(); delay(200); displayPort = displayPortOledInit(); #if defined(CMS) cmsDisplayPortRegister(displayPort); #endif dashboardSetPage(PAGE_WELCOME); const timeUs_t now = micros(); dashboardSetNextPageChangeAt(now + 5 * MICROSECONDS_IN_A_SECOND); dashboardUpdate(now); }
void dashboardShowFixedPage(pageId_e pageId) { dashboardSetPage(pageId); dashboardDisablePageCycling(); }
void dashboardUpdate(timeUs_t currentTimeUs) { static uint8_t previousArmedState = 0; #ifdef CMS if (displayIsGrabbed(displayPort)) { return; } #endif const bool updateNow = (int32_t)(currentTimeUs - nextDisplayUpdateAt) >= 0L; if (!updateNow) { return; } nextDisplayUpdateAt = currentTimeUs + DISPLAY_UPDATE_FREQUENCY; bool armedState = ARMING_FLAG(ARMED) ? true : false; bool armedStateChanged = armedState != previousArmedState; previousArmedState = armedState; if (armedState) { if (!armedStateChanged) { return; } dashboardSetPage(PAGE_ARMED); pageState.pageChanging = true; } else { if (armedStateChanged) { pageState.pageFlags |= PAGE_STATE_FLAG_FORCE_PAGE_CHANGE; } pageState.pageChanging = (pageState.pageFlags & PAGE_STATE_FLAG_FORCE_PAGE_CHANGE) || (((int32_t)(currentTimeUs - pageState.nextPageAt) >= 0L && (pageState.pageFlags & PAGE_STATE_FLAG_CYCLE_ENABLED))); if (pageState.pageChanging && (pageState.pageFlags & PAGE_STATE_FLAG_CYCLE_ENABLED)) { do { pageState.cycleIndex++; pageState.cycleIndex = pageState.cycleIndex % PAGE_COUNT; pageState.page = &pages[pageState.cycleIndex]; } while (pageState.page->flags & PAGE_FLAGS_SKIP_CYCLING); } } if (pageState.pageChanging) { pageState.pageFlags &= ~PAGE_STATE_FLAG_FORCE_PAGE_CHANGE; pageState.nextPageAt = currentTimeUs + PAGE_CYCLE_FREQUENCY; // Some OLED displays do not respond on the first initialisation so refresh the display // when the page changes in the hopes the hardware responds. This also allows the // user to power off/on the display or connect it while powered. resetDisplay(); if (!dashboardPresent) { return; } handlePageChange(); } if (!dashboardPresent) { return; } pageState.page->drawFn(); if (!armedState) { updateFailsafeStatus(); updateRxStatus(); updateTicker(); } }