Skip to content

Commit

Permalink
Added macros to Dynamic Keymaps, Zeal60 RGB backlight improvements (q…
Browse files Browse the repository at this point in the history
…mk#4520)

* Refactored M6-B to use Zeal60 RGB backlight code

* Fixed M6-B LED co-ordinates

* Minor changes to RGB config for Zeal65

* Added dynamic keymaps to WT80-A, WT60-A, WT-80A, U80-A

* Macro implementation

* Implemented macros, API protocol version 8, RGB backlight fixes

* Improved radial effects for M6-B

* Fixed undefined references when building an RGB keyboard after M6-A
  • Loading branch information
wilba authored and drashna committed Nov 30, 2018
1 parent b10aad4 commit d7f1e07
Show file tree
Hide file tree
Showing 22 changed files with 561 additions and 106 deletions.
13 changes: 8 additions & 5 deletions keyboards/rama/m60_a/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define MATRIX_ROWS 5
#define MATRIX_COLS 14

// Zeal60 PCB default pin-out
// M60-A PCB default pin-out
#define MATRIX_ROW_PINS { F0, F1, F4, F6, F7 }
#define MATRIX_COL_PINS { F5, D5, B1, B2, B3, D3, D2, C7, C6, B6, B5, B4, D7, D6 }
#define UNUSED_PINS
Expand Down Expand Up @@ -118,11 +118,14 @@
// Bump this every time we change what we store
// This will automatically reset the EEPROM with defaults
// and avoid loading invalid data from the EEPROM
#define EEPROM_VERSION 0x07
#define EEPROM_VERSION 0x08
#define EEPROM_VERSION_ADDR 34

// Backlight config starts after EEPROM version
#define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35
// Dynamic keymap starts after backlight config (35+37)
#define DYNAMIC_KEYMAP_EEPROM_ADDR 72

// Dynamic keymap starts after backlight config (35+31)
#define DYNAMIC_KEYMAP_EEPROM_ADDR 66
// Dynamic macro starts after dynamic keymaps (66+(4*5*14*2)) = (66+560)
#define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 626
#define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 398
#define DYNAMIC_KEYMAP_MACRO_COUNT 16
4 changes: 2 additions & 2 deletions keyboards/rama/m60_a/rules.mk
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@


# project specific files
SRC = ../zeal60/zeal60.c \
../zeal60/rgb_backlight.c \
SRC = keyboards/zeal60/zeal60.c \
keyboards/zeal60/rgb_backlight.c \
quantum/color.c \
drivers/issi/is31fl3731.c \
drivers/avr/i2c_master.c
Expand Down
14 changes: 10 additions & 4 deletions keyboards/rama/m6_a/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,17 @@
// Bump this every time we change what we store
// This will automatically reset the EEPROM with defaults
// and avoid loading invalid data from the EEPROM
#define EEPROM_VERSION 0x07
#define EEPROM_VERSION 0x08
#define EEPROM_VERSION_ADDR 34

// NOTE: M6-A doesn't use RGB backlight, but we keep this
// consistent with M6-B which does.

// Backlight config starts after EEPROM version
#define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35
// Dynamic keymap starts after backlight config (35+37)
#define DYNAMIC_KEYMAP_EEPROM_ADDR 72

// Dynamic keymap starts after backlight config (35+43)
#define DYNAMIC_KEYMAP_EEPROM_ADDR 78
// Dynamic macro starts after dynamic keymaps (78+(4*6*2)) = (78+48)
#define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 126
#define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 898
#define DYNAMIC_KEYMAP_MACRO_COUNT 16
2 changes: 1 addition & 1 deletion keyboards/rama/m6_a/rules.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# project specific files
SRC = ../zeal60/zeal60.c
SRC = keyboards/zeal60/zeal60.c

# MCU name
MCU = atmega32u4
Expand Down
11 changes: 7 additions & 4 deletions keyboards/rama/m6_b/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,14 @@
// Bump this every time we change what we store
// This will automatically reset the EEPROM with defaults
// and avoid loading invalid data from the EEPROM
#define EEPROM_VERSION 0x07
#define EEPROM_VERSION 0x08
#define EEPROM_VERSION_ADDR 34

// Backlight config starts after EEPROM version
#define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35
// Dynamic keymap starts after backlight config (35+37)
#define DYNAMIC_KEYMAP_EEPROM_ADDR 72

// Dynamic keymap starts after backlight config (35+43)
#define DYNAMIC_KEYMAP_EEPROM_ADDR 78
// Dynamic macro starts after dynamic keymaps (78+(4*6*2)) = (78+48)
#define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 126
#define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 898
#define DYNAMIC_KEYMAP_MACRO_COUNT 16
4 changes: 2 additions & 2 deletions keyboards/rama/m6_b/rules.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# project specific files
SRC = ../zeal60/zeal60.c \
../zeal60/rgb_backlight.c \
SRC = keyboards/zeal60/zeal60.c \
keyboards/zeal60/rgb_backlight.c \
quantum/color.c \
drivers/issi/is31fl3218.c \
drivers/avr/i2c_master.c
Expand Down
10 changes: 6 additions & 4 deletions keyboards/rama/u80_a/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@
#define EEPROM_VERSION 0x07
#define EEPROM_VERSION_ADDR 34

// Backlight config starts after EEPROM version
#define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35
// Dynamic keymap starts after backlight config (35+37)
#define DYNAMIC_KEYMAP_EEPROM_ADDR 72
// Dynamic keymap starts after EEPROM version
#define DYNAMIC_KEYMAP_EEPROM_ADDR 35
// Dynamic macro starts after dynamic keymaps (35+(4*6*17*2)) = (35+816)
#define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 851
#define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 173
#define DYNAMIC_KEYMAP_MACRO_COUNT 16
12 changes: 7 additions & 5 deletions keyboards/wilba_tech/wt60_a/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,12 @@
// Bump this every time we change what we store
// This will automatically reset the EEPROM with defaults
// and avoid loading invalid data from the EEPROM
#define EEPROM_VERSION 0x07
#define EEPROM_VERSION 0x08
#define EEPROM_VERSION_ADDR 34

// Backlight config starts after EEPROM version
#define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35
// Dynamic keymap starts after backlight config (35+37)
#define DYNAMIC_KEYMAP_EEPROM_ADDR 72
// Dynamic keymap starts after EEPROM version
#define DYNAMIC_KEYMAP_EEPROM_ADDR 35
// Dynamic macro starts after dynamic keymaps (35+(4*5*14*2)) = (35+560)
#define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 595
#define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 429
#define DYNAMIC_KEYMAP_MACRO_COUNT 16
12 changes: 7 additions & 5 deletions keyboards/wilba_tech/wt65_a/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,12 @@
// Bump this every time we change what we store
// This will automatically reset the EEPROM with defaults
// and avoid loading invalid data from the EEPROM
#define EEPROM_VERSION 0x07
#define EEPROM_VERSION 0x08
#define EEPROM_VERSION_ADDR 34

// Backlight config starts after EEPROM version
#define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35
// Dynamic keymap starts after backlight config (35+37)
#define DYNAMIC_KEYMAP_EEPROM_ADDR 72
// Dynamic keymap starts after EEPROM version
#define DYNAMIC_KEYMAP_EEPROM_ADDR 35
// Dynamic macro starts after dynamic keymaps (35+(4*5*15*2)) = (35+600)
#define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 635
#define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 389
#define DYNAMIC_KEYMAP_MACRO_COUNT 16
12 changes: 7 additions & 5 deletions keyboards/wilba_tech/wt80_a/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,12 @@
// Bump this every time we change what we store
// This will automatically reset the EEPROM with defaults
// and avoid loading invalid data from the EEPROM
#define EEPROM_VERSION 0x07
#define EEPROM_VERSION 0x08
#define EEPROM_VERSION_ADDR 34

// Backlight config starts after EEPROM version
#define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35
// Dynamic keymap starts after backlight config (35+37)
#define DYNAMIC_KEYMAP_EEPROM_ADDR 72
// Dynamic keymap starts after EEPROM version
#define DYNAMIC_KEYMAP_EEPROM_ADDR 35
// Dynamic macro starts after dynamic keymaps (35+(4*6*17*2)) = (35+816)
#define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 851
#define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 173
#define DYNAMIC_KEYMAP_MACRO_COUNT 16
92 changes: 85 additions & 7 deletions keyboards/wilba_tech/wt_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "quantum.h"
#include "keyboards/wilba_tech/wt_mono_backlight.h"
#include "keyboards/zeal60/zeal60_api.h" // Temporary hack
#include "keyboards/zeal60/zeal60_keycodes.h" // Temporary hack

#include "raw_hid.h"
#include "dynamic_keymap.h"
Expand Down Expand Up @@ -91,22 +92,57 @@ void raw_hid_receive( uint8_t *data, uint8_t length )
dynamic_keymap_reset();
break;
}
#endif // DYNAMIC_KEYMAP_ENABLE
case id_backlight_config_set_value:
case id_dynamic_keymap_macro_get_count:
{
command_data[0] = dynamic_keymap_macro_get_count();
break;
}
case id_dynamic_keymap_macro_get_buffer_size:
{
uint16_t size = dynamic_keymap_macro_get_buffer_size();
command_data[0] = size >> 8;
command_data[1] = size & 0xFF;
break;
}
case id_dynamic_keymap_macro_get_buffer:
{
uint16_t offset = ( command_data[0] << 8 ) | command_data[1];
uint16_t size = command_data[2]; // size <= 28
dynamic_keymap_macro_get_buffer( offset, size, &command_data[3] );
break;
}
case id_dynamic_keymap_macro_set_buffer:
{
uint16_t offset = ( command_data[0] << 8 ) | command_data[1];
uint16_t size = command_data[2]; // size <= 28
dynamic_keymap_macro_set_buffer( offset, size, &command_data[3] );
break;
}
case id_dynamic_keymap_macro_reset:
{
dynamic_keymap_macro_reset();
break;
}
case id_dynamic_keymap_get_layer_count:
{
//backlight_config_set_value(command_data);
command_data[0] = dynamic_keymap_get_layer_count();
break;
}
case id_backlight_config_get_value:
case id_dynamic_keymap_get_buffer:
{
//backlight_config_get_value(command_data);
uint16_t offset = ( command_data[0] << 8 ) | command_data[1];
uint16_t size = command_data[2]; // size <= 28
dynamic_keymap_get_buffer( offset, size, &command_data[3] );
break;
}
case id_backlight_config_save:
case id_dynamic_keymap_set_buffer:
{
//backlight_config_save();
uint16_t offset = ( command_data[0] << 8 ) | command_data[1];
uint16_t size = command_data[2]; // size <= 28
dynamic_keymap_set_buffer( offset, size, &command_data[3] );
break;
}
#endif // DYNAMIC_KEYMAP_ENABLE
case id_eeprom_reset:
{
eeprom_reset();
Expand Down Expand Up @@ -151,6 +187,8 @@ void main_init(void)
#ifdef DYNAMIC_KEYMAP_ENABLE
// This resets the keymaps in EEPROM to what is in flash.
dynamic_keymap_reset();
// This resets the macros in EEPROM to nothing.
dynamic_keymap_macro_reset();
#endif
// Save the magic number last, in case saving was interrupted
eeprom_set_valid(true);
Expand Down Expand Up @@ -196,3 +234,43 @@ void matrix_scan_kb(void)
backlight_update_pwm_buffers();
matrix_scan_user();
}

