Extra lvars for the Bonanza's KAS297B
-
Hi @Black-Square,
You might remember me mucking about with the Starship and the DH and MDA vars, getting them exposed so I could show them on a Stream Deck from this thread
Well you'll be thrilled to hear I've been fiddling again - this time with the Bonanza!

I've been building a Stream Deck profile for the aircraft using PilotsDeck, and following the same approach you kindly helped with on the Starship, I've made some small modifications to KAS297B.js that I'd love to see included in a future update, both to save others the effort, and more selfishly, so that my changes don't get overwritten!
The KAS297B has several internal JavaScript properties that are invisible externally, so I've exposed some of them as L-Vars with the following additions:
-
L:var_kas297b_ArmedVS (feet per minute)
The "pending" vertical speed held in this.armedVerticalSpeed before ENG VS is pressed. Updated in each of the 100_INC, 100_DEC, 1000_INC, 1000_DEC knob cases, and also in the Update() loop where armedVerticalSpeed is synced from the AP var. -
L:var_kas297b_OptionalArming (0/1)
Exposes this.optionalArmingMode. Updated in the ArmButton case (both true and false branches), and in the Update() loop where it's reset when VS hold becomes active. -
L:var_kas297b_ArmAnnun (0/1)
Mirrors the ARM annunciator state. Set at the end of the ARM annunciator block in Update(). -
L:var_kas297b_AltAlert (0/1)
Mirrors the ALERT annunciator state. Set in both branches of the altitude alerting block in Update(). -
L:var_kas297b_CaptAnnun (0/1)
Mirrors the CAPT annunciator state. Set at the end of the capture annunciator block in Update().
All changes are purely additive and don't change any existing logic. The L-Vars only update when the underlying values actually change, so the performance impact should be negligible - they're driven by the same conditionals that already drive the screen annunciators.
I'd be happy to share the full modified file or a diff if that would make it easier.
For reference, here's a summary of all the new L-Vars:
L-Var Type Description L:var_kas297b_ArmedVS feet per minute Pending armed VS value before ENG VS is pressed. Matches what the unit displays on screen. L:var_kas297b_OptionalArming 0/1 Whether optional arming mode is active (ARM button pressed manually). L:var_kas297b_ArmAnnun 0/1 Mirrors the ARM annunciator on the unit display. L:var_kas297b_AltAlert 0/1 Mirrors the ALERT annunciator (aircraft within 280–1020ft of selected altitude). L:var_kas297b_CaptAnnun 0/1 Mirrors the CAPT annunciator. Thanks again for everything you do for the community - and for being so generous with your time helping users like me dig into the internals... probably a little too much!
Here's an unfinished example of what it's all for, straight from the Stream Deck:

And from the cockpit:

Thanks!
Jiblet -
-
That's wonderful! I always enjoy seeing my users take things into their own hands to get exactly what they're looking for from my aircraft. Yes, please share the file, and I will take a look. I can't image why we shouldn't be able to include this in the base file, assuming you're willing to contribute. If you use something like pastebin, you can set an expiratory date of even just one day, and I should be able to get to this tomorrow. Thank you! I also appreciate the documentation you wrote here so I can see all your changes when I go through the file

-
Thanks so much for the positive response - I'd be absolutely delighted to contribute, and it would be great to see these changes make it into the base file! They should work in other KAS297B equipped planes too unless your code changes wildly between them.
Here's the modified KAS297B.js on Pastebin: https://pastebin.com/N2zwz8ia
I've not changed any formatting, so it should diff nicely. And all my additions are commented with //Jiblet:
I've added a bit of explanation inline either for you, or for future me when I need to go back and see why I did what I did.I think its as performant as possible but I've not written a line of production code in about 15 years, so I make no promises that I haven't done something daft!
I've spent some time this morning completing the Stream Deck version of the KAS297B, in case I needed any other vars exposed but it looks like we're good and I'm done with it, bar any minor formatting/position tweaks as I give it some testing:


It's a silly little thing but I'm quite please with it!
The little extra grey dot is just to show if you're changing 100s or 1000s (using the upper/lower knob) as the Stream Deck only has single knobs, not dual.Thanks again! It's a great to be able to contribute something back, even if it's tiny!