Skip to content

Commit

Permalink
Merge branch 'master' into dstrelau
Browse files Browse the repository at this point in the history
* master:
  Keymap: Boy_314's Preonic and XD75 Layouts (qmk#3781)
  Docs: Add docs for the `LAYOUT_*` macro to layouts (qmk#3772)
  Keyboard: xealous (qmk#3731)
  Keyboard: Dactyl - Only initialize relevant variables (qmk#3771)
  Keymap: xtonhasvim updates (qmk#3768)
  Keymap: Adding keymap to the XD60 (qmk#3767)
  Putting my ducks in a row: Eagle/Viper V2 into Duck directory (qmk#3766)
  Putting my ducks in a row: Octagon V1/V2  (qmk#3765)
  Keymap: Bocaj - Create Userspace and Ergodox Layout (qmk#3750)
  ISSI31FL3733 driver  (qmk#3679)
  Fixes STM32F303XC timer issue for Planck Rev 6 (qmk#3777)
  • Loading branch information
Dean Strelau committed Aug 29, 2018
2 parents d5de47f + 661ca44 commit 2218311
Show file tree
Hide file tree
Showing 110 changed files with 3,293 additions and 783 deletions.
40 changes: 32 additions & 8 deletions common_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ endif

ifeq ($(strip $(STENO_ENABLE)), yes)
OPT_DEFS += -DSTENO_ENABLE
VIRTSER_ENABLE := yes
SRC += $(QUANTUM_DIR)/process_keycode/process_steno.c
VIRTSER_ENABLE := yes
SRC += $(QUANTUM_DIR)/process_keycode/process_steno.c
endif

ifeq ($(strip $(VIRTSER_ENABLE)), yes)
Expand All @@ -75,9 +75,9 @@ ifeq ($(strip $(FAUXCLICKY_ENABLE)), yes)
endif

ifeq ($(strip $(POINTING_DEVICE_ENABLE)), yes)
OPT_DEFS += -DPOINTING_DEVICE_ENABLE
OPT_DEFS += -DMOUSE_ENABLE
SRC += $(QUANTUM_DIR)/pointing_device.c
OPT_DEFS += -DPOINTING_DEVICE_ENABLE
OPT_DEFS += -DMOUSE_ENABLE
SRC += $(QUANTUM_DIR)/pointing_device.c
endif

ifeq ($(strip $(UCIS_ENABLE)), yes)
Expand Down Expand Up @@ -110,19 +110,43 @@ ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes)
OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER
else
SRC += ws2812.c
SRC += ws2812.c
endif
endif

ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
OPT_DEFS += -DRGB_MATRIX_ENABLE
OPT_DEFS += -DIS31FL3731
COMMON_VPATH += $(DRIVER_PATH)/issi
SRC += is31fl3731.c
SRC += i2c_master.c
SRC += $(QUANTUM_DIR)/color.c
SRC += $(QUANTUM_DIR)/rgb_matrix.c
CIE1931_CURVE = yes
endif

ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3731)
OPT_DEFS += -DRGB_MATRIX_ENABLE
OPT_DEFS += -DIS31FL3731
COMMON_VPATH += $(DRIVER_PATH)/issi
SRC += is31fl3731.c
SRC += i2c_master.c
SRC += $(QUANTUM_DIR)/color.c
SRC += $(QUANTUM_DIR)/rgb_matrix.c
CIE1931_CURVE = yes
endif

ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3733)
OPT_DEFS += -DRGB_MATRIX_ENABLE
OPT_DEFS += -DIS31FL3733
COMMON_VPATH += $(DRIVER_PATH)/issi
SRC += is31fl3733.c
SRC += i2c_master.c
SRC += $(QUANTUM_DIR)/color.c
SRC += $(QUANTUM_DIR)/rgb_matrix.c
CIE1931_CURVE = yes
endif

ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
OPT_DEFS += -DTAP_DANCE_ENABLE
SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
Expand Down Expand Up @@ -169,7 +193,7 @@ ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
CIE1931_CURVE = yes
endif
ifeq ($(strip $(BACKLIGHT_CUSTOM_DRIVER)), yes)
ifeq ($(strip $(BACKLIGHT_CUSTOM_DRIVER)), yes)
OPT_DEFS += -DBACKLIGHT_CUSTOM_DRIVER
endif
endif
Expand Down Expand Up @@ -200,7 +224,7 @@ endif

ifeq ($(strip $(HD44780_ENABLE)), yes)
SRC += drivers/avr/hd44780.c
OPT_DEFS += -DHD44780_ENABLE
OPT_DEFS += -DHD44780_ENABLE
endif

QUANTUM_SRC:= \
Expand Down
6 changes: 6 additions & 0 deletions docs/feature_layouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ but the `LAYOUT_<layout>` variable must be defined in `<folder>.h` as well.

## Tips for Making Layouts Keyboard-Agnostic

### Includes

Instead of using `#include "planck.h"`, you can use this line to include whatever `<keyboard>.h` (`<folder>.h` should not be included here) file that is being compiled:

#include QMK_KEYBOARD_H
Expand All @@ -72,3 +74,7 @@ For example:
```

Note that the names are lowercase and match the folder/file names for the keyboard/revision exactly.

### Keymaps

In order to support both split and non-split keyboards with the same layout, you need to use the keyboard agnostic `LAYOUT_<layout name>` macro in your keymap. For instance, in order for a Let's Split and Planck to share the same layout file, you need to use `LAYOUT_ortho_4x12` instead of `LAYOUT_planck_grid` or just `{}` for a C array.
52 changes: 50 additions & 2 deletions docs/feature_rgb_matrix.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# RGB Matrix Lighting

## Driver configuration

### IS31FL3731

There is basic support for addressable RGB matrix lighting with the I2C IS31FL3731 RGB controller. To enable it, add this to your `rules.mk`:

RGB_MATRIX_ENABLE = yes
RGB_MATRIX_ENABLE = IS31FL3731

Configure the hardware via your `config.h`:

Expand Down Expand Up @@ -36,7 +40,51 @@ Define these arrays listing all the LEDs in your `<keyboard>.c`:
....
}

Where `Cx_y` is the location of the LED in the matrix defined by [the datasheet](http://www.issi.com/WW/pdf/31FL3731.pdf). The `driver` is the index of the driver you defined in your `config.h` (`0` or `1` right now).
Where `Cx_y` is the location of the LED in the matrix defined by [the datasheet](http://www.issi.com/WW/pdf/31FL3731.pdf) and the header file `drivers/issi/is31fl3731.h`. The `driver` is the index of the driver you defined in your `config.h` (`0` or `1` right now).

### IS31FL3733

There is basic support for addressable RGB matrix lighting with the I2C IS31FL3733 RGB controller. To enable it, add this to your `rules.mk`:

RGB_MATRIX_ENABLE = IS31FL3733

Configure the hardware via your `config.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 DRIVER_ADDR_1 0b1010000
#define DRIVER_ADDR_2 0b1010000 // this is here for compliancy reasons.

#define DRIVER_COUNT 1
#define DRIVER_1_LED_TOTAL 64
#define DRIVER_LED_TOTAL DRIVER_1_LED_TOTAL

Currently only a single drivers is supported, but it would be trivial to support all 4 combinations. For now define `DRIVER_ADDR_2` as `DRIVER_ADDR_1`

Define these arrays listing all the LEDs in your `<keyboard>.c`:

const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
/* Refer to IS31 manual for these locations
* driver
* | R location
* | | G location
* | | | B location
* | | | | */
{0, B_1, A_1, C_1},
....
}

Where `X_Y` is the location of the LED in the matrix defined by [the datasheet](http://www.issi.com/WW/pdf/31FL3733.pdf) and the header file `drivers/issi/is31fl3733.h`. The `driver` is the index of the driver you defined in your `config.h` (Only `0` right now).

From this point forward the configuration is the same for all the drivers.

const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
/* {row | col << 4}
Expand Down
6 changes: 5 additions & 1 deletion docs/hardware_drivers.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ You can make use of uGFX within QMK to drive character and graphic LCD's, LED ar

Support for WS2811/WS2812{a,b,c} LED's. For more information see the [RGB Light](feature_rgblight.md) page.

## IS31FL3731 (AVR Only)
## IS31FL3731

Support for up to 2 drivers. Each driver impliments 2 charlieplex matrices to individually address LEDs using I2C. This allows up to 144 same color LEDs or 32 RGB LEDs. For more information on how to setup the driver see the [RGB Matrix](feature_rgb_matrix.md) page.

## IS31FL3733

Support for up to a single driver with room for expansion. Each driver can control 192 individual LEDs or 64 RGB LEDs. For more information on how to setup the driver see the [RGB Matrix](feature_rgb_matrix.md) page.
13 changes: 7 additions & 6 deletions drivers/arm/i2c_master.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/* This library follows the convention of the AVR i2c_master library.
/* This library is only valid for STM32 processors.
* This library follows the convention of the AVR i2c_master library.
* As a result addresses are expected to be already shifted (addr << 1).
* I2CD1 is the default driver which corresponds to pins B6 and B7. This
* can be changed.
* Please ensure that HAL_USE_I2C is TRUE in the halconf.h file and that
* STM32_I2C_USE_I2C1 is TRUE in the mcuconf.h file.
* STM32_I2C_USE_I2C1 is TRUE in the mcuconf.h file. Pins B6 and B7 are used
* but using any other I2C pins should be trivial.
*/

#include "i2c_master.h"
Expand All @@ -41,7 +43,7 @@ static const I2CConfig i2cconfig = {

void i2c_init(void)
{
palSetGroupMode(GPIOB,6,7, PAL_MODE_INPUT); // Try releasing special pins for a short time
palSetGroupMode(GPIOB, GPIOB_PIN6 | GPIOB_PIN7, 0, PAL_MODE_INPUT); // Try releasing special pins for a short time
chThdSleepMilliseconds(10);

palSetPadMode(GPIOB, 6, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP);
Expand Down Expand Up @@ -82,12 +84,12 @@ uint8_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t l
{
complete_packet[i+1] = data[i];
}
complete_packet[0] = regaddr
complete_packet[0] = regaddr;

return i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), complete_packet, length + 1, 0, 0, MS2ST(timeout));
}

uint8_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)
uint8_t i2c_readReg(uint8_t devaddr, uint8_t* regaddr, uint8_t* data, uint16_t length, uint16_t timeout)
{
i2c_address = devaddr;
i2cStart(&I2C_DRIVER, &i2cconfig);
Expand All @@ -97,7 +99,6 @@ uint8_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t le
// This is usually not needed. It releases the driver to allow pins to become GPIO again.
uint8_t i2c_stop(uint16_t timeout)
{
i2c_address = address;
i2cStop(&I2C_DRIVER);
return 0;
}
4 changes: 2 additions & 2 deletions drivers/arm/i2c_master.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ uint8_t i2c_start(uint8_t address);
uint8_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);
uint8_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);
uint8_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout);
uint8_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout);
void i2c_stop(void);
uint8_t i2c_readReg(uint8_t devaddr, uint8_t* regaddr, uint8_t* data, uint16_t length, uint16_t timeout);
uint8_t i2c_stop(uint16_t timeout);
50 changes: 25 additions & 25 deletions drivers/is31fl3731.c → drivers/issi/is31fl3731.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ bool g_led_control_registers_update_required = false;
// 0x10 - R16,R15,R14,R13,R12,R11,R10,R09


void IS31_write_register( uint8_t addr, uint8_t reg, uint8_t data )
void IS31FL3731_write_register( uint8_t addr, uint8_t reg, uint8_t data )
{
g_twi_transfer_buffer[0] = reg;
g_twi_transfer_buffer[1] = data;
Expand All @@ -106,7 +106,7 @@ void IS31_write_register( uint8_t addr, uint8_t reg, uint8_t data )
#endif
}

void IS31_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer )
void IS31FL3731_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer )
{
// assumes bank is already selected

Expand Down Expand Up @@ -135,18 +135,18 @@ void IS31_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer )
}
}

