From a4ef86034c328ed7db9b9f0e2e49c5019d5aabc8 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sun, 9 Apr 2017 20:08:46 +0300 Subject: Fix undefined eeprom warnings in unicode processing --- quantum/process_keycode/process_unicode.c | 1 + quantum/process_keycode/process_unicode_common.c | 1 + 2 files changed, 2 insertions(+) (limited to 'quantum') diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index 678a15234..fd008eca1 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c @@ -15,6 +15,7 @@ */ #include "process_unicode.h" #include "action_util.h" +#include "eeprom.h" static uint8_t first_flag = 0; diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 1dbdec3e7..84b5d673d 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -15,6 +15,7 @@ */ #include "process_unicode_common.h" +#include "eeprom.h" static uint8_t input_mode; uint8_t mods; -- cgit v1.2.3 From 653580477663f527f322650f6d39824cdf6cddc0 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sun, 9 Apr 2017 21:00:42 +0300 Subject: Disable array bounds warning in keymap_function_id_to_action --- quantum/keymap_common.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'quantum') diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 6cf4f031f..9dafc8b51 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -179,5 +179,12 @@ uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) __attribute__ ((weak)) uint16_t keymap_function_id_to_action( uint16_t function_id ) { + // The compiler sees the empty (weak) fn_actions and generates a warning + // This function should not be called in that case, so the warning is too strict + // If this function is called however, the keymap should have overridden fn_actions, and then the compile + // is comparing against the wrong array + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Warray-bounds" return pgm_read_word(&fn_actions[function_id]); + #pragma GCC diagnostic pop } -- cgit v1.2.3 From f7b59427faeaef210227017c8a173f1324fbc795 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sun, 9 Apr 2017 21:17:32 +0300 Subject: Fix name collision between ChibiOS and keymap_german --- quantum/keymap_extras/keymap_german_ch.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'quantum') diff --git a/quantum/keymap_extras/keymap_german_ch.h b/quantum/keymap_extras/keymap_german_ch.h index 8332e00af..67350d660 100644 --- a/quantum/keymap_extras/keymap_german_ch.h +++ b/quantum/keymap_extras/keymap_german_ch.h @@ -33,6 +33,10 @@ #define CH_E KC_E #define CH_F KC_F #define CH_G KC_G +#ifdef CH_H +// The ChibiOS ch.h file defines this... +#undef CH_H +#endif #define CH_H KC_H #define CH_I KC_I #define CH_J KC_J -- cgit v1.2.3 From 109ae2f1e889a2450a98da41f17956c8ce9b79da Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Mon, 10 Apr 2017 10:36:09 +0300 Subject: Fix warnings in process_printer --- quantum/process_keycode/process_printer.c | 22 +++++++++++----------- quantum/process_keycode/process_printer.h | 2 ++ quantum/process_keycode/process_printer_bb.c | 4 ++-- 3 files changed, 15 insertions(+), 13 deletions(-) (limited to 'quantum') diff --git a/quantum/process_keycode/process_printer.c b/quantum/process_keycode/process_printer.c index 807f7a0b9..613af7018 100644 --- a/quantum/process_keycode/process_printer.c +++ b/quantum/process_keycode/process_printer.c @@ -20,12 +20,12 @@ bool printing_enabled = false; uint8_t character_shift = 0; -void enabled_printing() { +void enable_printing(void) { printing_enabled = true; serial_init(); } -void disable_printing() { +void disable_printing(void) { printing_enabled = false; } @@ -41,9 +41,14 @@ void print_char(char c) { USB_Init(); } -void print_box_string(uint8_t text[]) { - uint8_t len = strlen(text); - uint8_t out[len * 3 + 8]; +void print_string(char c[]) { + for(uint8_t i = 0; i < strlen(c); i++) + print_char(c[i]); +} + +void print_box_string(const char text[]) { + size_t len = strlen(text); + char out[len * 3 + 8]; out[0] = 0xDA; for (uint8_t i = 0; i < len; i++) { out[i+1] = 0xC4; @@ -69,14 +74,9 @@ void print_box_string(uint8_t text[]) { print_string(out); } -void print_string(char c[]) { - for(uint8_t i = 0; i < strlen(c); i++) - print_char(c[i]); -} - bool process_printer(uint16_t keycode, keyrecord_t *record) { if (keycode == PRINT_ON) { - enabled_printing(); + enable_printing(); return false; } if (keycode == PRINT_OFF) { diff --git a/quantum/process_keycode/process_printer.h b/quantum/process_keycode/process_printer.h index aa494ac8a..71d3a4b56 100644 --- a/quantum/process_keycode/process_printer.h +++ b/quantum/process_keycode/process_printer.h @@ -21,4 +21,6 @@ #include "protocol/serial.h" +bool process_printer(uint16_t keycode, keyrecord_t *record); + #endif diff --git a/quantum/process_keycode/process_printer_bb.c b/quantum/process_keycode/process_printer_bb.c index 55d3b552b..3a00f169d 100644 --- a/quantum/process_keycode/process_printer_bb.c +++ b/quantum/process_keycode/process_printer_bb.c @@ -46,7 +46,7 @@ void serial_output(void) { } -void enabled_printing() { +void enable_printing() { printing_enabled = true; serial_output(); serial_high(); @@ -82,7 +82,7 @@ void print_string(char c[]) { bool process_printer(uint16_t keycode, keyrecord_t *record) { if (keycode == PRINT_ON) { - enabled_printing(); + enable_printing(); return false; } if (keycode == PRINT_OFF) { -- cgit v1.2.3 From 5c251b5575a5008c81b35cd31313591c4910722a Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Thu, 13 Apr 2017 21:40:06 +0300 Subject: Fix buffer overrun in lcd_keyframes This would often cause the keyboard to crash when restarting the computer. --- quantum/visualizer/lcd_keyframes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'quantum') diff --git a/quantum/visualizer/lcd_keyframes.c b/quantum/visualizer/lcd_keyframes.c index df11861dd..82e4184d2 100644 --- a/quantum/visualizer/lcd_keyframes.c +++ b/quantum/visualizer/lcd_keyframes.c @@ -125,8 +125,8 @@ static void get_led_state_string(char* output, visualizer_state_t* state) { pos += 5; } if (state->status.leds & (1u << USB_LED_KANA)) { - memcpy(output + pos, "KANA ", 5); - pos += 5; + memcpy(output + pos, "KANA", 4); + pos += 4; } output[pos] = 0; } -- cgit v1.2.3 From ffa4c72a893b416da32efef80f4779b8bd48b4bb Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo Date: Wed, 19 Apr 2017 01:40:16 +0700 Subject: Faux clicky bug fixes --- quantum/fauxclicky.c | 15 ++++----------- quantum/fauxclicky.h | 10 +++++----- 2 files changed, 9 insertions(+), 16 deletions(-) (limited to 'quantum') diff --git a/quantum/fauxclicky.c b/quantum/fauxclicky.c index 13273e705..c3341ca33 100644 --- a/quantum/fauxclicky.c +++ b/quantum/fauxclicky.c @@ -20,13 +20,6 @@ along with this program. If not, see . #include #include -__attribute__ ((weak)) -float fauxclicky_pressed_note[2] = MUSICAL_NOTE(_F3, 2); -__attribute__ ((weak)) -float fauxclicky_released_note[2] = MUSICAL_NOTE(_A3, 2); -__attribute__ ((weak)) -float fauxclicky_beep_note[2] = MUSICAL_NOTE(_C3, 2); - bool fauxclicky_enabled = true; uint16_t note_start = 0; bool note_playing = false; @@ -48,13 +41,13 @@ void fauxclicky_stop() note_playing = false; } -void fauxclicky_play(float note[2]) { +void fauxclicky_play(float note[]) { if (!fauxclicky_enabled) return; if (note_playing) fauxclicky_stop(); - FAUXCLICKY_TIMER_PERIOD = (uint16_t)(((float)F_CPU) / (note[0] * FAUXCLICKY_CPU_PRESCALER)); - FAUXCLICKY_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (note[0] * FAUXCLICKY_CPU_PRESCALER)) / 2); + FAUXCLICKY_TIMER_PERIOD = (uint16_t)(((float)F_CPU) / (note[0] * (float)FAUXCLICKY_CPU_PRESCALER)); + FAUXCLICKY_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (note[0] * (float)FAUXCLICKY_CPU_PRESCALER)) / (float)2); note_playing = true; - note_period = (note[1] / 16) * (60 / (float)FAUXCLICKY_TEMPO) * 100; // check this + note_period = (note[1] / (float)16) * ((float)60 / (float)FAUXCLICKY_TEMPO) * 1000; note_start = timer_read(); FAUXCLICKY_ENABLE_OUTPUT; } diff --git a/quantum/fauxclicky.h b/quantum/fauxclicky.h index 109bd0d83..1a8e188dd 100644 --- a/quantum/fauxclicky.h +++ b/quantum/fauxclicky.h @@ -21,11 +21,11 @@ along with this program. If not, see . #include "stdbool.h" __attribute__ ((weak)) -float fauxclicky_pressed_note[2]; +float fauxclicky_pressed_note[2] = MUSICAL_NOTE(_D4, 0.25); __attribute__ ((weak)) -float fauxclicky_released_note[2]; +float fauxclicky_released_note[2] = MUSICAL_NOTE(_C4, 0.125); __attribute__ ((weak)) -float fauxclicky_beep_note[2]; +float fauxclicky_beep_note[2] = MUSICAL_NOTE(_C4, 0.25); bool fauxclicky_enabled; @@ -73,11 +73,11 @@ bool fauxclicky_enabled; #endif #ifndef FAUXCLICKY_ENABLE_OUTPUT -#define FAUXCLICKY_ENABLE_OUTPUT TCCR3A |= _BV(COM3A1); +#define FAUXCLICKY_ENABLE_OUTPUT TCCR3A |= _BV(COM3A1) #endif #ifndef FAUXCLICKY_DISABLE_OUTPUT -#define FAUXCLICKY_DISABLE_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0)); +#define FAUXCLICKY_DISABLE_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0)) #endif #ifndef FAUXCLICKY_TIMER_PERIOD -- cgit v1.2.3 From 4ff40a551a310e9b29a5838f87a9db58c0e5767e Mon Sep 17 00:00:00 2001 From: Weiyi Lou Date: Sat, 29 Apr 2017 22:02:01 +1000 Subject: Add `DYN_REC_STOP` to dynamic macros Dynamic macro functionality is modified to check for `DYN_REC_STOP`, so that macro recording can be stopped with a designated key combination (e.g. `qs` or anything) instead of mandating the use of a `_DYN` layer. `_DYN` layer stopping can still be done by passing `DYN_REC_STOP` within `process_record_user()`: bool process_record_user(uint16_t keycode, keyrecord_t *record) { uint16_t macro_kc = (keycode == MO(_DYN) ? DYN_REC_STOP : keycode); if (!process_record_dynamic_macro(macro_kc, record)) { return false; } return true; } --- quantum/dynamic_macro.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'quantum') diff --git a/quantum/dynamic_macro.h b/quantum/dynamic_macro.h index 64093f293..939816a59 100644 --- a/quantum/dynamic_macro.h +++ b/quantum/dynamic_macro.h @@ -40,6 +40,7 @@ enum dynamic_macro_keycodes { DYN_REC_START1 = DYNAMIC_MACRO_RANGE, DYN_REC_START2, + DYN_REC_STOP, DYN_MACRO_PLAY1, DYN_MACRO_PLAY2, }; @@ -209,9 +210,8 @@ bool process_record_dynamic_macro(uint16_t keycode, keyrecord_t *record) } else { /* A macro is being recorded right now. */ switch (keycode) { - case MO(_DYN): - /* Use the layer key used to access the macro recording as - * a stop button. */ + case DYN_REC_STOP: + /* Stop the macro recording. */ if (record->event.pressed) { /* Ignore the initial release * just after the recoding * starts. */ -- cgit v1.2.3 From 40fe30e4d6b521284fa3cb7ae217ebb6d013bcdf Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Wed, 3 May 2017 23:47:52 +0200 Subject: dynamic_macro.h: Ignore all the initial key releases Right after the user initiates the macro recording, they usually need to release some keys used to access the DYN_REC_START layers. It makes sense to ignore them. Note: The keys used to access the DYN_REC_STOP key are *not* ignored. --- quantum/dynamic_macro.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'quantum') diff --git a/quantum/dynamic_macro.h b/quantum/dynamic_macro.h index 939816a59..1a8ec4032 100644 --- a/quantum/dynamic_macro.h +++ b/quantum/dynamic_macro.h @@ -97,17 +97,24 @@ void dynamic_macro_play( /** * Record a single key in a dynamic macro. * + * @param macro_buffer[in] The start of the used macro buffer. * @param macro_pointer[in,out] The current buffer position. * @param macro_end2[in] The end of the other macro which shouldn't be overwritten. * @param direction[in] Either +1 or -1, which way to iterate the buffer. * @param record[in] The current keypress. */ void dynamic_macro_record_key( + keyrecord_t *macro_buffer, keyrecord_t **macro_pointer, keyrecord_t *macro_end2, int8_t direction, keyrecord_t *record) { + /* If we've just started recording, ignore all the key releases. */ + if (!record->event.pressed && *macro_pointer == macro_buffer) { + return; + } + if (*macro_pointer + direction != macro_end2) { **macro_pointer = *record; *macro_pointer += direction; @@ -230,10 +237,10 @@ bool process_record_dynamic_macro(uint16_t keycode, keyrecord_t *record) /* Store the key in the macro buffer and process it normally. */ switch (macro_id) { case 1: - dynamic_macro_record_key(¯o_pointer, r_macro_end, +1, record); + dynamic_macro_record_key(macro_buffer, ¯o_pointer, r_macro_end, +1, record); break; case 2: - dynamic_macro_record_key(¯o_pointer, macro_end, -1, record); + dynamic_macro_record_key(r_macro_buffer, ¯o_pointer, macro_end, -1, record); break; } return true; -- cgit v1.2.3 From 5e2a9992783e584f66dfeef16abf9d31c976311a Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Thu, 4 May 2017 00:58:01 +0200 Subject: dynamic_macro.h: Always toggle the backlight twice as a notification Apparently sometimes the backlight was toggled only once and it was left on. --- quantum/dynamic_macro.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'quantum') diff --git a/quantum/dynamic_macro.h b/quantum/dynamic_macro.h index 1a8ec4032..c9120897f 100644 --- a/quantum/dynamic_macro.h +++ b/quantum/dynamic_macro.h @@ -119,9 +119,7 @@ void dynamic_macro_record_key( **macro_pointer = *record; *macro_pointer += direction; } else { - /* Notify about the end of buffer. The blinks are paired - * because they should happen on both down and up events. */ - backlight_toggle(); + dynamic_macro_led_blink(); } } -- cgit v1.2.3 From 436d661775178fb62b46afdc3d755fdb413dcb35 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Thu, 4 May 2017 01:19:05 +0200 Subject: dynamic_macro.h: Fix an off-by-two error We need to check whether we just passed the after-the-end point of the other macro. Instead we were checking whether we are going to reach it now. --- quantum/dynamic_macro.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'quantum') diff --git a/quantum/dynamic_macro.h b/quantum/dynamic_macro.h index c9120897f..9e7845c99 100644 --- a/quantum/dynamic_macro.h +++ b/quantum/dynamic_macro.h @@ -99,14 +99,14 @@ void dynamic_macro_play( * * @param macro_buffer[in] The start of the used macro buffer. * @param macro_pointer[in,out] The current buffer position. - * @param macro_end2[in] The end of the other macro which shouldn't be overwritten. + * @param macro2_end[in] The last buffer element it is safe to use before overwriting the other macro. * @param direction[in] Either +1 or -1, which way to iterate the buffer. * @param record[in] The current keypress. */ void dynamic_macro_record_key( keyrecord_t *macro_buffer, keyrecord_t **macro_pointer, - keyrecord_t *macro_end2, + keyrecord_t *macro2_end, int8_t direction, keyrecord_t *record) { @@ -115,7 +115,7 @@ void dynamic_macro_record_key( return; } - if (*macro_pointer + direction != macro_end2) { + if (*macro_pointer - direction != macro2_end) { **macro_pointer = *record; *macro_pointer += direction; } else { -- cgit v1.2.3