mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 08:13:35 +08:00
boards: new ARK FPV FC (#23830)
* add new payload power switch (RC_MAP_PAY_SW)
This commit is contained in:
@@ -204,6 +204,9 @@ void ADC::update_system_power(hrt_abstime now)
|
||||
# if defined(ADC_SCALED_V5_SENSE) && defined(ADC_SCALED_V3V3_SENSORS_SENSE)
|
||||
cnt += ADC_SCALED_V3V3_SENSORS_COUNT;
|
||||
# endif
|
||||
# if defined(ADC_SCALED_PAYLOAD_SENSE)
|
||||
cnt++;
|
||||
# endif
|
||||
|
||||
for (unsigned i = 0; i < _channel_count; i++) {
|
||||
# if defined(ADC_SCALED_V5_SENSE)
|
||||
@@ -234,6 +237,16 @@ void ADC::update_system_power(hrt_abstime now)
|
||||
}
|
||||
|
||||
# endif
|
||||
# if defined(ADC_SCALED_PAYLOAD_SENSE)
|
||||
|
||||
if (_samples[i].am_channel == ADC_SCALED_PAYLOAD_SENSE) {
|
||||
system_power.voltage_payload_v = _samples[i].am_data * ((ADC_PAYLOAD_V_FULL_SCALE / 3.3f) *
|
||||
(px4_arch_adc_reference_v() /
|
||||
px4_arch_adc_dn_fullcount()));
|
||||
cnt--;
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
if (cnt == 0) {
|
||||
break;
|
||||
@@ -285,6 +298,9 @@ void ADC::update_system_power(hrt_abstime now)
|
||||
#ifdef BOARD_GPIO_VDD_5V_CAN1_GPS1_VALID
|
||||
system_power.can1_gps1_5v_valid = read_gpio_value(_5v_can1_gps1_valid_fd);
|
||||
#endif
|
||||
#ifdef BOARD_GPIO_PAYOLOAD_V_VALID
|
||||
system_power.payload_v_valid = BOARD_GPIO_PAYOLOAD_V_VALID;
|
||||
#endif
|
||||
|
||||
system_power.timestamp = hrt_absolute_time();
|
||||
_to_system_power.publish(system_power);
|
||||
|
||||
@@ -271,6 +271,19 @@ void ManualControl::processSwitches(hrt_abstime &now)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(PAYLOAD_POWER_EN)
|
||||
|
||||
if (switches.payload_power_switch != _previous_switches.payload_power_switch) {
|
||||
if (switches.payload_power_switch == manual_control_switches_s::SWITCH_POS_ON) {
|
||||
PAYLOAD_POWER_EN(true);
|
||||
|
||||
} else if (switches.payload_power_switch == manual_control_switches_s::SWITCH_POS_OFF) {
|
||||
PAYLOAD_POWER_EN(false);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // PAYLOAD_POWER_EN
|
||||
|
||||
} else if (!_armed) {
|
||||
// Directly initialize mode using RC switch but only before arming
|
||||
evaluateModeSlot(switches.mode_slot);
|
||||
|
||||
@@ -1762,6 +1762,35 @@ PARAM_DEFINE_INT32(RC_MAP_AUX5, 0);
|
||||
* @value 18 Channel 18
|
||||
*/
|
||||
PARAM_DEFINE_INT32(RC_MAP_AUX6, 0);
|
||||
|
||||
/**
|
||||
* Payload Power Switch RC channel
|
||||
*
|
||||
* @min 0
|
||||
* @max 18
|
||||
* @group Radio Switches
|
||||
* @value 0 Unassigned
|
||||
* @value 1 Channel 1
|
||||
* @value 2 Channel 2
|
||||
* @value 3 Channel 3
|
||||
* @value 4 Channel 4
|
||||
* @value 5 Channel 5
|
||||
* @value 6 Channel 6
|
||||
* @value 7 Channel 7
|
||||
* @value 8 Channel 8
|
||||
* @value 9 Channel 9
|
||||
* @value 10 Channel 10
|
||||
* @value 11 Channel 11
|
||||
* @value 12 Channel 12
|
||||
* @value 13 Channel 13
|
||||
* @value 14 Channel 14
|
||||
* @value 15 Channel 15
|
||||
* @value 16 Channel 16
|
||||
* @value 17 Channel 17
|
||||
* @value 18 Channel 18
|
||||
*/
|
||||
PARAM_DEFINE_INT32(RC_MAP_PAY_SW, 0);
|
||||
|
||||
/**
|
||||
* PARAM1 tuning channel
|
||||
*
|
||||
@@ -2029,6 +2058,22 @@ PARAM_DEFINE_FLOAT(RC_GEAR_TH, 0.75f);
|
||||
*/
|
||||
PARAM_DEFINE_FLOAT(RC_ENG_MOT_TH, 0.75f);
|
||||
|
||||
/**
|
||||
* Threshold for selecting payload power switch
|
||||
*
|
||||
* 0-1 indicate where in the full channel range the threshold sits
|
||||
* 0 : min
|
||||
* 1 : max
|
||||
* sign indicates polarity of comparison
|
||||
* positive : true when channel>th
|
||||
* negative : true when channel<th
|
||||
*
|
||||
* @min -1
|
||||
* @max 1
|
||||
* @group Radio Switches
|
||||
*/
|
||||
PARAM_DEFINE_FLOAT(RC_PAYLOAD_TH, 0.75f);
|
||||
|
||||
/**
|
||||
* PWM input channel that provides RSSI.
|
||||
*
|
||||
|
||||
@@ -57,6 +57,7 @@ static bool operator ==(const manual_control_switches_s &a, const manual_control
|
||||
a.gear_switch == b.gear_switch &&
|
||||
a.photo_switch == b.photo_switch &&
|
||||
a.video_switch == b.video_switch &&
|
||||
a.payload_power_switch == b.payload_power_switch &&
|
||||
a.engage_main_motor_switch == b.engage_main_motor_switch);
|
||||
}
|
||||
|
||||
@@ -219,6 +220,8 @@ void RCUpdate::update_rc_functions()
|
||||
_rc.function[rc_channels_s::FUNCTION_AUX_5] = _param_rc_map_aux5.get() - 1;
|
||||
_rc.function[rc_channels_s::FUNCTION_AUX_6] = _param_rc_map_aux6.get() - 1;
|
||||
|
||||
_rc.function[rc_channels_s::FUNCTION_PAYLOAD_POWER] = _param_rc_map_payload_sw.get() - 1;
|
||||
|
||||
for (int i = 0; i < rc_parameter_map_s::RC_PARAM_MAP_NCHAN; i++) {
|
||||
_rc.function[rc_channels_s::FUNCTION_PARAM_1 + i] = _parameters.rc_map_param[i] - 1;
|
||||
}
|
||||
@@ -616,6 +619,11 @@ void RCUpdate::UpdateManualSwitches(const hrt_abstime ×tamp_sample)
|
||||
switches.video_switch = getRCSwitchOnOffPosition(rc_channels_s::FUNCTION_AUX_4, 0.5f);
|
||||
#endif
|
||||
|
||||
#if defined(PAYLOAD_POWER_EN)
|
||||
switches.payload_power_switch = getRCSwitchOnOffPosition(rc_channels_s::FUNCTION_PAYLOAD_POWER,
|
||||
_param_rc_payload_th.get());
|
||||
#endif
|
||||
|
||||
// last 2 switch updates identical within 1 second (simple protection from bad RC data)
|
||||
if ((switches == _manual_switches_previous)
|
||||
&& (switches.timestamp_sample < _manual_switches_previous.timestamp_sample + VALID_DATA_MIN_INTERVAL_US)) {
|
||||
|
||||
@@ -230,6 +230,8 @@ protected:
|
||||
|
||||
(ParamInt<px4::params::RC_FAILS_THR>) _param_rc_fails_thr,
|
||||
|
||||
(ParamInt<px4::params::RC_MAP_PAY_SW>) _param_rc_map_payload_sw,
|
||||
|
||||
(ParamFloat<px4::params::RC_LOITER_TH>) _param_rc_loiter_th,
|
||||
(ParamFloat<px4::params::RC_OFFB_TH>) _param_rc_offb_th,
|
||||
(ParamFloat<px4::params::RC_KILLSWITCH_TH>) _param_rc_killswitch_th,
|
||||
@@ -238,6 +240,7 @@ protected:
|
||||
(ParamFloat<px4::params::RC_GEAR_TH>) _param_rc_gear_th,
|
||||
(ParamFloat<px4::params::RC_RETURN_TH>) _param_rc_return_th,
|
||||
(ParamFloat<px4::params::RC_ENG_MOT_TH>) _param_rc_eng_mot_th,
|
||||
(ParamFloat<px4::params::RC_PAYLOAD_TH>) _param_rc_payload_th,
|
||||
|
||||
(ParamInt<px4::params::RC_CHAN_CNT>) _param_rc_chan_cnt
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user