hilink: control WFB lifecycle and power from CH6 knob

This commit is contained in:
2026-09-30 11:29:39 +02:00
parent 5799a283e8
commit e7d1f1524d
3 changed files with 47 additions and 10 deletions
@@ -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"