Compare commits

...

1 Commits

Author SHA1 Message Date
Erez Zukerman 6652f5dbc4 LED test
6 years ago

@ -11,7 +11,10 @@ enum custom_keycodes {
PLACEHOLDER = SAFE_RANGE, // can always be here PLACEHOLDER = SAFE_RANGE, // can always be here
EPRM, EPRM,
VRSN, VRSN,
RGB_SLD RGB_SLD,
RED,
GRN,
BLU
}; };
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
@ -49,9 +52,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_HOME, KC_HOME,
KC_SPC,KC_BSPC,KC_END, KC_SPC,KC_BSPC,KC_END,
// right hand // right hand
KC_RGHT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_RGHT, KC_6, KC_7, KC_8, KC_9, KC_0, RED,
TG(SYMB), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS, TG(SYMB), KC_Y, KC_U, KC_I, KC_O, KC_P, GRN,
KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN),GUI_T(KC_QUOT), KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN),BLU,
MEH_T(KC_NO),KC_N, KC_M, KC_COMM,KC_DOT, CTL_T(KC_SLSH), KC_RSFT, MEH_T(KC_NO),KC_N, KC_M, KC_COMM,KC_DOT, CTL_T(KC_SLSH), KC_RSFT,
KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, KC_FN1, KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, KC_FN1,
KC_LALT, CTL_T(KC_ESC), KC_LALT, CTL_T(KC_ESC),
@ -168,6 +171,24 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
bool process_record_user(uint16_t keycode, keyrecord_t *record) { bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) { switch (keycode) {
// dynamically generate these. // dynamically generate these.
case RED:
if (record->event.pressed) {
rgb_matrix_set_color_all(255, 0, 0);
}
return false;
break;
case GRN:
if (record->event.pressed) {
rgb_matrix_set_color_all(0, 255, 0);
}
return false;
break;
case BLU:
if (record->event.pressed) {
rgb_matrix_set_color_all(0, 0, 255);
}
return false;
break;
case EPRM: case EPRM:
if (record->event.pressed) { if (record->event.pressed) {
eeconfig_init(); eeconfig_init();

@ -150,26 +150,27 @@ void rgb_matrix_set_suspend_state(bool state) {
void rgb_matrix_test(void) { void rgb_matrix_test(void) {
// Mask out bits 4 and 5 // Mask out bits 4 and 5
// This 2-bit value will stay the same for 16 ticks. // This 2-bit value will stay the same for 16 ticks.
switch ( (g_tick & 0x30) >> 4 ) uint32_t factor = 10;
switch ( (g_tick & (0b11 << factor)) >> factor )
{ {
case 0: case 0:
{ {
rgb_matrix_set_color_all( 20, 0, 0 ); rgb_matrix_set_color_all( 255, 0, 0 );
break; break;
} }
case 1: case 1:
{ {
rgb_matrix_set_color_all( 0, 20, 0 ); rgb_matrix_set_color_all( 0, 255, 0 );
break; break;
} }
case 2: case 2:
{ {
rgb_matrix_set_color_all( 0, 0, 20 ); rgb_matrix_set_color_all( 0, 0, 255 );
break; break;
} }
case 3: case 3:
{ {
rgb_matrix_set_color_all( 20, 20, 20 ); rgb_matrix_set_color_all( 255, 255, 255 );
break; break;
} }
} }
@ -217,7 +218,7 @@ void rgb_matrix_single_LED_test(void) {
} }
// All LEDs off // All LEDs off
void rgb_matrix_all_off(void) { void rgb_matrix_all_off(void) {
rgb_matrix_set_color_all( 0, 0, 0 ); rgb_matrix_set_color_all( 0, 0, 0 );
} }
@ -243,7 +244,7 @@ void rgb_matrix_solid_reactive(void) {
// alphas = color1, mods = color2 // alphas = color1, mods = color2
void rgb_matrix_alphas_mods(void) { void rgb_matrix_alphas_mods(void) {
RGB rgb1 = hsv_to_rgb( (HSV){ .h = rgb_matrix_config.hue, .s = rgb_matrix_config.sat, .v = rgb_matrix_config.val } ); RGB rgb1 = hsv_to_rgb( (HSV){ .h = rgb_matrix_config.hue, .s = rgb_matrix_config.sat, .v = rgb_matrix_config.val } );
RGB rgb2 = hsv_to_rgb( (HSV){ .h = (rgb_matrix_config.hue + 180) % 360, .s = rgb_matrix_config.sat, .v = rgb_matrix_config.val } ); RGB rgb2 = hsv_to_rgb( (HSV){ .h = (rgb_matrix_config.hue + 180) % 360, .s = rgb_matrix_config.sat, .v = rgb_matrix_config.val } );
@ -577,10 +578,10 @@ void rgb_matrix_custom(void) {
} }
void rgb_matrix_task(void) { void rgb_matrix_task(void) {
static uint8_t toggle_enable_last = 255; // static uint8_t toggle_enable_last = 255;
if (!rgb_matrix_config.enable) { if (!rgb_matrix_config.enable) {
rgb_matrix_all_off(); rgb_matrix_all_off();
toggle_enable_last = rgb_matrix_config.enable; // toggle_enable_last = rgb_matrix_config.enable;
return; return;
} }
// delay 1 second before driving LEDs or doing anything else // delay 1 second before driving LEDs or doing anything else
@ -619,50 +620,61 @@ void rgb_matrix_task(void) {
// Keep track of the effect used last time, // Keep track of the effect used last time,
// detect change in effect, so each effect can // detect change in effect, so each effect can
// have an optional initialization. // have an optional initialization.
static uint8_t effect_last = 255; // static uint8_t effect_last = 255;
bool initialize = (effect != effect_last) || (rgb_matrix_config.enable != toggle_enable_last); // bool initialize = (effect != effect_last) || (rgb_matrix_config.enable != toggle_enable_last);
effect_last = effect; // effect_last = effect;
toggle_enable_last = rgb_matrix_config.enable; // toggle_enable_last = rgb_matrix_config.enable;
// this gets ticked at 20 Hz. // this gets ticked at 20 Hz.
// each effect can opt to do calculations // each effect can opt to do calculations
// and/or request PWM buffer updates. // and/or request PWM buffer updates.
switch ( effect ) { switch ( effect ) {
case RGB_MATRIX_SOLID_COLOR: case RGB_MATRIX_SOLID_COLOR:
rgb_matrix_solid_color(); rgb_matrix_test();
break; break;
case RGB_MATRIX_ALPHAS_MODS: case RGB_MATRIX_ALPHAS_MODS:
rgb_matrix_alphas_mods(); rgb_matrix_test();
// rgb_matrix_alphas_mods();
break; break;
case RGB_MATRIX_DUAL_BEACON: case RGB_MATRIX_DUAL_BEACON:
rgb_matrix_dual_beacon(); rgb_matrix_test();
// rgb_matrix_dual_beacon();
break; break;
case RGB_MATRIX_GRADIENT_UP_DOWN: case RGB_MATRIX_GRADIENT_UP_DOWN:
rgb_matrix_gradient_up_down(); rgb_matrix_test();
// rgb_matrix_gradient_up_down();
break; break;
case RGB_MATRIX_RAINDROPS: case RGB_MATRIX_RAINDROPS:
rgb_matrix_raindrops( initialize ); rgb_matrix_test();
// rgb_matrix_raindrops( initialize );
break; break;
case RGB_MATRIX_CYCLE_ALL: case RGB_MATRIX_CYCLE_ALL:
rgb_matrix_cycle_all(); rgb_matrix_test();
// rgb_matrix_cycle_all();
break; break;
case RGB_MATRIX_CYCLE_LEFT_RIGHT: case RGB_MATRIX_CYCLE_LEFT_RIGHT:
rgb_matrix_cycle_left_right(); rgb_matrix_test();
// rgb_matrix_cycle_left_right();
break; break;
case RGB_MATRIX_CYCLE_UP_DOWN: case RGB_MATRIX_CYCLE_UP_DOWN:
rgb_matrix_cycle_up_down(); rgb_matrix_test();
// rgb_matrix_cycle_up_down();
break; break;
case RGB_MATRIX_RAINBOW_BEACON: case RGB_MATRIX_RAINBOW_BEACON:
rgb_matrix_rainbow_beacon(); rgb_matrix_test();
// rgb_matrix_rainbow_beacon();
break; break;
case RGB_MATRIX_RAINBOW_PINWHEELS: case RGB_MATRIX_RAINBOW_PINWHEELS:
rgb_matrix_rainbow_pinwheels(); rgb_matrix_test();
// rgb_matrix_rainbow_pinwheels();
break; break;
case RGB_MATRIX_RAINBOW_MOVING_CHEVRON: case RGB_MATRIX_RAINBOW_MOVING_CHEVRON:
rgb_matrix_rainbow_moving_chevron(); rgb_matrix_test();
// rgb_matrix_rainbow_moving_chevron();
break; break;
case RGB_MATRIX_JELLYBEAN_RAINDROPS: case RGB_MATRIX_JELLYBEAN_RAINDROPS:
rgb_matrix_jellybean_raindrops( initialize ); rgb_matrix_test();
// rgb_matrix_jellybean_raindrops( initialize );
break; break;
#ifdef RGB_MATRIX_KEYPRESSES #ifdef RGB_MATRIX_KEYPRESSES
case RGB_MATRIX_SOLID_REACTIVE: case RGB_MATRIX_SOLID_REACTIVE:

@ -86,6 +86,7 @@ enum rgb_matrix_effects {
}; };
void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ); void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue );
// This runs after another backlight effect and replaces // This runs after another backlight effect and replaces
// colors already set // colors already set

Loading…
Cancel
Save