KAP140: annunciate modes from per-mode status datarefs (same bitfield fix)
The steam-panel KAP140 LCD decoded the same unreliable autopilot_state bitfield as the G1000 panel, so its lateral/vertical annunciation could be wrong. Read the *_status datarefs instead, consistent with AutopilotPanel and the PFD. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -4,15 +4,16 @@ import { num } from '../api/useXplane.js';
|
|||||||
// Bendix/King KAP 140 — the panel-mounted autopilot in the steam-gauge Cessna
|
// Bendix/King KAP 140 — the panel-mounted autopilot in the steam-gauge Cessna
|
||||||
// 172. A green segment LCD annunciates the active modes + armed altitude, with a
|
// 172. A green segment LCD annunciates the active modes + armed altitude, with a
|
||||||
// row of buttons (AP HDG NAV APR REV ALT, UP/DN, BARO) and the ALT knob. Buttons
|
// row of buttons (AP HDG NAV APR REV ALT, UP/DN, BARO) and the ALT knob. Buttons
|
||||||
// fire X-Plane's own autopilot commands; annunciation comes from autopilot_state.
|
// fire X-Plane's own autopilot commands; annunciation reads the per-mode
|
||||||
const BITS = { fd: 1 << 0, hdg: 1 << 1, vs: 1 << 4, flc: 1 << 6, nav: 1 << 8, apr: 1 << 9, alt: 1 << 14, bc: 1 << 18 };
|
// *_status datarefs (off/armed/active) — the same reliable source as the PFD,
|
||||||
const on = (s, b) => (num(s) & b) !== 0;
|
// not the autopilot_state bitfield (whose bit positions don't match X-Plane).
|
||||||
|
|
||||||
export default function KAP140({ xp }) {
|
export default function KAP140({ xp }) {
|
||||||
const { values: V, command, setDataref } = xp;
|
const { values: V, command, setDataref } = xp;
|
||||||
const s = num(V.apState), eng = num(V.apEngaged) > 0;
|
const lit = (k) => num(V[k]) > 0;
|
||||||
const lat = on(s, BITS.apr) ? 'APR' : on(s, BITS.nav) ? 'NAV' : on(s, BITS.bc) ? 'REV' : on(s, BITS.hdg) ? 'HDG' : 'ROL';
|
const eng = num(V.apEngaged) > 0 || num(V.apMode) >= 2;
|
||||||
const vert = on(s, BITS.alt) ? 'ALT' : on(s, BITS.vs) ? 'VS' : '';
|
const lat = lit('aprStatus') ? 'APR' : (lit('navStatus') || lit('gpssStatus')) ? 'NAV' : lit('bcStatus') ? 'REV' : lit('hdgStatus') ? 'HDG' : 'ROL';
|
||||||
|
const vert = lit('altStatus') ? 'ALT' : lit('vsStatus') ? 'VS' : '';
|
||||||
const selAlt = Math.round(num(V.apAltBug));
|
const selAlt = Math.round(num(V.apAltBug));
|
||||||
const vs = Math.round(num(V.apVsBug));
|
const vs = Math.round(num(V.apVsBug));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user