diff options
author | Sean Dwyer <sean.dwyer@gmail.com> | 2018-11-06 11:54:53 -0800 |
---|---|---|
committer | Drashna Jaelre <drashna@live.com> | 2018-11-06 11:54:53 -0800 |
commit | 63e212c0b78be664785433c11cd728f15f50cd6a (patch) | |
tree | f20c10f2e0b3201d003e664bcd80f481c9982047 | |
parent | 388df5359b913eaf1ce6fb0ef624e430ad010ea5 (diff) | |
download | qmk_firmware-63e212c0b78be664785433c11cd728f15f50cd6a.tar.gz qmk_firmware-63e212c0b78be664785433c11cd728f15f50cd6a.zip |
Add localized LED flash effect on keypress to Massdrop ALT (#4340)
-rw-r--r-- | keyboards/massdrop/alt/keymaps/reywood/keymap.c | 195 | ||||
-rw-r--r-- | keyboards/massdrop/alt/keymaps/reywood/rgb_matrix_user.c | 193 | ||||
-rw-r--r-- | keyboards/massdrop/alt/keymaps/reywood/rgb_matrix_user.h | 3 | ||||
-rw-r--r-- | keyboards/massdrop/alt/keymaps/reywood/rules.mk | 34 | ||||
-rw-r--r-- | tmk_core/protocol/arm_atsam/led_matrix.c | 14 | ||||
-rw-r--r-- | tmk_core/protocol/arm_atsam/led_matrix.h | 3 |
6 files changed, 438 insertions, 4 deletions
diff --git a/keyboards/massdrop/alt/keymaps/reywood/keymap.c b/keyboards/massdrop/alt/keymaps/reywood/keymap.c new file mode 100644 index 000000000..8b69f0e8e --- /dev/null +++ b/keyboards/massdrop/alt/keymaps/reywood/keymap.c | |||
@@ -0,0 +1,195 @@ | |||
1 | #include QMK_KEYBOARD_H | ||
2 | #include "rgb_matrix_user.h" | ||
3 | |||
4 | enum alt_keycodes { | ||
5 | L_BRI = SAFE_RANGE, //LED Brightness Increase | ||
6 | L_BRD, //LED Brightness Decrease | ||
7 | L_PTN, //LED Pattern Select Next | ||
8 | L_PTP, //LED Pattern Select Previous | ||
9 | L_PSI, //LED Pattern Speed Increase | ||
10 | L_PSD, //LED Pattern Speed Decrease | ||
11 | L_T_MD, //LED Toggle Mode | ||
12 | L_T_ONF, //LED Toggle On / Off | ||
13 | L_ON, //LED On | ||
14 | L_OFF, //LED Off | ||
15 | L_T_BR, //LED Toggle Breath Effect | ||
16 | L_T_PTD, //LED Toggle Scrolling Pattern Direction | ||
17 | U_T_AUTO, //USB Extra Port Toggle Auto Detect / Always Active | ||
18 | U_T_AGCR, //USB Toggle Automatic GCR control | ||
19 | DBG_TOG, //DEBUG Toggle On / Off | ||
20 | DBG_MTRX, //DEBUG Toggle Matrix Prints | ||
21 | DBG_KBD, //DEBUG Toggle Keyboard Prints | ||
22 | DBG_MOU, //DEBUG Toggle Mouse Prints | ||
23 | MD_BOOT, //Restart into bootloader after hold timeout | ||
24 | }; | ||
25 | |||
26 | #define TG_NKRO MAGIC_TOGGLE_NKRO //Toggle 6KRO / NKRO mode | ||
27 | #define ______ KC_TRNS | ||
28 | |||
29 | keymap_config_t keymap_config; | ||
30 | |||
31 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
32 | [0] = LAYOUT( | ||
33 | KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_DEL, \ | ||
34 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_HOME, \ | ||
35 | KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP, \ | ||
36 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN, \ | ||
37 | KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, MO(1), KC_LEFT, KC_DOWN, KC_RGHT \ | ||
38 | ), | ||
39 | [1] = LAYOUT( | ||
40 | KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, KC_MUTE, \ | ||
41 | _______, _______, _______, KC_UP, _______, _______, _______, U_T_AUTO,U_T_AGCR,_______, KC_PSCR, KC_SLCK, KC_PAUS, _______, KC_END, \ | ||
42 | _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
43 | _______, _______, _______, _______, _______, MD_BOOT, TG_NKRO, _______, _______, _______, _______, _______, KC_VOLU, _______, \ | ||
44 | _______, _______, _______, KC_MPLY, MO(2), _______, KC_MRWD, KC_VOLD, KC_MFFD \ | ||
45 | ), | ||
46 | [2] = LAYOUT( | ||
47 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
48 | L_T_BR, L_PSD, L_BRI, L_PSI, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
49 | L_T_PTD, L_PTP, L_BRD, L_PTN, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
50 | _______, L_T_MD, L_T_ONF, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
51 | _______, _______, _______, _______, _______, _______, _______, _______, _______ \ | ||
52 | ), | ||
53 | }; | ||
54 | |||
55 | const uint16_t PROGMEM fn_actions[] = { | ||
56 | |||
57 | }; | ||
58 | |||
59 | // Runs just one time when the keyboard initializes. | ||
60 | void matrix_init_user(void) { | ||
61 | }; | ||
62 | |||
63 | // Runs constantly in the background, in a loop. | ||
64 | void matrix_scan_user(void) { | ||
65 | }; | ||
66 | |||
67 | #define MODS_SHIFT (keyboard_report->mods & MOD_BIT(KC_LSHIFT) || keyboard_report->mods & MOD_BIT(KC_RSHIFT)) | ||
68 | #define MODS_CTRL (keyboard_report->mods & MOD_BIT(KC_LCTL) || keyboard_report->mods & MOD_BIT(KC_RCTRL)) | ||
69 | #define MODS_ALT (keyboard_report->mods & MOD_BIT(KC_LALT) || keyboard_report->mods & MOD_BIT(KC_RALT)) | ||
70 | |||
71 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
72 | static uint32_t key_timer; | ||
73 | |||
74 | rgb_matrix_record_key_press(record); | ||
75 | |||
76 | switch (keycode) { | ||
77 | case L_BRI: | ||
78 | if (record->event.pressed) { | ||
79 | if (LED_GCR_STEP > LED_GCR_MAX - gcr_desired) gcr_desired = LED_GCR_MAX; | ||
80 | else gcr_desired += LED_GCR_STEP; | ||
81 | if (led_animation_breathing) gcr_breathe = gcr_desired; | ||
82 | } | ||
83 | return false; | ||
84 | case L_BRD: | ||
85 | if (record->event.pressed) { | ||
86 | if (LED_GCR_STEP > gcr_desired) gcr_desired = 0; | ||
87 | else gcr_desired -= LED_GCR_STEP; | ||
88 | if (led_animation_breathing) gcr_breathe = gcr_desired; | ||
89 | } | ||
90 | return false; | ||
91 | case L_PTN: | ||
92 | if (record->event.pressed) { | ||
93 | if (led_animation_id == led_setups_count - 1) led_animation_id = 0; | ||
94 | else led_animation_id++; | ||
95 | } | ||
96 | return false; | ||
97 | case L_PTP: | ||
98 | if (record->event.pressed) { | ||
99 | if (led_animation_id == 0) led_animation_id = led_setups_count - 1; | ||
100 | else led_animation_id--; | ||
101 | } | ||
102 | return false; | ||
103 | case L_PSI: | ||
104 | if (record->event.pressed) { | ||
105 | led_animation_speed += ANIMATION_SPEED_STEP; | ||
106 | } | ||
107 | return false; | ||
108 | case L_PSD: | ||
109 | if (record->event.pressed) { | ||
110 | led_animation_speed -= ANIMATION_SPEED_STEP; | ||
111 | if (led_animation_speed < 0) led_animation_speed = 0; | ||
112 | } | ||
113 | return false; | ||
114 | case L_T_MD: | ||
115 | if (record->event.pressed) { | ||
116 | led_lighting_mode++; | ||
117 | if (led_lighting_mode > LED_MODE_MAX_INDEX) led_lighting_mode = LED_MODE_NORMAL; | ||
118 | } | ||
119 | return false; | ||
120 | case L_T_ONF: | ||
121 | if (record->event.pressed) { | ||
122 | led_enabled = !led_enabled; | ||
123 | I2C3733_Control_Set(led_enabled); | ||
124 | } | ||
125 | return false; | ||
126 | case L_ON: | ||
127 | if (record->event.pressed) { | ||
128 | led_enabled = 1; | ||
129 | I2C3733_Control_Set(led_enabled); | ||
130 | } | ||
131 | return false; | ||
132 | case L_OFF: | ||
133 | if (record->event.pressed) { | ||
134 | led_enabled = 0; | ||
135 | I2C3733_Control_Set(led_enabled); | ||
136 | } | ||
137 | return false; | ||
138 | case L_T_BR: | ||
139 | if (record->event.pressed) { | ||
140 | led_animation_breathing = !led_animation_breathing; | ||
141 | if (led_animation_breathing) { | ||
142 | gcr_breathe = gcr_desired; | ||
143 | led_animation_breathe_cur = BREATHE_MIN_STEP; | ||
144 | breathe_dir = 1; | ||
145 | } | ||
146 | } | ||
147 | return false; | ||
148 | case L_T_PTD: | ||
149 | if (record->event.pressed) { | ||
150 | led_animation_direction = !led_animation_direction; | ||
151 | } | ||
152 | return false; | ||
153 | case U_T_AUTO: | ||
154 | if (record->event.pressed && MODS_SHIFT && MODS_CTRL) { | ||
155 | TOGGLE_FLAG_AND_PRINT(usb_extra_manual, "USB extra port manual mode"); | ||
156 | } | ||
157 | return false; | ||
158 | case U_T_AGCR: | ||
159 | if (record->event.pressed && MODS_SHIFT && MODS_CTRL) { | ||
160 | TOGGLE_FLAG_AND_PRINT(usb_gcr_auto, "USB GCR auto mode"); | ||
161 | } | ||
162 | return false; | ||
163 | case DBG_TOG: | ||
164 | if (record->event.pressed) { | ||
165 | TOGGLE_FLAG_AND_PRINT(debug_enable, "Debug mode"); | ||
166 | } | ||
167 | return false; | ||
168 | case DBG_MTRX: | ||
169 | if (record->event.pressed) { | ||
170 | TOGGLE_FLAG_AND_PRINT(debug_matrix, "Debug matrix"); | ||
171 | } | ||
172 | return false; | ||
173 | case DBG_KBD: | ||
174 | if (record->event.pressed) { | ||
175 | TOGGLE_FLAG_AND_PRINT(debug_keyboard, "Debug keyboard"); | ||
176 | } | ||
177 | return false; | ||
178 | case DBG_MOU: | ||
179 | if (record->event.pressed) { | ||
180 | TOGGLE_FLAG_AND_PRINT(debug_mouse, "Debug mouse"); | ||
181 | } | ||
182 | return false; | ||
183 | case MD_BOOT: | ||
184 | if (record->event.pressed) { | ||
185 | key_timer = timer_read32(); | ||
186 | } else { | ||
187 | if (timer_elapsed32(key_timer) >= 500) { | ||
188 | reset_keyboard(); | ||
189 | } | ||
190 | } | ||
191 | return false; | ||
192 | default: | ||
193 | return true; //Process all other keycodes normally | ||
194 | } | ||
195 | } | ||
diff --git a/keyboards/massdrop/alt/keymaps/reywood/rgb_matrix_user.c b/keyboards/massdrop/alt/keymaps/reywood/rgb_matrix_user.c new file mode 100644 index 000000000..36131e202 --- /dev/null +++ b/keyboards/massdrop/alt/keymaps/reywood/rgb_matrix_user.c | |||
@@ -0,0 +1,193 @@ | |||
1 | #include "quantum.h" | ||
2 | #include "led_matrix.h" | ||
3 | |||
4 | extern issi3733_led_t *led_cur; | ||
5 | extern uint8_t led_per_run; | ||
6 | extern issi3733_led_t *lede; | ||
7 | extern issi3733_led_t led_map[]; | ||
8 | |||
9 | static uint16_t last_boost_update; | ||
10 | static uint8_t led_boosts[ISSI3733_LED_COUNT]; | ||
11 | static uint8_t led_boost_index; | ||
12 | static uint8_t led_cur_index; | ||
13 | |||
14 | #define LED_BOOST_REFRESH_INTERVAL_IN_MS 40 | ||
15 | #define LED_BOOST_DECAY 0.7 | ||
16 | #define LED_BOOST_PROPAGATE 0.5 | ||
17 | #define LED_BOOST_PEAK 100 | ||
18 | |||
19 | #define MIN_RGB 0x050008 | ||
20 | #define MIN_R (MIN_RGB >> 16 & 0xff) | ||
21 | #define MIN_G (MIN_RGB >> 8 & 0xff) | ||
22 | #define MIN_B (MIN_RGB & 0xff) | ||
23 | |||
24 | #define MAX_RGB 0xc26eff | ||
25 | #define MAX_R (MAX_RGB >> 16 & 0xff) | ||
26 | #define MAX_G (MAX_RGB >> 8 & 0xff) | ||
27 | #define MAX_B (MAX_RGB & 0xff) | ||
28 | |||
29 | #define UNDERGLOW_RGB 0x4f002e | ||
30 | #define UNDERGLOW_R (UNDERGLOW_RGB >> 16 & 0xff) | ||
31 | #define UNDERGLOW_G (UNDERGLOW_RGB >> 8 & 0xff) | ||
32 | #define UNDERGLOW_B (UNDERGLOW_RGB & 0xff) | ||
33 | |||
34 | #define UNDERGLOW_SCAN_CODE 255 | ||
35 | |||
36 | #define max(a, b) (((a) > (b)) ? (a) : (b)) | ||
37 | |||
38 | #define __ -1 | ||
39 | static const uint8_t KEY_TO_LED_MAP[MATRIX_ROWS][MATRIX_COLS] = { | ||
40 | { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, | ||
41 | {15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29}, | ||
42 | {30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, __, 42, 43}, | ||
43 | {44, __, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57}, | ||
44 | {58, 59, 60, __, __, __, 61, __, __, __, 62, 63, 64, 65, 66}, | ||
45 | }; | ||
46 | |||
47 | #define KEY_LED_COUNT 67 | ||
48 | #define KP(c, r) { .col = c, .row = r } // shorthand for keypos_t | ||
49 | static const keypos_t LED_TO_KEY_MAP[KEY_LED_COUNT] = { | ||
50 | KP(0, 0), KP(1, 0), KP(2, 0), KP(3, 0), KP(4, 0), KP(5, 0), KP(6, 0), KP(7, 0), KP(8, 0), KP(9, 0), KP(10, 0), KP(11, 0), KP(12, 0), KP(13, 0), KP(14, 0), | ||
51 | KP(0, 1), KP(1, 1), KP(2, 1), KP(3, 1), KP(4, 1), KP(5, 1), KP(6, 1), KP(7, 1), KP(8, 1), KP(9, 1), KP(10, 1), KP(11, 1), KP(12, 1), KP(13, 1), KP(14, 1), | ||
52 | KP(0, 2), KP(1, 2), KP(2, 2), KP(3, 2), KP(4, 2), KP(5, 2), KP(6, 2), KP(7, 2), KP(8, 2), KP(9, 2), KP(10, 2), KP(11, 2), KP(13, 2), KP(14, 2), | ||
53 | KP(0, 3), KP(2, 3), KP(3, 3), KP(4, 3), KP(5, 3), KP(6, 3), KP(7, 3), KP(8, 3), KP(9, 3), KP(10, 3), KP(11, 3), KP(12, 3), KP(13, 3), KP(14, 3), | ||
54 | KP(0, 4), KP(1, 4), KP(2, 4), KP(6, 4), KP(10, 4), KP(11, 4), KP(12, 4), KP(13, 4), KP(14, 4), | ||
55 | }; | ||
56 | |||
57 | |||
58 | static void update_led_boosts(void); | ||
59 | static void update_led_cur_rgb_values(void); | ||
60 | static void set_nearest_led_to_max(uint8_t col, uint8_t row); | ||
61 | static uint8_t calculate_new_color_component_value(uint8_t max, uint8_t min); | ||
62 | static void calculate_new_led_boosts(uint8_t new_led_boosts[]); | ||
63 | static uint8_t calculate_new_led_boost_at(int index); | ||
64 | static uint8_t get_propagated_boost_from_neighbors(int led_position); | ||
65 | static uint8_t get_led_boost_at_keypos(uint8_t row, uint8_t col); | ||
66 | static void set_new_led_boosts(uint8_t* new_led_boosts); | ||
67 | static uint8_t map_key_position_to_led_index(uint8_t col, uint8_t row); | ||
68 | |||
69 | |||
70 | void rgb_matrix_init_user(void) { | ||
71 | for (int i = 0; i < ISSI3733_LED_COUNT; i++) { | ||
72 | led_boosts[i] = 0; | ||
73 | } | ||
74 | last_boost_update = timer_read(); | ||
75 | led_boost_index = 0; | ||
76 | led_cur_index = 0; | ||
77 | } | ||
78 | |||
79 | void led_matrix_run(void) { | ||
80 | uint8_t led_this_run = 0; | ||
81 | |||
82 | if (led_cur == 0) { //Denotes start of new processing cycle in the case of chunked processing | ||
83 | led_cur = led_map; | ||
84 | led_cur_index = 0; | ||
85 | } | ||
86 | update_led_boosts(); | ||
87 | |||
88 | while (led_cur < lede && led_this_run < led_per_run) { | ||
89 | update_led_cur_rgb_values(); | ||
90 | |||
91 | led_cur++; | ||
92 | led_cur_index++; | ||
93 | led_this_run++; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | void rgb_matrix_record_key_press(keyrecord_t *record) { | ||
98 | if (record->event.pressed) { | ||
99 | keypos_t key = record->event.key; | ||
100 | set_nearest_led_to_max(key.col, key.row); | ||
101 | } | ||
102 | } | ||
103 | |||
104 | |||
105 | static void update_led_boosts(void) { | ||
106 | if (timer_elapsed(last_boost_update) > LED_BOOST_REFRESH_INTERVAL_IN_MS) { | ||
107 | last_boost_update = timer_read(); | ||
108 | |||
109 | uint8_t new_led_boosts[ISSI3733_LED_COUNT]; | ||
110 | calculate_new_led_boosts(new_led_boosts); | ||
111 | set_new_led_boosts(new_led_boosts); | ||
112 | } | ||
113 | } | ||
114 | |||
115 | static void update_led_cur_rgb_values(void) { | ||
116 | if (led_cur->scan == UNDERGLOW_SCAN_CODE) { | ||
117 | *led_cur->rgb.r = UNDERGLOW_R; | ||
118 | *led_cur->rgb.g = UNDERGLOW_G; | ||
119 | *led_cur->rgb.b = UNDERGLOW_B; | ||
120 | } else { | ||
121 | *led_cur->rgb.r = calculate_new_color_component_value(MAX_R, MIN_R); | ||
122 | *led_cur->rgb.g = calculate_new_color_component_value(MAX_G, MIN_G); | ||
123 | *led_cur->rgb.b = calculate_new_color_component_value(MAX_B, MIN_B); | ||
124 | } | ||
125 | } | ||
126 | |||
127 | static void set_nearest_led_to_max(uint8_t col, uint8_t row) { | ||
128 | uint8_t led_index = map_key_position_to_led_index(col, row); | ||
129 | if (led_index >= 0 && led_index < ISSI3733_LED_COUNT) { | ||
130 | led_boosts[led_index] = LED_BOOST_PEAK; | ||
131 | } | ||
132 | } | ||
133 | |||
134 | static uint8_t calculate_new_color_component_value(uint8_t max, uint8_t min) { | ||
135 | uint8_t current_boost = led_boosts[led_cur_index]; | ||
136 | return (float)(max - min) * current_boost / LED_BOOST_PEAK + min; | ||
137 | } | ||
138 | |||
139 | static void calculate_new_led_boosts(uint8_t new_led_boosts[]) { | ||
140 | for (int i = 0; i < ISSI3733_LED_COUNT; i++) { | ||
141 | new_led_boosts[i] = calculate_new_led_boost_at(i); | ||
142 | } | ||
143 | } | ||
144 | |||
145 | static uint8_t calculate_new_led_boost_at(int index) { | ||
146 | uint8_t decayed_boost = led_boosts[index] * LED_BOOST_DECAY; | ||
147 | uint8_t propagated_boost = get_propagated_boost_from_neighbors(index); | ||
148 | uint8_t new_boost = (propagated_boost > decayed_boost) ? propagated_boost : decayed_boost; | ||
149 | if (new_boost > LED_BOOST_PEAK) { | ||
150 | new_boost = LED_BOOST_PEAK; | ||
151 | } | ||
152 | return new_boost; | ||
153 | } | ||
154 | |||
155 | static uint8_t get_propagated_boost_from_neighbors(int led_position) { | ||
156 | if (led_position < 0 || led_position >= KEY_LED_COUNT) { | ||
157 | return 0; | ||
158 | } | ||
159 | keypos_t led_keypos = LED_TO_KEY_MAP[led_position]; | ||
160 | uint8_t top_boost = get_led_boost_at_keypos(led_keypos.row - 1, led_keypos.col); | ||
161 | uint8_t bottom_boost = get_led_boost_at_keypos(led_keypos.row + 1, led_keypos.col); | ||
162 | uint8_t left_boost = get_led_boost_at_keypos(led_keypos.row, led_keypos.col - 1); | ||
163 | uint8_t right_boost = get_led_boost_at_keypos(led_keypos.row, led_keypos.col + 1); | ||
164 | uint8_t max_boost = max(max(top_boost, bottom_boost), max(left_boost, right_boost)); | ||
165 | if (max_boost > LED_BOOST_PEAK) { | ||
166 | max_boost = LED_BOOST_PEAK; | ||
167 | } | ||
168 | return max_boost * LED_BOOST_PROPAGATE; | ||
169 | } | ||
170 | |||
171 | static uint8_t get_led_boost_at_keypos(uint8_t row, uint8_t col) { | ||
172 | if (row < 0 || row >= MATRIX_ROWS || col < 0 || col >= MATRIX_COLS) { | ||
173 | return 0; | ||
174 | } | ||
175 | uint8_t led_index = KEY_TO_LED_MAP[row][col]; | ||
176 | if (led_index < 0) { | ||
177 | return 0; | ||
178 | } | ||
179 | return led_boosts[led_index]; | ||
180 | } | ||
181 | |||
182 | static void set_new_led_boosts(uint8_t* new_led_boosts) { | ||
183 | for (int i = 0; i < ISSI3733_LED_COUNT; i++) { | ||
184 | led_boosts[i] = new_led_boosts[i]; | ||
185 | } | ||
186 | } | ||
187 | |||
188 | static uint8_t map_key_position_to_led_index(uint8_t col, uint8_t row) { | ||
189 | if (row >= 0 && row < MATRIX_ROWS && col >= 0 && col < MATRIX_COLS) { | ||
190 | return KEY_TO_LED_MAP[row][col]; | ||
191 | } | ||
192 | return -1; | ||
193 | } | ||
diff --git a/keyboards/massdrop/alt/keymaps/reywood/rgb_matrix_user.h b/keyboards/massdrop/alt/keymaps/reywood/rgb_matrix_user.h new file mode 100644 index 000000000..4ffd202e9 --- /dev/null +++ b/keyboards/massdrop/alt/keymaps/reywood/rgb_matrix_user.h | |||
@@ -0,0 +1,3 @@ | |||
1 | #pragma once | ||
2 | |||
3 | void rgb_matrix_record_key_press(keyrecord_t *record); | ||
diff --git a/keyboards/massdrop/alt/keymaps/reywood/rules.mk b/keyboards/massdrop/alt/keymaps/reywood/rules.mk new file mode 100644 index 000000000..b5b961a0f --- /dev/null +++ b/keyboards/massdrop/alt/keymaps/reywood/rules.mk | |||
@@ -0,0 +1,34 @@ | |||
1 | # project specific files | ||
2 | SRC = led_programs.c | ||
3 | SRC += matrix.c | ||
4 | SRC += rgb_matrix_user.c | ||
5 | |||
6 | #For platform and packs | ||
7 | ARM_ATSAM = SAMD51J18A | ||
8 | MCU = cortex-m4 | ||
9 | |||
10 | CUSTOM_MATRIX = yes | ||
11 | |||
12 | # Build Options | ||
13 | # comment out to disable the options. | ||
14 | # | ||
15 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) | ||
16 | MOUSEKEY_ENABLE = no # Mouse keys(+4700) | ||
17 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | ||
18 | CONSOLE_ENABLE = no # Console for debug(+400) | ||
19 | COMMAND_ENABLE = no # Commands for debug and configuration | ||
20 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | ||
21 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | ||
22 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
23 | NKRO_ENABLE = yes # USB Nkey Rollover | ||
24 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default | ||
25 | RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow | ||
26 | MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config) | ||
27 | UNICODE_ENABLE = no # Unicode | ||
28 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
29 | AUDIO_ENABLE = no # Audio output on port C6 | ||
30 | FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches | ||
31 | HD44780_ENABLE = no # Enable support for HD44780 based LCDs (+400) | ||
32 | VIRTSER_ENABLE = no # USB Serial Driver | ||
33 | RAW_ENABLE = no # Raw device | ||
34 | AUTO_SHIFT_ENABLE = no # Auto Shift | ||
diff --git a/tmk_core/protocol/arm_atsam/led_matrix.c b/tmk_core/protocol/arm_atsam/led_matrix.c index 7ee1dad22..c328fdc4c 100644 --- a/tmk_core/protocol/arm_atsam/led_matrix.c +++ b/tmk_core/protocol/arm_atsam/led_matrix.c | |||
@@ -257,13 +257,15 @@ issi3733_led_t *led_cur; | |||
257 | uint8_t led_per_run = 15; | 257 | uint8_t led_per_run = 15; |
258 | float breathe_mult; | 258 | float breathe_mult; |
259 | 259 | ||
260 | void led_matrix_run(led_setup_t *f) | 260 | __attribute__ ((weak)) |
261 | void led_matrix_run(void) | ||
261 | { | 262 | { |
262 | float ro; | 263 | float ro; |
263 | float go; | 264 | float go; |
264 | float bo; | 265 | float bo; |
265 | float px; | 266 | float px; |
266 | uint8_t led_this_run = 0; | 267 | uint8_t led_this_run = 0; |
268 | led_setup_t *f = (led_setup_t*)led_setups[led_animation_id]; | ||
267 | 269 | ||
268 | if (led_cur == 0) //Denotes start of new processing cycle in the case of chunked processing | 270 | if (led_cur == 0) //Denotes start of new processing cycle in the case of chunked processing |
269 | { | 271 | { |
@@ -459,13 +461,19 @@ uint8_t led_matrix_init(void) | |||
459 | 461 | ||
460 | //Run led matrix code once for initial LED coloring | 462 | //Run led matrix code once for initial LED coloring |
461 | led_cur = 0; | 463 | led_cur = 0; |
462 | led_matrix_run((led_setup_t*)led_setups[led_animation_id]); | 464 | rgb_matrix_init_user(); |
465 | led_matrix_run(); | ||
463 | 466 | ||
464 | DBGC(DC_LED_MATRIX_INIT_COMPLETE); | 467 | DBGC(DC_LED_MATRIX_INIT_COMPLETE); |
465 | 468 | ||
466 | return 0; | 469 | return 0; |
467 | } | 470 | } |
468 | 471 | ||
472 | __attribute__ ((weak)) | ||
473 | void rgb_matrix_init_user(void) { | ||
474 | |||
475 | } | ||
476 | |||
469 | #define LED_UPDATE_RATE 10 //ms | 477 | #define LED_UPDATE_RATE 10 //ms |
470 | 478 | ||
471 | //led data processing can take time, so process data in chunks to free up the processor | 479 | //led data processing can take time, so process data in chunks to free up the processor |
@@ -502,7 +510,7 @@ void led_matrix_task(void) | |||
502 | if (led_cur != lede) | 510 | if (led_cur != lede) |
503 | { | 511 | { |
504 | //m15_off; //debug profiling | 512 | //m15_off; //debug profiling |
505 | led_matrix_run((led_setup_t*)led_setups[led_animation_id]); | 513 | led_matrix_run(); |
506 | //m15_on; //debug profiling | 514 | //m15_on; //debug profiling |
507 | } | 515 | } |
508 | } | 516 | } |
diff --git a/tmk_core/protocol/arm_atsam/led_matrix.h b/tmk_core/protocol/arm_atsam/led_matrix.h index 01b078b71..3f2b9cdb8 100644 --- a/tmk_core/protocol/arm_atsam/led_matrix.h +++ b/tmk_core/protocol/arm_atsam/led_matrix.h | |||
@@ -86,6 +86,7 @@ typedef struct led_disp_s { | |||
86 | } led_disp_t; | 86 | } led_disp_t; |
87 | 87 | ||
88 | uint8_t led_matrix_init(void); | 88 | uint8_t led_matrix_init(void); |
89 | void rgb_matrix_init_user(void); | ||
89 | 90 | ||
90 | #define LED_MODE_NORMAL 0 //Must be 0 | 91 | #define LED_MODE_NORMAL 0 //Must be 0 |
91 | #define LED_MODE_KEYS_ONLY 1 | 92 | #define LED_MODE_KEYS_ONLY 1 |
@@ -134,7 +135,7 @@ extern void *led_setups[]; | |||
134 | extern issi3733_led_t *led_cur; | 135 | extern issi3733_led_t *led_cur; |
135 | extern issi3733_led_t *lede; | 136 | extern issi3733_led_t *lede; |
136 | 137 | ||
137 | void led_matrix_run(led_setup_t *f); | 138 | void led_matrix_run(void); |
138 | void led_matrix_task(void); | 139 | void led_matrix_task(void); |
139 | 140 | ||
140 | void gcr_compute(void); | 141 | void gcr_compute(void); |