Merge remote-tracking branch 'origin/master' into develop

master
Joshua Diamond 2022-09-28 16:47:03 -04:00
commit d2e5e64990
7 changed files with 76 additions and 45 deletions

View File

@ -28,7 +28,7 @@ const uint8_t led_map[RGB_MATRIX_LED_COUNT] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 0xff, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 68, 69,
// right side - 36 keys includes LP
0 + LPH, 1 + LPH, 2 + LPH, 3 + LPH, 4 + LPH, 5 + LPH, 6 + LPH, 15 + LPH, 8 + LPH, 9 + LPH, 10 + LPH, 11 + LPH, 12 + LPH, 13 + LPH, 14 + LPH, 7 + LPH, 16 + LPH, 17 + LPH, 18 + LPH, 19 + LPH,
0 + LPH, 1 + LPH, 2 + LPH, 3 + LPH, 4 + LPH, 5 + LPH, 6 + LPH, 7 + LPH, 8 + LPH, 9 + LPH, 10 + LPH, 11 + LPH, 12 + LPH, 13 + LPH, 14 + LPH, 15 + LPH, 16 + LPH, 17 + LPH, 18 + LPH, 19 + LPH,
20 + LPH, 21 + LPH, 22 + LPH, 23 + LPH, 24 + LPH, 25 + LPH, 26 + LPH, 27 + LPH, 28 + LPH, 29 + LPH, 30 + LPH, 31 + LPH, 32 + LPH, 33 + LPH, 68 + LPH, 69 + LPH,
// left under glow - 30
@ -50,11 +50,11 @@ led_config_t g_led_config = { {
{ 26 , 27 , 28 , 29 , 30 , NO_LED , 31 , 32 } ,
// right hand
{ NO_LED , 6 + LHK , 5 + LHK , 4 + LHK , 3 + LHK , 2 + LHK , 1 + LHK , 0 + LHK } ,
{ 14 + LHK , 13 + LHK , 12 + LHK , 11 + LHK , 10 + LHK , 9 + LHK , 8 + LHK , 7 + LHK } ,
{ NO_LED , 21 + LHK , 20 + LHK , 19 + LHK , 18 + LHK , 17 + LHK , 16 + LHK , 15 + LHK } ,
{ NO_LED , NO_LED , 27 + LHK , 26 + LHK , 25 + LHK , 24 + LHK , 23 + LHK , 22 + LHK } ,
{ 35 + LHK , 34 + LHK , 33 + LHK , 32 + LHK , 31 + LHK , 30 + LHK , 29 + LHK , 28 + LHK }
{ 33 , 34 , 35 , 36 , 37 , 38 , 39 , NO_LED } ,
{ 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47 } ,
{ 48 , 49 , 50 , 51 , 52 , 53 , 54 , NO_LED } ,
{ 55 , 56 , 57 , 58 , 59 , 60 , NO_LED , NO_LED } ,
{ 61 , 62 , 63 , 64 , 65 , 66 , 67 , 68 }
}, {
// generated from the svg image of the keyboard, see create-led-config.js
{82, 3}, {88, 3}, {94, 3}, {100, 3}, {106, 3}, {112, 3}, {118, 3}, {84, 10}, {91, 10}, {97, 10}, {103, 10}, {109, 10},

View File

@ -25,3 +25,33 @@
#define DEBOUNCE 0
#define RGB_MATRIX_LED_COUNT 132
#ifdef RGB_MATRIX_ENABLE
// At the default flush limit of 16ms (~62.5 fps), the matrix scan rate is approximately
// ~140 scans per second under full load (when changes are being made to the LED state).
// Such a low scan rate will have impact the keyboard's accuracy for faster typists.
//
// With RGB completely disabled, the matrix scan rate is ~660 scans per second, and typing
// accuracy feels on par with the Dygma Raise Neuron.
//
// At 100ms (10 fps), the matrix scan rate is ~355 scans per second under full load, and typing
// accuracy is reasonably good.
#define RGB_MATRIX_LED_FLUSH_LIMIT 100
#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
#define RGB_MATRIX_KEYPRESSES
#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
// enabled only if RGB_MATRIX_FRAMEBUFFER_EFFECTS is defined
#define ENABLE_RGB_MATRIX_TYPING_HEATMAP
//# define ENABLE_RGB_MATRIX_DIGITAL_RAIN
// enabled only of RGB_MATRIX_KEYPRESSES or RGB_MATRIX_KEYRELEASES is defined
#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
#define ENABLE_RGB_MATRIX_SOLID_REACTIVE
#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE
#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS
#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS
#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS
#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS
#endif

View File

@ -50,11 +50,11 @@ led_config_t g_led_config = { {
{ 26 , 27 , 28 , 29 , 30 , NO_LED , 31 , 32 } ,
// right hand
{ NO_LED , 6 + LHK , 5 + LHK , 4 + LHK , 3 + LHK , 2 + LHK , 1 + LHK , 0 + LHK } ,
{ 14 + LHK , 13 + LHK , 12 + LHK , 11 + LHK , 10 + LHK , 9 + LHK , 8 + LHK , 7 + LHK } ,
{ NO_LED , 21 + LHK , 20 + LHK , 19 + LHK , 18 + LHK , 17 + LHK , 16 + LHK , 15 + LHK } ,
{ NO_LED , NO_LED , 27 + LHK , 26 + LHK , 25 + LHK , 24 + LHK , 23 + LHK , 22 + LHK } ,
{ 35 + LHK , 34 + LHK , 33 + LHK , 32 + LHK , 31 + LHK , 30 + LHK , 29 + LHK , 28 + LHK }
{ 33 , 34 , 35 , 36 , 37 , 38 , 39 , NO_LED } ,
{ 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47 } ,
{ 48 , 49 , 50 , 51 , 52 , 53 , 54 , NO_LED } ,
{ 55 , 56 , 57 , 58 , 59 , 60 , NO_LED , NO_LED } ,
{ 61 , 62 , 63 , 64 , 65 , 66 , 67 , 68 }
}, {
// generated from the svg image of the keyboard, see create-led-config.js
{82, 3}, {88, 3}, {94, 3}, {100, 3}, {106, 3}, {112, 3}, {118, 3}, {84, 10}, {91, 10}, {97, 10}, {103, 10}, {109, 10},

View File

@ -24,16 +24,17 @@
#include "print.h"
#include "leds.h"
struct __attribute__((packed)) cRGB {
// Color order of LEDs is Green, Red, Blue.
typedef struct PACKED {
uint8_t r;
uint8_t g;
uint8_t b;
};
} raiseRGB;
#define LEDS_PER_HAND 72
#define LED_BANKS 9
#define LEDS_PER_BANK 8
#define LED_BYTES_PER_BANK (sizeof(cRGB) * LEDS_PER_BANK)
#define LED_BYTES_PER_BANK (sizeof(raiseRGB) * LEDS_PER_BANK)
// shifting << 1 is because drivers/chibios/i2c_master.h expects the address
// shifted.
@ -44,37 +45,28 @@ struct __attribute__((packed)) cRGB {
#define LEFT 0
#define RIGHT 1
static cRGB led_state[2 * LEDS_PER_HAND];
void set_all_leds_to(uint8_t r, uint8_t g, uint8_t b) {
uint8_t buf[] = {TWI_CMD_LED_SET_ALL_TO, b, g, r};
i2c_transmit(I2C_ADDR(LEFT), buf, sizeof(buf), I2C_TIMEOUT);
wait_us(10);
i2c_transmit(I2C_ADDR(RIGHT), buf, sizeof(buf), I2C_TIMEOUT);
wait_us(10);
}
void set_led_to(int led, uint8_t r, uint8_t g, uint8_t b) {
int sled = led_map[led];
uint8_t buf[] = {TWI_CMD_LED_SET_ONE_TO, sled & 0x1f, b, g, r};
int hand = (sled >= LEDS_PER_HAND) ? RIGHT : LEFT;
i2c_transmit(I2C_ADDR(hand), buf, sizeof(buf), I2C_TIMEOUT);
wait_us(10);
}
static raiseRGB led_pending[2 * LEDS_PER_HAND];
static raiseRGB led_state[2 * LEDS_PER_HAND];
static void set_color(int index, uint8_t r, uint8_t g, uint8_t b) {
int sled = led_map[index];
led_state[sled].r = r;
led_state[sled].g = g;
led_state[sled].b = b;
// The red component of the LED is apparently stronger than the others.
// From: https://github.com/keyboardio/Kaleidoscope/blob/aba8c9ee66bbb5ded15135618d2b2964ee82b2cc/plugins/Kaleidoscope-Hardware-Dygma-Raise/src/kaleidoscope/device/dygma/raise/RaiseSide.cpp#L235-L242
if (r >= 26) {
r -= 26;
}
led_pending[sled].r = r;
led_pending[sled].g = g;
led_pending[sled].b = b;
}
static void set_color_all(uint8_t r, uint8_t g, uint8_t b) {
for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) set_color(i, r, g, b);
}
static void init(void) {}
static void init(void) {
set_color_all(0,0,0);
}
static void flush(void) {
uint8_t command[1 + LED_BYTES_PER_BANK];
@ -86,10 +78,17 @@ static void flush(void) {
for (int hand = 0; hand < 2; hand++) {
int addr = I2C_ADDR(hand);
int i = (hand * LEDS_PER_HAND) + (bank * LEDS_PER_BANK);
uint8_t *bank_data = (uint8_t *)&led_state[i];
if (memcmp(&led_state[i], &led_pending[i], LED_BYTES_PER_BANK) == 0) {
// No change.
continue;
}
// Update LED state
memcpy(&led_state[i], &led_pending[i], LED_BYTES_PER_BANK);
command[0] = TWI_CMD_LED_BASE + bank;
memcpy(&command[1], bank_data, LED_BYTES_PER_BANK);
memcpy(&command[1], &led_pending[i], LED_BYTES_PER_BANK);
i2c_transmit(addr, command, sizeof(command), I2C_TIMEOUT);
// delay to prevent issues with the i2c bus

View File

@ -0,0 +1,3 @@
ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
SRC += leds.c
endif

View File

@ -17,6 +17,5 @@
#include "raise.h"
void keyboard_post_init_kb(void) {
set_all_leds_to(0, 0, 0);
keyboard_post_init_user();
}

View File

@ -10,7 +10,7 @@ BOOTLOADER = stm32-dfu
#
BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite
MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = no # Audio control and System control
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = no # Console for debug
COMMAND_ENABLE = no # Commands for debug and configuration
NKRO_ENABLE = no # Enable N-Key Rollover
@ -28,6 +28,6 @@ CUSTOM_MATRIX = lite
RAW_ENABLE = yes
QUANTUM_LIB_SRC += i2c_master.c
SRC += leds.c matrix.c
SRC += matrix.c
DEFAULT_FOLDER = handwired/dygma/raise/ansi