void IS31_init( uint8_t addr )
void IS31FL3731_init( uint8_t addr )
{
// In order to avoid the LEDs being driven with garbage data
// in the LED driver's PWM registers, first enable software shutdown,
// then set up the mode and other settings, clear the PWM registers,
// then disable software shutdown.

// select "function register" bank
IS31_write_register( addr, ISSI_COMMANDREGISTER, ISSI_BANK_FUNCTIONREG );
IS31FL3731_write_register( addr, ISSI_COMMANDREGISTER, ISSI_BANK_FUNCTIONREG );

// enable software shutdown
IS31_write_register( addr, ISSI_REG_SHUTDOWN, 0x00 );
IS31FL3731_write_register( addr, ISSI_REG_SHUTDOWN, 0x00 );
// this delay was copied from other drivers, might not be needed
#ifdef __AVR__
_delay_ms( 10 );
Expand All @@ -155,47 +155,47 @@ void IS31_init( uint8_t addr )
#endif

// picture mode
IS31_write_register( addr, ISSI_REG_CONFIG, ISSI_REG_CONFIG_PICTUREMODE );
IS31FL3731_write_register( addr, ISSI_REG_CONFIG, ISSI_REG_CONFIG_PICTUREMODE );
// display frame 0
IS31_write_register( addr, ISSI_REG_PICTUREFRAME, 0x00 );
IS31FL3731_write_register( addr, ISSI_REG_PICTUREFRAME, 0x00 );
// audio sync off
IS31_write_register( addr, ISSI_REG_AUDIOSYNC, 0x00 );
IS31FL3731_write_register( addr, ISSI_REG_AUDIOSYNC, 0x00 );

// select bank 0
IS31_write_register( addr, ISSI_COMMANDREGISTER, 0 );
IS31FL3731_write_register( addr, ISSI_COMMANDREGISTER, 0 );

// turn off all LEDs in the LED control register
for ( int i = 0x00; i <= 0x11; i++ )
{
IS31_write_register( addr, i, 0x00 );
IS31FL3731_write_register( addr, i, 0x00 );
}

// turn off all LEDs in the blink control register (not really needed)
for ( int i = 0x12; i <= 0x23; i++ )
{
IS31_write_register( addr, i, 0x00 );
IS31FL3731_write_register( addr, i, 0x00 );
}

// set PWM on all LEDs to 0
for ( int i = 0x24; i <= 0xB3; i++ )
{
IS31_write_register( addr, i, 0x00 );
IS31FL3731_write_register( addr, i, 0x00 );
}

// select "function register" bank
IS31_write_register( addr, ISSI_COMMANDREGISTER, ISSI_BANK_FUNCTIONREG );
IS31FL3731_write_register( addr, ISSI_COMMANDREGISTER, ISSI_BANK_FUNCTIONREG );

// disable software shutdown
IS31_write_register( addr, ISSI_REG_SHUTDOWN, 0x01 );
IS31FL3731_write_register( addr, ISSI_REG_SHUTDOWN, 0x01 );

// select bank 0 and leave it selected.
// most usage after initialization is just writing PWM buffers in bank 0
// as there's not much point in double-buffering
IS31_write_register( addr, ISSI_COMMANDREGISTER, 0 );
IS31FL3731_write_register( addr, ISSI_COMMANDREGISTER, 0 );

}

