diff --git a/keyboards/handwired/set_st/rp2040/config.h b/keyboards/handwired/set_st/rp2040/config.h new file mode 100644 index 00000000000..983424ba7a3 --- /dev/null +++ b/keyboards/handwired/set_st/rp2040/config.h @@ -0,0 +1,30 @@ +/* Copyright 2022 Jose Pablo Ramirez + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#define OLED_DISPLAY_128X64 +#define OLED_COLUMN_OFFSET 0 +#define USE_I2C +#define I2C_DRIVER I2CD1 +#define I2C1_SDA_PIN GP26 +#define I2C1_SCL_PIN GP27 +#define SSD1306_I2C_ADDRESS 0x3c + +/* Double tap the side button to enter bootloader */ +#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET +#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_LED GP13 +#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_TIMEOUT 500U \ No newline at end of file diff --git a/keyboards/handwired/set_st/rp2040/halconf.h b/keyboards/handwired/set_st/rp2040/halconf.h new file mode 100644 index 00000000000..d63462a7825 --- /dev/null +++ b/keyboards/handwired/set_st/rp2040/halconf.h @@ -0,0 +1,22 @@ +/* Copyright 2022 Jose Pablo Ramirez + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include_next + +#undef STM32_I2C_USE_I2C2 +#define STM32_I2C_USE_I2C2 TRUE \ No newline at end of file diff --git a/keyboards/handwired/set_st/rp2040/info.json b/keyboards/handwired/set_st/rp2040/info.json new file mode 100644 index 00000000000..039e2c4441e --- /dev/null +++ b/keyboards/handwired/set_st/rp2040/info.json @@ -0,0 +1,124 @@ +{ + "keyboard_name": "Macropad 10", + "manufacturer": "PDAINUA", + "url": "https://pda.in.ua", + "maintainer": "set-st", + "features": { + "bootmagic": true, + "command": false, + "console": false, + "extrakey": true, + "mousekey": true, + "nkro": true, + "encoder": true, + "rgb_matrix": true, + "oled": true, + "os_detection": true + }, + "usb": { + "vid": "0x20A0", + "pid": "0x42F9", + "device_version": "0.0.2" + }, + "encoder": { + "rotary": [ + {"pin_a": "GP11", "pin_b": "GP12"} + ] + }, + "rgb_matrix": { + "driver": "ws2812", + "animations": { + "alphas_mods": true, + "gradient_up_down": true, + "gradient_left_right": true, + "breathing": true, + "band_sat": true, + "band_val": true, + "band_pinwheel_sat": true, + "band_pinwheel_val": true, + "band_spiral_sat": true, + "band_spiral_val": true, + "cycle_all": true, + "cycle_left_right": true, + "cycle_up_down": true, + "rainbow_moving_chevron": true, + "cycle_out_in": true, + "cycle_out_in_dual": true, + "cycle_pinwheel": true, + "cycle_spiral": true, + "dual_beacon": true, + "rainbow_beacon": true, + "rainbow_pinwheels": true, + "flower_blooming": true, + "raindrops": true, + "jellybean_raindrops": true, + "hue_breathing": true, + "hue_pendulum": true, + "hue_wave": true, + "pixel_fractal": true, + "pixel_flow": true, + "pixel_rain": true, + "typing_heatmap": true, + "digital_rain": true, + "solid_reactive_simple": true, + "solid_reactive": true, + "solid_reactive_wide": true, + "solid_reactive_multiwide": true, + "solid_reactive_cross": true, + "solid_reactive_multicross": true, + "solid_reactive_nexus": true, + "solid_reactive_multinexus": true, + "splash": true, + "multisplash": true, + "solid_splash": true, + "solid_multisplash": true + }, + "react_on_keyup": true, + "timeout": 360000, + "layout": [ + {"matrix": [1, 0], "x": 1, "y": 0, "flags": 2}, + {"matrix": [1, 1], "x": 1, "y": 1, "flags": 2}, + {"matrix": [1, 2], "x": 1, "y": 2, "flags": 2}, + {"matrix": [1, 3], "x": 1, "y": 3, "flags": 2}, + {"matrix": [1, 4], "x": 1, "y": 4, "flags": 2}, + {"matrix": [2, 4], "x": 2, "y": 4, "flags": 2}, + {"matrix": [2, 3], "x": 2, "y": 3, "flags": 2}, + {"matrix": [2, 2], "x": 2, "y": 2, "flags": 2}, + {"matrix": [2, 1], "x": 2, "y": 1, "flags": 2}, + {"matrix": [2, 0], "x": 2, "y": 0, "flags": 2} + ] + }, + "bootmagic": { + "matrix": [1, 2] + }, + "ws2812": { + "pin": "GP13", + "driver": "vendor" + }, + "processor": "RP2040", + "bootloader": "rp2040", + "matrix_pins": { + "direct": [ + [null, null, null, "GP0", null], + ["GP1", "GP2", "GP3","GP4", "GP5"], + ["GP6","GP7", "GP8", "GP9", "GP10"] + ] + }, + "layouts": { + "LAYOUT": { + "layout": [ + {"x": 3, "y": 0, "matrix": [0, 3]}, + {"x": 0, "y": 1, "matrix": [1, 0]}, + {"x": 1, "y": 1, "matrix": [1, 1]}, + {"x": 2, "y": 1, "matrix": [1, 2]}, + {"x": 3, "y": 1, "matrix": [1, 3]}, + {"x": 4, "y": 1, "matrix": [1, 4]}, + {"x": 0, "y": 2, "matrix": [2, 0]}, + {"x": 1, "y": 2, "matrix": [2, 1]}, + {"x": 2, "y": 2, "matrix": [2, 2]}, + {"x": 3, "y": 2, "matrix": [2, 3]}, + {"x": 4, "y": 2, "matrix": [2, 4]} + ] + } + } +} diff --git a/keyboards/handwired/set_st/rp2040/keymaps/default/keymap.c b/keyboards/handwired/set_st/rp2040/keymaps/default/keymap.c new file mode 100644 index 00000000000..1034c065a74 --- /dev/null +++ b/keyboards/handwired/set_st/rp2040/keymaps/default/keymap.c @@ -0,0 +1,176 @@ +/* Copyright 2020 set_st + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include QMK_KEYBOARD_H + +enum keycodes { + KC_CYCLE_LAYERS = QK_USER, +}; + +enum layers{ + BASE, + FN, + MEDIA, + LIGHT +}; + +#define KC_TASK LGUI(KC_TAB) +#define KC_FLXP LGUI(KC_E) + +// 1st layer on the cycle +#define LAYER_CYCLE_START 0 +// Last layer on the cycle +#define LAYER_CYCLE_END 4 + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [BASE] = LAYOUT( + KC_MEDIA_PLAY_PAUSE, + KC_CYCLE_LAYERS, LGUI(KC_C), LGUI(KC_V), LCTL(KC_SPC), KC_KP_5, + KC_KP_6, KC_KP_7, KC_KP_8, LCTL(KC_LEFT), LCTL(KC_RIGHT) + ), + [FN] = LAYOUT( + _______, + KC_CYCLE_LAYERS, _______, _______, _______, _______, + _______, _______, _______, _______, _______ + ), + [MEDIA] = LAYOUT( + KC_MEDIA_PLAY_PAUSE, + KC_CYCLE_LAYERS, _______, _______, _______, _______, + KC_MEDIA_PLAY_PAUSE, _______, _______, KC_VOLD, KC_VOLU + ), + [LIGHT] = LAYOUT( + _______, + KC_CYCLE_LAYERS, RGB_MOD, RGB_RMOD, _______, _______, + RGB_TOG, _______, _______, RGB_VAD, RGB_VAI + ), +}; + +#ifdef ENCODER_MAP_ENABLE +const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { + [BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, + [FN] = { ENCODER_CCW_CW(LCTL(KC_LEFT), LCTL(KC_RIGHT)) }, + [MEDIA] = { ENCODER_CCW_CW(_______, _______) }, + [LIGHT] = { ENCODER_CCW_CW(_______, _______) } +}; +#endif + + +#ifdef OLED_ENABLE + +bool oled_task_user(void) { + // Set cursor position + oled_set_cursor(0, 0); + // Switch on current active layer + switch (get_highest_layer(layer_state)) { + case BASE : + oled_write_ln_P("1:Base", false); + break; + case FN : + oled_write_ln_P("2:Functions", false); + break; + case MEDIA : + oled_write_ln_P("3:Media", false); + break; + case LIGHT : + oled_write_ln_P("4:Lights controll", false); + break; + } + + + oled_set_cursor(0, 1); + oled_write(PSTR("Keys: "), false); + + os_variant_t os = detected_host_os(); + switch (os){ + case OS_MACOS: + oled_write("MAC", false); + break; + case OS_LINUX: + oled_write("LIN", false); + break; + case OS_WINDOWS: + oled_write("WIN", false); + break; + default: + break; + } + oled_write_ln("", false); + + for (int i = 0; i < MATRIX_ROWS; i++) { + for (int j = 0; j < MATRIX_COLS; j++) { + uint16_t keycode = keymaps[get_highest_layer(layer_state)][i][j]; + if(keycode == KC_NO || keycode == KC_TRANSPARENT){ + oled_write(" ", false); + } + else{ + oled_write("(", false); + if (KEYCODE2CONSUMER(keycode)) { + oled_write("M", false); + } + else if (IS_ANY(keycode)) + { + oled_write("A", false); + } + else{ + oled_write("D", false); + } + oled_write(") ", false); + } + } + oled_write_ln("", false); // Переходим на новую строку + } + + return false; +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case KC_CYCLE_LAYERS: + // Our logic will happen on presses, nothing is done on releases + if (!record->event.pressed) { + // We've already handled the keycode (doing nothing), let QMK know so no further code is run unnecessarily + return false; + } + + uint8_t current_layer = get_highest_layer(layer_state); + + // Check if we are within the range, if not quit + if (current_layer > LAYER_CYCLE_END || current_layer < LAYER_CYCLE_START) { + return false; + } + + uint8_t next_layer = current_layer + 1; + if (next_layer >= LAYER_CYCLE_END) { + next_layer = LAYER_CYCLE_START; + } + layer_move(next_layer); + return false; + + // Process other keycodes normally + default: + // Код клавиши будет отображаться на OLED дисплее + oled_clear(); // Очищаем дисплей + oled_set_cursor(0, 6); + oled_write("Keycode: ", false); // Отображаем текст "Keycode:" + char keycode_str[6]; // Создаем массив для хранения строки с кодом клавиши (5 символов для числа + 1 символ для завершающего нуля) + itoa(keycode, keycode_str, 10); // Преобразуем код клавиши в строку + oled_write(keycode_str, false); // Отображаем код клавиши на OLED дисплее + oled_write_ln("", false); + return true; + } +} + +#endif diff --git a/keyboards/handwired/set_st/rp2040/keymaps/default/rules.mk b/keyboards/handwired/set_st/rp2040/keymaps/default/rules.mk new file mode 100644 index 00000000000..ee325681483 --- /dev/null +++ b/keyboards/handwired/set_st/rp2040/keymaps/default/rules.mk @@ -0,0 +1 @@ +ENCODER_MAP_ENABLE = yes diff --git a/keyboards/handwired/set_st/rp2040/keymaps/via/keymap.c b/keyboards/handwired/set_st/rp2040/keymaps/via/keymap.c new file mode 100644 index 00000000000..1034c065a74 --- /dev/null +++ b/keyboards/handwired/set_st/rp2040/keymaps/via/keymap.c @@ -0,0 +1,176 @@ +/* Copyright 2020 set_st + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include QMK_KEYBOARD_H + +enum keycodes { + KC_CYCLE_LAYERS = QK_USER, +}; + +enum layers{ + BASE, + FN, + MEDIA, + LIGHT +}; + +#define KC_TASK LGUI(KC_TAB) +#define KC_FLXP LGUI(KC_E) + +// 1st layer on the cycle +#define LAYER_CYCLE_START 0 +// Last layer on the cycle +#define LAYER_CYCLE_END 4 + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [BASE] = LAYOUT( + KC_MEDIA_PLAY_PAUSE, + KC_CYCLE_LAYERS, LGUI(KC_C), LGUI(KC_V), LCTL(KC_SPC), KC_KP_5, + KC_KP_6, KC_KP_7, KC_KP_8, LCTL(KC_LEFT), LCTL(KC_RIGHT) + ), + [FN] = LAYOUT( + _______, + KC_CYCLE_LAYERS, _______, _______, _______, _______, + _______, _______, _______, _______, _______ + ), + [MEDIA] = LAYOUT( + KC_MEDIA_PLAY_PAUSE, + KC_CYCLE_LAYERS, _______, _______, _______, _______, + KC_MEDIA_PLAY_PAUSE, _______, _______, KC_VOLD, KC_VOLU + ), + [LIGHT] = LAYOUT( + _______, + KC_CYCLE_LAYERS, RGB_MOD, RGB_RMOD, _______, _______, + RGB_TOG, _______, _______, RGB_VAD, RGB_VAI + ), +}; + +#ifdef ENCODER_MAP_ENABLE +const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { + [BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, + [FN] = { ENCODER_CCW_CW(LCTL(KC_LEFT), LCTL(KC_RIGHT)) }, + [MEDIA] = { ENCODER_CCW_CW(_______, _______) }, + [LIGHT] = { ENCODER_CCW_CW(_______, _______) } +}; +#endif + + +#ifdef OLED_ENABLE + +bool oled_task_user(void) { + // Set cursor position + oled_set_cursor(0, 0); + // Switch on current active layer + switch (get_highest_layer(layer_state)) { + case BASE : + oled_write_ln_P("1:Base", false); + break; + case FN : + oled_write_ln_P("2:Functions", false); + break; + case MEDIA : + oled_write_ln_P("3:Media", false); + break; + case LIGHT : + oled_write_ln_P("4:Lights controll", false); + break; + } + + + oled_set_cursor(0, 1); + oled_write(PSTR("Keys: "), false); + + os_variant_t os = detected_host_os(); + switch (os){ + case OS_MACOS: + oled_write("MAC", false); + break; + case OS_LINUX: + oled_write("LIN", false); + break; + case OS_WINDOWS: + oled_write("WIN", false); + break; + default: + break; + } + oled_write_ln("", false); + + for (int i = 0; i < MATRIX_ROWS; i++) { + for (int j = 0; j < MATRIX_COLS; j++) { + uint16_t keycode = keymaps[get_highest_layer(layer_state)][i][j]; + if(keycode == KC_NO || keycode == KC_TRANSPARENT){ + oled_write(" ", false); + } + else{ + oled_write("(", false); + if (KEYCODE2CONSUMER(keycode)) { + oled_write("M", false); + } + else if (IS_ANY(keycode)) + { + oled_write("A", false); + } + else{ + oled_write("D", false); + } + oled_write(") ", false); + } + } + oled_write_ln("", false); // Переходим на новую строку + } + + return false; +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case KC_CYCLE_LAYERS: + // Our logic will happen on presses, nothing is done on releases + if (!record->event.pressed) { + // We've already handled the keycode (doing nothing), let QMK know so no further code is run unnecessarily + return false; + } + + uint8_t current_layer = get_highest_layer(layer_state); + + // Check if we are within the range, if not quit + if (current_layer > LAYER_CYCLE_END || current_layer < LAYER_CYCLE_START) { + return false; + } + + uint8_t next_layer = current_layer + 1; + if (next_layer >= LAYER_CYCLE_END) { + next_layer = LAYER_CYCLE_START; + } + layer_move(next_layer); + return false; + + // Process other keycodes normally + default: + // Код клавиши будет отображаться на OLED дисплее + oled_clear(); // Очищаем дисплей + oled_set_cursor(0, 6); + oled_write("Keycode: ", false); // Отображаем текст "Keycode:" + char keycode_str[6]; // Создаем массив для хранения строки с кодом клавиши (5 символов для числа + 1 символ для завершающего нуля) + itoa(keycode, keycode_str, 10); // Преобразуем код клавиши в строку + oled_write(keycode_str, false); // Отображаем код клавиши на OLED дисплее + oled_write_ln("", false); + return true; + } +} + +#endif diff --git a/keyboards/handwired/set_st/rp2040/keymaps/via/rules.mk b/keyboards/handwired/set_st/rp2040/keymaps/via/rules.mk new file mode 100644 index 00000000000..715838ecc5d --- /dev/null +++ b/keyboards/handwired/set_st/rp2040/keymaps/via/rules.mk @@ -0,0 +1,2 @@ +ENCODER_MAP_ENABLE = yes +VIA_ENABLE = yes diff --git a/keyboards/handwired/set_st/rp2040/mcuconf.h b/keyboards/handwired/set_st/rp2040/mcuconf.h new file mode 100644 index 00000000000..aae1fb04657 --- /dev/null +++ b/keyboards/handwired/set_st/rp2040/mcuconf.h @@ -0,0 +1,22 @@ +/* Copyright 2022 Jose Pablo Ramirez + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include_next + +#undef RP_I2C_USE_I2C0 +#define RP_I2C_USE_I2C0 TRUE \ No newline at end of file diff --git a/keyboards/handwired/set_st/rp2040/readme.md b/keyboards/handwired/set_st/rp2040/readme.md new file mode 100644 index 00000000000..c85ef5c601f --- /dev/null +++ b/keyboards/handwired/set_st/rp2040/readme.md @@ -0,0 +1,28 @@ +# MacroPad 10 RP2040 + +A RP2040-powered Macropad with a 2x5 layout. + +Make example for this board (after setting up your build environment): + +```sh +qmk compile -kb handwired/set_st/rp2040 -km via +``` + +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). + +## Features + +- Raspberry Pi RP2040 Zero or Plus. +- 2x10 Mechanical key switch sockets - accepts any Cherry MX-compatible switches. Individually tied to GPIO pins (not matrix wired) +- One NeoPixel RGB LED per switch, on north side. +- Rotary encoder, 20 detents per rotation, with push-switch on GPIO pin. +- 128x64 SH1306 Monochrome OLED i2c display. + +## Bootloader + +Enter the bootloader in 4 ways: + +* **Bootmagic reset**: Hold down the key just below the rotary encoder push-button on power-up. +* **Physical reset button**: Press twice the button on the side while the board is connected. +* **BOOT button** Hold down the rotary encoder push-button on power-up or reset. +* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available. diff --git a/keyboards/handwired/set_st/rp2040/rules.mk b/keyboards/handwired/set_st/rp2040/rules.mk new file mode 100644 index 00000000000..7ff128fa692 --- /dev/null +++ b/keyboards/handwired/set_st/rp2040/rules.mk @@ -0,0 +1 @@ +# This file intentionally left blank \ No newline at end of file