void UpdateDisplay()

in BalancingRobot/Software/HighLevelApp/main.c [776:890]


void UpdateDisplay(uint8_t batteryLevel, bool haveNetwork, bool haveIoTC, int AppUpdateIcon)
{
    // don't update the display if we're applying an update or waiting for IMU stability.
    if (updateApplied || WaitForIMU)
        return;
    // update the display.
    SSD1306_Clear();
    memset(BatteryIcon_Rot180, 0x00, 128);

    Log_Debug("Battery: %d, Network: %s, IoTC: %s, AppUpdateIcon %d\n", batteryLevel, haveNetwork ? "Yes" : "No", haveIoTC ? "Yes" : "No", AppUpdateIcon);

    if (batteryLevel == 255)
    {
        memcpy(BatteryIcon_Rot180, low_Batt, 128);
    }
    else
    {
        if (batteryLevel > 90 && batteryLevel <= 100)
        {
            SSD1306_RotateImage(Battery_Icon100, BatteryIcon_Rot180, 32, 32, 180);
        }

        if (batteryLevel > 80 && batteryLevel <= 90)
        {
            SSD1306_RotateImage(Battery_Icon90, BatteryIcon_Rot180, 32, 32, 180);
        }

        if (batteryLevel > 70 && batteryLevel <= 80)
        {
            SSD1306_RotateImage(Battery_Icon80, BatteryIcon_Rot180, 32, 32, 180);
        }

        if (batteryLevel > 60 && batteryLevel <= 70)
        {
            SSD1306_RotateImage(Battery_Icon70, BatteryIcon_Rot180, 32, 32, 180);
        }

        if (batteryLevel > 50 && batteryLevel <= 60)
        {
            SSD1306_RotateImage(Battery_Icon60, BatteryIcon_Rot180, 32, 32, 180);
        }

        if (batteryLevel > 40 && batteryLevel <= 50)
        {
            SSD1306_RotateImage(Battery_Icon50, BatteryIcon_Rot180, 32, 32, 180);
        }

        if (batteryLevel > 30 && batteryLevel <= 40)
        {
            SSD1306_RotateImage(Battery_Icon40, BatteryIcon_Rot180, 32, 32, 180);
        }

        if (batteryLevel > 20 && batteryLevel <= 30)
        {
            SSD1306_RotateImage(Battery_Icon30, BatteryIcon_Rot180, 32, 32, 180);
        }

        if (batteryLevel > 10 && batteryLevel <= 20)
        {
            SSD1306_RotateImage(Battery_Icon20, BatteryIcon_Rot180, 32, 32, 180);
        }

        if (batteryLevel > 0 && batteryLevel <= 10)
        {
            SSD1306_RotateImage(Battery_Icon10, BatteryIcon_Rot180, 32, 32, 180);
        }

        if (batteryLevel == 0)
        {
            SSD1306_RotateImage(Battery_Icon00, BatteryIcon_Rot180, 32, 32, 180);
        }
    }
    SSD1306_DrawImage(&BatteryIcon_Rot180[0], 32, 32, 96, 0);

    if (haveNetwork)
    {
        SSD1306_DrawImage(&WiFiIcon_Rot180[0], 32, 32, 64, 0);
    }
    else
    {
        SSD1306_DrawImage(&not_WiFi[0], 32, 32, 64, 0);
    }

    if (haveIoTC)
    {
        SSD1306_DrawImage(&IotcIcon_Rot180[0], 32, 32, 32, 0);
    }
    else
    {
        SSD1306_DrawImage(&not_IoTC[0], 32, 32, 32, 0);
    }

    if (updateDeferred)
    {
        SSD1306_DrawImage(&Update_Icon_Defer_Rejected_Rot180[0], 32, 32, 0, 0);
    }
    else
    {
        switch (AppUpdateIcon) {
        case UpdateApp:
            SSD1306_DrawImage(&UpdateIcon_Rot180[0], 32, 32, 0, 0);
            break;
        case AppA:
            SSD1306_DrawImage(&AppA_Rot180[0], 32, 32, 0, 0);
            break;
        case AppB:
            SSD1306_DrawImage(&AppB_Rot180[0], 32, 32, 0, 0);
            break;
        default:
            break;
        }
    }

    SSD1306_Display();
}