Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Keyboard] Add BINEPAD BNK9 #22831

Merged
merged 18 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions keyboards/binepad/bnk9/bnk9.h
silvinor marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2023 binepad (@binepad)
silvinor marked this conversation as resolved.
Show resolved Hide resolved
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#ifdef VIA_ENABLE // Only works if VIA is enabled

# define EEPROM_USER_CONFIG_ADDRESS (VIA_EEPROM_CUSTOM_CONFIG_ADDR + 1)

# include "color.h"

typedef struct PACKED {
uint8_t h;
uint8_t s;
} HS;

typedef struct {
HS color[9];
} user_config_t;

extern user_config_t user_config;

#endif // VIA_ENABLE
122 changes: 122 additions & 0 deletions keyboards/binepad/bnk9/bnk9_effect.c
zvecr marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// Copyright 2023 Binepad (@binpad)
// SPDX-License-Identifier: GPL-2.0-or-later

#include "quantum.h"

#ifdef VIA_ENABLE // Only works if VIA is enabled

#include "color.h"
#include "progmem.h"
#include "quantum/color.h"
#include "eeprom.h"
#include "bnk9.h"

#ifndef EEPROM_USER_CONFIG_ADDRESS
#error EEPROM_USER_CONFIG_ADDRESS not defined
#endif
#if EEPROM_USER_CONFIG_ADDRESS == 0
#error EEPROM_USER_CONFIG_ADDRESS = 0
#endif

#define RGB_PER_KEY_DEFAULT_COLOR { .h = RGB_MATRIX_DEFAULT_HUE, .s = RGB_MATRIX_DEFAULT_SAT }

user_config_t user_config = {
.color = {
RGB_PER_KEY_DEFAULT_COLOR,
RGB_PER_KEY_DEFAULT_COLOR,
RGB_PER_KEY_DEFAULT_COLOR,
RGB_PER_KEY_DEFAULT_COLOR,
RGB_PER_KEY_DEFAULT_COLOR,
RGB_PER_KEY_DEFAULT_COLOR,
RGB_PER_KEY_DEFAULT_COLOR,
RGB_PER_KEY_DEFAULT_COLOR,
RGB_PER_KEY_DEFAULT_COLOR
}
};

enum via_per_key_value {
id_custom_color = 1
};

// *** Helpers ***

void bkn9_config_set_value( uint8_t *data ) {
uint8_t *value_id = &(data[0]);
uint8_t *value_data = &(data[1]);

switch ( *value_id ) {
case id_custom_color: {
uint8_t i = value_data[0];
user_config.color[ i ].h = value_data[1];
user_config.color[ i ].s = value_data[2];
break;
}
}
}

void bkn9_config_get_value( uint8_t *data ) {
uint8_t *value_id = &(data[0]);
uint8_t *value_data = &(data[1]);

switch ( *value_id ) {
case id_custom_color: {
uint8_t i = value_data[0];
value_data[1] = user_config.color[ i ].h;
value_data[2] = user_config.color[ i ].s;
break;
}
}
}

void bkn9_config_load(void) {
eeprom_read_block(
&user_config,
((void*)EEPROM_USER_CONFIG_ADDRESS),
sizeof(user_config_t) );
}

void bkn9_config_save(void) {
eeprom_update_block(
&user_config,
((void*)EEPROM_USER_CONFIG_ADDRESS),
sizeof(user_config_t) );
}

void via_custom_value_command_kb(uint8_t *data, uint8_t length) {
uint8_t *command_id = &(data[0]);
uint8_t *channel_id = &(data[1]);
uint8_t *value_id_and_data = &(data[2]);

if ( *channel_id == id_custom_channel ) {
switch ( *command_id ) {
case id_custom_set_value:
bkn9_config_set_value(value_id_and_data);
break;
case id_custom_get_value:
bkn9_config_get_value(value_id_and_data);
break;
case id_custom_save:
bkn9_config_save();
break;
default:
// Unhandled message.
*command_id = id_unhandled;
break;
}
return;
}

*command_id = id_unhandled;
}

void via_init_kb(void) {
// This checks both an EEPROM reset (from bootmagic lite, keycodes)
// and also firmware build date (from via_eeprom_is_valid())
if (eeconfig_is_enabled()) {
bkn9_config_load();
} else {
bkn9_config_save();
}
}

