7 Commits

Author SHA1 Message Date
73daaa4198 update protocol on HID according to hsgw's one 2024-02-18 17:43:53 +09:00
1e67c09ddf Merge remote-tracking branch 'hsgw/hid_rgbled' into hid_rgb_control 2024-02-18 17:35:51 +09:00
hsgw
7b22a4dbf1 add ichi_pp 2024-02-18 03:25:28 +09:00
hsgw
381b60a084 add hid_rgbled/rp2040_zero 2024-02-17 23:32:54 +09:00
hsgw
56718042b0 add hid-rgbled 2024-02-17 23:01:31 +09:00
c27330e306 simple rgblight control via hid 2024-02-04 20:38:54 +09:00
hsgw
76f5c55e80 add hid_rgbled keymap 2024-01-31 23:05:25 +09:00
21 changed files with 322 additions and 4 deletions

View File

@@ -0,0 +1,20 @@
// Copyright 2024 hsgw (@hsgw)
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
/*
* Feature disable options
* These options are also useful to firmware size reduction.
*/
/* disable debug print */
//#define NO_DEBUG
/* disable print */
//#define NO_PRINT
/* disable action features */
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT

View File

@@ -0,0 +1,35 @@
#include "hid_rgbled.h"
#include <raw_hid.h>
#include <rgblight.h>
void keyboard_post_init_kb(void) {
rgblight_enable();
rgblight_sethsv_noeeprom(0, 0, 0);
rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
keyboard_post_init_user();
}
void raw_hid_receive(uint8_t *data, uint8_t length) {
switch (data[0]) {
case HID_PING:
data[0] = 1;
data[1] = 'R';
data[2] = 'G';
data[3] = 'B';
break;
case HID_SET_HSV:
rgblight_sethsv_noeeprom(data[1], data[2], data[3]);
data[0] = 1;
break;
case HID_SET_RGB:
rgblight_setrgb(data[1], data[2], data[3]);
data[0] = 1;
break;
default:
data[1] = data[0];
data[0] = 0;
break;
}
raw_hid_send(data, length);
}

View File

@@ -0,0 +1,3 @@
#include <quantum.h>
enum HID_RGBLED_COMMAND { HID_PING = 0, HID_SET_HSV, HID_SET_RGB };

View File

@@ -0,0 +1,22 @@
// Copyright 2024 hsgw (Takuya Urakawa, Dm9Records, 5z6p.com)
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
#define NO_USB_STARTUP_CHECK
// SPI
#define WS2812_SPI_DRIVER SPID1
#define WS2812_SPI_MOSI_PAL_MODE 0
#define WS2812_SPI_SCK_PAL_MODE 0
#define WS2812_SPI_SCK_PIN A5
// #define WS2812_EXTERNAL_PULLUP
#define RGBLIGHT_DEFAULT_ON true
#define LAYER_STATE_8BIT
#define NO_ACTION_LAYER
#define NO_ACTION_TAPPING
#define NO_ACTION_ONESHOT

View File

@@ -0,0 +1,9 @@
// Copyright 2024 hsgw (Takuya Urakawa, Dm9Records, 5z6p.com)
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
// #define HAL_USE_I2C TRUE
#define HAL_USE_SPI TRUE
#include_next <halconf.h>

View File

@@ -0,0 +1,10 @@
// Copyright 2024 hsgw (Takuya Urakawa, Dm9Records, 5z6p.com)
// SPDX-License-Identifier: GPL-2.0-or-later
#include "quantum.h"
void keyboard_pre_init_kb() {
// Enable USB pins
SYSCFG->CFGR1 |= SYSCFG_CFGR1_PA11_PA12_RMP;
keyboard_pre_init_user();
}

View File

@@ -0,0 +1,21 @@
{
"bootloader": "stm32-dfu",
"processor": "STM32F042",
"url": "",
"usb": {
"device_version": "1.0.0",
"pid": "0x0000",
"vid": "0xFEED"
},
"matrix_pins":{
"direct": [["A4"]]
},
"ws2812": {
"pin": "A7",
"driver": "spi"
},
"rgblight": {
"led_count": 10,
"max_brightness": 255
}
}

View File

@@ -0,0 +1,21 @@
// Copyright 2024 hsgw (Takuya Urakawa, Dm9Records, 5z6p.com)
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include_next <mcuconf.h>
// #undef STM32_I2C_USE_I2C1
// #define STM32_I2C_USE_I2C1 TRUE
// #undef STM32_I2C_I2C1_RX_DMA_STREAM
// #define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
// #undef STM32_I2C_I2C1_TX_DMA_STREAM
// #define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
#undef STM32_SPI_SPI1_RX_DMA_STREAM
#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
#undef STM32_SPI_SPI1_TX_DMA_STREAM
#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
#undef STM32_SPI_USE_SPI1
#define STM32_SPI_USE_SPI1 TRUE

View File

@@ -0,0 +1 @@
# This file intentionally left blank

View File

