Skip to content

Commit

Permalink
[Keyboard] Add LED matrix and 2 layouts to hub20 (qmk#12505)
Browse files Browse the repository at this point in the history
Co-authored-by: Drashna Jaelre <[email protected]>
  • Loading branch information
peepeetee and drashna authored Jun 20, 2021
1 parent 0504578 commit dc39d90
Show file tree
Hide file tree
Showing 7 changed files with 478 additions and 28 deletions.
76 changes: 52 additions & 24 deletions keyboards/hub20/config.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright 2020 joshajohnson
Copyright 2020 joshajohnson
Copyright 2021 peepeetee
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -41,29 +42,56 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#define RGB_DI_PIN B15
#define RGBLED_NUM 27
#define RGBLIGHT_HUE_STEP 8
#define RGBLIGHT_SAT_STEP 8
#define RGBLIGHT_VAL_STEP 8
#define RGBLIGHT_LIMIT_VAL 255 /* The maximum brightness level */
#define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */
// /*== all animations enable ==*/
#define RGBLIGHT_ANIMATIONS
// /*== or choose animations ==*/
// #define RGBLIGHT_EFFECT_BREATHING
// #define RGBLIGHT_EFFECT_RAINBOW_MOOD
// #define RGBLIGHT_EFFECT_RAINBOW_SWIRL
// #define RGBLIGHT_EFFECT_SNAKE
// #define RGBLIGHT_EFFECT_KNIGHT
// #define RGBLIGHT_EFFECT_CHRISTMAS
// #define RGBLIGHT_EFFECT_STATIC_GRADIENT
// #define RGBLIGHT_EFFECT_RGB_TEST
// #define RGBLIGHT_EFFECT_ALTERNATING
// /*== customize breathing effect ==*/
// /*==== (DEFAULT) use fixed table instead of exp() and sin() ====*/
// #define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256(default) or 128 or 64
// /*==== use exp() and sin() ====*/
// #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1 to 2.7
// #define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0 to 255

#define DRIVER_LED_TOTAL 27
#ifdef RGB_DI_PIN
#define RGBLED_NUM 27
#endif

#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
#define RGB_MATRIX_KEYPRESSES

// This list in in the correct mode order. Next mode is the following line, previous mode is previous line. Loops around.
// #define DISABLE_RGB_MATRIX_SOLID_COLOR // Static single hue, no speed support
#define DISABLE_RGB_MATRIX_ALPHAS_MODS // Static dual hue, speed is hue for secondary hue
//#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN // Static gradient top to bottom, speed controls how much gradient changes
//#define DISABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT // Static gradient top to bottom, speed controls how much gradient changes
//#define DISABLE_RGB_MATRIX_BREATHING // Single hue brightness cycling animation
#define DISABLE_RGB_MATRIX_BAND_SAT // Single hue band fading saturation scrolling left to right
#define DISABLE_RGB_MATRIX_BAND_VAL // Single hue band fading brightness scrolling left to right
#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT // Single hue 3 blade spinning pinwheel fades saturation
#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_VAL // Single hue 3 blade spinning pinwheel fades brightness
#define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT // Single hue spinning spiral fades saturation
#define DISABLE_RGB_MATRIX_BAND_SPIRAL_VAL // Single hue spinning spiral fades brightness
#define DISABLE_RGB_MATRIX_CYCLE_ALL // Full keyboard solid hue cycling through full gradient
//#define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT // Full gradient scrolling left to right
//#define DISABLE_RGB_MATRIX_CYCLE_UP_DOWN // Full gradient scrolling top to bottom
#define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON // Full gradent Chevron shapped scrolling left to right
#define DISABLE_RGB_MATRIX_CYCLE_OUT_IN // Full gradient scrolling out to in
#define DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL // Full dual gradients scrolling out to in
#define DISABLE_RGB_MATRIX_CYCLE_PINWHEEL // Full gradient spinning pinwheel around center of keyboard
#define DISABLE_RGB_MATRIX_CYCLE_SPIRAL // Full gradient spinning spiral around center of keyboard
#define DISABLE_RGB_MATRIX_DUAL_BEACON // Full gradient spinning around center of keyboard
#define DISABLE_RGB_MATRIX_RAINBOW_BEACON // Full tighter gradient spinning around center of keyboard
#define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS // Full dual gradients spinning two halfs of keyboard
//#define DISABLE_RGB_MATRIX_RAINDROPS // Randomly changes a single key's hue
//#define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS // Randomly changes a single key's hue and saturation
// =================================================== Requires RGB_MATRIX_FRAMEBUFFER_EFFECTS =============================================================
// #define DISABLE_RGB_MATRIX_TYPING_HEATMAP // How hot is your WPM!
//#define DISABLE_RGB_MATRIX_DIGITAL_RAIN // That famous computer simulation
// =================================================== RGB_MATRIX_KEYPRESSES OR RGB_MATRIX_KEYRELEASES =====================================================
//#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE // Pulses keys hit to hue & value then fades value out
//#define DISABLE_RGB_MATRIX_SOLID_REACTIVE // Static single hue, pulses keys hit to shifted hue then fades to current hue
#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE // Hue & value pulse near a single key hit then fades value out
#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE // Hue & value pulse near multiple key hits then fades value out
#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS // Hue & value pulse the same column and row of a single key hit then fades value out
#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS // Hue & value pulse the same column and row of multiple key hits then fades value out
#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS // Hue & value pulse away on the same column and row of a single key hit then fades value out
#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS // Hue & value pulse away on the same column and row of multiple key hits then fades value out
#define DISABLE_RGB_MATRIX_SPLASH // Full gradient & value pulse away from a single key hit then fades value out
#define DISABLE_RGB_MATRIX_MULTISPLASH // Full gradient & value pulse away from multiple key hits then fades value out
#define DISABLE_RGB_MATRIX_SOLID_SPLASH // Hue & value pulse away from a single key hit then fades value out
#define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH // Hue & value pulse away from multiple key hits then fades value out

/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
#define DEBOUNCE 5
Expand Down
155 changes: 154 additions & 1 deletion keyboards/hub20/hub20.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2020 joshajohnson
/* Copyright 2020 joshajohnson 2021 peepeetee
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -16,3 +16,156 @@

#include "hub20.h"


#ifdef RGB_MATRIX_ENABLE
led_config_t g_led_config = { {
// Key Matrix to LED Index
{NO_LED,NO_LED,NO_LED,NO_LED},
{ 7, 8, 9, 10},
{ 11, 12, 13, 14},
{ 15, 16, 17, 18},
{ 19, 20, 21, 22},
{ 23, 24, 25, 26}
//todo: assign leds to keys differently for the different layouts
}, {
// LED Index to Physical Position
{ 190, 50}, { 111, 50}, { 35, 50}, {38, 0}, {38, 35}, {186, 35}, {186, 0}, // UNDERGLOW
//todo: underglow location needs to be recalculated. The top row is above row 4, and for now they have the same y value 0
{ 0, 0}, {75, 0}, {150, 0}, {225, 0}, // row 4
{ 0, 16}, {75, 16}, {150, 16}, {225, 16}, // row 3
{ 0, 32}, {75, 32}, {150, 32}, {225, 32}, // row 2
{ 0, 48}, {75, 48}, {150, 48}, {225, 48}, // row 1
{ 0, 64}, {75, 64}, {150, 64}, {225, 64} // row 0

}, {
// LED Index to Flag
LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, // UNDERGLOW
LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, // row 4
LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, // row 3
LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, // row 2
LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, // row 1
LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT // row 0

} };
#endif



// #if LED_MERGE_NUMPAD_LEFT_HANDED_ENTER && LED_MERGE_NUMPAD_RIGHT_HANDED_ZERO
// #error lower left enter conflicts with lower left zero
// #endif

// #if LED_MERGE_NUMPAD_RIGHT_HANDED_ENTER && LED_MERGE_NUMPAD_LEFT_HANDED_ZERO
// #error lower right enter conflicts with lower right zero
// #endif

// /* LAYOUT_left_handed


// * ┌───┬───┐
// * │01 │02 │
// * ┌───┼───┼───┼───┐
// * │10 │11 │12 │13 │
// * ├───┼───┼───┼───┤
// * │ │21 │22 │23 │
// * │20 ├───┼───┼───┤
// * │ │31 │32 │33 │
// * ├───┼───┼───┼───┤
// * │ │41 │42 │43 │
// * │40 ├───┼───┴───┤
// * │ │51 │ 52 │
// * └───┴───┴───────┘
// */

// #ifndef LED_MERGE_NUMPAD_LEFT_HANDED_PLUS //key 20
// #define LED_MERGE_NUMPAD_LEFT_HANDED_PLUS FALSE
// #endif // LED_MERGE_NUMPAD_LEFT_HANDED_PLUS

// #ifndef LED_MERGE_NUMPAD_LEFT_HANDED_ENTER //key 40
// #define LED_MERGE_NUMPAD_LEFT_HANDED_ENTER FALSE
// #endif // LED_MERGE_NUMPAD_LEFT_HANDED_ENTER

// #ifndef LED_MERGE_NUMPAD_LEFT_HANDED_ZERO //key 52
// #define LED_MERGE_NUMPAD_LEFT_HANDED_ZERO FALSE
// #endif // LED_MERGE_NUMPAD_LEFT_HANDED_ZERO


// /* LAYOUT_right_handed


// * ┌───┬───┐
// * │01 │02 │
// * ┌───┼───┼───┼───┐
// * │10 │11 │12 │13 │
// * ├───┼───┼───┼───┤
// * │20 │21 │22 │ │
// * ├───┼───┼───┤23 │
// * │30 │31 │32 │ │
// * ├───┼───┼───┼───┤
// * │40 │41 │42 │ │
// * ├───┴───┼───┤43 │
// * │ 50 │52 │ │
// * └───────┴───┴───┘
// */
// //LOCATION OF bottom row 0 NOT TESTED, WAITING ENDORSEMENT FROM MANUFACTURER

// #ifndef LED_MERGE_NUMPAD_RIGHT_HANDED_PLUS // key 23
// #define LED_MERGE_NUMPAD_RIGHT_HANDED_PLUS FALSE
// #endif // LED_MERGE_NUMPAD_RIGHT_HANDED_PLUS

// #ifndef LED_MERGE_NUMPAD_RIGHT_HANDED_ENTER // key 43
// #define LED_MERGE_NUMPAD_RIGHT_HANDED_ENTER FALSE
// #endif // LED_MERGE_NUMPAD_RIGHT_HANDED_ENTER

// #ifndef LED_MERGE_NUMPAD_RIGHT_HANDED_ZERO // key 50 (confirm with manufacturer)
// #define LED_MERGE_NUMPAD_RIGHT_HANDED_ZERO FALSE
// #endif // LED_MERGE_NUMPAD_RIGHT_HANDED_ZERO

// uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) {
// // Keys here have 2 leds. Here we add the led that is not bound to the key
// // and the default led would be added
// // by the default code that runs after this in rgb_matrix_map_row_column_to_led

// uint8_t counter = 0;

// #if LED_MERGE_NUMPAD_LEFT_HANDED_PLUS //key 20, leds 7 and 11, 7 already bound

// if (row == 2 && column == 0) {
// led_i[counter] = 11;
// counter ++;
// }
// #endif
// #if LED_MERGE_NUMPAD_LEFT_HANDED_ENTER //key 40, leds 19 and 23, 23 already bound
// if (row == 4 && column == 0) {
// led_i[counter] = 23;
// counter ++;
// }
// #endif
// #if LED_MERGE_NUMPAD_LEFT_HANDED_ZERO //key 52, leds 25 and 26, 26 already bound
// if (row == 5 && column == 2) {
// led_i[counter] = 26;
// counter ++;
// }
// #endif

// #if LED_MERGE_NUMPAD_RIGHT_HANDED_PLUS // key 23, led 14 and 18, 14 already bound
// if (row == 2 && column == 3) {
// led_i[counter] = 18;
// counter ++;
// }
// #endif
// #if LED_MERGE_NUMPAD_RIGHT_HANDED_ENTER // key 43, led 22 and 26, 22 already bound
// if (row == 4 && column == 3) {
// led_i[counter] = 26;
// counter ++;
// }
// #endif
// #if LED_MERGE_NUMPAD_RIGHT_HANDED_ZERO // key 50 (confirm with manufacturer)
// // LED 23 and 24, 23(?) already bound
// if (row == 5 && column == 0) {
// led_i[counter] = 24;
// counter ++;
// }
// #endif
// return counter;
// }
90 changes: 90 additions & 0 deletions keyboards/hub20/hub20.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@
* represents the switch matrix.
*/


/* LAYOUT_all
* ┌───┬───┐
* │01 │02 │
* ┌───┼───┼───┼───┐
* │10 │11 │12 │13 │
* ├───┼───┼───┼───┤
* │20 │21 │22 │23 │
* ├───┼───┼───┼───┤
* │30 │31 │32 │33 │
* ├───┼───┼───┼───┤
* │40 │41 │42 │43 │
* ├───┼───┼───┼───┤
* │50 │51 │52 │53 │
* └───┴───┴───┴───┘
*/
#define LAYOUT_all( \
K01, K02, \
K10, K11, K12, K13, \
Expand All @@ -45,3 +63,75 @@
{ K40, K41, K42, K43, }, \
{ K50, K51, K52, K53, }, \
}

