From 6fbba7234e92e050a981589803c14b6de794e897 Mon Sep 17 00:00:00 2001 From: silvinor <366673+silvinor@users.noreply.github.com> Date: Fri, 2 May 2025 15:55:02 +1000 Subject: [PATCH 01/10] Add CandyPad numpad --- keyboards/binepad/candypad/candypad.c | 34 +++ keyboards/binepad/candypad/candypad.h | 31 +++ keyboards/binepad/candypad/candypad_oled.c | 250 ++++++++++++++++++ keyboards/binepad/candypad/config.h | 40 +++ keyboards/binepad/candypad/glcdfont.c | 138 ++++++++++ keyboards/binepad/candypad/halconf.h | 5 + keyboards/binepad/candypad/keyboard.json | 63 +++++ .../candypad/keymaps/default/keymap.json | 46 ++++ keyboards/binepad/candypad/matrix.c | 239 +++++++++++++++++ keyboards/binepad/candypad/mcuconf.h | 9 + keyboards/binepad/candypad/readme.md | 29 ++ keyboards/binepad/candypad/rules.mk | 12 + 12 files changed, 896 insertions(+) create mode 100644 keyboards/binepad/candypad/candypad.c create mode 100644 keyboards/binepad/candypad/candypad.h create mode 100644 keyboards/binepad/candypad/candypad_oled.c create mode 100644 keyboards/binepad/candypad/config.h create mode 100644 keyboards/binepad/candypad/glcdfont.c create mode 100644 keyboards/binepad/candypad/halconf.h create mode 100644 keyboards/binepad/candypad/keyboard.json create mode 100644 keyboards/binepad/candypad/keymaps/default/keymap.json create mode 100644 keyboards/binepad/candypad/matrix.c create mode 100644 keyboards/binepad/candypad/mcuconf.h create mode 100644 keyboards/binepad/candypad/readme.md create mode 100644 keyboards/binepad/candypad/rules.mk diff --git a/keyboards/binepad/candypad/candypad.c b/keyboards/binepad/candypad/candypad.c new file mode 100644 index 00000000000..c2afcda3304 --- /dev/null +++ b/keyboards/binepad/candypad/candypad.c @@ -0,0 +1,34 @@ +// Copyright 2023 binepad (@binepad) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "candypad.h" + +#ifdef OLED_ENABLE + +// OLED functions +uint8_t oled_mode = OLED_SPLASH; +bool oled_repaint_requested = false; +uint32_t oled_splash_timer = 0; + +void housekeeping_task_kb(void) { + if (0 != oled_splash_timer) { + if (timer_elapsed(oled_splash_timer) > OLED_SPLASH_TIMEOUT) { + switch (oled_mode) { + case OLED_SPLASH: + default: + oled_mode = OLED_DEFAULT; + oled_splash_timer = 0; // disable + break; + } + oled_repaint_requested = true; + } + } + housekeeping_task_user(); +} + +void suspend_wakeup_init_kb(void) { + suspend_wakeup_init_user(); + oled_on(); +} + +#endif // OLED_ENABLE diff --git a/keyboards/binepad/candypad/candypad.h b/keyboards/binepad/candypad/candypad.h new file mode 100644 index 00000000000..53bbce9002e --- /dev/null +++ b/keyboards/binepad/candypad/candypad.h @@ -0,0 +1,31 @@ +// Copyright 2023 binepad (@binepad) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "quantum.h" + +#ifdef OLED_ENABLE + +# ifndef OLED_SPLASH_TIMEOUT +# define OLED_SPLASH_TIMEOUT 2500 +# endif + +enum oled_modes { + OLED_SPLASH, + OLED_DEFAULT, + OLED_OFF, + __NUM_OLED_MODES +} oled_modes_t; + +bool candypad_render_logo_user(void); +bool candypad_render_logo_kb(void); +bool candypad_render_default_user(void); +bool candypad_render_default_kb(void); + +// OLED functions +extern uint8_t oled_mode; +extern bool oled_repaint_requested; +extern uint32_t oled_splash_timer; + +#endif diff --git a/keyboards/binepad/candypad/candypad_oled.c b/keyboards/binepad/candypad/candypad_oled.c new file mode 100644 index 00000000000..99caa62ec66 --- /dev/null +++ b/keyboards/binepad/candypad/candypad_oled.c @@ -0,0 +1,250 @@ +// Copyright 2023 binepad (@binepad) +// SPDX-License-Identifier: GPL-2.0-or-later +// Portions of this code are based on [Andrew Kannan](https://github.com/awkannan1)'s +// work on the Satisfaction75 + +#include "candypad.h" +#include "oled_driver.h" +#include "keymap_introspection.h" +#include // needed for `snprintf` +#ifdef CONSOLE_ENABLE +# include "print.h" +# include "debug.h" +#endif + +#ifdef OLED_ENABLE + +/* CandyPad Logo */ +static void __candypad_render_logo_default(void) { + // Generated from https://joric.github.io/qle/ + static const unsigned char PROGMEM raw_logo[] = { + 0, 0, 0, 0, 128, 192, 224, 96, 240, 240, 152, 24, 24, 24, 24, 24, 24, 24, 24, 56, 48, 96, 224, 192, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 0, 0, 192, 248, 62, 7, 15, 28, 56, 112, 225, 195, 135, 14, 28, 56, 112, 224, 192, 128, 0, 0, 0, 0, 1, 7, 62, 252, 192, 0, 128, 192, 224, 112, 48, 48, 48, 112, 96, 0, 128, 192, 224, 96, + 48, 48, 48, 112, 224, 240, 240, 0, 0, 240, 240, 96, 112, 48, 48, 48, 112, 224, 192, 128, 0, 0, 128, 192, 224, 112, 48, 48, 48, 112, 224, 255, 255, 0, 48, 112, 224, 128, 0, 0, 0, 0, 128, 224, 112, 48, 0, 240, 240, 224, 112, 48, 48, 48, 112, 224, 192, 128, 0, 0, 128, 192, 224, 96, 48, 48, 48, 112, 224, 240, 240, 0, 0, 128, 192, 224, 112, 48, 48, 48, 112, 224, 255, 255, 0, 0, 3, 31, 124, 224, 192, 0, 0, 0, 0, 1, 3, 7, 14, 28, 56, 112, 225, 195, 135, 14, 28, 56, 240, 224, 124, 63, 3, 0, 15, 31, 56, 112, 96, 96, 96, 112, 48, 0, 15, 31, 56, 112, 96, 96, 96, 112, 56, 127, 127, 0, 0, 127, 127, 0, 0, 0, 0, 0, 0, 1, 127, 127, 0, 0, 15, 31, 56, 112, 96, 96, 96, 112, 56, 127, 127, 0, 0, 0, 3, 15, 62, 240, 248, 62, 15, + 3, 0, 0, 0, 255, 255, 56, 112, 96, 96, 96, 112, 56, 31, 15, 0, 0, 15, 31, 56, 112, 96, 96, 96, 112, 56, 127, 127, 0, 0, 15, 63, 56, 112, 96, 96, 96, 112, 56, 127, 127, 0, 0, 0, 0, 0, 1, 3, 7, 6, 14, 12, 24, 24, 24, 24, 24, 24, 24, 24, 25, 15, 15, 6, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 31, 7, 1, 0, 0, 0, 0, 0, 0, 31, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }; + oled_write_raw_P((char *)raw_logo, sizeof(raw_logo)); +} + +// weak so that user keymaps can make their own +__attribute__((weak)) bool candypad_render_logo_user(void) { + return false; // return true if your user keymap renders its own +} + +__attribute__((weak)) bool candypad_render_logo_kb(void) { + if (!candypad_render_logo_user()) { + __candypad_render_logo_default(); + } + return true; +} + +oled_rotation_t oled_init_kb(oled_rotation_t rotation) { + oled_mode = OLED_SPLASH; + oled_splash_timer = sync_timer_read(); + return rotation; +} + +static char *get_enc_mode(uint8_t encoder) { +# ifdef ENCODER_MAP_ENABLE + + static char s_u_d[4] = {24, 38, 25, 0}; // up and down + static char s_l_r[4] = {27, 38, 26, 0}; // left and right + + uint8_t layer = get_highest_layer(layer_state); + uint16_t keycode = KC_TRNS; + + while (keycode == KC_TRNS) { + keycode = keycode_at_encodermap_location(layer, encoder, true); // only reads ENCODER_CW + if (keycode == KC_TRNS) { + if (layer > 0) { + layer--; + } else { + keycode = KC_NO; + } + } + } + + switch (keycode) { + case KC_NO: + return " - "; + break; + + case KC_WH_U: + case KC_WH_D: + return "MWL"; + break; + + case KC_VOLD: + case KC_VOLU: + return "VOL"; + break; + + case KC_MEDIA_NEXT_TRACK: + case KC_MEDIA_PREV_TRACK: + return "MED"; + break; + + case KC_UP: + case KC_DOWN: + return (char *)&s_u_d; + break; + + case KC_LEFT: + case KC_RIGHT: + return (char *)&s_l_r; + break; + + default: + return "Usr"; + break; + } + +# else + + return "Err"; + +# endif +} + +static void __draw_line_h(uint8_t x, uint8_t y, uint8_t len, bool on) { + for (uint8_t i = 0; i < len; i++) { + oled_write_pixel(i + x, y, on); + } +} + +static void __draw_line_v(uint8_t x, uint8_t y, uint8_t len, bool on) { + for (uint8_t i = 0; i < len; i++) { + oled_write_pixel(x, i + y, on); + } +} + +// weak so that user keymaps can make their own +__attribute__((weak)) bool candypad_render_default_user(void) { + return false; // return true if your user keymap renders its own +} + +__attribute__((weak)) bool candypad_render_default_kb(void) { + if (candypad_render_default_user()) { + return true; // was handled by user code + } + + bool on; + + // --- Show Layer --- + + oled_set_cursor(0, 1); + oled_write_P(PSTR("LAYER"), false); + + oled_set_cursor(6, 1); + oled_write_char(get_highest_layer(layer_state) + 0x30, true); + + __draw_line_h((OLED_FONT_WIDTH * 6) - 1, OLED_FONT_HEIGHT - 1, OLED_FONT_WIDTH + 1, true); + __draw_line_v((OLED_FONT_WIDTH * 6) - 1, OLED_FONT_HEIGHT, OLED_FONT_HEIGHT, true); + + // --- Show Encoder 1 --- + + oled_set_cursor(13, 1); + oled_write_P(PSTR("ENC1"), false); + + oled_set_cursor(18, 1); + oled_write(get_enc_mode(0), true); + + __draw_line_h((OLED_FONT_WIDTH * 18) - 1, OLED_FONT_HEIGHT - 1, (OLED_FONT_WIDTH * 3) + 1, true); + __draw_line_v((OLED_FONT_WIDTH * 18) - 1, OLED_FONT_HEIGHT, OLED_FONT_HEIGHT, true); + + // --- Show Encoder 2 --- + + oled_set_cursor(13, 3); + oled_write_P(PSTR("ENC2"), false); + + oled_set_cursor(18, 3); + oled_write(get_enc_mode(1), true); + + __draw_line_h((OLED_FONT_WIDTH * 18) - 1, (OLED_FONT_HEIGHT * 3) - 1, (OLED_FONT_WIDTH * 3) + 1, true); + __draw_line_v((OLED_FONT_WIDTH * 18) - 1, OLED_FONT_HEIGHT * 3, OLED_FONT_HEIGHT, true); + + // --- Keyboard Modifiers --- + + led_t led_state = host_keyboard_led_state(); + oled_set_cursor(4, 3); + if (led_state.caps_lock && !led_state.num_lock) { // Caps-Lock transcends keyboards, so show it if on if num-lock is off + oled_write_P(PSTR("CAP"), true); + } else { + oled_write_P(PSTR("NUM"), led_state.num_lock); + } + on = led_state.num_lock || led_state.caps_lock; + __draw_line_h((OLED_FONT_WIDTH * 4) - 1, (OLED_FONT_HEIGHT * 3) - 1, (OLED_FONT_WIDTH * 3) + 1, on); + __draw_line_v((OLED_FONT_WIDTH * 4) - 1, OLED_FONT_HEIGHT * 3, OLED_FONT_HEIGHT, on); + + // --- Show keymap matrix --- + +# define MXDS_X 2 +# define MXDS_Y (OLED_FONT_HEIGHT * 3) + + // matrix + for (uint8_t x = 0; x < MATRIX_ROWS - 1; x++) { + for (uint8_t y = 0; y < MATRIX_COLS; y++) { + on = (matrix_get_row(x) & (1 << y)) > 0; + oled_write_pixel(MXDS_X + y, MXDS_Y + x + 1, on); + } + } + + on = (matrix_get_row(1) & (1 << 3)) > 0; // `+` + oled_write_pixel(MXDS_X + 3, MXDS_Y + 1 + 2, on); + + on = (matrix_get_row(3) & (1 << 3)) > 0; // `Enter` + oled_write_pixel(MXDS_X + 3, MXDS_Y + 3 + 2, on); + + on = (matrix_get_row(4) & (1 << 0)) > 0; // `0` + oled_write_pixel(MXDS_X + 0 + 1, MXDS_Y + 4 + 1, on); + + on = (matrix_get_row(5) & (1 << 0)) > 0; // Enc 1 press + oled_write_pixel(MXDS_X + 2, MXDS_Y, on); + + on = (matrix_get_row(5) & (1 << 1)) > 0; // Enc 2 press + oled_write_pixel(MXDS_X + 3, MXDS_Y, on); + + // outline + __draw_line_h(MXDS_X - 2, MXDS_Y - 2, 8, true); + __draw_line_h(MXDS_X - 2, MXDS_Y + 7, 8, true); + __draw_line_v(MXDS_X - 2, MXDS_Y - 1, 8, true); + __draw_line_v(MXDS_X + 5, MXDS_Y - 1, 8, true); + + return true; // was handled here +} + +bool oled_task_kb(void) { + if (!oled_task_user()) { + return false; + } + // if (!oled_task_needs_to_repaint()) { return false; } + /* !!! oled_clear(); // is broken !!! */ + if (oled_repaint_requested) { + oled_repaint_requested = false; + oled_clear(); + return false; + } + + switch (oled_mode) { + case OLED_OFF: + // do nothing + // this PCB has no digital switch to power off the OLED :( + break; + + case OLED_SPLASH: + if (candypad_render_logo_kb()) { + break; + } else { + oled_mode = OLED_DEFAULT; + // don't break - let the default draw + } + + case OLED_DEFAULT: + default: + candypad_render_default_kb(); + break; + } + + return false; +} + +#endif // OLED_ENABLE diff --git a/keyboards/binepad/candypad/config.h b/keyboards/binepad/candypad/config.h new file mode 100644 index 00000000000..49d3a11af4d --- /dev/null +++ b/keyboards/binepad/candypad/config.h @@ -0,0 +1,40 @@ +// Copyright 2023 binepad (@binepad) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +/* ----- Encoder ----- */ +#define ENCODER_DEFAULT_POS 0x3 // enable 1:1 resolution + +/* ----- OLED ----- */ +#ifdef OLED_ENABLE +/* I2C (for OLED) */ +# define I2C1_SCL_PIN GP23 +# define I2C1_SDA_PIN GP22 +# define I2C_DRIVER I2CD1 + +/* Configure oled driver for the 128x32 oled */ +# define OLED_DISPLAY_128X32 +# define OLED_TIMEOUT (15 * 60 * 1000) // 15 minutes +# define OLED_BRIGHTNESS 128 +# define OLED_UPDATE_INTERVAL 33 // ~30fps + +/* Font */ +# define OLED_FONT_H "glcdfont.c" +# define OLED_FONT_WIDTH 6 +# define OLED_FONT_HEIGHT 8 +#endif // OLED_ENABLE + +/* ---- Direct pins, for use in `matrix.c` (please read that file) ----- */ +// *NB*: DIRECT_PINS_CUSTOM must match the MATRIX_ROWS / MATRIX_COLS matrix structure +// clang-format off +#define DIRECT_PINS_CUSTOM \ + { \ + {NO_PIN, NO_PIN, NO_PIN, NO_PIN}, \ + {NO_PIN, NO_PIN, NO_PIN, NO_PIN}, \ + {NO_PIN, NO_PIN, NO_PIN, NO_PIN}, \ + {NO_PIN, NO_PIN, NO_PIN, NO_PIN}, \ + {NO_PIN, NO_PIN, NO_PIN, NO_PIN}, \ + {GP26, GP3, NO_PIN, NO_PIN} \ + } +// clang-format on diff --git a/keyboards/binepad/candypad/glcdfont.c b/keyboards/binepad/candypad/glcdfont.c new file mode 100644 index 00000000000..b11ef12d032 --- /dev/null +++ b/keyboards/binepad/candypad/glcdfont.c @@ -0,0 +1,138 @@ +// Copyright 2023 binepad (@binepad) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "progmem.h" + +/* based on https://lexus2k.github.io/ssd1306/ssd1306__fonts_8c_source.html, chars 32 - 127 */ +// clang-format off +static const unsigned char PROGMEM font[] = { + 0xFF, 0x81, 0x81, 0x81, 0x81, 0xFF, + 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, + 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00, + 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, + 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00, + 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00, + 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, + 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00, + 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, + 0x00, 0x18, 0x24, 0x18, 0x00, 0x00, + 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00, + 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00, + 0x26, 0x29, 0x79, 0x29, 0x26, 0x00, + 0x40, 0x7F, 0x05, 0x05, 0x07, 0x00, + 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00, + 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00, + 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00, + 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00, + 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00, + 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00, + 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, + 0x00, 0x66, 0x89, 0x95, 0x6A, 0x00, + 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, + 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00, + 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00, + 0x10, 0x20, 0x7E, 0x20, 0x10, 0x00, + 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, + 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00, + 0x1E, 0x10, 0x10, 0x10, 0x10, 0x00, + 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00, + 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00, + 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x2F, 0x00, 0x00, + 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, + 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, + 0x00, 0x24, 0x2A, 0x7F, 0x2A, 0x12, + 0x00, 0x23, 0x13, 0x08, 0x64, 0x62, + 0x00, 0x36, 0x49, 0x55, 0x22, 0x50, + 0x00, 0x00, 0x05, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, + 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, + 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14, + 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, + 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00, + 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, + 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, + 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E, + 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, + 0x00, 0x42, 0x61, 0x51, 0x49, 0x46, + 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31, + 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10, + 0x00, 0x27, 0x45, 0x45, 0x45, 0x39, + 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30, + 0x00, 0x01, 0x71, 0x09, 0x05, 0x03, + 0x00, 0x36, 0x49, 0x49, 0x49, 0x36, + 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E, + 0x00, 0x00, 0x36, 0x36, 0x00, 0x00, + 0x00, 0x00, 0x56, 0x36, 0x00, 0x00, + 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, + 0x00, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x00, 0x00, 0x41, 0x22, 0x14, 0x08, + 0x00, 0x02, 0x01, 0x51, 0x09, 0x06, + 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E, + 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C, + 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36, + 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22, + 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C, + 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41, + 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01, + 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A, + 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F, + 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00, + 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, + 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41, + 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40, + 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F, + 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F, + 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E, + 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06, + 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E, + 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46, + 0x00, 0x46, 0x49, 0x49, 0x49, 0x31, + 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01, + 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F, + 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F, + 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F, + 0x00, 0x63, 0x14, 0x08, 0x14, 0x63, + 0x00, 0x07, 0x08, 0x70, 0x08, 0x07, + 0x00, 0x61, 0x51, 0x49, 0x45, 0x43, + 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00, + 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, + 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00, + 0x00, 0x04, 0x02, 0x01, 0x02, 0x04, + 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, + 0x00, 0x00, 0x01, 0x02, 0x04, 0x00, + 0x00, 0x20, 0x54, 0x54, 0x54, 0x78, + 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38, + 0x00, 0x38, 0x44, 0x44, 0x44, 0x20, + 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F, + 0x00, 0x38, 0x54, 0x54, 0x54, 0x18, + 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02, + 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C, + 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78, + 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00, + 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00, + 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, + 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, + 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78, + 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78, + 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, + 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18, + 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC, + 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08, + 0x00, 0x48, 0x54, 0x54, 0x54, 0x20, + 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20, + 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C, + 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C, + 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C, + 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, + 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C, + 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, + 0x00, 0x00, 0x08, 0x77, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, + 0x00, 0x00, 0x77, 0x08, 0x00, 0x00, + 0x00, 0x10, 0x08, 0x10, 0x08, 0x00, + 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA +}; +// clang-format on diff --git a/keyboards/binepad/candypad/halconf.h b/keyboards/binepad/candypad/halconf.h new file mode 100644 index 00000000000..c4a7101379f --- /dev/null +++ b/keyboards/binepad/candypad/halconf.h @@ -0,0 +1,5 @@ +#pragma once + +#define HAL_USE_I2C TRUE + +#include_next diff --git a/keyboards/binepad/candypad/keyboard.json b/keyboards/binepad/candypad/keyboard.json new file mode 100644 index 00000000000..b7b583ac64a --- /dev/null +++ b/keyboards/binepad/candypad/keyboard.json @@ -0,0 +1,63 @@ +{ + "manufacturer": "binepad", + "keyboard_name": "CandyPad", + "url": "https://candykeys.com/product/candypad-keyboard", + "maintainer": "binepad", + "processor": "RP2040", + "bootloader": "rp2040", + "usb": { + "vid": "0x4249", + "pid": "0x4350", + "device_version": "1.0.0" + }, + "features": { + "bootmagic": true, + "command": false, + "console": false, + "extrakey": true, + "mousekey": true, + "nkro": true, + "encoder": true + }, + "diode_direction": "COL2ROW", + "matrix_pins": { + "cols": ["GP15", "GP14", "GP13", "GP10"], + "rows": ["GP12", "GP9", "GP7", "GP6", "GP5", null] + }, + "encoder": { + "rotary": [ + {"pin_a": "GP28", "pin_b": "GP27"}, + {"pin_a": "GP1", "pin_b": "GP2"} + ] + }, + "layouts": { + "LAYOUT": { + "layout": [ + { "matrix": [0, 0], "label": "Num Lock", "x": 0, "y": 1}, + { "matrix": [0, 1], "label": "/", "x": 1, "y": 1}, + { "matrix": [0, 2], "label": "*", "x": 2, "y": 1}, + { "matrix": [0, 3], "label": "-", "x": 3, "y": 1}, + + { "matrix": [1, 0], "label": "7", "x": 0, "y": 2}, + { "matrix": [1, 1], "label": "8", "x": 1, "y": 2}, + { "matrix": [1, 2], "label": "9", "x": 2, "y": 2}, + { "matrix": [1, 3], "label": "+", "x": 3, "y": 2, "h": 2}, + + { "matrix": [2, 0], "label": "4", "x": 0, "y": 3}, + { "matrix": [2, 1], "label": "5", "x": 1, "y": 3}, + { "matrix": [2, 2], "label": "6", "x": 2, "y": 3}, + + { "matrix": [3, 0], "label": "1", "x": 0, "y": 4}, + { "matrix": [3, 1], "label": "2", "x": 1, "y": 4}, + { "matrix": [3, 2], "label": "3", "x": 2, "y": 4}, + { "matrix": [3, 3], "label": "Enter", "x": 3, "y": 4, "h": 2}, + + { "matrix": [4, 0], "label": "0", "x": 0, "y": 5, "w": 2}, + { "matrix": [4, 2], "label": ".", "x": 2, "y": 5}, + + { "matrix": [5, 0], "label": "", "x": 2, "y": 0}, + { "matrix": [5, 1], "label": "", "x": 3, "y": 0} + ] + } + } +} diff --git a/keyboards/binepad/candypad/keymaps/default/keymap.json b/keyboards/binepad/candypad/keymaps/default/keymap.json new file mode 100644 index 00000000000..9e90c12ccb8 --- /dev/null +++ b/keyboards/binepad/candypad/keymaps/default/keymap.json @@ -0,0 +1,46 @@ +{ + "keyboard": "binepad/candypad", + "keymap": "default", + "version": 1, + "layout": "LAYOUT", + "layers": [ + [ + "KC_NUM", + "KC_PSLS", + "KC_PAST", + "KC_PMNS", + "KC_P7", + "KC_P8", + "KC_P9", + "KC_PPLS", + "KC_P4", + "KC_P5", + "KC_P6", + "KC_P1", + "KC_P2", + "KC_P3", + "KC_PENT", + "KC_P0", + "KC_PDOT", + "MO(1)", + "KC_MUTE" + ] + ], + "config": { + "features": { + "encoder_map": true + } + }, + "encoders": [ + [ + { + "ccw": "KC_WH_U", + "cw": "KC_WH_D" + }, + { + "ccw": "KC_VOLD", + "cw": "KC_VOLU" + } + ] + ] +} diff --git a/keyboards/binepad/candypad/matrix.c b/keyboards/binepad/candypad/matrix.c new file mode 100644 index 00000000000..29bc06690e1 --- /dev/null +++ b/keyboards/binepad/candypad/matrix.c @@ -0,0 +1,239 @@ +// Copyright 2023 Silvino R. (@silvinor) +// Copyright 2012-2018 Jun Wako, Jack Humbert, Yiancar [portions from `qantum/matrix.c`] +// SPDX-License-Identifier: GPL-2.0-or-later + +/** + * This file is mostly a copy of `matrix.c` from the QMK core, however + * it assumes the matrix is always COL2ROW and that the KB has BOTH + * matrix and direct pins. + + * For direct pins define + * `DIRECT_PINS_CUSTOM` + * This stucture must match exactly the MATRIX_ROWS / MATRIX_COLS matrix. + * + * NB!!: The ROW that supports direct pins **must** have the row set + * to NO_PIN in the matrix array. +*/ + +#include "matrix.h" +#include "debounce.h" +#include "atomic_util.h" +#include +#include "wait.h" +#include "print.h" + +#ifndef DEBOUNCE +# define DEBOUNCE 5 +#endif + +#ifndef MATRIX_INPUT_PRESSED_STATE +# define MATRIX_INPUT_PRESSED_STATE 0 +#endif + +#ifndef MATRIX_IO_DELAY +# define MATRIX_IO_DELAY 30 +#endif + +static pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; +static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; + +// define DIRECT_PINS_CUSTOM in `config.h` +// ** NB: ** must match the MATRIX_ROWS / MATRIX_COLS matrix structure +static pin_t direct_pins[MATRIX_ROWS][MATRIX_COLS] = DIRECT_PINS_CUSTOM; + +/* matrix state(1:on, 0:off) */ +matrix_row_t raw_matrix[MATRIX_ROWS]; +matrix_row_t matrix[MATRIX_ROWS]; + +__attribute__((weak)) void matrix_init_user(void) {} + +__attribute__((weak)) void matrix_init_kb(void) { + matrix_init_user(); +} + +__attribute__((weak)) void matrix_scan_user(void) {} + +__attribute__((weak)) void matrix_scan_kb(void) { + matrix_scan_user(); +} + +#define print_matrix_header() print("\nr/c 01234567\n") +#define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) + +__attribute__((weak)) void matrix_output_select_delay(void) { + waitInputPinDelay(); +} + +__attribute__((weak)) void matrix_output_unselect_delay(uint8_t line, bool key_pressed) { + wait_us(MATRIX_IO_DELAY); +} + +static inline void setPinOutput_writeLow(pin_t pin) { + ATOMIC_BLOCK_FORCEON { + setPinOutput(pin); + writePinLow(pin); + } +} + +static inline void setPinInputHigh_atomic(pin_t pin) { + ATOMIC_BLOCK_FORCEON { + setPinInputHigh(pin); + } +} + +static inline uint8_t readMatrixPin(pin_t pin) { + if (pin != NO_PIN) { + return (readPin(pin) == MATRIX_INPUT_PRESSED_STATE) ? 0 : 1; + } else { + return 1; + } +} + +void matrix_print(void) { + print_matrix_header(); + + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + print_hex8(row); + print(": "); + print_matrix_row(row); + print("\n"); + } +} + +static bool select_row(uint8_t row) { + pin_t pin = row_pins[row]; + if (pin != NO_PIN) { + setPinOutput_writeLow(pin); + return true; + } + return false; +} + +static void unselect_row(uint8_t row) { + pin_t pin = row_pins[row]; + if (pin != NO_PIN) { + setPinInputHigh_atomic(pin); + } +} + +static void unselect_rows(void) { + for (uint8_t x = 0; x < MATRIX_ROWS; x++) { + unselect_row(x); + } +} + +void matrix_init_pins__matrix(void) { + unselect_rows(); + for (uint8_t x = 0; x < MATRIX_COLS; x++) { + if (col_pins[x] != NO_PIN) { + setPinInputHigh_atomic(col_pins[x]); + } + } +} + +void matrix_init_pins__direct(void) { + for (int row = 0; row < MATRIX_ROWS; row++) { + for (int col = 0; col < MATRIX_COLS; col++) { + pin_t pin = direct_pins[row][col]; + if (pin != NO_PIN) { + setPinInputHigh(pin); + } + } + } +} + +inline uint8_t matrix_rows(void) { + return MATRIX_ROWS; +} + +inline uint8_t matrix_cols(void) { + return MATRIX_COLS; +} + +void matrix_init(void) { + // initialize key pins + matrix_init_pins__matrix(); + matrix_init_pins__direct(); + + // initialize matrix state: all keys off + memset(raw_matrix, 0, sizeof(raw_matrix)); + memset(matrix, 0, sizeof(matrix)); + + // Unless hardware debouncing - Init the configured debounce routine + debounce_init(MATRIX_ROWS); + + // This *must* be called for correct keyboard behavior + matrix_init_kb(); +} + +inline bool matrix_is_on(uint8_t row, uint8_t col) { + return (matrix[row] & ((matrix_row_t)1 << col)); +} + +inline matrix_row_t matrix_get_row(uint8_t row) { + return matrix[row]; +} + +void matrix_read_cols_on_row__matrix(matrix_row_t current_matrix[], uint8_t current_row) { + // Start with a clear matrix row + matrix_row_t current_row_value = 0; + + if (!select_row(current_row)) { // Select row + return; // skip NO_PIN row + } + matrix_output_select_delay(); + + // For each col... + matrix_row_t row_shifter = MATRIX_ROW_SHIFTER; + for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++, row_shifter <<= 1) { + uint8_t pin_state = readMatrixPin(col_pins[col_index]); + + // Populate the matrix row with the state of the col pin + current_row_value |= pin_state ? 0 : row_shifter; + } + + // Unselect row + unselect_row(current_row); + matrix_output_unselect_delay(current_row, current_row_value != 0); // wait for all Col signals to go HIGH + + // Update the matrix + current_matrix[current_row] = current_row_value; +} + +void matrix_read_cols_on_row__direct(matrix_row_t current_matrix[], uint8_t current_row) { + // Start with a clear matrix row + matrix_row_t current_row_value = 0; + + matrix_row_t row_shifter = MATRIX_ROW_SHIFTER; + for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++, row_shifter <<= 1) { + pin_t pin = direct_pins[current_row][col_index]; + if (NO_PIN != pin) { + current_row_value |= readMatrixPin(pin) ? 0 : row_shifter; + } + } + + // Update the matrix + current_matrix[current_row] = current_row_value; +} + +uint8_t matrix_scan(void) { + matrix_row_t curr_matrix[MATRIX_ROWS] = {0}; + + // Matrix keys: Set row, read cols + for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { + // if the row is a NO_PIN then assume it's on a direct pins matrix, else assume COL2ROW matrix + if (NO_PIN != row_pins[current_row]) { + matrix_read_cols_on_row__matrix(curr_matrix, current_row); + } else { + matrix_read_cols_on_row__direct(curr_matrix, current_row); + } + } + + bool changed = memcmp(raw_matrix, curr_matrix, sizeof(curr_matrix)) != 0; + if (changed) memcpy(raw_matrix, curr_matrix, sizeof(curr_matrix)); + + changed = debounce(raw_matrix, matrix, MATRIX_ROWS, changed); + matrix_scan_kb(); + + return (uint8_t)changed; +} diff --git a/keyboards/binepad/candypad/mcuconf.h b/keyboards/binepad/candypad/mcuconf.h new file mode 100644 index 00000000000..743d16da1a5 --- /dev/null +++ b/keyboards/binepad/candypad/mcuconf.h @@ -0,0 +1,9 @@ +#pragma once + +#include_next + +#undef RP_I2C_USE_I2C0 +#define RP_I2C_USE_I2C0 FALSE + +#undef RP_I2C_USE_I2C1 +#define RP_I2C_USE_I2C1 TRUE diff --git a/keyboards/binepad/candypad/readme.md b/keyboards/binepad/candypad/readme.md new file mode 100644 index 00000000000..d2c1944e8ba --- /dev/null +++ b/keyboards/binepad/candypad/readme.md @@ -0,0 +1,29 @@ +# CandyPad Number Pad + +![CandyPad Keyboard](https://i.imgur.com/W9cfNOm.png) + +*A numeric pad with 2x rotary encoders and OLED display, a joint venture by CandyKeys × BinePad* + +* Keyboard Maintainer: [binepad](https://github.com/binepad) +* Hardware Supported: CandyPad Keyboard +* Hardware Availability: + - [candykeys.com](https://candykeys.com/product/candypad-keyboard) + - [binepad.com](https://binepad.com/products/candypad) + +Make example for this keyboard (after setting up your build environment): + + make binepad/candypad:default + +Flashing example for this keyboard: + + make binepad/candypad: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 (0:0) in the matrix (the top left key) 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` if it is available diff --git a/keyboards/binepad/candypad/rules.mk b/keyboards/binepad/candypad/rules.mk new file mode 100644 index 00000000000..d77de6626af --- /dev/null +++ b/keyboards/binepad/candypad/rules.mk @@ -0,0 +1,12 @@ +# @see `info.json` for config + +CUSTOM_MATRIX = yes + +OLED_ENABLE = yes +OLED_DRIVER = ssd1306 +OLED_TRANSPORT = i2c + +SRC += matrix.c \ + candypad_oled.c + +OPT_DEFS += -DHAL_USE_I2C=TRUE From 84aedd1872d9dc229df433b9249e52634414c192 Mon Sep 17 00:00:00 2001 From: silvinor <366673+silvinor@users.noreply.github.com> Date: Fri, 2 May 2025 19:52:05 +1000 Subject: [PATCH 02/10] lint related fixes 1 --- keyboards/binepad/candypad/halconf.h | 3 +++ keyboards/binepad/candypad/keyboard.json | 2 -- keyboards/binepad/candypad/mcuconf.h | 3 +++ keyboards/binepad/candypad/rules.mk | 3 ++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/keyboards/binepad/candypad/halconf.h b/keyboards/binepad/candypad/halconf.h index c4a7101379f..8d0392e4980 100644 --- a/keyboards/binepad/candypad/halconf.h +++ b/keyboards/binepad/candypad/halconf.h @@ -1,3 +1,6 @@ +// Copyright 2023 binepad (@binepad) +// SPDX-License-Identifier: GPL-2.0-or-later + #pragma once #define HAL_USE_I2C TRUE diff --git a/keyboards/binepad/candypad/keyboard.json b/keyboards/binepad/candypad/keyboard.json index b7b583ac64a..cc8c8b3eeb8 100644 --- a/keyboards/binepad/candypad/keyboard.json +++ b/keyboards/binepad/candypad/keyboard.json @@ -12,8 +12,6 @@ }, "features": { "bootmagic": true, - "command": false, - "console": false, "extrakey": true, "mousekey": true, "nkro": true, diff --git a/keyboards/binepad/candypad/mcuconf.h b/keyboards/binepad/candypad/mcuconf.h index 743d16da1a5..050d9875e5c 100644 --- a/keyboards/binepad/candypad/mcuconf.h +++ b/keyboards/binepad/candypad/mcuconf.h @@ -1,3 +1,6 @@ +// Copyright 2023 binepad (@binepad) +// SPDX-License-Identifier: GPL-2.0-or-later + #pragma once #include_next diff --git a/keyboards/binepad/candypad/rules.mk b/keyboards/binepad/candypad/rules.mk index d77de6626af..c73142b210c 100644 --- a/keyboards/binepad/candypad/rules.mk +++ b/keyboards/binepad/candypad/rules.mk @@ -1,4 +1,5 @@ -# @see `info.json` for config +# Copyright 2023 binepad (@binepad) +# SPDX-License-Identifier: GPL-2.0-or-later CUSTOM_MATRIX = yes From b45d849da8aa5bb67931c2dd6b0335660cea378b Mon Sep 17 00:00:00 2001 From: silvinor <366673+silvinor@users.noreply.github.com> Date: Sat, 3 May 2025 11:16:06 +1000 Subject: [PATCH 03/10] post @waffle87 recommendations --- keyboards/binepad/candypad/candypad.c | 3 +- keyboards/binepad/candypad/candypad_oled.c | 6 - keyboards/binepad/candypad/config.h | 9 +- keyboards/binepad/candypad/glcdfont.c | 3 +- keyboards/binepad/candypad/keyboard.json | 227 ++++++++++++++++++--- keyboards/binepad/candypad/readme.md | 2 +- keyboards/binepad/candypad/rules.mk | 4 - 7 files changed, 205 insertions(+), 49 deletions(-) diff --git a/keyboards/binepad/candypad/candypad.c b/keyboards/binepad/candypad/candypad.c index c2afcda3304..7362385d3ab 100644 --- a/keyboards/binepad/candypad/candypad.c +++ b/keyboards/binepad/candypad/candypad.c @@ -23,12 +23,11 @@ void housekeeping_task_kb(void) { oled_repaint_requested = true; } } - housekeeping_task_user(); } void suspend_wakeup_init_kb(void) { - suspend_wakeup_init_user(); oled_on(); + suspend_wakeup_init_user(); } #endif // OLED_ENABLE diff --git a/keyboards/binepad/candypad/candypad_oled.c b/keyboards/binepad/candypad/candypad_oled.c index 99caa62ec66..3d335b30508 100644 --- a/keyboards/binepad/candypad/candypad_oled.c +++ b/keyboards/binepad/candypad/candypad_oled.c @@ -4,13 +4,7 @@ // work on the Satisfaction75 #include "candypad.h" -#include "oled_driver.h" #include "keymap_introspection.h" -#include // needed for `snprintf` -#ifdef CONSOLE_ENABLE -# include "print.h" -# include "debug.h" -#endif #ifdef OLED_ENABLE diff --git a/keyboards/binepad/candypad/config.h b/keyboards/binepad/candypad/config.h index 49d3a11af4d..80eb26b062b 100644 --- a/keyboards/binepad/candypad/config.h +++ b/keyboards/binepad/candypad/config.h @@ -14,18 +14,15 @@ # define I2C_DRIVER I2CD1 /* Configure oled driver for the 128x32 oled */ -# define OLED_DISPLAY_128X32 # define OLED_TIMEOUT (15 * 60 * 1000) // 15 minutes -# define OLED_BRIGHTNESS 128 # define OLED_UPDATE_INTERVAL 33 // ~30fps /* Font */ -# define OLED_FONT_H "glcdfont.c" -# define OLED_FONT_WIDTH 6 -# define OLED_FONT_HEIGHT 8 +# define OLED_FONT_H "keyboards/binepad/candypad/glcdfont.c" +# define OLED_FONT_END 127 #endif // OLED_ENABLE -/* ---- Direct pins, for use in `matrix.c` (please read that file) ----- */ +/* ---- Direct pins, for use in (custom) `matrix.c` (please read that file) ----- */ // *NB*: DIRECT_PINS_CUSTOM must match the MATRIX_ROWS / MATRIX_COLS matrix structure // clang-format off #define DIRECT_PINS_CUSTOM \ diff --git a/keyboards/binepad/candypad/glcdfont.c b/keyboards/binepad/candypad/glcdfont.c index b11ef12d032..3564aa0a7c9 100644 --- a/keyboards/binepad/candypad/glcdfont.c +++ b/keyboards/binepad/candypad/glcdfont.c @@ -4,6 +4,7 @@ #include "progmem.h" /* based on https://lexus2k.github.io/ssd1306/ssd1306__fonts_8c_source.html, chars 32 - 127 */ +/* generated and tested on https://joric.github.io/qle/ */ // clang-format off static const unsigned char PROGMEM font[] = { 0xFF, 0x81, 0x81, 0x81, 0x81, 0xFF, @@ -38,7 +39,7 @@ static const unsigned char PROGMEM font[] = { 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00, 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00, 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // by @lexus2k form here down 0x00, 0x00, 0x00, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, diff --git a/keyboards/binepad/candypad/keyboard.json b/keyboards/binepad/candypad/keyboard.json index cc8c8b3eeb8..1ad030d74e9 100644 --- a/keyboards/binepad/candypad/keyboard.json +++ b/keyboards/binepad/candypad/keyboard.json @@ -15,46 +15,215 @@ "extrakey": true, "mousekey": true, "nkro": true, - "encoder": true + "encoder": true, + "oled": true }, "diode_direction": "COL2ROW", "matrix_pins": { - "cols": ["GP15", "GP14", "GP13", "GP10"], - "rows": ["GP12", "GP9", "GP7", "GP6", "GP5", null] + "cols": [ + "GP15", + "GP14", + "GP13", + "GP10" + ], + "rows": [ + "GP12", + "GP9", + "GP7", + "GP6", + "GP5", + null + ] }, "encoder": { "rotary": [ - {"pin_a": "GP28", "pin_b": "GP27"}, - {"pin_a": "GP1", "pin_b": "GP2"} + { + "pin_a": "GP28", + "pin_b": "GP27" + }, + { + "pin_a": "GP1", + "pin_b": "GP2" + } ] }, "layouts": { "LAYOUT": { "layout": [ - { "matrix": [0, 0], "label": "Num Lock", "x": 0, "y": 1}, - { "matrix": [0, 1], "label": "/", "x": 1, "y": 1}, - { "matrix": [0, 2], "label": "*", "x": 2, "y": 1}, - { "matrix": [0, 3], "label": "-", "x": 3, "y": 1}, - - { "matrix": [1, 0], "label": "7", "x": 0, "y": 2}, - { "matrix": [1, 1], "label": "8", "x": 1, "y": 2}, - { "matrix": [1, 2], "label": "9", "x": 2, "y": 2}, - { "matrix": [1, 3], "label": "+", "x": 3, "y": 2, "h": 2}, - - { "matrix": [2, 0], "label": "4", "x": 0, "y": 3}, - { "matrix": [2, 1], "label": "5", "x": 1, "y": 3}, - { "matrix": [2, 2], "label": "6", "x": 2, "y": 3}, - - { "matrix": [3, 0], "label": "1", "x": 0, "y": 4}, - { "matrix": [3, 1], "label": "2", "x": 1, "y": 4}, - { "matrix": [3, 2], "label": "3", "x": 2, "y": 4}, - { "matrix": [3, 3], "label": "Enter", "x": 3, "y": 4, "h": 2}, - - { "matrix": [4, 0], "label": "0", "x": 0, "y": 5, "w": 2}, - { "matrix": [4, 2], "label": ".", "x": 2, "y": 5}, - - { "matrix": [5, 0], "label": "", "x": 2, "y": 0}, - { "matrix": [5, 1], "label": "", "x": 3, "y": 0} + { + "matrix": [ + 5, + 0 + ], + "label": "", + "x": 2, + "y": 0 + }, + { + "matrix": [ + 5, + 1 + ], + "label": "", + "x": 3, + "y": 0 + }, + { + "matrix": [ + 0, + 0 + ], + "label": "Num Lock", + "x": 0, + "y": 1 + }, + { + "matrix": [ + 0, + 1 + ], + "label": "/", + "x": 1, + "y": 1 + }, + { + "matrix": [ + 0, + 2 + ], + "label": "*", + "x": 2, + "y": 1 + }, + { + "matrix": [ + 0, + 3 + ], + "label": "-", + "x": 3, + "y": 1 + }, + { + "matrix": [ + 1, + 0 + ], + "label": "7", + "x": 0, + "y": 2 + }, + { + "matrix": [ + 1, + 1 + ], + "label": "8", + "x": 1, + "y": 2 + }, + { + "matrix": [ + 1, + 2 + ], + "label": "9", + "x": 2, + "y": 2 + }, + { + "matrix": [ + 1, + 3 + ], + "label": "+", + "x": 3, + "y": 2, + "h": 2 + }, + { + "matrix": [ + 2, + 0 + ], + "label": "4", + "x": 0, + "y": 3 + }, + { + "matrix": [ + 2, + 1 + ], + "label": "5", + "x": 1, + "y": 3 + }, + { + "matrix": [ + 2, + 2 + ], + "label": "6", + "x": 2, + "y": 3 + }, + { + "matrix": [ + 3, + 0 + ], + "label": "1", + "x": 0, + "y": 4 + }, + { + "matrix": [ + 3, + 1 + ], + "label": "2", + "x": 1, + "y": 4 + }, + { + "matrix": [ + 3, + 2 + ], + "label": "3", + "x": 2, + "y": 4 + }, + { + "matrix": [ + 3, + 3 + ], + "label": "Enter", + "x": 3, + "y": 4, + "h": 2 + }, + { + "matrix": [ + 4, + 0 + ], + "label": "0", + "x": 0, + "y": 5, + "w": 2 + }, + { + "matrix": [ + 4, + 2 + ], + "label": ".", + "x": 2, + "y": 5 + } ] } } diff --git a/keyboards/binepad/candypad/readme.md b/keyboards/binepad/candypad/readme.md index d2c1944e8ba..dd64ebbaf8f 100644 --- a/keyboards/binepad/candypad/readme.md +++ b/keyboards/binepad/candypad/readme.md @@ -26,4 +26,4 @@ Enter the bootloader in 3 ways: * **Bootmagic reset**: Hold down the key at (0:0) in the matrix (the top left key) 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` if it is available +* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available diff --git a/keyboards/binepad/candypad/rules.mk b/keyboards/binepad/candypad/rules.mk index c73142b210c..d0d3e2f4473 100644 --- a/keyboards/binepad/candypad/rules.mk +++ b/keyboards/binepad/candypad/rules.mk @@ -3,10 +3,6 @@ CUSTOM_MATRIX = yes -OLED_ENABLE = yes -OLED_DRIVER = ssd1306 -OLED_TRANSPORT = i2c - SRC += matrix.c \ candypad_oled.c From bbd29448defd2b7d58efdc253f3d8aa9213d6a20 Mon Sep 17 00:00:00 2001 From: silvinor <366673+silvinor@users.noreply.github.com> Date: Sat, 3 May 2025 12:52:24 +1000 Subject: [PATCH 04/10] ran qmk format-json --- keyboards/binepad/candypad/keyboard.json | 241 +++--------------- .../candypad/keymaps/default/keymap.json | 36 +-- 2 files changed, 42 insertions(+), 235 deletions(-) diff --git a/keyboards/binepad/candypad/keyboard.json b/keyboards/binepad/candypad/keyboard.json index 1ad030d74e9..fbcc2647bb9 100644 --- a/keyboards/binepad/candypad/keyboard.json +++ b/keyboards/binepad/candypad/keyboard.json @@ -1,229 +1,56 @@ { "manufacturer": "binepad", "keyboard_name": "CandyPad", - "url": "https://candykeys.com/product/candypad-keyboard", "maintainer": "binepad", - "processor": "RP2040", "bootloader": "rp2040", - "usb": { - "vid": "0x4249", - "pid": "0x4350", - "device_version": "1.0.0" + "diode_direction": "COL2ROW", + "encoder": { + "rotary": [ + {"pin_a": "GP28", "pin_b": "GP27"}, + {"pin_a": "GP1", "pin_b": "GP2"} + ] }, "features": { "bootmagic": true, + "encoder": true, "extrakey": true, "mousekey": true, "nkro": true, - "encoder": true, "oled": true }, - "diode_direction": "COL2ROW", "matrix_pins": { - "cols": [ - "GP15", - "GP14", - "GP13", - "GP10" - ], - "rows": [ - "GP12", - "GP9", - "GP7", - "GP6", - "GP5", - null - ] + "cols": ["GP15", "GP14", "GP13", "GP10"], + "rows": ["GP12", "GP9", "GP7", "GP6", "GP5", null] }, - "encoder": { - "rotary": [ - { - "pin_a": "GP28", - "pin_b": "GP27" - }, - { - "pin_a": "GP1", - "pin_b": "GP2" - } - ] + "processor": "RP2040", + "url": "https://candykeys.com/product/candypad-keyboard", + "usb": { + "device_version": "1.0.0", + "pid": "0x4350", + "vid": "0x4249" }, "layouts": { "LAYOUT": { "layout": [ - { - "matrix": [ - 5, - 0 - ], - "label": "", - "x": 2, - "y": 0 - }, - { - "matrix": [ - 5, - 1 - ], - "label": "", - "x": 3, - "y": 0 - }, - { - "matrix": [ - 0, - 0 - ], - "label": "Num Lock", - "x": 0, - "y": 1 - }, - { - "matrix": [ - 0, - 1 - ], - "label": "/", - "x": 1, - "y": 1 - }, - { - "matrix": [ - 0, - 2 - ], - "label": "*", - "x": 2, - "y": 1 - }, - { - "matrix": [ - 0, - 3 - ], - "label": "-", - "x": 3, - "y": 1 - }, - { - "matrix": [ - 1, - 0 - ], - "label": "7", - "x": 0, - "y": 2 - }, - { - "matrix": [ - 1, - 1 - ], - "label": "8", - "x": 1, - "y": 2 - }, - { - "matrix": [ - 1, - 2 - ], - "label": "9", - "x": 2, - "y": 2 - }, - { - "matrix": [ - 1, - 3 - ], - "label": "+", - "x": 3, - "y": 2, - "h": 2 - }, - { - "matrix": [ - 2, - 0 - ], - "label": "4", - "x": 0, - "y": 3 - }, - { - "matrix": [ - 2, - 1 - ], - "label": "5", - "x": 1, - "y": 3 - }, - { - "matrix": [ - 2, - 2 - ], - "label": "6", - "x": 2, - "y": 3 - }, - { - "matrix": [ - 3, - 0 - ], - "label": "1", - "x": 0, - "y": 4 - }, - { - "matrix": [ - 3, - 1 - ], - "label": "2", - "x": 1, - "y": 4 - }, - { - "matrix": [ - 3, - 2 - ], - "label": "3", - "x": 2, - "y": 4 - }, - { - "matrix": [ - 3, - 3 - ], - "label": "Enter", - "x": 3, - "y": 4, - "h": 2 - }, - { - "matrix": [ - 4, - 0 - ], - "label": "0", - "x": 0, - "y": 5, - "w": 2 - }, - { - "matrix": [ - 4, - 2 - ], - "label": ".", - "x": 2, - "y": 5 - } + {"label": "", "matrix": [5, 0], "x": 2, "y": 0}, + {"label": "", "matrix": [5, 1], "x": 3, "y": 0}, + {"label": "Num Lock", "matrix": [0, 0], "x": 0, "y": 1}, + {"label": "/", "matrix": [0, 1], "x": 1, "y": 1}, + {"label": "*", "matrix": [0, 2], "x": 2, "y": 1}, + {"label": "-", "matrix": [0, 3], "x": 3, "y": 1}, + {"label": "7", "matrix": [1, 0], "x": 0, "y": 2}, + {"label": "8", "matrix": [1, 1], "x": 1, "y": 2}, + {"label": "9", "matrix": [1, 2], "x": 2, "y": 2}, + {"label": "+", "matrix": [1, 3], "x": 3, "y": 2, "h": 2}, + {"label": "4", "matrix": [2, 0], "x": 0, "y": 3}, + {"label": "5", "matrix": [2, 1], "x": 1, "y": 3}, + {"label": "6", "matrix": [2, 2], "x": 2, "y": 3}, + {"label": "1", "matrix": [3, 0], "x": 0, "y": 4}, + {"label": "2", "matrix": [3, 1], "x": 1, "y": 4}, + {"label": "3", "matrix": [3, 2], "x": 2, "y": 4}, + {"label": "Enter", "matrix": [3, 3], "x": 3, "y": 4, "h": 2}, + {"label": "0", "matrix": [4, 0], "x": 0, "y": 5, "w": 2}, + {"label": ".", "matrix": [4, 2], "x": 2, "y": 5} ] } } diff --git a/keyboards/binepad/candypad/keymaps/default/keymap.json b/keyboards/binepad/candypad/keymaps/default/keymap.json index 9e90c12ccb8..d235bb4d84f 100644 --- a/keyboards/binepad/candypad/keymaps/default/keymap.json +++ b/keyboards/binepad/candypad/keymaps/default/keymap.json @@ -1,31 +1,4 @@ { - "keyboard": "binepad/candypad", - "keymap": "default", - "version": 1, - "layout": "LAYOUT", - "layers": [ - [ - "KC_NUM", - "KC_PSLS", - "KC_PAST", - "KC_PMNS", - "KC_P7", - "KC_P8", - "KC_P9", - "KC_PPLS", - "KC_P4", - "KC_P5", - "KC_P6", - "KC_P1", - "KC_P2", - "KC_P3", - "KC_PENT", - "KC_P0", - "KC_PDOT", - "MO(1)", - "KC_MUTE" - ] - ], "config": { "features": { "encoder_map": true @@ -42,5 +15,12 @@ "cw": "KC_VOLU" } ] - ] + ], + "keyboard": "binepad/candypad", + "keymap": "default", + "layers": [ + ["KC_NUM", "KC_PSLS", "KC_PAST", "KC_PMNS", "KC_P7", "KC_P8", "KC_P9", "KC_PPLS", "KC_P4", "KC_P5", "KC_P6", "KC_P1", "KC_P2", "KC_P3", "KC_PENT", "KC_P0", "KC_PDOT", "MO(1)", "KC_MUTE"] + ], + "layout": "LAYOUT", + "version": 1 } From ef8a97659a2077736102c65a06cba18a7e21554e Mon Sep 17 00:00:00 2001 From: silvinor <366673+silvinor@users.noreply.github.com> Date: Sun, 4 May 2025 20:43:42 +1000 Subject: [PATCH 05/10] post @drashna review --- keyboards/binepad/candypad/candypad.h | 6 +- keyboards/binepad/candypad/candypad_oled.c | 26 ++--- keyboards/binepad/candypad/config.h | 4 +- keyboards/binepad/candypad/halconf.h | 8 -- keyboards/binepad/candypad/matrix.c | 127 +++++---------------- keyboards/binepad/candypad/rules.mk | 4 +- 6 files changed, 49 insertions(+), 126 deletions(-) delete mode 100644 keyboards/binepad/candypad/halconf.h diff --git a/keyboards/binepad/candypad/candypad.h b/keyboards/binepad/candypad/candypad.h index 53bbce9002e..e4259e8726d 100644 --- a/keyboards/binepad/candypad/candypad.h +++ b/keyboards/binepad/candypad/candypad.h @@ -11,12 +11,14 @@ # define OLED_SPLASH_TIMEOUT 2500 # endif +// clang-format off enum oled_modes { OLED_SPLASH, OLED_DEFAULT, OLED_OFF, __NUM_OLED_MODES } oled_modes_t; +// clang-format on bool candypad_render_logo_user(void); bool candypad_render_logo_kb(void); @@ -24,8 +26,8 @@ bool candypad_render_default_user(void); bool candypad_render_default_kb(void); // OLED functions -extern uint8_t oled_mode; -extern bool oled_repaint_requested; +extern uint8_t oled_mode; +extern bool oled_repaint_requested; extern uint32_t oled_splash_timer; #endif diff --git a/keyboards/binepad/candypad/candypad_oled.c b/keyboards/binepad/candypad/candypad_oled.c index 3d335b30508..e88ea747e81 100644 --- a/keyboards/binepad/candypad/candypad_oled.c +++ b/keyboards/binepad/candypad/candypad_oled.c @@ -11,17 +11,17 @@ /* CandyPad Logo */ static void __candypad_render_logo_default(void) { // Generated from https://joric.github.io/qle/ - static const unsigned char PROGMEM raw_logo[] = { + static const char PROGMEM raw_logo[] = { 0, 0, 0, 0, 128, 192, 224, 96, 240, 240, 152, 24, 24, 24, 24, 24, 24, 24, 24, 56, 48, 96, 224, 192, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 0, 0, 192, 248, 62, 7, 15, 28, 56, 112, 225, 195, 135, 14, 28, 56, 112, 224, 192, 128, 0, 0, 0, 0, 1, 7, 62, 252, 192, 0, 128, 192, 224, 112, 48, 48, 48, 112, 96, 0, 128, 192, 224, 96, 48, 48, 48, 112, 224, 240, 240, 0, 0, 240, 240, 96, 112, 48, 48, 48, 112, 224, 192, 128, 0, 0, 128, 192, 224, 112, 48, 48, 48, 112, 224, 255, 255, 0, 48, 112, 224, 128, 0, 0, 0, 0, 128, 224, 112, 48, 0, 240, 240, 224, 112, 48, 48, 48, 112, 224, 192, 128, 0, 0, 128, 192, 224, 96, 48, 48, 48, 112, 224, 240, 240, 0, 0, 128, 192, 224, 112, 48, 48, 48, 112, 224, 255, 255, 0, 0, 3, 31, 124, 224, 192, 0, 0, 0, 0, 1, 3, 7, 14, 28, 56, 112, 225, 195, 135, 14, 28, 56, 240, 224, 124, 63, 3, 0, 15, 31, 56, 112, 96, 96, 96, 112, 48, 0, 15, 31, 56, 112, 96, 96, 96, 112, 56, 127, 127, 0, 0, 127, 127, 0, 0, 0, 0, 0, 0, 1, 127, 127, 0, 0, 15, 31, 56, 112, 96, 96, 96, 112, 56, 127, 127, 0, 0, 0, 3, 15, 62, 240, 248, 62, 15, 3, 0, 0, 0, 255, 255, 56, 112, 96, 96, 96, 112, 56, 31, 15, 0, 0, 15, 31, 56, 112, 96, 96, 96, 112, 56, 127, 127, 0, 0, 15, 63, 56, 112, 96, 96, 96, 112, 56, 127, 127, 0, 0, 0, 0, 0, 1, 3, 7, 6, 14, 12, 24, 24, 24, 24, 24, 24, 24, 24, 25, 15, 15, 6, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 31, 7, 1, 0, 0, 0, 0, 0, 0, 31, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; - oled_write_raw_P((char *)raw_logo, sizeof(raw_logo)); + oled_write_raw_P(raw_logo, sizeof(raw_logo)); } -// weak so that user keymaps can make their own +// Weak so that user keymaps can make their own __attribute__((weak)) bool candypad_render_logo_user(void) { - return false; // return true if your user keymap renders its own + return false; // Return true if your user keymap renders its own } __attribute__((weak)) bool candypad_render_logo_kb(void) { @@ -40,8 +40,8 @@ oled_rotation_t oled_init_kb(oled_rotation_t rotation) { static char *get_enc_mode(uint8_t encoder) { # ifdef ENCODER_MAP_ENABLE - static char s_u_d[4] = {24, 38, 25, 0}; // up and down - static char s_l_r[4] = {27, 38, 26, 0}; // left and right + static char s_u_d[4] = {24, 38, 25, 0}; // Up and down + static char s_l_r[4] = {27, 38, 26, 0}; // Left and right uint8_t layer = get_highest_layer(layer_state); uint16_t keycode = KC_TRNS; @@ -111,14 +111,14 @@ static void __draw_line_v(uint8_t x, uint8_t y, uint8_t len, bool on) { } } -// weak so that user keymaps can make their own +// Weak so that user keymaps can make their own __attribute__((weak)) bool candypad_render_default_user(void) { - return false; // return true if your user keymap renders its own + return false; // Return true if your user keymap renders its own } __attribute__((weak)) bool candypad_render_default_kb(void) { if (candypad_render_default_user()) { - return true; // was handled by user code + return true; // Was handled by user code } bool on; @@ -203,7 +203,7 @@ __attribute__((weak)) bool candypad_render_default_kb(void) { __draw_line_v(MXDS_X - 2, MXDS_Y - 1, 8, true); __draw_line_v(MXDS_X + 5, MXDS_Y - 1, 8, true); - return true; // was handled here + return true; // Was handled here } bool oled_task_kb(void) { @@ -211,7 +211,7 @@ bool oled_task_kb(void) { return false; } // if (!oled_task_needs_to_repaint()) { return false; } - /* !!! oled_clear(); // is broken !!! */ + /* !! : oled_clear(); // Is broken !!! */ if (oled_repaint_requested) { oled_repaint_requested = false; oled_clear(); @@ -220,8 +220,8 @@ bool oled_task_kb(void) { switch (oled_mode) { case OLED_OFF: - // do nothing - // this PCB has no digital switch to power off the OLED :( + // Do nothing + // This PCB has no digital switch to power off the OLED :( break; case OLED_SPLASH: diff --git a/keyboards/binepad/candypad/config.h b/keyboards/binepad/candypad/config.h index 80eb26b062b..20c0c88abcf 100644 --- a/keyboards/binepad/candypad/config.h +++ b/keyboards/binepad/candypad/config.h @@ -15,7 +15,7 @@ /* Configure oled driver for the 128x32 oled */ # define OLED_TIMEOUT (15 * 60 * 1000) // 15 minutes -# define OLED_UPDATE_INTERVAL 33 // ~30fps +# define OLED_UPDATE_INTERVAL 33 // ~30fps /* Font */ # define OLED_FONT_H "keyboards/binepad/candypad/glcdfont.c" @@ -23,7 +23,7 @@ #endif // OLED_ENABLE /* ---- Direct pins, for use in (custom) `matrix.c` (please read that file) ----- */ -// *NB*: DIRECT_PINS_CUSTOM must match the MATRIX_ROWS / MATRIX_COLS matrix structure +// !! : DIRECT_PINS_CUSTOM must match the MATRIX_ROWS / MATRIX_COLS matrix structure // clang-format off #define DIRECT_PINS_CUSTOM \ { \ diff --git a/keyboards/binepad/candypad/halconf.h b/keyboards/binepad/candypad/halconf.h deleted file mode 100644 index 8d0392e4980..00000000000 --- a/keyboards/binepad/candypad/halconf.h +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2023 binepad (@binepad) -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#define HAL_USE_I2C TRUE - -#include_next diff --git a/keyboards/binepad/candypad/matrix.c b/keyboards/binepad/candypad/matrix.c index 29bc06690e1..2e9867e5b46 100644 --- a/keyboards/binepad/candypad/matrix.c +++ b/keyboards/binepad/candypad/matrix.c @@ -6,104 +6,59 @@ * This file is mostly a copy of `matrix.c` from the QMK core, however * it assumes the matrix is always COL2ROW and that the KB has BOTH * matrix and direct pins. - + * * For direct pins define * `DIRECT_PINS_CUSTOM` - * This stucture must match exactly the MATRIX_ROWS / MATRIX_COLS matrix. + * This stucture must exactly match the MATRIX_ROWS / MATRIX_COLS matrix. * - * NB!!: The ROW that supports direct pins **must** have the row set - * to NO_PIN in the matrix array. -*/ + * !! : The ROW that supports direct pins __must__ have the row set to NO_PIN in the matrix array. + */ #include "matrix.h" #include "debounce.h" #include "atomic_util.h" -#include +#include // For memset, memcmp & memcpy #include "wait.h" -#include "print.h" - -#ifndef DEBOUNCE -# define DEBOUNCE 5 -#endif #ifndef MATRIX_INPUT_PRESSED_STATE # define MATRIX_INPUT_PRESSED_STATE 0 #endif -#ifndef MATRIX_IO_DELAY -# define MATRIX_IO_DELAY 30 -#endif - static pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; // define DIRECT_PINS_CUSTOM in `config.h` -// ** NB: ** must match the MATRIX_ROWS / MATRIX_COLS matrix structure +// !! : Must match the MATRIX_ROWS / MATRIX_COLS matrix structure static pin_t direct_pins[MATRIX_ROWS][MATRIX_COLS] = DIRECT_PINS_CUSTOM; /* matrix state(1:on, 0:off) */ matrix_row_t raw_matrix[MATRIX_ROWS]; -matrix_row_t matrix[MATRIX_ROWS]; -__attribute__((weak)) void matrix_init_user(void) {} - -__attribute__((weak)) void matrix_init_kb(void) { - matrix_init_user(); -} - -__attribute__((weak)) void matrix_scan_user(void) {} - -__attribute__((weak)) void matrix_scan_kb(void) { - matrix_scan_user(); -} - -#define print_matrix_header() print("\nr/c 01234567\n") -#define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) - -__attribute__((weak)) void matrix_output_select_delay(void) { - waitInputPinDelay(); -} - -__attribute__((weak)) void matrix_output_unselect_delay(uint8_t line, bool key_pressed) { - wait_us(MATRIX_IO_DELAY); -} - -static inline void setPinOutput_writeLow(pin_t pin) { +static inline void gpio_atomic_set_pin_output_low(pin_t pin) { ATOMIC_BLOCK_FORCEON { - setPinOutput(pin); - writePinLow(pin); + gpio_set_pin_output(pin); + gpio_write_pin_low(pin); } } -static inline void setPinInputHigh_atomic(pin_t pin) { +static inline void gpio_atomic_set_pin_input_high(pin_t pin) { ATOMIC_BLOCK_FORCEON { - setPinInputHigh(pin); + gpio_set_pin_input_high(pin); } } -static inline uint8_t readMatrixPin(pin_t pin) { +static inline uint8_t gpio_read_matrix_pin(pin_t pin) { if (pin != NO_PIN) { - return (readPin(pin) == MATRIX_INPUT_PRESSED_STATE) ? 0 : 1; + return (gpio_read_pin(pin) == MATRIX_INPUT_PRESSED_STATE) ? 0 : 1; } else { return 1; } } -void matrix_print(void) { - print_matrix_header(); - - for (uint8_t row = 0; row < MATRIX_ROWS; row++) { - print_hex8(row); - print(": "); - print_matrix_row(row); - print("\n"); - } -} - static bool select_row(uint8_t row) { pin_t pin = row_pins[row]; if (pin != NO_PIN) { - setPinOutput_writeLow(pin); + gpio_atomic_set_pin_output_low(pin); return true; } return false; @@ -112,7 +67,7 @@ static bool select_row(uint8_t row) { static void unselect_row(uint8_t row) { pin_t pin = row_pins[row]; if (pin != NO_PIN) { - setPinInputHigh_atomic(pin); + gpio_atomic_set_pin_input_high(pin); } } @@ -126,7 +81,7 @@ void matrix_init_pins__matrix(void) { unselect_rows(); for (uint8_t x = 0; x < MATRIX_COLS; x++) { if (col_pins[x] != NO_PIN) { - setPinInputHigh_atomic(col_pins[x]); + gpio_atomic_set_pin_input_high(col_pins[x]); } } } @@ -136,42 +91,19 @@ void matrix_init_pins__direct(void) { for (int col = 0; col < MATRIX_COLS; col++) { pin_t pin = direct_pins[row][col]; if (pin != NO_PIN) { - setPinInputHigh(pin); + gpio_atomic_set_pin_input_high(pin); } } } } -inline uint8_t matrix_rows(void) { - return MATRIX_ROWS; -} - -inline uint8_t matrix_cols(void) { - return MATRIX_COLS; -} - -void matrix_init(void) { +void matrix_init_custom(void) { // initialize key pins matrix_init_pins__matrix(); matrix_init_pins__direct(); // initialize matrix state: all keys off memset(raw_matrix, 0, sizeof(raw_matrix)); - memset(matrix, 0, sizeof(matrix)); - - // Unless hardware debouncing - Init the configured debounce routine - debounce_init(MATRIX_ROWS); - - // This *must* be called for correct keyboard behavior - matrix_init_kb(); -} - -inline bool matrix_is_on(uint8_t row, uint8_t col) { - return (matrix[row] & ((matrix_row_t)1 << col)); -} - -inline matrix_row_t matrix_get_row(uint8_t row) { - return matrix[row]; } void matrix_read_cols_on_row__matrix(matrix_row_t current_matrix[], uint8_t current_row) { @@ -186,7 +118,7 @@ void matrix_read_cols_on_row__matrix(matrix_row_t current_matrix[], uint8_t curr // For each col... matrix_row_t row_shifter = MATRIX_ROW_SHIFTER; for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++, row_shifter <<= 1) { - uint8_t pin_state = readMatrixPin(col_pins[col_index]); + uint8_t pin_state = gpio_read_matrix_pin(col_pins[col_index]); // Populate the matrix row with the state of the col pin current_row_value |= pin_state ? 0 : row_shifter; @@ -208,7 +140,7 @@ void matrix_read_cols_on_row__direct(matrix_row_t current_matrix[], uint8_t curr for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++, row_shifter <<= 1) { pin_t pin = direct_pins[current_row][col_index]; if (NO_PIN != pin) { - current_row_value |= readMatrixPin(pin) ? 0 : row_shifter; + current_row_value |= gpio_read_matrix_pin(pin) ? 0 : row_shifter; } } @@ -216,24 +148,23 @@ void matrix_read_cols_on_row__direct(matrix_row_t current_matrix[], uint8_t curr current_matrix[current_row] = current_row_value; } -uint8_t matrix_scan(void) { - matrix_row_t curr_matrix[MATRIX_ROWS] = {0}; +bool matrix_scan_custom(matrix_row_t current_matrix[]) { + bool matrix_has_changed = false; // Matrix keys: Set row, read cols for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { // if the row is a NO_PIN then assume it's on a direct pins matrix, else assume COL2ROW matrix if (NO_PIN != row_pins[current_row]) { - matrix_read_cols_on_row__matrix(curr_matrix, current_row); + matrix_read_cols_on_row__matrix(current_matrix, current_row); } else { - matrix_read_cols_on_row__direct(curr_matrix, current_row); + matrix_read_cols_on_row__direct(current_matrix, current_row); } } - bool changed = memcmp(raw_matrix, curr_matrix, sizeof(curr_matrix)) != 0; - if (changed) memcpy(raw_matrix, curr_matrix, sizeof(curr_matrix)); + matrix_has_changed = memcmp(raw_matrix, current_matrix, MATRIX_ROWS) != 0; + if (matrix_has_changed) { + memcpy(raw_matrix, current_matrix, MATRIX_ROWS); + } - changed = debounce(raw_matrix, matrix, MATRIX_ROWS, changed); - matrix_scan_kb(); - - return (uint8_t)changed; + return matrix_has_changed; } diff --git a/keyboards/binepad/candypad/rules.mk b/keyboards/binepad/candypad/rules.mk index d0d3e2f4473..4879c468ada 100644 --- a/keyboards/binepad/candypad/rules.mk +++ b/keyboards/binepad/candypad/rules.mk @@ -1,9 +1,7 @@ # Copyright 2023 binepad (@binepad) # SPDX-License-Identifier: GPL-2.0-or-later -CUSTOM_MATRIX = yes +CUSTOM_MATRIX = lite SRC += matrix.c \ candypad_oled.c - -OPT_DEFS += -DHAL_USE_I2C=TRUE From ce69ee413eebd33e272d9bc2e64a8018e0a54e38 Mon Sep 17 00:00:00 2001 From: silvinor <366673+silvinor@users.noreply.github.com> Date: Tue, 6 May 2025 08:56:48 +1000 Subject: [PATCH 06/10] roll-back on some post review code --- keyboards/binepad/candypad/glcdfont.c | 185 ++++++++++++----------- keyboards/binepad/candypad/keyboard.json | 6 +- keyboards/binepad/candypad/matrix.c | 125 +++++++++++---- keyboards/binepad/candypad/rules.mk | 2 +- 4 files changed, 195 insertions(+), 123 deletions(-) diff --git a/keyboards/binepad/candypad/glcdfont.c b/keyboards/binepad/candypad/glcdfont.c index 3564aa0a7c9..aa6588df260 100644 --- a/keyboards/binepad/candypad/glcdfont.c +++ b/keyboards/binepad/candypad/glcdfont.c @@ -7,7 +7,7 @@ /* generated and tested on https://joric.github.io/qle/ */ // clang-format off static const unsigned char PROGMEM font[] = { - 0xFF, 0x81, 0x81, 0x81, 0x81, 0xFF, + 0xFF, 0x81, 0x81, 0x81, 0xFF, 0x00, 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00, 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, @@ -39,96 +39,99 @@ static const unsigned char PROGMEM font[] = { 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00, 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00, 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // by @lexus2k form here down - 0x00, 0x00, 0x00, 0x2F, 0x00, 0x00, - 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, - 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, - 0x00, 0x24, 0x2A, 0x7F, 0x2A, 0x12, - 0x00, 0x23, 0x13, 0x08, 0x64, 0x62, - 0x00, 0x36, 0x49, 0x55, 0x22, 0x50, - 0x00, 0x00, 0x05, 0x03, 0x00, 0x00, - 0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, - 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, - 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14, - 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, - 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00, - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, - 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, - 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E, - 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, - 0x00, 0x42, 0x61, 0x51, 0x49, 0x46, - 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31, - 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10, - 0x00, 0x27, 0x45, 0x45, 0x45, 0x39, - 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30, - 0x00, 0x01, 0x71, 0x09, 0x05, 0x03, - 0x00, 0x36, 0x49, 0x49, 0x49, 0x36, - 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E, - 0x00, 0x00, 0x36, 0x36, 0x00, 0x00, - 0x00, 0x00, 0x56, 0x36, 0x00, 0x00, - 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, - 0x00, 0x14, 0x14, 0x14, 0x14, 0x14, - 0x00, 0x00, 0x41, 0x22, 0x14, 0x08, - 0x00, 0x02, 0x01, 0x51, 0x09, 0x06, - 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E, - 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C, - 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36, - 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22, - 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C, - 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41, - 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01, - 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A, - 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F, - 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00, - 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, - 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41, - 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40, - 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F, - 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F, - 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E, - 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06, - 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E, - 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46, - 0x00, 0x46, 0x49, 0x49, 0x49, 0x31, - 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01, - 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F, - 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F, - 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F, - 0x00, 0x63, 0x14, 0x08, 0x14, 0x63, - 0x00, 0x07, 0x08, 0x70, 0x08, 0x07, - 0x00, 0x61, 0x51, 0x49, 0x45, 0x43, - 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00, - 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, - 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00, - 0x00, 0x04, 0x02, 0x01, 0x02, 0x04, - 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, - 0x00, 0x00, 0x01, 0x02, 0x04, 0x00, - 0x00, 0x20, 0x54, 0x54, 0x54, 0x78, - 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38, - 0x00, 0x38, 0x44, 0x44, 0x44, 0x20, - 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F, - 0x00, 0x38, 0x54, 0x54, 0x54, 0x18, - 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02, - 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C, - 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78, - 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00, - 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00, - 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, - 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, - 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78, - 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78, - 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, - 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18, - 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC, - 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08, - 0x00, 0x48, 0x54, 0x54, 0x54, 0x20, - 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20, - 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C, - 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C, - 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C, - 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, - 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // sp + 0x00, 0x00, 0x2F, 0x00, 0x00, 0x00, + 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, + 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, + 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, + 0x23, 0x13, 0x08, 0x64, 0x62, 0x00, + 0x36, 0x49, 0x55, 0x22, 0x50, 0x00, + 0x00, 0x05, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, + 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00, + 0x14, 0x08, 0x3E, 0x08, 0x14, 0x00, + 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, + 0x00, 0x00, 0xA0, 0x60, 0x00, 0x00, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, + 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, + 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, + 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, + 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, + 0x42, 0x61, 0x51, 0x49, 0x46, 0x00, + 0x21, 0x41, 0x45, 0x4B, 0x31, 0x00, + 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, + 0x27, 0x45, 0x45, 0x45, 0x39, 0x00, + 0x3C, 0x4A, 0x49, 0x49, 0x30, 0x00, + 0x01, 0x71, 0x09, 0x05, 0x03, 0x00, + 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, + 0x06, 0x49, 0x49, 0x29, 0x1E, 0x00, + 0x00, 0x36, 0x36, 0x00, 0x00, 0x00, + 0x00, 0x56, 0x36, 0x00, 0x00, 0x00, + 0x08, 0x14, 0x22, 0x41, 0x00, 0x00, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, + 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, + 0x02, 0x01, 0x51, 0x09, 0x06, 0x00, + + 0x32, 0x49, 0x59, 0x51, 0x3E, 0x00, + 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00, + 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, + 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, + 0x7F, 0x41, 0x41, 0x22, 0x1C, 0x00, + 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, + 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, + 0x3E, 0x41, 0x49, 0x49, 0x7A, 0x00, + 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, + 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, + 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00, + 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, + 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, + 0x7F, 0x02, 0x0C, 0x02, 0x7F, 0x00, + 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, + 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, + 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, + 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, + 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, + 0x46, 0x49, 0x49, 0x49, 0x31, 0x00, + 0x01, 0x01, 0x7F, 0x01, 0x01, 0x00, + 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, + 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, + 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, + 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, + 0x07, 0x08, 0x70, 0x08, 0x07, 0x00, + 0x61, 0x51, 0x49, 0x45, 0x43, 0x00, + 0x00, 0x7F, 0x41, 0x41, 0x00, 0x00, + 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, + 0x00, 0x41, 0x41, 0x7F, 0x00, 0x00, + 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, + + 0x00, 0x01, 0x02, 0x04, 0x00, 0x00, + 0x20, 0x54, 0x54, 0x54, 0x78, 0x00, + 0x7F, 0x48, 0x44, 0x44, 0x38, 0x00, + 0x38, 0x44, 0x44, 0x44, 0x20, 0x00, + 0x38, 0x44, 0x44, 0x48, 0x7F, 0x00, + 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, + 0x08, 0x7E, 0x09, 0x01, 0x02, 0x00, + 0x18, 0xA4, 0xA4, 0xA4, 0x7C, 0x00, + 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, + 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00, + 0x40, 0x80, 0x84, 0x7D, 0x00, 0x00, + 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, + 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, + 0x7C, 0x04, 0x18, 0x04, 0x78, 0x00, + 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00, + 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, + 0xFC, 0x24, 0x24, 0x24, 0x18, 0x00, + 0x18, 0x24, 0x24, 0x18, 0xFC, 0x00, + 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, + 0x48, 0x54, 0x54, 0x54, 0x20, 0x00, + 0x04, 0x3F, 0x44, 0x40, 0x20, 0x00, + 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, + 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, + 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, + 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, + 0x1C, 0xA0, 0xA0, 0xA0, 0x7C, 0x00, 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x00, 0x08, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, diff --git a/keyboards/binepad/candypad/keyboard.json b/keyboards/binepad/candypad/keyboard.json index fbcc2647bb9..42016243af8 100644 --- a/keyboards/binepad/candypad/keyboard.json +++ b/keyboards/binepad/candypad/keyboard.json @@ -32,8 +32,6 @@ "layouts": { "LAYOUT": { "layout": [ - {"label": "", "matrix": [5, 0], "x": 2, "y": 0}, - {"label": "", "matrix": [5, 1], "x": 3, "y": 0}, {"label": "Num Lock", "matrix": [0, 0], "x": 0, "y": 1}, {"label": "/", "matrix": [0, 1], "x": 1, "y": 1}, {"label": "*", "matrix": [0, 2], "x": 2, "y": 1}, @@ -50,7 +48,9 @@ {"label": "3", "matrix": [3, 2], "x": 2, "y": 4}, {"label": "Enter", "matrix": [3, 3], "x": 3, "y": 4, "h": 2}, {"label": "0", "matrix": [4, 0], "x": 0, "y": 5, "w": 2}, - {"label": ".", "matrix": [4, 2], "x": 2, "y": 5} + {"label": ".", "matrix": [4, 2], "x": 2, "y": 5}, + {"label": "", "matrix": [5, 0], "x": 2, "y": 0}, + {"label": "", "matrix": [5, 1], "x": 3, "y": 0}, ] } } diff --git a/keyboards/binepad/candypad/matrix.c b/keyboards/binepad/candypad/matrix.c index 2e9867e5b46..5933809ddb8 100644 --- a/keyboards/binepad/candypad/matrix.c +++ b/keyboards/binepad/candypad/matrix.c @@ -6,59 +6,104 @@ * This file is mostly a copy of `matrix.c` from the QMK core, however * it assumes the matrix is always COL2ROW and that the KB has BOTH * matrix and direct pins. - * + * For direct pins define * `DIRECT_PINS_CUSTOM` * This stucture must exactly match the MATRIX_ROWS / MATRIX_COLS matrix. * - * !! : The ROW that supports direct pins __must__ have the row set to NO_PIN in the matrix array. - */ + * NB!!: The ROW that supports direct pins **must** have the row set + * to NO_PIN in the matrix array. +*/ #include "matrix.h" #include "debounce.h" #include "atomic_util.h" -#include // For memset, memcmp & memcpy +#include #include "wait.h" +#include "print.h" + +#ifndef DEBOUNCE +# define DEBOUNCE 5 +#endif #ifndef MATRIX_INPUT_PRESSED_STATE # define MATRIX_INPUT_PRESSED_STATE 0 #endif +#ifndef MATRIX_IO_DELAY +# define MATRIX_IO_DELAY 30 +#endif + static pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; // define DIRECT_PINS_CUSTOM in `config.h` -// !! : Must match the MATRIX_ROWS / MATRIX_COLS matrix structure +// ** NB: ** must match the MATRIX_ROWS / MATRIX_COLS matrix structure static pin_t direct_pins[MATRIX_ROWS][MATRIX_COLS] = DIRECT_PINS_CUSTOM; /* matrix state(1:on, 0:off) */ matrix_row_t raw_matrix[MATRIX_ROWS]; +matrix_row_t matrix[MATRIX_ROWS]; -static inline void gpio_atomic_set_pin_output_low(pin_t pin) { +__attribute__((weak)) void matrix_init_user(void) {} + +__attribute__((weak)) void matrix_init_kb(void) { + matrix_init_user(); +} + +__attribute__((weak)) void matrix_scan_user(void) {} + +__attribute__((weak)) void matrix_scan_kb(void) { + matrix_scan_user(); +} + +#define print_matrix_header() print("\nr/c 01234567\n") +#define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) + +__attribute__((weak)) void matrix_output_select_delay(void) { + waitInputPinDelay(); +} + +__attribute__((weak)) void matrix_output_unselect_delay(uint8_t line, bool key_pressed) { + wait_us(MATRIX_IO_DELAY); +} + +static inline void setPinOutput_writeLow(pin_t pin) { ATOMIC_BLOCK_FORCEON { - gpio_set_pin_output(pin); - gpio_write_pin_low(pin); + setPinOutput(pin); + writePinLow(pin); } } -static inline void gpio_atomic_set_pin_input_high(pin_t pin) { +static inline void setPinInputHigh_atomic(pin_t pin) { ATOMIC_BLOCK_FORCEON { - gpio_set_pin_input_high(pin); + setPinInputHigh(pin); } } -static inline uint8_t gpio_read_matrix_pin(pin_t pin) { +static inline uint8_t readMatrixPin(pin_t pin) { if (pin != NO_PIN) { - return (gpio_read_pin(pin) == MATRIX_INPUT_PRESSED_STATE) ? 0 : 1; + return (readPin(pin) == MATRIX_INPUT_PRESSED_STATE) ? 0 : 1; } else { return 1; } } +void matrix_print(void) { + print_matrix_header(); + + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + print_hex8(row); + print(": "); + print_matrix_row(row); + print("\n"); + } +} + static bool select_row(uint8_t row) { pin_t pin = row_pins[row]; if (pin != NO_PIN) { - gpio_atomic_set_pin_output_low(pin); + setPinOutput_writeLow(pin); return true; } return false; @@ -67,7 +112,7 @@ static bool select_row(uint8_t row) { static void unselect_row(uint8_t row) { pin_t pin = row_pins[row]; if (pin != NO_PIN) { - gpio_atomic_set_pin_input_high(pin); + setPinInputHigh_atomic(pin); } } @@ -81,7 +126,7 @@ void matrix_init_pins__matrix(void) { unselect_rows(); for (uint8_t x = 0; x < MATRIX_COLS; x++) { if (col_pins[x] != NO_PIN) { - gpio_atomic_set_pin_input_high(col_pins[x]); + setPinInputHigh_atomic(col_pins[x]); } } } @@ -91,19 +136,42 @@ void matrix_init_pins__direct(void) { for (int col = 0; col < MATRIX_COLS; col++) { pin_t pin = direct_pins[row][col]; if (pin != NO_PIN) { - gpio_atomic_set_pin_input_high(pin); + setPinInputHigh(pin); } } } } -void matrix_init_custom(void) { +inline uint8_t matrix_rows(void) { + return MATRIX_ROWS; +} + +inline uint8_t matrix_cols(void) { + return MATRIX_COLS; +} + +void matrix_init(void) { // initialize key pins matrix_init_pins__matrix(); matrix_init_pins__direct(); // initialize matrix state: all keys off memset(raw_matrix, 0, sizeof(raw_matrix)); + memset(matrix, 0, sizeof(matrix)); + + // Unless hardware debouncing - Init the configured debounce routine + debounce_init(MATRIX_ROWS); + + // This *must* be called for correct keyboard behavior + matrix_init_kb(); +} + +inline bool matrix_is_on(uint8_t row, uint8_t col) { + return (matrix[row] & ((matrix_row_t)1 << col)); +} + +inline matrix_row_t matrix_get_row(uint8_t row) { + return matrix[row]; } void matrix_read_cols_on_row__matrix(matrix_row_t current_matrix[], uint8_t current_row) { @@ -118,7 +186,7 @@ void matrix_read_cols_on_row__matrix(matrix_row_t current_matrix[], uint8_t curr // For each col... matrix_row_t row_shifter = MATRIX_ROW_SHIFTER; for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++, row_shifter <<= 1) { - uint8_t pin_state = gpio_read_matrix_pin(col_pins[col_index]); + uint8_t pin_state = readMatrixPin(col_pins[col_index]); // Populate the matrix row with the state of the col pin current_row_value |= pin_state ? 0 : row_shifter; @@ -140,7 +208,7 @@ void matrix_read_cols_on_row__direct(matrix_row_t current_matrix[], uint8_t curr for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++, row_shifter <<= 1) { pin_t pin = direct_pins[current_row][col_index]; if (NO_PIN != pin) { - current_row_value |= gpio_read_matrix_pin(pin) ? 0 : row_shifter; + current_row_value |= readMatrixPin(pin) ? 0 : row_shifter; } } @@ -148,23 +216,24 @@ void matrix_read_cols_on_row__direct(matrix_row_t current_matrix[], uint8_t curr current_matrix[current_row] = current_row_value; } -bool matrix_scan_custom(matrix_row_t current_matrix[]) { - bool matrix_has_changed = false; +uint8_t matrix_scan(void) { + matrix_row_t curr_matrix[MATRIX_ROWS] = {0}; // Matrix keys: Set row, read cols for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { // if the row is a NO_PIN then assume it's on a direct pins matrix, else assume COL2ROW matrix if (NO_PIN != row_pins[current_row]) { - matrix_read_cols_on_row__matrix(current_matrix, current_row); + matrix_read_cols_on_row__matrix(curr_matrix, current_row); } else { - matrix_read_cols_on_row__direct(current_matrix, current_row); + matrix_read_cols_on_row__direct(curr_matrix, current_row); } } - matrix_has_changed = memcmp(raw_matrix, current_matrix, MATRIX_ROWS) != 0; - if (matrix_has_changed) { - memcpy(raw_matrix, current_matrix, MATRIX_ROWS); - } + bool changed = memcmp(raw_matrix, curr_matrix, sizeof(curr_matrix)) != 0; + if (changed) memcpy(raw_matrix, curr_matrix, sizeof(curr_matrix)); - return matrix_has_changed; + changed = debounce(raw_matrix, matrix, MATRIX_ROWS, changed); + matrix_scan_kb(); + + return (uint8_t)changed; } diff --git a/keyboards/binepad/candypad/rules.mk b/keyboards/binepad/candypad/rules.mk index 4879c468ada..faaa32cb5f0 100644 --- a/keyboards/binepad/candypad/rules.mk +++ b/keyboards/binepad/candypad/rules.mk @@ -1,7 +1,7 @@ # Copyright 2023 binepad (@binepad) # SPDX-License-Identifier: GPL-2.0-or-later -CUSTOM_MATRIX = lite +CUSTOM_MATRIX = yes SRC += matrix.c \ candypad_oled.c From b5eb8717c8593f204ccdc08b4c64a9c851437657 Mon Sep 17 00:00:00 2001 From: silvinor <366673+silvinor@users.noreply.github.com> Date: Mon, 12 May 2025 12:15:13 +1000 Subject: [PATCH 07/10] confirmed fixes for lite matrix.c implementation --- keyboards/binepad/candypad/keyboard.json | 38 ++-- .../candypad/keymaps/default/keymap.json | 9 +- keyboards/binepad/candypad/matrix.c | 205 ++++++------------ keyboards/binepad/candypad/rules.mk | 2 +- 4 files changed, 92 insertions(+), 162 deletions(-) diff --git a/keyboards/binepad/candypad/keyboard.json b/keyboards/binepad/candypad/keyboard.json index 42016243af8..4fed86b0aea 100644 --- a/keyboards/binepad/candypad/keyboard.json +++ b/keyboards/binepad/candypad/keyboard.json @@ -32,25 +32,25 @@ "layouts": { "LAYOUT": { "layout": [ - {"label": "Num Lock", "matrix": [0, 0], "x": 0, "y": 1}, - {"label": "/", "matrix": [0, 1], "x": 1, "y": 1}, - {"label": "*", "matrix": [0, 2], "x": 2, "y": 1}, - {"label": "-", "matrix": [0, 3], "x": 3, "y": 1}, - {"label": "7", "matrix": [1, 0], "x": 0, "y": 2}, - {"label": "8", "matrix": [1, 1], "x": 1, "y": 2}, - {"label": "9", "matrix": [1, 2], "x": 2, "y": 2}, - {"label": "+", "matrix": [1, 3], "x": 3, "y": 2, "h": 2}, - {"label": "4", "matrix": [2, 0], "x": 0, "y": 3}, - {"label": "5", "matrix": [2, 1], "x": 1, "y": 3}, - {"label": "6", "matrix": [2, 2], "x": 2, "y": 3}, - {"label": "1", "matrix": [3, 0], "x": 0, "y": 4}, - {"label": "2", "matrix": [3, 1], "x": 1, "y": 4}, - {"label": "3", "matrix": [3, 2], "x": 2, "y": 4}, - {"label": "Enter", "matrix": [3, 3], "x": 3, "y": 4, "h": 2}, - {"label": "0", "matrix": [4, 0], "x": 0, "y": 5, "w": 2}, - {"label": ".", "matrix": [4, 2], "x": 2, "y": 5}, - {"label": "", "matrix": [5, 0], "x": 2, "y": 0}, - {"label": "", "matrix": [5, 1], "x": 3, "y": 0}, + {"label": "Num Lock", "matrix": [0, 0], "x": 0, "y": 1, "hand": "R"}, + {"label": "/", "matrix": [0, 1], "x": 1, "y": 1, "hand": "R"}, + {"label": "*", "matrix": [0, 2], "x": 2, "y": 1, "hand": "R"}, + {"label": "-", "matrix": [0, 3], "x": 3, "y": 1, "hand": "R"}, + {"label": "7", "matrix": [1, 0], "x": 0, "y": 2, "hand": "R"}, + {"label": "8", "matrix": [1, 1], "x": 1, "y": 2, "hand": "R"}, + {"label": "9", "matrix": [1, 2], "x": 2, "y": 2, "hand": "R"}, + {"label": "+", "matrix": [1, 3], "x": 3, "y": 2, "h": 2, "hand": "R"}, + {"label": "4", "matrix": [2, 0], "x": 0, "y": 3, "hand": "R"}, + {"label": "5", "matrix": [2, 1], "x": 1, "y": 3, "hand": "R"}, + {"label": "6", "matrix": [2, 2], "x": 2, "y": 3, "hand": "R"}, + {"label": "1", "matrix": [3, 0], "x": 0, "y": 4, "hand": "R"}, + {"label": "2", "matrix": [3, 1], "x": 1, "y": 4, "hand": "R"}, + {"label": "3", "matrix": [3, 2], "x": 2, "y": 4, "hand": "R"}, + {"label": "Enter", "matrix": [3, 3], "x": 3, "y": 4, "h": 2, "hand": "R"}, + {"label": "0", "matrix": [4, 0], "x": 0, "y": 5, "w": 2, "hand": "R"}, + {"label": ".", "matrix": [4, 2], "x": 2, "y": 5, "hand": "R"}, + {"label": "", "matrix": [5, 0], "x": 2, "y": 0, "hand": "L"}, + {"label": "", "matrix": [5, 1], "x": 3, "y": 0, "hand": "L"}, ] } } diff --git a/keyboards/binepad/candypad/keymaps/default/keymap.json b/keyboards/binepad/candypad/keymaps/default/keymap.json index d235bb4d84f..e4c7f66b6f1 100644 --- a/keyboards/binepad/candypad/keymaps/default/keymap.json +++ b/keyboards/binepad/candypad/keymaps/default/keymap.json @@ -19,7 +19,14 @@ "keyboard": "binepad/candypad", "keymap": "default", "layers": [ - ["KC_NUM", "KC_PSLS", "KC_PAST", "KC_PMNS", "KC_P7", "KC_P8", "KC_P9", "KC_PPLS", "KC_P4", "KC_P5", "KC_P6", "KC_P1", "KC_P2", "KC_P3", "KC_PENT", "KC_P0", "KC_PDOT", "MO(1)", "KC_MUTE"] + [ + "KC_NUM", "KC_PSLS", "KC_PAST", "KC_PMNS", + "KC_P7", "KC_P8", "KC_P9", "KC_PPLS", + "KC_P4", "KC_P5", "KC_P6", + "KC_P1", "KC_P2", "KC_P3", "KC_PENT", + "KC_P0", "KC_PDOT", + "MO(1)", "KC_MUTE" + ] ], "layout": "LAYOUT", "version": 1 diff --git a/keyboards/binepad/candypad/matrix.c b/keyboards/binepad/candypad/matrix.c index 5933809ddb8..2670dfeca42 100644 --- a/keyboards/binepad/candypad/matrix.c +++ b/keyboards/binepad/candypad/matrix.c @@ -7,103 +7,48 @@ * it assumes the matrix is always COL2ROW and that the KB has BOTH * matrix and direct pins. - * For direct pins define + * For direct pins define: * `DIRECT_PINS_CUSTOM` - * This stucture must exactly match the MATRIX_ROWS / MATRIX_COLS matrix. + * This stucture must match exactly the MATRIX_ROWS / MATRIX_COLS matrix. * * NB!!: The ROW that supports direct pins **must** have the row set * to NO_PIN in the matrix array. */ +#include "quantum.h" #include "matrix.h" -#include "debounce.h" #include "atomic_util.h" -#include -#include "wait.h" -#include "print.h" -#ifndef DEBOUNCE -# define DEBOUNCE 5 -#endif +// ---------- Interal defs and vars ---------- #ifndef MATRIX_INPUT_PRESSED_STATE # define MATRIX_INPUT_PRESSED_STATE 0 #endif -#ifndef MATRIX_IO_DELAY -# define MATRIX_IO_DELAY 30 -#endif - -static pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; -static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; - -// define DIRECT_PINS_CUSTOM in `config.h` -// ** NB: ** must match the MATRIX_ROWS / MATRIX_COLS matrix structure +static pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; +static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; static pin_t direct_pins[MATRIX_ROWS][MATRIX_COLS] = DIRECT_PINS_CUSTOM; -/* matrix state(1:on, 0:off) */ -matrix_row_t raw_matrix[MATRIX_ROWS]; -matrix_row_t matrix[MATRIX_ROWS]; +// ---------- Interal functions ---------- +// .......... Helpers .......... -__attribute__((weak)) void matrix_init_user(void) {} - -__attribute__((weak)) void matrix_init_kb(void) { - matrix_init_user(); -} - -__attribute__((weak)) void matrix_scan_user(void) {} - -__attribute__((weak)) void matrix_scan_kb(void) { - matrix_scan_user(); -} - -#define print_matrix_header() print("\nr/c 01234567\n") -#define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) - -__attribute__((weak)) void matrix_output_select_delay(void) { - waitInputPinDelay(); -} - -__attribute__((weak)) void matrix_output_unselect_delay(uint8_t line, bool key_pressed) { - wait_us(MATRIX_IO_DELAY); -} - -static inline void setPinOutput_writeLow(pin_t pin) { +static inline void gpio_atomic_set_pin_output_low(pin_t pin) { ATOMIC_BLOCK_FORCEON { - setPinOutput(pin); - writePinLow(pin); + gpio_set_pin_output(pin); + gpio_write_pin_low(pin); } } -static inline void setPinInputHigh_atomic(pin_t pin) { +static inline void gpio_atomic_set_pin_input_high(pin_t pin) { ATOMIC_BLOCK_FORCEON { - setPinInputHigh(pin); - } -} - -static inline uint8_t readMatrixPin(pin_t pin) { - if (pin != NO_PIN) { - return (readPin(pin) == MATRIX_INPUT_PRESSED_STATE) ? 0 : 1; - } else { - return 1; - } -} - -void matrix_print(void) { - print_matrix_header(); - - for (uint8_t row = 0; row < MATRIX_ROWS; row++) { - print_hex8(row); - print(": "); - print_matrix_row(row); - print("\n"); + gpio_set_pin_input_high(pin); } } static bool select_row(uint8_t row) { pin_t pin = row_pins[row]; if (pin != NO_PIN) { - setPinOutput_writeLow(pin); + gpio_atomic_set_pin_output_low(pin); return true; } return false; @@ -112,7 +57,7 @@ static bool select_row(uint8_t row) { static void unselect_row(uint8_t row) { pin_t pin = row_pins[row]; if (pin != NO_PIN) { - setPinInputHigh_atomic(pin); + gpio_atomic_set_pin_input_high(pin); } } @@ -122,118 +67,96 @@ static void unselect_rows(void) { } } -void matrix_init_pins__matrix(void) { +// .......... Inits .......... + +void matrix_init_matrix_pins(void) { unselect_rows(); for (uint8_t x = 0; x < MATRIX_COLS; x++) { if (col_pins[x] != NO_PIN) { - setPinInputHigh_atomic(col_pins[x]); + gpio_atomic_set_pin_input_high(col_pins[x]); } } } -void matrix_init_pins__direct(void) { +void matrix_init_direct_pins(void) { for (int row = 0; row < MATRIX_ROWS; row++) { for (int col = 0; col < MATRIX_COLS; col++) { pin_t pin = direct_pins[row][col]; if (pin != NO_PIN) { - setPinInputHigh(pin); + gpio_atomic_set_pin_input_high(pin); } } } } -inline uint8_t matrix_rows(void) { - return MATRIX_ROWS; +// .......... Scanners .......... + +static inline uint8_t readMatrixPin(pin_t pin) { + if (pin != NO_PIN) { + return (gpio_read_pin(pin) == MATRIX_INPUT_PRESSED_STATE) ? 0 : 1; + } else { + return 1; + } } -inline uint8_t matrix_cols(void) { - return MATRIX_COLS; -} +void matrix_scan_matrix_row(matrix_row_t row_buffer[], uint8_t row_to_scan) { + matrix_row_t scan_row_value = 0; -void matrix_init(void) { - // initialize key pins - matrix_init_pins__matrix(); - matrix_init_pins__direct(); - - // initialize matrix state: all keys off - memset(raw_matrix, 0, sizeof(raw_matrix)); - memset(matrix, 0, sizeof(matrix)); - - // Unless hardware debouncing - Init the configured debounce routine - debounce_init(MATRIX_ROWS); - - // This *must* be called for correct keyboard behavior - matrix_init_kb(); -} - -inline bool matrix_is_on(uint8_t row, uint8_t col) { - return (matrix[row] & ((matrix_row_t)1 << col)); -} - -inline matrix_row_t matrix_get_row(uint8_t row) { - return matrix[row]; -} - -void matrix_read_cols_on_row__matrix(matrix_row_t current_matrix[], uint8_t current_row) { - // Start with a clear matrix row - matrix_row_t current_row_value = 0; - - if (!select_row(current_row)) { // Select row - return; // skip NO_PIN row + if (!select_row(row_to_scan)) { + return; } matrix_output_select_delay(); - // For each col... matrix_row_t row_shifter = MATRIX_ROW_SHIFTER; - for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++, row_shifter <<= 1) { - uint8_t pin_state = readMatrixPin(col_pins[col_index]); + for (uint8_t col_to_scan = 0; col_to_scan < MATRIX_COLS; col_to_scan++, row_shifter <<= 1) { + uint8_t pin_state = readMatrixPin(col_pins[col_to_scan]); // Populate the matrix row with the state of the col pin - current_row_value |= pin_state ? 0 : row_shifter; + scan_row_value |= pin_state ? 0 : row_shifter; } - // Unselect row - unselect_row(current_row); - matrix_output_unselect_delay(current_row, current_row_value != 0); // wait for all Col signals to go HIGH + unselect_row(row_to_scan); + matrix_output_unselect_delay(row_to_scan, scan_row_value != 0); - // Update the matrix - current_matrix[current_row] = current_row_value; + row_buffer[row_to_scan] = scan_row_value; } -void matrix_read_cols_on_row__direct(matrix_row_t current_matrix[], uint8_t current_row) { - // Start with a clear matrix row - matrix_row_t current_row_value = 0; +void matrix_scan_direct_row(matrix_row_t row_buffer[], uint8_t row_to_scan) { + matrix_row_t scan_row_value = 0; matrix_row_t row_shifter = MATRIX_ROW_SHIFTER; - for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++, row_shifter <<= 1) { - pin_t pin = direct_pins[current_row][col_index]; - if (NO_PIN != pin) { - current_row_value |= readMatrixPin(pin) ? 0 : row_shifter; + for (uint8_t col_to_scan = 0; col_to_scan < MATRIX_COLS; col_to_scan++, row_shifter <<= 1) { + pin_t pin = direct_pins[row_to_scan][col_to_scan]; + if (pin != NO_PIN) { + scan_row_value |= readMatrixPin(pin) ? 0 : row_shifter; } } - // Update the matrix - current_matrix[current_row] = current_row_value; + row_buffer[row_to_scan] = scan_row_value; } -uint8_t matrix_scan(void) { - matrix_row_t curr_matrix[MATRIX_ROWS] = {0}; +// ========== Core functions required by lite matrix driver ========== - // Matrix keys: Set row, read cols - for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { +void matrix_init_custom(void) { + matrix_init_matrix_pins(); + matrix_init_direct_pins(); +} + +bool matrix_scan_custom(matrix_row_t current_matrix[]) { + matrix_row_t buff_matrix[MATRIX_ROWS] = {0}; + + for (uint8_t scan_row = 0; scan_row < MATRIX_ROWS; scan_row++) { // if the row is a NO_PIN then assume it's on a direct pins matrix, else assume COL2ROW matrix - if (NO_PIN != row_pins[current_row]) { - matrix_read_cols_on_row__matrix(curr_matrix, current_row); + if (row_pins[scan_row] == NO_PIN) { + matrix_scan_direct_row(buff_matrix, scan_row); } else { - matrix_read_cols_on_row__direct(curr_matrix, current_row); + matrix_scan_matrix_row(buff_matrix, scan_row); } } - bool changed = memcmp(raw_matrix, curr_matrix, sizeof(curr_matrix)) != 0; - if (changed) memcpy(raw_matrix, curr_matrix, sizeof(curr_matrix)); - - changed = debounce(raw_matrix, matrix, MATRIX_ROWS, changed); - matrix_scan_kb(); - - return (uint8_t)changed; + bool matrix_has_changed = memcmp(current_matrix, buff_matrix, sizeof(buff_matrix)) != 0; + if (matrix_has_changed) { + memcpy(current_matrix, buff_matrix, sizeof(buff_matrix)); + } + return matrix_has_changed; } diff --git a/keyboards/binepad/candypad/rules.mk b/keyboards/binepad/candypad/rules.mk index faaa32cb5f0..4879c468ada 100644 --- a/keyboards/binepad/candypad/rules.mk +++ b/keyboards/binepad/candypad/rules.mk @@ -1,7 +1,7 @@ # Copyright 2023 binepad (@binepad) # SPDX-License-Identifier: GPL-2.0-or-later -CUSTOM_MATRIX = yes +CUSTOM_MATRIX = lite SRC += matrix.c \ candypad_oled.c From 1d00dfc5d9e5fe25bff9a70d525e81d4b89bbbe5 Mon Sep 17 00:00:00 2001 From: "Silvino R." <366673+silvinor@users.noreply.github.com> Date: Tue, 13 May 2025 10:52:17 +1000 Subject: [PATCH 08/10] Apply suggestions from code review post @zvecr suggestions Co-authored-by: Joel Challis --- keyboards/binepad/candypad/keyboard.json | 38 +++++++++---------- .../candypad/keymaps/default/keymap.json | 4 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/keyboards/binepad/candypad/keyboard.json b/keyboards/binepad/candypad/keyboard.json index 4fed86b0aea..c4e379e250a 100644 --- a/keyboards/binepad/candypad/keyboard.json +++ b/keyboards/binepad/candypad/keyboard.json @@ -32,25 +32,25 @@ "layouts": { "LAYOUT": { "layout": [ - {"label": "Num Lock", "matrix": [0, 0], "x": 0, "y": 1, "hand": "R"}, - {"label": "/", "matrix": [0, 1], "x": 1, "y": 1, "hand": "R"}, - {"label": "*", "matrix": [0, 2], "x": 2, "y": 1, "hand": "R"}, - {"label": "-", "matrix": [0, 3], "x": 3, "y": 1, "hand": "R"}, - {"label": "7", "matrix": [1, 0], "x": 0, "y": 2, "hand": "R"}, - {"label": "8", "matrix": [1, 1], "x": 1, "y": 2, "hand": "R"}, - {"label": "9", "matrix": [1, 2], "x": 2, "y": 2, "hand": "R"}, - {"label": "+", "matrix": [1, 3], "x": 3, "y": 2, "h": 2, "hand": "R"}, - {"label": "4", "matrix": [2, 0], "x": 0, "y": 3, "hand": "R"}, - {"label": "5", "matrix": [2, 1], "x": 1, "y": 3, "hand": "R"}, - {"label": "6", "matrix": [2, 2], "x": 2, "y": 3, "hand": "R"}, - {"label": "1", "matrix": [3, 0], "x": 0, "y": 4, "hand": "R"}, - {"label": "2", "matrix": [3, 1], "x": 1, "y": 4, "hand": "R"}, - {"label": "3", "matrix": [3, 2], "x": 2, "y": 4, "hand": "R"}, - {"label": "Enter", "matrix": [3, 3], "x": 3, "y": 4, "h": 2, "hand": "R"}, - {"label": "0", "matrix": [4, 0], "x": 0, "y": 5, "w": 2, "hand": "R"}, - {"label": ".", "matrix": [4, 2], "x": 2, "y": 5, "hand": "R"}, - {"label": "", "matrix": [5, 0], "x": 2, "y": 0, "hand": "L"}, - {"label": "", "matrix": [5, 1], "x": 3, "y": 0, "hand": "L"}, + {"matrix": [5, 0], "x": 2, "y": 0, "encoder":0}, + {"matrix": [5, 1], "x": 3, "y": 0, "encoder":1}, + {"label": "Num Lock", "matrix": [0, 0], "x": 0, "y": 1}, + {"label": "/", "matrix": [0, 1], "x": 1, "y": 1}, + {"label": "*", "matrix": [0, 2], "x": 2, "y": 1}, + {"label": "-", "matrix": [0, 3], "x": 3, "y": 1}, + {"label": "7", "matrix": [1, 0], "x": 0, "y": 2}, + {"label": "8", "matrix": [1, 1], "x": 1, "y": 2}, + {"label": "9", "matrix": [1, 2], "x": 2, "y": 2}, + {"label": "+", "matrix": [1, 3], "x": 3, "y": 2, "h": 2}, + {"label": "4", "matrix": [2, 0], "x": 0, "y": 3}, + {"label": "5", "matrix": [2, 1], "x": 1, "y": 3}, + {"label": "6", "matrix": [2, 2], "x": 2, "y": 3}, + {"label": "1", "matrix": [3, 0], "x": 0, "y": 4}, + {"label": "2", "matrix": [3, 1], "x": 1, "y": 4}, + {"label": "3", "matrix": [3, 2], "x": 2, "y": 4}, + {"label": "Enter", "matrix": [3, 3], "x": 3, "y": 4, "h": 2}, + {"label": "0", "matrix": [4, 0], "x": 0, "y": 5, "w": 2}, + {"label": ".", "matrix": [4, 2], "x": 2, "y": 5} ] } } diff --git a/keyboards/binepad/candypad/keymaps/default/keymap.json b/keyboards/binepad/candypad/keymaps/default/keymap.json index e4c7f66b6f1..adbbbb35795 100644 --- a/keyboards/binepad/candypad/keymaps/default/keymap.json +++ b/keyboards/binepad/candypad/keymaps/default/keymap.json @@ -20,12 +20,12 @@ "keymap": "default", "layers": [ [ + "MO(1)", "KC_MUTE", "KC_NUM", "KC_PSLS", "KC_PAST", "KC_PMNS", "KC_P7", "KC_P8", "KC_P9", "KC_PPLS", "KC_P4", "KC_P5", "KC_P6", "KC_P1", "KC_P2", "KC_P3", "KC_PENT", - "KC_P0", "KC_PDOT", - "MO(1)", "KC_MUTE" + "KC_P0", "KC_PDOT" ] ], "layout": "LAYOUT", From 0774cb31aa832f5e9dd3df1c70deb53b7a6c658a Mon Sep 17 00:00:00 2001 From: silvinor <366673+silvinor@users.noreply.github.com> Date: Mon, 2 Jun 2025 15:44:14 +1000 Subject: [PATCH 09/10] post 2nd @drashna review --- keyboards/binepad/candypad/candypad.c | 33 ----- keyboards/binepad/candypad/candypad.h | 33 ----- keyboards/binepad/candypad/candypad_oled.c | 63 +-------- keyboards/binepad/candypad/config.h | 6 +- keyboards/binepad/candypad/glcdfont.c | 142 --------------------- 5 files changed, 7 insertions(+), 270 deletions(-) delete mode 100644 keyboards/binepad/candypad/candypad.c delete mode 100644 keyboards/binepad/candypad/candypad.h delete mode 100644 keyboards/binepad/candypad/glcdfont.c diff --git a/keyboards/binepad/candypad/candypad.c b/keyboards/binepad/candypad/candypad.c deleted file mode 100644 index 7362385d3ab..00000000000 --- a/keyboards/binepad/candypad/candypad.c +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 binepad (@binepad) -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "candypad.h" - -#ifdef OLED_ENABLE - -// OLED functions -uint8_t oled_mode = OLED_SPLASH; -bool oled_repaint_requested = false; -uint32_t oled_splash_timer = 0; - -void housekeeping_task_kb(void) { - if (0 != oled_splash_timer) { - if (timer_elapsed(oled_splash_timer) > OLED_SPLASH_TIMEOUT) { - switch (oled_mode) { - case OLED_SPLASH: - default: - oled_mode = OLED_DEFAULT; - oled_splash_timer = 0; // disable - break; - } - oled_repaint_requested = true; - } - } -} - -void suspend_wakeup_init_kb(void) { - oled_on(); - suspend_wakeup_init_user(); -} - -#endif // OLED_ENABLE diff --git a/keyboards/binepad/candypad/candypad.h b/keyboards/binepad/candypad/candypad.h deleted file mode 100644 index e4259e8726d..00000000000 --- a/keyboards/binepad/candypad/candypad.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 binepad (@binepad) -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "quantum.h" - -#ifdef OLED_ENABLE - -# ifndef OLED_SPLASH_TIMEOUT -# define OLED_SPLASH_TIMEOUT 2500 -# endif - -// clang-format off -enum oled_modes { - OLED_SPLASH, - OLED_DEFAULT, - OLED_OFF, - __NUM_OLED_MODES -} oled_modes_t; -// clang-format on - -bool candypad_render_logo_user(void); -bool candypad_render_logo_kb(void); -bool candypad_render_default_user(void); -bool candypad_render_default_kb(void); - -// OLED functions -extern uint8_t oled_mode; -extern bool oled_repaint_requested; -extern uint32_t oled_splash_timer; - -#endif diff --git a/keyboards/binepad/candypad/candypad_oled.c b/keyboards/binepad/candypad/candypad_oled.c index e88ea747e81..fa4f450023e 100644 --- a/keyboards/binepad/candypad/candypad_oled.c +++ b/keyboards/binepad/candypad/candypad_oled.c @@ -3,40 +3,11 @@ // Portions of this code are based on [Andrew Kannan](https://github.com/awkannan1)'s // work on the Satisfaction75 -#include "candypad.h" +#include "quantum.h" #include "keymap_introspection.h" #ifdef OLED_ENABLE -/* CandyPad Logo */ -static void __candypad_render_logo_default(void) { - // Generated from https://joric.github.io/qle/ - static const char PROGMEM raw_logo[] = { - 0, 0, 0, 0, 128, 192, 224, 96, 240, 240, 152, 24, 24, 24, 24, 24, 24, 24, 24, 56, 48, 96, 224, 192, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 0, 0, 192, 248, 62, 7, 15, 28, 56, 112, 225, 195, 135, 14, 28, 56, 112, 224, 192, 128, 0, 0, 0, 0, 1, 7, 62, 252, 192, 0, 128, 192, 224, 112, 48, 48, 48, 112, 96, 0, 128, 192, 224, 96, - 48, 48, 48, 112, 224, 240, 240, 0, 0, 240, 240, 96, 112, 48, 48, 48, 112, 224, 192, 128, 0, 0, 128, 192, 224, 112, 48, 48, 48, 112, 224, 255, 255, 0, 48, 112, 224, 128, 0, 0, 0, 0, 128, 224, 112, 48, 0, 240, 240, 224, 112, 48, 48, 48, 112, 224, 192, 128, 0, 0, 128, 192, 224, 96, 48, 48, 48, 112, 224, 240, 240, 0, 0, 128, 192, 224, 112, 48, 48, 48, 112, 224, 255, 255, 0, 0, 3, 31, 124, 224, 192, 0, 0, 0, 0, 1, 3, 7, 14, 28, 56, 112, 225, 195, 135, 14, 28, 56, 240, 224, 124, 63, 3, 0, 15, 31, 56, 112, 96, 96, 96, 112, 48, 0, 15, 31, 56, 112, 96, 96, 96, 112, 56, 127, 127, 0, 0, 127, 127, 0, 0, 0, 0, 0, 0, 1, 127, 127, 0, 0, 15, 31, 56, 112, 96, 96, 96, 112, 56, 127, 127, 0, 0, 0, 3, 15, 62, 240, 248, 62, 15, - 3, 0, 0, 0, 255, 255, 56, 112, 96, 96, 96, 112, 56, 31, 15, 0, 0, 15, 31, 56, 112, 96, 96, 96, 112, 56, 127, 127, 0, 0, 15, 63, 56, 112, 96, 96, 96, 112, 56, 127, 127, 0, 0, 0, 0, 0, 1, 3, 7, 6, 14, 12, 24, 24, 24, 24, 24, 24, 24, 24, 25, 15, 15, 6, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 31, 7, 1, 0, 0, 0, 0, 0, 0, 31, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - }; - oled_write_raw_P(raw_logo, sizeof(raw_logo)); -} - -// Weak so that user keymaps can make their own -__attribute__((weak)) bool candypad_render_logo_user(void) { - return false; // Return true if your user keymap renders its own -} - -__attribute__((weak)) bool candypad_render_logo_kb(void) { - if (!candypad_render_logo_user()) { - __candypad_render_logo_default(); - } - return true; -} - -oled_rotation_t oled_init_kb(oled_rotation_t rotation) { - oled_mode = OLED_SPLASH; - oled_splash_timer = sync_timer_read(); - return rotation; -} - static char *get_enc_mode(uint8_t encoder) { # ifdef ENCODER_MAP_ENABLE @@ -206,38 +177,16 @@ __attribute__((weak)) bool candypad_render_default_kb(void) { return true; // Was handled here } +void oled_request_repaint(void) { + oled_clear(); +} + bool oled_task_kb(void) { if (!oled_task_user()) { return false; } - // if (!oled_task_needs_to_repaint()) { return false; } - /* !! : oled_clear(); // Is broken !!! */ - if (oled_repaint_requested) { - oled_repaint_requested = false; - oled_clear(); - return false; - } - - switch (oled_mode) { - case OLED_OFF: - // Do nothing - // This PCB has no digital switch to power off the OLED :( - break; - - case OLED_SPLASH: - if (candypad_render_logo_kb()) { - break; - } else { - oled_mode = OLED_DEFAULT; - // don't break - let the default draw - } - - case OLED_DEFAULT: - default: - candypad_render_default_kb(); - break; - } + candypad_render_default_kb(); return false; } diff --git a/keyboards/binepad/candypad/config.h b/keyboards/binepad/candypad/config.h index 20c0c88abcf..eefc84cd924 100644 --- a/keyboards/binepad/candypad/config.h +++ b/keyboards/binepad/candypad/config.h @@ -14,12 +14,8 @@ # define I2C_DRIVER I2CD1 /* Configure oled driver for the 128x32 oled */ -# define OLED_TIMEOUT (15 * 60 * 1000) // 15 minutes +# define OLED_TIMEOUT (2 * 60 * 1000) // 2 minutes # define OLED_UPDATE_INTERVAL 33 // ~30fps - -/* Font */ -# define OLED_FONT_H "keyboards/binepad/candypad/glcdfont.c" -# define OLED_FONT_END 127 #endif // OLED_ENABLE /* ---- Direct pins, for use in (custom) `matrix.c` (please read that file) ----- */ diff --git a/keyboards/binepad/candypad/glcdfont.c b/keyboards/binepad/candypad/glcdfont.c deleted file mode 100644 index aa6588df260..00000000000 --- a/keyboards/binepad/candypad/glcdfont.c +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright 2023 binepad (@binepad) -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "progmem.h" - -/* based on https://lexus2k.github.io/ssd1306/ssd1306__fonts_8c_source.html, chars 32 - 127 */ -/* generated and tested on https://joric.github.io/qle/ */ -// clang-format off -static const unsigned char PROGMEM font[] = { - 0xFF, 0x81, 0x81, 0x81, 0xFF, 0x00, - 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, - 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00, - 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, - 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00, - 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00, - 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, - 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00, - 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, - 0x00, 0x18, 0x24, 0x18, 0x00, 0x00, - 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00, - 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00, - 0x26, 0x29, 0x79, 0x29, 0x26, 0x00, - 0x40, 0x7F, 0x05, 0x05, 0x07, 0x00, - 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00, - 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00, - 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00, - 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00, - 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00, - 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00, - 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, - 0x00, 0x66, 0x89, 0x95, 0x6A, 0x00, - 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, - 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00, - 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00, - 0x10, 0x20, 0x7E, 0x20, 0x10, 0x00, - 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, - 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00, - 0x1E, 0x10, 0x10, 0x10, 0x10, 0x00, - 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00, - 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00, - 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, - - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // sp - 0x00, 0x00, 0x2F, 0x00, 0x00, 0x00, - 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, - 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, - 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, - 0x23, 0x13, 0x08, 0x64, 0x62, 0x00, - 0x36, 0x49, 0x55, 0x22, 0x50, 0x00, - 0x00, 0x05, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, - 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00, - 0x14, 0x08, 0x3E, 0x08, 0x14, 0x00, - 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, - 0x00, 0x00, 0xA0, 0x60, 0x00, 0x00, - 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, - 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, - 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, - 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, - 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, - 0x42, 0x61, 0x51, 0x49, 0x46, 0x00, - 0x21, 0x41, 0x45, 0x4B, 0x31, 0x00, - 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, - 0x27, 0x45, 0x45, 0x45, 0x39, 0x00, - 0x3C, 0x4A, 0x49, 0x49, 0x30, 0x00, - 0x01, 0x71, 0x09, 0x05, 0x03, 0x00, - 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, - 0x06, 0x49, 0x49, 0x29, 0x1E, 0x00, - 0x00, 0x36, 0x36, 0x00, 0x00, 0x00, - 0x00, 0x56, 0x36, 0x00, 0x00, 0x00, - 0x08, 0x14, 0x22, 0x41, 0x00, 0x00, - 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, - 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, - 0x02, 0x01, 0x51, 0x09, 0x06, 0x00, - - 0x32, 0x49, 0x59, 0x51, 0x3E, 0x00, - 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00, - 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, - 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, - 0x7F, 0x41, 0x41, 0x22, 0x1C, 0x00, - 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, - 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, - 0x3E, 0x41, 0x49, 0x49, 0x7A, 0x00, - 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, - 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, - 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00, - 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, - 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, - 0x7F, 0x02, 0x0C, 0x02, 0x7F, 0x00, - 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, - 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, - 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, - 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, - 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, - 0x46, 0x49, 0x49, 0x49, 0x31, 0x00, - 0x01, 0x01, 0x7F, 0x01, 0x01, 0x00, - 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, - 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, - 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, - 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, - 0x07, 0x08, 0x70, 0x08, 0x07, 0x00, - 0x61, 0x51, 0x49, 0x45, 0x43, 0x00, - 0x00, 0x7F, 0x41, 0x41, 0x00, 0x00, - 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, - 0x00, 0x41, 0x41, 0x7F, 0x00, 0x00, - 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, - 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, - - 0x00, 0x01, 0x02, 0x04, 0x00, 0x00, - 0x20, 0x54, 0x54, 0x54, 0x78, 0x00, - 0x7F, 0x48, 0x44, 0x44, 0x38, 0x00, - 0x38, 0x44, 0x44, 0x44, 0x20, 0x00, - 0x38, 0x44, 0x44, 0x48, 0x7F, 0x00, - 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, - 0x08, 0x7E, 0x09, 0x01, 0x02, 0x00, - 0x18, 0xA4, 0xA4, 0xA4, 0x7C, 0x00, - 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, - 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00, - 0x40, 0x80, 0x84, 0x7D, 0x00, 0x00, - 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, - 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, - 0x7C, 0x04, 0x18, 0x04, 0x78, 0x00, - 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00, - 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, - 0xFC, 0x24, 0x24, 0x24, 0x18, 0x00, - 0x18, 0x24, 0x24, 0x18, 0xFC, 0x00, - 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, - 0x48, 0x54, 0x54, 0x54, 0x20, 0x00, - 0x04, 0x3F, 0x44, 0x40, 0x20, 0x00, - 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, - 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, - 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, - 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, - 0x1C, 0xA0, 0xA0, 0xA0, 0x7C, 0x00, - 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, - 0x00, 0x00, 0x08, 0x77, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, - 0x00, 0x00, 0x77, 0x08, 0x00, 0x00, - 0x00, 0x10, 0x08, 0x10, 0x08, 0x00, - 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA -}; -// clang-format on From 47789c4229d2d887e3f63e35ddf635b4251dd7a5 Mon Sep 17 00:00:00 2001 From: silvinor <366673+silvinor@users.noreply.github.com> Date: Sun, 6 Jul 2025 08:32:56 +1000 Subject: [PATCH 10/10] post drashna and zvecr review --- keyboards/binepad/candypad/keyboard.json | 2 ++ keyboards/binepad/candypad/rules.mk | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/keyboards/binepad/candypad/keyboard.json b/keyboards/binepad/candypad/keyboard.json index c4e379e250a..76cfeeb5c9d 100644 --- a/keyboards/binepad/candypad/keyboard.json +++ b/keyboards/binepad/candypad/keyboard.json @@ -19,6 +19,8 @@ "oled": true }, "matrix_pins": { + "custom": true, + "custom_lite": true, "cols": ["GP15", "GP14", "GP13", "GP10"], "rows": ["GP12", "GP9", "GP7", "GP6", "GP5", null] }, diff --git a/keyboards/binepad/candypad/rules.mk b/keyboards/binepad/candypad/rules.mk index 4879c468ada..a7b061422de 100644 --- a/keyboards/binepad/candypad/rules.mk +++ b/keyboards/binepad/candypad/rules.mk @@ -1,7 +1,5 @@ # Copyright 2023 binepad (@binepad) # SPDX-License-Identifier: GPL-2.0-or-later -CUSTOM_MATRIX = lite - SRC += matrix.c \ candypad_oled.c