Skip to content

Commit

Permalink
Update necessities
Browse files Browse the repository at this point in the history
  • Loading branch information
adophoxia committed Jun 26, 2024
1 parent 9d4dcb9 commit f8a6391
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 25 deletions.
4 changes: 3 additions & 1 deletion data/schemas/keyboard.jsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,8 @@
"is31fl3743a",
"is31fl3745",
"is31fl3746a",
"snled27351"
"snled27351",
"snled27351_spi"
]
},
"center_point": {
Expand Down Expand Up @@ -539,6 +540,7 @@
"is31fl3745",
"is31fl3746a",
"snled27351",
"snled27351_spi",
"ws2812"
]
},
Expand Down
11 changes: 10 additions & 1 deletion drivers/encoder/encoder_quadrature.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ __attribute__((weak)) uint8_t encoder_quadrature_read_pin(uint8_t index, bool pa

static pin_t encoders_pad_a[NUM_ENCODERS_MAX_PER_SIDE] = ENCODERS_PAD_A;
static pin_t encoders_pad_b[NUM_ENCODERS_MAX_PER_SIDE] = ENCODERS_PAD_B;
static bool encoder_interrupt_update[NUM_ENCODERS] = {false};

__attribute__((weak)) void encoder_wait_pullup_charge(void) {
wait_us(100);
Expand Down Expand Up @@ -199,13 +200,21 @@ static void encoder_handle_state_change(uint8_t index, uint8_t state) {

void encoder_quadrature_handle_read(uint8_t index, uint8_t pin_a_state, uint8_t pin_b_state) {
uint8_t state = pin_a_state | (pin_b_state << 1);
if ((encoder_state[index] & 0x3) != state) {
if ((encoder_state[index] & 0x3) != state || encoder_interrupt_update[index]) {
encoder_state[index] <<= 2;
encoder_state[index] |= state;
encoder_handle_state_change(index, encoder_state[index]);
encoder_interrupt_update[index] = false;
}
}

void encoder_quadrature_inerrupt_read(uint8_t index) {
encoder_state[index] <<= 2;
encoder_state[index] |= (readPin(encoders_pad_a[index]) << 0) | (readPin(encoders_pad_b[index]) << 1);
encoder_pulses[index] += encoder_LUT[encoder_state[index] & 0xF];
encoder_interrupt_update[index] = true;
}

__attribute__((weak)) void encoder_driver_task(void) {
for (uint8_t i = 0; i < thisCount; i++) {
encoder_quadrature_handle_read(i, encoder_quadrature_read_pin(i, false), encoder_quadrature_read_pin(i, true));
Expand Down
2 changes: 1 addition & 1 deletion keyboards/keychron/common/keychron_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void keychron_common_task(void) {
#ifdef ENCODER_ENABLE
static void encoder0_pad_cb(void *param) {
(void)param;
encoder_inerrupt_read(0);
encoder_quadrature_inerrupt_read(0);
}

void encoder_cb_init(void) {
Expand Down
2 changes: 1 addition & 1 deletion quantum/encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bool encoder_dequeue_event(uint8_t *index, bool *clockwise);

bool encoder_update_kb(uint8_t index, bool clockwise);
bool encoder_update_user(uint8_t index, bool clockwise);
void encoder_inerrupt_read(uint8_t index);
void encoder_quadrature_inerrupt_read(uint8_t index);

# ifdef SPLIT_KEYBOARD

Expand Down
21 changes: 0 additions & 21 deletions quantum/rgb_matrix/rgb_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
#include "color.h"
#include "keyboard.h"

#if defined(RGB_MATRIX_SNLED27351_SPI)
# include "snled27351-spi.h"
#endif

#ifndef RGB_MATRIX_TIMEOUT
# define RGB_MATRIX_TIMEOUT 0
#endif
Expand Down Expand Up @@ -277,23 +273,6 @@ bool rgb_matrix_driver_allow_shutdown(void);
# define rgblight_decrease_speed_noeeprom rgb_matrix_decrease_speed_noeeprom
#endif

typedef struct {
/* Perform any initialisation required for the other driver functions to work. */
void (*init)(void);
/* Set the colour of a single LED in the buffer. */
void (*set_color)(int index, uint8_t r, uint8_t g, uint8_t b);
/* Set the colour of all LEDS on the keyboard in the buffer. */
void (*set_color_all)(uint8_t r, uint8_t g, uint8_t b);
/* Flush any buffered changes to the hardware. */
void (*flush)(void);
#ifdef RGB_MATRIX_DRIVER_SHUTDOWN_ENABLE
/* Shutdown the driver. */
void (*shutdown)(void);
/* Exit from shutdown state. */
void (*exit_shutdown)(void);
#endif
} rgb_matrix_driver_t;

static inline bool rgb_matrix_check_finished_leds(uint8_t led_idx) {
#if defined(RGB_MATRIX_SPLIT)
if (is_keyboard_left()) {
Expand Down
8 changes: 8 additions & 0 deletions quantum/rgb_matrix/rgb_matrix_drivers.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
# include "is31fl3746a.h"
#elif defined(RGB_MATRIX_SNLED27351)
# include "snled27351.h"
#elif defined(RGB_MATRIX_SNLED27351_SPI)
# include "snled27351-spi.h"
#elif defined(RGB_MATRIX_WS2812)
# include "ws2812.h"
#endif
Expand All @@ -44,6 +46,12 @@ typedef struct {
void (*set_color_all)(uint8_t r, uint8_t g, uint8_t b);
/* Flush any buffered changes to the hardware. */
void (*flush)(void);
#ifdef RGB_MATRIX_DRIVER_SHUTDOWN_ENABLE
/* Shutdown the driver. */
void (*shutdown)(void);
/* Exit from shutdown state. */
void (*exit_shutdown)(void);
#endif
} rgb_matrix_driver_t;

extern const rgb_matrix_driver_t rgb_matrix_driver;

0 comments on commit f8a6391

Please sign in to comment.