Compare commits
10 Commits
0.7.154
...
planck_ez_
Author | SHA1 | Date | |
---|---|---|---|
|
9c0137f954 | ||
|
08fd17b3fd | ||
|
fd519c7ca8 | ||
|
44006889d7 | ||
|
f6fd320049 | ||
|
96e6c1fa31 | ||
|
e7d3cf02ba | ||
|
74b7c3a4fb | ||
|
161c4b21dc | ||
|
8073da5dea |
@ -114,7 +114,7 @@ ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
|
||||
endif
|
||||
endif
|
||||
|
||||
VALID_MATRIX_TYPES := yes IS31FL3731 IS31FL3733 custom
|
||||
VALID_MATRIX_TYPES := yes IS31FL3731 IS31FL3733 IS31FL3737 custom
|
||||
|
||||
LED_MATRIX_ENABLE ?= no
|
||||
ifneq ($(strip $(LED_MATRIX_ENABLE)), no)
|
||||
@ -135,6 +135,7 @@ ifeq ($(strip $(LED_MATRIX_ENABLE)), IS31FL3731)
|
||||
endif
|
||||
|
||||
RGB_MATRIX_ENABLE ?= no
|
||||
|
||||
ifneq ($(strip $(RGB_MATRIX_ENABLE)), no)
|
||||
ifeq ($(filter $(RGB_MATRIX_ENABLE),$(VALID_MATRIX_TYPES)),)
|
||||
$(error RGB_MATRIX_ENABLE="$(RGB_MATRIX_ENABLE)" is not a valid matrix type)
|
||||
@ -151,19 +152,26 @@ ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3731)
|
||||
OPT_DEFS += -DIS31FL3731
|
||||
OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/issi
|
||||
SRC += is31fl3731.c
|
||||
SRC += i2c_master.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3733)
|
||||
OPT_DEFS += -DIS31FL3733
|
||||
OPT_DEFS += -DIS31FL3733 -DSTM32_I2C -DHAL_USE_I2C=TRUE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/issi
|
||||
SRC += is31fl3733.c
|
||||
SRC += i2c_master.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3737)
|
||||
OPT_DEFS += -DIS31FL3737 -DSTM32_I2C -DHAL_USE_I2C=TRUE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/issi
|
||||
SRC += is31fl3737.c
|
||||
SRC += i2c_master.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
|
||||
OPT_DEFS += -DTAP_DANCE_ENABLE
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
|
||||
|
File diff suppressed because it is too large
Load Diff
252
drivers/issi/is31fl3737.c
Normal file
252
drivers/issi/is31fl3737.c
Normal file
@ -0,0 +1,252 @@
|
||||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef __AVR__
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#else
|
||||
#include "wait.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include "i2c_master.h"
|
||||
#include "progmem.h"
|
||||
#include "rgb_matrix.h"
|
||||
|
||||
// This is a 7-bit address, that gets left-shifted and bit 0
|
||||
// set to 0 for write, 1 for read (as per I2C protocol)
|
||||
// The address will vary depending on your wiring:
|
||||
// 00 <-> GND
|
||||
// 01 <-> SCL
|
||||
// 10 <-> SDA
|
||||
// 11 <-> VCC
|
||||
// ADDR1 represents A1:A0 of the 7-bit address.
|
||||
// ADDR2 represents A3:A2 of the 7-bit address.
|
||||
// The result is: 0b101(ADDR2)(ADDR1)
|
||||
#define ISSI_ADDR_DEFAULT 0x50
|
||||
|
||||
#define ISSI_COMMANDREGISTER 0xFD
|
||||
#define ISSI_COMMANDREGISTER_WRITELOCK 0xFE
|
||||
#define ISSI_INTERRUPTMASKREGISTER 0xF0
|
||||
#define ISSI_INTERRUPTSTATUSREGISTER 0xF1
|
||||
|
||||
#define ISSI_PAGE_LEDCONTROL 0x00 //PG0
|
||||
#define ISSI_PAGE_PWM 0x01 //PG1
|
||||
#define ISSI_PAGE_AUTOBREATH 0x02 //PG2
|
||||
#define ISSI_PAGE_FUNCTION 0x03 //PG3
|
||||
|
||||
#define ISSI_REG_CONFIGURATION 0x00 //PG3
|
||||
#define ISSI_REG_GLOBALCURRENT 0x01 //PG3
|
||||
#define ISSI_REG_RESET 0x11// PG3
|
||||
#define ISSI_REG_SWPULLUP 0x0F //PG3
|
||||
#define ISSI_REG_CSPULLUP 0x10 //PG3
|
||||
|
||||
#ifndef ISSI_TIMEOUT
|
||||
#define ISSI_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef ISSI_PERSISTENCE
|
||||
#define ISSI_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
// Transfer buffer for TWITransmitData()
|
||||
uint8_t g_twi_transfer_buffer[20];
|
||||
|
||||
// These buffers match the IS31FL3737 PWM registers.
|
||||
// The control buffers match the PG0 LED On/Off registers.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
// We could optimize this and take out the unused registers from these
|
||||
// buffers and the transfers in IS31FL3737_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
uint8_t g_pwm_buffer[DRIVER_COUNT][192];
|
||||
bool g_pwm_buffer_update_required = false;
|
||||
|
||||
uint8_t g_led_control_registers[DRIVER_COUNT][24] = { { 0 } };
|
||||
bool g_led_control_registers_update_required = false;
|
||||
|
||||
void IS31FL3737_write_register( uint8_t addr, uint8_t reg, uint8_t data )
|
||||
{
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void IS31FL3737_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer )
|
||||
{
|
||||
// assumes PG1 is already selected
|
||||
|
||||
// transmit PWM registers in 12 transfers of 16 bytes
|
||||
// g_twi_transfer_buffer[] is 20 bytes
|
||||
|
||||
// iterate over the pwm_buffer contents at 16 byte intervals
|
||||
for ( int i = 0; i < 192; i += 16 ) {
|
||||
g_twi_transfer_buffer[0] = i;
|
||||
// copy the data from i to i+15
|
||||
// device will auto-increment register for data after the first byte
|
||||
// thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer
|
||||
for ( int j = 0; j < 16; j++ ) {
|
||||
g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j];
|
||||
}
|
||||
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3737_init( uint8_t addr )
|
||||
{
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
|
||||
// Unlock the command register.
|
||||
IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
|
||||
// Select PG0
|
||||
IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL );
|
||||
// Turn off all LEDs.
|
||||
for ( int i = 0x00; i <= 0x17; i++ )
|
||||
{
|
||||
IS31FL3737_write_register( addr, i, 0x00 );
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
|
||||
// Select PG1
|
||||
IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM );
|
||||
// Set PWM on all LEDs to 0
|
||||
// No need to setup Breath registers to PWM as that is the default.
|
||||
for ( int i = 0x00; i <= 0xBF; i++ )
|
||||
{
|
||||
IS31FL3737_write_register( addr, i, 0x00 );
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
|
||||
// Select PG3
|
||||
IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION );
|
||||
// Set global current to maximum.
|
||||
IS31FL3737_write_register( addr, ISSI_REG_GLOBALCURRENT, 0xFF );
|
||||
// Disable software shutdown.
|
||||
IS31FL3737_write_register( addr, ISSI_REG_CONFIGURATION, 0x01 );
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
#ifdef __AVR__
|
||||
_delay_ms( 10 );
|
||||
#else
|
||||
wait_ms(10);
|
||||
#endif
|
||||
}
|
||||
|
||||
void IS31FL3737_set_color( int index, uint8_t red, uint8_t green, uint8_t blue )
|
||||
{
|
||||
if ( index >= 0 && index < DRIVER_LED_TOTAL ) {
|
||||
is31_led led = g_is31_leds[index];
|
||||
|
||||
g_pwm_buffer[led.driver][led.r] = red;
|
||||
g_pwm_buffer[led.driver][led.g] = green;
|
||||
g_pwm_buffer[led.driver][led.b] = blue;
|
||||
g_pwm_buffer_update_required = true;
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3737_set_color_all( uint8_t red, uint8_t green, uint8_t blue )
|
||||
{
|
||||
for ( int i = 0; i < DRIVER_LED_TOTAL; i++ )
|
||||
{
|
||||
IS31FL3737_set_color( i, red, green, blue );
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3737_set_led_control_register( uint8_t index, bool red, bool green, bool blue )
|
||||
{
|
||||
is31_led led = g_is31_leds[index];
|
||||
|
||||
uint8_t control_register_r = led.r / 8;
|
||||
uint8_t control_register_g = led.g / 8;
|
||||
uint8_t control_register_b = led.b / 8;
|
||||
uint8_t bit_r = led.r % 8;
|
||||
uint8_t bit_g = led.g % 8;
|
||||
uint8_t bit_b = led.b % 8;
|
||||
|
||||
if ( red ) {
|
||||
g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r);
|
||||
}
|
||||
if ( green ) {
|
||||
g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g);
|
||||
}
|
||||
if ( blue ) {
|
||||
g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b);
|
||||
}
|
||||
|
||||
g_led_control_registers_update_required = true;
|
||||
|
||||
}
|
||||
|
||||
void IS31FL3737_update_pwm_buffers( uint8_t addr1, uint8_t addr2 )
|
||||
{
|
||||
if ( g_pwm_buffer_update_required )
|
||||
{
|
||||
// Firstly we need to unlock the command register and select PG1
|
||||
IS31FL3737_write_register( addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
IS31FL3737_write_register( addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM );
|
||||
|
||||
IS31FL3737_write_pwm_buffer( addr1, g_pwm_buffer[0] );
|
||||
//IS31FL3737_write_pwm_buffer( addr2, g_pwm_buffer[1] );
|
||||
}
|
||||
g_pwm_buffer_update_required = false;
|
||||
}
|
||||
|
||||
void IS31FL3737_update_led_control_registers( uint8_t addr1, uint8_t addr2 )
|
||||
{
|
||||
if ( g_led_control_registers_update_required )
|
||||
{
|
||||
// Firstly we need to unlock the command register and select PG0
|
||||
IS31FL3737_write_register( addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
|
||||
IS31FL3737_write_register( addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL );
|
||||
for ( int i=0; i<24; i++ )
|
||||
{
|
||||
IS31FL3737_write_register(addr1, i, g_led_control_registers[0][i] );
|
||||
//IS31FL3737_write_register(addr2, i, g_led_control_registers[1][i] );
|
||||
}
|
||||
}
|
||||
}
|
207
drivers/issi/is31fl3737.h
Normal file
207
drivers/issi/is31fl3737.h
Normal file
@ -0,0 +1,207 @@
|
||||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef IS31FL3737_DRIVER_H
|
||||
#define IS31FL3737_DRIVER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct is31_led {
|
||||
uint8_t driver:2;
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
} __attribute__((packed)) is31_led;
|
||||
|
||||
extern const is31_led g_is31_leds[DRIVER_LED_TOTAL];
|
||||
|
||||
void IS31FL3737_init( uint8_t addr );
|
||||
void IS31FL3737_write_register( uint8_t addr, uint8_t reg, uint8_t data );
|
||||
void IS31FL3737_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer );
|
||||
|
||||
void IS31FL3737_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
|
||||
void IS31FL3737_set_color_all( uint8_t red, uint8_t green, uint8_t blue );
|
||||
|
||||
void IS31FL3737_set_led_control_register( uint8_t index, bool red, bool green, bool blue );
|
||||
|
||||
// This should not be called from an interrupt
|
||||
// (eg. from a timer interrupt).
|
||||
// Call this while idle (in between matrix scans).
|
||||
// If the buffer is dirty, it will update the driver with the buffer.
|
||||
void IS31FL3737_update_pwm_buffers( uint8_t addr1, uint8_t addr2 );
|
||||
void IS31FL3737_update_led_control_registers( uint8_t addr1, uint8_t addr2 );
|
||||
|
||||
#define A_1 0x00
|
||||
#define A_2 0x01
|
||||
#define A_3 0x02
|
||||
#define A_4 0x03
|
||||
#define A_5 0x04
|
||||
#define A_6 0x05
|
||||
#define A_7 0x08
|
||||
#define A_8 0x09
|
||||
#define A_9 0x0A
|
||||
#define A_10 0x0B
|
||||
#define A_11 0x0C
|
||||
#define A_12 0x0D
|
||||
|
||||
#define B_1 0x10
|
||||
#define B_2 0x11
|
||||
#define B_3 0x12
|
||||
#define B_4 0x13
|
||||
#define B_5 0x14
|
||||
#define B_6 0x15
|
||||
#define B_7 0x18
|
||||
#define B_8 0x19
|
||||
#define B_9 0x1A
|
||||
#define B_10 0x1B
|
||||
#define B_11 0x1C
|
||||
#define B_12 0x1D
|
||||
|
||||
#define C_1 0x20
|
||||
#define C_2 0x21
|
||||
#define C_3 0x22
|
||||
#define C_4 0x23
|
||||
#define C_5 0x24
|
||||
#define C_6 0x25
|
||||
#define C_7 0x28
|
||||
#define C_8 0x29
|
||||
#define C_9 0x2A
|
||||
#define C_10 0x2B
|
||||
#define C_11 0x2C
|
||||
#define C_12 0x2D
|
||||
|
||||
#define D_1 0x30
|
||||
#define D_2 0x31
|
||||
#define D_3 0x32
|
||||
#define D_4 0x33
|
||||
#define D_5 0x34
|
||||
#define D_6 0x35
|
||||
#define D_7 0x38
|
||||
#define D_8 0x39
|
||||
#define D_9 0x3A
|
||||
#define D_10 0x3B
|
||||
#define D_11 0x3C
|
||||
#define D_12 0x3D
|
||||
|
||||
#define E_1 0x40
|
||||
#define E_2 0x41
|
||||
#define E_3 0x42
|
||||
#define E_4 0x43
|
||||
#define E_5 0x44
|
||||
#define E_6 0x45
|
||||
#define E_7 0x48
|
||||
#define E_8 0x49
|
||||
#define E_9 0x4A
|
||||
#define E_10 0x4B
|
||||
#define E_11 0x4C
|
||||
#define E_12 0x4D
|
||||
|
||||
#define F_1 0x50
|
||||
#define F_2 0x51
|
||||
#define F_3 0x52
|
||||
#define F_4 0x53
|
||||
#define F_5 0x54
|
||||
#define F_6 0x55
|
||||
#define F_7 0x58
|
||||
#define F_8 0x59
|
||||
#define F_9 0x5A
|
||||
#define F_10 0x5B
|
||||
#define F_11 0x5C
|
||||
#define F_12 0x5D
|
||||
|
||||
#define G_1 0x60
|
||||
#define G_2 0x61
|
||||
#define G_3 0x62
|
||||
#define G_4 0x63
|
||||
#define G_5 0x64
|
||||
#define G_6 0x65
|
||||
#define G_7 0x68
|
||||
#define G_8 0x69
|
||||
#define G_9 0x6A
|
||||
#define G_10 0x6B
|
||||
#define G_11 0x6C
|
||||
#define G_12 0x6D
|
||||
|
||||
#define H_1 0x70
|
||||
#define H_2 0x71
|
||||
#define H_3 0x72
|
||||
#define H_4 0x73
|
||||
#define H_5 0x74
|
||||
#define H_6 0x75
|
||||
#define H_7 0x78
|
||||
#define H_8 0x79
|
||||
#define H_9 0x7A
|
||||
#define H_10 0x7B
|
||||
#define H_11 0x7C
|
||||
#define H_12 0x7D
|
||||
|
||||
#define I_1 0x80
|
||||
#define I_2 0x81
|
||||
#define I_3 0x82
|
||||
#define I_4 0x83
|
||||
#define I_5 0x84
|
||||
#define I_6 0x85
|
||||
#define I_7 0x88
|
||||
#define I_8 0x89
|
||||
#define I_9 0x8A
|
||||
#define I_10 0x8B
|
||||
#define I_11 0x8C
|
||||
#define I_12 0x8D
|
||||
|
||||
#define J_1 0x90
|
||||
#define J_2 0x91
|
||||
#define J_3 0x92
|
||||
#define J_4 0x93
|
||||
#define J_5 0x94
|
||||
#define J_6 0x95
|
||||
#define J_7 0x98
|
||||
#define J_8 0x99
|
||||
#define J_9 0x9A
|
||||
#define J_10 0x9B
|
||||
#define J_11 0x9C
|
||||
#define J_12 0x9D
|
||||
|
||||
#define K_1 0xA0
|
||||
#define K_2 0xA1
|
||||
#define K_3 0xA2
|
||||
#define K_4 0xA3
|
||||
#define K_5 0xA4
|
||||
#define K_6 0xA5
|
||||
#define K_7 0xA8
|
||||
#define K_8 0xA9
|
||||
#define K_9 0xAA
|
||||
#define K_10 0xAB
|
||||
#define K_11 0xAC
|
||||
#define K_12 0xAD
|
||||
|
||||
#define L_1 0xB0
|
||||
#define L_2 0xB1
|
||||
#define L_3 0xB2
|
||||
#define L_4 0xB3
|
||||
#define L_5 0xB4
|
||||
#define L_6 0xB5
|
||||
#define L_7 0xB8
|
||||
#define L_8 0xB9
|
||||
#define L_9 0xBA
|
||||
#define L_10 0xBB
|
||||
#define L_11 0xBC
|
||||
#define L_12 0xBD
|
||||
|
||||
#endif // IS31FL3737_DRIVER_H
|
@ -22,7 +22,6 @@
|
||||
#define DEBOUNCE 3
|
||||
#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
|
||||
#define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended
|
||||
#define RGB_MATRIX_SKIP_FRAMES 10
|
||||
#define RGB_MATRIX_KEYPRESSES
|
||||
#define DISABLE_RGB_MATRIX_SPLASH
|
||||
#define DISABLE_RGB_MATRIX_MULTISPLASH
|
||||
|
@ -23,7 +23,6 @@
|
||||
#define DEBOUNCE 3
|
||||
#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
|
||||
#define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended
|
||||
#define RGB_MATRIX_SKIP_FRAMES 10
|
||||
#define RGB_MATRIX_KEYPRESSES
|
||||
#define DISABLE_RGB_MATRIX_SPLASH
|
||||
#define DISABLE_RGB_MATRIX_MULTISPLASH
|
||||
|
@ -109,7 +109,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define DRIVER_1_LED_TOTAL 24
|
||||
#define DRIVER_2_LED_TOTAL 24
|
||||
#define DRIVER_LED_TOTAL DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL
|
||||
#define RGB_MATRIX_SKIP_FRAMES 10
|
||||
|
||||
// #define RGBLIGHT_COLOR_LAYER_0 0x00, 0x00, 0xFF
|
||||
/* #define RGBLIGHT_COLOR_LAYER_1 0x00, 0x00, 0xFF */
|
||||
|
@ -120,7 +120,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
|
||||
#define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended
|
||||
#define RGB_MATRIX_SKIP_FRAMES 0
|
||||
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 215
|
||||
|
||||
#define DRIVER_ADDR_1 0b1110100
|
||||
|
141
keyboards/planck/ez/config.h
Normal file
141
keyboards/planck/ez/config.h
Normal file
@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright 2018 Jack Humbert <jack.humb@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define DEVICE_VER 0x0000
|
||||
|
||||
#undef MATRIX_ROWS
|
||||
#undef MATRIX_COLS
|
||||
/* key matrix size */
|
||||
#define MATRIX_ROWS 8
|
||||
#define MATRIX_COLS 6
|
||||
|
||||
/*
|
||||
* Keyboard Matrix Assignments
|
||||
*
|
||||
* Change this to how you wired your keyboard
|
||||
* COLS: AVR pins used for columns, left to right
|
||||
* ROWS: AVR pins used for rows, top to bottom
|
||||
* DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
|
||||
* ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
|
||||
*
|
||||
*/
|
||||
|
||||
#undef MATRIX_ROW_PINS
|
||||
#undef MATRIX_COL_PINS
|
||||
|
||||
#define MATRIX_ROW_PINS { A10, A9, A8, B15, C13, C14, C15, A2 }
|
||||
#define MATRIX_COL_PINS { B11, B10, B2, B1, A7, B0 }
|
||||
|
||||
#define NUMBER_OF_ENCODERS 1
|
||||
#define ENCODERS_PAD_A { B12 }
|
||||
#define ENCODERS_PAD_B { B13 }
|
||||
|
||||
#define MUSIC_MAP
|
||||
#undef AUDIO_VOICES
|
||||
#undef C6_AUDIO
|
||||
|
||||
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
|
||||
#define DEBOUNCE 6
|
||||
|
||||
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
|
||||
//#define LOCKING_SUPPORT_ENABLE
|
||||
/* Locking resynchronize hack */
|
||||
//#define LOCKING_RESYNC_ENABLE
|
||||
|
||||
/*
|
||||
* Force NKRO
|
||||
*
|
||||
* Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved
|
||||
* state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the
|
||||
* makefile for this to work.)
|
||||
*
|
||||
* If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N)
|
||||
* until the next keyboard reset.
|
||||
*
|
||||
* NKRO may prevent your keystrokes from being detected in the BIOS, but it is
|
||||
* fully operational during normal computer usage.
|
||||
*
|
||||
* For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N)
|
||||
* or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by
|
||||
* bootmagic, NKRO mode will always be enabled until it is toggled again during a
|
||||
* power-up.
|
||||
*
|
||||
*/
|
||||
//#define FORCE_NKRO
|
||||
|
||||
/*
|
||||
* Feature disable options
|
||||
* These options are also useful to firmware size reduction.
|
||||
*/
|
||||
|
||||
/* disable debug print */
|
||||
//#define NO_DEBUG
|
||||
|
||||
/* disable print */
|
||||
//#define NO_PRINT
|
||||
|
||||
/* disable action features */
|
||||
//#define NO_ACTION_LAYER
|
||||
//#define NO_ACTION_TAPPING
|
||||
//#define NO_ACTION_ONESHOT
|
||||
//#define NO_ACTION_MACRO
|
||||
//#define NO_ACTION_FUNCTION
|
||||
|
||||
/*
|
||||
* MIDI options
|
||||
*/
|
||||
|
||||
/* Prevent use of disabled MIDI features in the keymap */
|
||||
//#define MIDI_ENABLE_STRICT 1
|
||||
|
||||
/* enable basic MIDI features:
|
||||
- MIDI notes can be sent when in Music mode is on
|
||||
*/
|
||||
//#define MIDI_BASIC
|
||||
|
||||
/* enable advanced MIDI features:
|
||||
- MIDI notes can be added to the keymap
|
||||
- Octave shift and transpose
|
||||
- Virtual sustain, portamento, and modulation wheel
|
||||
- etc.
|
||||
*/
|
||||
//#define MIDI_ADVANCED
|
||||
|
||||
/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */
|
||||
//#define MIDI_TONE_KEYCODE_OCTAVES 1
|
||||
|
||||
// #define WS2812_LED_N 2
|
||||
// #define RGBLED_NUM WS2812_LED_N
|
||||
// #define WS2812_TIM_N 2
|
||||
// #define WS2812_TIM_CH 2
|
||||
// #define PORT_WS2812 GPIOA
|
||||
// #define PIN_WS2812 1
|
||||
// #define WS2812_DMA_STREAM STM32_DMA1_STREAM2 // DMA stream for TIMx_UP (look up in reference manual under DMA Channel selection)
|
||||
//#define WS2812_DMA_CHANNEL 7 // DMA channel for TIMx_UP
|
||||
//#define WS2812_EXTERNAL_PULLUP
|
||||
|
||||
#define DRIVER_ADDR_1 0b1010000
|
||||
#define DRIVER_ADDR_2 0b1010000 // this is here for compliancy reasons.
|
||||
|
||||
#define DRIVER_COUNT 1
|
||||
#define DRIVER_1_LED_TOTAL 47
|
||||
#define DRIVER_LED_TOTAL DRIVER_1_LED_TOTAL
|
||||
|
||||
#define RGB_MATRIX_KEYPRESSES
|
175
keyboards/planck/ez/ez.c
Normal file
175
keyboards/planck/ez/ez.c
Normal file
@ -0,0 +1,175 @@
|
||||
/* Copyright 2018 Jack Humbert <jack.humb@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "ez.h"
|
||||
|
||||
const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
|
||||
/* Refer to IS31 manual for these locations
|
||||
* driver
|
||||
* | R location
|
||||
* | | G location
|
||||
* | | | B location
|
||||
* | | | | */
|
||||
{0, A_12, B_12, C_12},
|
||||
{0, A_11, B_11, C_11},
|
||||
{0, A_10, B_10, C_10},
|
||||
{0, A_9, B_9, C_9},
|
||||
{0, A_8, B_8, C_8},
|
||||
{0, A_7, B_7, C_7},
|
||||
|
||||
{0, G_12, H_12, I_12},
|
||||
{0, G_11, H_11, I_11},
|
||||
{0, G_10, H_10, I_10},
|
||||
{0, G_9, H_9, I_9},
|
||||
{0, G_8, H_8, I_8},
|
||||
{0, G_7, H_7, I_7},
|
||||
|
||||
{0, A_6, B_6, C_6},
|
||||
{0, A_5, B_5, C_5},
|
||||
{0, A_4, B_4, C_4},
|
||||
{0, A_3, B_3, C_3},
|
||||
{0, A_2, B_2, C_2},
|
||||
{0, A_1, B_1, C_1},
|
||||
|
||||
{0, G_6, H_6, I_6},
|
||||
{0, G_5, H_5, I_5},
|
||||
{0, G_4, H_4, I_4},
|
||||
{0, G_3, H_3, I_3},
|
||||
{0, G_2, H_2, I_2},
|
||||
{0, G_1, H_1, I_1},
|
||||
|
||||
{0, D_12, E_12, F_12},
|
||||
{0, D_11, E_11, F_11},
|
||||
{0, D_10, E_10, F_10},
|
||||
{0, D_9, E_9, F_9},
|
||||
{0, D_8, E_8, F_8},
|
||||
{0, D_7, E_7, F_7},
|
||||
|
||||
{0, J_12, K_12, L_12},
|
||||
{0, J_11, K_11, L_11},
|
||||
{0, J_10, K_10, L_10},
|
||||
{0, J_9, K_9, L_9},
|
||||
{0, J_8, K_8, L_8},
|
||||
{0, J_7, K_7, L_7},
|
||||
|
||||
{0, D_6, E_6, F_6},
|
||||
{0, D_5, E_5, F_5},
|
||||
{0, D_4, E_4, F_4},
|
||||
{0, D_3, E_3, F_3},
|
||||
{0, D_2, E_2, F_2},
|
||||
{0, D_1, E_1, F_1},
|
||||
|
||||
{0, J_6, K_6, L_6},
|
||||
{0, J_5, K_5, L_5},
|
||||
{0, J_4, K_4, L_4},
|
||||
{0, J_3, K_3, L_3},
|
||||
{0, J_2, K_2, L_2},
|
||||
|
||||
};
|
||||
|
||||
const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
|
||||
|
||||
/*{row | col << 4}
|
||||
| {x=0..224, y=0..64}
|
||||
| | modifier
|
||||
| | | */
|
||||
{{0|(0<<4)}, {20.36*0, 21.33*0}, 1},
|
||||
{{0|(1<<4)}, {20.36*1, 21.33*0}, 0},
|
||||
{{0|(2<<4)}, {20.36*2, 21.33*0}, 0},
|
||||
{{0|(3<<4)}, {20.36*3, 21.33*0}, 0},
|
||||
{{0|(4<<4)}, {20.36*4, 21.33*0}, 0},
|
||||
{{0|(5<<4)}, {20.36*5, 21.33*0}, 0},
|
||||
{{4|(0<<4)}, {20.36*6, 21.33*0}, 0},
|
||||
{{4|(1<<4)}, {20.36*7, 21.33*0}, 0},
|
||||
{{4|(2<<4)}, {20.36*8, 21.33*0}, 0},
|
||||
{{4|(3<<4)}, {20.36*9, 21.33*0}, 0},
|
||||
{{4|(4<<4)}, {20.36*10,21.33*0}, 0},
|
||||
{{4|(5<<4)}, {20.36*11,21.33*0}, 1},
|
||||
|
||||
{{1|(0<<4)}, {20.36*0, 21.33*1}, 1},
|
||||
{{1|(1<<4)}, {20.36*1, 21.33*1}, 0},
|
||||
{{1|(2<<4)}, {20.36*2, 21.33*1}, 0},
|
||||
{{1|(3<<4)}, {20.36*3, 21.33*1}, 0},
|
||||
{{1|(4<<4)}, {20.36*4, 21.33*1}, 0},
|
||||
{{1|(5<<4)}, {20.36*5, 21.33*1}, 0},
|
||||
{{5|(0<<4)}, {20.36*6, 21.33*1}, 0},
|
||||
{{5|(1<<4)}, {20.36*7, 21.33*1}, 0},
|
||||
{{5|(2<<4)}, {20.36*8, 21.33*1}, 0},
|
||||
{{5|(3<<4)}, {20.36*9, 21.33*1}, 0},
|
||||
{{5|(4<<4)}, {20.36*10,21.33*1}, 0},
|
||||
{{5|(5<<4)}, {20.36*11,21.33*1}, 1},
|
||||
|
||||
{{2|(0<<4)}, {20.36*0, 21.33*2}, 1},
|
||||
{{2|(1<<4)}, {20.36*1, 21.33*2}, 0},
|
||||
{{2|(2<<4)}, {20.36*2, 21.33*2}, 0},
|
||||
{{2|(3<<4)}, {20.36*3, 21.33*2}, 0},
|
||||
{{2|(4<<4)}, {20.36*4, 21.33*2}, 0},
|
||||
{{2|(5<<4)}, {20.36*5, 21.33*2}, 0},
|
||||
{{6|(0<<4)}, {20.36*6, 21.33*2}, 0},
|
||||
{{6|(1<<4)}, {20.36*7, 21.33*2}, 0},
|
||||
{{6|(2<<4)}, {20.36*8, 21.33*2}, 0},
|
||||
{{6|(3<<4)}, {20.36*9, 21.33*2}, 0},
|
||||
{{6|(4<<4)}, {20.36*10,21.33*2}, 0},
|
||||
{{6|(5<<4)}, {20.36*11,21.33*2}, 1},
|
||||
|
||||
{{3|(0<<4)}, {20.36*0, 21.33*3}, 1},
|
||||
{{3|(1<<4)}, {20.36*1, 21.33*3}, 1},
|
||||
{{3|(2<<4)}, {20.36*2, 21.33*3}, 1},
|
||||
{{7|(3<<4)}, {20.36*3, 21.33*3}, 1},
|
||||
{{7|(4<<4)}, {20.36*4, 21.33*3}, 1},
|
||||
{{7|(5<<4)}, {20.36*5.5,21.33*3}, 0},
|
||||
{{7|(0<<4)}, {20.36*7, 21.33*3}, 1},
|
||||
{{7|(1<<4)}, {20.36*8, 21.33*3}, 1},
|
||||
{{7|(2<<4)}, {20.36*9, 21.33*3}, 1},
|
||||
{{3|(3<<4)}, {20.36*10,21.33*3}, 1},
|
||||
{{3|(4<<4)}, {20.36*11,21.33*3}, 1}
|
||||
};
|
||||
|
||||
void matrix_init_kb(void) {
|
||||
matrix_init_user();
|
||||
|
||||
palSetPadMode(GPIOB, 8, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOB, 9, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
|
||||
palClearPad(GPIOB, 8);
|
||||
palClearPad(GPIOB, 9);
|
||||
}
|
||||
|
||||
void matrix_scan_kb(void) {
|
||||
matrix_scan_user();
|
||||
}
|
||||
|
||||
uint32_t layer_state_set_kb(uint32_t state) {
|
||||
|
||||
palClearPad(GPIOB, 8);
|
||||
palClearPad(GPIOB, 9);
|
||||
state = layer_state_set_user(state);
|
||||
uint8_t layer = biton32(state);
|
||||
switch (layer) {
|
||||
case 3:
|
||||
palSetPad(GPIOB, 9);
|
||||
break;
|
||||
case 4:
|
||||
palSetPad(GPIOB, 8);
|
||||
break;
|
||||
case 6:
|
||||
palSetPad(GPIOB, 9);
|
||||
palSetPad(GPIOB, 8);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return state;
|
||||
}
|
107
keyboards/planck/ez/ez.h
Normal file
107
keyboards/planck/ez/ez.h
Normal file
@ -0,0 +1,107 @@
|
||||
/* Copyright 2018 Jack Humbert <jack.humb@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "planck.h"
|
||||
|
||||
#define LAYOUT_planck_1x2uC( \
|
||||
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \
|
||||
k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, \
|
||||
k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, \
|
||||
k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a \
|
||||
) \
|
||||
{ \
|
||||
{ k00, k01, k02, k03, k04, k05 }, \
|
||||
{ k10, k11, k12, k13, k14, k15 }, \
|
||||
{ k20, k21, k22, k23, k24, k25 }, \
|
||||
{ k30, k31, k32, k39, k3a, k3b }, \
|
||||
{ k06, k07, k08, k09, k0a, k0b }, \
|
||||
{ k16, k17, k18, k19, k1a, k1b }, \
|
||||
{ k26, k27, k28, k29, k2a, k2b }, \
|
||||
{ k36, k37, k38, k33, k34, k35 } \
|
||||
}
|
||||
|
||||
#define LAYOUT_planck_1x2uR( \
|
||||
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \
|
||||
k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, \
|
||||
k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, \
|
||||
k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a \
|
||||
) \
|
||||
{ \
|
||||
{ k00, k01, k02, k03, k04, k05 }, \
|
||||
{ k10, k11, k12, k13, k14, k15 }, \
|
||||
{ k20, k21, k22, k23, k24, k25 }, \
|
||||
{ k30, k31, k32, k39, k3a, k3b }, \
|
||||
{ k06, k07, k08, k09, k0a, k0b }, \
|
||||
{ k16, k17, k18, k19, k1a, k1b }, \
|
||||
{ k26, k27, k28, k29, k2a, k2b }, \
|
||||
{ k36, k37, k38, k33, k34, k35 } \
|
||||
}
|
||||
|
||||
#define LAYOUT_planck_1x2uL( \
|
||||
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \
|
||||
k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, \
|
||||
k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, \
|
||||
k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a \
|
||||
) \
|
||||
{ \
|
||||
{ k00, k01, k02, k03, k04, k05 }, \
|
||||
{ k10, k11, k12, k13, k14, k15 }, \
|
||||
{ k20, k21, k22, k23, k24, k25 }, \
|
||||
{ k30, k31, k32, k39, k3a, k3b }, \
|
||||
{ k06, k07, k08, k09, k0a, k0b }, \
|
||||
{ k16, k17, k18, k19, k1a, k1b }, \
|
||||
{ k26, k27, k28, k29, k2a, k2b }, \
|
||||
{ k36, k37, k38, k33, k34, k35 } \
|
||||
}
|
||||
|
||||
#define LAYOUT_planck_2x2u( \
|
||||
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \
|
||||
k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, \
|
||||
k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, \
|
||||
k30, k31, k32, k33, k34, k36, k37, k38, k39, k3a \
|
||||
) \
|
||||
{ \
|
||||
{ k00, k01, k02, k03, k04, k05 }, \
|
||||
{ k10, k11, k12, k13, k14, k15 }, \
|
||||
{ k20, k21, k22, k23, k24, k25 }, \
|
||||
{ k30, k31, k32, k39, k3a, k3b }, \
|
||||
{ k06, k07, k08, k09, k0a, k0b }, \
|
||||
{ k16, k17, k18, k19, k1a, k1b }, \
|
||||
{ k26, k27, k28, k29, k2a, k2b }, \
|
||||
{ k36, k37, k38, k33, k34, k35 } \
|
||||
}
|
||||
|
||||
#define LAYOUT_planck_grid( \
|
||||
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \
|
||||
k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, \
|
||||
k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, \
|
||||
k30, k31, k32, k33, k34, k35, KC_NO, k36, k37, k38, k39, k3a \
|
||||
) \
|
||||
{ \
|
||||
{ k00, k01, k02, k03, k04, k05 }, \
|
||||
{ k10, k11, k12, k13, k14, k15 }, \
|
||||
{ k20, k21, k22, k23, k24, k25 }, \
|
||||
{ k30, k31, k32, k39, k3a, KC_NO }, \
|
||||
{ k06, k07, k08, k09, k0a, k0b }, \
|
||||
{ k16, k17, k18, k19, k1a, k1b }, \
|
||||
{ k26, k27, k28, k29, k2a, k2b }, \
|
||||
{ k36, k37, k38, k33, k34, k35 } \
|
||||
}
|
||||
|
||||
#define KEYMAP LAYOUT_planck_grid
|
||||
#define LAYOUT_ortho_4x12 LAYOUT_planck_grid
|
||||
#define KC_LAYOUT_ortho_4x12 KC_KEYMAP
|
24
keyboards/planck/ez/rules.mk
Normal file
24
keyboards/planck/ez/rules.mk
Normal file
@ -0,0 +1,24 @@
|
||||
# project specific files
|
||||
LAYOUTS += ortho_4x12
|
||||
|
||||
# Cortex version
|
||||
MCU = STM32F303
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BACKLIGHT_ENABLE = no
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
|
||||
## (Note that for BOOTMAGIC on Teensy LC you have to use a custom .ld script.)
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = yes # Console for debug
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
NKRO_ENABLE = yes # USB Nkey Rollover
|
||||
CUSTOM_MATRIX = no # Custom matrix file
|
||||
AUDIO_ENABLE = yes
|
||||
RGBLIGHT_ENABLE = no
|
||||
# SERIAL_LINK_ENABLE = yes
|
||||
ENCODER_ENABLE = yes
|
||||
RGB_MATRIX_ENABLE = IS31FL3737
|
@ -5,6 +5,10 @@
|
||||
|
||||
#define encoder_update(clockwise) encoder_update_user(uint8_t index, clockwise)
|
||||
|
||||
#ifdef KEYBOARD_planck_ez
|
||||
#include "ez.h"
|
||||
#endif
|
||||
|
||||
#ifdef __AVR__
|
||||
#define LAYOUT_planck_mit( \
|
||||
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \
|
||||
@ -50,7 +54,7 @@
|
||||
#define LAYOUT_ortho_4x12 LAYOUT_planck_grid
|
||||
#define KC_LAYOUT_ortho_4x12 KC_KEYMAP
|
||||
|
||||
#else
|
||||
#elif KEYBOARD_planck_rev6
|
||||
|
||||
#define LAYOUT_planck_1x2uC( \
|
||||
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \
|
||||
|
@ -13,7 +13,6 @@
|
||||
// #define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (not recommened)
|
||||
// #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
|
||||
#define RGB_DISABLE_WHEN_USB_SUSPENDED true// turn off effects when suspended
|
||||
// #define RGB_MATRIX_SKIP_FRAMES 1 // number of frames to skip when displaying animations (0 is full effect) if not defined defaults to 1
|
||||
// #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
|
||||
// #define EECONFIG_RGB_MATRIX (uint32_t *)16
|
||||
#endif
|
||||
|
@ -18,7 +18,6 @@
|
||||
// #define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (not recommened)
|
||||
// #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
|
||||
#define RGB_DISABLE_WHEN_USB_SUSPENDED true// turn off effects when suspended
|
||||
// #define RGB_MATRIX_SKIP_FRAMES 1 // number of frames to skip when displaying animations (0 is full effect) if not defined defaults to 1
|
||||
// #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
|
||||
#define EECONFIG_RGB_MATRIX (uint32_t *)15
|
||||
#endif
|
||||
|
20
lib/lib8tion/LICENSE
Normal file
20
lib/lib8tion/LICENSE
Normal file
@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 FastLED
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
242
lib/lib8tion/lib8tion.c
Normal file
242
lib/lib8tion/lib8tion.c
Normal file
@ -0,0 +1,242 @@
|
||||
#define FASTLED_INTERNAL
|
||||
#include <stdint.h>
|
||||
|
||||
#define RAND16_SEED 1337
|
||||
uint16_t rand16seed = RAND16_SEED;
|
||||
|
||||
|
||||
// memset8, memcpy8, memmove8:
|
||||
// optimized avr replacements for the standard "C" library
|
||||
// routines memset, memcpy, and memmove.
|
||||
//
|
||||
// There are two techniques that make these routines
|
||||
// faster than the standard avr-libc routines.
|
||||
// First, the loops are unrolled 2X, meaning that
|
||||
// the average loop overhead is cut in half.
|
||||
// And second, the compare-and-branch at the bottom
|
||||
// of each loop decrements the low byte of the
|
||||
// counter, and if the carry is clear, it branches
|
||||
// back up immediately. Only if the low byte math
|
||||
// causes carry do we bother to decrement the high
|
||||
// byte and check that result for carry as well.
|
||||
// Results for a 100-byte buffer are 20-40% faster
|
||||
// than standard avr-libc, at a cost of a few extra
|
||||
// bytes of code.
|
||||
|
||||
#if defined(__AVR__)
|
||||
//__attribute__ ((noinline))
|
||||
void * memset8 ( void * ptr, uint8_t val, uint16_t num )
|
||||
{
|
||||
asm volatile(
|
||||
" movw r26, %[ptr] \n\t"
|
||||
" sbrs %A[num], 0 \n\t"
|
||||
" rjmp Lseteven_%= \n\t"
|
||||
" rjmp Lsetodd_%= \n\t"
|
||||
"Lsetloop_%=: \n\t"
|
||||
" st X+, %[val] \n\t"
|
||||
"Lsetodd_%=: \n\t"
|
||||
" st X+, %[val] \n\t"
|
||||
"Lseteven_%=: \n\t"
|
||||
" subi %A[num], 2 \n\t"
|
||||
" brcc Lsetloop_%= \n\t"
|
||||
" sbci %B[num], 0 \n\t"
|
||||
" brcc Lsetloop_%= \n\t"
|
||||
: [num] "+r" (num)
|
||||
: [ptr] "r" (ptr),
|
||||
[val] "r" (val)
|
||||
: "memory"
|
||||
);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//__attribute__ ((noinline))
|
||||
void * memcpy8 ( void * dst, const void* src, uint16_t num )
|
||||
{
|
||||
asm volatile(
|
||||
" movw r30, %[src] \n\t"
|
||||
" movw r26, %[dst] \n\t"
|
||||
" sbrs %A[num], 0 \n\t"
|
||||
" rjmp Lcpyeven_%= \n\t"
|
||||
" rjmp Lcpyodd_%= \n\t"
|
||||
"Lcpyloop_%=: \n\t"
|
||||
" ld __tmp_reg__, Z+ \n\t"
|
||||
" st X+, __tmp_reg__ \n\t"
|
||||
"Lcpyodd_%=: \n\t"
|
||||
" ld __tmp_reg__, Z+ \n\t"
|
||||
" st X+, __tmp_reg__ \n\t"
|
||||
"Lcpyeven_%=: \n\t"
|
||||
" subi %A[num], 2 \n\t"
|
||||
" brcc Lcpyloop_%= \n\t"
|
||||
" sbci %B[num], 0 \n\t"
|
||||
" brcc Lcpyloop_%= \n\t"
|
||||
: [num] "+r" (num)
|
||||
: [src] "r" (src),
|
||||
[dst] "r" (dst)
|
||||
: "memory"
|
||||
);
|
||||
return dst;
|
||||
}
|
||||
|
||||
//__attribute__ ((noinline))
|
||||
void * memmove8 ( void * dst, const void* src, uint16_t num )
|
||||
{
|
||||
if( src > dst) {
|
||||
// if src > dst then we can use the forward-stepping memcpy8
|
||||
return memcpy8( dst, src, num);
|
||||
} else {
|
||||
// if src < dst then we have to step backward:
|
||||
dst = (char*)dst + num;
|
||||
src = (char*)src + num;
|
||||
asm volatile(
|
||||
" movw r30, %[src] \n\t"
|
||||
" movw r26, %[dst] \n\t"
|
||||
" sbrs %A[num], 0 \n\t"
|
||||
" rjmp Lmoveven_%= \n\t"
|
||||
" rjmp Lmovodd_%= \n\t"
|
||||
"Lmovloop_%=: \n\t"
|
||||
" ld __tmp_reg__, -Z \n\t"
|
||||
" st -X, __tmp_reg__ \n\t"
|
||||
"Lmovodd_%=: \n\t"
|
||||
" ld __tmp_reg__, -Z \n\t"
|
||||
" st -X, __tmp_reg__ \n\t"
|
||||
"Lmoveven_%=: \n\t"
|
||||
" subi %A[num], 2 \n\t"
|
||||
" brcc Lmovloop_%= \n\t"
|
||||
" sbci %B[num], 0 \n\t"
|
||||
" brcc Lmovloop_%= \n\t"
|
||||
: [num] "+r" (num)
|
||||
: [src] "r" (src),
|
||||
[dst] "r" (dst)
|
||||
: "memory"
|
||||
);
|
||||
return dst;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* AVR */
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
// TEST / VERIFICATION CODE ONLY BELOW THIS POINT
|
||||
#include <Arduino.h>
|
||||
#include "lib8tion.h"
|
||||
|
||||
void test1abs( int8_t i)
|
||||
{
|
||||
Serial.print("abs("); Serial.print(i); Serial.print(") = ");
|
||||
int8_t j = abs8(i);
|
||||
Serial.print(j); Serial.println(" ");
|
||||
}
|
||||
|
||||
void testabs()
|
||||
{
|
||||
delay(5000);
|
||||
for( int8_t q = -128; q != 127; q++) {
|
||||
test1abs(q);
|
||||
}
|
||||
for(;;){};
|
||||
}
|
||||
|
||||
|
||||
void testmul8()
|
||||
{
|
||||
delay(5000);
|
||||
byte r, c;
|
||||
|
||||
Serial.println("mul8:");
|
||||
for( r = 0; r <= 20; r += 1) {
|
||||
Serial.print(r); Serial.print(" : ");
|
||||
for( c = 0; c <= 20; c += 1) {
|
||||
byte t;
|
||||
t = mul8( r, c);
|
||||
Serial.print(t); Serial.print(' ');
|
||||
}
|
||||
Serial.println(' ');
|
||||
}
|
||||
Serial.println("done.");
|
||||
for(;;){};
|
||||
}
|
||||
|
||||
|
||||
void testscale8()
|
||||
{
|
||||
delay(5000);
|
||||
byte r, c;
|
||||
|
||||
Serial.println("scale8:");
|
||||
for( r = 0; r <= 240; r += 10) {
|
||||
Serial.print(r); Serial.print(" : ");
|
||||
for( c = 0; c <= 240; c += 10) {
|
||||
byte t;
|
||||
t = scale8( r, c);
|
||||
Serial.print(t); Serial.print(' ');
|
||||
}
|
||||
Serial.println(' ');
|
||||
}
|
||||
|
||||
Serial.println(' ');
|
||||
Serial.println("scale8_video:");
|
||||
|
||||
for( r = 0; r <= 100; r += 4) {
|
||||
Serial.print(r); Serial.print(" : ");
|
||||
for( c = 0; c <= 100; c += 4) {
|
||||
byte t;
|
||||
t = scale8_video( r, c);
|
||||
Serial.print(t); Serial.print(' ');
|
||||
}
|
||||
Serial.println(' ');
|
||||
}
|
||||
|
||||
Serial.println("done.");
|
||||
for(;;){};
|
||||
}
|
||||
|
||||
|
||||
|
||||
void testqadd8()
|
||||
{
|
||||
delay(5000);
|
||||
byte r, c;
|
||||
for( r = 0; r <= 240; r += 10) {
|
||||
Serial.print(r); Serial.print(" : ");
|
||||
for( c = 0; c <= 240; c += 10) {
|
||||
byte t;
|
||||
t = qadd8( r, c);
|
||||
Serial.print(t); Serial.print(' ');
|
||||
}
|
||||
Serial.println(' ');
|
||||
}
|
||||
Serial.println("done.");
|
||||
for(;;){};
|
||||
}
|
||||
|
||||
void testnscale8x3()
|
||||
{
|
||||
delay(5000);
|
||||
byte r, g, b, sc;
|
||||
for( byte z = 0; z < 10; z++) {
|
||||
r = random8(); g = random8(); b = random8(); sc = random8();
|
||||
|
||||
Serial.print("nscale8x3_video( ");
|
||||
Serial.print(r); Serial.print(", ");
|
||||
Serial.print(g); Serial.print(", ");
|
||||
Serial.print(b); Serial.print(", ");
|
||||
Serial.print(sc); Serial.print(") = [ ");
|
||||
|
||||
nscale8x3_video( r, g, b, sc);
|
||||
|
||||
Serial.print(r); Serial.print(", ");
|
||||
Serial.print(g); Serial.print(", ");
|
||||
Serial.print(b); Serial.print("]");
|
||||
|
||||
Serial.println(' ');
|
||||
}
|
||||
Serial.println("done.");
|
||||
for(;;){};
|
||||
}
|
||||
|
||||
#endif
|
934
lib/lib8tion/lib8tion.h
Normal file
934
lib/lib8tion/lib8tion.h
Normal file
File diff suppressed because it is too large
Load Diff
552
lib/lib8tion/math8.h
Normal file
552
lib/lib8tion/math8.h
Normal file
File diff suppressed because it is too large
Load Diff
94
lib/lib8tion/random8.h
Normal file
94
lib/lib8tion/random8.h
Normal file
@ -0,0 +1,94 @@
|
||||
#ifndef __INC_LIB8TION_RANDOM_H
|
||||
#define __INC_LIB8TION_RANDOM_H
|
||||
///@ingroup lib8tion
|
||||
|
||||
///@defgroup Random Fast random number generators
|
||||
/// Fast 8- and 16- bit unsigned random numbers.
|
||||
/// Significantly faster than Arduino random(), but
|
||||
/// also somewhat less random. You can add entropy.
|
||||
///@{
|
||||
|
||||
// X(n+1) = (2053 * X(n)) + 13849)
|
||||
#define FASTLED_RAND16_2053 ((uint16_t)(2053))
|
||||
#define FASTLED_RAND16_13849 ((uint16_t)(13849))
|
||||
|
||||
/// random number seed
|
||||
extern uint16_t rand16seed;// = RAND16_SEED;
|
||||
|
||||
/// Generate an 8-bit random number
|
||||
LIB8STATIC uint8_t random8(void)
|
||||
{
|
||||
rand16seed = (rand16seed * FASTLED_RAND16_2053) + FASTLED_RAND16_13849;
|
||||
// return the sum of the high and low bytes, for better
|
||||
// mixing and non-sequential correlation
|
||||
return (uint8_t)(((uint8_t)(rand16seed & 0xFF)) +
|
||||
((uint8_t)(rand16seed >> 8)));
|
||||
}
|
||||
|
||||
/// Generate a 16 bit random number
|
||||
LIB8STATIC uint16_t random16(void)
|
||||
{
|
||||
rand16seed = (rand16seed * FASTLED_RAND16_2053) + FASTLED_RAND16_13849;
|
||||
return rand16seed;
|
||||
}
|
||||
|
||||
/// Generate an 8-bit random number between 0 and lim
|
||||
/// @param lim the upper bound for the result
|
||||
LIB8STATIC uint8_t random8_max(uint8_t lim)
|
||||
{
|
||||
uint8_t r = random8();
|
||||
r = (r*lim) >> 8;
|
||||
return r;
|
||||
}
|
||||
|
||||
/// Generate an 8-bit random number in the given range
|
||||
/// @param min the lower bound for the random number
|
||||
/// @param lim the upper bound for the random number
|
||||
LIB8STATIC uint8_t random8_min_max(uint8_t min, uint8_t lim)
|
||||
{
|
||||
uint8_t delta = lim - min;
|
||||
uint8_t r = random8_max(delta) + min;
|
||||
return r;
|
||||
}
|
||||
|
||||
/// Generate an 16-bit random number between 0 and lim
|
||||
/// @param lim the upper bound for the result
|
||||
LIB8STATIC uint16_t random16_max(uint16_t lim)
|
||||
{
|
||||
uint16_t r = random16();
|
||||
uint32_t p = (uint32_t)lim * (uint32_t)r;
|
||||
r = p >> 16;
|
||||
return r;
|
||||
}
|
||||
|
||||
/// Generate an 16-bit random number in the given range
|
||||
/// @param min the lower bound for the random number
|
||||
/// @param lim the upper bound for the random number
|
||||
LIB8STATIC uint16_t random16_min_max( uint16_t min, uint16_t lim)
|
||||
{
|
||||
uint16_t delta = lim - min;
|
||||
uint16_t r = random16_max(delta) + min;
|
||||
return r;
|
||||
}
|
||||
|
||||
/// Set the 16-bit seed used for the random number generator
|
||||
LIB8STATIC void random16_set_seed(uint16_t seed)
|
||||
{
|
||||
rand16seed = seed;
|
||||
}
|
||||
|
||||
/// Get the current seed value for the random number generator
|
||||
LIB8STATIC uint16_t random16_get_seed(void)
|
||||
{
|
||||
return rand16seed;
|
||||
}
|
||||
|
||||
/// Add entropy into the random number generator
|
||||
LIB8STATIC void random16_add_entropy(uint16_t entropy)
|
||||
{
|
||||
rand16seed += entropy;
|
||||
}
|
||||
|
||||
///@}
|
||||
|
||||
#endif
|
542
lib/lib8tion/scale8.h
Normal file
542
lib/lib8tion/scale8.h
Normal file
File diff suppressed because it is too large
Load Diff
259
lib/lib8tion/trig8.h
Normal file
259
lib/lib8tion/trig8.h
Normal file
@ -0,0 +1,259 @@
|
||||
#ifndef __INC_LIB8TION_TRIG_H
|
||||
#define __INC_LIB8TION_TRIG_H
|
||||
|
||||
///@ingroup lib8tion
|
||||
|
||||
///@defgroup Trig Fast trig functions
|
||||
/// Fast 8 and 16-bit approximations of sin(x) and cos(x).
|
||||
/// Don't use these approximations for calculating the
|
||||
/// trajectory of a rocket to Mars, but they're great
|
||||
/// for art projects and LED displays.
|
||||
///
|
||||
/// On Arduino/AVR, the 16-bit approximation is more than
|
||||
/// 10X faster than floating point sin(x) and cos(x), while
|
||||
/// the 8-bit approximation is more than 20X faster.
|
||||
///@{
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define sin16 sin16_avr
|
||||
#else
|
||||
#define sin16 sin16_C
|
||||
#endif
|
||||
|
||||
/// Fast 16-bit approximation of sin(x). This approximation never varies more than
|
||||
/// 0.69% from the floating point value you'd get by doing
|
||||
///
|
||||
/// float s = sin(x) * 32767.0;
|
||||
///
|
||||
/// @param theta input angle from 0-65535
|
||||
/// @returns sin of theta, value between -32767 to 32767.
|
||||
LIB8STATIC int16_t sin16_avr( uint16_t theta )
|
||||
{
|
||||
static const uint8_t data[] =
|
||||
{ 0, 0, 49, 0, 6393%256, 6393/256, 48, 0,
|
||||
12539%256, 12539/256, 44, 0, 18204%256, 18204/256, 38, 0,
|
||||
23170%256, 23170/256, 31, 0, 27245%256, 27245/256, 23, 0,
|
||||
30273%256, 30273/256, 14, 0, 32137%256, 32137/256, 4 /*,0*/ };
|
||||
|
||||
uint16_t offset = (theta & 0x3FFF);
|
||||
|
||||
// AVR doesn't have a multi-bit shift instruction,
|
||||
// so if we say "offset >>= 3", gcc makes a tiny loop.
|
||||
// Inserting empty volatile statements between each
|
||||
// bit shift forces gcc to unroll the loop.
|
||||
offset >>= 1; // 0..8191
|
||||
asm volatile("");
|
||||
offset >>= 1; // 0..4095
|
||||
asm volatile("");
|
||||
offset >>= 1; // 0..2047
|
||||
|
||||
if( theta & 0x4000 ) offset = 2047 - offset;
|
||||
|
||||
uint8_t sectionX4;
|
||||
sectionX4 = offset / 256;
|
||||
sectionX4 *= 4;
|
||||
|
||||
uint8_t m;
|
||||
|
||||
union {
|
||||
uint16_t b;
|
||||
struct {
|
||||
uint8_t blo;
|
||||
uint8_t bhi;
|
||||
};
|
||||
} u;
|
||||
|
||||
//in effect u.b = blo + (256 * bhi);
|
||||
u.blo = data[ sectionX4 ];
|
||||
u.bhi = data[ sectionX4 + 1];
|
||||
m = data[ sectionX4 + 2];
|
||||
|
||||
uint8_t secoffset8 = (uint8_t)(offset) / 2;
|
||||
|
||||
uint16_t mx = m * secoffset8;
|
||||
|
||||
int16_t y = mx + u.b;
|
||||
if( theta & 0x8000 ) y = -y;
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
/// Fast 16-bit approximation of sin(x). This approximation never varies more than
|
||||
/// 0.69% from the floating point value you'd get by doing
|
||||
///
|
||||
/// float s = sin(x) * 32767.0;
|
||||
///
|
||||
/// @param theta input angle from 0-65535
|
||||
/// @returns sin of theta, value between -32767 to 32767.
|
||||
LIB8STATIC int16_t sin16_C( uint16_t theta )
|
||||
{
|
||||
static const uint16_t base[] =
|
||||
{ 0, 6393, 12539, 18204, 23170, 27245, 30273, 32137 };
|
||||
static const uint8_t slope[] =
|
||||
{ 49, 48, 44, 38, 31, 23, 14, 4 };
|
||||
|
||||
uint16_t offset = (theta & 0x3FFF) >> 3; // 0..2047
|
||||
if( theta & 0x4000 ) offset = 2047 - offset;
|
||||
|
||||
uint8_t section = offset / 256; // 0..7
|
||||
uint16_t b = base[section];
|
||||
uint8_t m = slope[section];
|
||||
|
||||
uint8_t secoffset8 = (uint8_t)(offset) / 2;
|
||||
|
||||
uint16_t mx = m * secoffset8;
|
||||
int16_t y = mx + b;
|
||||
|
||||
if( theta & 0x8000 ) y = -y;
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
/// Fast 16-bit approximation of cos(x). This approximation never varies more than
|
||||
/// 0.69% from the floating point value you'd get by doing
|
||||
///
|
||||
/// float s = cos(x) * 32767.0;
|
||||
///
|
||||
/// @param theta input angle from 0-65535
|
||||
/// @returns sin of theta, value between -32767 to 32767.
|
||||
LIB8STATIC int16_t cos16( uint16_t theta)
|
||||
{
|
||||
return sin16( theta + 16384);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
// sin8 & cos8
|
||||
// Fast 8-bit approximations of sin(x) & cos(x).
|
||||
// Input angle is an unsigned int from 0-255.
|
||||
// Output is an unsigned int from 0 to 255.
|
||||
//
|
||||
// This approximation can vary to to 2%
|
||||
// from the floating point value you'd get by doing
|
||||
// float s = (sin( x ) * 128.0) + 128;
|
||||
//
|
||||
// Don't use this approximation for calculating the
|
||||
// "real" trigonometric calculations, but it's great
|
||||
// for art projects and LED displays.
|
||||
//
|
||||
// On Arduino/AVR, this approximation is more than
|
||||
// 20X faster than floating point sin(x) and cos(x)
|
||||
|
||||
#if defined(__AVR__) && !defined(LIB8_ATTINY)
|
||||
#define sin8 sin8_avr
|
||||
#else
|
||||
#define sin8 sin8_C
|
||||
#endif
|
||||
|
||||
|
||||
const uint8_t b_m16_interleave[] = { 0, 49, 49, 41, 90, 27, 117, 10 };
|
||||
|
||||
/// Fast 8-bit approximation of sin(x). This approximation never varies more than
|
||||
/// 2% from the floating point value you'd get by doing
|
||||
///
|
||||
/// float s = (sin(x) * 128.0) + 128;
|
||||
///
|
||||
/// @param theta input angle from 0-255
|
||||
/// @returns sin of theta, value between 0 and 255
|
||||
LIB8STATIC uint8_t sin8_avr( uint8_t theta)
|
||||
{
|
||||
uint8_t offset = theta;
|
||||
|
||||
asm volatile(
|
||||
"sbrc %[theta],6 \n\t"
|
||||
"com %[offset] \n\t"
|
||||
: [theta] "+r" (theta), [offset] "+r" (offset)
|
||||
);
|
||||
|
||||
offset &= 0x3F; // 0..63
|
||||
|
||||
uint8_t secoffset = offset & 0x0F; // 0..15
|
||||
if( theta & 0x40) secoffset++;
|
||||
|
||||
uint8_t m16; uint8_t b;
|
||||
|
||||
uint8_t section = offset >> 4; // 0..3
|
||||
uint8_t s2 = section * 2;
|
||||
|
||||
const uint8_t* p = b_m16_interleave;
|
||||
p += s2;
|
||||
b = *p;
|
||||
p++;
|
||||
m16 = *p;
|
||||
|
||||
uint8_t mx;
|
||||
uint8_t xr1;
|
||||
asm volatile(
|
||||
"mul %[m16],%[secoffset] \n\t"
|
||||
"mov %[mx],r0 \n\t"
|
||||
"mov %[xr1],r1 \n\t"
|
||||
"eor r1, r1 \n\t"
|
||||
"swap %[mx] \n\t"
|
||||
"andi %[mx],0x0F \n\t"
|
||||
"swap %[xr1] \n\t"
|
||||
"andi %[xr1], 0xF0 \n\t"
|
||||
"or %[mx], %[xr1] \n\t"
|
||||
: [mx] "=d" (mx), [xr1] "=d" (xr1)
|
||||
: [m16] "d" (m16), [secoffset] "d" (secoffset)
|
||||
);
|
||||
|
||||
int8_t y = mx + b;
|
||||
if( theta & 0x80 ) y = -y;
|
||||
|
||||
y += 128;
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
/// Fast 8-bit approximation of sin(x). This approximation never varies more than
|
||||
/// 2% from the floating point value you'd get by doing
|
||||
///
|
||||
/// float s = (sin(x) * 128.0) + 128;
|
||||
///
|
||||
/// @param theta input angle from 0-255
|
||||
/// @returns sin of theta, value between 0 and 255
|
||||
LIB8STATIC uint8_t sin8_C( uint8_t theta)
|
||||
{
|
||||
uint8_t offset = theta;
|
||||
if( theta & 0x40 ) {
|
||||
offset = (uint8_t)255 - offset;
|
||||
}
|
||||
offset &= 0x3F; // 0..63
|
||||
|
||||
uint8_t secoffset = offset & 0x0F; // 0..15
|
||||
if( theta & 0x40) secoffset++;
|
||||
|
||||
uint8_t section = offset >> 4; // 0..3
|
||||
uint8_t s2 = section * 2;
|
||||
const uint8_t* p = b_m16_interleave;
|
||||
p += s2;
|
||||
uint8_t b = *p;
|
||||
p++;
|
||||
uint8_t m16 = *p;
|
||||
|
||||
uint8_t mx = (m16 * secoffset) >> 4;
|
||||
|
||||
int8_t y = mx + b;
|
||||
if( theta & 0x80 ) y = -y;
|
||||
|
||||
y += 128;
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
/// Fast 8-bit approximation of cos(x). This approximation never varies more than
|
||||
/// 2% from the floating point value you'd get by doing
|
||||
///
|
||||
/// float s = (cos(x) * 128.0) + 128;
|
||||
///
|
||||
/// @param theta input angle from 0-255
|
||||
/// @returns sin of theta, value between 0 and 255
|
||||
LIB8STATIC uint8_t cos8( uint8_t theta)
|
||||
{
|
||||
return sin8( theta + 64);
|
||||
}
|
||||
|
||||
///@}
|
||||
#endif
|
@ -79,7 +79,7 @@ float startup_song[][2] = STARTUP_SONG;
|
||||
|
||||
static void gpt_cb8(GPTDriver *gptp);
|
||||
|
||||
#define DAC_BUFFER_SIZE 720
|
||||
#define DAC_BUFFER_SIZE 100
|
||||
#ifndef DAC_SAMPLE_MAX
|
||||
#define DAC_SAMPLE_MAX 65535U
|
||||
#endif
|
||||
@ -98,8 +98,8 @@ static void gpt_cb8(GPTDriver *gptp);
|
||||
RESTART_CHANNEL_1()
|
||||
#define UPDATE_CHANNEL_2_FREQ(freq) gpt7cfg1.frequency = freq * DAC_BUFFER_SIZE; \
|
||||
RESTART_CHANNEL_2()
|
||||
#define GET_CHANNEL_1_FREQ gpt6cfg1.frequency
|
||||
#define GET_CHANNEL_2_FREQ gpt7cfg1.frequency
|
||||
#define GET_CHANNEL_1_FREQ (uint16_t)(gpt6cfg1.frequency * DAC_BUFFER_SIZE)
|
||||
#define GET_CHANNEL_2_FREQ (uint16_t)(gpt7cfg1.frequency * DAC_BUFFER_SIZE)
|
||||
|
||||
|
||||
/*
|
||||
|
@ -78,9 +78,11 @@ RGB hsv_to_rgb( HSV hsv )
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef USE_CIE1931_CURVE
|
||||
rgb.r = pgm_read_byte( &CIE1931_CURVE[rgb.r] );
|
||||
rgb.g = pgm_read_byte( &CIE1931_CURVE[rgb.g] );
|
||||
rgb.b = pgm_read_byte( &CIE1931_CURVE[rgb.b] );
|
||||
#endif
|
||||
|
||||
return rgb;
|
||||
}
|
||||
|
@ -274,10 +274,10 @@ bool process_record_quantum(keyrecord_t *record) {
|
||||
#ifdef HAPTIC_ENABLE
|
||||
process_haptic(keycode, record) &&
|
||||
#endif //HAPTIC_ENABLE
|
||||
process_record_kb(keycode, record) &&
|
||||
#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_KEYPRESSES)
|
||||
#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_KEYREACTIVE_ENABLED)
|
||||
process_rgb_matrix(keycode, record) &&
|
||||
#endif
|
||||
process_record_kb(keycode, record) &&
|
||||
#if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED)
|
||||
process_midi(keycode, record) &&
|
||||
#endif
|
||||
@ -1049,12 +1049,6 @@ void matrix_init_quantum() {
|
||||
matrix_init_kb();
|
||||
}
|
||||
|
||||
uint8_t rgb_matrix_task_counter = 0;
|
||||
|
||||
#ifndef RGB_MATRIX_SKIP_FRAMES
|
||||
#define RGB_MATRIX_SKIP_FRAMES 1
|
||||
#endif
|
||||
|
||||
void matrix_scan_quantum() {
|
||||
#if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE)
|
||||
matrix_scan_music();
|
||||
@ -1078,10 +1072,6 @@ void matrix_scan_quantum() {
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
rgb_matrix_task();
|
||||
if (rgb_matrix_task_counter == 0) {
|
||||
rgb_matrix_update_pwm_buffers();
|
||||
}
|
||||
rgb_matrix_task_counter = ((rgb_matrix_task_counter + 1) % (RGB_MATRIX_SKIP_FRAMES + 1));
|
||||
#endif
|
||||
|
||||
#ifdef ENCODER_ENABLE
|
||||
|
1175
quantum/rgb_matrix.c
1175
quantum/rgb_matrix.c
File diff suppressed because it is too large
Load Diff
@ -21,32 +21,35 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "rgb_matrix_types.h"
|
||||
#include "color.h"
|
||||
#include "quantum.h"
|
||||
|
||||
#ifdef IS31FL3731
|
||||
#include "is31fl3731.h"
|
||||
#include "is31fl3731.h"
|
||||
#elif defined (IS31FL3733)
|
||||
#include "is31fl3733.h"
|
||||
#elif defined (IS31FL3737)
|
||||
#include "is31fl3737.h"
|
||||
#endif
|
||||
|
||||
typedef struct Point {
|
||||
uint8_t x;
|
||||
uint8_t y;
|
||||
} __attribute__((packed)) Point;
|
||||
#ifndef RGB_MATRIX_LED_FLUSH_LIMIT
|
||||
#define RGB_MATRIX_LED_FLUSH_LIMIT 16
|
||||
#endif
|
||||
|
||||
typedef struct rgb_led {
|
||||
union {
|
||||
uint8_t raw;
|
||||
struct {
|
||||
uint8_t row:4; // 16 max
|
||||
uint8_t col:4; // 16 max
|
||||
};
|
||||
} matrix_co;
|
||||
Point point;
|
||||
uint8_t modifier:1;
|
||||
} __attribute__((packed)) rgb_led;
|
||||
#ifndef RGB_MATRIX_LED_PROCESS_LIMIT
|
||||
#define RGB_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5
|
||||
#endif
|
||||
|
||||
#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < DRIVER_LED_TOTAL
|
||||
#define RGB_MATRIX_USE_LIMITS(min, max) uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter; \
|
||||
uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \
|
||||
if (max > DRIVER_LED_TOTAL) \
|
||||
max = DRIVER_LED_TOTAL;
|
||||
#else
|
||||
#define RGB_MATRIX_USE_LIMITS(min, max) uint8_t min = 0; \
|
||||
uint8_t max = DRIVER_LED_TOTAL;
|
||||
#endif
|
||||
|
||||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
|
||||
|
||||
@ -56,79 +59,73 @@ typedef struct
|
||||
uint8_t index;
|
||||
} rgb_indicator;
|
||||
|
||||
typedef union {
|
||||
uint32_t raw;
|
||||
struct {
|
||||
bool enable :1;
|
||||
uint8_t mode :6;
|
||||
uint16_t hue :9;
|
||||
uint8_t sat :8;
|
||||
uint8_t val :8;
|
||||
uint8_t speed :8;//EECONFIG needs to be increased to support this
|
||||
};
|
||||
} rgb_config_t;
|
||||
|
||||
enum rgb_matrix_effects {
|
||||
RGB_MATRIX_NONE = 0,
|
||||
RGB_MATRIX_SOLID_COLOR = 1,
|
||||
#ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS
|
||||
RGB_MATRIX_ALPHAS_MODS,
|
||||
#endif
|
||||
#ifndef DISABLE_RGB_MATRIX_DUAL_BEACON
|
||||
RGB_MATRIX_DUAL_BEACON,
|
||||
#endif
|
||||
RGB_MATRIX_ALPHAS_MODS,
|
||||
#endif // DISABLE_RGB_MATRIX_ALPHAS_MODS
|
||||
#ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
|
||||
RGB_MATRIX_GRADIENT_UP_DOWN,
|
||||
#endif
|
||||
#ifndef DISABLE_RGB_MATRIX_RAINDROPS
|
||||
RGB_MATRIX_RAINDROPS,
|
||||
#endif
|
||||
RGB_MATRIX_GRADIENT_UP_DOWN,
|
||||
#endif // DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
|
||||
#ifndef DISABLE_RGB_MATRIX_BREATHING
|
||||
RGB_MATRIX_BREATHING,
|
||||
#endif // DISABLE_RGB_MATRIX_BREATHING
|
||||
#ifndef DISABLE_RGB_MATRIX_CYCLE_ALL
|
||||
RGB_MATRIX_CYCLE_ALL,
|
||||
#endif
|
||||
RGB_MATRIX_CYCLE_ALL,
|
||||
#endif // DISABLE_RGB_MATRIX_CYCLE_ALL
|
||||
#ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
|
||||
RGB_MATRIX_CYCLE_LEFT_RIGHT,
|
||||
#endif
|
||||
RGB_MATRIX_CYCLE_LEFT_RIGHT,
|
||||
#endif // DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
|
||||
#ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
|
||||
RGB_MATRIX_CYCLE_UP_DOWN,
|
||||
#endif
|
||||
#ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON
|
||||
RGB_MATRIX_RAINBOW_BEACON,
|
||||
#endif
|
||||
#ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
|
||||
RGB_MATRIX_RAINBOW_PINWHEELS,
|
||||
#endif
|
||||
RGB_MATRIX_CYCLE_UP_DOWN,
|
||||
#endif // DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
|
||||
#ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
|
||||
RGB_MATRIX_RAINBOW_MOVING_CHEVRON,
|
||||
#endif
|
||||
RGB_MATRIX_RAINBOW_MOVING_CHEVRON,
|
||||
#endif // DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
|
||||
#ifndef DISABLE_RGB_MATRIX_DUAL_BEACON
|
||||
RGB_MATRIX_DUAL_BEACON,
|
||||
#endif // DISABLE_RGB_MATRIX_DUAL_BEACON
|
||||
#ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON
|
||||
RGB_MATRIX_RAINBOW_BEACON,
|
||||
#endif // DISABLE_RGB_MATRIX_RAINBOW_BEACON
|
||||
#ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
|
||||
RGB_MATRIX_RAINBOW_PINWHEELS,
|
||||
#endif // DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
|
||||
#ifndef DISABLE_RGB_MATRIX_RAINDROPS
|
||||
RGB_MATRIX_RAINDROPS,
|
||||
#endif // DISABLE_RGB_MATRIX_RAINDROPS
|
||||
#ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
|
||||
RGB_MATRIX_JELLYBEAN_RAINDROPS,
|
||||
#endif
|
||||
RGB_MATRIX_JELLYBEAN_RAINDROPS,
|
||||
#endif // DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
|
||||
#ifndef DISABLE_RGB_MATRIX_DIGITAL_RAIN
|
||||
RGB_MATRIX_DIGITAL_RAIN,
|
||||
#endif
|
||||
#ifdef RGB_MATRIX_KEYPRESSES
|
||||
#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE
|
||||
RGB_MATRIX_SOLID_REACTIVE,
|
||||
#endif
|
||||
#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
|
||||
RGB_MATRIX_SOLID_REACTIVE_SIMPLE,
|
||||
#endif
|
||||
#ifndef DISABLE_RGB_MATRIX_SPLASH
|
||||
RGB_MATRIX_SPLASH,
|
||||
#endif
|
||||
#ifndef DISABLE_RGB_MATRIX_MULTISPLASH
|
||||
RGB_MATRIX_MULTISPLASH,
|
||||
#endif
|
||||
#ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH
|
||||
RGB_MATRIX_SOLID_SPLASH,
|
||||
#endif
|
||||
#ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
|
||||
RGB_MATRIX_SOLID_MULTISPLASH,
|
||||
#endif
|
||||
#endif
|
||||
RGB_MATRIX_EFFECT_MAX
|
||||
RGB_MATRIX_DIGITAL_RAIN,
|
||||
#endif // DISABLE_RGB_MATRIX_DIGITAL_RAIN
|
||||
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
|
||||
#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
|
||||
RGB_MATRIX_SOLID_REACTIVE_SIMPLE,
|
||||
#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
|
||||
#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE
|
||||
RGB_MATRIX_SOLID_REACTIVE,
|
||||
#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE
|
||||
#ifndef DISABLE_RGB_MATRIX_SPLASH
|
||||
RGB_MATRIX_SPLASH,
|
||||
#endif // DISABLE_RGB_MATRIX_SPLASH
|
||||
#ifndef DISABLE_RGB_MATRIX_MULTISPLASH
|
||||
RGB_MATRIX_MULTISPLASH,
|
||||
#endif // DISABLE_RGB_MATRIX_MULTISPLASH
|
||||
#ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH
|
||||
RGB_MATRIX_SOLID_SPLASH,
|
||||
#endif // DISABLE_RGB_MATRIX_SOLID_SPLASH
|
||||
#ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
|
||||
RGB_MATRIX_SOLID_MULTISPLASH,
|
||||
#endif // DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
|
||||
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
|
||||
RGB_MATRIX_EFFECT_MAX
|
||||
};
|
||||
|
||||
uint8_t rgb_matrix_map_row_column_to_led( uint8_t row, uint8_t column, uint8_t *led_i);
|
||||
|
||||
void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
|
||||
void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue );
|
||||
|
||||
@ -162,8 +159,6 @@ void rgb_matrix_decrease(void);
|
||||
// void backlight_get_key_color( uint8_t led, HSV *hsv );
|
||||
// void backlight_set_key_color( uint8_t row, uint8_t column, HSV hsv );
|
||||
|
||||
uint32_t rgb_matrix_get_tick(void);
|
||||
|
||||
void rgb_matrix_toggle(void);
|
||||
void rgb_matrix_enable(void);
|
||||
void rgb_matrix_enable_noeeprom(void);
|
||||
@ -212,7 +207,6 @@ uint8_t rgb_matrix_get_mode(void);
|
||||
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. */
|
||||
|
26
quantum/rgb_matrix_animations/alpha_mods_anim.h
Normal file
26
quantum/rgb_matrix_animations/alpha_mods_anim.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS
|
||||
|
||||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
|
||||
// alphas = color1, mods = color2
|
||||
bool rgb_matrix_alphas_mods(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val };
|
||||
RGB rgb1 = hsv_to_rgb(hsv);
|
||||
hsv.h += rgb_matrix_config.speed;
|
||||
RGB rgb2 = hsv_to_rgb(hsv);
|
||||
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
if (g_rgb_leds[i].modifier) {
|
||||
rgb_matrix_set_color(i, rgb2.r, rgb2.g, rgb2.b);
|
||||
} else {
|
||||
rgb_matrix_set_color(i, rgb1.r, rgb1.g, rgb1.b);
|
||||
}
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
||||
|
||||
#endif // DISABLE_RGB_MATRIX_ALPHAS_MODS
|
19
quantum/rgb_matrix_animations/breathing_anim.h
Normal file
19
quantum/rgb_matrix_animations/breathing_anim.h
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
#ifndef DISABLE_RGB_MATRIX_BREATHING
|
||||
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
|
||||
bool rgb_matrix_breathing(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 8);
|
||||
uint8_t val = scale8(abs8(sin8(time) - 128) * 2, rgb_matrix_config.val);
|
||||
HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, val };
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
||||
|
||||
#endif // DISABLE_RGB_MATRIX_BREATHING
|
21
quantum/rgb_matrix_animations/cycle_all_anim.h
Normal file
21
quantum/rgb_matrix_animations/cycle_all_anim.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#ifndef DISABLE_RGB_MATRIX_CYCLE_ALL
|
||||
|
||||
extern rgb_counters_t g_rgb_counters;
|
||||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
|
||||
bool rgb_matrix_cycle_all(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
|
||||
uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
hsv.h = time;
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
||||
|
||||
#endif // DISABLE_RGB_MATRIX_CYCLE_ALL
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user