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/handwired/onekey/keymaps/chibios_waiting_test/keymap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'keyboards/handwired/onekey/keymaps') diff --git a/keyboards/handwired/onekey/keymaps/chibios_waiting_test/keymap.c b/keyboards/handwired/onekey/keymaps/chibios_waiting_test/keymap.c index ecf67d3b3c..65983c8dd8 100644 --- a/keyboards/handwired/onekey/keymaps/chibios_waiting_test/keymap.c +++ b/keyboards/handwired/onekey/keymaps/chibios_waiting_test/keymap.c @@ -34,11 +34,11 @@ static const uint32_t waiting_values[] = {0, 1, 5, 10, 25, 50, 100, 150, 200, 50 void housekeeping_task_user(void) { static uint32_t last_bench = 0; if (timer_elapsed32(last_bench) > 500) { - for (int i = 0; i < (sizeof(waiting_values) / sizeof(waiting_values[0])); i++) { + for (int i = 0; i < ARRAY_SIZE(waiting_values); i++) { wait_us_polling_with_strobe(waiting_values[i]); wait_us(10); } - for (int i = 0; i < (sizeof(waiting_values) / sizeof(waiting_values[0])); i++) { + for (int i = 0; i < ARRAY_SIZE(waiting_values); i++) { wait_us_yield_with_strobe(waiting_values[i]); wait_us(10); } -- cgit v1.2.3 From be8907d634ac8967de1ae2ac8346b845f738c9e6 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 27 Sep 2022 18:37:13 +1000 Subject: Further refactoring of joystick feature (#18437) --- keyboards/handwired/onekey/keymaps/joystick/keymap.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'keyboards/handwired/onekey/keymaps') diff --git a/keyboards/handwired/onekey/keymaps/joystick/keymap.c b/keyboards/handwired/onekey/keymaps/joystick/keymap.c index 7a2f138b28..c74707e931 100644 --- a/keyboards/handwired/onekey/keymaps/joystick/keymap.c +++ b/keyboards/handwired/onekey/keymaps/joystick/keymap.c @@ -10,11 +10,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { void matrix_scan_user() { int16_t val = (((uint32_t)timer_read() % 5000 - 2500) * 255) / 5000; - - if (val != joystick_status.axes[1]) { - joystick_status.axes[1] = val; - joystick_status.status |= JS_UPDATED; - } + joystick_set_axis(1, val); } // Joystick config -- cgit v1.2.3 From 45b5ed5c6e1ecdf95e9ce0523a8ff49d45b8822f Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 30 Sep 2022 04:23:11 +1000 Subject: Onekey: migrate some stuff to data driven (#18502) --- keyboards/handwired/onekey/keymaps/quine/keymap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'keyboards/handwired/onekey/keymaps') diff --git a/keyboards/handwired/onekey/keymaps/quine/keymap.c b/keyboards/handwired/onekey/keymaps/quine/keymap.c index e7c1e6d064..f440bba83a 100644 --- a/keyboards/handwired/onekey/keymaps/quine/keymap.c +++ b/keyboards/handwired/onekey/keymaps/quine/keymap.c @@ -1,7 +1,7 @@ -#include +#include const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { LAYOUT_ortho_1x1(KC_A) }; const char *buf[30] = { -"#include ", +"#include ", "const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { LAYOUT_ortho_1x1(KC_A) };", "const char *buf[30] = {", "", -- cgit v1.2.3 From 9f0d9b4fbea2da81c82d7dc091aa56d52a7db675 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 1 Oct 2022 12:54:42 +1000 Subject: onekey: fix quine keymap (#18555) --- keyboards/handwired/onekey/keymaps/quine/keymap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'keyboards/handwired/onekey/keymaps') diff --git a/keyboards/handwired/onekey/keymaps/quine/keymap.c b/keyboards/handwired/onekey/keymaps/quine/keymap.c index f440bba83a..5f1416c77e 100644 --- a/keyboards/handwired/onekey/keymaps/quine/keymap.c +++ b/keyboards/handwired/onekey/keymaps/quine/keymap.c @@ -1,7 +1,7 @@ -#include +#include QMK_KEYBOARD_H const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { LAYOUT_ortho_1x1(KC_A) }; const char *buf[30] = { -"#include ", +"#include QMK_KEYBOARD_H", "const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { LAYOUT_ortho_1x1(KC_A) };", "const char *buf[30] = {", "", @@ -57,4 +57,3 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return true; }; - -- cgit v1.2.3 From 55b9a4d06e12df08564d3b6261f9ed81f75e07ec Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Sat, 15 Oct 2022 09:55:27 -0700 Subject: Remove RGBLIGHT_ANIMATION and clean up effect defines for G-K (#18726) --- keyboards/handwired/onekey/keymaps/apa102/config.h | 11 ++++++++++- keyboards/handwired/onekey/keymaps/rgb/config.h | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'keyboards/handwired/onekey/keymaps') diff --git a/keyboards/handwired/onekey/keymaps/apa102/config.h b/keyboards/handwired/onekey/keymaps/apa102/config.h index aeb22a261b..756ebb3593 100644 --- a/keyboards/handwired/onekey/keymaps/apa102/config.h +++ b/keyboards/handwired/onekey/keymaps/apa102/config.h @@ -2,4 +2,13 @@ #define RGBLED_NUM 40 #define APA102_DEFAULT_BRIGHTNESS 5 -#define RGBLIGHT_ANIMATIONS +#define RGBLIGHT_EFFECT_BREATHING +#define RGBLIGHT_EFFECT_RAINBOW_MOOD +#define RGBLIGHT_EFFECT_RAINBOW_SWIRL +#define RGBLIGHT_EFFECT_SNAKE +#define RGBLIGHT_EFFECT_KNIGHT +#define RGBLIGHT_EFFECT_CHRISTMAS +#define RGBLIGHT_EFFECT_STATIC_GRADIENT +#define RGBLIGHT_EFFECT_RGB_TEST +#define RGBLIGHT_EFFECT_ALTERNATING +#define RGBLIGHT_EFFECT_TWINKLE diff --git a/keyboards/handwired/onekey/keymaps/rgb/config.h b/keyboards/handwired/onekey/keymaps/rgb/config.h index 89e76326b4..1e54383769 100644 --- a/keyboards/handwired/onekey/keymaps/rgb/config.h +++ b/keyboards/handwired/onekey/keymaps/rgb/config.h @@ -1,4 +1,13 @@ #pragma once #define RGBLED_NUM 9 -#define RGBLIGHT_ANIMATIONS +#define RGBLIGHT_EFFECT_BREATHING +#define RGBLIGHT_EFFECT_RAINBOW_MOOD +#define RGBLIGHT_EFFECT_RAINBOW_SWIRL +#define RGBLIGHT_EFFECT_SNAKE +#define RGBLIGHT_EFFECT_KNIGHT +#define RGBLIGHT_EFFECT_CHRISTMAS +#define RGBLIGHT_EFFECT_STATIC_GRADIENT +#define RGBLIGHT_EFFECT_RGB_TEST +#define RGBLIGHT_EFFECT_ALTERNATING +#define RGBLIGHT_EFFECT_TWINKLE -- 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/handwired/onekey/keymaps/eep_rst/keymap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'keyboards/handwired/onekey/keymaps') diff --git a/keyboards/handwired/onekey/keymaps/eep_rst/keymap.c b/keyboards/handwired/onekey/keymaps/eep_rst/keymap.c index 3f7a6b8502..e206b6b39f 100644 --- a/keyboards/handwired/onekey/keymaps/eep_rst/keymap.c +++ b/keyboards/handwired/onekey/keymaps/eep_rst/keymap.c @@ -1,5 +1,5 @@ #include QMK_KEYBOARD_H const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - LAYOUT_ortho_1x1(EEP_RST) + LAYOUT_ortho_1x1(EE_CLR) }; -- cgit v1.2.3 From 6bbe8b6eddc56d43f4db07c665bf1791ea2ab871 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 25 Oct 2022 01:50:33 +1100 Subject: Normalise Joystick and Programmable Button keycodes (#18832) --- keyboards/handwired/onekey/keymaps/joystick/keymap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'keyboards/handwired/onekey/keymaps') diff --git a/keyboards/handwired/onekey/keymaps/joystick/keymap.c b/keyboards/handwired/onekey/keymaps/joystick/keymap.c index c74707e931..96115aa496 100644 --- a/keyboards/handwired/onekey/keymaps/joystick/keymap.c +++ b/keyboards/handwired/onekey/keymaps/joystick/keymap.c @@ -5,7 +5,7 @@ #endif const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - LAYOUT_ortho_1x1(JS_BUTTON0) + LAYOUT_ortho_1x1(JS_0) }; void matrix_scan_user() { -- cgit v1.2.3 From 7407347be1df69928d27ea9b6a4fe094429f2a55 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 28 Oct 2022 09:50:14 +1100 Subject: Remove rgblight_list.h (#18878) * Remove rgblight_list defines with no usage * Remove rgblight_setrgb_*[_at] defines * Remove rgblight_sethsv_* defines * Remove rgblight_sethsv_noeeprom_* defines * Delete rgblight_list.h and remove all references --- keyboards/handwired/onekey/keymaps/apa102/keymap.c | 2 +- keyboards/handwired/onekey/keymaps/rgb/keymap.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'keyboards/handwired/onekey/keymaps') diff --git a/keyboards/handwired/onekey/keymaps/apa102/keymap.c b/keyboards/handwired/onekey/keymaps/apa102/keymap.c index 700755a452..8b4191fb28 100644 --- a/keyboards/handwired/onekey/keymaps/apa102/keymap.c +++ b/keyboards/handwired/onekey/keymaps/apa102/keymap.c @@ -9,6 +9,6 @@ void keyboard_post_init_user(void) { apa102_set_brightness(5); rgblight_enable_noeeprom(); - rgblight_sethsv_noeeprom_cyan(); + rgblight_sethsv_noeeprom(HSV_CYAN); rgblight_mode_noeeprom(RGBLIGHT_MODE_RAINBOW_SWIRL); } diff --git a/keyboards/handwired/onekey/keymaps/rgb/keymap.c b/keyboards/handwired/onekey/keymaps/rgb/keymap.c index c3e77f1ec1..c99eb86339 100644 --- a/keyboards/handwired/onekey/keymaps/rgb/keymap.c +++ b/keyboards/handwired/onekey/keymaps/rgb/keymap.c @@ -6,6 +6,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { void keyboard_post_init_user(void) { rgblight_enable_noeeprom(); - rgblight_sethsv_noeeprom_cyan(); + rgblight_sethsv_noeeprom(HSV_CYAN); rgblight_mode_noeeprom(RGBLIGHT_MODE_RAINBOW_SWIRL); } -- cgit v1.2.3 From 6cc9513ab0cd5e21354c51ab83a89af9f2eb517e Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 13 Nov 2022 10:28:11 +1100 Subject: Digitizer feature improvements (#19034) --- .../handwired/onekey/keymaps/digitizer/keymap.c | 72 ++++++++++++++-------- 1 file changed, 46 insertions(+), 26 deletions(-) (limited to 'keyboards/handwired/onekey/keymaps') diff --git a/keyboards/handwired/onekey/keymaps/digitizer/keymap.c b/keyboards/handwired/onekey/keymaps/digitizer/keymap.c index 6b304e86fe..dcc0adc59b 100644 --- a/keyboards/handwired/onekey/keymaps/digitizer/keymap.c +++ b/keyboards/handwired/onekey/keymaps/digitizer/keymap.c @@ -1,38 +1,58 @@ - /* Copyright 2021 QMK - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ +/* Copyright 2021 QMK + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include QMK_KEYBOARD_H -#include "digitizer.h" +#include -#include "math.h" +enum custom_keycodes { + DG_TIP = SAFE_RANGE, +}; -const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {LAYOUT_ortho_1x1(KC_A)}; +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + LAYOUT_ortho_1x1(DG_TIP) +}; uint32_t timer = 0; +void keyboard_post_init_user(void) { + digitizer_in_range_on(); +} + void matrix_scan_user() { if (timer_elapsed32(timer) < 200) { return; } - - timer = timer_read32(); - digitizer_t digitizer; - digitizer.x = 0.5 - 0.2 * cos(timer_read() / 250. / 6.28); - digitizer.y = 0.5 - 0.2 * sin(timer_read() / 250. / 6.28); - digitizer.tipswitch = 0; - digitizer.inrange = 1; - digitizer_set_report(digitizer); + + timer = timer_read32(); + + float x = 0.5 - 0.2 * cos(timer / 250. / 6.28); + float y = 0.5 - 0.2 * sin(timer / 250. / 6.28); + digitizer_set_position(x, y); +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case DG_TIP: + if (record->event.pressed) { + digitizer_tip_switch_on(); + } else { + digitizer_tip_switch_off(); + } + return false; + } + return true; } -- cgit v1.2.3 From 5d882ab6ef6bc3cf384046f409a86cbb7550153c Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Fri, 18 Nov 2022 02:16:38 +0000 Subject: Disable onekey console by default (#19104) --- keyboards/handwired/onekey/keymaps/console/keymap.c | 8 ++++++++ keyboards/handwired/onekey/keymaps/console/rules.mk | 2 ++ keyboards/handwired/onekey/keymaps/hardware_id/rules.mk | 1 + keyboards/handwired/onekey/keymaps/oled/rules.mk | 1 + 4 files changed, 12 insertions(+) create mode 100644 keyboards/handwired/onekey/keymaps/console/rules.mk create mode 100644 keyboards/handwired/onekey/keymaps/hardware_id/rules.mk (limited to 'keyboards/handwired/onekey/keymaps') diff --git a/keyboards/handwired/onekey/keymaps/console/keymap.c b/keyboards/handwired/onekey/keymaps/console/keymap.c index b47fb59d17..3f5d0664f5 100644 --- a/keyboards/handwired/onekey/keymaps/console/keymap.c +++ b/keyboards/handwired/onekey/keymaps/console/keymap.c @@ -18,3 +18,11 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return true; } + +void keyboard_post_init_user(void) { + // Customise these values to desired behaviour + debug_enable=true; + debug_matrix=true; + //debug_keyboard=true; + //debug_mouse=true; +} diff --git a/keyboards/handwired/onekey/keymaps/console/rules.mk b/keyboards/handwired/onekey/keymaps/console/rules.mk new file mode 100644 index 0000000000..7c83606d2d --- /dev/null +++ b/keyboards/handwired/onekey/keymaps/console/rules.mk @@ -0,0 +1,2 @@ +CONSOLE_ENABLE = yes +DEBUG_MATRIX_SCAN_RATE_ENABLE = yes diff --git a/keyboards/handwired/onekey/keymaps/hardware_id/rules.mk b/keyboards/handwired/onekey/keymaps/hardware_id/rules.mk new file mode 100644 index 0000000000..15b7f725b2 --- /dev/null +++ b/keyboards/handwired/onekey/keymaps/hardware_id/rules.mk @@ -0,0 +1 @@ +CONSOLE_ENABLE = yes diff --git a/keyboards/handwired/onekey/keymaps/oled/rules.mk b/keyboards/handwired/onekey/keymaps/oled/rules.mk index 6b69e50dbb..83757b1909 100644 --- a/keyboards/handwired/onekey/keymaps/oled/rules.mk +++ b/keyboards/handwired/onekey/keymaps/oled/rules.mk @@ -1,3 +1,4 @@ OLED_ENABLE = yes OLED_DRIVER = SSD1306 TAP_DANCE_ENABLE = yes +CONSOLE_ENABLE = yes -- cgit v1.2.3 From 1e95f7be8f214c544bf99f415916a4a5f07a1e9b Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 27 Nov 2022 03:14:45 +1100 Subject: Joystick feature improvements (#19052) --- keyboards/handwired/onekey/keymaps/joystick/config.h | 2 +- keyboards/handwired/onekey/keymaps/joystick/keymap.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'keyboards/handwired/onekey/keymaps') diff --git a/keyboards/handwired/onekey/keymaps/joystick/config.h b/keyboards/handwired/onekey/keymaps/joystick/config.h index a3b5858ad2..8a4e461b27 100644 --- a/keyboards/handwired/onekey/keymaps/joystick/config.h +++ b/keyboards/handwired/onekey/keymaps/joystick/config.h @@ -1,4 +1,4 @@ #pragma once -#define JOYSTICK_AXES_COUNT 2 +#define JOYSTICK_AXIS_COUNT 2 #define JOYSTICK_BUTTON_COUNT 1 diff --git a/keyboards/handwired/onekey/keymaps/joystick/keymap.c b/keyboards/handwired/onekey/keymaps/joystick/keymap.c index 96115aa496..6463900b7b 100644 --- a/keyboards/handwired/onekey/keymaps/joystick/keymap.c +++ b/keyboards/handwired/onekey/keymaps/joystick/keymap.c @@ -14,7 +14,7 @@ void matrix_scan_user() { } // Joystick config -joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT] = { +joystick_config_t joystick_axes[JOYSTICK_AXIS_COUNT] = { [0] = JOYSTICK_AXIS_IN(ADC_PIN, 0, 512, 1023), [1] = JOYSTICK_AXIS_VIRTUAL }; -- cgit v1.2.3 From cf3c26533cadf4e6739dbc9117caad01df2fa5e3 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Fri, 2 Dec 2022 21:55:28 +1100 Subject: Fixup EFL and F4's sector selection. (#19221) --- .../onekey/keymaps/wear_leveling/config.h | 6 ++ .../onekey/keymaps/wear_leveling/keymap.c | 65 ++++++++++++++++++++++ .../onekey/keymaps/wear_leveling/rules.mk | 1 + 3 files changed, 72 insertions(+) create mode 100644 keyboards/handwired/onekey/keymaps/wear_leveling/config.h create mode 100644 keyboards/handwired/onekey/keymaps/wear_leveling/keymap.c create mode 100644 keyboards/handwired/onekey/keymaps/wear_leveling/rules.mk (limited to 'keyboards/handwired/onekey/keymaps') diff --git a/keyboards/handwired/onekey/keymaps/wear_leveling/config.h b/keyboards/handwired/onekey/keymaps/wear_leveling/config.h new file mode 100644 index 0000000000..642b442da3 --- /dev/null +++ b/keyboards/handwired/onekey/keymaps/wear_leveling/config.h @@ -0,0 +1,6 @@ +// Copyright 2018-2022 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-3.0-or-later +#pragma once + +#define DEBUG_EEPROM_OUTPUT +#define WEAR_LEVELING_DEBUG_OUTPUT diff --git a/keyboards/handwired/onekey/keymaps/wear_leveling/keymap.c b/keyboards/handwired/onekey/keymaps/wear_leveling/keymap.c new file mode 100644 index 0000000000..dc40ca1580 --- /dev/null +++ b/keyboards/handwired/onekey/keymaps/wear_leveling/keymap.c @@ -0,0 +1,65 @@ +// Copyright 2018-2022 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-3.0-or-later +#include QMK_KEYBOARD_H + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + LAYOUT_ortho_1x1(QK_BOOT) +}; + +#ifdef DEBUG_EEPROM_OUTPUT + +# ifdef WEAR_LEVELING_ENABLE +# include "wear_leveling.h" +# endif // WEAR_LEVELING_ENABLE + +uint8_t prng(void) { + static uint8_t s = 0xAA, a = 0; + s ^= s << 3; + s ^= s >> 5; + s ^= a++ >> 2; + return s; +} + +void keyboard_post_init_user(void) { + debug_enable = true; + debug_matrix = true; + debug_keyboard = true; +} + +void matrix_scan_user(void) { + static uint32_t last_eeprom_access = 0; + uint32_t now = timer_read32(); + if (now - last_eeprom_access > 5000) { + dprint("reading eeprom\n"); + last_eeprom_access = now; + + union { + uint8_t bytes[4]; + uint32_t raw; + } tmp; + extern uint8_t prng(void); + tmp.bytes[0] = prng(); + tmp.bytes[1] = prng(); + tmp.bytes[2] = prng(); + tmp.bytes[3] = prng(); + + eeconfig_update_user(tmp.raw); + uint32_t value = eeconfig_read_user(); + if (value != tmp.raw) { + dprint("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + dprint("!! EEPROM readback mismatch!\n"); + dprint("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + } + } + +# ifdef WEAR_LEVELING_ENABLE + static uint32_t last_wear_leveling_init = 0; + if (now - last_wear_leveling_init > 30000) { + dprint("init'ing wear-leveling\n"); + last_wear_leveling_init = now; + wear_leveling_init(); + } +# endif // WEAR_LEVELING_ENABLE +} + +#endif // DEBUG_EEPROM_OUTPUT diff --git a/keyboards/handwired/onekey/keymaps/wear_leveling/rules.mk b/keyboards/handwired/onekey/keymaps/wear_leveling/rules.mk new file mode 100644 index 0000000000..15b7f725b2 --- /dev/null +++ b/keyboards/handwired/onekey/keymaps/wear_leveling/rules.mk @@ -0,0 +1 @@ +CONSOLE_ENABLE = yes -- cgit v1.2.3