void targetConfiguration(void) { voltageSensorADCConfigMutable(VOLTAGE_SENSOR_ADC_VBAT)->vbatscale = VBAT_SCALE; barometerConfigMutable()->baro_hardware = 0; compassConfigMutable()->mag_hardware = 0; osdConfigMutable()->item_pos[OSD_MAIN_BATT_VOLTAGE] = OSD_POS(12, 1) | VISIBLE_FLAG; }
void pgResetFn_osdConfig(osdConfig_t *osdConfig) { // Position elements near centre of screen and disabled by default for (int i = 0; i < OSD_ITEM_COUNT; i++) { osdConfig->item_pos[i] = OSD_POS(10, 7); } // Always enable warnings elements by default osdConfig->item_pos[OSD_WARNINGS] = OSD_POS(9, 10) | VISIBLE_FLAG; // Default to old fixed positions for these elements osdConfig->item_pos[OSD_CROSSHAIRS] = OSD_POS(13, 6); osdConfig->item_pos[OSD_ARTIFICIAL_HORIZON] = OSD_POS(14, 2); osdConfig->item_pos[OSD_HORIZON_SIDEBARS] = OSD_POS(14, 6); // Enable the default stats osdConfig->enabled_stats = 0; // reset all to off and enable only a few initially osdStatSetState(OSD_STAT_MAX_SPEED, true); osdStatSetState(OSD_STAT_MIN_BATTERY, true); osdStatSetState(OSD_STAT_MIN_RSSI, true); osdStatSetState(OSD_STAT_MAX_CURRENT, true); osdStatSetState(OSD_STAT_USED_MAH, true); osdStatSetState(OSD_STAT_BLACKBOX, true); osdStatSetState(OSD_STAT_BLACKBOX_NUMBER, true); osdStatSetState(OSD_STAT_TIMER_2, true); osdConfig->units = OSD_UNIT_METRIC; // Enable all warnings by default for (int i=0; i < OSD_WARNING_COUNT; i++) { osdWarnSetState(i, true); } osdConfig->timers[OSD_TIMER_1] = OSD_TIMER(OSD_TIMER_SRC_ON, OSD_TIMER_PREC_SECOND, 10); osdConfig->timers[OSD_TIMER_2] = OSD_TIMER(OSD_TIMER_SRC_TOTAL_ARMED, OSD_TIMER_PREC_SECOND, 10); osdConfig->rssi_alarm = 20; osdConfig->cap_alarm = 2200; osdConfig->alt_alarm = 100; // meters or feet depend on configuration osdConfig->esc_temp_alarm = ESC_TEMP_ALARM_OFF; // off by default osdConfig->esc_rpm_alarm = ESC_RPM_ALARM_OFF; // off by default osdConfig->esc_current_alarm = ESC_CURRENT_ALARM_OFF; // off by default osdConfig->core_temp_alarm = 70; // a temperature above 70C should produce a warning, lockups have been reported above 80C osdConfig->ahMaxPitch = 20; // 20 degrees osdConfig->ahMaxRoll = 40; // 40 degrees }
void targetConfiguration(void) { pinioConfigMutable()->ioTag[0] = IO_TAG(OSD_CH_SWITCH); pinioConfigMutable()->config[0] = PINIO_CONFIG_MODE_OUT_PP; // Default state is LOW voltageSensorADCConfigMutable(VOLTAGE_SENSOR_ADC_VBAT)->vbatscale = VBAT_SCALE; barometerConfigMutable()->baro_hardware = 0; compassConfigMutable()->mag_hardware = 0; osdConfigMutable()->item_pos[OSD_MAIN_BATT_VOLTAGE] = OSD_POS(12, 1) | OSD_PROFILE_1_FLAG; }
void osdInit(displayPort_t *osdDisplayPortToUse) { if (!osdDisplayPortToUse) { return; } BUILD_BUG_ON(OSD_POS_MAX != OSD_POS(31,31)); osdDisplayPort = osdDisplayPortToUse; #ifdef USE_CMS cmsDisplayPortRegister(osdDisplayPort); #endif armState = ARMING_FLAG(ARMED); memset(blinkBits, 0, sizeof(blinkBits)); displayClearScreen(osdDisplayPort); osdDrawLogo(3, 1); char string_buffer[30]; tfp_sprintf(string_buffer, "V%s", FC_VERSION_STRING); displayWrite(osdDisplayPort, 20, 6, string_buffer); #ifdef USE_CMS displayWrite(osdDisplayPort, 7, 8, CMS_STARTUP_HELP_TEXT1); displayWrite(osdDisplayPort, 11, 9, CMS_STARTUP_HELP_TEXT2); displayWrite(osdDisplayPort, 11, 10, CMS_STARTUP_HELP_TEXT3); #endif #ifdef USE_RTC_TIME char dateTimeBuffer[FORMATTED_DATE_TIME_BUFSIZE]; if (osdFormatRtcDateTime(&dateTimeBuffer[0])) { displayWrite(osdDisplayPort, 5, 12, dateTimeBuffer); } #endif displayResync(osdDisplayPort); resumeRefreshAt = micros() + (4 * REFRESH_1S); }
void resetOsdConfig(osd_profile_t *osdProfile) { osdProfile->item_pos[OSD_RSSI_VALUE] = OSD_POS(22, 0) | VISIBLE_FLAG; osdProfile->item_pos[OSD_MAIN_BATT_VOLTAGE] = OSD_POS(12, 0) | VISIBLE_FLAG; osdProfile->item_pos[OSD_ARTIFICIAL_HORIZON] = OSD_POS(8, 6) | VISIBLE_FLAG; osdProfile->item_pos[OSD_HORIZON_SIDEBARS] = OSD_POS(8, 6) | VISIBLE_FLAG; osdProfile->item_pos[OSD_ONTIME] = OSD_POS(22, 11) | VISIBLE_FLAG; osdProfile->item_pos[OSD_FLYTIME] = OSD_POS(22, 12) | VISIBLE_FLAG; osdProfile->item_pos[OSD_FLYMODE] = OSD_POS(12, 11) | VISIBLE_FLAG; osdProfile->item_pos[OSD_CRAFT_NAME] = OSD_POS(12, 12); osdProfile->item_pos[OSD_THROTTLE_POS] = OSD_POS(1, 4); osdProfile->item_pos[OSD_VTX_CHANNEL] = OSD_POS(8, 6); osdProfile->item_pos[OSD_CURRENT_DRAW] = OSD_POS(1, 3); osdProfile->item_pos[OSD_MAH_DRAWN] = OSD_POS(15, 3); osdProfile->item_pos[OSD_GPS_SPEED] = OSD_POS(2, 2); osdProfile->item_pos[OSD_GPS_SATS] = OSD_POS(2, 12); osdProfile->item_pos[OSD_ALTITUDE] = OSD_POS(1, 5); osdProfile->rssi_alarm = 20; osdProfile->cap_alarm = 2200; osdProfile->time_alarm = 10; // in minutes osdProfile->alt_alarm = 100; // meters or feet depend on configuration osdProfile->video_system = 0; }
void osdUpdate(uint32_t currentTime) { static uint8_t rcDelay = BUTTON_TIME; static uint8_t lastSec = 0; uint8_t key = 0, sec; // detect enter to menu if (IS_MID(THROTTLE) && IS_HI(YAW) && IS_HI(PITCH) && !ARMING_FLAG(ARMED)) osdOpenMenu(); // detect arm/disarm if (armState != ARMING_FLAG(ARMED)) { if (ARMING_FLAG(ARMED)) osdArmMotors(); // reset statistic etc else osdShowStats(); // show statistic armState = ARMING_FLAG(ARMED); } osdUpdateStats(); sec = currentTime / 1000000; if (ARMING_FLAG(ARMED) && sec != lastSec) { flyTime++; lastSec = sec; } if (refreshTimeout) { if (IS_HI(THROTTLE) || IS_HI(PITCH)) // hide statistics refreshTimeout = 1; refreshTimeout--; if (!refreshTimeout) max7456ClearScreen(); return; } blinkState = (millis() / 200) % 2; if (inMenu) { if (rcDelay) { rcDelay--; } else if (IS_HI(PITCH)) { key = KEY_UP; rcDelay = BUTTON_TIME; } else if (IS_LO(PITCH)) { key = KEY_DOWN; rcDelay = BUTTON_TIME; } else if (IS_LO(ROLL)) { key = KEY_LEFT; rcDelay = BUTTON_TIME; } else if (IS_HI(ROLL)) { key = KEY_RIGHT; rcDelay = BUTTON_TIME; } else if ((IS_HI(YAW) || IS_LO(YAW)) && currentMenu != menuRc) // this menu is used to check transmitter signals so can exit using YAW { key = KEY_ESC; rcDelay = BUTTON_TIME; } if (key && !currentElement) { rcDelay = osdHandleKey(key); return; } if (currentElement) // edit position of element { if (key) { if (key == KEY_ESC) { // exit osdMenuBack(); rcDelay = BUTTON_PAUSE; *currentElement &= ~BLINK_FLAG; currentElement = NULL; return; } else { uint8_t x, y; x = OSD_X(*currentElement); y = OSD_Y(*currentElement); switch (key) { case KEY_UP: y--; break; case KEY_DOWN: y++; break; case KEY_RIGHT: x++; break; case KEY_LEFT: x--; break; } *currentElement &= 0xFC00; *currentElement |= OSD_POS(x, y); max7456ClearScreen(); } } osdDrawElements(); } else osdDrawMenu(); } else { osdUpdateAlarms(); osdDrawElements(); } }
void targetConfiguration(void) { if (hardwareMotorType == MOTOR_BRUSHED) { motorConfigMutable()->dev.motorPwmRate = BRUSHED_MOTORS_PWM_RATE; motorConfigMutable()->minthrottle = 1030; pidConfigMutable()->pid_process_denom = 1; } for (uint8_t pidProfileIndex = 0; pidProfileIndex < PID_PROFILE_COUNT; pidProfileIndex++) { pidProfile_t *pidProfile = pidProfilesMutable(pidProfileIndex); pidProfile->pid[PID_ROLL].P = 86; pidProfile->pid[PID_ROLL].I = 50; pidProfile->pid[PID_ROLL].D = 60; pidProfile->pid[PID_PITCH].P = 90; pidProfile->pid[PID_PITCH].I = 55; pidProfile->pid[PID_PITCH].D = 60; pidProfile->pid[PID_YAW].P = 123; pidProfile->pid[PID_YAW].I = 75; } for (uint8_t rateProfileIndex = 0; rateProfileIndex < CONTROL_RATE_PROFILE_COUNT; rateProfileIndex++) { controlRateConfig_t *controlRateConfig = controlRateProfilesMutable(rateProfileIndex); controlRateConfig->rcRates[FD_YAW] = 120; controlRateConfig->rcExpo[FD_ROLL] = 15; controlRateConfig->rcExpo[FD_PITCH] = 15; controlRateConfig->rcExpo[FD_YAW] = 15; controlRateConfig->rates[FD_ROLL] = 85; controlRateConfig->rates[FD_PITCH] = 85; } batteryConfigMutable()->batteryCapacity = 250; batteryConfigMutable()->vbatmincellvoltage = 280; batteryConfigMutable()->vbatwarningcellvoltage = 330; *customMotorMixerMutable(0) = (motorMixer_t){ 1.0f, -0.414178f, 1.0f, -1.0f }; // REAR_R *customMotorMixerMutable(1) = (motorMixer_t){ 1.0f, -0.414178f, -1.0f, 1.0f }; // FRONT_R *customMotorMixerMutable(2) = (motorMixer_t){ 1.0f, 0.414178f, 1.0f, 1.0f }; // REAR_L *customMotorMixerMutable(3) = (motorMixer_t){ 1.0f, 0.414178f, -1.0f, -1.0f }; // FRONT_L vcdProfileMutable()->video_system = VIDEO_SYSTEM_NTSC; #if defined(BEESTORM) strcpy(pilotConfigMutable()->name, "BeeStorm"); #else strcpy(pilotConfigMutable()->name, "BeeBrain V2"); #endif osdConfigMutable()->cap_alarm = 250; osdConfigMutable()->item_pos[OSD_CRAFT_NAME] = OSD_POS(9, 11) | OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_MAIN_BATT_VOLTAGE] = OSD_POS(23, 10) | OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_ITEM_TIMER_2] = OSD_POS(2, 10) | OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_FLYMODE] = OSD_POS(17, 10) | OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_VTX_CHANNEL] = OSD_POS(10, 10) | OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_RSSI_VALUE] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_ITEM_TIMER_1] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_THROTTLE_POS] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_CROSSHAIRS] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_HORIZON_SIDEBARS] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_ARTIFICIAL_HORIZON] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_CURRENT_DRAW] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_MAH_DRAWN] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_GPS_SPEED] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_GPS_LON] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_GPS_LAT] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_GPS_SATS] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_HOME_DIR] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_HOME_DIST] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_COMPASS_BAR] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_ALTITUDE] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_ROLL_PIDS] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_PITCH_PIDS] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_YAW_PIDS] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_DEBUG] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_POWER] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_PIDRATE_PROFILE] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_WARNINGS] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_AVG_CELL_VOLTAGE] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_PITCH_ANGLE] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_ROLL_ANGLE] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_MAIN_BATT_USAGE] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_DISARMED] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_NUMERICAL_HEADING] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_NUMERICAL_VARIO] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_ESC_TMP] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_ESC_RPM] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_G_FORCE] &= ~OSD_PROFILE_1_FLAG; osdConfigMutable()->item_pos[OSD_FLIP_ARROW] &= ~OSD_PROFILE_1_FLAG; modeActivationConditionsMutable(0)->modeId = BOXANGLE; modeActivationConditionsMutable(0)->auxChannelIndex = AUX2 - NON_AUX_CHANNEL_COUNT; modeActivationConditionsMutable(0)->range.startStep = CHANNEL_VALUE_TO_STEP(900); modeActivationConditionsMutable(0)->range.endStep = CHANNEL_VALUE_TO_STEP(2100); analyzeModeActivationConditions(); #if defined(BEEBRAIN_V2D) // DSM version for (uint8_t rxRangeIndex = 0; rxRangeIndex < NON_AUX_CHANNEL_COUNT; rxRangeIndex++) { rxChannelRangeConfig_t *channelRangeConfig = rxChannelRangeConfigsMutable(rxRangeIndex); channelRangeConfig->min = 1160; channelRangeConfig->max = 1840; } #else // Frsky version serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIALRX_UART)].functionMask = FUNCTION_TELEMETRY_FRSKY_HUB | FUNCTION_RX_SERIAL; rxConfigMutable()->rssi_channel = BBV2_FRSKY_RSSI_CH_IDX; rxFailsafeChannelConfig_t *channelFailsafeConfig = rxFailsafeChannelConfigsMutable(BBV2_FRSKY_RSSI_CH_IDX - 1); channelFailsafeConfig->mode = RX_FAILSAFE_MODE_SET; channelFailsafeConfig->step = CHANNEL_VALUE_TO_RXFAIL_STEP(1000); osdConfigMutable()->item_pos[OSD_RSSI_VALUE] = OSD_POS(2, 11) | OSD_PROFILE_1_FLAG; #endif }