2014-01-14 19:02:57 -04:00
|
|
|
#!nsh
|
|
|
|
#
|
|
|
|
# Script to configure control interface
|
|
|
|
#
|
|
|
|
|
2014-03-06 18:11:13 -04:00
|
|
|
if [ $MIXER != none -a $MIXER != skip ]
|
2014-01-14 19:02:57 -04:00
|
|
|
then
|
|
|
|
#
|
|
|
|
# Load mixer
|
|
|
|
#
|
|
|
|
|
|
|
|
#Use the mixer file from the SD-card if it exists
|
2014-11-17 09:56:11 -04:00
|
|
|
if [ -f /fs/microsd/etc/mixers/$MIXER.mix ]
|
2014-01-14 19:02:57 -04:00
|
|
|
then
|
2014-11-17 09:56:11 -04:00
|
|
|
set MIXER_FILE /fs/microsd/etc/mixers/$MIXER.mix
|
2014-01-14 19:02:57 -04:00
|
|
|
else
|
|
|
|
set MIXER_FILE /etc/mixers/$MIXER.mix
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $OUTPUT_MODE == mkblctrl ]
|
|
|
|
then
|
|
|
|
set OUTPUT_DEV /dev/mkblctrl
|
|
|
|
else
|
|
|
|
set OUTPUT_DEV /dev/pwm_output
|
|
|
|
fi
|
2014-05-08 09:23:33 -03:00
|
|
|
|
2014-07-06 19:31:05 -03:00
|
|
|
if [ $OUTPUT_MODE == uavcan_esc ]
|
2014-05-08 09:23:33 -03:00
|
|
|
then
|
2014-05-08 10:03:40 -03:00
|
|
|
set OUTPUT_DEV /dev/uavcan/esc
|
2014-05-08 09:23:33 -03:00
|
|
|
fi
|
2014-01-14 19:02:57 -04:00
|
|
|
|
|
|
|
if mixer load $OUTPUT_DEV $MIXER_FILE
|
|
|
|
then
|
2014-11-17 09:58:29 -04:00
|
|
|
echo "[i] Mixer: $MIXER_FILE"
|
2014-01-14 19:02:57 -04:00
|
|
|
else
|
2014-11-17 09:58:29 -04:00
|
|
|
echo "[i] Error loading mixer: $MIXER_FILE"
|
2014-11-17 09:56:11 -04:00
|
|
|
tone_alarm $TUNE_ERR
|
2014-01-14 19:02:57 -04:00
|
|
|
fi
|
2014-11-17 09:56:11 -04:00
|
|
|
|
|
|
|
unset MIXER_FILE
|
2014-01-14 19:02:57 -04:00
|
|
|
else
|
2014-03-06 07:45:10 -04:00
|
|
|
if [ $MIXER != skip ]
|
|
|
|
then
|
2014-11-17 09:58:29 -04:00
|
|
|
echo "[i] Mixer not defined"
|
2014-11-17 09:56:11 -04:00
|
|
|
tone_alarm $TUNE_ERR
|
2014-03-06 07:45:10 -04:00
|
|
|
fi
|
2014-01-14 19:02:57 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $OUTPUT_MODE == fmu -o $OUTPUT_MODE == io ]
|
|
|
|
then
|
2014-11-17 09:56:11 -04:00
|
|
|
if [ $PWM_OUT != none ]
|
2014-01-14 19:02:57 -04:00
|
|
|
then
|
|
|
|
#
|
|
|
|
# Set PWM output frequency
|
|
|
|
#
|
|
|
|
if [ $PWM_RATE != none ]
|
|
|
|
then
|
2014-11-17 09:58:29 -04:00
|
|
|
echo "[i] PWM rate: $PWM_RATE"
|
2014-11-17 09:56:11 -04:00
|
|
|
pwm rate -c $PWM_OUT -r $PWM_RATE
|
2014-01-14 19:02:57 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Set disarmed, min and max PWM values
|
|
|
|
#
|
|
|
|
if [ $PWM_DISARMED != none ]
|
|
|
|
then
|
2014-11-17 09:58:29 -04:00
|
|
|
echo "[i] PWM disarmed: $PWM_DISARMED"
|
2014-11-17 09:56:11 -04:00
|
|
|
pwm disarmed -c $PWM_OUT -p $PWM_DISARMED
|
2014-01-14 19:02:57 -04:00
|
|
|
fi
|
|
|
|
if [ $PWM_MIN != none ]
|
|
|
|
then
|
2014-11-17 09:58:29 -04:00
|
|
|
echo "[i] PWM min: $PWM_MIN"
|
2014-11-17 09:56:11 -04:00
|
|
|
pwm min -c $PWM_OUT -p $PWM_MIN
|
2014-01-14 19:02:57 -04:00
|
|
|
fi
|
|
|
|
if [ $PWM_MAX != none ]
|
|
|
|
then
|
2014-11-17 09:58:29 -04:00
|
|
|
echo "[i] PWM max: $PWM_MAX"
|
2014-11-17 09:56:11 -04:00
|
|
|
pwm max -c $PWM_OUT -p $PWM_MAX
|
2014-01-14 19:02:57 -04:00
|
|
|
fi
|
|
|
|
fi
|
2014-08-26 05:13:52 -03:00
|
|
|
|
|
|
|
if [ $FAILSAFE != none ]
|
|
|
|
then
|
|
|
|
pwm failsafe -d $OUTPUT_DEV $FAILSAFE
|
|
|
|
fi
|
2014-01-14 19:02:57 -04:00
|
|
|
fi
|