From 213b56a1323c6dc98a11c34912ddb09c68a42a12 Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 11 Jul 2022 10:39:06 -0700 Subject: [PATCH] Moved fft table definitions --- README.md | 1 - keyboards/betalupi_ergodox/animations/fft.h | 39 +---------------- keyboards/betalupi_ergodox/extra_mappings.c | 48 +++++++++++++++++++++ keyboards/betalupi_ergodox/extra_mappings.h | 6 +++ keyboards/betalupi_ergodox/rawhid.c | 24 ++--------- keyboards/betalupi_ergodox/rules.mk | 3 +- 6 files changed, 60 insertions(+), 61 deletions(-) create mode 100644 keyboards/betalupi_ergodox/extra_mappings.c create mode 100644 keyboards/betalupi_ergodox/extra_mappings.h diff --git a/README.md b/README.md index 5031d95..aa21f3d 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ This repository contains everything required to build qmk firmware. - Better build/flash command - Warning when directory is moved - **Keyboard:** - - Place FFT maps in one place - Random FFT animation ------------------------------------------------- diff --git a/keyboards/betalupi_ergodox/animations/fft.h b/keyboards/betalupi_ergodox/animations/fft.h index 69fd473..0002dbd 100644 --- a/keyboards/betalupi_ergodox/animations/fft.h +++ b/keyboards/betalupi_ergodox/animations/fft.h @@ -4,44 +4,7 @@ RGB_MATRIX_EFFECT(FFT_ANIM) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -static int8_t fft_array_to_col[4][14] = { - // Each number represets a bin and a height: - // x % bin_height = height, - // x / bin_height = bin - // - // Indices are [col][row]. - - // Right side - { 29, 34, 39, 44, 49, - 28, 33, 38, 43, 48, - 27, 32, 37, 42},{47, - 26, 31, 36, 41, 46, - 30, 35, 40, 45, - - // Left side, mirrored - 24, 19, 14, 9},{ 4, - 23, 18, 13, 8, 3, - 22, 17, 12, 7, 2, - 21, 16, 11},{ 6, 1, - 20, 15, 10, 5, 0, - - // No keys here, fill array length - 0, 0, 0, 0, 0, 0, 0} -}; - -static int8_t fft_col_to_array[10][5] = { - { 47, 43, 38, 33, 28 }, - { 46, 42, 37, 32, 27 }, - { 45, 41, 36, 31, 26 }, - { 44, 40, 35, 30, 25 }, - { -1, 39, 34, 29, 24 }, - { -1, 15, 10, 5, 0 }, - { 20, 16, 11, 6, 1 }, - { 21, 17, 12, 7, 2 }, - { 22, 18, 13, 8, 3 }, - { 23, 19, 14, 9, 4 } -}; +#include "extra_mappings.h" // TODO: // Dynamic color settings diff --git a/keyboards/betalupi_ergodox/extra_mappings.c b/keyboards/betalupi_ergodox/extra_mappings.c new file mode 100644 index 0000000..4d8bb44 --- /dev/null +++ b/keyboards/betalupi_ergodox/extra_mappings.c @@ -0,0 +1,48 @@ +#include "extra_mappings.h" + +// Maps fft columns to leds. +// fft_col_to_array[i] returns an array of leds in the ith bin of the fft. +// Negative indices are "invisible" leds. +// Use them when your keyboard has gaps. +// +// This layout is for the Ergodox EZ. +const int8_t fft_col_to_array[10][5] = { + { 47, 43, 38, 33, 28 }, + { 46, 42, 37, 32, 27 }, + { 45, 41, 36, 31, 26 }, + { 44, 40, 35, 30, 25 }, + { -1, 39, 34, 29, 24 }, + { -1, 15, 10, 5, 0 }, + { 20, 16, 11, 6, 1 }, + { 21, 17, 12, 7, 2 }, + { 22, 18, 13, 8, 3 }, + { 23, 19, 14, 9, 4 } +}; + +// This is the inverse of fft_col_to_array. +// +// Each number represets a bin and a height: +// x % bin_height = height, +// x / bin_height = bin +// +// Indices are [col][row]. +const int8_t fft_array_to_col[4][14] = { + // Right side + { 29, 34, 39, 44, 49, + 28, 33, 38, 43, 48, + 27, 32, 37, 42},{47, + 26, 31, 36, 41, 46, + 30, 35, 40, 45, + + // Left side, mirrored + 24, 19, 14, 9},{ 4, + 23, 18, 13, 8, 3, + 22, 17, 12, 7, 2, + 21, 16, 11},{ 6, 1, + 20, 15, 10, 5, 0, + + // No keys here, fill array length + 0, 0, 0, 0, 0, 0, 0} +}; + + diff --git a/keyboards/betalupi_ergodox/extra_mappings.h b/keyboards/betalupi_ergodox/extra_mappings.h new file mode 100644 index 0000000..d1d5e81 --- /dev/null +++ b/keyboards/betalupi_ergodox/extra_mappings.h @@ -0,0 +1,6 @@ +#pragma once + +#include + +extern const int8_t fft_array_to_col[4][14]; +extern const int8_t fft_col_to_array[10][5]; \ No newline at end of file diff --git a/keyboards/betalupi_ergodox/rawhid.c b/keyboards/betalupi_ergodox/rawhid.c index 66beff5..0e4ff07 100644 --- a/keyboards/betalupi_ergodox/rawhid.c +++ b/keyboards/betalupi_ergodox/rawhid.c @@ -1,6 +1,5 @@ #include "rawhid.h" - -uint8_t hid_anim_data[32]; +#include "extra_mappings.h" // See rawhid.h for prococol documentation void raw_hid_receive(uint8_t *data, uint8_t length) { @@ -58,26 +57,9 @@ void hid_send_state() { raw_hid_send(packet, RAW_EPSIZE); } -#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS -// Maps fft columns to leds. -// fft_col_to_array[i] returns an array of leds in the ith bin of the fft. -// Negative indices are "invisible" leds. -// Use them when your keyboard has gaps. -// -// This layout is for the Ergodox EZ. -static int8_t fft_col_to_array[10][5] = { - { 47, 43, 38, 33, 28 }, - { 46, 42, 37, 32, 27 }, - { 45, 41, 36, 31, 26 }, - { 44, 40, 35, 30, 25 }, - { -1, 39, 34, 29, 24 }, - { -1, 15, 10, 5, 0 }, - { 20, 16, 11, 6, 1 }, - { 21, 17, 12, 7, 2 }, - { 22, 18, 13, 8, 3 }, - { 23, 19, 14, 9, 4 } -}; + +#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS #define FFT_PER_KEY 50 diff --git a/keyboards/betalupi_ergodox/rules.mk b/keyboards/betalupi_ergodox/rules.mk index 5c40a93..f2a652a 100644 --- a/keyboards/betalupi_ergodox/rules.mk +++ b/keyboards/betalupi_ergodox/rules.mk @@ -38,7 +38,8 @@ DEBOUNCE_TYPE = sym_eager_pr SRC += \ matrix.c \ led_i2c.c \ - rawhid.c + rawhid.c \ + extra_mappings.c QUANTUM_LIB_SRC += i2c_master.c