The idea of the stacked encoder comes from Serkan from Soelpec. The Spectra XR steering wheel runs a custom DDC firmware, and amongst the functions designed for Soelpec's wheel is the stacked encoders. The function allows you to use a pushbutton to scroll through a stack of button number layers. How many layers you can decide yourself.
The function will also push the current stack number to the rotary field, which in return will give you SimHub properties that you can use to make your dashboard change as you scroll through the stack. With more layers, more bits are used in the field. For instance 7 layers will use 3 bits, since 3 bits are required to get type the number 7 in binary.
In addition, there is a LED function encoderStack() that you can use to trigger LEDs depending on which stack you're currently in.
For instance, lets say we have a stacked encoder with its stack button on row 3, column 1. We want LEDs 0 to 4 to change color when scrolling through the stack. Writing something like this in 36_LEDtop.ino would work well:
void rotary2Stack(int stackButtonRow, int stackButtonColumn, int fieldPlacement, int layers, int row, int column, bool reverse)
Lets say our encoder is on row 3, columns 2+3, and our stackbutton is on row 1, column 5. We want 4 layers and we push the layer number to field placement 1.
rotary2Stack(1, 5, 1, 4, 3, 2, false);
The button numbers used is determined by the number written in the block for the A pin. B pin block will not be read. If button number was set to 15, the switch will use buttons 15 and 16 for the first layer, then 17+18, etc. The reverse part of the function will switch the button numbers if set to true.
In this example, we're using field slot 1, and with 4 layers we'll be using 2 bits. So slot 1 and slot 2 will be used. This is reflected by the properties [DahlDesign.DDCR1] and [DahlDesign.DDCR2] properties, which will go 00, 01, 10 and 11 as you scroll through the 4 layers.
void rotary4Stack(int stackButtonRow, int stackButtonColumn, int fieldPlacement, int layers, int row, int column, bool reverse)
Lets say our encoder is on row 3, columns 2+3, and our stackbutton is on row 1, column 5. We want 4 layers and we push the layer number to field placement 1.
rotary4Stack(1, 5, 1, 4, 3, 2, false);
The button numbers used is determined by the number written in the block for the A pin. B pin block will not be read. If button number was set to 15, the switch will use buttons 15 and 16 for the first layer, then 17+18, etc. The reverse part of the function will switch the button numbers if set to true.
In this example, we're using field slot 1, and with 4 layers we'll be using 2 bits. So slot 1 and slot 2 will be used. This is reflected by the properties [DahlDesign.DDCR1] and [DahlDesign.DDCR2] properties, which will go 00, 01, 10 and 11 as you scroll through the 4 layers.
void PEC11Stack(int stackButtonRow, int stackButtonColumn, int fieldPlacement, int layers, int row, int col, bool reverse)
Lets say our encoder is on row 3, columns 2+3, and our stackbutton is on row 1, column 5. We want 4 layers and we push the layer number to field placement 1.
PEC11Stack(1, 5, 1, 4, 3, 2, false);
The button numbers used is determined by the number written in the block for the A pin. B pin block will not be read. If button number was set to 15, the switch will use buttons 15 and 16 for the first layer, then 17+18, etc. The reverse part of the function will switch the button numbers if set to true.
In this example, we're using field slot 1, and with 4 layers we'll be using 2 bits. So slot 1 and slot 2 will be used. This is reflected by the properties [DahlDesign.DDCR1] and [DahlDesign.DDCR2] properties, which will go 00, 01, 10 and 11 as you scroll through the 4 layers.
2 x layers = button numbers
funkyRotaryStack()
Stacked encoder in the funkyRotary category. This is for using a regular pushbutton to change layer, not the funky pushbutton.
void funkyRotaryStack(int stackButtonRow, int stackButtonColumn, int fieldPlacement, int layers, int Arow, int Acol, int Bcol, bool reverse)
Lets say our encoder is on row 3, columns 2+3, and our stackbutton is on row 1, column 5. We want 4 layers and we push the layer number to field placement 1.
funkyRotaryStack(1, 5, 1, 4, 3, 2, 3, false);
The button numbers used is determined by the number written in the block for the A pin. B pin block will not be read. If button number was set to 15, the switch will use buttons 15 and 16 for the first layer, then 17+18, etc. The reverse part of the function will switch the button numbers if set to true.
In this example, we're using field slot 1, and with 4 layers we'll be using 2 bits. So slot 1 and slot 2 will be used. This is reflected by the properties [DahlDesign.DDCR1] and [DahlDesign.DDCR2] properties, which will go 00, 01, 10 and 11 as you scroll through the 4 layers.
2 x layers = button numbers
funkyRotaryStackPush()
Stacked encoder in the funkyRotary category. This is for using the funky pushbutton.
void funkyRotaryStackPush(int pushButtonRow, int pushButtonColumn, int aButton, int bButton, int cButton, int dButton, int fieldPlacement, int layers, int rotRow, int rotAcol, int rotBcol, bool reverse)
Lets say our encoder is on row 3, columns 2+3, and our funky pushbutton+directional buttons are on row 1, usign columns 3-7, where pushbutton is row 3. We want 4 layers and we push the layer number to field placement 1.
The button numbers used is determined by the number written in the block for the A pin. B pin block will not be read. If button number was set to 15, the switch will use buttons 15 and 16 for the first layer, then 17+18, etc. The reverse part of the function will switch the button numbers if set to true.
In this example, we're using field slot 1, and with 4 layers we'll be using 2 bits. So slot 1 and slot 2 will be used. This is reflected by the properties [DahlDesign.DDCR1] and [DahlDesign.DDCR2] properties, which will go 00, 01, 10 and 11 as you scroll through the 4 layers.