forked from qmk/qmk_firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8914d7
commit a06fcb4
Showing
14 changed files
with
1,494 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* Copyright 2023 Cipulot | ||
* | ||
* 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 3 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#define MATRIX_ROWS 6 | ||
#define MATRIX_COLS 19 | ||
|
||
#define MATRIX_ROW_PINS \ | ||
{ B13, B12, B14, A9, B6, B7 } | ||
|
||
#define AMUX_COUNT 3 | ||
#define AMUX_MAX_COLS_COUNT 8 | ||
|
||
#define AMUX_EN_PINS \ | ||
{ A0, A1, A8 } | ||
|
||
#define AMUX_SEL_PINS \ | ||
{ A4, A3, A2 } | ||
|
||
#define AMUX_COL_CHANNELS_SIZES \ | ||
{ 8, 7, 4 } | ||
|
||
#define AMUX_0_COL_CHANNELS \ | ||
{ 0, 3, 1, 2, 4, 6, 7, 5 } | ||
|
||
#define AMUX_1_COL_CHANNELS \ | ||
{ 1, 0, 3, 2, 4, 6, 7 } | ||
|
||
#define AMUX_2_COL_CHANNELS \ | ||
{ 4, 6, 7, 5 } | ||
|
||
#define AMUX_COL_CHANNELS AMUX_0_COL_CHANNELS, AMUX_1_COL_CHANNELS, AMUX_2_COL_CHANNELS | ||
|
||
#define DISCHARGE_PIN A6 | ||
#define ANALOG_PORT A7 | ||
|
||
#define DEFAULT_ACTUATION_MODE 0 | ||
#define DEFAULT_MODE_0_ACTUATION_LEVEL 550 | ||
#define DEFAULT_MODE_0_RELEASE_LEVEL 500 | ||
#define DEFAULT_MODE_1_INITIAL_DEADZONE_OFFSET DEFAULT_MODE_0_ACTUATION_LEVEL | ||
#define DEFAULT_MODE_1_ACTUATION_OFFSET 70 | ||
#define DEFAULT_MODE_1_RELEASE_OFFSET 70 | ||
#define DEFAULT_EXTREMUM 1023 | ||
#define EXPECTED_NOISE_FLOOR 0 | ||
#define NOISE_FLOOR_THRESHOLD 50 | ||
#define BOTTOMING_CALIBRATION_THRESHOLD 100 | ||
#define DEFAULT_NOISE_FLOOR_SAMPLING_COUNT 30 | ||
#define DEFAULT_BOTTOMING_READING 1023 | ||
#define DEFAULT_CALIBRATION_STARTER true | ||
|
||
#define DISCHARGE_TIME 10 | ||
|
||
//#define DEBUG_MATRIX_SCAN_RATE | ||
|
||
#define EECONFIG_KB_DATA_SIZE 249 | ||
|
||
// Indicators | ||
// PWM driver with direct memory access (DMA) support | ||
#define WS2812_PWM_COMPLEMENTARY_OUTPUT | ||
#define WS2812_PWM_DRIVER PWMD1 | ||
#define WS2812_PWM_CHANNEL 3 | ||
#define WS2812_PWM_PAL_MODE 1 | ||
#define WS2812_DMA_STREAM STM32_DMA2_STREAM5 | ||
#define WS2812_DMA_CHANNEL 6 | ||
|
||
#define NUM_INDICATOR_INDEX 0 | ||
#define CAPS_INDICATOR_INDEX 1 | ||
#define SCROLL_INDICATOR_INDEX 2 | ||
|
||
#define RGB_MATRIX_DEFAULT_VAL 60 | ||
#define RGB_MATRIX_SLEEP | ||
#define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_SOLID_COLOR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/* Copyright 2023 Cipulot | ||
* | ||
* 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 3 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "ec_switch_matrix.h" | ||
#include "quantum.h" | ||
|
||
void eeconfig_init_kb(void) { | ||
// Default values | ||
eeprom_ec_config.num.h = 0; | ||
eeprom_ec_config.num.s = 0; | ||
eeprom_ec_config.num.v = 60; | ||
eeprom_ec_config.num.enabled = true; | ||
eeprom_ec_config.caps.h = 0; | ||
eeprom_ec_config.caps.s = 0; | ||
eeprom_ec_config.caps.v = 60; | ||
eeprom_ec_config.caps.enabled = true; | ||
eeprom_ec_config.scroll.h = 0; | ||
eeprom_ec_config.scroll.s = 0; | ||
eeprom_ec_config.scroll.v = 60; | ||
eeprom_ec_config.scroll.enabled = true; | ||
eeprom_ec_config.actuation_mode = DEFAULT_ACTUATION_MODE; | ||
eeprom_ec_config.mode_0_actuation_threshold = DEFAULT_MODE_0_ACTUATION_LEVEL; | ||
eeprom_ec_config.mode_0_release_threshold = DEFAULT_MODE_0_RELEASE_LEVEL; | ||
eeprom_ec_config.mode_1_initial_deadzone_offset = DEFAULT_MODE_1_INITIAL_DEADZONE_OFFSET; | ||
eeprom_ec_config.mode_1_actuation_offset = DEFAULT_MODE_1_ACTUATION_OFFSET; | ||
eeprom_ec_config.mode_1_release_offset = DEFAULT_MODE_1_RELEASE_OFFSET; | ||
|
||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
for (uint8_t col = 0; col < MATRIX_COLS; col++) { | ||
eeprom_ec_config.bottoming_reading[row][col] = DEFAULT_BOTTOMING_READING; | ||
} | ||
} | ||
// Write default value to EEPROM now | ||
eeconfig_update_kb_datablock(&eeprom_ec_config); | ||
|
||
eeconfig_init_user(); | ||
} | ||
|
||
// On Keyboard startup | ||
void keyboard_post_init_kb(void) { | ||
// Read custom menu variables from memory | ||
eeconfig_read_kb_datablock(&eeprom_ec_config); | ||
|
||
// Set runtime values to EEPROM values | ||
ec_config.actuation_mode = eeprom_ec_config.actuation_mode; | ||
ec_config.mode_0_actuation_threshold = eeprom_ec_config.mode_0_actuation_threshold; | ||
ec_config.mode_0_release_threshold = eeprom_ec_config.mode_0_release_threshold; | ||
ec_config.mode_1_initial_deadzone_offset = eeprom_ec_config.mode_1_initial_deadzone_offset; | ||
ec_config.mode_1_actuation_offset = eeprom_ec_config.mode_1_actuation_offset; | ||
ec_config.mode_1_release_offset = eeprom_ec_config.mode_1_release_offset; | ||
ec_config.bottoming_calibration = false; | ||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
for (uint8_t col = 0; col < MATRIX_COLS; col++) { | ||
ec_config.bottoming_calibration_starter[row][col] = true; | ||
ec_config.bottoming_reading[row][col] = eeprom_ec_config.bottoming_reading[row][col]; | ||
ec_config.rescaled_mode_0_actuation_threshold[row][col] = rescale(ec_config.mode_0_actuation_threshold, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]); | ||
ec_config.rescaled_mode_0_release_threshold[row][col] = rescale(ec_config.mode_0_release_threshold, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]); | ||
ec_config.rescaled_mode_1_initial_deadzone_offset[row][col] = rescale(ec_config.mode_1_initial_deadzone_offset, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]); | ||
} | ||
} | ||
|
||
// Call the indicator callback to set the indicator color | ||
rgb_matrix_indicators_kb(); | ||
|
||
keyboard_post_init_user(); | ||
} | ||
|
||
// INDICATOR CALLBACK ------------------------------------------------------------------------------ | ||
/* LED index to physical position | ||
* | ||
* LED0 | LED1 | LED2 | ||
* -----+------+-------- | ||
* Num | Caps | Scroll | | ||
*/ | ||
bool rgb_matrix_indicators_kb(void) { | ||
if (eeprom_ec_config.num.enabled) { | ||
// The rgb_matrix_set_color function needs an RGB code to work, so first the indicator color is cast to an HSV value and then translated to RGB | ||
HSV hsv_num_indicator_color = {eeprom_ec_config.num.h, eeprom_ec_config.num.s, eeprom_ec_config.num.v}; | ||
RGB rgb_num_indicator_color = hsv_to_rgb(hsv_num_indicator_color); | ||
if (host_keyboard_led_state().num_lock) | ||
rgb_matrix_set_color(NUM_INDICATOR_INDEX, rgb_num_indicator_color.r, rgb_num_indicator_color.g, rgb_num_indicator_color.b); | ||
else | ||
rgb_matrix_set_color(NUM_INDICATOR_INDEX, 0, 0, 0); | ||
} | ||
if (eeprom_ec_config.caps.enabled) { | ||
HSV hsv_caps_indicator_color = {eeprom_ec_config.caps.h, eeprom_ec_config.caps.s, eeprom_ec_config.caps.v}; | ||
RGB rgb_caps_indicator_color = hsv_to_rgb(hsv_caps_indicator_color); | ||
if (host_keyboard_led_state().caps_lock) | ||
rgb_matrix_set_color(CAPS_INDICATOR_INDEX, rgb_caps_indicator_color.r, rgb_caps_indicator_color.g, rgb_caps_indicator_color.b); | ||
else | ||
rgb_matrix_set_color(CAPS_INDICATOR_INDEX, 0, 0, 0); | ||
} | ||
if (eeprom_ec_config.scroll.enabled) { | ||
HSV hsv_scroll_indicator_color = {eeprom_ec_config.scroll.h, eeprom_ec_config.scroll.s, eeprom_ec_config.scroll.v}; | ||
RGB rgb_scroll_indicator_color = hsv_to_rgb(hsv_scroll_indicator_color); | ||
if (host_keyboard_led_state().scroll_lock) | ||
rgb_matrix_set_color(SCROLL_INDICATOR_INDEX, rgb_scroll_indicator_color.r, rgb_scroll_indicator_color.g, rgb_scroll_indicator_color.b); | ||
else | ||
rgb_matrix_set_color(SCROLL_INDICATOR_INDEX, 0, 0, 0); | ||
} | ||
|
||
return true; | ||
} |
Oops, something went wrong.