void IS31_set_color( int index, uint8_t red, uint8_t green, uint8_t blue )
void IS31FL3731_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];
Expand All @@ -208,15 +208,15 @@ void IS31_set_color( int index, uint8_t red, uint8_t green, uint8_t blue )
}
}

void IS31_set_color_all( uint8_t red, uint8_t green, uint8_t blue )
void IS31FL3731_set_color_all( uint8_t red, uint8_t green, uint8_t blue )
{
for ( int i = 0; i < DRIVER_LED_TOTAL; i++ )
{
IS31_set_color( i, red, green, blue );
IS31FL3731_set_color( i, red, green, blue );
}
}

void IS31_set_led_control_register( uint8_t index, bool red, bool green, bool blue )
void IS31FL3731_set_led_control_register( uint8_t index, bool red, bool green, bool blue )
{
is31_led led = g_is31_leds[index];

Expand Down Expand Up @@ -247,24 +247,24 @@ void IS31_set_led_control_register( uint8_t index, bool red, bool green, bool bl

}

void IS31_update_pwm_buffers( uint8_t addr1, uint8_t addr2 )
void IS31FL3731_update_pwm_buffers( uint8_t addr1, uint8_t addr2 )
{
if ( g_pwm_buffer_update_required )
{
IS31_write_pwm_buffer( addr1, g_pwm_buffer[0] );
IS31_write_pwm_buffer( addr2, g_pwm_buffer[1] );
IS31FL3731_write_pwm_buffer( addr1, g_pwm_buffer[0] );
IS31FL3731_write_pwm_buffer( addr2, g_pwm_buffer[1] );
}
g_pwm_buffer_update_required = false;
}

void IS31_update_led_control_registers( uint8_t addr1, uint8_t addr2 )
void IS31FL3731_update_led_control_registers( uint8_t addr1, uint8_t addr2 )
{
if ( g_led_control_registers_update_required )
{
for ( int i=0; i<18; i++ )
{
IS31_write_register(addr1, i, g_led_control_registers[0][i] );
IS31_write_register(addr2, i, g_led_control_registers[1][i] );
IS31FL3731_write_register(addr1, i, g_led_control_registers[0][i] );
IS31FL3731_write_register(addr2, i, g_led_control_registers[1][i] );
}
}
}
Expand Down
Loading

0 comments on commit 2218311

Please sign in to comment.