From 9632360caa5e6511b0ec13cb4c55eb64408232b5 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 30 Aug 2022 03:20:04 -0500 Subject: Use a macro to compute the size of arrays at compile time (#18044) * Add ARRAY_SIZE and CEILING utility macros * Apply a coccinelle patch to use ARRAY_SIZE * fix up some straggling items * Fix 'make test:secure' * Enhance ARRAY_SIZE macro to reject acting on pointers The previous definition would not produce a diagnostic for ``` int *p; size_t num_elem = ARRAY_SIZE(p) ``` but the new one will. * explicitly get definition of ARRAY_SIZE * Convert to ARRAY_SIZE when const is involved The following spatch finds additional instances where the array is const and the division is by the size of the type, not the size of the first element: ``` @ rule5a using "empty.iso" @ type T; const T[] E; @@ - (sizeof(E)/sizeof(T)) + ARRAY_SIZE(E) @ rule6a using "empty.iso" @ type T; const T[] E; @@ - sizeof(E)/sizeof(T) + ARRAY_SIZE(E) ``` * New instances of ARRAY_SIZE added since initial spatch run * Use `ARRAY_SIZE` in docs (found by grep) * Manually use ARRAY_SIZE hs_set is expected to be the same size as uint16_t, though it's made of two 8-bit integers * Just like char, sizeof(uint8_t) is guaranteed to be 1 This is at least true on any plausible system where qmk is actually used. Per my understanding it's universally true, assuming that uint8_t exists: https://stackoverflow.com/questions/48655310/can-i-assume-that-sizeofuint8-t-1 * Run qmk-format on core C files touched in this branch Co-authored-by: Stefan Kerkmann --- keyboards/tzarc/djinn/djinn_portscan_matrix.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'keyboards/tzarc/djinn') diff --git a/keyboards/tzarc/djinn/djinn_portscan_matrix.c b/keyboards/tzarc/djinn/djinn_portscan_matrix.c index f0ae9721f9..6fcfd48bba 100644 --- a/keyboards/tzarc/djinn/djinn_portscan_matrix.c +++ b/keyboards/tzarc/djinn/djinn_portscan_matrix.c @@ -92,11 +92,11 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) { void matrix_wait_for_interrupt(void) { // Set up row/col pins and attach callback - for (int i = 0; i < sizeof(col_pins) / sizeof(pin_t); ++i) { + for (int i = 0; i < ARRAY_SIZE(col_pins); ++i) { setPinOutput(col_pins[i]); writePinLow(col_pins[i]); } - for (int i = 0; i < sizeof(row_pins) / sizeof(pin_t); ++i) { + for (int i = 0; i < ARRAY_SIZE(row_pins); ++i) { setPinInputHigh(row_pins[i]); palEnableLineEvent(row_pins[i], PAL_EVENT_MODE_BOTH_EDGES); } @@ -105,12 +105,12 @@ void matrix_wait_for_interrupt(void) { __WFI(); // Now that the interrupt has woken us up, reset all the row/col pins back to defaults - for (int i = 0; i < sizeof(row_pins) / sizeof(pin_t); ++i) { + for (int i = 0; i < ARRAY_SIZE(row_pins); ++i) { palDisableLineEvent(row_pins[i]); writePinHigh(row_pins[i]); setPinInputHigh(row_pins[i]); } - for (int i = 0; i < sizeof(col_pins) / sizeof(pin_t); ++i) { + for (int i = 0; i < ARRAY_SIZE(col_pins); ++i) { writePinHigh(col_pins[i]); setPinInputHigh(col_pins[i]); } -- cgit v1.2.3 From 36c410592dbd35da33ccc5fd6d2a5cbf4b25a708 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 23 Sep 2022 22:46:23 +1000 Subject: Change `DRIVER_LED_COUNT` to `{LED,RGB}_MATRIX_LED_COUNT` (#18399) --- keyboards/tzarc/djinn/rev1/config.h | 2 +- keyboards/tzarc/djinn/rev2/config.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'keyboards/tzarc/djinn') diff --git a/keyboards/tzarc/djinn/rev1/config.h b/keyboards/tzarc/djinn/rev1/config.h index 14cdaf2fdb..6f001cbd0c 100644 --- a/keyboards/tzarc/djinn/rev1/config.h +++ b/keyboards/tzarc/djinn/rev1/config.h @@ -21,7 +21,7 @@ // RGB configuration #define RGBLED_NUM 84 -#define DRIVER_LED_TOTAL 84 +#define RGB_MATRIX_LED_COUNT 84 #define RGB_MATRIX_SPLIT \ { 42, 42 } #define RGB_POWER_ENABLE_PIN B1 diff --git a/keyboards/tzarc/djinn/rev2/config.h b/keyboards/tzarc/djinn/rev2/config.h index 52c909d442..b0deb6d991 100644 --- a/keyboards/tzarc/djinn/rev2/config.h +++ b/keyboards/tzarc/djinn/rev2/config.h @@ -23,7 +23,7 @@ // RGB configuration #define RGBLED_NUM 86 -#define DRIVER_LED_TOTAL 86 +#define RGB_MATRIX_LED_COUNT 86 #define RGB_MATRIX_SPLIT \ { 43, 43 } #define RGB_POWER_ENABLE_PIN B0 -- cgit v1.2.3 From 1bdf4cdc22ae57d111efb2f7d71e405e5c7b3f11 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sun, 25 Sep 2022 22:04:52 +1000 Subject: Fix `tzarc/djinn` screen geometry. (#18478) --- keyboards/tzarc/djinn/djinn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'keyboards/tzarc/djinn') diff --git a/keyboards/tzarc/djinn/djinn.c b/keyboards/tzarc/djinn/djinn.c index 5e5fe44c67..e6529e555d 100644 --- a/keyboards/tzarc/djinn/djinn.c +++ b/keyboards/tzarc/djinn/djinn.c @@ -70,7 +70,7 @@ void keyboard_post_init_kb(void) { wait_ms(150); // Initialise the LCD - lcd = qp_ili9341_make_spi_device(320, 240, LCD_CS_PIN, LCD_DC_PIN, LCD_RST_PIN, 4, 0); + lcd = qp_ili9341_make_spi_device(240, 320, LCD_CS_PIN, LCD_DC_PIN, LCD_RST_PIN, 4, 0); qp_init(lcd, QP_ROTATION_0); // Turn on the LCD and clear the display @@ -230,4 +230,4 @@ void housekeeping_task_kb(void) { if (last_input_activity_elapsed() > 250) { matrix_wait_for_interrupt(); } -} \ No newline at end of file +} -- cgit v1.2.3 From 059a7fb9b033fe1adb8a797e0f3dbc074499020c Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sun, 2 Oct 2022 00:21:22 +1000 Subject: Djinn theme, allow force redraws (#18558) --- keyboards/tzarc/djinn/djinn.c | 4 ++-- keyboards/tzarc/djinn/graphics/theme_djinn_default.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'keyboards/tzarc/djinn') diff --git a/keyboards/tzarc/djinn/djinn.c b/keyboards/tzarc/djinn/djinn.c index e6529e555d..93b1ee775e 100644 --- a/keyboards/tzarc/djinn/djinn.c +++ b/keyboards/tzarc/djinn/djinn.c @@ -129,7 +129,7 @@ RGB rgb_matrix_hsv_to_rgb(HSV hsv) { //---------------------------------------------------------- // UI Placeholder, implemented in themes -__attribute__((weak)) void draw_ui_user(void) {} +__attribute__((weak)) void draw_ui_user(bool force_redraw) {} //---------------------------------------------------------- // Housekeeping @@ -223,7 +223,7 @@ void housekeeping_task_kb(void) { // Draw the UI if (kb_state.lcd_power) { - draw_ui_user(); + draw_ui_user(false); } // Go into low-scan interrupt-based mode if we haven't had any matrix activity in the last 250 milliseconds diff --git a/keyboards/tzarc/djinn/graphics/theme_djinn_default.c b/keyboards/tzarc/djinn/graphics/theme_djinn_default.c index a4e87bd341..c9863f2285 100644 --- a/keyboards/tzarc/djinn/graphics/theme_djinn_default.c +++ b/keyboards/tzarc/djinn/graphics/theme_djinn_default.c @@ -89,8 +89,8 @@ void keyboard_post_init_display(void) { //---------------------------------------------------------- // UI Drawing -void draw_ui_user(void) { - bool hue_redraw = false; +void draw_ui_user(bool force_redraw) { + bool hue_redraw = force_redraw; static uint16_t last_hue = 0xFFFF; #if defined(RGB_MATRIX_ENABLE) uint16_t curr_hue = rgb_matrix_get_hue(); -- cgit v1.2.3 From c6f1b594a2085e67219bd5f0f7ba7898429d331c Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 11 Oct 2022 06:06:26 +1100 Subject: Remove legacy keycodes, part 2 (#18660) * `KC_SYSREQ` -> `KC_SYRQ` And one `KC_ALT_ERASE` -> `KC_ERAS` * `KC_NONUS_BSLASH` -> `KC_NUBS` * `KC_NUMLOCK` -> `KC_NUM` * `KC_CLCK` -> `KC_CAPS` * `KC_SCROLLLOCK` -> `KC_SCRL` * `KC_LBRACKET` -> `KC_LBRC` * `KC_RBRACKET` -> `KC_RBRC` * `KC_CAPSLOCK` -> `KC_CAPS` --- keyboards/tzarc/djinn/keymaps/default/keymap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'keyboards/tzarc/djinn') diff --git a/keyboards/tzarc/djinn/keymaps/default/keymap.c b/keyboards/tzarc/djinn/keymaps/default/keymap.c index 32a53e27b8..a5aa07e127 100644 --- a/keyboards/tzarc/djinn/keymaps/default/keymap.c +++ b/keyboards/tzarc/djinn/keymaps/default/keymap.c @@ -45,7 +45,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______ ), [_ADJUST] = LAYOUT_all( - _______, KC_CLCK, KC_NLCK, KC_SLCK, _______, _______, _______, _______, _______, _______, _______, DEBUG, EEP_RST, QK_BOOT, + _______, KC_CAPS, KC_NLCK, KC_SLCK, _______, _______, _______, _______, _______, _______, _______, DEBUG, EEP_RST, QK_BOOT, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, -- cgit v1.2.3 From 5e4b076af3c99d36632d6b92f3ddd046f38a01af Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 16 Oct 2022 08:29:43 +1100 Subject: Remove legacy keycodes, part 5 (#18710) * `KC_SLCK` -> `KC_SCRL` * `KC_NLCK` -> `KC_NUM` --- keyboards/tzarc/djinn/keymaps/default/keymap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'keyboards/tzarc/djinn') diff --git a/keyboards/tzarc/djinn/keymaps/default/keymap.c b/keyboards/tzarc/djinn/keymaps/default/keymap.c index a5aa07e127..14239dc45a 100644 --- a/keyboards/tzarc/djinn/keymaps/default/keymap.c +++ b/keyboards/tzarc/djinn/keymaps/default/keymap.c @@ -45,7 +45,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______ ), [_ADJUST] = LAYOUT_all( - _______, KC_CAPS, KC_NLCK, KC_SLCK, _______, _______, _______, _______, _______, _______, _______, DEBUG, EEP_RST, QK_BOOT, + _______, KC_CAPS, KC_NUM, KC_SCRL, _______, _______, _______, _______, _______, _______, _______, DEBUG, EEP_RST, QK_BOOT, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, -- cgit v1.2.3 From 18dc851e37a203b32db0261c365dd300488e1c71 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 19 Oct 2022 21:33:05 +1100 Subject: Remove legacy Debug keycode (#18769) * `DEBUG` -> `DB_TOGG`, default-ish keymaps * `DEBUG` -> `DB_TOGG`, user keymaps * `DEBUG` -> `DB_TOGG`, community layouts * `DEBUG` -> `DB_TOGG`, userspace * `DEBUG` -> `DB_TOGG`, docs & core --- keyboards/tzarc/djinn/keymaps/default/keymap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'keyboards/tzarc/djinn') diff --git a/keyboards/tzarc/djinn/keymaps/default/keymap.c b/keyboards/tzarc/djinn/keymaps/default/keymap.c index 14239dc45a..3523c9ab6b 100644 --- a/keyboards/tzarc/djinn/keymaps/default/keymap.c +++ b/keyboards/tzarc/djinn/keymaps/default/keymap.c @@ -45,7 +45,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______ ), [_ADJUST] = LAYOUT_all( - _______, KC_CAPS, KC_NUM, KC_SCRL, _______, _______, _______, _______, _______, _______, _______, DEBUG, EEP_RST, QK_BOOT, + _______, KC_CAPS, KC_NUM, KC_SCRL, _______, _______, _______, _______, _______, _______, _______, DB_TOGG, EEP_RST, QK_BOOT, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, -- cgit v1.2.3 From c347e732be6b50500c1651b3fb8c0753b0c9c40d Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 20 Oct 2022 22:20:07 +1100 Subject: Remove legacy EEPROM clear keycodes (#18782) * `EEP_RST` -> `EE_CLR`, default-ish keymaps * `EEP_RST` -> `EE_CLR`, user keymaps * `EEP_RST` -> `EE_CLR`, community layouts * `EEP_RST` -> `EE_CLR`, userspace * `EEP_RST` -> `EE_CLR`, docs & core --- keyboards/tzarc/djinn/keymaps/default/keymap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'keyboards/tzarc/djinn') diff --git a/keyboards/tzarc/djinn/keymaps/default/keymap.c b/keyboards/tzarc/djinn/keymaps/default/keymap.c index 3523c9ab6b..926c728b2d 100644 --- a/keyboards/tzarc/djinn/keymaps/default/keymap.c +++ b/keyboards/tzarc/djinn/keymaps/default/keymap.c @@ -45,7 +45,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______ ), [_ADJUST] = LAYOUT_all( - _______, KC_CAPS, KC_NUM, KC_SCRL, _______, _______, _______, _______, _______, _______, _______, DB_TOGG, EEP_RST, QK_BOOT, + _______, KC_CAPS, KC_NUM, KC_SCRL, _______, _______, _______, _______, _______, _______, _______, DB_TOGG, EE_CLR, QK_BOOT, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, -- cgit v1.2.3 From 219afaba42e6b4384f578977eadbb71a03383ecc Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sun, 6 Nov 2022 08:11:59 +1100 Subject: Reworked backlight keycodes. (#18961) Co-authored-by: Ryan --- keyboards/tzarc/djinn/keymaps/default/keymap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'keyboards/tzarc/djinn') diff --git a/keyboards/tzarc/djinn/keymaps/default/keymap.c b/keyboards/tzarc/djinn/keymaps/default/keymap.c index 926c728b2d..65b494cf32 100644 --- a/keyboards/tzarc/djinn/keymaps/default/keymap.c +++ b/keyboards/tzarc/djinn/keymaps/default/keymap.c @@ -28,7 +28,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, KC_LEFT, KC_DOWN, KC_RIGHT,_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - BL_DEC, BL_INC, + BL_DOWN, BL_UP, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ -- cgit v1.2.3