Skip to content

Commit

Permalink
update geekrgb default color
Browse files Browse the repository at this point in the history
  • Loading branch information
puterjam committed Dec 26, 2022
1 parent 3e7e23e commit 4a89081
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 51 deletions.
10 changes: 7 additions & 3 deletions keyboards/keychron/q1/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
/* Disable DIP switch in matrix data */
#define MATRIX_MASKED

/* Disable RGB lighting when PC is in suspend */
#define RGB_DISABLE_WHEN_USB_SUSPENDED

// RGB Matrix Animation modes. Explicitly enabled
// For full list of effects, see:
// https://docs.qmk.fm/#/feature_rgb_matrix?id=rgb-matrix-effects
Expand Down Expand Up @@ -80,8 +77,15 @@
#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
#define RGB_MATRIX_KEYPRESSES

#ifdef RGB_MATRIX_ENABLE
# define RGB_DISABLE_WHEN_USB_SUSPENDED // Disable RGB lighting when PC is in suspend
# undef RGB_DISABLE_TIMEOUT
# define RGB_DISABLE_TIMEOUT 900000 // 15 minutes (15 * 60 * 1000ms)
#endif

/* GEEKRGB config */
#define GEEKRGB_USE_UNIVERSAL_BRIGHTNESS
#define GEEKRGB_WELCOME_ANIM_SPD 170
#define OPENRGB_DEFAULT_KEYMAP_ID 2 //read windows keymap for openrgb

/* Enable receive custom command from host */
Expand Down
16 changes: 10 additions & 6 deletions keyboards/melgeek/tegic/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
#define DEBOUNCE 3

/* Disable RGB lighting when PC is in suspend */
#define RGB_DISABLE_WHEN_USB_SUSPENDED

// #define RGB_ENABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
#define RGB_MATRIX_KEYPRESSES
// #define RGB_MATRIX_FRAMEBUFFER_EFFECTS
Expand All @@ -43,6 +40,12 @@

#define RGB_MATRIX_STARTUP_SPD 40

#ifdef RGB_MATRIX_ENABLE
# define RGB_DISABLE_WHEN_USB_SUSPENDED // Disable RGB lighting when PC is in suspend
# undef RGB_DISABLE_TIMEOUT
# define RGB_DISABLE_TIMEOUT 900000 // 15 minutes (15 * 60 * 1000ms)
#endif

#define DRIVER_ADDR_1 0b0110000
#define DRIVER_COUNT 1

Expand All @@ -64,7 +67,7 @@
#define ENABLE_RGB_MATRIX_CYCLE_UP_DOWN
#define ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
#define ENABLE_RGB_MATRIX_CYCLE_OUT_IN
#define ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL
// #define ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL
#define ENABLE_RGB_MATRIX_CYCLE_PINWHEEL
#define ENABLE_RGB_MATRIX_CYCLE_SPIRAL
#define ENABLE_RGB_MATRIX_DUAL_BEACON
Expand Down Expand Up @@ -95,9 +98,10 @@
// #define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH

//new effects
#define ENABLE_RGB_MATRIX_PIXEL_RAIN
// #define ENABLE_RGB_MATRIX_PIXEL_RAIN
// #define ENABLE_RGB_MATRIX_PIXEL_FLOW
// #define ENABLE_RGB_MATRIX_PIXEL_FRACTAL

/* GEEKRGB config */
#define GEEKRGB_USE_UNIVERSAL_BRIGHTNESS //no use OPENRGB_DIRECT_MODE_USE_UNIVERSAL_BRIGHTNESS

#define GEEKRGB_WELCOME_ANIM_SPD 170
40 changes: 19 additions & 21 deletions quantum/geekrgb.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,35 @@
#include "raw_hid.h"

#if !defined(GEEKRGB_STARTUP_RED)
# define GEEKRGB_STARTUP_RED 40
# define GEEKRGB_STARTUP_RED 20
#endif

#if !defined(GEEKRGB_STARTUP_GREEN)
# define GEEKRGB_STARTUP_GREEN 255
# define GEEKRGB_STARTUP_GREEN 120
#endif

#if !defined(GEEKRGB_STARTUP_BLUE)
# define GEEKRGB_STARTUP_BLUE 140
# define GEEKRGB_STARTUP_BLUE 190
#endif


// global
uint16_t g_geekrgb_timer = 0;
bool g_geekrgb_anim_playing = false;
uint16_t g_geekrgb_timer = 0;
bool g_geekrgb_anim_playing = false;

// internals
static uint8_t hidrgb_mode = HID_MODE_OPENRGB;
static RGB last_openrgb_colors[DRIVER_LED_TOTAL] = {[0 ... DRIVER_LED_TOTAL - 1] ={GEEKRGB_STARTUP_GREEN, GEEKRGB_STARTUP_RED, GEEKRGB_STARTUP_BLUE}};
static uint8_t geekrgb_mode = HID_MODE_OPENRGB;
static RGB last_openrgb_colors[DRIVER_LED_TOTAL] = {[0 ... DRIVER_LED_TOTAL - 1] = {GEEKRGB_STARTUP_GREEN, GEEKRGB_STARTUP_RED, GEEKRGB_STARTUP_BLUE}};

