hilink: control WFB lifecycle and power from CH6 knob
This commit is contained in:
@@ -3,20 +3,23 @@
|
||||
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 ;;
|
||||
''|*[!0-9]*) exit 2 ;;
|
||||
esac
|
||||
|
||||
if [ "$VALUE" -le 1250 ]; then
|
||||
logger -t channels "AUX2=$VALUE -> management"
|
||||
exec /usr/bin/link-mode management
|
||||
# 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
|
||||
|
||||
if [ "$VALUE" -ge 1350 ]; then
|
||||
logger -t channels "AUX2=$VALUE -> preflight"
|
||||
exec /usr/bin/link-mode preflight
|
||||
fi
|
||||
|
||||
exit 0
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user