adding ergosentry ansi

This commit is contained in:
David Hoelscher 2024-12-03 21:01:57 -06:00
parent 04fbcdc68d
commit 819028dd28
12 changed files with 957 additions and 0 deletions

View File

@ -0,0 +1,114 @@
// Copyright 2025 customMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include <stdbool.h>
#include "cmk_cm6646.h"
static bool cm6646_enabled = 0;
static bool mic_mute_pressed = 0;
static bool cm6646_enabled_prev = 0;
static bool starting_up = false;
void update_mic_mute_led(void) {
if (!starting_up) {
//mic mute is stateful within CM6646, so simply convey the status provided by CM6646 (when enabled)
if (cm6646_enabled) {
gpio_write_pin(LED_MIC_MUTE_PIN, (CMK_6646_LED_PIN_ON_STATE == gpio_read_pin(MIC_MUTE_STATE_PIN)));
}
else {
gpio_write_pin(LED_MIC_MUTE_PIN, !CMK_6646_LED_PIN_ON_STATE);
}
}
}
void update_mic_mute_control(void) {
// This function briefly asserts MIC_MUTE_CONTROL_PIN
// whenever the mic mute keycode is pressed. CM6646
// has internal debouncing of this pin, so we are just
// simulating a mechanical key being pressed
static uint32_t mic_mute_timer = 0;
static bool mic_mute_in_progress = 0;
if (mic_mute_in_progress) {
if (timer_elapsed32(mic_mute_timer) > 40) {
gpio_write_pin(MIC_MUTE_CONTROL_PIN, 0);
mic_mute_in_progress = 0;
mic_mute_pressed = 0;
}
}
else if (mic_mute_pressed) {
mic_mute_pressed = 0;
mic_mute_in_progress = 1;
gpio_write_pin(MIC_MUTE_CONTROL_PIN, 1);
mic_mute_timer = timer_read32();
}
}
void update_usb_audio_enable(void) {
static uint32_t start_up_timer = 0;
static uint32_t led_flash_counter = 0;
static bool LED_state = CMK_6646_LED_PIN_ON_STATE;
gpio_write_pin(USB_AUDIO_ENABLE_PIN, cm6646_enabled);
if (cm6646_enabled) {
if (!cm6646_enabled_prev) {
starting_up = true;
start_up_timer = timer_read32();
led_flash_counter = 0;
}
if (starting_up == true) {
if (timer_elapsed32(start_up_timer) > 500) {
if (led_flash_counter > 8) {
starting_up = false;
} else {
//wait for CM6646 to initialize
//flash the mic mute LED while waiting
gpio_write_pin(LED_MIC_MUTE_PIN, LED_state);
LED_state = !LED_state;
start_up_timer = timer_read32();
led_flash_counter++;
}
}
}
}
else {
starting_up = false;
start_up_timer = 0;
led_flash_counter = 0;
}
cm6646_enabled_prev = cm6646_enabled;
}
void process_record_cmk_cm6646(uint16_t keycode, keyrecord_t *record) {
if (keycode == KB_MIC_MUTE) {
if (record->event.pressed) {
mic_mute_pressed = 1;
}
}
else if (keycode == KB_USB_AUDIO_TOGGLE) {
if (record->event.pressed) {
cm6646_enabled = !cm6646_enabled;
}
}
}
void cmk_cmk6646_init(bool enabled) {
gpio_set_pin_input(MIC_MUTE_STATE_PIN);
gpio_set_pin_output(LED_MIC_MUTE_PIN);
gpio_set_pin_output(MIC_MUTE_CONTROL_PIN);
gpio_write_pin(MIC_MUTE_CONTROL_PIN, 0);
gpio_set_pin_output(USB_AUDIO_ENABLE_PIN);
cm6646_enabled = enabled;
cm6646_enabled_prev = false;
update_usb_audio_enable();
}
bool cmk_cmk6646_housekeeping_task(void) {
update_mic_mute_control();
update_mic_mute_led();
update_usb_audio_enable();
// Return value is enabled state of the CM6646
return cm6646_enabled;
}

View File

@ -0,0 +1,45 @@
// Copyright 2025 customMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include "quantum.h"
#pragma once
#ifndef CMK_CM6646_KEYCODES_START
# define CMK_CM6646_KEYCODES_START QK_KB_0
#endif
#ifndef CMK_CM6646_KEYCODES_END
# define CMK_CM6646_KEYCODES_END QK_KB_2
#endif
#define CMK_CM6646_NUM_KEYCODES 2
#ifndef LED_MIC_MUTE_PIN
# define LED_MIC_MUTE_PIN B13
#endif
#ifndef MIC_MUTE_STATE_PIN
# define MIC_MUTE_STATE_PIN B9
#endif
#ifndef MIC_MUTE_CONTROL_PIN
# define MIC_MUTE_CONTROL_PIN A0
#endif
#ifndef USB_AUDIO_ENABLE_PIN
# define USB_AUDIO_ENABLE_PIN B6
#endif
#ifndef CMK_6646_LED_PIN_ON_STATE
# define CMK_6646_LED_PIN_ON_STATE 0
#endif
enum cmk_cm6646_keycodes {
KB_MIC_MUTE = CMK_CM6646_KEYCODES_START,
KB_USB_AUDIO_TOGGLE
};
void process_record_cmk_cm6646(uint16_t keycode, keyrecord_t *record);
void cmk_cmk6646_init(bool enabled);
bool cmk_cmk6646_housekeeping_task(void);

View File

