Major master controller firmware update!

I have finally managed to rewrite some parts of firmware code I wasn’t particularly happy with, namely the collective head switch parser! It was a mess, used huge amounts of memory, yet only allowed using around 17 physical buttons.

I understood that with 2 more collective heads that will soon be added to Simchair collection, a major cleanup was needed, along with some changes related to use of flash memory to store configurations more efficiently. This allowed me to design a cleaner configuration structure that could be parsed more efficiently, and thus, I was able to add more buttons!

As of now, we can use up to 32 buttons of types 1 and 2, and up to 9 buttons of types 3 and 4 – buttons from 33 to 42 are reserved for to be assigned as middle buttons. With a mode switch support, this is 96 virtual buttons plus 33 available for middle switch positions. The latter are now defined explicitly, allowing for a wider range of configurations. These changes should allow for pretty much any collective configuration, with twice the buttons compared to what we had before.

Another good thing – all heads now have common data structures, that are populated in setup subroutines from corresponding configuration structures. This reduces chances of breaking something when adding features and makes things cleaner =)

Please sync with the repo and reflash, report bugs if you find any!

Here’s how new head switches configuration looks:

// COLLECTIVE SWITCHPANEL SWITCH MATRIX – NOW SUPPORTS UP TO 32
// BUTTONS + 10 ADDITIONAL BUTTONS FOR TYPES 3 AND 4
// 4 SWITCH TYPES ARE SUPPORTED:
// 1: button
// 2: momentary press button
// 3: selector button (button + middle button press when switch is centered)
// 4: selector momentary press button (momentary press button + middle button momentary press when switch is centered)
// ASSIGN THE BUTTON AFTER TYPES 3 AND 4 TO TYPE 5 (SLAVE) AND SET JOYSTICK BUTTON YOU WANT TO BE THE MIDDLE BUTTON IN 3RD COLUMN!
// BUTTONS FROM 33 TO 42 ARE RESERVED FOR MIDDLE BUTTONS

//0 – disabled, 1 – button, 2 – 3 – selector_button, 4 – selector, 5 – slave
const sw_matrix ab412_switch_matrix[] PROGMEM =
{
// i t m is i – id, t – type, m – middle button for types 3 and 4
{1, 1, 0},
{2, 1, 0},
{3, 2, 0},
{4, 2, 0},
{5, 2, 0},
{6, 2, 0},
{7, 2, 0},
{8, 2, 0},
{9, 3, 33},
{10,5, 33},
{11,3, 34},
{12,5, 34},
{13,3, 35},
{14,5, 35},
{15,4, 36},
{16,5, 36},

};