simple rgblight control via hid for raspberry pi pico
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#pragma once
|
||||
|
||||
#define RAW_ENABLE
|
||||
|
||||
#ifndef CORTEX_ENABLE_WFI_IDLE
|
||||
# define CORTEX_ENABLE_WFI_IDLE TRUE
|
||||
#endif // CORTEX_ENABLE_WFI_IDLE
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "usb_descriptor.h"
|
||||
#include "usb_driver.h"
|
||||
#include "usb_types.h"
|
||||
#include "rgblight.h"
|
||||
|
||||
#ifdef NKRO_ENABLE
|
||||
# include "keycode_config.h"
|
||||
@@ -973,10 +974,29 @@ void raw_hid_send(uint8_t *data, uint8_t length) {
|
||||
chnWrite(&drivers.raw_driver.driver, data, length);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) {
|
||||
// Users should #include "raw_hid.h" in their own code
|
||||
// and implement this function there. Leave this as weak linkage
|
||||
// so users can opt to not handle data coming in.
|
||||
enum HID_RGBLED_COMMAND { HID_PING = 0, HID_SET_HSV, HID_SET_RGB };
|
||||
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);
|
||||
}
|
||||
|
||||
void raw_hid_task(void) {
|
||||
|
||||
Reference in New Issue
Block a user