void showBatteryPage(void) { uint8_t rowIndex = PAGE_TITLE_LINE_COUNT; if (feature(FEATURE_VBAT)) { tfp_sprintf(lineBuffer, "Volts: %d.%1d Cells: %d", vbat / 10, vbat % 10, batteryCellCount); padLineBuffer(); i2c_OLED_set_line(rowIndex++); i2c_OLED_send_string(lineBuffer); uint8_t batteryPercentage = calculateBatteryPercentage(); i2c_OLED_set_line(rowIndex++); drawHorizonalPercentageBar(SCREEN_CHARACTER_COLUMN_COUNT, batteryPercentage); } if (feature(FEATURE_CURRENT_METER)) { tfp_sprintf(lineBuffer, "Amps: %d.%2d mAh: %d", amperage / 100, amperage % 100, mAhDrawn); padLineBuffer(); i2c_OLED_set_line(rowIndex++); i2c_OLED_send_string(lineBuffer); uint8_t capacityPercentage = calculateBatteryCapacityRemainingPercentage(); i2c_OLED_set_line(rowIndex++); drawHorizonalPercentageBar(SCREEN_CHARACTER_COLUMN_COUNT, capacityPercentage); } }
static void sendFuelLevel(void) { sendDataHead(ID_FUEL_LEVEL); if (batteryConfig->batteryCapacity > 0) { serialize16((uint16_t)calculateBatteryCapacityRemainingPercentage()); } else { serialize16((uint16_t)constrain(mAhDrawn, 0, 0xFFFF)); } }
static void applyLedFixedLayers() { for (int ledIndex = 0; ledIndex < ledCounts.count; ledIndex++) { const ledConfig_t *ledConfig = ¤tLedStripConfig->ledConfigs[ledIndex]; hsvColor_t color = *getSC(LED_SCOLOR_BACKGROUND); int fn = ledGetFunction(ledConfig); int hOffset = HSV_HUE_MAX; switch (fn) { case LED_FUNCTION_COLOR: color = currentLedStripConfig->colors[ledGetColor(ledConfig)]; break; case LED_FUNCTION_FLIGHT_MODE: for (unsigned i = 0; i < ARRAYLEN(flightModeToLed); i++) if (!flightModeToLed[i].flightMode || FLIGHT_MODE(flightModeToLed[i].flightMode)) { hsvColor_t *directionalColor = getDirectionalModeColor(ledIndex, ¤tLedStripConfig->modeColors[flightModeToLed[i].ledMode]); if (directionalColor) { color = *directionalColor; } break; // stop on first match } break; case LED_FUNCTION_ARM_STATE: color = ARMING_FLAG(ARMED) ? *getSC(LED_SCOLOR_ARMED) : *getSC(LED_SCOLOR_DISARMED); break; case LED_FUNCTION_BATTERY: color = HSV(RED); hOffset += scaleRange(calculateBatteryCapacityRemainingPercentage(), 0, 100, -30, 120); break; case LED_FUNCTION_RSSI: color = HSV(RED); hOffset += scaleRange(rssi * 100, 0, 1023, -30, 120); break; default: break; } if (ledGetOverlayBit(ledConfig, LED_OVERLAY_THROTTLE)) { hOffset += scaledAux; } color.h = (color.h + hOffset) % (HSV_HUE_MAX + 1); setLedHsv(ledIndex, &color); } }
static void showStatusPage(void) { uint8_t rowIndex = PAGE_TITLE_LINE_COUNT; if (feature(FEATURE_VBAT)) { i2c_OLED_set_line(rowIndex++); tfp_sprintf(lineBuffer, "V: %d.%1d ", vbat / 10, vbat % 10); padLineBufferToChar(12); i2c_OLED_send_string(lineBuffer); uint8_t batteryPercentage = calculateBatteryPercentage(); drawHorizonalPercentageBar(10, batteryPercentage); } if (feature(FEATURE_CURRENT_METER)) { i2c_OLED_set_line(rowIndex++); tfp_sprintf(lineBuffer, "mAh: %d", mAhDrawn); padLineBufferToChar(12); i2c_OLED_send_string(lineBuffer); uint8_t capacityPercentage = calculateBatteryCapacityRemainingPercentage(); drawHorizonalPercentageBar(10, capacityPercentage); } #ifdef GPS if (feature(FEATURE_GPS)) { tfp_sprintf(lineBuffer, "Sats: %d", gpsSol.numSat); padHalfLineBuffer(); i2c_OLED_set_line(rowIndex); i2c_OLED_send_string(lineBuffer); tfp_sprintf(lineBuffer, "Fix: %s", gpsFixTypeText[gpsSol.fixType]); padHalfLineBuffer(); i2c_OLED_set_xy(HALF_SCREEN_CHARACTER_COLUMN_COUNT, rowIndex++); i2c_OLED_send_string(lineBuffer); tfp_sprintf(lineBuffer, "HDOP: %d.%1d", gpsSol.hdop / 100, gpsSol.hdop % 100); padLineBuffer(); i2c_OLED_set_line(rowIndex++); i2c_OLED_send_string(lineBuffer); tfp_sprintf(lineBuffer, "La/Lo: %d/%d", gpsSol.llh.lat / GPS_DEGREES_DIVIDER, gpsSol.llh.lon / GPS_DEGREES_DIVIDER); padLineBuffer(); i2c_OLED_set_line(rowIndex++); i2c_OLED_send_string(lineBuffer); } #endif #ifdef MAG if (sensors(SENSOR_MAG)) { tfp_sprintf(lineBuffer, "HDG: %d", DECIDEGREES_TO_DEGREES(attitude.values.yaw)); padHalfLineBuffer(); i2c_OLED_set_line(rowIndex); i2c_OLED_send_string(lineBuffer); } #endif #ifdef BARO if (sensors(SENSOR_BARO)) { int32_t alt = baroCalculateAltitude(); tfp_sprintf(lineBuffer, "Alt: %d", alt / 100); padHalfLineBuffer(); i2c_OLED_set_xy(HALF_SCREEN_CHARACTER_COLUMN_COUNT, rowIndex); i2c_OLED_send_string(lineBuffer); } #endif rowIndex++; char rollTrim[7], pitchTrim[7]; formatTrimDegrees(rollTrim, boardAlignment()->rollDeciDegrees); formatTrimDegrees(pitchTrim, boardAlignment()->pitchDeciDegrees); tfp_sprintf(lineBuffer, "Acc: %sR, %sP", rollTrim, pitchTrim ); i2c_OLED_set_line(rowIndex++); i2c_OLED_send_string(lineBuffer); }