Files
openipc-builder/devices/ssc338q_fpv_openipc-urllc-aio/general/overlay/usr/bin/channels.sh
T

26 lines
671 B
Bash
Executable File

#!/bin/sh
CHANNEL="${1:-}"
VALUE="${2:-}"
# CH6 is the GX12 WFB knob. Betaflight exposes it as 1000..2000 PWM.
[ "$CHANNEL" = "6" ] || exit 0
case "$VALUE" in
''|*[!0-9]*) exit 2 ;;
esac
# First 5% is an explicit OFF detent. Above it WFB starts at 5% and the
# remaining travel maps continuously to 100%. This is a UI-range guard, not a
# regulatory EIRP cap.
if [ "$VALUE" -le 1050 ]; then
rm -f /run/wfb-power
logger -t channels "CH6=$VALUE -> management"
exec /usr/bin/link-mode management
fi
POWER=$((5 + (VALUE - 1051) * 95 / 949))
[ "$POWER" -gt 100 ] && POWER=100
logger -t channels "CH6=$VALUE -> WFB txpower=$POWER"
exec /usr/bin/wfb-power "$POWER"