Minor cleanup

This commit is contained in:
2022-07-21 17:49:35 -07:00
parent 4cb3fe0ee9
commit e6cc6bfa10
11 changed files with 141 additions and 114 deletions

View File

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

View File

@ -3,7 +3,6 @@
void raw_hid_receive(uint8_t *data, uint8_t length);
void hid_send_word(void);
// 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 RGB_MATRIX_FRAMEBUFFER_EFFECTS
extern uint8_t g_rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS];
#ifdef BETA_ENABLE_SPELLCHECK
void hid_send_word(void);
#endif
// 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
#ifdef ENABLE_RGB_MATRIX_FFT_ANIM
void cmd_animation(uint8_t *data, uint8_t length);
extern uint8_t g_rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS];
#endif

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/beta_rawhid.h"
@ -108,3 +110,5 @@ bool process_spellcheck(uint16_t keycode, keyrecord_t* record) {
return true;
}
#endif

View File

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