#endif // VIA_ENABLE
22 changes: 22 additions & 0 deletions keyboards/binepad/bnk9/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2023 binepad (@binepad)
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#define ENCODER_DEFAULT_POS 0x3 // enable 1:1 resolution

#ifdef RGB_MATRIX_ENABLE
#define WS2812_PIO_USE_PIO1
// #define RGB_MATRIX_TIMEOUT 600000 // 10 minutes
#define RGB_DISABLE_WITH_FADE_OUTS
#define RGB_DISABLE_WHEN_USB_SUSPENDED
#define RGB_MATRIX_LED_PROCESS_LIMIT 9 // All nine keys
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 180 // Not too bright so that the LED's don't burn out

// Timing for SK6812
#define WS2812_TIMING 1250
#define WS2812_T0H 350
#define WS2812_T0L (WS2812_TIMING - WS2812_T0H)
#define WS2812_T1H 650
#define WS2812_T1L (WS2812_TIMING - WS2812_T1H)
#endif
silvinor marked this conversation as resolved.
Show resolved Hide resolved
96 changes: 96 additions & 0 deletions keyboards/binepad/bnk9/info.json
silvinor marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"manufacturer": "binepad",
"keyboard_name": "BNK9",
"url": "https://www.binepad.com/product-page/bnk9",
"maintainer": "binepad",
"board": "GENERIC_RP_RP2040",
"processor": "RP2040",
"bootloader": "rp2040",
"bootloader_instructions": "Hold down the key at (0x0) in the matrix (the 'knob' / rotary encoder) and plug in the keyboard.",
"diode_direction": "COL2ROW",
"usb": {
"vid": "0x4249",
"pid": "0x4E39",
"device_version": "1.0.0"
},
"features": {
"bootmagic": true,
"command": false,
"console": false,
silvinor marked this conversation as resolved.
Show resolved Hide resolved
"extrakey": true,
"mousekey": true,
"nkro": true,
"encoder": true,
"encoder_map": true,
silvinor marked this conversation as resolved.
Show resolved Hide resolved
"rgb_matrix": true,
"sleep_led": false
silvinor marked this conversation as resolved.
Show resolved Hide resolved
},
"ws2812": {
"driver": "vendor",
"pin": "GP11"
},
"matrix_pins": {
"cols": ["GP1", "GP2", "GP3"],
"rows": ["GP12", "GP4", "GP5", "GP6"]
},
"encoder": {
"rotary": [
{
"pin_a": "GP13",
"pin_b": "GP14"
}
]
},
"rgb_matrix": {
"driver": "ws2812",
"animations": {
"solid_color": true,
"breathing": true,
"cycle_all": true,
"cycle_left_right": true,
"cycle_up_down": true,
"cycle_pinwheel": true,
"jellybean_raindrops": true,
"solid_reactive_simple": true,
"solid_reactive": true,
"splash": true,
"solid_splash": true,
"starlight": true,
"starlight_dual_hue": true,
"starlight_dual_sat": true,
"riverflow": true
},
"layout": [
{"flags": 4, "matrix": [1, 0], "x": 80, "y": 0},
{"flags": 4, "matrix": [1, 1], "x": 112, "y": 0},
{"flags": 4, "matrix": [1, 2], "x": 144, "y": 0},

{"flags": 4, "matrix": [2, 2], "x": 144, "y": 32},
{"flags": 4, "matrix": [2, 1], "x": 112, "y": 32},
{"flags": 4, "matrix": [2, 0], "x": 80, "y": 32},

{"flags": 4, "matrix": [3, 0], "x": 80, "y": 64},
{"flags": 4, "matrix": [3, 1], "x": 112, "y": 64},
{"flags": 4, "matrix": [3, 2], "x": 144, "y": 64}
]
silvinor marked this conversation as resolved.
Show resolved Hide resolved
}
"layouts": {
"LAYOUT": {
"layout": [
{ "matrix": [0, 0], "label": "Knob", "x": 0, "y": 0, "w": 3, "h": 3 },

{ "matrix": [1, 0], "label": "1", "x": 3.25, "y": 0 },
{ "matrix": [1, 1], "label": "2", "x": 4.25, "y": 0 },
{ "matrix": [1, 2], "label": "3", "x": 5.25, "y": 0 },

{ "matrix": [2, 0], "label": "4", "x": 3.25, "y": 1 },
{ "matrix": [2, 1], "label": "5", "x": 4.25, "y": 1 },
{ "matrix": [2, 2], "label": "6", "x": 5.25, "y": 1 },

{ "matrix": [3, 0], "label": "7", "x": 3.25, "y": 2 },
{ "matrix": [3, 1], "label": "8", "x": 4.25, "y": 2 },
{ "matrix": [3, 2], "label": "9", "x": 5.25, "y": 2 }
]
}
}
}
28 changes: 28 additions & 0 deletions keyboards/binepad/bnk9/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2023 Binepad (@binpad)
// SPDX-License-Identifier: GPL-2.0-or-later

