1
0
mirror of https://github.com/whowechina/iidx_pico.git synced 2024-09-23 18:58:22 +02:00

Merge pull request #1 from MitsuyoDADADA/main

HIG lights for turntable
This commit is contained in:
whowechina 2024-06-10 15:11:40 +08:00 committed by GitHub
commit 4f766124b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 27 additions and 10 deletions

Binary file not shown.

View File

@ -168,8 +168,9 @@ void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id,
{
if ((report_id == REPORT_ID_LIGHTS) &&
(report_type == HID_REPORT_TYPE_OUTPUT)) {
if (bufsize >= rgb_button_num()) {
if (bufsize >= rgb_button_num() + 3) {
rgb_set_hid_light(buffer, rgb_button_num());
rgb_set_tt_light(buffer + rgb_button_num(), 3);
}
}
}

View File

@ -27,6 +27,7 @@ static const uint8_t button_rgb_map[BUTTON_RGB_NUM] = BUTTON_RGB_MAP;
static void trap() {}
static tt_effect_t effects[10] = { {trap, trap, trap, 0} };
uint8_t tt_hid[3];
static size_t effect_num = 0;
static unsigned current_effect = 0;
@ -38,6 +39,9 @@ static unsigned current_effect = 0;
#define REMAP_BUTTON_RGB _MAP_LED(BUTTON_RGB_ORDER)
#define REMAP_TT_RGB _MAP_LED(TT_RGB_ORDER)
#define HID_EXPIRE_DURATION 1000000ULL
static uint64_t hid_expire_time = 0;
static inline uint32_t _rgb32(uint32_t c1, uint32_t c2, uint32_t c3, bool gamma_fix)
{
c1 = c1 * iidx_cfg->level / 255;
@ -105,10 +109,16 @@ void drive_led()
for (int i = 0; i < iidx_cfg->tt_led.start; i++) {
pio_sm_put_blocking(pio1, 0, 0);
}
for (int i = 0; i < TT_LED_NUM; i++) {
bool reversed = iidx_cfg->tt_led.mode & 0x01;
uint8_t id = reversed ? TT_LED_NUM - i - 1 : i;
pio_sm_put_blocking(pio1, 0, tt_led_buf[id] << 8u);
if (time_us_64() < hid_expire_time && (tt_hid[0] != 0 || tt_hid[1] != 0 || tt_hid[2] != 0) ) {
for (int i = 0; i < TT_LED_NUM; i++) {
pio_sm_put_blocking(pio1, 0, tt_rgb32(tt_hid[0], tt_hid[1], tt_hid[2], false) << 8u);
}
}else{
for (int i = 0; i < TT_LED_NUM; i++) {
bool reversed = iidx_cfg->tt_led.mode & 0x01;
uint8_t id = reversed ? TT_LED_NUM - i - 1 : i;
pio_sm_put_blocking(pio1, 0, tt_led_buf[id] << 8u); //
}
}
for (int i = 0; i < 8; i++) { // a few more to wipe out the last led
pio_sm_put_blocking(pio1, 0, 0);
@ -172,9 +182,6 @@ uint32_t tt_hsv(hsv_t hsv)
#endif
}
#define HID_EXPIRE_DURATION 1000000ULL
static uint64_t hid_expire_time = 0;
static void button_lights_update()
{
for (int i = 0; i < BUTTON_RGB_NUM; i++) {
@ -210,6 +217,11 @@ void rgb_set_hid_light(uint8_t const *lights, uint8_t num)
hid_expire_time = time_us_64() + HID_EXPIRE_DURATION;
}
void rgb_set_tt_light(uint8_t const *lights, uint8_t num)
{
memcpy(tt_hid, lights, num);
}
static void effect_update()
{
effects[current_effect].update(effects[current_effect].context);

View File

@ -22,6 +22,7 @@ void rgb_set_level(uint8_t level);
void rgb_set_button_light(uint16_t buttons);
void rgb_set_hid_light(uint8_t const *lights, uint8_t num);
void rgb_set_tt_light(uint8_t const *lights, uint8_t num);
void rgb_force_display(uint32_t *keyboard, uint32_t *tt);

View File

@ -143,7 +143,10 @@ const char *string_desc_arr[] = {
"E1",
"E2",
"E3",
"E4"
"E4",
"TT R",
"TT G",
"TT B"
};
static uint16_t _desc_str[64];

View File

@ -34,7 +34,7 @@ enum {
#define GAMECON_REPORT_DESC_LIGHTS(...) \
HID_USAGE_PAGE(HID_USAGE_PAGE_DESKTOP), HID_USAGE(0x00), \
HID_COLLECTION(HID_COLLECTION_APPLICATION), \
__VA_ARGS__ HID_REPORT_COUNT(11), /* LED NUM */ \
__VA_ARGS__ HID_REPORT_COUNT(14), /* LED NUM */ \
HID_REPORT_SIZE(8), HID_LOGICAL_MIN(0x00), HID_LOGICAL_MAX_N(0x00ff, 2), \
HID_USAGE_PAGE(HID_USAGE_PAGE_ORDINAL), \
HID_STRING_MINIMUM(5), HID_STRING_MAXIMUM(17), \