/* LAYOUT_left_handed
* ┌───┬───┐
* │01 │02 │
* ┌───┼───┼───┼───┐
* │10 │11 │12 │13 │
* ├───┼───┼───┼───┤
* │ │21 │22 │23 │
* │20 ├───┼───┼───┤
* │ │31 │32 │33 │
* ├───┼───┼───┼───┤
* │ │41 │42 │43 │
* │40 ├───┼───┴───┤
* │ │51 │ 52 │
* └───┴───┴───────┘
*/
#define LAYOUT_left_handed( \
K01, K02, \
K10, K11, K12, K13, \
K21, K22, K23, \
K20, K31, K32, K33, \
K41, K42, K43, \
K40, K51, K52 \
) \
{ \
{ ___, K01, K02, ___, }, \
{ K10, K11, K12, K13, }, \
{ K20, K21, K22, K23, }, \
{ ___, K31, K32, K33, }, \
{ K40, K41, K42, K43, }, \
{ ___, K51, K52, ___, }, \
}


/* LAYOUT_right_handed
* ┌───┬───┐
* │01 │02 │
* ┌───┼───┼───┼───┐
* │10 │11 │12 │13 │
* ├───┼───┼───┼───┤
* │20 │21 │22 │ │
* ├───┼───┼───┤23 │
* │30 │31 │32 │ │
* ├───┼───┼───┼───┤
* │40 │41 │42 │ │
* ├───┴───┼───┤43 │
* │ 50(not sure, confirm) │52 │ │
* └───────┴───┴───┘
*/
//NOT TESTED, WAITING ENDORSEMENT FROM MANUFACTURER
#define LAYOUT_right_handed( \
K01, K02, \
K10, K11, K12, K13, \
K20, K21, K22, \
K30, K31, K32, K23, \
K40, K41, K42, \
K50, K52, K43 \
) \
{ \
{ ___, K01, K02, ___, }, \
{ K10, K11, K12, K13, }, \
{ K20, K21, K22, K23, }, \
{ K30, K31, K32, ___, }, \
{ K40, K41, K42, K43, }, \
{ K50, ___, K52, ___, }, \
}


Loading

0 comments on commit dc39d90

Please sign in to comment.