add hid-rgbled

This commit is contained in:
hsgw
2024-02-17 23:01:31 +09:00
parent 76f5c55e80
commit 56718042b0
8 changed files with 71 additions and 50 deletions

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

@@ -12,10 +12,11 @@
"bootmagic": true,
"command": false,
"console": false,
"extrakey": true,
"mousekey": true,
"nkro": true,
"rgblight": true
"extrakey": false,
"mousekey": false,
"nkro": false,
"rgblight": true,
"raw": true
},
"rgblight": {
"saturation_steps": 8,
@@ -23,16 +24,16 @@
"led_count": 1,
"sleep": true,
"animations": {
"breathing": true,
"rainbow_mood": true,
"rainbow_swirl": true,
"snake": true,
"knight": true,
"christmas": true,
"static_gradient": true,
"breathing": false,
"rainbow_mood": false,
"rainbow_swirl": false,
"snake": false,
"knight": false,
"christmas": false,
"static_gradient": false,
"rgb_test": true,
"alternating": true,
"twinkle": true
"alternating": false,
"twinkle": false
}
},
"layouts": {

View File

@@ -5,12 +5,6 @@
// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT_ortho_1x1(KC_A)
[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

@@ -1,27 +0,0 @@
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include QMK_KEYBOARD_H
#include <raw_hid.h>
// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT_ortho_1x1(KC_A)
};
// clang-format on
void keyboard_post_init_user(void) {
rgblight_enable();
}
void raw_hid_receive(uint8_t *data, uint8_t length) {
// `data` is a pointer to the buffer containing the received HID report
// `length` is the length of the report - always `RAW_EPSIZE`
uint8_t response[length];
memset(response, 0, length);
response[0] = 'B';
if (data[0] == 'A') {
raw_hid_send(response, length);
}
}

View File

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

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

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