@ -0,0 +1,48 @@
// Copyright 2025 customMK
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
// FRAM configuration
#define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN B7
#define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 4
// SPI configuration
#define SPI_DRIVER SPID1
#define SPI_SCK_PIN B3
#define SPI_MOSI_PIN B5
#define SPI_MISO_PIN B4
// Audio configuration
#define AUDIO_PIN B8
#define AUDIO_PWM_DRIVER PWMD4
#define AUDIO_PWM_CHANNEL 3
#define AUDIO_PWM_PAL_MODE 2
#define AUDIO_STATE_TIMER GPTD5
#define AUDIO_INIT_DELAY
// RGB Matrix configuration
#define WS2812_PWM_DRIVER PWMD1
#define WS2812_PWM_CHANNEL 3
#define WS2812_PWM_PAL_MODE 1
#define WS2812_DMA_STREAM STM32_DMA2_STREAM5
#define WS2812_DMA_CHANNEL 6
// Switch matrix configuration
#define COL_SHIFT_IN_PIN A2
#define COL_SHIFT_CLK_PIN A3
#define MATRIX_ROWS 7
#define MATRIX_COLS 32
#define MATRIX_ROW_PINS { C13, C14, C15, B1, A7, A5, A6 }
#define LED_CAPS_LOCK_PIN B10
#define LED_NUM_LOCK_PIN B0
#define LED_SCROLL_LOCK_PIN A1
#define LED_MIC_MUTE_PIN B13
#define MIC_MUTE_STATE_PIN B9
#define MIC_MUTE_CONTROL_PIN A0
#define USB_AUDIO_ENABLE_PIN B6
#define LED_PIN_ON_STATE 0

View File

@ -0,0 +1,51 @@
// Copyright 2025 customMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include <stdbool.h>
#include "keyboards/custommk/cmk_cm6646.h"
typedef union {
uint32_t raw;
struct {
bool usb_audio_enabled;
};
} user_config_t;
user_config_t user_config;
void update_kb_eeprom(void) {
eeconfig_update_kb(user_config.raw);
}
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
process_record_cmk_cm6646(keycode, record);
return process_record_user(keycode, record);
}
void keyboard_post_init_kb(void) {
user_config.raw = eeconfig_read_kb();
cmk_cmk6646_init(user_config.usb_audio_enabled);
keyboard_post_init_user();
}
void housekeeping_task_kb(void) {
bool usb_audio_enabled;
usb_audio_enabled = cmk_cmk6646_housekeeping_task();
if (usb_audio_enabled != user_config.usb_audio_enabled) {
user_config.usb_audio_enabled = usb_audio_enabled;
update_kb_eeprom();
}
}
void eeconfig_init_kb() {
//enable nkro by default (not forced)
keymap_config.raw = eeconfig_read_keymap();
keymap_config.nkro = 1;
eeconfig_update_keymap(keymap_config.raw);
//enable audio by default (not forced)
user_config.raw = eeconfig_read_kb();
user_config.usb_audio_enabled = 1;
eeconfig_update_kb(user_config.raw);
}

View File

@ -0,0 +1,18 @@
// Copyright 2025 customMK
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#define HAL_USE_PWM TRUE
#define HAL_USE_SPI TRUE
#define HAL_USE_GPT TRUE
#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD
#define SERIAL_BUFFERS_SIZE 256
#define SPI_USE_WAIT TRUE
#include_next <halconf.h>

View File

