Something cool has happened this weekend!
While updating the AB412 head code to work with XTrident 412 in Xplane I decided to rewrite it in a better way, and then inspiration kicked in and I have made a few important changes in the firmware structure =)
Up to this point, simchair firmware was basically a collection of loosely connected independent files with nothing but a few global variables in common. That means every file was different, to create a new device we had to copy a file powering a similar one and edit it. Usually, that file ended up containing functions, very similar to ones in the other files. That was beginning to look like a mess, so I decided to improve it by making the firmware look more like a library.
So far, I have rewritten 412 head and MKIII single collective files, here are the most notable changes:
- The 412 head now has two “middle” positions for starter and idle rel switches, Xtrident AB412 should work fine with the Lua script from extras dir of the repo
- collective heads now have unified functions to create an array of buttons from bytes and parse it. Those functions should be usable for any other head we will have! The first head I have updated is the 412 one.
- virtual buttons can be added to any collective head in a simple way. So far “middle” buttons of switches are supported, just tell the function where you want them to be =)
- collective levers now have a universal set of functions as well. The amount of code needed to run the lever has notably decreased, it became much more readable! Below you can see the whole single collective MKIII code:
All other levers will be using those functions in a while, and that will help us to eliminate a lot of bugs- instead of having to trace individual bugs for each device and copy the fix everywhere manually – we will only have to change stuff in one place for all devices.
Another idea is to make the code easier to use for beginners – adding new devices with such an approach will be a pure joy – sometimes all one will have to do is just to change a number of buttons and specify some configuration settings.
Changes are fairly global, the process will take time – so I thought it’s time to create a separate branch for the most recent version. Please check out the new testing branch! I will be happy to hear some feedback in the comments.