Files
scottokeebs/Scotto48/PCB/QMK/keymaps/scotto/rgb.c
T
2026-07-11 14:03:45 -04:00

46 lines
1.0 KiB
C

#include QMK_KEYBOARD_H
#include "keys.h"
#define SCALE(x) ((x * RGB_BRIGHTNESS) / 255)
void housekeeping_task_user(void) {
uint8_t layer = get_highest_layer(layer_state | default_layer_state);
static bool init = false;
if (!init) {
gpio_set_pin_output(GP25);
gpio_write_pin_low(GP25);
init = true;
}
// Caps lock LED
gpio_write_pin(GP25, host_keyboard_led_state().caps_lock);
// Layer colors
switch (layer) {
case CODE:
rgblight_setrgb(SCALE(255), SCALE(255), 0); // Yellow
return;
case NUMBER:
rgblight_setrgb(0, 0, SCALE(255)); // Blue
return;
case FUNCTION:
rgblight_setrgb(SCALE(255), SCALE(64), 0); // Orange
return;
case MOUSE:
rgblight_setrgb(SCALE(128), 0, SCALE(255)); // Purple
return;
}
if (user_config.is_game_mode) {
rgblight_setrgb(SCALE(255), 0, 0); // Red
} else if (user_config.is_windows) {
rgblight_setrgb(0, SCALE(255), 0); // Green
} else {
rgblight_setrgb(SCALE(255), SCALE(255), SCALE(255)); // White
}
}