@ -0,0 +1,470 @@
{
"manufacturer": "customMK",
"keyboard_name": "ErgoSentry ANSI",
"maintainer": "customMK",
"bootloader": "stm32-dfu",
"debounce": 10,
"diode_direction": "ROW2COL",
"audio": {
"driver": "pwm_hardware"
},
"dynamic_keymap": {
"layer_count": 12
},
"eeprom": {
"driver": "spi"
},
"encoder": {
"rotary": [
{ "pin_a": "A8", "pin_b": "A4", "resolution": 2},
{ "pin_a": "B12", "pin_b": "B14", "resolution": 2},
{ "pin_a": "B15", "pin_b": "A15", "resolution": 2}
]
},
"features": {
"command": false,
"console": false,
"audio": true,
"bootmagic": true,
"encoder": true,
"extrakey": true,
"mousekey": true,
"nkro": true,
"rgb_matrix": true
},
"processor": "STM32F411",
"qmk": {
"tap_keycode_delay": 10
},
"build": {
"debounce_type": "sym_eager_pk"
},
"rgb_matrix": {
"animations": {
"alphas_mods": true,
"band_pinwheel_sat": true,
"band_pinwheel_val": true,
"band_sat": true,
"band_spiral_sat": true,
"band_spiral_val": true,
"band_val": true,
"breathing": true,
"cycle_all": true,
"cycle_left_right": true,
"cycle_out_in": true,
"cycle_out_in_dual": true,
"cycle_pinwheel": true,
"cycle_spiral": true,
"cycle_up_down": true,
"digital_rain": true,
"dual_beacon": true,
"gradient_left_right": true,
"gradient_up_down": true,
"hue_breathing": true,
"hue_pendulum": true,
"hue_wave": true,
"jellybean_raindrops": true,
"multisplash": true,
"pixel_flow": true,
"pixel_fractal": true,
"pixel_rain": true,
"rainbow_beacon": true,
"rainbow_moving_chevron": true,
"rainbow_pinwheels": true,
"raindrops": true,
"solid_multisplash": true,
"solid_reactive": true,
"solid_reactive_cross": true,
"solid_reactive_multicross": true,
"solid_reactive_multinexus": true,
"solid_reactive_multiwide": true,
"solid_reactive_nexus": true,
"solid_reactive_simple": true,
"solid_reactive_wide": true,
"solid_splash": true,
"splash": true,
"typing_heatmap": true
},
"center_point": [112, 30],
"driver": "ws2812",
"layout": [
{"matrix": [6, 0], "x": 65, "y": 54, "flags": 4},
{"matrix": [6, 1], "x": 76, "y": 54, "flags": 4},
{"matrix": [6, 4], "x": 87, "y": 54, "flags": 4},
{"matrix": [6, 7], "x": 119, "y": 54, "flags": 4},
{"matrix": [6, 10], "x": 151, "y": 54, "flags": 4},
{"matrix": [6, 12], "x": 160, "y": 54, "flags": 4},
{"matrix": [6, 13], "x": 168, "y": 54, "flags": 4},
{"matrix": [6, 14], "x": 177, "y": 54, "flags": 4},
{"matrix": [6, 15], "x": 185, "y": 54, "flags": 4},
{"matrix": [6, 21], "x": 194, "y": 54, "flags": 4},
{"matrix": [6, 17], "x": 205, "y": 54, "flags": 4},
{"matrix": [6, 18], "x": 214, "y": 54, "flags": 4},
{"matrix": [6, 19], "x": 225, "y": 47, "flags": 4},
{"matrix": [5, 18], "x": 214, "y": 45, "flags": 4},
{"matrix": [5, 17], "x": 205, "y": 45, "flags": 4},
{"matrix": [5, 16], "x": 196, "y": 45, "flags": 4},
{"matrix": [5, 15], "x": 185, "y": 45, "flags": 4},
{"matrix": [5, 14], "x": 174, "y": 45, "flags": 4},
{"matrix": [5, 13], "x": 162, "y": 45, "flags": 4},
{"matrix": [5, 12], "x": 153, "y": 45, "flags": 4},
{"matrix": [5, 10], "x": 144, "y": 45, "flags": 4},
{"matrix": [5, 9], "x": 136, "y": 45, "flags": 4},
{"matrix": [5, 8], "x": 127, "y": 45, "flags": 4},
{"matrix": [5, 7], "x": 118, "y": 45, "flags": 4},
{"matrix": [5, 6], "x": 110, "y": 45, "flags": 4},
{"matrix": [5, 5], "x": 101, "y": 45, "flags": 4},
{"matrix": [5, 4], "x": 92, "y": 45, "flags": 4},
{"matrix": [5, 2], "x": 84, "y": 45, "flags": 4},
{"matrix": [5, 0], "x": 70, "y": 45, "flags": 4},
{"matrix": [4, 0], "x": 65, "y": 37, "flags": 4},
{"matrix": [4, 2], "x": 79, "y": 37, "flags": 4},
{"matrix": [4, 4], "x": 88, "y": 37, "flags": 4},
{"matrix": [4, 5], "x": 97, "y": 37, "flags": 4},
{"matrix": [4, 6], "x": 105, "y": 37, "flags": 4},
{"matrix": [4, 7], "x": 114, "y": 37, "flags": 4},
{"matrix": [4, 8], "x": 123, "y": 37, "flags": 4},
{"matrix": [4, 9], "x": 131, "y": 37, "flags": 4},
{"matrix": [4, 10], "x": 140, "y": 37, "flags": 4},
{"matrix": [4, 12], "x": 149, "y": 37, "flags": 4},
{"matrix": [4, 13], "x": 157, "y": 37, "flags": 4},
{"matrix": [4, 14], "x": 166, "y": 37, "flags": 4},
{"matrix": [4, 15], "x": 180, "y": 37, "flags": 4},
{"matrix": [4, 16], "x": 196, "y": 37, "flags": 4},
{"matrix": [4, 17], "x": 205, "y": 37, "flags": 4},
{"matrix": [4, 18], "x": 214, "y": 37, "flags": 4},
{"matrix": [4, 19], "x": 225, "y": 30, "flags": 4},
{"matrix": [3, 18], "x": 214, "y": 28, "flags": 4},
{"matrix": [3, 17], "x": 205, "y": 28, "flags": 4},
{"matrix": [3, 16], "x": 196, "y": 28, "flags": 4},
{"matrix": [3, 15], "x": 183, "y": 28, "flags": 4},
{"matrix": [3, 14], "x": 173, "y": 28, "flags": 4},
{"matrix": [3, 13], "x": 164, "y": 28, "flags": 4},
{"matrix": [3, 12], "x": 155, "y": 28, "flags": 4},
{"matrix": [3, 10], "x": 147, "y": 28, "flags": 4},
{"matrix": [3, 9], "x": 138, "y": 28, "flags": 4},
{"matrix": [3, 8], "x": 128, "y": 28, "flags": 4},
{"matrix": [3, 7], "x": 121, "y": 28, "flags": 4},
{"matrix": [3, 6], "x": 112, "y": 28, "flags": 4},
{"matrix": [3, 5], "x": 103, "y": 28, "flags": 4},
{"matrix": [3, 4], "x": 95, "y": 28, "flags": 4},
{"matrix": [3, 2], "x": 86, "y": 28, "flags": 4},
{"matrix": [3, 1], "x": 77, "y": 28, "flags": 4},
{"matrix": [3, 0], "x": 66, "y": 28, "flags": 4},
{"matrix": [2, 0], "x": 64, "y": 19, "flags": 4},
{"matrix": [2, 1], "x": 73, "y": 19, "flags": 4},
{"matrix": [2, 2], "x": 82, "y": 19, "flags": 4},
{"matrix": [2, 4], "x": 90, "y": 19, "flags": 4},
{"matrix": [2, 5], "x": 99, "y": 19, "flags": 4},
{"matrix": [2, 6], "x": 108, "y": 19, "flags": 4},
{"matrix": [2, 7], "x": 116, "y": 19, "flags": 4},
{"matrix": [2, 8], "x": 125, "y": 19, "flags": 4},
{"matrix": [2, 9], "x": 134, "y": 19, "flags": 4},
{"matrix": [2, 10], "x": 142, "y": 19, "flags": 4},
{"matrix": [2, 12], "x": 151, "y": 19, "flags": 4},
{"matrix": [2, 13], "x": 160, "y": 19, "flags": 4},
{"matrix": [2, 14], "x": 168, "y": 19, "flags": 4},
{"matrix": [2, 15], "x": 181, "y": 19, "flags": 4},
{"matrix": [2, 16], "x": 196, "y": 19, "flags": 4},
{"matrix": [2, 17], "x": 205, "y": 19, "flags": 4},
{"matrix": [2, 18], "x": 214, "y": 19, "flags": 4},
{"matrix": [2, 19], "x": 222, "y": 19, "flags": 4},
{"matrix": [1, 19], "x": 222, "y": 9, "flags": 4},
{"matrix": [1, 18], "x": 214, "y": 9, "flags": 4},
{"matrix": [1, 17], "x": 205, "y": 9, "flags": 4},
{"matrix": [1, 16], "x": 196, "y": 9, "flags": 4},
{"matrix": [1, 15], "x": 185, "y": 9, "flags": 4},
{"matrix": [1, 14], "x": 175, "y": 9, "flags": 4},
{"matrix": [1, 13], "x": 166, "y": 9, "flags": 4},
{"matrix": [1, 12], "x": 157, "y": 9, "flags": 4},
{"matrix": [1, 10], "x": 149, "y": 9, "flags": 4},
{"matrix": [1, 9], "x": 138, "y": 9, "flags": 4},
{"matrix": [1, 8], "x": 129, "y": 9, "flags": 4},
{"matrix": [1, 7], "x": 121, "y": 9, "flags": 4},
{"matrix": [1, 6], "x": 112, "y": 9, "flags": 4},
{"matrix": [1, 5], "x": 101, "y": 9, "flags": 4},
{"matrix": [1, 4], "x": 92, "y": 9, "flags": 4},
{"matrix": [1, 2], "x": 84, "y": 9, "flags": 4},
{"matrix": [1, 1], "x": 75, "y": 9, "flags": 4},
{"matrix": [0, 0], "x": 64, "y": 9, "flags": 4},
{"matrix": [0, 1], "x": 75, "y": 0, "flags": 4},
{"matrix": [0, 2], "x": 84, "y": 0, "flags": 4},
{"matrix": [0, 4], "x": 92, "y": 0, "flags": 4},
{"matrix": [0, 5], "x": 101, "y": 0, "flags": 4},
{"matrix": [0, 6], "x": 112, "y": 0, "flags": 4},
{"matrix": [0, 7], "x": 121, "y": 0, "flags": 4},
{"matrix": [0, 8], "x": 129, "y": 0, "flags": 4},
{"matrix": [0, 9], "x": 138, "y": 0, "flags": 4},
{"matrix": [0, 10], "x": 149, "y": 0, "flags": 4},
{"matrix": [0, 12], "x": 157, "y": 0, "flags": 4},
{"matrix": [0, 13], "x": 166, "y": 0, "flags": 4},
{"matrix": [0, 14], "x": 175, "y": 0, "flags": 4},
{"matrix": [0, 15], "x": 185, "y": 0, "flags": 4},
{"matrix": [0, 29], "x": 45, "y": 9, "flags": 4},
{"matrix": [0, 28], "x": 37, "y": 6, "flags": 4},
{"matrix": [0, 27], "x": 30, "y": 4, "flags": 4},
{"matrix": [0, 26], "x": 22, "y": 3, "flags": 4},
{"matrix": [0, 25], "x": 13, "y": 3, "flags": 4},
{"matrix": [1, 25], "x": 12, "y": 10, "flags": 4},
{"matrix": [1, 26], "x": 20, "y": 10, "flags": 4},
{"matrix": [1, 27], "x": 28, "y": 11, "flags": 4},
{"matrix": [1, 28], "x": 36, "y": 13, "flags": 4},
{"matrix": [1, 29], "x": 44, "y": 16, "flags": 4},
{"matrix": [1, 24], "x": 55, "y": 9, "flags": 4},
{"matrix": [2, 24], "x": 50, "y": 16, "flags": 4},
{"matrix": [3, 24], "x": 55, "y": 24, "flags": 4},
{"matrix": [1, 30], "x": 52, "y": 34, "flags": 4},
{"matrix": [3, 29], "x": 44, "y": 33, "flags": 4},
{"matrix": [2, 29], "x": 44, "y": 25, "flags": 4},
{"matrix": [2, 28], "x": 37, "y": 22, "flags": 4},
{"matrix": [3, 27], "x": 30, "y": 20, "flags": 4},
{"matrix": [2, 27], "x": 24, "y": 14, "flags": 4},
{"matrix": [2, 26], "x": 16, "y": 18, "flags": 4},
{"matrix": [2, 25], "x": 10, "y": 14, "flags": 4},
{"matrix": [4, 24], "x": 0, "y": 20, "flags": 4},
{"matrix": [3, 25], "x": 7, "y": 26, "flags": 4},
{"matrix": [3, 26], "x": 16, "y": 27, "flags": 4},
{"matrix": [4, 27], "x": 25, "y": 28, "flags": 4},
{"matrix": [3, 28], "x": 35, "y": 30, "flags": 4},
{"matrix": [4, 29], "x": 41, "y": 40, "flags": 4},
{"matrix": [2, 30], "x": 50, "y": 41, "flags": 4},
{"matrix": [4, 30], "x": 53, "y": 52, "flags": 4},
{"matrix": [3, 30], "x": 45, "y": 51, "flags": 4},
{"matrix": [5, 29], "x": 36, "y": 46, "flags": 4},
{"matrix": [4, 28], "x": 32, "y": 37, "flags": 4},
{"matrix": [5, 27], "x": 24, "y": 36, "flags": 4},
{"matrix": [4, 26], "x": 15, "y": 34, "flags": 4},
{"matrix": [4, 25], "x": 4, "y": 33, "flags": 4},
{"matrix": [5, 25], "x": 2, "y": 40, "flags": 4},
{"matrix": [0, 31], "x": 0, "y": 47, "flags": 4},
{"matrix": [5, 26], "x": 13, "y": 42, "flags": 4},
{"matrix": [1, 31], "x": 22, "y": 44, "flags": 4},
{"matrix": [2, 31], "x": 32, "y": 57, "flags": 4},
{"matrix": [5, 30], "x": 47, "y": 59, "flags": 4}
],
"max_brightness": 255,
"sat_steps": 8,
"speed_steps": 10,
"val_steps": 8,
"default": {
"val": 128
}
},
"url": "https://shop.custommk.com/collections/ergosentry/products/ergosentry",
"usb": {
"device_version": "1.0.0",
"vid": "0xF35B",
"pid": "0xFABC"
},
"ws2812": {
"driver": "pwm",
"pin": "A10"
},
"layouts": {
"LAYOUT": {
"layout": [
{"label": "Enc1", "matrix": [5, 21], "x": 5.25, "y": 0, "w": 1.5},
{"label": "Enc2", "matrix": [1, 21], "x": 7.25, "y": 0, "w": 1.5},
{"label": "Enc3", "matrix": [3, 21], "x": 9.25, "y": 0, "w": 1.5},
{"label": "F13", "matrix": [0, 1], "x": 10.75, "y": 0},
{"label": "F14", "matrix": [0, 2], "x": 11.75, "y": 0},
{"label": "F15", "matrix": [0, 4], "x": 12.75, "y": 0},
{"label": "F16", "matrix": [0, 5], "x": 13.75, "y": 0},
{"label": "F17", "matrix": [0, 6], "x": 15, "y": 0},
{"label": "F18", "matrix": [0, 7], "x": 16, "y": 0},
{"label": "F19", "matrix": [0, 8], "x": 17, "y": 0},
{"label": "F20", "matrix": [0, 9], "x": 18, "y": 0},
{"label": "F21", "matrix": [0, 10], "x": 19.25, "y": 0},
{"label": "F22", "matrix": [0, 12], "x": 20.25, "y": 0},
{"label": "F23", "matrix": [0, 13], "x": 21.25, "y": 0},
{"label": "F24", "matrix": [0, 14], "x": 22.25, "y": 0},
{"label": "PgUp", "matrix": [0, 15], "x": 23.5, "y": 0},
{"label": "Y", "matrix": [0, 25], "x": 1.5, "y": 1.25},
{"label": "U", "matrix": [0, 26], "x": 2.5, "y": 1.25},
{"label": "I", "matrix": [0, 27], "x": 3.5, "y": 1.25},
{"label": "O", "matrix": [0, 28], "x": 4.5, "y": 1.25},
{"label": "P", "matrix": [0, 29], "x": 5.5, "y": 1.25},
{"label": "F9", "matrix": [1, 24], "x": 7.5, "y": 1},
{"label": "Esc", "matrix": [0, 0], "x": 9.5, "y": 1},
{"label": "F1", "matrix": [1, 1], "x": 10.75, "y": 1},
{"label": "F2", "matrix": [1, 2], "x": 11.75, "y": 1},
{"label": "F3", "matrix": [1, 4], "x": 12.75, "y": 1},
{"label": "F4", "matrix": [1, 5], "x": 13.75, "y": 1},
{"label": "F5", "matrix": [1, 6], "x": 15, "y": 1},
{"label": "F6", "matrix": [1, 7], "x": 16, "y": 1},
{"label": "F7", "matrix": [1, 8], "x": 17, "y": 1},
{"label": "F8", "matrix": [1, 9], "x": 18, "y": 1},
{"label": "F9", "matrix": [1, 10], "x": 19.25, "y": 1},
{"label": "F10", "matrix": [1, 12], "x": 20.25, "y": 1},
{"label": "F11", "matrix": [1, 13], "x": 21.25, "y": 1},
{"label": "F12", "matrix": [1, 14], "x": 22.25, "y": 1},
{"label": "PgDn", "matrix": [1, 15], "x": 23.5, "y": 1},
{"label": "Rev", "matrix": [1, 16], "x": 24.75, "y": 1},
{"label": "Play", "matrix": [1, 17], "x": 25.75, "y": 1},
{"label": "Fwd", "matrix": [1, 18], "x": 26.75, "y": 1},
{"label": "Mute", "matrix": [1, 19], "x": 27.75, "y": 1},
{"label": "7", "matrix": [1, 25], "x": 1.5, "y": 2.25},
{"label": "8", "matrix": [1, 26], "x": 2.5, "y": 2.25},
{"label": "9", "matrix": [1, 27], "x": 3.5, "y": 2.25},
{"label": "0", "matrix": [1, 28], "x": 4.5, "y": 2.25},
{"label": "-", "matrix": [1, 29], "x": 5.5, "y": 2.25},
{"label": "PrtScr", "matrix": [2, 24], "x": 7.5, "y": 2},
{"label": "`", "matrix": [2, 0], "x": 9.5, "y": 2.25},
{"label": "1", "matrix": [2, 1], "x": 10.5, "y": 2.25},
{"label": "2", "matrix": [2, 2], "x": 11.5, "y": 2.25},
{"label": "3", "matrix": [2, 4], "x": 12.5, "y": 2.25},
{"label": "4", "matrix": [2, 5], "x": 13.5, "y": 2.25},
{"label": "5", "matrix": [2, 6], "x": 14.5, "y": 2.25},
{"label": "6", "matrix": [2, 7], "x": 15.5, "y": 2.25},
{"label": "7", "matrix": [2, 8], "x": 16.5, "y": 2.25},
{"label": "8", "matrix": [2, 9], "x": 17.5, "y": 2.25},
{"label": "9", "matrix": [2, 10], "x": 18.5, "y": 2.25},
{"label": "0", "matrix": [2, 12], "x": 19.5, "y": 2.25},
{"label": "-", "matrix": [2, 13], "x": 20.5, "y": 2.25},
{"label": "=", "matrix": [2, 14], "x": 21.5, "y": 2.25},
{"label": "Backspace", "matrix": [2, 15], "x": 22.5, "y": 2.25, "w": 2},
{"label": "NumLock", "matrix": [2, 16], "x": 24.75, "y": 2.25},
{"label": "/", "matrix": [2, 17], "x": 25.75, "y": 2.25},
{"label": "*", "matrix": [2, 18], "x": 26.75, "y": 2.25},
{"label": "-", "matrix": [2, 19], "x": 27.75, "y": 2.25},
{"label": "1", "matrix": [2, 25], "x": 1, "y": 3.25},
{"label": "2", "matrix": [2, 26], "x": 2, "y": 3.25},
{"label": "3", "matrix": [2, 27], "x": 3, "y": 3.25},
{"label": "4", "matrix": [3, 27], "x": 4, "y": 3.25},
{"label": "5", "matrix": [2, 28], "x": 5, "y": 3.25},
{"label": "6", "matrix": [2, 29], "x": 6, "y": 3.25},
{"label": "F5", "matrix": [3, 24], "x": 7.5, "y": 3},
{"label": "Tab", "matrix": [3, 0], "x": 9.5, "y": 3.25, "w": 1.5},
{"label": "Q", "matrix": [3, 1], "x": 11, "y": 3.25},
{"label": "W", "matrix": [3, 2], "x": 12, "y": 3.25},
{"label": "E", "matrix": [3, 4], "x": 13, "y": 3.25},
{"label": "R", "matrix": [3, 5], "x": 14, "y": 3.25},
{"label": "T", "matrix": [3, 6], "x": 15, "y": 3.25},
{"label": "Y", "matrix": [3, 7], "x": 16, "y": 3.25},
{"label": "U", "matrix": [3, 8], "x": 17, "y": 3.25},
{"label": "I", "matrix": [3, 9], "x": 18, "y": 3.25},
{"label": "O", "matrix": [3, 10], "x": 19, "y": 3.25},
{"label": "P", "matrix": [3, 12], "x": 20, "y": 3.25},
{"label": "[", "matrix": [3, 13], "x": 21, "y": 3.25},
{"label": "]", "matrix": [3, 14], "x": 22, "y": 3.25},
{"label": "\\", "matrix": [3, 15], "x": 23, "y": 3.25, "w": 1.5},
{"label": "7", "matrix": [3, 16], "x": 24.75, "y": 3.25},
{"label": "8", "matrix": [3, 17], "x": 25.75, "y": 3.25},
{"label": "9", "matrix": [3, 18], "x": 26.75, "y": 3.25},
{"label": "+", "matrix": [4, 19], "x": 27.75, "y": 3.25, "h": 2},
{"label": "Caps Lock", "matrix": [4, 24], "x": 0, "y": 4.5},
{"label": "Tab", "matrix": [3, 25], "x": 1, "y": 4.5},
{"label": "Q", "matrix": [3, 26], "x": 2.5, "y": 4.4},
{"label": "W", "matrix": [4, 27], "x": 3.5, "y": 4.4},
{"label": "E", "matrix": [3, 28], "x": 4.5, "y": 4.4},
{"label": "R", "matrix": [3, 29], "x": 6, "y": 4.3},
{"label": "T", "matrix": [1, 30], "x": 7.25, "y": 4.25, "w": 1.5},
{"label": "Caps Lock", "matrix": [4, 0], "x": 9.5, "y": 4.25, "w": 1.75},
{"label": "A", "matrix": [4, 2], "x": 11.25, "y": 4.25},
{"label": "S", "matrix": [4, 4], "x": 12.25, "y": 4.25},
{"label": "D", "matrix": [4, 5], "x": 13.25, "y": 4.25},
{"label": "F", "matrix": [4, 6], "x": 14.25, "y": 4.25},
{"label": "G", "matrix": [4, 7], "x": 15.25, "y": 4.25},
{"label": "H", "matrix": [4, 8], "x": 16.25, "y": 4.25},
{"label": "J", "matrix": [4, 9], "x": 17.25, "y": 4.25},
{"label": "K", "matrix": [4, 10], "x": 18.25, "y": 4.25},
{"label": "L", "matrix": [4, 12], "x": 19.25, "y": 4.25},
{"label": ";", "matrix": [4, 13], "x": 20.25, "y": 4.25},
{"label": "'", "matrix": [4, 14], "x": 21.25, "y": 4.25},
{"label": "Enter", "matrix": [4, 15], "x": 22.25, "y": 4.25, "w": 2.25},
{"label": "4", "matrix": [4, 16], "x": 24.75, "y": 4.25},
{"label": "5", "matrix": [4, 17], "x": 25.75, "y": 4.25},
{"label": "6", "matrix": [4, 18], "x": 26.75, "y": 4.25},
{"label": "L Alt", "matrix": [4, 25], "x": 0.25, "y": 5.75, "w": 1.5},
{"label": "A", "matrix": [4, 26], "x": 2.5, "y": 5.5},
{"label": "S", "matrix": [5, 27], "x": 3.5, "y": 5.5},
{"label": "D", "matrix": [4, 28], "x": 4.5, "y": 5.5},
{"label": "F", "matrix": [4, 29], "x": 6, "y": 5.3},
{"label": "G", "matrix": [2, 30], "x": 7.25, "y": 5.25, "w": 1.5},
{"label": "Shift", "matrix": [5, 0], "x": 9.5, "y": 5.25, "w": 2.25},
{"label": "Z", "matrix": [5, 2], "x": 11.75, "y": 5.25},
{"label": "X", "matrix": [5, 4], "x": 12.75, "y": 5.25},
{"label": "C", "matrix": [5, 5], "x": 13.75, "y": 5.25},
{"label": "V", "matrix": [5, 6], "x": 14.75, "y": 5.25},
{"label": "B", "matrix": [5, 7], "x": 15.75, "y": 5.25},
{"label": "N", "matrix": [5, 8], "x": 16.75, "y": 5.25},
{"label": "M", "matrix": [5, 9], "x": 17.75, "y": 5.25},
{"label": ",", "matrix": [5, 10], "x": 18.75, "y": 5.25},
{"label": ".", "matrix": [5, 12], "x": 19.75, "y": 5.25},
{"label": "/", "matrix": [5, 13], "x": 20.75, "y": 5.25},
{"label": "Shift", "matrix": [5, 14], "x": 21.75, "y": 5.25, "w": 1.75},
{"label": "Up", "matrix": [5, 15], "x": 23.5, "y": 5.25},
{"label": "1", "matrix": [5, 16], "x": 24.75, "y": 5.25},
{"label": "2", "matrix": [5, 17], "x": 25.75, "y": 5.25},
{"label": "3", "matrix": [5, 18], "x": 26.75, "y": 5.25},
{"label": "Enter", "matrix": [6, 19], "x": 27.75, "y": 5.25, "h": 2},
{"label": "L Shift", "matrix": [5, 25], "x": 0.25, "y": 6.75, "w": 1.5},
{"label": "Z", "matrix": [5, 26], "x": 2.5, "y": 6.6},
{"label": "X", "matrix": [1, 31], "x": 3.5, "y": 6.6},
{"label": "V", "matrix": [5, 29], "x": 5, "y": 6.75, "w": 1.5},
{"label": "B", "matrix": [3, 30], "x": 6.5, "y": 6.75, "w": 1.5},
{"label": "P", "matrix": [4, 30], "x": 8, "y": 6.75},
{"label": "Ctrl", "matrix": [6, 0], "x": 9.5, "y": 6.25, "w": 1.25},
{"label": "GUI", "matrix": [6, 1], "x": 10.75, "y": 6.25, "w": 1.25},
{"label": "Alt", "matrix": [6, 4], "x": 12, "y": 6.25, "w": 1.25},
{"label": "Space", "matrix": [6, 7], "x": 13.25, "y": 6.25, "w": 6.25},
{"label": "Alt", "matrix": [6, 10], "x": 19.5, "y": 6.25},
{"label": "Menu", "matrix": [6, 12], "x": 20.5, "y": 6.25},
{"label": "Ctrl", "matrix": [6, 13], "x": 21.5, "y": 6.25},
{"label": "Left", "matrix": [6, 14], "x": 22.5, "y": 6.25},
{"label": "Down", "matrix": [6, 15], "x": 23.5, "y": 6.25},
{"label": "Right", "matrix": [6, 21], "x": 24.5, "y": 6.25},
{"label": "0", "matrix": [6, 17], "x": 25.75, "y": 6.25},
{"label": ".", "matrix": [6, 18], "x": 26.75, "y": 6.25},
{"label": "L Ctrl Duck", "matrix": [0, 31], "x": 0.25, "y": 7.75, "w": 1.5},
{"label": "C", "matrix": [2, 31], "x": 4.75, "y": 7.85, "w": 1.75},
{"label": "Space", "matrix": [5, 30], "x": 6.5, "y": 7.85, "w": 1.75}
]
}
}
}