bool process_record_kb(uint16_t keycode, keyrecord_t *record)
{
switch(keycode) {
case FN_MO13:
if (record->event.pressed) {
layer_on(1);
update_tri_layer(1, 2, 3);
} else {
layer_off(1);
update_tri_layer(1, 2, 3);
}
return false;
break;
case FN_MO23:
if (record->event.pressed) {
layer_on(2);
update_tri_layer(1, 2, 3);
} else {
layer_off(2);
update_tri_layer(1, 2, 3);
}
return false;
break;
}

#ifdef DYNAMIC_KEYMAP_ENABLE
// Handle macros
if (record->event.pressed) {
if ( keycode >= MACRO00 && keycode <= MACRO15 )
{
uint8_t id = keycode - MACRO00;
dynamic_keymap_macro_send(id);
return false;
}
}
#endif //DYNAMIC_KEYMAP_ENABLE

return process_record_user(keycode, record);
}
10 changes: 7 additions & 3 deletions keyboards/zeal60/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,15 @@
// Bump this every time we change what we store
// This will automatically reset the EEPROM with defaults
// and avoid loading invalid data from the EEPROM
#define EEPROM_VERSION 0x07
#define EEPROM_VERSION 0x08
#define EEPROM_VERSION_ADDR 34

// Backlight config starts after EEPROM version
#define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35
// Dynamic keymap starts after backlight config (35+37)
#define DYNAMIC_KEYMAP_EEPROM_ADDR 72
// Dynamic keymap starts after backlight config (35+31)
#define DYNAMIC_KEYMAP_EEPROM_ADDR 66
// Dynamic macro starts after dynamic keymaps (66+(4*5*14*2)) = (66+560)
#define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 626
#define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 398
#define DYNAMIC_KEYMAP_MACRO_COUNT 16

Loading

0 comments on commit d7f1e07

Please sign in to comment.