#include QMK_KEYBOARD_H

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(
KC_MUTE,
KC_P1, KC_P2, KC_P3,
KC_P4, KC_P5, KC_P6,
KC_P7, KC_P8, LT(1, KC_P9)
),
[1] = LAYOUT(
RGB_TOG,
RGB_HUI, RGB_SAI, RGB_SPI,
RGB_HUD, RGB_SAD, RGB_SPD,
RGB_RMOD, RGB_MOD, _______
)
};

#if defined(ENCODER_MAP_ENABLE)

const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
[0] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
[1] = { ENCODER_CCW_CW(RGB_VAD, RGB_VAI) }
};

#endif
28 changes: 28 additions & 0 deletions keyboards/binepad/bnk9/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2023 Binepad (@binpad)
// SPDX-License-Identifier: GPL-2.0-or-later

#include QMK_KEYBOARD_H

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(
KC_MUTE,
KC_P1, KC_P2, KC_P3,
KC_P4, KC_P5, KC_P6,
KC_P7, KC_P8, LT(1, KC_P9)
),
[1] = LAYOUT(
RGB_TOG,
RGB_HUI, RGB_SAI, RGB_SPI,
RGB_HUD, RGB_SAD, RGB_SPD,
RGB_RMOD, RGB_MOD, _______
)
};

#if defined(ENCODER_MAP_ENABLE)

const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
[0] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
[1] = { ENCODER_CCW_CW(RGB_VAD, RGB_VAI) }
};

#endif
3 changes: 3 additions & 0 deletions keyboards/binepad/bnk9/keymaps/via/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @see `info.json` for config

silvinor marked this conversation as resolved.
Show resolved Hide resolved
VIA_ENABLE = yes
18 changes: 18 additions & 0 deletions keyboards/binepad/bnk9/mcuconf.h
silvinor marked this conversation as resolved.
Show resolved Hide resolved
silvinor marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2023 binepad (@binepad)
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include_next <mcuconf.h>

// Don't need SPI
#undef RP_SPI_USE_SPI0
#define RP_SPI_USE_SPI0 FALSE

// Don't need I2C
#undef RP_I2C_USE_I2C1
#define RP_I2C_USE_I2C1 FALSE

// Don't need ADC
#undef RP_ADC_USE_ADC1
#define RP_ADC_USE_ADC1 FALSE
27 changes: 27 additions & 0 deletions keyboards/binepad/bnk9/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# BINEPAD BNK9

![BINEPAD BNK9](https://i.imgur.com/FrkVRhhh.jpg)

*A 3x3 macropad with a large rotary encoder*
silvinor marked this conversation as resolved.
Show resolved Hide resolved

* Keyboard Maintainer: [binepad](https://github.com/binepad)
* Hardware Supported: BINPAD BNK9
* Hardware Availability: [binepad.com](https://www.binepad.com/product-page/bnk9)

Make example for this keyboard (after setting up your build environment):

make binepad/bnk9:default

Flashing example for this keyboard:

make binepad/bnk9:default:flash

See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).

## Bootloader

Enter the bootloader in 3 ways:

* **Bootmagic reset**: Hold down the key at (0x0) in the matrix (the 'knob' / rotary encoder) and plug in the keyboard.
* **Physical reset button**: Briefly press the PCB button located on the back of the PCB.
* **Keycode in layout**: Press the key mapped to `QK_BOOT` *(or* `RESET` *in VIA)* if it is available.
Loading