View File

@ -0,0 +1,24 @@
// Copyright 2025 customMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include QMK_KEYBOARD_H
#include "cmk_cm6646.h"
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(
KC_AUDIO_MUTE, RM_TOGG, KB_USB_AUDIO_TOGGLE, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_F21, KC_F22, KC_F23, KC_F24, KC_PGUP,
KC_Y, KC_U, KC_I, KC_O, KC_P, KC_F9, KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PGDN, KC_MPRV, KC_MPLY, KC_MNXT, KB_MIC_MUTE,
KC_7, KC_8, KC_9, KC_0, KC_MINUS, KC_PSCR, KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINUS, KC_EQL, KC_BSPC, KC_NUM, KC_PSLS, KC_PAST, KC_PMNS,
KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_F5, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_P7, KC_P8, KC_P9, KC_PPLS,
KC_CAPS, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_P4, KC_P5, KC_P6,
KC_LALT, KC_A, KC_S, KC_D, KC_F, KC_G, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_P1, KC_P2, KC_P3, KC_PENT,
KC_LSFT, KC_Z, KC_X, KC_V, KC_B, KC_P, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RIGHT, KC_P0, KC_PDOT,
KC_LCTL, KC_C, KC_SPC
)
};
#if defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
[0] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(RM_PREV, RM_NEXT), ENCODER_CCW_CW(RM_VALD, RM_VALU) }
};
#endif

