Vial firmware for the wired Royal Kludge R75 (WB32FQ95), based on mossbed/r75 vialrgb and checked against RK's own R75 source: - the keymap is generated from the factory keymap read off the keyboard (factory reset moved to Fn+RShift+Space) - the Caps Lock LED uses RK's pin C4 instead of matrix column C9 - five custom RGB matrix effects (synthwave, glitch, heartbeat, plasma, scanner) - raw HID command 0xC7: custom effect select, colour/speed for any effect, and alert overlays drawn over the running effect - host simulator in sim/ to preview the effects as PNGs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
2.5 KiB
C
48 lines
2.5 KiB
C
// Host-side harness: runs the custom effects from rgb_matrix_user.inc with QMK's real
|
|
// lib8tion + colour code and prints one line per LED per frame: frame,led,r,g,b
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
#define FASTLED_SCALE8_FIXED 1
|
|
#include "lib8tion/lib8tion.h"
|
|
#include "color.h"
|
|
#include "leds.h"
|
|
#define RGB_MATRIX_LED_COUNT SIM_LED_COUNT
|
|
#define LED_HITS_TO_REMEMBER 8
|
|
#define RGB_MATRIX_KEYPRESSES
|
|
typedef uint8_t led_flags_t;
|
|
typedef struct { uint8_t iter; led_flags_t flags; bool init; } effect_params_t;
|
|
typedef struct { uint8_t x, y; } led_point_t;
|
|
typedef struct { led_point_t point[SIM_LED_COUNT]; uint8_t flags[SIM_LED_COUNT]; } led_config_t;
|
|
typedef struct { uint8_t count; uint8_t x[8], y[8], index[8]; uint16_t tick[8]; } last_hit_t;
|
|
typedef struct { HSV hsv; uint8_t speed; } cfg_t;
|
|
led_config_t g_led_config; last_hit_t g_last_hit_tracker; cfg_t rgb_matrix_config; uint32_t g_rgb_timer;
|
|
static RGB out[SIM_LED_COUNT];
|
|
static uint32_t fake_now;
|
|
static void rgb_matrix_set_color(int i, uint8_t r, uint8_t g, uint8_t b) { out[i] = (RGB){r, g, b}; }
|
|
static bool rgb_matrix_check_finished_leds(uint8_t m) { (void)m; return false; }
|
|
static uint32_t timer_read32(void) { return fake_now; }
|
|
static uint32_t timer_elapsed32(uint32_t t) { return fake_now - t; }
|
|
static bool timer_expired32(uint32_t now, uint32_t until) { return (int32_t)(now - until) >= 0; }
|
|
#define RGB_MATRIX_USE_LIMITS(a, b) uint8_t a = 0, b = SIM_LED_COUNT; (void)params
|
|
#define RGB_MATRIX_TEST_LED_FLAGS() do {} while (0)
|
|
#define RGB_MATRIX_EFFECT(name)
|
|
#define RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
|
#include "../keyboards/rk/r75/keymaps/vial/rgb_matrix_user.inc"
|
|
int main(int argc, char **argv) {
|
|
int effect = atoi(argv[1]), frames = atoi(argv[2]), step = atoi(argv[3]);
|
|
for (int i = 0; i < SIM_LED_COUNT; i++) g_led_config.point[i] = (led_point_t){sim_x[i], sim_y[i]};
|
|
rgb_matrix_config.hsv = (HSV){0, 255, 200}; rgb_matrix_config.speed = 96;
|
|
bool (*fx[])(effect_params_t *) = {CD_SYNTHWAVE, CD_GLITCH, CD_HEARTBEAT, CD_PLASMA, CD_SCANNER};
|
|
for (int f = 0; f < frames; f++) {
|
|
g_rgb_timer = fake_now = f * step;
|
|
if (effect == 2 && f == 3) { g_last_hit_tracker.count = 1; g_last_hit_tracker.x[0] = 60; g_last_hit_tracker.y[0] = 36; }
|
|
if (g_last_hit_tracker.count) g_last_hit_tracker.tick[0] = (f - 3) * step;
|
|
effect_params_t p = {0, 0xFF, f == 0};
|
|
fx[effect](&p);
|
|
for (int i = 0; i < SIM_LED_COUNT; i++) printf("%d,%d,%d,%d,%d\n", f, i, out[i].r, out[i].g, out[i].b);
|
|
}
|
|
}
|