[Keyboard] Add audio support to Adafruit MacroPad RP2040 (#20353)

master
Drashna Jaelre 2023-04-07 17:59:13 -07:00 committed by GitHub
parent a5e68e5f74
commit 2c375e6478
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 53 additions and 11 deletions

View File

@ -42,9 +42,14 @@
#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_LED GP13
#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_TIMEOUT 500U
/* Audio (Unsupported for now)*/
// #define AUDIO_PIN GP16
// #define SPEAKER_SHUTDOWN GP14
/* Audio */
#define AUDIO_PIN GP16
#define AUDIO_PWM_DRIVER PWMD0
#define AUDIO_PWM_CHANNEL RP2040_PWM_CHANNEL_A
#define AUDIO_INIT_DELAY
#define AUDIO_CLICKY
#define SPEAKER_SHUTDOWN GP14
#ifdef RGB_MATRIX_ENABLE

View File

@ -26,3 +26,6 @@
#undef SPI_SELECT_MODE
#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD
#undef HAL_USE_PWM
#define HAL_USE_PWM TRUE

View File

@ -18,17 +18,25 @@
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(
KC_MUTE,
LT(1,KC_MUTE),
KC_ENT, KC_0, KC_BSPC,
KC_7, KC_8, KC_9,
KC_4, KC_5, KC_6,
KC_1, KC_2, KC_3
)
),
[1] = LAYOUT(
_______,
CK_TOGG, AU_TOGG, _______,
_______, _______, _______,
_______, _______, _______,
_______, _______, _______
),
};
#ifdef ENCODER_MAP_ENABLE
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
[0] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
[1] = { ENCODER_CCW_CW(_______, _______) },
};
#endif
@ -111,4 +119,3 @@ bool oled_task_user(void) {
}
#endif

View File

@ -18,7 +18,7 @@
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(
KC_MUTE,
LT(1,KC_MUTE),
KC_ENT, KC_0, KC_BSPC,
KC_7, KC_8, KC_9,
KC_4, KC_5, KC_6,
@ -26,7 +26,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
),
[1] = LAYOUT(
_______,
_______, _______, _______,
CK_TOGG, AU_TOGG, _______,
_______, _______, _______,
_______, _______, _______,
_______, _______, _______
@ -135,4 +135,3 @@ bool oled_task_user(void) {
}
#endif

View File

@ -41,6 +41,31 @@ led_config_t g_led_config = { {
#endif
#ifdef AUDIO_ENABLE
void keyboard_pre_init_kb(void) {
// ensure pin is set and enabled pre-audio init
setPinOutput(SPEAKER_SHUTDOWN);
writePinHigh(SPEAKER_SHUTDOWN);
keyboard_pre_init_user();
}
void keyboard_post_init_kb(void) {
// set pin based on active status
writePin(SPEAKER_SHUTDOWN, audio_is_on());
keyboard_post_init_user();
}
void audio_on_user(void) {
writePinHigh(SPEAKER_SHUTDOWN);
}
void audio_off_user(void) {
// needs a delay or it runs right after play note.
wait_ms(200);
writePinLow(SPEAKER_SHUTDOWN);
}
#endif
#ifdef ENCODER_ENABLE
bool encoder_update_kb(uint8_t index, bool clockwise) {
if (!encoder_update_user(index, clockwise)) { return false; }

View File

@ -20,3 +20,6 @@
#undef RP_SPI_USE_SPI1
#define RP_SPI_USE_SPI1 TRUE
#undef RP_PWM_USE_PWM0
#define RP_PWM_USE_PWM0 TRUE

View File

@ -9,8 +9,8 @@ COMMAND_ENABLE = no # Commands for debug and configuration
NKRO_ENABLE = yes # Enable N-Key Rollover
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
AUDIO_ENABLE = no # Audio output
# AUDIO_DRIVER = pwm_software
AUDIO_ENABLE = yes # Audio output
AUDIO_DRIVER = pwm_hardware
ENCODER_ENABLE = yes
RGB_MATRIX_ENABLE = yes
RGB_MATRIX_DRIVER = WS2812