Minor cleanup

master
Mark 2022-07-21 17:49:35 -07:00
parent 4cb3fe0ee9
commit e6cc6bfa10
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
11 changed files with 141 additions and 114 deletions

View File

@ -1,5 +1,8 @@
#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS #ifndef RGB_MATRIX_FRAMEBUFFER_EFFECTS
#ifndef DISABLE_RGB_MATRIX_FFT_ANIM #undef ENABLE_RGB_MATRIX_FFT_ANIM
#endif
#ifdef ENABLE_RGB_MATRIX_FFT_ANIM
RGB_MATRIX_EFFECT(FFT_ANIM) RGB_MATRIX_EFFECT(FFT_ANIM)
#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
@ -52,6 +55,5 @@ bool FFT_ANIM(effect_params_t* params) {
return led_max < sizeof(g_rgb_frame_buffer); return led_max < sizeof(g_rgb_frame_buffer);
} }
#endif
#endif #endif
#endif #endif

View File

@ -1,10 +1,15 @@
#include "betalupi_ergodox.h" #include "betalupi_ergodox.h"
#include "features/beta_rawhid.h"
#include "extra_mappings.h" #include "extra_mappings.h"
#include "features/beta_rawhid.h"
#include "features/rawhid_commands.h"
extern uint8_t layer_layouts[]; extern uint8_t layer_layouts[];
#ifdef BETA_ENABLE_SPELLCHECK
#include "features/spellcheck.h" #include "features/spellcheck.h"
#endif
// See features/beta_rawhid.h for prococol documentation // See features/beta_rawhid.h for prococol documentation
void raw_hid_receive(uint8_t *data, uint8_t length) { void raw_hid_receive(uint8_t *data, uint8_t length) {
@ -19,12 +24,13 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
hid_send_state(); hid_send_state();
break; break;
#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS #ifdef ENABLE_RGB_MATRIX_FFT_ANIM
case CMD_ANIM_DATA: case CMD_ANIM_DATA:
cmd_animation(data, length); cmd_animation(data, length);
break; break;
#endif #endif
#ifdef BETA_ENABLE_SPELLCHECK
case CMD_SPELLCHECK_WORD: case CMD_SPELLCHECK_WORD:
if (data[1]) { if (data[1]) {
ergodox_right_led_1_on(); ergodox_right_led_1_on();
@ -32,6 +38,7 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
ergodox_right_led_1_off(); ergodox_right_led_1_off();
} }
break; break;
#endif
default: default:
break; break;
@ -75,7 +82,7 @@ void _hid_send_state(_hid_send_state_args args) {
uint8_t mode = rgb_matrix_get_mode(); uint8_t mode = rgb_matrix_get_mode();
switch (mode) { switch (mode) {
#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS #ifdef ENABLE_RGB_MATRIX_FFT_ANIM
case RGB_MATRIX_CUSTOM_FFT_ANIM: case RGB_MATRIX_CUSTOM_FFT_ANIM:
// FFT Animation is active // FFT Animation is active
packet[1] = 0x02; packet[1] = 0x02;
@ -95,6 +102,7 @@ void _hid_send_state(_hid_send_state_args args) {
} }
#ifdef BETA_ENABLE_SPELLCHECK
void hid_send_word() { void hid_send_word() {
uint8_t packet[RAW_EPSIZE] = { uint8_t packet[RAW_EPSIZE] = {
CMD_SPELLCHECK_WORD, CMD_SPELLCHECK_WORD,
@ -107,12 +115,10 @@ void hid_send_word() {
raw_hid_send(packet, RAW_EPSIZE); raw_hid_send(packet, RAW_EPSIZE);
} }
#endif
#ifdef ENABLE_RGB_MATRIX_FFT_ANIM
#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS
#define FFT_PER_KEY 50 #define FFT_PER_KEY 50
void cmd_animation(uint8_t *data, uint8_t length) { void cmd_animation(uint8_t *data, uint8_t length) {
switch (data[1]) { switch (data[1]) {

View File

@ -3,7 +3,6 @@
void raw_hid_receive(uint8_t *data, uint8_t length); void raw_hid_receive(uint8_t *data, uint8_t length);
void hid_send_word(void);
// hid_send_state with advanced arguments // hid_send_state with advanced arguments
@ -20,89 +19,12 @@ void _hid_send_state(_hid_send_state_args args);
) )
void cmd_animation(uint8_t *data, uint8_t length); #ifdef BETA_ENABLE_SPELLCHECK
void hid_send_word(void);
#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS
extern uint8_t g_rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS];
#endif #endif
#ifdef ENABLE_RGB_MATRIX_FFT_ANIM
void cmd_animation(uint8_t *data, uint8_t length);
// Sent by host when connection is initiated. extern uint8_t g_rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS];
// #endif
// Packet structure:
// Data: | cmd |
// # of Bytes: | 1 |
#define CMD_HELLO 0x00
// Sent periodically by host to test connection.
// Keyboard should ignore this command.
//
// Packet structure:
// Data: | cmd |
// # of Bytes: | 1 |
#define CMD_RUTHERE 0x01
// Send keyboard state to host.
//
// Packet structure:
// Data: | cmd | anim state | layer state | layer layout |
// # of Bytes: | 1 | 1 | 4 | 1 |
//
// anim state:
// 0x00: RGBMatrix disabled
// 0x01: normal animation, no HID data.
// 0x02: FFT Animation
//
// layer state: layer state right now.
// This is a uint32_t, where each bit corresponds to a layer index.
// Lowest-order bit is base layer, highest bit is layer 31.
// Layer indices are defined by the LAYER_* enum in layer.h,
// host interface should have a matching enum.
// Make sure to update it when you change your layers!
//
// layer layout:
// The layout this layer was designed for.
// 0x00: en_us
// 0x01: russian
#define CMD_SEND_STATE 0x02
// Sent by keyboard to host when a complete word is typed.
// Host checks if this is a known word.
// If it is not, host responds with the same CMD (see below).
//
// Packet structure (sent by keyboard):
// Data: | cmd | word length | keycodes |
// # of Bytes: | 1 | 1 | ? |
//
// word length: number of bytes in `keycodes` block
//
//
// Packet structure (sent by host):
// Data: | cmd | typo? |
// # of Bytes: | 1 | 1 |
//
// typo: If this is 0x01, the word we got was a typo.
#define CMD_SPELLCHECK_WORD 0x04
// Animation data. Sent by host.
//
// Packet structure:
// Data: | cmd | data type | data |
// # of Bytes: | 1 | 1 | ? |
//
// data type:
// Which animation this data is for. These are defined below.
//
// data:
// Animation data. Content depends on data type.
#define CMD_ANIM_DATA 0x03
// Data for FFT animation.
// Data segment consists of 10 bits, each representing the height of a column.
// Minimum height is 0, maximum is 250.
#define CMD_ANIM_DATA_fft 0x00

View File

@ -0,0 +1,78 @@
#pragma once
// Sent by host when connection is initiated.
//
// Packet structure:
// Data: | cmd |
// # of Bytes: | 1 |
#define CMD_HELLO 0x00
// Sent periodically by host to test connection.
// Keyboard should ignore this command.
//
// Packet structure:
// Data: | cmd |
// # of Bytes: | 1 |
#define CMD_RUTHERE 0x01
// Send keyboard state to host.
//
// Packet structure:
// Data: | cmd | anim state | layer state | layer layout |
// # of Bytes: | 1 | 1 | 4 | 1 |
//
// anim state:
// 0x00: RGBMatrix disabled
// 0x01: normal animation, no HID data.
// 0x02: FFT Animation
//
// layer state: layer state right now.
// This is a uint32_t, where each bit corresponds to a layer index.
// Lowest-order bit is base layer, highest bit is layer 31.
// Layer indices are defined by the LAYER_* enum in layer.h,
// host interface should have a matching enum.
// Make sure to update it when you change your layers!
//
// layer layout:
// The layout this layer was designed for.
// 0x00: en_us
// 0x01: russian
#define CMD_SEND_STATE 0x02
// Sent by keyboard to host when a complete word is typed.
// Host checks if this is a known word.
// If it is not, host responds with the same CMD (see below).
//
// Packet structure (sent by keyboard):
// Data: | cmd | word length | keycodes |
// # of Bytes: | 1 | 1 | ? |
//
// word length: number of bytes in `keycodes` block
//
//
// Packet structure (sent by host):
// Data: | cmd | typo? |
// # of Bytes: | 1 | 1 |
//
// typo: If this is 0x01, the word we got was a typo.
#define CMD_SPELLCHECK_WORD 0x04
// Animation data. Sent by host.
//
// Packet structure:
// Data: | cmd | data type | data |
// # of Bytes: | 1 | 1 | ? |
//
// data type:
// Which animation this data is for. These are defined below.
//
// data:
// Animation data. Content depends on data type.
#define CMD_ANIM_DATA 0x03
// Data for FFT animation.
// Data segment consists of 10 bits, each representing the height of a column.
// Minimum height is 0, maximum is 250.
#define CMD_ANIM_DATA_fft 0x00

View File

@ -1,3 +1,5 @@
#ifdef BETA_ENABLE_SPELLCHECK
#include "features/spellcheck.h" #include "features/spellcheck.h"
#include "features/beta_rawhid.h" #include "features/beta_rawhid.h"
@ -108,3 +110,5 @@ bool process_spellcheck(uint16_t keycode, keyrecord_t* record) {
return true; return true;
} }
#endif

View File

@ -1,4 +1,7 @@
#pragma once #pragma once
#ifdef BETA_ENABLE_SPELLCHECK
#include "quantum.h" #include "quantum.h"
@ -12,4 +15,6 @@ uint8_t spellcheck_buffer[SPELLCHECK_BUFFER_MAX];
uint8_t spellcheck_buffer_size; uint8_t spellcheck_buffer_size;
bool process_spellcheck(uint16_t keycode, keyrecord_t* record); bool process_spellcheck(uint16_t keycode, keyrecord_t* record);
#endif

View File

@ -7,6 +7,9 @@
#define LEADER_TIMEOUT 250 #define LEADER_TIMEOUT 250
// Enable spellcheck over HID
#define BETA_ENABLE_SPELLCHECK
// RGBLight effects // RGBLight effects
// Static color is always enabled. // Static color is always enabled.
//#define RGBLIGHT_EFFECT_ALTERNATING //#define RGBLIGHT_EFFECT_ALTERNATING
@ -20,5 +23,7 @@
//#define RGBLIGHT_EFFECT_STATIC_GRADIENT //#define RGBLIGHT_EFFECT_STATIC_GRADIENT
//#define RGBLIGHT_EFFECT_TWINKLE //#define RGBLIGHT_EFFECT_TWINKLE
// Special effects // Custom effects
//#define RGB_MATRIX_FRAMEBUFFER_EFFECTS #define RGB_MATRIX_FRAMEBUFFER_EFFECTS
#define ENABLE_RGB_MATRIX_FFT_ANIM // Requires framebuffer

View File

@ -1,7 +1,10 @@
#include "keymap.h" #include "keymap.h"
#include "layers/layers.h" #include "layers/layers.h"
#ifdef BETA_ENABLE_SPELLCHECK
#include "features/spellcheck.h" #include "features/spellcheck.h"
#endif
#include "features/beta_rawhid.h" #include "features/beta_rawhid.h"
// Values that should not be saved to git. // Values that should not be saved to git.
@ -37,20 +40,13 @@ void matrix_scan_user(void) {
} }
} }
uint32_t layer_state_set_user(uint32_t state) {
set_layer_colors(state);
//uint8_t layer = biton32(state);
return state;
};
// Return FALSE to halt key processing, // Return FALSE to halt key processing,
// Return TRUE to allow QMK to handle keypress. // Return TRUE to allow QMK to handle keypress.
bool process_record_user(uint16_t keycode, keyrecord_t *record) { bool process_record_user(uint16_t keycode, keyrecord_t *record) {
#ifdef BETA_ENABLE_SPELLCHECK
if (!process_spellcheck(keycode, record)) { return false; } if (!process_spellcheck(keycode, record)) { return false; }
#endif
// Handle macros // Handle macros
switch (keycode) { switch (keycode) {

View File

@ -49,7 +49,7 @@ void set_layer_color(int layer) {
void rgb_matrix_indicators_user(void) { void set_layer_matrix_indicator(void) {
if (keyboard_config.disable_layer_led) { if (keyboard_config.disable_layer_led) {
return; return;
} }
@ -78,8 +78,7 @@ void rgb_matrix_indicators_user(void) {
uint32_t set_layer_colors(uint32_t state) { uint32_t layer_state_set_user(uint32_t state) {
uint8_t layer = biton32(state); uint8_t layer = biton32(state);
ergodox_board_led_off(); ergodox_board_led_off();

View File

@ -35,7 +35,7 @@ enum led_indices {
extern uint8_t layer_layouts[]; extern uint8_t layer_layouts[];
void set_layer_color(int layer); void set_layer_color(int layer); // Helper method
void rgb_matrix_indicators_user(void); void rgb_matrix_indicators_user(void); // QMK method
uint32_t set_layer_colors(uint32_t state); uint32_t layer_state_set_user(uint32_t state); // QMK method

View File

@ -30,6 +30,16 @@ See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_to
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
# Notes # Notes
Custom configuration defines
```cpp
// Enable fft animation (requires RGB_MATRIX_FRAMEBUFFER_EFFECTS)
#def ENABLE_RGB_MATRIX_FFT_ANIM
// Enable spellcheck over hid (features/spellcheck)
#def ENABLE_SPELLCHECK
```
Custom keycodes (betalupi_keyboard.c) Custom keycodes (betalupi_keyboard.c)
``` ```