//static RGB last_openrgb_colors[DRIVER_LED_TOTAL] = {[0 ... DRIVER_LED_TOTAL - 1] ={0,0,0}};
//static RGB last_signalrgb_colors[DRIVER_LED_TOTAL] = {[0 ... DRIVER_LED_TOTAL - 1] ={0,0,0}};

//set one matrix led color
void hidrgb_set_color(int index, uint8_t red, uint8_t green, uint8_t blue){
void geekrgb_set_color(int index, uint8_t red, uint8_t green, uint8_t blue){
if (rgb_matrix_get_mode() != RGB_MATRIX_GEEKRGB) { // if matrix mode not signalrgb, do not streaming led.
return;
}

//cache openRGB colors
if (hidrgb_get_mode() == HID_MODE_OPENRGB) {
if (geekrgb_get_mode() == HID_MODE_OPENRGB) {
last_openrgb_colors[index].r = red;
last_openrgb_colors[index].g = green;
last_openrgb_colors[index].b = blue;
Expand All @@ -64,36 +62,36 @@ void hidrgb_set_color(int index, uint8_t red, uint8_t green, uint8_t blue){
}

//set openrgb colors
void hidrgb_reload_openrgb_colors(void){
if (hidrgb_get_mode() == HID_MODE_OPENRGB) {
void geekrgb_reload_openrgb_colors(void){
if (geekrgb_get_mode() == HID_MODE_OPENRGB) {
for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
hidrgb_set_color(i,last_openrgb_colors[i].r,last_openrgb_colors[i].g,last_openrgb_colors[i].b);
geekrgb_set_color(i,last_openrgb_colors[i].r,last_openrgb_colors[i].g,last_openrgb_colors[i].b);
}
}
}

void hidrgb_reload_openrgb_anim(void){
void geekrgb_reload_openrgb_anim(void){
if (!g_geekrgb_anim_playing) g_geekrgb_timer = 0;
rgb_matrix_set_color_all(0,0,0);
}

//get openrgb colors
RGB* hidrgb_get_openrgb_colors(void){
RGB* geekrgb_get_openrgb_colors(void){
return last_openrgb_colors;
}

RGB hidrgb_get_openrgb_color(int index){
RGB geekrgb_get_openrgb_color(int index){
return last_openrgb_colors[index];
}

//set hidrgb software mode, HID_MODE_OPENRGB or HID_MODE_SIGNALRGB
void hidrgb_set_mode(int mode){
hidrgb_mode = mode;
void geekrgb_set_mode(int mode){
geekrgb_mode = mode;
}

//get hidrgb software mode, HID_MODE_OPENRGB or HID_MODE_SIGNALRGB
uint8_t hidrgb_get_mode(void){
return hidrgb_mode;
uint8_t geekrgb_get_mode(void){
return geekrgb_mode;
}

//receive HIDRGB usbhid raw data.
Expand Down
14 changes: 7 additions & 7 deletions quantum/geekrgb.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ enum hidrgb_mode {
extern uint16_t g_geekrgb_timer;
extern bool g_geekrgb_anim_playing;

void hidrgb_set_color(int index, uint8_t red, uint8_t green, uint8_t blue); //set one led color
void hidrgb_set_mode(int mode); //set hidrgb software mode, HID_MODE_OPENRGB or HID_MODE_SIGNALRGB
uint8_t hidrgb_get_mode(void); //get software mode
void geekrgb_set_color(int index, uint8_t red, uint8_t green, uint8_t blue); //set one led color
void geekrgb_set_mode(int mode); //set hidrgb software mode, HID_MODE_OPENRGB or HID_MODE_SIGNALRGB
uint8_t geekrgb_get_mode(void); //get software mode

void hidrgb_reload_openrgb_colors(void); //reload openrgb colors
void hidrgb_reload_openrgb_anim(void);//reload openrgb colors in animation
RGB* hidrgb_get_openrgb_colors(void); //get openrgb colors
RGB hidrgb_get_openrgb_color(int index);
void geekrgb_reload_openrgb_colors(void); //reload openrgb colors
void geekrgb_reload_openrgb_anim(void);//reload openrgb colors in animation
RGB* geekrgb_get_openrgb_colors(void); //get openrgb colors
RGB geekrgb_get_openrgb_color(int index);

14 changes: 7 additions & 7 deletions quantum/openrgb.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void openrgb_get_mode_info(void) {
void openrgb_get_led_info(uint8_t *data) {
const uint8_t first_led = data[1];
const uint8_t number_leds = data[2];
const RGB* openrgb_colors = hidrgb_get_openrgb_colors();
const RGB* openrgb_colors = geekrgb_get_openrgb_colors();

raw_hid_buffer[0] = OPENRGB_GET_LED_INFO;

Expand Down Expand Up @@ -330,7 +330,7 @@ void openrgb_set_mode(uint8_t *data) {
return;
}

hidrgb_set_mode(HID_MODE_OPENRGB);
geekrgb_set_mode(HID_MODE_OPENRGB);

if (save == 1) {
rgb_matrix_mode(mode);
Expand All @@ -344,13 +344,13 @@ void openrgb_set_mode(uint8_t *data) {
}

if (rgb_matrix_get_mode() == RGB_MATRIX_GEEKRGB) { // if matrix mode not signalrgb, do not streaming led.
hidrgb_reload_openrgb_anim();
geekrgb_reload_openrgb_anim();
}

raw_hid_buffer[OPENRGB_EPSIZE - 2] = OPENRGB_SUCCESS;
}
void openrgb_direct_mode_set_single_led(uint8_t *data) {
if (hidrgb_get_mode() != HID_MODE_OPENRGB || rgb_matrix_get_mode() != RGB_MATRIX_GEEKRGB) {
if (geekrgb_get_mode() != HID_MODE_OPENRGB || rgb_matrix_get_mode() != RGB_MATRIX_GEEKRGB) {
raw_hid_buffer[OPENRGB_EPSIZE - 2] = OPENRGB_FAILURE;
return;
}
Expand All @@ -367,12 +367,12 @@ void openrgb_direct_mode_set_single_led(uint8_t *data) {
return;
}

hidrgb_set_color(led,r,g,b);
geekrgb_set_color(led,r,g,b);

raw_hid_buffer[OPENRGB_EPSIZE - 2] = OPENRGB_SUCCESS;
}
void openrgb_direct_mode_set_leds(uint8_t *data) {
if (hidrgb_get_mode() != HID_MODE_OPENRGB || rgb_matrix_get_mode() != RGB_MATRIX_GEEKRGB) {
if (geekrgb_get_mode() != HID_MODE_OPENRGB || rgb_matrix_get_mode() != RGB_MATRIX_GEEKRGB) {
return;
}

Expand All @@ -382,6 +382,6 @@ void openrgb_direct_mode_set_leds(uint8_t *data) {
const uint8_t data_idx = i * 4;
const uint8_t color_idx = data[data_idx + 2];

hidrgb_set_color(color_idx,data[data_idx + 3],data[data_idx + 4],data[data_idx + 5]);
geekrgb_set_color(color_idx,data[data_idx + 3],data[data_idx + 4],data[data_idx + 5]);
}
}
4 changes: 2 additions & 2 deletions quantum/rgb_matrix/animations/geek_rgb_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RGB_MATRIX_EFFECT(GEEKRGB)


static void set_openrgb_color(uint8_t led_index, uint8_t val){
RGB rgb = hidrgb_get_openrgb_color(led_index);
RGB rgb = geekrgb_get_openrgb_color(led_index);

# ifdef GEEKRGB_USE_UNIVERSAL_BRIGHTNESS
float brightness = (float) val / UINT8_MAX;
Expand Down Expand Up @@ -49,7 +49,7 @@ bool GEEKRGB(effect_params_t* params){
if (g_geekrgb_anim_playing) g_geekrgb_timer++; //tick counter
}

if (hidrgb_get_mode() == HID_MODE_OPENRGB) {
if (geekrgb_get_mode() == HID_MODE_OPENRGB) {
set_openrgb_colors(params);
}

Expand Down
10 changes: 5 additions & 5 deletions quantum/signalrgb.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void led_streaming(uint8_t *data) //Stream data from HID Packets to Keyboard.
uint8_t index = data[1];
uint8_t numberofleds = data[2];

if (hidrgb_get_mode() != HID_MODE_SIGNALRGB) {
if (geekrgb_get_mode() != HID_MODE_SIGNALRGB) {
return;
}

Expand All @@ -63,21 +63,21 @@ void led_streaming(uint8_t *data) //Stream data from HID Packets to Keyboard.
uint8_t g = data[offset + 1];
uint8_t b = data[offset + 2];

hidrgb_set_color(index + i,r,g,b);
geekrgb_set_color(index + i,r,g,b);
}
}

void signalrgb_mode_enable(void)
{
hidrgb_set_mode(HID_MODE_SIGNALRGB);
geekrgb_set_mode(HID_MODE_SIGNALRGB);
rgb_matrix_mode_noeeprom(RGB_MATRIX_GEEKRGB); //Set RGB Matrix to SignalRGB Compatible Mode
}

void signalrgb_mode_disable(void)
{
hidrgb_set_mode(HID_MODE_OPENRGB); //switch to OpenRGB mode
geekrgb_set_mode(HID_MODE_OPENRGB); //switch to OpenRGB mode
#ifdef OPENRGB_ENABLE
hidrgb_reload_openrgb_anim();
geekrgb_reload_openrgb_anim();
#else
rgb_matrix_reload_from_eeprom(); //Reloading last effect from eeprom
#endif
Expand Down

0 comments on commit 4a89081

Please sign in to comment.