Skip to content

Commit

Permalink
2020 May 30 Breaking Changes Update (qmk#9215)
Browse files Browse the repository at this point in the history
* Branch point for 2020 May 30 Breaking Change

* Migrate `ACTION_LAYER_TOGGLE` to `TG()` (qmk#8954)

* Migrate `ACTION_MODS_ONESHOT` to `OSM()` (qmk#8957)

* Migrate `ACTION_DEFAULT_LAYER_SET` to `DF()` (qmk#8958)

* Migrate `ACTION_LAYER_MODS` to `LM()` (qmk#8959)

* Migrate `ACTION_MODS_TAP_KEY` to `MT()` (qmk#8968)

* Convert V-USB usbdrv to a submodule (qmk#8321)

* Unify Tap Hold functions and documentation (qmk#8348)

* Changing board names to prevent confusion (qmk#8412)

* Move the Keyboardio Model01 to a keyboardio/ subdir (qmk#8499)

* Move spaceman keyboards (qmk#8830)

* Migrate miscellaneous `fn_actions` entries (qmk#8977)

* Migrate `ACTION_MODS_KEY` to chained mod keycodes (qmk#8979)

* Organizing my keyboards (plaid, tartan, ergoinu) (qmk#8537)

* Refactor Lily58 to use split_common (qmk#6260)

* Refactor zinc to use split_common (qmk#7114)

* Add a message if bin/qmk doesn't work (qmk#9000)

* Fix conflicting types for 'tfp_printf' (qmk#8269)

* Fixed RGB_DISABLE_AFTER_TIMEOUT to be seconds based & small internals cleanup (qmk#6480)

* Refactor and updates to TKC1800 code (qmk#8472)

* Switch to qmk forks for everything (qmk#9019)

* audio refactor: replace deprecated PLAY_NOTE_ARRAY (qmk#8484)

* Audio enable corrections (2/3) (qmk#8903)

* Split HHKB to ANSI and JP layouts and Add VIA support for each (qmk#8582)

* Audio enable corrections (Part 4) (qmk#8974)

* Fix typo from PR7114 (qmk#9171)

* Augment future branch Changelogs (qmk#8978)

* Revert "Branch point for 2020 May 30 Breaking Change"
  • Loading branch information
noroadsleft authored and drashna committed Aug 9, 2020
1 parent 51912a8 commit d9cebd5
Show file tree
Hide file tree
Showing 59 changed files with 179 additions and 7,875 deletions.
8 changes: 7 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
branch = master
[submodule "lib/googletest"]
path = lib/googletest
url = https://github.com/google/googletest
url = https://github.com/qmk/googletest
[submodule "lib/lufa"]
path = lib/lufa
url = https://github.com/zsa/lufa
[submodule "lib/vusb"]
path = lib/vusb
url = https://github.com/qmk/v-usb
[submodule "lib/printf"]
path = lib/printf
url = https://github.com/qmk/printf
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -557,14 +557,16 @@ endef
%:
# Check if we have the CMP tool installed
cmp $(ROOT_DIR)/Makefile $(ROOT_DIR)/Makefile >/dev/null 2>&1; if [ $$? -gt 0 ]; then printf "$(MSG_NO_CMP)"; exit 1; fi;
# Ensure that python3 is installed. This check can be removed after python is used in more places.
if ! python3 --version 1> /dev/null 2>&1; then printf "$(MSG_PYTHON_MISSING)"; fi
# Ensure that bin/qmk works. This will be a failing check after the next develop merge on 2020 Aug 29.
if ! bin/qmk hello 1> /dev/null 2>&1; then printf "$(MSG_PYTHON_MISSING)"; fi
# Check if the submodules are dirty, and display a warning if they are
ifndef SKIP_GIT
if [ ! -e lib/chibios ]; then git submodule sync lib/chibios && git submodule update --depth 50 --init lib/chibios; fi
if [ ! -e lib/chibios-contrib ]; then git submodule sync lib/chibios-contrib && git submodule update --depth 50 --init lib/chibios-contrib; fi
if [ ! -e lib/ugfx ]; then git submodule sync lib/ugfx && git submodule update --depth 50 --init lib/ugfx; fi
if [ ! -e lib/lufa ]; then git submodule sync lib/lufa && git submodule update --depth 50 --init lib/lufa; fi
if [ ! -e lib/vusb ]; then git submodule sync lib/vusb && git submodule update --depth 50 --init lib/vusb; fi
if [ ! -e lib/printf ]; then git submodule sync lib/printf && git submodule update --depth 50 --init lib/printf; fi
git submodule status --recursive 2>/dev/null | \
while IFS= read -r x; do \
case "$$x" in \
Expand Down
1 change: 1 addition & 0 deletions lib/printf
Submodule printf added at d3b984
1 change: 1 addition & 0 deletions lib/vusb
Submodule vusb added at 9a42d2
3 changes: 1 addition & 2 deletions message.mk
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ MSG_FILE_TOO_SMALL = The firmware is too small! $(CURRENT_SIZE)/$(MAX_SIZE)\n
MSG_FILE_JUST_RIGHT = The firmware size is fine - $(CURRENT_SIZE)/$(MAX_SIZE) ($(PERCENT_SIZE)%%, $(FREE_SIZE) bytes free)\n
MSG_FILE_NEAR_LIMIT = The firmware size is approaching the maximum - $(CURRENT_SIZE)/$(MAX_SIZE) ($(PERCENT_SIZE)%%, $(FREE_SIZE) bytes free)\n
MSG_PYTHON_MISSING = $(WARN_COLOR)WARNING:$(NO_COLOR)\n \
Python 3 is not installed. It will be required by a future version\n\
of qmk_firmware.\n\n\
Can not run bin/qmk! This tool will be required when the develop branch is merged on 2020 Aug 29.\n\n\
Please run $(BOLD)util/qmk_install.sh$(NO_COLOR) to install all the dependencies QMK requires.\n\n
MSG_FLASH_BOOTLOADER = $(WARN_COLOR)WARNING:$(NO_COLOR) This board's bootloader is not specified or is not supported by the \":flash\" target at this time.\n\n
MSG_FLASH_ARCH = $(WARN_COLOR)WARNING:$(NO_COLOR) This board's architecture is not supported by the \":flash\" target at this time.\n\n
Expand Down
3 changes: 0 additions & 3 deletions quantum/audio/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat);
// length. This works around the limitation of C's sizeof operation on pointers.
// The global float array for the song must be used here.
#define NOTE_ARRAY_SIZE(x) ((int16_t)(sizeof(x) / (sizeof(x[0]))))
#define PLAY_NOTE_ARRAY(note_array, note_repeat, deprecated_arg) \
play_notes(&note_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat)); \
_Pragma("message \"'PLAY_NOTE_ARRAY' macro is deprecated\"")
#define PLAY_SONG(note_array) play_notes(&note_array, NOTE_ARRAY_SIZE((note_array)), false)
#define PLAY_LOOP(note_array) play_notes(&note_array, NOTE_ARRAY_SIZE((note_array)), true)

Expand Down
5 changes: 5 additions & 0 deletions quantum/audio/audio_avr.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@
# define TIMER_1_DUTY_CYCLE OCR1C
# define TIMER1_AUDIO_vect TIMER1_COMPC_vect
#endif

#if !defined(BPIN_AUDIO) && !defined(CPIN_AUDIO)
# error "Audio feature enabled, but no suitable pin selected - see docs/feature_audio.md under the AVR settings for available options."
#endif

// -----------------------------------------------------------------------------

int voices = 0;
Expand Down
106 changes: 63 additions & 43 deletions quantum/rgb_matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ const point_t k_rgb_matrix_center = RGB_MATRIX_CENTER;
// -----End rgb effect includes macros-------
// ------------------------------------------

#ifndef RGB_DISABLE_AFTER_TIMEOUT
# define RGB_DISABLE_AFTER_TIMEOUT 0
#if defined(RGB_DISABLE_AFTER_TIMEOUT) && !defined(RGB_DISABLE_TIMEOUT)
# define RGB_DISABLE_TIMEOUT (RGB_DISABLE_AFTER_TIMEOUT * 1200)
#endif

#ifndef RGB_DISABLE_TIMEOUT
# define RGB_DISABLE_TIMEOUT 0
#endif

#ifndef RGB_DISABLE_WHEN_USB_SUSPENDED
Expand Down Expand Up @@ -112,19 +116,29 @@ const point_t k_rgb_matrix_center = RGB_MATRIX_CENTER;
#endif


bool g_suspend_state = false;

rgb_config_t rgb_matrix_config;

rgb_counters_t g_rgb_counters;
static uint32_t rgb_counters_buffer;

// globals
bool g_suspend_state = false;
rgb_config_t rgb_matrix_config; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr
uint32_t g_rgb_timer;
#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS
uint8_t rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}};
#endif
uint8_t g_rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}};
#endif // RGB_MATRIX_FRAMEBUFFER_EFFECTS
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
last_hit_t g_last_hit_tracker;
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED

// internals
static uint8_t rgb_last_enable = UINT8_MAX;
static uint8_t rgb_last_effect = UINT8_MAX;
static effect_params_t rgb_effect_params = {0, 0xFF};
static rgb_task_states rgb_task_state = SYNCING;
#if RGB_DISABLE_TIMEOUT > 0
static uint32_t rgb_anykey_timer;
#endif // RGB_DISABLE_TIMEOUT > 0

// double buffers
static uint32_t rgb_timer_buffer;
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
last_hit_t g_last_hit_tracker;
static last_hit_t last_hit_buffer;
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED

Expand Down Expand Up @@ -170,21 +184,24 @@ 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) { rgb_matrix_driver.set_color_all(red, green, blue); }

bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
#if RGB_DISABLE_TIMEOUT > 0
if (record->event.pressed) {
rgb_anykey_timer = 0;
}
#endif // RGB_DISABLE_TIMEOUT > 0

#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
uint8_t led[LED_HITS_TO_REMEMBER];
uint8_t led_count = 0;

# if defined(RGB_MATRIX_KEYRELEASES)
if (!record->event.pressed) {
led_count = rgb_matrix_map_row_column_to_led(record->event.key.row, record->event.key.col, led);
g_rgb_counters.any_key_hit = 0;
}
if (!record->event.pressed)
# elif defined(RGB_MATRIX_KEYPRESSES)
if (record->event.pressed) {
led_count = rgb_matrix_map_row_column_to_led(record->event.key.row, record->event.key.col, led);
g_rgb_counters.any_key_hit = 0;
}
if (record->event.pressed)
# endif // defined(RGB_MATRIX_KEYRELEASES)
{
led_count = rgb_matrix_map_row_column_to_led(record->event.key.row, record->event.key.col, led);
}

if (last_hit_buffer.count + led_count > LED_HITS_TO_REMEMBER) {
memcpy(&last_hit_buffer.x[0], &last_hit_buffer.x[led_count], LED_HITS_TO_REMEMBER - led_count);
Expand Down Expand Up @@ -217,7 +234,7 @@ void rgb_matrix_test(void) {
// Mask out bits 4 and 5
// Increase the factor to make the test animation slower (and reduce to make it faster)
uint8_t factor = 10;
switch ((g_rgb_counters.tick & (0b11 << factor)) >> factor) {
switch ((g_rgb_timer & (0b11 << factor)) >> factor) {
case 0: {
rgb_matrix_set_color_all(20, 0, 0);
break;
Expand All @@ -242,29 +259,26 @@ static bool rgb_matrix_none(effect_params_t *params) {
return false;
}

RGB_MATRIX_USE_LIMITS(led_min, led_max);
for (uint8_t i = led_min; i < led_max; i++) {
rgb_matrix_set_color(i, 0, 0, 0);
}
return led_max < DRIVER_LED_TOTAL;
rgb_matrix_set_color_all(0, 0, 0);
return false;
}

static uint8_t rgb_last_enable = UINT8_MAX;
static uint8_t rgb_last_effect = UINT8_MAX;
static effect_params_t rgb_effect_params = {0, 0xFF};
static rgb_task_states rgb_task_state = SYNCING;

static void rgb_task_timers(void) {
#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0
uint32_t deltaTime = timer_elapsed32(rgb_timer_buffer);
#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0
rgb_timer_buffer = timer_read32();

// Update double buffer timers
uint16_t deltaTime = timer_elapsed32(rgb_counters_buffer);
rgb_counters_buffer = timer_read32();
if (g_rgb_counters.any_key_hit < UINT32_MAX) {
if (UINT32_MAX - deltaTime < g_rgb_counters.any_key_hit) {
g_rgb_counters.any_key_hit = UINT32_MAX;
#if RGB_DISABLE_TIMEOUT > 0
if (rgb_anykey_timer < UINT32_MAX) {
if (UINT32_MAX - deltaTime < rgb_anykey_timer) {
rgb_anykey_timer = UINT32_MAX;
} else {
g_rgb_counters.any_key_hit += deltaTime;
rgb_anykey_timer += deltaTime;
}
}
#endif // RGB_DISABLE_TIMEOUT > 0

// Update double buffer last hit timers
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
Expand All @@ -281,15 +295,15 @@ static void rgb_task_timers(void) {

static void rgb_task_sync(void) {
// next task
if (timer_elapsed32(g_rgb_counters.tick) >= RGB_MATRIX_LED_FLUSH_LIMIT) rgb_task_state = STARTING;
if (timer_elapsed32(g_rgb_timer) >= RGB_MATRIX_LED_FLUSH_LIMIT) rgb_task_state = STARTING;
}

static void rgb_task_start(void) {
// reset iter
rgb_effect_params.iter = 0;

// update double buffers
g_rgb_counters.tick = rgb_counters_buffer;
g_rgb_timer = rgb_timer_buffer;
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
g_last_hit_tracker = last_hit_buffer;
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
Expand Down Expand Up @@ -371,8 +385,16 @@ void rgb_matrix_task(void) {

// Ideally we would also stop sending zeros to the LED driver PWM buffers
// while suspended and just do a software shutdown. This is a cheap hack for now.
bool suspend_backlight = ((g_suspend_state && RGB_DISABLE_WHEN_USB_SUSPENDED) || (RGB_DISABLE_AFTER_TIMEOUT > 0 && g_rgb_counters.any_key_hit > RGB_DISABLE_AFTER_TIMEOUT * 60 * 20));
uint8_t effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode;
bool suspend_backlight =
#if RGB_DISABLE_WHEN_USB_SUSPENDED == true
g_suspend_state ||
#endif // RGB_DISABLE_WHEN_USB_SUSPENDED == true
#if RGB_DISABLE_TIMEOUT > 0
(rgb_anykey_timer > (uint32_t)RGB_DISABLE_TIMEOUT) ||
#endif // RGB_DISABLE_TIMEOUT > 0
false;

uint8_t effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode;

switch (rgb_task_state) {
case STARTING:
Expand Down Expand Up @@ -406,8 +428,6 @@ __attribute__((weak)) void rgb_matrix_indicators_user(void) {}
void rgb_matrix_init(void) {
rgb_matrix_driver.init();

// TODO: put the 1 second startup delay here?

#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
g_last_hit_tracker.count = 0;
for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) {
Expand Down
8 changes: 4 additions & 4 deletions quantum/rgb_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ extern const rgb_matrix_driver_t rgb_matrix_driver;

extern rgb_config_t rgb_matrix_config;

extern bool g_suspend_state;
extern rgb_counters_t g_rgb_counters;
extern led_config_t g_led_config;
extern bool g_suspend_state;
extern uint32_t g_rgb_timer;
extern led_config_t g_led_config;
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
extern last_hit_t g_last_hit_tracker;
#endif
#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS
extern uint8_t rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS];
extern uint8_t g_rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS];
#endif

#endif
2 changes: 1 addition & 1 deletion quantum/rgb_matrix_animations/breathing_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ bool BREATHING(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);

HSV hsv = rgb_matrix_config.hsv;
uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 8);
uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8);
hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
RGB rgb = hsv_to_rgb(hsv);
for (uint8_t i = led_min; i < led_max; i++) {
Expand Down
24 changes: 12 additions & 12 deletions quantum/rgb_matrix_animations/digital_rain_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ bool DIGITAL_RAIN(effect_params_t* params) {

if (params->init) {
rgb_matrix_set_color_all(0, 0, 0);
memset(rgb_frame_buffer, 0, sizeof(rgb_frame_buffer));
memset(g_rgb_frame_buffer, 0, sizeof(g_rgb_frame_buffer));
drop = 0;
}

Expand All @@ -27,22 +27,22 @@ bool DIGITAL_RAIN(effect_params_t* params) {
if (row == 0 && drop == 0 && rand() < RAND_MAX / RGB_DIGITAL_RAIN_DROPS) {
// top row, pixels have just fallen and we're
// making a new rain drop in this column
rgb_frame_buffer[row][col] = max_intensity;
} else if (rgb_frame_buffer[row][col] > 0 && rgb_frame_buffer[row][col] < max_intensity) {
g_rgb_frame_buffer[row][col] = max_intensity;
} else if (g_rgb_frame_buffer[row][col] > 0 && g_rgb_frame_buffer[row][col] < max_intensity) {
// neither fully bright nor dark, decay it
rgb_frame_buffer[row][col]--;
g_rgb_frame_buffer[row][col]--;
}
// set the pixel colour
uint8_t led[LED_HITS_TO_REMEMBER];
uint8_t led_count = rgb_matrix_map_row_column_to_led(row, col, led);

// TODO: multiple leds are supported mapped to the same row/column
if (led_count > 0) {
if (rgb_frame_buffer[row][col] > pure_green_intensity) {
const uint8_t boost = (uint8_t)((uint16_t)max_brightness_boost * (rgb_frame_buffer[row][col] - pure_green_intensity) / (max_intensity - pure_green_intensity));
if (g_rgb_frame_buffer[row][col] > pure_green_intensity) {
const uint8_t boost = (uint8_t)((uint16_t)max_brightness_boost * (g_rgb_frame_buffer[row][col] - pure_green_intensity) / (max_intensity - pure_green_intensity));
rgb_matrix_set_color(led[0], boost, max_intensity, boost);
} else {
const uint8_t green = (uint8_t)((uint16_t)max_intensity * rgb_frame_buffer[row][col] / pure_green_intensity);
const uint8_t green = (uint8_t)((uint16_t)max_intensity * g_rgb_frame_buffer[row][col] / pure_green_intensity);
rgb_matrix_set_color(led[0], 0, green, 0);
}
}
Expand All @@ -55,15 +55,15 @@ bool DIGITAL_RAIN(effect_params_t* params) {
for (uint8_t row = MATRIX_ROWS - 1; row > 0; row--) {
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
// if ths is on the bottom row and bright allow decay
if (row == MATRIX_ROWS - 1 && rgb_frame_buffer[row][col] == max_intensity) {
rgb_frame_buffer[row][col]--;
if (row == MATRIX_ROWS - 1 && g_rgb_frame_buffer[row][col] == max_intensity) {
g_rgb_frame_buffer[row][col]--;
}
// check if the pixel above is bright
if (rgb_frame_buffer[row - 1][col] == max_intensity) {
if (g_rgb_frame_buffer[row - 1][col] == max_intensity) {
// allow old bright pixel to decay
rgb_frame_buffer[row - 1][col]--;
g_rgb_frame_buffer[row - 1][col]--;
// make this pixel bright
rgb_frame_buffer[row][col] = max_intensity;
g_rgb_frame_buffer[row][col] = max_intensity;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion quantum/rgb_matrix_animations/jellybean_raindrops_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static void jellybean_raindrops_set_color(int i, effect_params_t* params) {
bool JELLYBEAN_RAINDROPS(effect_params_t* params) {
if (!params->init) {
// Change one LED every tick, make sure speed is not 0
if (scale16by8(g_rgb_counters.tick, qadd8(rgb_matrix_config.speed, 16)) % 5 == 0) {
if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 5 == 0) {
jellybean_raindrops_set_color(rand() % DRIVER_LED_TOTAL, params);
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion quantum/rgb_matrix_animations/raindrops_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static void raindrops_set_color(int i, effect_params_t* params) {
bool RAINDROPS(effect_params_t* params) {
if (!params->init) {
// Change one LED every tick, make sure speed is not 0
if (scale16by8(g_rgb_counters.tick, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) {
if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) {
raindrops_set_color(rand() % DRIVER_LED_TOTAL, params);
}
return false;
Expand Down
Loading

0 comments on commit d9cebd5

Please sign in to comment.