@@ -0,0 +1,45 @@
{
"manufacturer": "hsgw",
"keyboard_name": "hid_rgbled",
"maintainer": "hsgw",
"url": "",
"usb": {
"device_version": "1.0.0",
"pid": "0x0000",
"vid": "0xFEED"
},
"features": {
"bootmagic": true,
"command": false,
"console": false,
"extrakey": false,
"mousekey": false,
"nkro": false,
"rgblight": true,
"raw": true
},
"rgblight": {
"saturation_steps": 8,
"brightness_steps": 8,
"sleep": true,
"animations": {
"breathing": false,
"rainbow_mood": false,
"rainbow_swirl": false,
"snake": false,
"knight": false,
"christmas": false,
"static_gradient": false,
"rgb_test": true,
"alternating": false,
"twinkle": false
}
},
"layouts": {
"LAYOUT_ortho_1x1": {
"layout": [
{"matrix": [0, 0], "x": 0, "y": 0}
]
}
}
}

View File

@@ -0,0 +1,10 @@
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include QMK_KEYBOARD_H
// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT_ortho_1x1(KC_ENT)
};
// clang-format on

View File

@@ -0,0 +1,16 @@
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include QMK_KEYBOARD_H
// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT_ortho_1x1(KC_ENT)
};
// clang-format on
void keyboard_post_init_user(void) {
rgblight_enable();
rgblight_mode(RGBLIGHT_MODE_RGB_TEST);
}

View File

@@ -0,0 +1,28 @@
# hid_rgbled
![hid_rgbled](imgur.com image replace me!)
*A short description of the keyboard/project*
* Keyboard Maintainer: [hsgw](https://github.com/hsgw)
* Hardware Supported: *The PCBs, controllers supported*
* Hardware Availability: *Links to where you can find this hardware*
Make example for this keyboard (after setting up your build environment):
make hid_rgbled:xiao_rp2040:default
make hid_rgbled:(your add direcry):default
Flashing example for this keyboard:
make hid_rgbled: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 (usually the top left key or Escape) and plug in the keyboard
* **Physical reset button**: Briefly press the button on the back of the PCB - some may have pads you must short instead
* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available

View File

@@ -0,0 +1,21 @@
{
"bootloader": "rp2040",
"processor": "RP2040",
"url": "",
"usb": {
"device_version": "1.0.0",
"pid": "0x0000",
"vid": "0xFEED"
},
"matrix_pins":{
"direct": [["GP0"]]
},
"ws2812": {
"pin": "GP16",
"driver": "vendor"
},
"rgblight": {
"led_count": 1,
"max_brightness": 255
}
}

View File

@@ -0,0 +1 @@
# This file intentionally left blank

View File

@@ -0,0 +1 @@
# This file intentionally left blank

View File

@@ -0,0 +1,21 @@
{
"bootloader": "rp2040",
"processor": "RP2040",
"url": "",
"usb": {
"device_version": "1.0.0",
"pid": "0x0000",
"vid": "0xFEED"
},
"matrix_pins":{
"direct": [["GP26"]]
},
"ws2812": {
"pin": "GP12",
"driver": "vendor"
},
"rgblight": {
"led_count": 1,
"max_brightness": 200
}
}

View File

@@ -0,0 +1 @@
# This file intentionally left blank

View File

@@ -0,0 +1,9 @@
#include "quantum.h"
void keyboard_pre_init_kb(void) {
// power up rgbled
setPinOutput(GP11);
writePinHigh(GP11);
keyboard_pre_init_user();
}

View File

@@ -2,6 +2,8 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once
#define RAW_ENABLE
#ifndef CORTEX_ENABLE_WFI_IDLE #ifndef CORTEX_ENABLE_WFI_IDLE
# define CORTEX_ENABLE_WFI_IDLE TRUE # define CORTEX_ENABLE_WFI_IDLE TRUE
#endif // CORTEX_ENABLE_WFI_IDLE #endif // CORTEX_ENABLE_WFI_IDLE

View File

@@ -44,6 +44,7 @@
#include "usb_descriptor.h" #include "usb_descriptor.h"
#include "usb_driver.h" #include "usb_driver.h"
#include "usb_types.h" #include "usb_types.h"
#include "rgblight.h"
#ifdef NKRO_ENABLE #ifdef NKRO_ENABLE
# include "keycode_config.h" # include "keycode_config.h"
@@ -972,10 +973,30 @@ void raw_hid_send(uint8_t *data, uint8_t length) {
chnWrite(&drivers.raw_driver.driver, data, length); chnWrite(&drivers.raw_driver.driver, data, length);
} }
__attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) { enum HID_RGBLED_COMMAND { HID_PING = 0, HID_SET_HSV, HID_SET_RGB };
// Users should #include "raw_hid.h" in their own code void raw_hid_receive(uint8_t *data, uint8_t length) {
// and implement this function there. Leave this as weak linkage switch (data[0]) {
// so users can opt to not handle data coming in. case HID_PING:
data[0] = 1;
data[1] = 'R';
data[2] = 'G';
data[3] = 'B';
break;
case HID_SET_HSV:
rgblight_sethsv_noeeprom(data[1], data[2], data[3]);
data[0] = 1;
break;
case HID_SET_RGB:
rgblight_setrgb(data[1], data[2], data[3]);
data[0] = 1;
break;
default:
data[1] = data[0];
data[0] = 0;
break;
}
raw_hid_send(data, length);
//rgblight_setrgb(data[0], data[1], data[2]);
} }
void raw_hid_task(void) { void raw_hid_task(void) {