Skip to content

Commit 0ffe72e

Browse files
committed
back to default 4 key 1 encoder config and set up more sensible config for supported keypads
1 parent 21a801d commit 0ffe72e

8 files changed

Lines changed: 225 additions & 212 deletions

File tree

Keypad.Flasher.Server.Tests/ConfigurationGeneratorTests.cs

Lines changed: 155 additions & 71 deletions
Large diffs are not rendered by default.

Keypad.Flasher.Server.Tests/ExpectedOutputs/ConfigurationGenerator/generate_source_10_buttons.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const button_binding_t button_bindings[] = {
2121
.pin = 14,
2222
.active_low = true,
2323
.led_index = -1,
24-
.bootloader_on_boot = true,
24+
.bootloader_on_boot = false,
2525
.bootloader_chord_member = true,
2626
.function = {
2727
.type = HID_BINDING_SEQUENCE,
@@ -36,7 +36,7 @@ const button_binding_t button_bindings[] = {
3636
.pin = 15,
3737
.active_low = true,
3838
.led_index = -1,
39-
.bootloader_on_boot = true,
39+
.bootloader_on_boot = false,
4040
.bootloader_chord_member = true,
4141
.function = {
4242
.type = HID_BINDING_SEQUENCE,
@@ -51,7 +51,7 @@ const button_binding_t button_bindings[] = {
5151
.pin = 16,
5252
.active_low = true,
5353
.led_index = -1,
54-
.bootloader_on_boot = true,
54+
.bootloader_on_boot = false,
5555
.bootloader_chord_member = true,
5656
.function = {
5757
.type = HID_BINDING_SEQUENCE,
@@ -66,7 +66,7 @@ const button_binding_t button_bindings[] = {
6666
.pin = 17,
6767
.active_low = true,
6868
.led_index = -1,
69-
.bootloader_on_boot = true,
69+
.bootloader_on_boot = false,
7070
.bootloader_chord_member = true,
7171
.function = {
7272
.type = HID_BINDING_SEQUENCE,
@@ -81,7 +81,7 @@ const button_binding_t button_bindings[] = {
8181
.pin = 31,
8282
.active_low = true,
8383
.led_index = -1,
84-
.bootloader_on_boot = true,
84+
.bootloader_on_boot = false,
8585
.bootloader_chord_member = true,
8686
.function = {
8787
.type = HID_BINDING_SEQUENCE,
@@ -96,7 +96,7 @@ const button_binding_t button_bindings[] = {
9696
.pin = 30,
9797
.active_low = true,
9898
.led_index = -1,
99-
.bootloader_on_boot = true,
99+
.bootloader_on_boot = false,
100100
.bootloader_chord_member = true,
101101
.function = {
102102
.type = HID_BINDING_SEQUENCE,
@@ -111,7 +111,7 @@ const button_binding_t button_bindings[] = {
111111
.pin = 11,
112112
.active_low = true,
113113
.led_index = -1,
114-
.bootloader_on_boot = true,
114+
.bootloader_on_boot = false,
115115
.bootloader_chord_member = true,
116116
.function = {
117117
.type = HID_BINDING_SEQUENCE,
@@ -126,7 +126,7 @@ const button_binding_t button_bindings[] = {
126126
.pin = 33,
127127
.active_low = true,
128128
.led_index = -1,
129-
.bootloader_on_boot = true,
129+
.bootloader_on_boot = false,
130130
.bootloader_chord_member = true,
131131
.function = {
132132
.type = HID_BINDING_SEQUENCE,
@@ -141,7 +141,7 @@ const button_binding_t button_bindings[] = {
141141
.pin = 34,
142142
.active_low = true,
143143
.led_index = -1,
144-
.bootloader_on_boot = true,
144+
.bootloader_on_boot = false,
145145
.bootloader_chord_member = true,
146146
.function = {
147147
.type = HID_BINDING_SEQUENCE,

Keypad.Flasher.Server.Tests/ExpectedOutputs/ConfigurationGenerator/generate_source_2_button_module.c

Lines changed: 0 additions & 43 deletions
This file was deleted.

Keypad.Flasher.Server.Tests/ExpectedOutputs/ConfigurationGenerator/generate_source_2_buttons.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,33 @@
33

44
const button_binding_t button_bindings[] = {
55
{
6-
.pin = 5,
7-
.active_low = false,
6+
.pin = 32,
7+
.active_low = true,
88
.led_index = -1,
9-
.bootloader_on_boot = false,
9+
.bootloader_on_boot = true,
1010
.bootloader_chord_member = false,
1111
.function = {
1212
.type = HID_BINDING_SEQUENCE,
1313
.function.sequence = {
14-
.sequence = {'a', 'b'},
15-
.length = 2,
16-
.delay = 10
14+
.sequence = {'1'},
15+
.length = 1,
16+
.delay = 0
1717
}
1818
}
1919
},
2020
{
21-
.pin = 6,
21+
.pin = 14,
2222
.active_low = true,
23-
.led_index = 1,
24-
.bootloader_on_boot = true,
25-
.bootloader_chord_member = true,
23+
.led_index = -1,
24+
.bootloader_on_boot = false,
25+
.bootloader_chord_member = false,
2626
.function = {
27-
.type = HID_BINDING_FUNCTION,
28-
.function.functionPointer = hid_consumer_volume_down
27+
.type = HID_BINDING_SEQUENCE,
28+
.function.sequence = {
29+
.sequence = {'2'},
30+
.length = 1,
31+
.delay = 0
32+
}
2933
}
3034
}
3135
};

Keypad.Flasher.Server.Tests/ExpectedOutputs/ConfigurationGenerator/generate_source_4_buttons_1_dial.c renamed to Keypad.Flasher.Server.Tests/ExpectedOutputs/ConfigurationGenerator/generate_source_3_buttons_1_encoder.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,60 +3,60 @@
33

44
const button_binding_t button_bindings[] = {
55
{
6-
.pin = 11,
6+
.pin = 33,
77
.active_low = true,
8-
.led_index = 0,
9-
.bootloader_on_boot = false,
10-
.bootloader_chord_member = true,
8+
.led_index = -1,
9+
.bootloader_on_boot = true,
10+
.bootloader_chord_member = false,
1111
.function = {
1212
.type = HID_BINDING_SEQUENCE,
1313
.function.sequence = {
14-
.sequence = {'a'},
15-
.length = 1,
16-
.delay = 0
14+
.sequence = {'e', 'n', 't', 'e', 'r'},
15+
.length = 5,
16+
.delay = 5
1717
}
1818
}
1919
},
2020
{
21-
.pin = 17,
21+
.pin = 16,
2222
.active_low = true,
23-
.led_index = 1,
23+
.led_index = 2,
2424
.bootloader_on_boot = false,
2525
.bootloader_chord_member = true,
2626
.function = {
2727
.type = HID_BINDING_SEQUENCE,
2828
.function.sequence = {
29-
.sequence = {'b'},
29+
.sequence = {'a'},
3030
.length = 1,
3131
.delay = 0
3232
}
3333
}
3434
},
3535
{
36-
.pin = 16,
36+
.pin = 17,
3737
.active_low = true,
38-
.led_index = 2,
38+
.led_index = 1,
3939
.bootloader_on_boot = false,
4040
.bootloader_chord_member = true,
4141
.function = {
4242
.type = HID_BINDING_SEQUENCE,
4343
.function.sequence = {
44-
.sequence = {'c'},
44+
.sequence = {'b'},
4545
.length = 1,
4646
.delay = 0
4747
}
4848
}
4949
},
5050
{
51-
.pin = 33,
51+
.pin = 11,
5252
.active_low = true,
53-
.led_index = -1,
54-
.bootloader_on_boot = true,
53+
.led_index = 0,
54+
.bootloader_on_boot = false,
5555
.bootloader_chord_member = true,
5656
.function = {
5757
.type = HID_BINDING_SEQUENCE,
5858
.function.sequence = {
59-
.sequence = {'d'},
59+
.sequence = {'c'},
6060
.length = 1,
6161
.delay = 0
6262
}

Keypad.Flasher.Server.Tests/ExpectedOutputs/ConfigurationGenerator/generate_source_4_buttons.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const button_binding_t button_bindings[] = {
2121
.pin = 16,
2222
.active_low = true,
2323
.led_index = 1,
24-
.bootloader_on_boot = true,
24+
.bootloader_on_boot = false,
2525
.bootloader_chord_member = true,
2626
.function = {
2727
.type = HID_BINDING_SEQUENCE,
@@ -36,7 +36,7 @@ const button_binding_t button_bindings[] = {
3636
.pin = 17,
3737
.active_low = true,
3838
.led_index = 2,
39-
.bootloader_on_boot = true,
39+
.bootloader_on_boot = false,
4040
.bootloader_chord_member = true,
4141
.function = {
4242
.type = HID_BINDING_SEQUENCE,
@@ -51,7 +51,7 @@ const button_binding_t button_bindings[] = {
5151
.pin = 11,
5252
.active_low = true,
5353
.led_index = 3,
54-
.bootloader_on_boot = true,
54+
.bootloader_on_boot = false,
5555
.bootloader_chord_member = true,
5656
.function = {
5757
.type = HID_BINDING_SEQUENCE,

Keypad.Flasher.Server/Controllers/FlasherController.cs

Lines changed: 24 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -131,80 +131,48 @@ public record Firmware(byte[] FileBytes);
131131

132132
internal static ConfigurationDefinition CreateDefaultConfiguration()
133133
{
134-
var buttons = new List<ButtonBinding>{
135-
new ButtonBinding(
136-
Pin: 32,
137-
ActiveLow: true,
138-
LedIndex: -1,
139-
BootloaderOnBoot: true,
140-
BootloaderChordMember: true,
141-
Function: new HidSequenceBinding("0", 0)),
142-
new ButtonBinding(
143-
Pin: 14,
144-
ActiveLow: true,
145-
LedIndex: -1,
146-
BootloaderOnBoot: true,
147-
BootloaderChordMember: true,
148-
Function: new HidSequenceBinding("1", 0)),
134+
var buttons = new List<ButtonBinding>
135+
{
149136
new ButtonBinding(
150-
Pin: 15,
137+
Pin: 33,
151138
ActiveLow: true,
152139
LedIndex: -1,
153140
BootloaderOnBoot: true,
154-
BootloaderChordMember: true,
155-
Function: new HidSequenceBinding("2", 0)),
141+
BootloaderChordMember: false,
142+
Function: new HidSequenceBinding("enter", 5)),
156143
new ButtonBinding(
157144
Pin: 16,
158145
ActiveLow: true,
159-
LedIndex: -1,
160-
BootloaderOnBoot: true,
146+
LedIndex: 2,
147+
BootloaderOnBoot: false,
161148
BootloaderChordMember: true,
162-
Function: new HidSequenceBinding("3", 0)),
149+
Function: new HidSequenceBinding("a", 0)),
163150
new ButtonBinding(
164151
Pin: 17,
165152
ActiveLow: true,
166-
LedIndex: -1,
167-
BootloaderOnBoot: true,
168-
BootloaderChordMember: true,
169-
Function: new HidSequenceBinding("4", 0)),
170-
new ButtonBinding(
171-
Pin: 31,
172-
ActiveLow: true,
173-
LedIndex: -1,
174-
BootloaderOnBoot: true,
153+
LedIndex: 1,
154+
BootloaderOnBoot: false,
175155
BootloaderChordMember: true,
176-
Function: new HidSequenceBinding("5", 0)),
177-
new ButtonBinding(
178-
Pin: 30,
179-
ActiveLow: true,
180-
LedIndex: -1,
181-
BootloaderOnBoot: true,
182-
BootloaderChordMember: true,
183-
Function: new HidSequenceBinding("6", 0)),
156+
Function: new HidSequenceBinding("b", 0)),
184157
new ButtonBinding(
185158
Pin: 11,
186159
ActiveLow: true,
187-
LedIndex: -1,
188-
BootloaderOnBoot: true,
160+
LedIndex: 0,
161+
BootloaderOnBoot: false,
189162
BootloaderChordMember: true,
190-
Function: new HidSequenceBinding("7", 0)),
191-
new ButtonBinding(
192-
Pin: 33,
193-
ActiveLow: true,
194-
LedIndex: -1,
195-
BootloaderOnBoot: true,
196-
BootloaderChordMember: true,
197-
Function: new HidSequenceBinding("8", 0)),
198-
new ButtonBinding(
199-
Pin: 34,
200-
ActiveLow: true,
201-
LedIndex: -1,
202-
BootloaderOnBoot: true,
203-
BootloaderChordMember: true,
204-
Function: new HidSequenceBinding("9", 0)),
163+
Function: new HidSequenceBinding("c", 0)),
164+
};
165+
166+
var encoders = new List<EncoderBinding>
167+
{
168+
new EncoderBinding(
169+
PinA: 31,
170+
PinB: 30,
171+
Clockwise: new HidFunctionBinding("hid_consumer_volume_up"),
172+
CounterClockwise: new HidFunctionBinding("hid_consumer_volume_down"))
205173
};
206174

207-
return new ConfigurationDefinition(buttons, Array.Empty<EncoderBinding>(), DebugMode: false, NeoPixelPin: -1);
175+
return new ConfigurationDefinition(buttons, encoders, DebugMode: false, NeoPixelPin: 34);
208176
}
209177

210178
private bool IsDebugRequested()

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Please note that the CH55x bootloader on some devices has a quirk where it will
6666

6767
Now you can hopefully connect to the device in the app and flash the new firmware! If you cannot see any devices in the connection window, please ensure that the device is connected in bootloader mode and that you have the correct drivers installed (on Windows).
6868

69-
At this time there is only very basic firmware that is designed for keypads with 1 dial and 3 buttons but this will be updated soon to handle different layouts and actually allow remapping of keys etc. The current firmware will just register the 3 buttons as Ctrl-C, Ctrl-V and Ctrl-Z and the dial as scroll up/down.
69+
At this time there is only very basic firmware that is designed for keypads with 1 knob and 3 buttons but this will be updated soon to handle different layouts and actually allow remapping of keys etc. The current firmware will just register the 3 buttons as Ctrl-C, Ctrl-V and Ctrl-Z and the knob as scroll up/down.
7070

7171
Please note that the original firmware on the device will be lost when you flash this custom firmware, so only proceed if you are okay with that.
7272

0 commit comments

Comments
 (0)