aboutsummaryrefslogtreecommitdiff
path: root/users/drashna
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2020-06-15 03:41:28 -0700
committerGitHub <noreply@github.com>2020-06-15 03:41:28 -0700
commit357a888d805c21c9cb4917f55d558195e8b85db5 (patch)
treefd1e8c30c3754ff89e8efd7e94ced3a1a8d92035 /users/drashna
parent7f5656996ca2f5a62a148ef9165d0681ba806f07 (diff)
downloadqmk_firmware-357a888d805c21c9cb4917f55d558195e8b85db5.tar.gz
qmk_firmware-357a888d805c21c9cb4917f55d558195e8b85db5.zip
[Keymap] Drashna's Keymap Update - Display Edition (#9282)
OLED Display fixes Add support for RGBLIGHT Layers Add gaming layer to corn and kyria RGBLight Startup Animation fixes and improvements (uses matrix_scan now!) Pimoroni Trackball support added (IT'S RGB!!!) Fix issues due to code changes
Diffstat (limited to 'users/drashna')
-rw-r--r--users/drashna/.gitlab-ci.yml5
-rw-r--r--users/drashna/config.h7
-rw-r--r--users/drashna/drashna.c6
-rw-r--r--users/drashna/drashna.h3
-rw-r--r--users/drashna/oled_stuff.c17
-rw-r--r--users/drashna/pimoroni_trackball.c114
-rw-r--r--users/drashna/pimoroni_trackball.h18
-rw-r--r--users/drashna/process_records.c2
-rw-r--r--users/drashna/rgb_matrix_stuff.c6
-rw-r--r--users/drashna/rgb_stuff.c177
-rw-r--r--users/drashna/rules.mk10
11 files changed, 197 insertions, 168 deletions
diff --git a/users/drashna/.gitlab-ci.yml b/users/drashna/.gitlab-ci.yml
index 7218a21be..71d216267 100644
--- a/users/drashna/.gitlab-ci.yml
+++ b/users/drashna/.gitlab-ci.yml
@@ -7,16 +7,15 @@ QMK Firmware:
7 GIT_SUBMODULE_STRATEGY: recursive 7 GIT_SUBMODULE_STRATEGY: recursive
8 tags: 8 tags:
9 - linux 9 - linux
10 image: ubuntu:18.10 10 image: qmkfm/base_container
11 before_script: 11 before_script:
12 - apt-get update -qy 12 - apt-get update -qy
13 - apt-get install -y build-essential avr-libc binutils-arm-none-eabi binutils-avr dfu-programmer dfu-util gcc gcc-arm-none-eabi git libnewlib-arm-none-eabi gcc-avr python3 unzip wget zip 13 - apt-get install -y build-essential avr-libc binutils-arm-none-eabi binutils-avr dfu-programmer dfu-util gcc gcc-arm-none-eabi git libnewlib-arm-none-eabi gcc-avr python3 unzip wget zip
14 - avr-gcc --version 14 - avr-gcc --version
15 - uname -a 15 - uname -a
16 script: 16 script:
17 - make test:all
18 - make planck/rev6:default planck/rev5:default 17 - make planck/rev6:default planck/rev5:default
19 - make keebio/iris/rev2:drashna keebio/iris/rev2:drashna_old ergodox_ez:drashna ergodox_ez:drashna_glow keebio/viterbi/rev1:drashna orthodox/rev1:drashna orthodox/rev3:drashna crkbd:drashna planck/light:drashna planck/rev6:drashna fractal:drashna primekb/prime_m:drashna -j2 --output-sync 18 - make all:drashna -j2
20 artifacts: 19 artifacts:
21 name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG" 20 name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
22 paths: 21 paths:
diff --git a/users/drashna/config.h b/users/drashna/config.h
index 64b4b64ab..7d83c7884 100644
--- a/users/drashna/config.h
+++ b/users/drashna/config.h
@@ -1,7 +1,7 @@
1#pragma once 1#pragma once
2 2
3// Use custom magic number so that when switching branches, EEPROM always gets reset 3// Use custom magic number so that when switching branches, EEPROM always gets reset
4#define EECONFIG_MAGIC_NUMBER (uint16_t)0x1338 4#define EECONFIG_MAGIC_NUMBER (uint16_t)0x1339
5 5
6/* Set Polling rate to 1000Hz */ 6/* Set Polling rate to 1000Hz */
7#define USB_POLLING_INTERVAL_MS 1 7#define USB_POLLING_INTERVAL_MS 1
@@ -98,8 +98,9 @@
98# define ONESHOT_TIMEOUT 3000 98# define ONESHOT_TIMEOUT 3000
99#endif // !ONESHOT_TIMEOUT 99#endif // !ONESHOT_TIMEOUT
100 100
101#ifndef QMK_KEYS_PER_SCAN 101#ifdef QMK_KEYS_PER_SCAN
102# define QMK_KEYS_PER_SCAN 4 102# undef QMK_KEYS_PER_SCAN
103# define QMK_KEYS_PER_SCAN 1
103#endif // !QMK_KEYS_PER_SCAN 104#endif // !QMK_KEYS_PER_SCAN
104 105
105// this makes it possible to do rolling combos (zx) with keys that 106// this makes it possible to do rolling combos (zx) with keys that
diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c
index ba19d4803..5c0f18027 100644
--- a/users/drashna/drashna.c
+++ b/users/drashna/drashna.c
@@ -113,13 +113,9 @@ void shutdown_user(void) {
113 rgblight_setrgb_red(); 113 rgblight_setrgb_red();
114#endif // RGBLIGHT_ENABLE 114#endif // RGBLIGHT_ENABLE
115#ifdef RGB_MATRIX_ENABLE 115#ifdef RGB_MATRIX_ENABLE
116# ifdef __AVR__
117 rgb_matrix_set_color_all(0xFF, 0x00, 0x00); 116 rgb_matrix_set_color_all(0xFF, 0x00, 0x00);
118 rgb_matrix_update_pwm_buffers(); 117 rgb_matrix_update_pwm_buffers();
119# else 118
120 rgb_matrix_sethsv_noeeprom(0, 255, 255);
121 rgb_matrix_mode_noeeprom(1);
122# endif
123#endif // RGB_MATRIX_ENABLE 119#endif // RGB_MATRIX_ENABLE
124 shutdown_keymap(); 120 shutdown_keymap();
125} 121}
diff --git a/users/drashna/drashna.h b/users/drashna/drashna.h
index c10ea5114..dd2b02258 100644
--- a/users/drashna/drashna.h
+++ b/users/drashna/drashna.h
@@ -34,6 +34,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
34#if defined(OLED_DRIVER_ENABLE) 34#if defined(OLED_DRIVER_ENABLE)
35# include "oled_stuff.h" 35# include "oled_stuff.h"
36#endif 36#endif
37#if defined(PIMORONI_TRACKBALL_ENABLE)
38# include "pimoroni_trackball.h"
39#endif
37 40
38/* Define layer names */ 41/* Define layer names */
39enum userspace_layers { 42enum userspace_layers {
diff --git a/users/drashna/oled_stuff.c b/users/drashna/oled_stuff.c
index 7580de1d3..6503b970e 100644
--- a/users/drashna/oled_stuff.c
+++ b/users/drashna/oled_stuff.c
@@ -170,6 +170,13 @@ void render_bootmagic_status(void) {
170 {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}}, 170 {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
171 }; 171 };
172 172
173 bool is_bootmagic_on;
174 #ifdef OLED_DISPLAY_128X64
175 is_bootmagic_on = !keymap_config.swap_lctl_lgui;
176 #else
177 is_bootmagic_on = keymap_config.swap_lctl_lgui;
178 #endif
179
173 oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NAME), false); 180 oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NAME), false);
174#ifdef OLED_DISPLAY_128X64 181#ifdef OLED_DISPLAY_128X64
175 if (keymap_config.swap_lctl_lgui) 182 if (keymap_config.swap_lctl_lgui)
@@ -177,11 +184,11 @@ void render_bootmagic_status(void) {
177 oled_write_P(PSTR(" "), false); 184 oled_write_P(PSTR(" "), false);
178#endif 185#endif
179 { 186 {
180 oled_write_P(logo[1][0], false); 187 oled_write_P(logo[1][0], is_bootmagic_on);
181#ifdef OLED_DISPLAY_128X64 188#ifdef OLED_DISPLAY_128X64
182 } else { 189 } else {
183#endif 190#endif
184 oled_write_P(logo[0][0], false); 191 oled_write_P(logo[0][0], !is_bootmagic_on);
185 } 192 }
186 oled_write_P(PSTR(" "), false); 193 oled_write_P(PSTR(" "), false);
187#ifdef OLED_DISPLAY_128X64 194#ifdef OLED_DISPLAY_128X64
@@ -192,11 +199,11 @@ void render_bootmagic_status(void) {
192 if (keymap_config.swap_lctl_lgui) 199 if (keymap_config.swap_lctl_lgui)
193#endif 200#endif
194 { 201 {
195 oled_write_P(logo[1][1], false); 202 oled_write_P(logo[1][1], is_bootmagic_on);
196#ifdef OLED_DISPLAY_128X64 203#ifdef OLED_DISPLAY_128X64
197 } else { 204 } else {
198#endif 205#endif
199 oled_write_P(logo[0][1], false); 206 oled_write_P(logo[0][1], !is_bootmagic_on);
200 } 207 }
201 oled_write_P(PSTR(" "), false); 208 oled_write_P(PSTR(" "), false);
202#ifdef OLED_DISPLAY_128X64 209#ifdef OLED_DISPLAY_128X64
@@ -233,7 +240,7 @@ __attribute__((weak)) void oled_driver_render_logo(void) {
233} 240}
234 241
235void render_status_secondary(void) { 242void render_status_secondary(void) {
236#if !defined(SPLIT_TRANSPORT_MIRROR) || defined(OLED_DRIVER_128x64) 243#if !defined(SPLIT_TRANSPORT_MIRROR) || defined(OLED_DISPLAY_128X64)
237 oled_driver_render_logo(); 244 oled_driver_render_logo();
238#endif 245#endif
239#ifdef SPLIT_TRANSPORT_MIRROR 246#ifdef SPLIT_TRANSPORT_MIRROR
diff --git a/users/drashna/pimoroni_trackball.c b/users/drashna/pimoroni_trackball.c
new file mode 100644
index 000000000..c5bb560b3
--- /dev/null
+++ b/users/drashna/pimoroni_trackball.c
@@ -0,0 +1,114 @@
1#include "pimoroni_trackball.h"
2#include "i2c_master.h"
3
4static uint8_t scrolling = 0;
5static int16_t x_offset = 0;
6static int16_t y_offset = 0;
7static int16_t h_offset = 0;
8static int16_t v_offset = 0;
9static float precisionSpeed = 1;
10
11#ifndef I2C_TIMEOUT
12# define I2C_TIMEOUT 100
13#endif
14#ifndef MOUSE_DEBOUNCE
15# define MOUSE_DEBOUNCE 5
16#endif
17
18void trackball_set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white) {
19 uint8_t data[] = {0x00, red, green, blue, white};
20 i2c_transmit(TRACKBALL_WRITE, data, sizeof(data), I2C_TIMEOUT);
21}
22
23int16_t mouse_offset(uint8_t positive, uint8_t negative, int16_t scale) {
24 int16_t offset = (int16_t)positive - (int16_t)negative;
25 int16_t magnitude = (int16_t)(scale * offset * offset * precisionSpeed);
26 return offset < 0 ? -magnitude : magnitude;
27}
28
29void update_member(int8_t* member, int16_t* offset) {
30 if (*offset > 127) {
31 *member = 127;
32 *offset -= 127;
33 } else if (*offset < -127) {
34 *member = -127;
35 *offset += 127;
36 } else {
37 *member = *offset;
38 *offset = 0;
39 }
40}
41
42__attribute__((weak)) void trackball_check_click(bool pressed, report_mouse_t* mouse) {
43 if (pressed) {
44 mouse->buttons |= MOUSE_BTN1;
45 } else {
46 mouse->buttons &= ~MOUSE_BTN1;
47 }
48}
49
50float trackball_get_precision(void) { return precisionSpeed; }
51void trackball_set_precision(float precision) { precisionSpeed = precision; }
52bool trackball_is_scrolling(void) { return scrolling; }
53void trackball_set_scrolling(bool scroll) { scrolling = scroll; }
54
55__attribute__((weak)) void pointing_device_init(void) { trackball_set_rgbw(0x00,0x00,0x00,0x4F); }
56
57void pointing_device_task(void) {
58 static bool debounce;
59 static uint16_t debounce_timer;
60 uint8_t state[5] = {};
61 if (i2c_readReg(TRACKBALL_WRITE, 0x04, state, 5, I2C_TIMEOUT) == I2C_STATUS_SUCCESS) {
62 if (!state[4] && !debounce) {
63 if (scrolling) {
64#ifdef PIMORONI_TRACKBALL_INVERT_X
65 h_offset += mouse_offset(state[2], state[3], 1);
66#else
67 h_offset -= mouse_offset(state[2], state[3], 1);
68#endif
69#ifdef PIMORONI_TRACKBALL_INVERT_Y
70 v_offset += mouse_offset(state[1], state[0], 1);
71#else
72 v_offset -= mouse_offset(state[1], state[0], 1);
73#endif
74 } else {
75#ifdef PIMORONI_TRACKBALL_INVERT_X
76 x_offset -= mouse_offset(state[2], state[3], 5);
77#else
78 x_offset += mouse_offset(state[2], state[3], 5);
79#endif
80#ifdef PIMORONI_TRACKBALL_INVERT_Y
81 y_offset -= mouse_offset(state[1], state[0], 5);
82#else
83 y_offset += mouse_offset(state[1], state[0], 5);
84#endif
85 }
86 } else {
87 if (state[4]) {
88 debounce = true;
89 debounce_timer = timer_read();
90 }
91 }
92 }
93
94 if (timer_elapsed(debounce_timer) > MOUSE_DEBOUNCE) debounce = false;
95
96 report_mouse_t mouse = pointing_device_get_report();
97
98 trackball_check_click(state[4] & (1 << 7), &mouse);
99
100
101#ifndef PIMORONI_TRACKBALL_ROTATE
102 update_member(&mouse.x, &x_offset);
103 update_member(&mouse.y, &y_offset);
104 update_member(&mouse.h, &h_offset);
105 update_member(&mouse.v, &v_offset);
106#else
107 update_member(&mouse.x, &y_offset);
108 update_member(&mouse.y, &x_offset);
109 update_member(&mouse.h, &v_offset);
110 update_member(&mouse.v, &h_offset);
111#endif
112 pointing_device_set_report(mouse);
113 pointing_device_send();
114}
diff --git a/users/drashna/pimoroni_trackball.h b/users/drashna/pimoroni_trackball.h
new file mode 100644
index 000000000..7e8a7cc81
--- /dev/null
+++ b/users/drashna/pimoroni_trackball.h
@@ -0,0 +1,18 @@
1#pragma once
2
3#include "quantum.h"
4#include "pointing_device.h"
5
6#ifndef TRACKBALL_ADDRESS
7# define TRACKBALL_ADDRESS 0x0A
8#endif
9#define TRACKBALL_WRITE ((TRACKBALL_ADDRESS << 1) | I2C_WRITE)
10#define TRACKBALL_READ ((TRACKBALL_ADDRESS << 1) | I2C_READ)
11
12void trackball_set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white);
13void trackball_check_click(bool pressed, report_mouse_t *mouse);
14
15float trackball_get_precision(void);
16void trackball_set_precision(float precision);
17bool trackball_is_scrolling(void);
18void trackball_set_scrolling(bool scroll);
diff --git a/users/drashna/process_records.c b/users/drashna/process_records.c
index 101b3d95c..8e3d3356e 100644
--- a/users/drashna/process_records.c
+++ b/users/drashna/process_records.c
@@ -51,7 +51,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
51 clear_mods(); 51 clear_mods();
52 clear_oneshot_mods(); 52 clear_oneshot_mods();
53#endif 53#endif
54 send_string_with_delay_P(PSTR("bin/qmk"), TAP_CODE_DELAY); 54 send_string_with_delay_P(PSTR("qmk"), TAP_CODE_DELAY);
55#ifndef MAKE_BOOTLOADER 55#ifndef MAKE_BOOTLOADER
56 if ((temp_mod | temp_osm) & MOD_MASK_SHIFT) 56 if ((temp_mod | temp_osm) & MOD_MASK_SHIFT)
57#endif 57#endif
diff --git a/users/drashna/rgb_matrix_stuff.c b/users/drashna/rgb_matrix_stuff.c
index 0914aab14..c9c3224fa 100644
--- a/users/drashna/rgb_matrix_stuff.c
+++ b/users/drashna/rgb_matrix_stuff.c
@@ -12,14 +12,14 @@ static uint32_t hypno_timer;
12 12
13void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode, uint8_t speed, uint8_t led_type) { 13void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode, uint8_t speed, uint8_t led_type) {
14 HSV hsv = {hue, sat, val}; 14 HSV hsv = {hue, sat, val};
15 if (hsv.v > rgb_matrix_config.hsv.v) { 15 if (hsv.v > rgb_matrix_get_val()) {
16 hsv.v = rgb_matrix_config.hsv.v; 16 hsv.v = rgb_matrix_get_val();
17 } 17 }
18 18
19 switch (mode) { 19 switch (mode) {
20 case 1: // breathing 20 case 1: // breathing
21 { 21 {
22 uint16_t time = scale16by8(g_rgb_counters.tick, speed / 8); 22 uint16_t time = scale16by8(g_rgb_timer, speed / 8);
23 hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); 23 hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
24 RGB rgb = hsv_to_rgb(hsv); 24 RGB rgb = hsv_to_rgb(hsv);
25 for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { 25 for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
diff --git a/users/drashna/rgb_stuff.c b/users/drashna/rgb_stuff.c
index 06b1e3c0c..defee9ac1 100644
--- a/users/drashna/rgb_stuff.c
+++ b/users/drashna/rgb_stuff.c
@@ -2,136 +2,13 @@
2#include "rgb_stuff.h" 2#include "rgb_stuff.h"
3#include "eeprom.h" 3#include "eeprom.h"
4 4
5extern rgblight_config_t rgblight_config; 5bool has_initialized;
6bool has_initialized;
7 6
8void rgblight_sethsv_default_helper(uint8_t index) { rgblight_sethsv_at(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, index); } 7void rgblight_sethsv_default_helper(uint8_t index) { rgblight_sethsv_at(rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val(), index); }
9
10/* Custom indicators for modifiers.
11 * This allows for certain lights to be lit up, based on what mods are active, giving some visual feedback.
12 * This is especially useful for One Shot Mods, since it's not always obvious if they're still lit up.
13 */
14#ifdef INDICATOR_LIGHTS
15void set_rgb_indicators(uint8_t this_mod, uint8_t this_led, uint8_t this_osm) {
16 if (userspace_config.rgb_layer_change && get_highest_layer(layer_state) == 0) {
17 if ((this_mod | this_osm) & MOD_MASK_SHIFT || this_led & (1 << USB_LED_CAPS_LOCK)) {
18# ifdef SHFT_LED1
19 rgblight_sethsv_at(120, 255, 255, SHFT_LED1);
20# endif // SHFT_LED1
21# ifdef SHFT_LED2
22 rgblight_sethsv_at(120, 255, 255, SHFT_LED2);
23# endif // SHFT_LED2
24 } else {
25# ifdef SHFT_LED1
26 rgblight_sethsv_default_helper(SHFT_LED1);
27# endif // SHFT_LED1
28# ifdef SHFT_LED2
29 rgblight_sethsv_default_helper(SHFT_LED2);
30# endif // SHFT_LED2
31 }
32 if ((this_mod | this_osm) & MOD_MASK_CTRL) {
33# ifdef CTRL_LED1
34 rgblight_sethsv_at(0, 255, 255, CTRL_LED1);
35# endif // CTRL_LED1
36# ifdef CTRL_LED2
37 rgblight_sethsv_at(0, 255, 255, CTRL_LED2);
38# endif // CTRL_LED2
39 } else {
40# ifdef CTRL_LED1
41 rgblight_sethsv_default_helper(CTRL_LED1);
42# endif // CTRL_LED1
43# ifdef CTRL_LED2
44 rgblight_sethsv_default_helper(CTRL_LED2);
45# endif // CTRL_LED2
46 }
47 if ((this_mod | this_osm) & MOD_MASK_GUI) {
48# ifdef GUI_LED1
49 rgblight_sethsv_at(51, 255, 255, GUI_LED1);
50# endif // GUI_LED1
51# ifdef GUI_LED2
52 rgblight_sethsv_at(51, 255, 255, GUI_LED2);
53# endif // GUI_LED2
54 } else {
55# ifdef GUI_LED1
56 rgblight_sethsv_default_helper(GUI_LED1);
57# endif // GUI_LED1
58# ifdef GUI_LED2
59 rgblight_sethsv_default_helper(GUI_LED2);
60# endif // GUI_LED2
61 }
62 if ((this_mod | this_osm) & MOD_MASK_ALT) {
63# ifdef ALT_LED1
64 rgblight_sethsv_at(240, 255, 255, ALT_LED1);
65# endif // ALT_LED1
66# ifdef GUI_LED2
67 rgblight_sethsv_at(240, 255, 255, ALT_LED2);
68# endif // GUI_LED2
69 } else {
70# ifdef GUI_LED1
71 rgblight_sethsv_default_helper(ALT_LED1);
72# endif // GUI_LED1
73# ifdef GUI_LED2
74 rgblight_sethsv_default_helper(ALT_LED2);
75# endif // GUI_LED2
76 }
77 }
78}
79
80/* Function for the indicators */
81void matrix_scan_indicator(void) {
82 if (has_initialized) {
83 set_rgb_indicators(get_mods(), host_keyboard_leds(), get_oneshot_mods());
84 }
85}
86#endif // INDICATOR_LIGHTS
87 8
88#ifdef RGBLIGHT_TWINKLE 9#ifdef RGBLIGHT_TWINKLE
89static rgblight_fadeout lights[RGBLED_NUM]; 10static rgblight_fadeout lights[RGBLED_NUM];
90 11
91__attribute__((weak)) bool rgblight_twinkle_is_led_used_keymap(uint8_t index) { return false; }
92
93/* This function checks for used LEDs. This way, collisions don't occur and cause weird rendering */
94bool rgblight_twinkle_is_led_used(uint8_t index) {
95 switch (index) {
96# ifdef INDICATOR_LIGHTS
97# ifdef SHFT_LED1
98 case SHFT_LED1:
99 return true;
100# endif // SHFT_LED1
101# ifdef SHFT_LED2
102 case SHFT_LED2:
103 return true;
104# endif // SHFT_LED2
105# ifdef CTRL_LED1
106 case CTRL_LED1:
107 return true;
108# endif // CTRL_LED1
109# ifdef CTRL_LED2
110 case CTRL_LED2:
111 return true;
112# endif // CTRL_LED2
113# ifdef GUI_LED1
114 case GUI_LED1:
115 return true;
116# endif // GUI_LED1
117# ifdef GUI_LED2
118 case GUI_LED2:
119 return true;
120# endif // GUI_LED2
121# ifdef ALT_LED1
122 case ALT_LED1:
123 return true;
124# endif // ALT_LED1
125# ifdef ALT_LED2
126 case ALT_LED2:
127 return true;
128# endif // ALT_LED2
129# endif // INDICATOR_LIGHTS
130 default:
131 return rgblight_twinkle_is_led_used_keymap(index);
132 }
133}
134
135/* Handler for fading/twinkling effect */ 12/* Handler for fading/twinkling effect */
136void scan_rgblight_fadeout(void) { // Don't effing change this function .... rgblight_sethsv is supppppper intensive 13void scan_rgblight_fadeout(void) { // Don't effing change this function .... rgblight_sethsv is supppppper intensive
137 bool litup = false; 14 bool litup = false;
@@ -170,9 +47,6 @@ void start_rgb_light(void) {
170 uint8_t min_life_index = -1; 47 uint8_t min_life_index = -1;
171 48
172 for (uint8_t index = 0; index < RGBLED_NUM; ++index) { 49 for (uint8_t index = 0; index < RGBLED_NUM; ++index) {
173 if (rgblight_twinkle_is_led_used(index)) {
174 continue;
175 }
176 if (lights[index].enabled) { 50 if (lights[index].enabled) {
177 if (min_life_index == -1 || lights[index].life < min_life) { 51 if (min_life_index == -1 || lights[index].life < min_life) {
178 min_life = lights[index].life; 52 min_life = lights[index].life;
@@ -197,7 +71,7 @@ void start_rgb_light(void) {
197 light->timer = timer_read(); 71 light->timer = timer_read();
198 light->life = 0xC0 + rand() % 0x40; 72 light->life = 0xC0 + rand() % 0x40;
199 73
200 light->hue = rgblight_config.hue + (rand() % 0xB4) - 0x54; 74 light->hue = rgblight_get_hue() + (rand() % 0xB4) - 0x54;
201 75
202 rgblight_sethsv_at(light->hue, 255, light->life, light_index); 76 rgblight_sethsv_at(light->hue, 255, light->life, light_index);
203} 77}
@@ -227,39 +101,52 @@ bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record) {
227 return true; 101 return true;
228} 102}
229 103
104#if defined(RGBLIGHT_STARTUP_ANIMATION)
105static bool is_enabled;
106static bool is_rgblight_startup;
107static uint8_t old_hue;
108static uint16_t rgblight_startup_loop_timer;
109#endif
110
230void keyboard_post_init_rgb_light(void) { 111void keyboard_post_init_rgb_light(void) {
231#if defined(RGBLIGHT_STARTUP_ANIMATION) 112#if defined(RGBLIGHT_STARTUP_ANIMATION)
232 bool is_enabled = rgblight_config.enable; 113 is_enabled = rgblight_is_enabled();
233 if (userspace_config.rgb_layer_change) { 114 if (userspace_config.rgb_layer_change) {
234 rgblight_enable_noeeprom(); 115 rgblight_enable_noeeprom();
235 } 116 }
236 if (rgblight_config.enable) { 117 if (rgblight_is_enabled()) {
237 layer_state_set_rgb_light(layer_state); 118 layer_state_set_rgb_light(layer_state);
238 uint16_t old_hue = rgblight_config.hue; 119 old_hue = rgblight_get_hue();
239 rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); 120 rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
240 for (uint16_t i = 255; i > 0; i--) { 121 is_rgblight_startup = true;
241 rgblight_sethsv_noeeprom((i + old_hue) % 255, 255, 255);
242 matrix_scan();
243 wait_ms(10);
244 }
245 } 122 }
246 if (!is_enabled) {
247 rgblight_disable_noeeprom();
248 }
249
250#endif 123#endif
251 layer_state_set_rgb_light(layer_state); 124 layer_state_set_rgb_light(layer_state);
252} 125}
253 126
254void matrix_scan_rgb_light(void) { 127void matrix_scan_rgb_light(void) {
255#ifdef RGBLIGHT_ENABLE
256# ifdef RGBLIGHT_TWINKLE 128# ifdef RGBLIGHT_TWINKLE
257 scan_rgblight_fadeout(); 129 scan_rgblight_fadeout();
258# endif // RGBLIGHT_ENABLE 130# endif // RGBLIGHT_ENABLE
259 131
260# ifdef INDICATOR_LIGHTS 132#if defined(RGBLIGHT_STARTUP_ANIMATION)
261 matrix_scan_indicator(); 133 if (is_rgblight_startup && is_keyboard_master()) {
262# endif 134 if (timer_elapsed(rgblight_startup_loop_timer) > 10) {
135 static uint8_t counter;
136 counter++;
137 rgblight_sethsv_noeeprom((counter + old_hue) % 255, 255, 255);
138 rgblight_startup_loop_timer = timer_read();
139 if (counter == 255) {
140 is_rgblight_startup = false;
141 if (!is_enabled) {
142 rgblight_disable_noeeprom();
143 }
144 if (userspace_config.rgb_layer_change) {
145 layer_state_set_rgb_light(layer_state);
146 }
147 }
148 }
149 }
263#endif 150#endif
264} 151}
265 152
diff --git a/users/drashna/rules.mk b/users/drashna/rules.mk
index 051368ff5..b7523a436 100644
--- a/users/drashna/rules.mk
+++ b/users/drashna/rules.mk
@@ -22,9 +22,6 @@ endif
22 22
23ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) 23ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
24 SRC += rgb_stuff.c 24 SRC += rgb_stuff.c
25 ifeq ($(strip $(INDICATOR_LIGHTS)), yes)
26 OPT_DEFS += -DINDICATOR_LIGHTS
27 endif
28 ifeq ($(strip $(RGBLIGHT_TWINKLE)), yes) 25 ifeq ($(strip $(RGBLIGHT_TWINKLE)), yes)
29 OPT_DEFS += -DRGBLIGHT_TWINKLE 26 OPT_DEFS += -DRGBLIGHT_TWINKLE
30 endif 27 endif
@@ -62,3 +59,10 @@ endif
62ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes) 59ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes)
63 SRC += oled_stuff.c 60 SRC += oled_stuff.c
64endif 61endif
62
63ifeq ($(strip $(PIMORONI_TRACKBALL_ENABLE)), yes)
64 POINTING_DEVICE_ENABLE := yes
65 OPT_DEFS += -DPIMORONI_TRACKBALL_ENABLE
66 SRC += pimoroni_trackball.c
67 QUANTUM_LIB_SRC += i2c_master.c
68endif