mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-17 13:12:08 +00:00
fix non-default keymap compiling, initial matrix state, watchdog options
This commit is contained in:
parent
e3b80b4151
commit
638fd9d594
@ -27,6 +27,7 @@ void matrix_init_custom(void) {
|
||||
// actual matrix setup - cols
|
||||
for (int i = 0; i < MATRIX_COLS; i++) {
|
||||
setPinOutput(matrix_col_pins[i]);
|
||||
writePinLow(matrix_col_pins[i]);
|
||||
}
|
||||
|
||||
// rows
|
||||
|
@ -44,6 +44,3 @@
|
||||
|
||||
/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */
|
||||
// #define MIDI_TONE_KEYCODE_OCTAVES 2
|
||||
|
||||
// Most tactile encoders have detents every 4 stages
|
||||
#define ENCODER_RESOLUTION 4
|
||||
|
@ -189,17 +189,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
case BACKLIT:
|
||||
if (record->event.pressed) {
|
||||
register_code(KC_RSFT);
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
backlight_step();
|
||||
#endif
|
||||
#ifdef KEYBOARD_planck_rev5
|
||||
writePinLow(E6);
|
||||
#endif
|
||||
} else {
|
||||
unregister_code(KC_RSFT);
|
||||
#ifdef KEYBOARD_planck_rev5
|
||||
writePinHigh(E6);
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
|
@ -31,6 +31,18 @@
|
||||
#define STM32_IWDG_RL_MS(s) STM32_IWDG_RL_US(s * 1000.0)
|
||||
#define STM32_IWDG_RL_S(s) STM32_IWDG_RL_US(s * 1000000.0)
|
||||
|
||||
#if !defined(PLANCK_ENCODER_RESOLUTION)
|
||||
# define PLANCK_ENCODER_RESOLUTION 4
|
||||
#endif
|
||||
|
||||
#if !defined(PLANCK_WATCHDOG_TIMEOUT)
|
||||
# define PLANCK_WATCHDOG_TIMEOUT 1.0
|
||||
#endif
|
||||
|
||||
#ifdef ENCODER_MAP_ENABLE
|
||||
#error "The encoder map feature is not currently supported by the Planck's encoder matrix"
|
||||
#endif
|
||||
|
||||
/* matrix state(1:on, 0:off) */
|
||||
static pin_t matrix_row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
|
||||
static pin_t matrix_col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
|
||||
@ -46,6 +58,7 @@ void matrix_init_custom(void) {
|
||||
// actual matrix setup - cols
|
||||
for (int i = 0; i < MATRIX_COLS; i++) {
|
||||
setPinOutput(matrix_col_pins[i]);
|
||||
writePinLow(matrix_col_pins[i]);
|
||||
}
|
||||
|
||||
// rows
|
||||
@ -57,14 +70,15 @@ void matrix_init_custom(void) {
|
||||
setPinInputLow(B12);
|
||||
setPinInputLow(B13);
|
||||
|
||||
// setup watchdog timer for 1 second
|
||||
#ifndef PLANCK_WATCHDOG_DISABLE
|
||||
wdgInit();
|
||||
|
||||
static WDGConfig wdgcfg;
|
||||
wdgcfg.pr = STM32_IWDG_PR_S(1.0);
|
||||
wdgcfg.rlr = STM32_IWDG_RL_S(1.0);
|
||||
wdgcfg.pr = STM32_IWDG_PR_S(PLANCK_WATCHDOG_TIMEOUT);
|
||||
wdgcfg.rlr = STM32_IWDG_RL_S(PLANCK_WATCHDOG_TIMEOUT);
|
||||
wdgcfg.winr = STM32_IWDG_WIN_DISABLED;
|
||||
wdgStart(&WDGD1, &wdgcfg);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool encoder_update(uint8_t index, uint8_t state) {
|
||||
@ -73,25 +87,17 @@ bool encoder_update(uint8_t index, uint8_t state) {
|
||||
|
||||
encoder_pulses[i] += encoder_LUT[state & 0xF];
|
||||
|
||||
if (encoder_pulses[i] >= ENCODER_RESOLUTION) {
|
||||
if (encoder_pulses[i] >= PLANCK_ENCODER_RESOLUTION) {
|
||||
encoder_value[index]++;
|
||||
changed = true;
|
||||
#ifdef ENCODER_MAP_ENABLE
|
||||
encoder_exec_mapping(index, false);
|
||||
#else // ENCODER_MAP_ENABLE
|
||||
encoder_update_kb(index, false);
|
||||
#endif // ENCODER_MAP_ENABLE
|
||||
}
|
||||
if (encoder_pulses[i] <= -ENCODER_RESOLUTION) {
|
||||
if (encoder_pulses[i] <= -PLANCK_ENCODER_RESOLUTION) {
|
||||
encoder_value[index]--;
|
||||
changed = true;
|
||||
#ifdef ENCODER_MAP_ENABLE
|
||||
encoder_exec_mapping(index, true);
|
||||
#else // ENCODER_MAP_ENABLE
|
||||
encoder_update_kb(index, true);
|
||||
#endif // ENCODER_MAP_ENABLE
|
||||
}
|
||||
encoder_pulses[i] %= ENCODER_RESOLUTION;
|
||||
encoder_pulses[i] %= PLANCK_ENCODER_RESOLUTION;
|
||||
#ifdef ENCODER_DEFAULT_POS
|
||||
encoder_pulses[i] = 0;
|
||||
#endif
|
||||
@ -99,8 +105,10 @@ bool encoder_update(uint8_t index, uint8_t state) {
|
||||
}
|
||||
|
||||
bool matrix_scan_custom(matrix_row_t current_matrix[]) {
|
||||
#ifndef PLANCK_WATCHDOG_DISABLE
|
||||
// reset watchdog
|
||||
wdgReset(&WDGD1);
|
||||
#endif
|
||||
|
||||
bool changed = false;
|
||||
|
||||
|
@ -14,7 +14,7 @@ See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_to
|
||||
|
||||
## Encoders
|
||||
|
||||
Encoders much have matching pulse & detent resolutions (e.g. 24/24) for the scanning to work properly. Multiple encoders can be used at the same time, and are zero-indexed (compared to being one-indexed on the PCB's silkscreen) in the `encoder_update_user(index, clockwise)` function:
|
||||
Encoders much have matching pulse & detent resolutions (e.g. 24/24) for the scanning to work properly. Multiple encoders can be used at the same time, and are zero-indexed (compared to being one-indexed on the PCB's silkscreen) in the `encoder_update_user(uint8_t index, bool clockwise)` function:
|
||||
|
||||
```
|
||||
,-----------------------------------------------------------------------------------.
|
||||
@ -28,4 +28,15 @@ Encoders much have matching pulse & detent resolutions (e.g. 24/24) for the scan
|
||||
`-----------------------------------------------------------------------------------'
|
||||
```
|
||||
|
||||
If an encoder has a switch built-in, it's connected to the key at that location. On the default keymap, each encoder will play its own rising/falling tone sequence when rotated, and will reset the pitch after one second of inactivity.
|
||||
If an encoder has a switch built-in, it's connected to the key at that location. On the default keymap, each encoder will play its own rising/falling tone sequence when rotated, and will reset the pitch after one second of inactivity. The encoder map feature is not currently supported.
|
||||
|
||||
## Some Planck-specific config.h options:
|
||||
|
||||
```c
|
||||
// sets the length (in seconds) of the watchdog timer, which will reset the keyboard due to hang/crash in the code
|
||||
#define PLANCK_WATCHDOG_TIMEOUT 1.0
|
||||
// disables the watchdog timer - you may want to disable the watchdog timer if you use longer macros
|
||||
#define PLANCK_WATCHDOG_DISABLE
|
||||
// the resolution of the encoders used in the encoder matrix
|
||||
#define PLANCK_ENCODER_RESOLUTION 4
|
||||
```
|
Loading…
Reference in New Issue
Block a user