View File

@ -0,0 +1 @@
ENCODER_MAP_ENABLE = yes

View File

@ -0,0 +1,132 @@
// Copyright 2025 customMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include "matrix.h"
#include <string.h>
static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
void matrix_wait_for_pin(pin_t pin, uint8_t target_state) {
rtcnt_t start = chSysGetRealtimeCounterX();
rtcnt_t end = start + 5000;
while (chSysIsCounterWithinX(chSysGetRealtimeCounterX(), start, end)) {
if (gpio_read_pin(pin) == target_state) {
break;
}
}
}
void matrix_wait_for_port(stm32_gpio_t *port, uint32_t target_bitmask) {
rtcnt_t start = chSysGetRealtimeCounterX();
rtcnt_t end = start + 5000;
while (chSysIsCounterWithinX(chSysGetRealtimeCounterX(), start, end)) {
if ((palReadPort(port) & target_bitmask) == target_bitmask) {
break;
}
}
}
void shift_pulse_clock(void) {
gpio_write_pin_high(COL_SHIFT_CLK_PIN);
matrix_wait_for_pin(COL_SHIFT_CLK_PIN, 1);
gpio_write_pin_low(COL_SHIFT_CLK_PIN);
}
void matrix_init_custom(void) {
//set all row pins as input with pullups
for (int i = 0; i < MATRIX_ROWS; ++i) {
gpio_write_pin_high(row_pins[i]);
gpio_set_pin_input_high(row_pins[i]);
}
//set all column pins high in ROW2COL matrix
gpio_set_pin_output(COL_SHIFT_IN_PIN);
gpio_set_pin_output(COL_SHIFT_CLK_PIN);
gpio_write_pin_high(COL_SHIFT_IN_PIN);
matrix_wait_for_pin(COL_SHIFT_IN_PIN, 1);
for (int i = 0; i < MATRIX_COLS; ++i) {
shift_pulse_clock();
}
}
bool matrix_scan_custom(matrix_row_t current_matrix[]) {
static matrix_row_t temp_matrix[MATRIX_ROWS] = {0};
gpio_write_pin_low(COL_SHIFT_IN_PIN);
matrix_wait_for_pin(COL_SHIFT_IN_PIN, 0);
// Setup the output column pin
shift_pulse_clock();
gpio_write_pin_high(COL_SHIFT_IN_PIN);
for (int current_col = 0; current_col < MATRIX_COLS; ++current_col) {
// Read the column ports
uint32_t gpio_a = palReadPort(GPIOA);
uint32_t gpio_b = palReadPort(GPIOB);
uint32_t gpio_c = palReadPort(GPIOC);
// row 0, pin C13
int current_row = 0;
if ((gpio_c & (1 << 13)) >> 13) {
temp_matrix[current_row] &= ~(1ul << current_col);
} else {
temp_matrix[current_row] |= (1ul << current_col);
}
// row 1, pin C14
current_row = 1;
if ((gpio_c & (1 << 14)) >> 14) {
temp_matrix[current_row] &= ~(1ul << current_col);
} else {
temp_matrix[current_row] |= (1ul << current_col);
}
// row 2, pin C15
current_row = 2;
if ((gpio_c & (1 << 15)) >> 15) {
temp_matrix[current_row] &= ~(1ul << current_col);
} else {
temp_matrix[current_row] |= (1ul << current_col);
}
// row 3, pin B1
current_row = 3;
if ((gpio_b & (1 << 1)) >> 1) {
temp_matrix[current_row] &= ~(1ul << current_col);
} else {
temp_matrix[current_row] |= (1ul << current_col);
}
// row 4, pin A7
current_row = 4;
if ((gpio_a & (1 << 7)) >> 7) {
temp_matrix[current_row] &= ~(1ul << current_col);
} else {
temp_matrix[current_row] |= (1ul << current_col);
}
// row 5, pin A5
current_row = 5;
if ((gpio_a & (1 << 5)) >> 5) {
temp_matrix[current_row] &= ~(1ul << current_col);
} else {
temp_matrix[current_row] |= (1ul << current_col);
}
// row 6, pin A6
current_row = 6;
if ((gpio_a & (1 << 6)) >> 6) {
temp_matrix[current_row] &= ~(1ul << current_col);
} else {
temp_matrix[current_row] |= (1ul << current_col);
}
// Setup the output column pin
shift_pulse_clock();
}
// Check if matrix has changed, return the last-read data
bool changed = memcmp(current_matrix, temp_matrix, sizeof(temp_matrix)) != 0;
if (changed) {
memcpy(current_matrix, temp_matrix, sizeof(temp_matrix));
}
shift_pulse_clock();
return changed;
}

