Calculate Roll Counte on core0

This commit is contained in:
Frederik Walk 2023-12-03 17:17:01 +01:00
parent 70846721cb
commit bf94a1effb
9 changed files with 58 additions and 235 deletions

View File

@ -23,7 +23,7 @@ The firmware is pretty much tailored to this specific use case, if you are looki
- Additional buttons via external i2c GPIO expander
- Basic configuration via on-screen menu on attached OLED screen
- Single WS2812 LED for trigger feedback
- Drumroll counters on display
- Drumroll counter on display
*: Will not work properly on an actual PS4 since there are measures to prevent unauthorized accessories from being used.

View File

@ -37,7 +37,7 @@ const Peripherals::Drum::Config drum_config = {
2, // Don Right
3, // Ka Right
},
// Trigger thresholds soft
// Trigger thresholds
{
80, // Don Left
50, // Ka Left
@ -47,6 +47,7 @@ const Peripherals::Drum::Config drum_config = {
10, // ADC sample count
25, // Debounce delay in milliseconds
500, // Roll Counter Timeout in Milliseconds
true, // Use external ADC
// SPI config for external ADC, unused if above is false
@ -108,8 +109,6 @@ const Peripherals::StatusLed::Config led_config = {
const Peripherals::Display::Config display_config = {
i2c_config.block, // Block
0x3C, // Address
500, // Roll Counter Timeout in Milliseconds
};
} // namespace Default

View File

@ -1,161 +0,0 @@
#ifndef _BITMAPS_IDLESCREEN_H_
#define _BITMAPS_IDLESCREEN_H_
#include <array>
static const std::array<uint8_t, 546> drum_bmp = {
0x42, 0x4d, 0x22, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x34,
0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x01, 0x00, 0x00,
0x23, 0x2e, 0x00, 0x00, 0x23, 0x2e, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xf8,
0x01, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0x87, 0xfe, 0x1f, 0xff, 0xf0, 0x00, 0xff, 0xfe, 0x7f, 0xff, 0xe7, 0xff,
0xf0, 0x00, 0xff, 0xf9, 0xff, 0xff, 0xf9, 0xff, 0xf0, 0x00, 0xff, 0xe7, 0xff, 0xff, 0xfe, 0x7f, 0xf0, 0x00, 0xff,
0xcf, 0xff, 0xff, 0xff, 0x3f, 0xf0, 0x00, 0xff, 0xbf, 0xfc, 0x03, 0xff, 0xdf, 0xf0, 0x00, 0xff, 0x7f, 0xc1, 0xf8,
0x3f, 0xef, 0xf0, 0x00, 0xfe, 0xff, 0x1f, 0xff, 0x8f, 0xf7, 0xf0, 0x00, 0xfd, 0xfe, 0x7f, 0xff, 0xe7, 0xfb, 0xf0,
0x00, 0xfb, 0xf8, 0xff, 0xff, 0xf1, 0xfd, 0xf0, 0x00, 0xf3, 0xf3, 0xff, 0xff, 0xfc, 0xfc, 0xf0, 0x00, 0xf7, 0xe7,
0xff, 0xff, 0xfe, 0x7e, 0xf0, 0x00, 0xef, 0xcf, 0xff, 0xff, 0xff, 0x3f, 0x70, 0x00, 0xef, 0xdf, 0xff, 0xff, 0xff,
0xbf, 0x70, 0x00, 0xdf, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xb0, 0x00, 0xdf, 0x3f, 0xff, 0xff, 0xff, 0xcf, 0xb0, 0x00,
0xbf, 0x7f, 0xff, 0xff, 0xff, 0xef, 0xd0, 0x00, 0xbe, 0x7f, 0xff, 0xff, 0xff, 0xe7, 0xd0, 0x00, 0xbe, 0xff, 0xff,
0xff, 0xff, 0xf7, 0xd0, 0x00, 0xbe, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xd0, 0x00, 0x7e, 0xff, 0xff, 0xff, 0xff, 0xf7,
0xe0, 0x00, 0x7c, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xe0, 0x00, 0x7d, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xe0, 0x00, 0x7d,
0xff, 0xff, 0xff, 0xff, 0xfb, 0xe0, 0x00, 0x7d, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xe0, 0x00, 0x7d, 0xff, 0xff, 0xff,
0xff, 0xfb, 0xe0, 0x00, 0x7d, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xe0, 0x00, 0x7d, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xe0,
0x00, 0x7c, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xe0, 0x00, 0x7e, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xe0, 0x00, 0xbe, 0xff,
0xff, 0xff, 0xff, 0xf7, 0xd0, 0x00, 0xbe, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xd0, 0x00, 0xbe, 0x7f, 0xff, 0xff, 0xff,
0xe7, 0xd0, 0x00, 0xbf, 0x7f, 0xff, 0xff, 0xff, 0xef, 0xd0, 0x00, 0xdf, 0x3f, 0xff, 0xff, 0xff, 0xcf, 0xb0, 0x00,
0xdf, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xb0, 0x00, 0xef, 0xdf, 0xff, 0xff, 0xff, 0xbf, 0x70, 0x00, 0xef, 0xcf, 0xff,
0xff, 0xff, 0x3f, 0x70, 0x00, 0xf7, 0xe7, 0xff, 0xff, 0xfe, 0x7e, 0xf0, 0x00, 0xf3, 0xf3, 0xff, 0xff, 0xfc, 0xfc,
0xf0, 0x00, 0xfb, 0xf8, 0xff, 0xff, 0xf1, 0xfd, 0xf0, 0x00, 0xfd, 0xfe, 0x7f, 0xff, 0xe7, 0xfb, 0xf0, 0x00, 0xfe,
0xff, 0x1f, 0xff, 0x8f, 0xf7, 0xf0, 0x00, 0xff, 0x7f, 0xc1, 0xf8, 0x3f, 0xef, 0xf0, 0x00, 0xff, 0xbf, 0xfc, 0x03,
0xff, 0xdf, 0xf0, 0x00, 0xff, 0xcf, 0xff, 0xff, 0xff, 0x3f, 0xf0, 0x00, 0xff, 0xe7, 0xff, 0xff, 0xfe, 0x7f, 0xf0,
0x00, 0xff, 0xf9, 0xff, 0xff, 0xf9, 0xff, 0xf0, 0x00, 0xff, 0xfe, 0x7f, 0xff, 0xe7, 0xff, 0xf0, 0x00, 0xff, 0xff,
0x87, 0xfe, 0x1f, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xf8, 0x01, 0xff, 0xff, 0xf0, 0x00};
static const std::array<uint8_t, 546> don_l_bmp = {
0x42, 0x4d, 0x22, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x34,
0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x01, 0x00, 0x00,
0x23, 0x2e, 0x00, 0x00, 0x23, 0x2e, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xfe, 0x3f,
0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0x80, 0x3f, 0xff, 0xff, 0xf0,
0x00, 0xff, 0xff, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xfc, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xf8,
0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xf0, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xe0, 0x00, 0x3f, 0xff,
0xff, 0xf0, 0x00, 0xff, 0xe0, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xc0, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00,
0xff, 0x80, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0x80, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0x00, 0x00,
0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0x00, 0x00, 0x3f, 0xff, 0xff,
0xf0, 0x00, 0xff, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xfe,
0x00, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xfe, 0x00, 0x00, 0x3f,
0xff, 0xff, 0xf0, 0x00, 0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xf0,
0x00, 0xff, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0x00,
0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0x80, 0x00, 0x3f, 0xff,
0xff, 0xf0, 0x00, 0xff, 0x80, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xc0, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00,
0xff, 0xe0, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xe0, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xf0, 0x00,
0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xf8, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xfc, 0x00, 0x3f, 0xff, 0xff,
0xf0, 0x00, 0xff, 0xff, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0x80, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff,
0xff, 0xe0, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00};
static const std::array<uint8_t, 546> don_r_bmp = {
0x42, 0x4d, 0x22, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x34,
0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x01, 0x00, 0x00,
0x23, 0x2e, 0x00, 0x00, 0x23, 0x2e, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc7,
0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x7f, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x1f, 0xff, 0xf0,
0x00, 0xff, 0xff, 0xff, 0xc0, 0x0f, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x03, 0xff, 0xf0, 0x00, 0xff, 0xff,
0xff, 0xc0, 0x01, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00,
0x7f, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x7f, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x3f, 0xf0, 0x00,
0xff, 0xff, 0xff, 0xc0, 0x00, 0x1f, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x1f, 0xf0, 0x00, 0xff, 0xff, 0xff,
0xc0, 0x00, 0x0f, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x0f, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x0f,
0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x0f, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x07, 0xf0, 0x00, 0xff,
0xff, 0xff, 0xc0, 0x00, 0x07, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x07, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0,
0x00, 0x07, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x07, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x07, 0xf0,
0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x0f, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x0f, 0xf0, 0x00, 0xff, 0xff,
0xff, 0xc0, 0x00, 0x0f, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x0f, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00,
0x1f, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x1f, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x3f, 0xf0, 0x00,
0xff, 0xff, 0xff, 0xc0, 0x00, 0x7f, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x7f, 0xf0, 0x00, 0xff, 0xff, 0xff,
0xc0, 0x00, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x03, 0xff,
0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x0f, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x1f, 0xff, 0xf0, 0x00, 0xff,
0xff, 0xff, 0xc0, 0x7f, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00};
static const std::array<uint8_t, 546> ka_l_bmp = {
0x42, 0x4d, 0x22, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x34,
0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x01, 0x00, 0x00,
0x23, 0x2e, 0x00, 0x00, 0x23, 0x2e, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0x80, 0x3f, 0xff, 0xff,
0xf0, 0x00, 0xff, 0xfe, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xf8, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff,
0xf0, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xc0, 0x03, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0x80, 0x3f, 0xff,
0xff, 0xff, 0xf0, 0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xfe, 0x01, 0xff, 0xff, 0xff, 0xff, 0xf0,
0x00, 0xfc, 0x07, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xfc, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xf8, 0x1f,
0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xf0, 0x3f, 0xff, 0xff, 0xff,
0xff, 0xf0, 0x00, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00,
0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xc1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xc1, 0xff, 0xff,
0xff, 0xff, 0xff, 0xf0, 0x00, 0xc1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x81, 0xff, 0xff, 0xff, 0xff, 0xff,
0xf0, 0x00, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x83,
0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x83, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x00, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
0x00, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xc1, 0xff,
0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xc1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xc1, 0xff, 0xff, 0xff, 0xff,
0xff, 0xf0, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00,
0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xf0, 0x3f, 0xff,
0xff, 0xff, 0xff, 0xf0, 0x00, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xfc, 0x0f, 0xff, 0xff, 0xff, 0xff,
0xf0, 0x00, 0xfc, 0x07, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xfe, 0x01, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff,
0x00, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0x80, 0x3f, 0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xc0, 0x03, 0xff,
0xff, 0xff, 0xf0, 0x00, 0xff, 0xf0, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xf8, 0x00, 0x3f, 0xff, 0xff, 0xf0,
0x00, 0xff, 0xfe, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0x80, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff,
0xf8, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00};
static const std::array<uint8_t, 546> ka_r_bmp = {
0x42, 0x4d, 0x22, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x34,
0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x01, 0x00, 0x00,
0x23, 0x2e, 0x00, 0x00, 0x23, 0x2e, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc1, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x1f, 0xff,
0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xf0, 0x00, 0xff,
0xff, 0xff, 0xc0, 0x00, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x3f, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff,
0xc0, 0x1f, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x0f, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x07, 0xf0,
0x00, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x03, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xf0, 0x00, 0xff, 0xff,
0xff, 0xff, 0xff, 0x81, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
0xc0, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x70, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x70, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x30, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x30, 0x00, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf8, 0x30, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x30, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8,
0x10, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x10, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x10, 0x00, 0xff,
0xff, 0xff, 0xff, 0xff, 0xfc, 0x10, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x10, 0x00, 0xff, 0xff, 0xff, 0xff,
0xff, 0xfc, 0x10, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x10, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x10,
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x10, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x10, 0x00, 0xff, 0xff,
0xff, 0xff, 0xff, 0xf8, 0x30, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x30, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
0xf8, 0x30, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x30, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x70, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x70, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf0, 0x00, 0xff, 0xff, 0xff,
0xff, 0xff, 0xc0, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x81, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03,
0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x03, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x07, 0xf0, 0x00, 0xff,
0xff, 0xff, 0xff, 0xf0, 0x0f, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x1f, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xfc,
0x00, 0x3f, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x00, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xf0,
0x00, 0xff, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xc0, 0x1f, 0xff, 0xf0, 0x00, 0xff, 0xff,
0xff, 0xc1, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00};
#endif // _BITMAPS_IDLESCREEN_H_

View File

@ -19,8 +19,6 @@ class Display {
struct Config {
i2c_inst_t *i2c_block;
uint8_t i2c_address;
uint32_t roll_counter_timeout_ms;
};
private:

View File

@ -35,6 +35,7 @@ class Drum {
uint8_t sample_count;
uint16_t debounce_delay_ms;
uint32_t roll_counter_timeout_ms;
bool use_external_adc;
@ -96,6 +97,7 @@ class Drum {
std::map<Id, Pad> m_pads;
private:
void updateRollCounter(Utils::InputState &input_state);
std::map<Id, uint16_t> sampleInputs();
public:

View File

@ -20,6 +20,7 @@ struct InputState {
};
Pad don_left, ka_left, don_right, ka_right;
uint16_t roll_counter;
};
struct Controller {

View File

@ -3,7 +3,6 @@
#include "hardware/gpio.h"
#include "pico/time.h"
#include "bitmaps/IdleScreen.h"
#include "bitmaps/MenuScreens.h"
#include <list>
@ -52,70 +51,15 @@ static std::string modeToString(usb_mode_t mode) {
return "?";
}
static std::vector<uint16_t> updateRollCounters(const Utils::InputState::Drum &drum, const uint32_t timeout_ms) {
struct CounterState {
uint32_t last_triggered_time;
bool last_state;
uint16_t count;
};
static CounterState ka_left_state = {0, false, 0};
static CounterState don_left_state = {0, false, 0};
static CounterState don_right_state = {0, false, 0};
static CounterState ka_right_state = {0, false, 0};
uint32_t now = to_ms_since_boot(get_absolute_time());
auto check_roll = [&](CounterState &target, bool current_state) {
if (current_state && (target.last_state != current_state)) {
if ((now - target.last_triggered_time) > timeout_ms) {
target.count = 0;
}
target.last_triggered_time = now;
target.count++;
}
target.last_state = current_state;
};
check_roll(ka_left_state, drum.ka_left.triggered);
check_roll(don_left_state, drum.don_left.triggered);
check_roll(don_right_state, drum.don_right.triggered);
check_roll(ka_right_state, drum.ka_right.triggered);
return {ka_left_state.count, don_left_state.count, don_right_state.count, ka_right_state.count};
}
void Display::drawIdleScreen() {
// Header
std::string mode_string = modeToString(m_usb_mode) + " mode";
ssd1306_draw_string(&m_display, 0, 0, 1, mode_string.c_str());
ssd1306_draw_line(&m_display, 0, 10, 128, 10);
// Drum
ssd1306_bmp_show_image_with_offset(&m_display, drum_bmp.data(), drum_bmp.size(), 64 - 26, 12);
if (m_input_state.drum.don_left.triggered) {
ssd1306_bmp_show_image_with_offset(&m_display, don_l_bmp.data(), don_l_bmp.size(), 64 - 26, 12);
}
if (m_input_state.drum.don_right.triggered) {
ssd1306_bmp_show_image_with_offset(&m_display, don_r_bmp.data(), don_r_bmp.size(), 64 - 26, 12);
}
if (m_input_state.drum.ka_left.triggered) {
ssd1306_bmp_show_image_with_offset(&m_display, ka_l_bmp.data(), ka_l_bmp.size(), 64 - 26, 12);
}
if (m_input_state.drum.ka_right.triggered) {
ssd1306_bmp_show_image_with_offset(&m_display, ka_r_bmp.data(), ka_r_bmp.size(), 64 - 26, 12);
}
// Roll counters
auto roll_counters = updateRollCounters(m_input_state.drum, m_config.roll_counter_timeout_ms);
int num = 1;
for (const auto &counter : roll_counters) {
ssd1306_draw_string(&m_display, 2, 12 * num, 1, std::to_string(counter).c_str());
num++;
}
// Roll counter
auto roll_str = std::to_string(m_input_state.drum.roll_counter) + " Roll";
ssd1306_draw_string(&m_display, (127 - (roll_str.length() * 12)) / 2, 20, 2, roll_str.c_str());
// Player "LEDs"
if (m_player_id != 0) {

View File

@ -95,6 +95,44 @@ std::map<Drum::Id, uint16_t> Drum::sampleInputs() {
return result;
}
void Drum::updateRollCounter(Utils::InputState &input_state) {
static uint32_t last_hit_time = 0;
static bool last_don_left_state = false;
static bool last_don_right_state = false;
static bool last_ka_left_state = false;
static bool last_ka_right_state = false;
static uint16_t roll_count = 0;
uint32_t now = to_ms_since_boot(get_absolute_time());
if ((now - last_hit_time) > m_config.roll_counter_timeout_ms) {
roll_count = 0;
}
if (input_state.drum.don_left.triggered && (last_don_left_state != input_state.drum.don_left.triggered)) {
last_hit_time = now;
roll_count++;
}
if (input_state.drum.don_right.triggered && (last_don_right_state != input_state.drum.don_right.triggered)) {
last_hit_time = now;
roll_count++;
}
if (input_state.drum.ka_right.triggered && (last_ka_right_state != input_state.drum.ka_right.triggered)) {
last_hit_time = now;
roll_count++;
}
if (input_state.drum.ka_left.triggered && (last_ka_left_state != input_state.drum.ka_left.triggered)) {
last_hit_time = now;
roll_count++;
}
last_don_left_state = input_state.drum.don_left.triggered;
last_don_right_state = input_state.drum.don_right.triggered;
last_ka_left_state = input_state.drum.ka_left.triggered;
last_ka_right_state = input_state.drum.ka_right.triggered;
input_state.drum.roll_counter = roll_count;
}
void Drum::updateInputState(Utils::InputState &input_state) {
// Oversample ADC inputs to get rid of ADC noise
const auto raw_values = sampleInputs();
@ -140,6 +178,8 @@ void Drum::updateInputState(Utils::InputState &input_state) {
input_state.drum.ka_left.triggered = m_pads.at(Id::KA_LEFT).getState();
input_state.drum.don_right.triggered = m_pads.at(Id::DON_RIGHT).getState();
input_state.drum.ka_right.triggered = m_pads.at(Id::KA_RIGHT).getState();
updateRollCounter(input_state);
}
void Drum::setDebounceDelay(const uint16_t delay) { m_config.debounce_delay_ms = delay; }

View File

@ -6,7 +6,7 @@
namespace Doncon::Utils {
InputState::InputState()
: drum({{false, 0}, {false, 0}, {false, 0}, {false, 0}}),
: drum({{false, 0}, {false, 0}, {false, 0}, {false, 0}, 0}),
controller(
{{false, false, false, false}, {false, false, false, false, false, false, false, false, false, false}}),
m_switch_report({}), m_ps3_report({}), m_ps4_report({}), m_keyboard_report({}),
@ -328,7 +328,7 @@ usb_report_t InputState::getDebugReport() {
}
void InputState::releaseAll() {
drum = {{false, 0}, {false, 0}, {false, 0}, {false, 0}};
drum = {{false, 0}, {false, 0}, {false, 0}, {false, 0}, 0};
controller = {{false, false, false, false}, {false, false, false, false, false, false, false, false, false, false}};
}