mockband/NOTES.md

74 lines
1.6 KiB
Markdown
Raw Normal View History

2024-01-01 12:19:50 -07:00
I did some performance testing.
The Pro Micro runs an Atmel 32u4 at 8MHz.
If the code does nothing else,
I was able to poll all pins around 13 times every 1ms,
or 13kHz.
Sample Rate
-----------
The number of samples taken since the last HID report
is sent as the second Y axis.
If you use the
[included gamepad tester](gamepad.html),
it will show the approximate number of samples as an integer,
for Y axis 2.
This is approximate,
because the browser encodes the value as a real number between -1 and 1.
We convert it back, but may lose a little precision.
It's close enough for me,
hopefully it's close enough for you.
Debouncing
----------
Using `millis()` time to debounce the switch
roughly halved my sample frequency.
So instead, I do some preprocessor arithmetic
to calculate how many samples to take after an edge,
in order to debounce switches.
The drum controller was a partcular pain:
in addition to the switch bouncing,
the stick was bouncing on the rubber pad.
I settled on a 40ms silence window as feeling pretty good.
You can adjust this if you want to.
Gamepad Buttons
---------------
The `buttons` struct member is a bitmap,
each bit mapping to one of the 12 buttons reported through HID.
Here's what each bit means:
* 0: Blue
* 1: Green
* 2: Red
* 3: Yellow
* 4: Orange
* 5: Tilt Switch / 2x kick
* 6: Solo modifier (second row of buttons on guitar)
* 7: ?
* 8: Minus
* 9: Plus
* 10: Drum pad modifier?
* 11: Cymbal modifier?
* 12: ?
hatAndConstant
--------------
I don't get this, but here's what the values mean:
* 2: right
* 6: left
* 0: up
* 4: down
* 8: nothing