View File

@ -0,0 +1,22 @@
// Copyright 2025 customMK
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include_next <mcuconf.h>
// Used for RGB matrix
#undef STM32_PWM_USE_TIM1
#define STM32_PWM_USE_TIM1 TRUE
// Used for audio
#undef STM32_PWM_USE_TIM4
#define STM32_PWM_USE_TIM4 TRUE
// Used for audio
#undef STM32_GPT_USE_TIM5
#define STM32_GPT_USE_TIM5 TRUE
// Used for FRAM
#undef STM32_SPI_USE_SPI1
#define STM32_SPI_USE_SPI1 TRUE

View File

@ -0,0 +1,27 @@
# ergosentry
![ergosentry](https://i.imgur.com/9jOk8Jqh.jpeg)
ErgoSentry ANSI is a gaming mechanical keyboard based on the layout of the discontinued SteelSeries Merc Stealth a.k.a. Zboard.
* Keyboard Maintainer: [customMK](https://github.com/customMK)
* Hardware Supported: ErgoStrafer ANSI
* Hardware Availability: [customMK](https://shop.custommk.com/products/ergosentry)
Make example for this keyboard (after setting up your build environment):
make custommk/ergosentry_ansi:default
Flashing example for this keyboard:
make custommk/ergosentry_ansi: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 Escape key while plugging in the keyboard
* **Physical reset button**: Briefly press the button underneath the spaebar
* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available

View File

@ -0,0 +1,5 @@
SRC += matrix.c \
keyboards/custommk/cmk_cm6646.c
CUSTOM_MATRIX = lite
CIE1931_CURVE = yes