From 48a992f1c037658bbacccefd2709ffdcda8bb345 Mon Sep 17 00:00:00 2001
From: Wilba6582
Date: Fri, 14 Sep 2018 04:37:13 +1000
Subject: Zeal60/Zeal65/M60-A implementation (#3879)
* Initial version of zeal60
* WIP
* Fixes issue #900
* Adding RGB underglow functionality.
Fixed a compile-time conflict caused by enabling RGB underglow functionality.
* Refactor RPC protocol
* Fix last merge
* README for RGB underglow updated.
* Additional README changes.
* Adding RGBW strip software-based current-limiting functionality.
* RGBW current-limiting functionality should be handled by RGBSTRIP_MAX_CURRENT_PER_LIGHT instead.
* Updated README to reflect implementation of built-in current limiting.
* Keymap readability improvements.
* Minor keymap improvements.
* Fixed LED driver init sequence, formatting
* Dimming implementation tested, working.
* Stab LEDs synced with spacebar hits in effects.
* RGB underglow tested and functional. Simplified README for RGB underglow.
* Undid accidental file deletion from previous merge conflict. Safer values for RGB underglow.
* Improved arrow key positions in keymap.
* Added functionality to correct uneven RGB underglow. Refactored related code.
* Reverted to safer values for underglow.
* Changes for v0.3
* Custom LED brightness scaling will take place after current adjustment in order to avoid being overridden.
* Create keymap.c
Added split backspace and split shift to ISO layout
* Create config.h
Turned on LEDs for new layout
* Fixed bug where left spacebar stabilizer LED (LC06) would adopt color of row above.
* Added hhkb_wilba keymap
* Update keymap.c
* Update keymap.c
* Update keymap.c
* Added indicators, full param setting via host
* Added "mousekey" layout
* Added Zeal65 support, factory test mode
* Keycode safe range changed, caused bugs
* Bumped EEPROM version due to change in QMK keycodes
* Disable HHKB "blocked" LEDs if KC_NO in keymap
* Added "disable_hhkb_blocker_leds"
* Required overridden function for keymaps in EEPROM
* Added polar coordinate mapping, effect speed
* Force Raw HID interface number to 1 always
* Fixed last merge from master
* Added effect speed to default keymaps
* add BACKLIGHT_ prefix to vars
* add BACKLIGHT_ prefix to vars
* Keymap speed effect; keymap improvements/fixes
Readme updated to match changes
* Refactored to use common IS31FL3731/I2C drivers
* Fixed make rules, backlight disabled feature
* Make split rightshift default for Zeal65
* Added M60-A as a "version" of Zeal60.
* Renamed IS31FL3731 driver functions
* Fix suspend_wakeup_init_kb() being defined twice
* First pass refactor dynamic keymaps
* Updated to changed I2C and ISSI drivers
* Refactor zeal_color.* usage to quantum/color.*
* Updated Zeal65, fixed dynamic_keymap
* Major refactoring of Zeal60 backlight and API
* Lots of little cleanups
* Added readme.md
* Added readme.md
* Added LAYOUT_60*() macros, refactored and cleaned up default keymaps
* Fix compile error in suspend.c
* Added Zeal65 LAYOUT macros, info.json
* Added rama/m60_a, deleted zeal60/keymaps/m60_a
* Fixed rama/m60_a/keymaps/proto
* Fixed compilation error for suspend.c
* Requested changes for PR
* Fixed readme.md images
* Another readme.md fix
* Added drashna's requested changes
---
quantum/dynamic_keymap.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 97 insertions(+)
create mode 100644 quantum/dynamic_keymap.c
(limited to 'quantum/dynamic_keymap.c')
diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c
new file mode 100644
index 0000000000..9f18612d56
--- /dev/null
+++ b/quantum/dynamic_keymap.c
@@ -0,0 +1,97 @@
+/* Copyright 2017 Jason Williams (Wilba)
+ *
+ * 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 .
+ */
+
+#include "config.h"
+#include "keymap.h" // to get keymaps[][][]
+
+#include "dynamic_keymap.h"
+
+#ifdef DYNAMIC_KEYMAP_ENABLE
+
+#ifndef DYNAMIC_KEYMAP_EEPROM_ADDR
+#error DYNAMIC_KEYMAP_EEPROM_ADDR not defined
+#endif
+
+#ifndef DYNAMIC_KEYMAP_LAYER_COUNT
+#error DYNAMIC_KEYMAP_LAYER_COUNT not defined
+#endif
+
+#define KC_EENULL 0xFFFF // TODO: move to enum quantum_keycodes
+
+void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column)
+{
+ // TODO: optimize this with some left shifts
+ return ((void*)DYNAMIC_KEYMAP_EEPROM_ADDR) + ( layer * MATRIX_ROWS * MATRIX_COLS * 2 ) +
+ ( row * MATRIX_COLS * 2 ) + ( column * 2 );
+}
+
+uint16_t dynamic_keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t column)
+{
+ void *address = dynamic_keymap_key_to_eeprom_address(layer, row, column);
+ // Big endian, so we can read/write EEPROM directly from host if we want
+ uint16_t keycode = eeprom_read_byte(address) << 8;
+ keycode |= eeprom_read_byte(address + 1);
+ return keycode;
+}
+
+void dynamic_keymap_set_keycode(uint8_t layer, uint8_t row, uint8_t column, uint16_t keycode)
+{
+ void *address = dynamic_keymap_key_to_eeprom_address(layer, row, column);
+ // Big endian, so we can read/write EEPROM directly from host if we want
+ eeprom_update_byte(address, (uint8_t)(keycode >> 8));
+ eeprom_update_byte(address+1, (uint8_t)(keycode & 0xFF));
+}
+
+void dynamic_keymap_clear_all(void)
+{
+ // Save "empty" keymaps.
+ for ( int layer = 0; layer < DYNAMIC_KEYMAP_LAYER_COUNT; layer++ )
+ {
+ for ( int row = 0; row < MATRIX_ROWS; row++ )
+ {
+ for ( int column = 0; column < MATRIX_COLS; column++ )
+ {
+ dynamic_keymap_set_keycode(layer, row, column, KC_EENULL);
+ }
+ }
+ }
+}
+
+// This overrides the one in quantum/keymap_common.c
+uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
+{
+ // This used to test EEPROM for magic bytes, but it was redundant.
+ // Test for EEPROM usage change (fresh install, address change, etc.)
+ // externally and call dynamic_keymap_default_save()
+ if ( layer < DYNAMIC_KEYMAP_LAYER_COUNT &&
+ key.row < MATRIX_ROWS && // possibly redundant
+ key.col < MATRIX_COLS ) // possibly redundant
+ {
+ uint16_t keycode = dynamic_keymap_get_keycode(layer, key.row, key.col);
+
+ // If keycode is not "empty", return it, otherwise
+ // drop down to return the one in flash
+ if ( keycode != KC_EENULL)
+ {
+ return keycode;
+ }
+ }
+
+ return pgm_read_word(&keymaps[layer][key.row][key.col]);
+}
+
+#endif // DYNAMIC_KEYMAP_ENABLE
+
--
cgit v1.2.3
From a173eda6d28bd09b2d59448a6532edb7a6c8e358 Mon Sep 17 00:00:00 2001
From: Wilba6582
Date: Fri, 28 Sep 2018 14:09:14 +1000
Subject: Improved dynamic keymaps (#3972)
* Improved dynamic keymaps
* K&R sucks
---
keyboards/zeal60/zeal60.c | 9 ++++-----
keyboards/zeal60/zeal60_api.h | 2 +-
quantum/dynamic_keymap.c | 42 +++++++++++++++---------------------------
quantum/dynamic_keymap.h | 7 ++-----
4 files changed, 22 insertions(+), 38 deletions(-)
(limited to 'quantum/dynamic_keymap.c')
diff --git a/keyboards/zeal60/zeal60.c b/keyboards/zeal60/zeal60.c
index e516c4dbfc..092235ca61 100644
--- a/keyboards/zeal60/zeal60.c
+++ b/keyboards/zeal60/zeal60.c
@@ -81,9 +81,9 @@ void raw_hid_receive( uint8_t *data, uint8_t length )
dynamic_keymap_set_keycode( command_data[0], command_data[1], command_data[2], ( command_data[3] << 8 ) | command_data[4] );
break;
}
- case id_dynamic_keymap_clear_all:
+ case id_dynamic_keymap_reset:
{
- dynamic_keymap_clear_all();
+ dynamic_keymap_reset();
break;
}
#endif // DYNAMIC_KEYMAP_ENABLE
@@ -171,9 +171,8 @@ void matrix_init_kb(void)
#endif // RGB_BACKLIGHT_ENABLED
#ifdef DYNAMIC_KEYMAP_ENABLE
- // This saves "empty" keymaps so it falls back to the keymaps
- // in the firmware (aka. progmem/flash)
- dynamic_keymap_clear_all();
+ // This resets the keymaps in EEPROM to what is in flash.
+ dynamic_keymap_reset();
#endif
// Save the magic number last, in case saving was interrupted
diff --git a/keyboards/zeal60/zeal60_api.h b/keyboards/zeal60/zeal60_api.h
index baa8ac09f8..eaac3ad7ce 100644
--- a/keyboards/zeal60/zeal60_api.h
+++ b/keyboards/zeal60/zeal60_api.h
@@ -24,7 +24,7 @@ enum zeal60_command_id
id_set_keyboard_value,
id_dynamic_keymap_get_keycode,
id_dynamic_keymap_set_keycode,
- id_dynamic_keymap_clear_all,
+ id_dynamic_keymap_reset,
id_backlight_config_set_value,
id_backlight_config_get_value,
id_backlight_config_save,
diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c
index 9f18612d56..2c989d6918 100644
--- a/quantum/dynamic_keymap.c
+++ b/quantum/dynamic_keymap.c
@@ -16,6 +16,8 @@
#include "config.h"
#include "keymap.h" // to get keymaps[][][]
+#include "tmk_core/common/eeprom.h"
+#include "progmem.h"// to read default from flash
#include "dynamic_keymap.h"
@@ -29,8 +31,6 @@
#error DYNAMIC_KEYMAP_LAYER_COUNT not defined
#endif
-#define KC_EENULL 0xFFFF // TODO: move to enum quantum_keycodes
-
void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column)
{
// TODO: optimize this with some left shifts
@@ -55,16 +55,15 @@ void dynamic_keymap_set_keycode(uint8_t layer, uint8_t row, uint8_t column, uint
eeprom_update_byte(address+1, (uint8_t)(keycode & 0xFF));
}
-void dynamic_keymap_clear_all(void)
+void dynamic_keymap_reset(void)
{
- // Save "empty" keymaps.
- for ( int layer = 0; layer < DYNAMIC_KEYMAP_LAYER_COUNT; layer++ )
- {
- for ( int row = 0; row < MATRIX_ROWS; row++ )
- {
- for ( int column = 0; column < MATRIX_COLS; column++ )
- {
- dynamic_keymap_set_keycode(layer, row, column, KC_EENULL);
+ // Reset the keymaps in EEPROM to what is in flash.
+ // All keyboards using dynamic keymaps should define a layout
+ // for the same number of layers as DYNAMIC_KEYMAP_LAYER_COUNT.
+ for ( int layer = 0; layer < DYNAMIC_KEYMAP_LAYER_COUNT; layer++ ) {
+ for ( int row = 0; row < MATRIX_ROWS; row++ ) {
+ for ( int column = 0; column < MATRIX_COLS; column++ ) {
+ dynamic_keymap_set_keycode(layer, row, column, pgm_read_word(&keymaps[layer][row][column]));
}
}
}
@@ -73,24 +72,13 @@ void dynamic_keymap_clear_all(void)
// This overrides the one in quantum/keymap_common.c
uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
{
- // This used to test EEPROM for magic bytes, but it was redundant.
- // Test for EEPROM usage change (fresh install, address change, etc.)
- // externally and call dynamic_keymap_default_save()
if ( layer < DYNAMIC_KEYMAP_LAYER_COUNT &&
- key.row < MATRIX_ROWS && // possibly redundant
- key.col < MATRIX_COLS ) // possibly redundant
- {
- uint16_t keycode = dynamic_keymap_get_keycode(layer, key.row, key.col);
-
- // If keycode is not "empty", return it, otherwise
- // drop down to return the one in flash
- if ( keycode != KC_EENULL)
- {
- return keycode;
- }
+ key.row < MATRIX_ROWS &&
+ key.col < MATRIX_COLS ) {
+ return dynamic_keymap_get_keycode(layer, key.row, key.col);
+ } else {
+ return KC_NO;
}
-
- return pgm_read_word(&keymaps[layer][key.row][key.col]);
}
#endif // DYNAMIC_KEYMAP_ENABLE
diff --git a/quantum/dynamic_keymap.h b/quantum/dynamic_keymap.h
index b0133aeb85..bd76adae20 100644
--- a/quantum/dynamic_keymap.h
+++ b/quantum/dynamic_keymap.h
@@ -13,9 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
-#ifndef DYNAMIC_KEYMAP_H
-#define DYNAMIC_KEYMAP_H
+#pragma once
#include
#include
@@ -23,9 +21,8 @@
void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column);
uint16_t dynamic_keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t column);
void dynamic_keymap_set_keycode(uint8_t layer, uint8_t row, uint8_t column, uint16_t keycode);
-void dynamic_keymap_clear_all(void);
+void dynamic_keymap_reset(void);
// This overrides the one in quantum/keymap_common.c
// uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
-#endif //DYNAMIC_KEYMAP_H
--
cgit v1.2.3
From 66ef1e3d6770e388d631d25e4cd1c6b1640cea24 Mon Sep 17 00:00:00 2001
From: Wilba6582
Date: Mon, 1 Oct 2018 01:35:10 +1000
Subject: RAMA M6-B and IS31FL3218 driver (#4021)
* Initial RAMA M6-B commit.
* Moved IS31FL3218 driver, minor cleanups
* Refactor, added dynamic keymap.
* Added dynamic keymaps to RAMA M6-A
* Refactor M6-A and M6-B to use common code.
* Formatting
* Cleanup
* Cleanup
* Changes from review
---
drivers/issi/is31fl3218.c | 102 +++++++++
drivers/issi/is31fl3218.h | 24 ++
keyboards/rama/m6_a/config.h | 24 +-
keyboards/rama/m6_a/keymaps/default/config.h | 24 --
keyboards/rama/m6_a/keymaps/default/keymap.c | 316 +--------------------------
keyboards/rama/m6_a/m6_a.c | 31 +--
keyboards/rama/m6_a/readme.md | 2 +-
keyboards/rama/m6_a/rules.mk | 44 ++--
keyboards/rama/m6_b/config.h | 129 +++++++++++
keyboards/rama/m6_b/info.json | 19 ++
keyboards/rama/m6_b/keymaps/default/keymap.c | 16 ++
keyboards/rama/m6_b/m6_b.c | 230 +++++++++++++++++++
keyboards/rama/m6_b/m6_b.h | 28 +++
keyboards/rama/m6_b/m6_b_api.h | 39 ++++
keyboards/rama/m6_b/readme.md | 15 ++
keyboards/rama/m6_b/rgb_backlight.c | 139 ++++++++++++
keyboards/rama/m6_b/rgb_backlight.h | 34 +++
keyboards/rama/m6_b/rules.mk | 77 +++++++
quantum/dynamic_keymap.c | 2 +-
19 files changed, 901 insertions(+), 394 deletions(-)
create mode 100644 drivers/issi/is31fl3218.c
create mode 100644 drivers/issi/is31fl3218.h
delete mode 100644 keyboards/rama/m6_a/keymaps/default/config.h
create mode 100644 keyboards/rama/m6_b/config.h
create mode 100644 keyboards/rama/m6_b/info.json
create mode 100644 keyboards/rama/m6_b/keymaps/default/keymap.c
create mode 100644 keyboards/rama/m6_b/m6_b.c
create mode 100644 keyboards/rama/m6_b/m6_b.h
create mode 100644 keyboards/rama/m6_b/m6_b_api.h
create mode 100644 keyboards/rama/m6_b/readme.md
create mode 100644 keyboards/rama/m6_b/rgb_backlight.c
create mode 100644 keyboards/rama/m6_b/rgb_backlight.h
create mode 100644 keyboards/rama/m6_b/rules.mk
(limited to 'quantum/dynamic_keymap.c')
diff --git a/drivers/issi/is31fl3218.c b/drivers/issi/is31fl3218.c
new file mode 100644
index 0000000000..db44f72564
--- /dev/null
+++ b/drivers/issi/is31fl3218.c
@@ -0,0 +1,102 @@
+/* Copyright 2018 Jason Williams (Wilba)
+ *
+ * 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 .
+ */
+#include "is31fl3218.h"
+#include "i2c_master.h"
+
+// This is the full 8-bit address
+#define ISSI_ADDRESS 0b10101000
+
+// These are the register addresses
+#define ISSI_REG_SHUTDOWN 0x00
+#define ISSI_REG_PWM 0x01
+#define ISSI_REG_CONTROL 0x13
+#define ISSI_REG_UPDATE 0x16
+#define ISSI_REG_RESET 0x17
+
+// Default timeout if no I2C response
+#define ISSI_TIMEOUT 100
+
+// Reusable buffer for transfers
+uint8_t g_twi_transfer_buffer[20];
+
+// IS31FL3218 has 18 PWM outputs and a fixed I2C address, so no chaining.
+// If used as RGB LED driver, LEDs are assigned RGB,RGB,RGB,RGB,RGB,RGB
+uint8_t g_pwm_buffer[18];
+bool g_pwm_buffer_update_required = false;
+
+void IS31FL3218_write_register( uint8_t reg, uint8_t data )
+{
+ g_twi_transfer_buffer[0] = reg;
+ g_twi_transfer_buffer[1] = data;
+ i2c_transmit( ISSI_ADDRESS, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
+}
+
+void IS31FL3218_write_pwm_buffer( uint8_t *pwm_buffer )
+{
+ g_twi_transfer_buffer[0] = ISSI_REG_PWM;
+ for ( int i=0; i<18; i++ ) {
+ g_twi_transfer_buffer[1+i] = pwm_buffer[i];
+ }
+
+ i2c_transmit( ISSI_ADDRESS, g_twi_transfer_buffer, 19, ISSI_TIMEOUT);
+}
+
+void IS31FL3218_init(void)
+{
+ // In case we ever want to reinitialize (?)
+ IS31FL3218_write_register( ISSI_REG_RESET, 0x00 );
+
+ // Turn off software shutdown
+ IS31FL3218_write_register( ISSI_REG_SHUTDOWN, 0x01 );
+
+ // Set all PWM values to zero
+ for ( uint8_t i = 0; i < 18; i++ ) {
+ IS31FL3218_write_register( ISSI_REG_PWM+i, 0x00 );
+ }
+
+ // Enable all channels
+ for ( uint8_t i = 0; i < 3; i++ ) {
+ IS31FL3218_write_register( ISSI_REG_CONTROL+i, 0b00111111 );
+ }
+
+ // Load PWM registers and LED Control register data
+ IS31FL3218_write_register( ISSI_REG_UPDATE, 0x01 );
+}
+
+void IS31FL3218_set_color( int index, uint8_t red, uint8_t green, uint8_t blue )
+{
+ g_pwm_buffer[index * 3 + 0] = red;
+ g_pwm_buffer[index * 3 + 1] = green;
+ g_pwm_buffer[index * 3 + 2] = blue;
+ g_pwm_buffer_update_required = true;
+}
+
+void IS31FL3218_set_color_all( uint8_t red, uint8_t green, uint8_t blue )
+{
+ for ( int i = 0; i < 6; i++ ) {
+ IS31FL3218_set_color( i, red, green, blue );
+ }
+}
+
+void IS31FL3218_update_pwm_buffers(void)
+{
+ if ( g_pwm_buffer_update_required ) {
+ IS31FL3218_write_pwm_buffer( g_pwm_buffer );
+ // Load PWM registers and LED Control register data
+ IS31FL3218_write_register( ISSI_REG_UPDATE, 0x01 );
+ }
+ g_pwm_buffer_update_required = false;
+}
diff --git a/drivers/issi/is31fl3218.h b/drivers/issi/is31fl3218.h
new file mode 100644
index 0000000000..2d24e51463
--- /dev/null
+++ b/drivers/issi/is31fl3218.h
@@ -0,0 +1,24 @@
+/* Copyright 2018 Jason Williams (Wilba)
+ *
+ * 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 .
+ */
+#pragma once
+
+#include
+#include
+
+void IS31FL3218_init(void);
+void IS31FL3218_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
+void IS31FL3218_set_color_all( uint8_t red, uint8_t green, uint8_t blue );
+void IS31FL3218_update_pwm_buffers(void);
diff --git a/keyboards/rama/m6_a/config.h b/keyboards/rama/m6_a/config.h
index 0c5355f4a8..8d77f5339d 100644
--- a/keyboards/rama/m6_a/config.h
+++ b/keyboards/rama/m6_a/config.h
@@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-#ifndef CONFIG_H
-#define CONFIG_H
+#pragma once
#include "config_common.h"
@@ -187,4 +186,23 @@ along with this program. If not, see .
/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */
//#define MIDI_TONE_KEYCODE_OCTAVES 1
-#endif
+#define RGB_BACKLIGHT_ENABLED 0
+
+#define DYNAMIC_KEYMAP_LAYER_COUNT 4
+
+
+// EEPROM usage
+
+// TODO: refactor with new user EEPROM code (coming soon)
+#define EEPROM_MAGIC 0x451F
+#define EEPROM_MAGIC_ADDR 32
+// 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_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
diff --git a/keyboards/rama/m6_a/keymaps/default/config.h b/keyboards/rama/m6_a/keymaps/default/config.h
deleted file mode 100644
index d150575c1a..0000000000
--- a/keyboards/rama/m6_a/keymaps/default/config.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright 2018 Wilba
- *
- * 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 .
- */
-
-#ifndef CONFIG_USER_H
-#define CONFIG_USER_H
-
-#include "../../config.h"
-
-// place overrides here
-
-#endif
diff --git a/keyboards/rama/m6_a/keymaps/default/keymap.c b/keyboards/rama/m6_a/keymaps/default/keymap.c
index 6b15f3cd10..7a408fa8aa 100644
--- a/keyboards/rama/m6_a/keymaps/default/keymap.c
+++ b/keyboards/rama/m6_a/keymaps/default/keymap.c
@@ -3,322 +3,14 @@
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
LAYOUT(
- TO(1), KC_A, KC_B, KC_C, KC_D, KC_E),
+ KC_1, KC_2, KC_3, KC_4, KC_5, KC_6),
LAYOUT(
- TO(2), KC_F, KC_G, KC_H, KC_I, KC_J),
+ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO),
LAYOUT(
- TO(3), KC_K, KC_L, KC_M, KC_N, KC_O),
+ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO),
LAYOUT(
- TO(4), KC_P, KC_Q, KC_R, KC_S, KC_T),
+ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO) };
- LAYOUT(
- TO(5), KC_U, KC_V, KC_W, KC_X, KC_Y),
-
- LAYOUT(
- TO(0), KC_Z, KC_1, KC_2, KC_3, KC_4)};
-
-const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
-{
- //keyevent_t event = record->event;
-
- switch (id)
- {
- case 0:
- if (record->event.pressed)
- {
- return MACRO(T(T), T(G), T(L), T(H), T(F), T(ENT), END);
- }
- break;
- case 1:
- if (record->event.pressed)
- {
- return MACRO(T(T), T(G), T(G), T(ENT), END);
- }
- break;
- case 2:
- if (record->event.pressed)
- {
- return MACRO(D(NO), T(L), U(NO), END);
- }
- break;
- case 3:
- if (record->event.pressed)
- {
- return MACRO(D(LCTL), T(Z), U(LCTL), END);
- }
- break;
- case 4:
- if (record->event.pressed)
- {
- return MACRO(D(LCTL), D(LSFT), T(Z), U(LSFT), U(LCTL), END);
- }
- break;
- case 5:
- if (record->event.pressed)
- {
- return MACRO(D(LCTL), T(X), U(LCTL), END);
- }
- break;
- case 6:
- if (record->event.pressed)
- {
- return MACRO(D(LCTL), T(C), U(LCTL), END);
- }
- break;
- case 7:
- if (record->event.pressed)
- {
- return MACRO(D(LCTL), T(V), U(LCTL), END);
- }
- break;
- }
- return MACRO_NONE;
-}
-
-// M6-A LEDs are connected to D6, B6, F5, B4, C7, F7
-// This is 1-based because I copied it from Knops code.
-void set_switch_led(int ledId, bool state)
-{
- if (state)
- {
- switch (ledId)
- {
- case 1:
- PORTD |= (1 << 6);
- break;
- case 2:
- PORTB |= (1 << 6);
- break;
- case 3:
- PORTF |= (1 << 5);
- break;
- case 4:
- PORTB |= (1 << 4);
- break;
- case 5:
- PORTC |= (1 << 7);
- break;
- case 6:
- PORTF |= (1 << 7);
- break;
- }
- }
- else
- {
- switch (ledId)
- {
- case 1:
- PORTD &= ~(1 << 6);
- break;
- case 2:
- PORTB &= ~(1 << 6);
- break;
- case 3:
- PORTF &= ~(1 << 5);
- break;
- case 4:
- PORTB &= ~(1 << 4);
- break;
- case 5:
- PORTC &= ~(1 << 7);
- break;
- case 6:
- PORTF &= ~(1 << 7);
- break;
- }
- }
-}
-
-void set_layer_led(int layerId)
-{
- // UNUSED
-}
-
-void led_set_layer(int layer);
-
-void matrix_init_user(void)
-{
- led_init_ports();
- led_set_layer(0);
-}
-
-void matrix_scan_user(void)
-{
-}
-
-// M6-A LEDs are connected to D6, B6, F5, B4, C7, F7
-void led_init_ports()
-{
- // Switch #1
- DDRD |= (1 << 6);
- PORTD &= ~(1 << 6);
-
- // Switch #2
- DDRB |= (1 << 6);
- PORTB &= ~(1 << 6);
-
- // Switch #3
- DDRF |= (1 << 5);
- PORTF &= ~(1 << 5);
-
- // Switch #4
- DDRB |= (1 << 4);
- PORTB &= ~(1 << 4);
-
- // Switch #5
- DDRC |= (1 << 7);
- PORTC &= ~(1 << 7);
-
- // Switch #6
- DDRF |= (1 << 7);
- PORTF &= ~(1 << 7);
-}
-
-void led_set_user(uint8_t usb_led)
-{
-
- if (usb_led & (1 << USB_LED_NUM_LOCK))
- {
- }
- else
- {
- }
-
- if (usb_led & (1 << USB_LED_CAPS_LOCK))
- {
- }
- else
- {
- }
-
- if (usb_led & (1 << USB_LED_SCROLL_LOCK))
- {
- }
- else
- {
- }
-
- if (usb_led & (1 << USB_LED_COMPOSE))
- {
- }
- else
- {
- }
-
- if (usb_led & (1 << USB_LED_KANA))
- {
- }
- else
- {
- }
-}
-
-void led_set_layer(int layer)
-{
- switch (layer)
- {
- case 0:
- set_switch_led(1, true);
- set_switch_led(2, false);
- set_switch_led(3, false);
- set_switch_led(4, false);
- set_switch_led(5, false);
- set_switch_led(6, false);
- break;
- case 1:
- set_switch_led(1, false);
- set_switch_led(2, true);
- set_switch_led(3, false);
- set_switch_led(4, false);
- set_switch_led(5, false);
- set_switch_led(6, false);
- break;
- case 2:
- set_switch_led(1, false);
- set_switch_led(2, false);
- set_switch_led(3, true);
- set_switch_led(4, false);
- set_switch_led(5, false);
- set_switch_led(6, false);
- break;
- case 3:
- set_switch_led(1, false);
- set_switch_led(2, false);
- set_switch_led(3, false);
- set_switch_led(4, true);
- set_switch_led(5, false);
- set_switch_led(6, false);
- break;
- case 4:
- set_switch_led(1, false);
- set_switch_led(2, false);
- set_switch_led(3, false);
- set_switch_led(4, false);
- set_switch_led(5, true);
- set_switch_led(6, false);
- break;
- case 5:
- set_switch_led(1, false);
- set_switch_led(2, false);
- set_switch_led(3, false);
- set_switch_led(4, false);
- set_switch_led(5, false);
- set_switch_led(6, true);
- break;
- default:
- set_switch_led(1, true);
- set_switch_led(2, true);
- set_switch_led(3, true);
- set_switch_led(4, true);
- set_switch_led(5, true);
- set_switch_led(6, true);
- break;
- }
-}
-
-bool process_record_user(uint16_t keycode, keyrecord_t *record)
-{
- switch (keycode)
- {
- case TO(0):
- if (record->event.pressed)
- {
- led_set_layer(0);
- }
- break;
- case TO(1):
- if (record->event.pressed)
- {
- led_set_layer(1);
- }
- break;
- case TO(2):
- if (record->event.pressed)
- {
- led_set_layer(2);
- }
- break;
- case TO(3):
- if (record->event.pressed)
- {
- led_set_layer(3);
- }
- break;
- case TO(4):
- if (record->event.pressed)
- {
- led_set_layer(4);
- }
- break;
- case TO(5):
- if (record->event.pressed)
- {
- led_set_layer(5);
- }
- break;
- }
- return true;
-}
diff --git a/keyboards/rama/m6_a/m6_a.c b/keyboards/rama/m6_a/m6_a.c
index 1c84ea2b83..fa19003600 100644
--- a/keyboards/rama/m6_a/m6_a.c
+++ b/keyboards/rama/m6_a/m6_a.c
@@ -1,4 +1,4 @@
-/* Copyright 2018 Wilba
+/* Copyright 2018 Jason Williams (Wilba)
*
* 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
@@ -13,32 +13,3 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-#include "m6_a.h"
-/*
-void matrix_init_kb(void) {
- // put your keyboard start-up code here
- // runs once when the firmware starts up
-
- matrix_init_user();
-}
-
-void matrix_scan_kb(void) {
- // put your looping keyboard code here
- // runs every cycle (a lot)
-
- matrix_scan_user();
-}
-
-bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
- // put your per-action keyboard code here
- // runs for every action, just before processing by the firmware
-
- return process_record_user(keycode, record);
-}
-
-void led_set_kb(uint8_t usb_led) {
- // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
-
- led_set_user(usb_led);
-}
-*/
diff --git a/keyboards/rama/m6_a/readme.md b/keyboards/rama/m6_a/readme.md
index 5dd2b92e19..ceaf6a88de 100644
--- a/keyboards/rama/m6_a/readme.md
+++ b/keyboards/rama/m6_a/readme.md
@@ -12,4 +12,4 @@ Make example for this keyboard (after setting up your build environment):
make rama/m6_a:default
-See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information.
\ No newline at end of file
+See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
\ No newline at end of file
diff --git a/keyboards/rama/m6_a/rules.mk b/keyboards/rama/m6_a/rules.mk
index ca2a2a5f80..ed85ac36d0 100644
--- a/keyboards/rama/m6_a/rules.mk
+++ b/keyboards/rama/m6_a/rules.mk
@@ -1,5 +1,7 @@
+# project specific files
+SRC = keyboards/rama/m6_b/m6_b.c
+
# MCU name
-#MCU = at90usb1286
MCU = atmega32u4
# Processor frequency.
@@ -38,31 +40,27 @@ F_USB = $(F_CPU)
# Interrupt driven control endpoint task(+60)
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
-
-# Boot Section Size in *bytes*
-# Teensy halfKay 512
-# Teensy++ halfKay 1024
-# Atmel DFU loader 4096
-# LUFA bootloader 4096
-# USBaspLoader 2048
-OPT_DEFS += -DBOOTLOADER_SIZE=4096
-
+# Boot Section
+BOOTLOADER = atmel-dfu
# Build Options
# change yes to no to disable
#
-BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000)
-MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700)
-EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450)
-CONSOLE_ENABLE ?= yes # Console for debug(+400)
-COMMAND_ENABLE ?= yes # Commands for debug and configuration
+BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE = no # Mouse keys(+4700)
+EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
+CONSOLE_ENABLE = no # Console for debug(+400)
+COMMAND_ENABLE = no # Commands for debug and configuration
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
-SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
-NKRO_ENABLE ?= no # USB Nkey Rollover
-BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality on B7 by default
-MIDI_ENABLE ?= no # MIDI support (+2400 to 4200, depending on config)
-UNICODE_ENABLE ?= no # Unicode
-BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID
-AUDIO_ENABLE ?= no # Audio output on port C6
-FAUXCLICKY_ENABLE ?= no # Use buzzer to emulate clicky switches
+NKRO_ENABLE = yes # USB Nkey Rollover
+BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default
+MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config)
+UNICODE_ENABLE = no # Unicode
+BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
+AUDIO_ENABLE = no # Audio output on port C6
+FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
+
+RAW_ENABLE = yes
+DYNAMIC_KEYMAP_ENABLE = yes
\ No newline at end of file
diff --git a/keyboards/rama/m6_b/config.h b/keyboards/rama/m6_b/config.h
new file mode 100644
index 0000000000..1adaad3f9e
--- /dev/null
+++ b/keyboards/rama/m6_b/config.h
@@ -0,0 +1,129 @@
+/* Copyright 2018 Jason Williams (Wilba)
+ *
+ * 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 .
+ */
+#pragma once
+
+#include "config_common.h"
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID 0x5241 // "RW"
+#define PRODUCT_ID 0x006B // 6-B
+#define DEVICE_VER 0x0001
+#define MANUFACTURER RAMA.WORKS
+#define PRODUCT RAMA M6-B
+#define DESCRIPTION RAMA M6-B Macropad
+
+/* key matrix size */
+#define MATRIX_ROWS 1
+#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)
+ *
+*/
+#define MATRIX_ROW_PINS { E6 }
+#define MATRIX_COL_PINS { D4, B5, F4, D7, C6, F6 }
+#define UNUSED_PINS
+
+/* COL2ROW, ROW2COL, or CUSTOM_MATRIX */
+#define DIODE_DIRECTION COL2ROW
+
+// #define BACKLIGHT_PIN B7
+// #define BACKLIGHT_BREATHING
+// #define BACKLIGHT_LEVELS 3
+
+
+/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
+#define DEBOUNCING_DELAY 5
+
+/* define if matrix has ghost (lacks anti-ghosting diodes) */
+//#define MATRIX_HAS_GHOST
+
+/* number of backlight levels */
+
+/* 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
+
+/* If defined, GRAVE_ESC will always act as ESC when CTRL is held.
+ * This is userful for the Windows task manager shortcut (ctrl+shift+esc).
+ */
+// #define GRAVE_ESC_CTRL_OVERRIDE
+
+/*
+ * 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
+
+/*
+ * Magic Key Options
+ *
+ * Magic keys are hotkey commands that allow control over firmware functions of
+ * the keyboard. They are best used in combination with the HID Listen program,
+ * found here: https://www.pjrc.com/teensy/hid_listen.html
+ *
+ * The options below allow the magic key functionality to be changed. This is
+ * useful if your keyboard/keypad is missing keys and you want magic key support.
+ *
+ */
+
+/* key combination for magic key command */
+#define IS_COMMAND() ( \
+ keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
+)
+
+#define RGB_BACKLIGHT_ENABLED 1
+
+#define DYNAMIC_KEYMAP_LAYER_COUNT 4
+
+
+// EEPROM usage
+
+// TODO: refactor with new user EEPROM code (coming soon)
+#define EEPROM_MAGIC 0x451F
+#define EEPROM_MAGIC_ADDR 32
+// 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_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
diff --git a/keyboards/rama/m6_b/info.json b/keyboards/rama/m6_b/info.json
new file mode 100644
index 0000000000..c88a3cc618
--- /dev/null
+++ b/keyboards/rama/m6_b/info.json
@@ -0,0 +1,19 @@
+{
+ "keyboard_name": "m6-b",
+ "url": "",
+ "maintainer": "qmk",
+ "width": 3,
+ "height": 2,
+ "layouts": {
+ "LAYOUT": {
+ "layout": [
+ { "x": 0, "y": 0 },
+ { "x": 1, "y": 0 },
+ { "x": 2, "y": 0 },
+ { "x": 0, "y": 1 },
+ { "x": 1, "y": 1 },
+ { "x": 2, "y": 1 }
+ ]
+ }
+ }
+}
diff --git a/keyboards/rama/m6_b/keymaps/default/keymap.c b/keyboards/rama/m6_b/keymaps/default/keymap.c
new file mode 100644
index 0000000000..7a408fa8aa
--- /dev/null
+++ b/keyboards/rama/m6_b/keymaps/default/keymap.c
@@ -0,0 +1,16 @@
+#include QMK_KEYBOARD_H
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+
+ LAYOUT(
+ KC_1, KC_2, KC_3, KC_4, KC_5, KC_6),
+
+ LAYOUT(
+ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO),
+
+ LAYOUT(
+ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO),
+
+ LAYOUT(
+ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO) };
+
diff --git a/keyboards/rama/m6_b/m6_b.c b/keyboards/rama/m6_b/m6_b.c
new file mode 100644
index 0000000000..e7cd2f6287
--- /dev/null
+++ b/keyboards/rama/m6_b/m6_b.c
@@ -0,0 +1,230 @@
+/* Copyright 2018 Jason Williams (Wilba)
+ *
+ * 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 .
+ */
+#include "m6_b.h"
+#include "m6_b_api.h"
+
+// Check that no backlight functions are called
+#if RGB_BACKLIGHT_ENABLED
+#include "rgb_backlight.h"
+#endif // RGB_BACKLIGHT_ENABLED
+
+#include "raw_hid.h"
+#include "dynamic_keymap.h"
+#include "timer.h"
+#include "tmk_core/common/eeprom.h"
+
+bool eeprom_is_valid(void)
+{
+ return (eeprom_read_word(((void*)EEPROM_MAGIC_ADDR)) == EEPROM_MAGIC &&
+ eeprom_read_byte(((void*)EEPROM_VERSION_ADDR)) == EEPROM_VERSION);
+}
+
+void eeprom_set_valid(bool valid)
+{
+ eeprom_update_word(((void*)EEPROM_MAGIC_ADDR), valid ? EEPROM_MAGIC : 0xFFFF);
+ eeprom_update_byte(((void*)EEPROM_VERSION_ADDR), valid ? EEPROM_VERSION : 0xFF);
+}
+
+void eeprom_reset(void)
+{
+ // Set the keyboard-specific EEPROM state as invalid.
+ eeprom_set_valid(false);
+ // Set the TMK/QMK EEPROM state as invalid.
+ eeconfig_disable();
+}
+
+#ifdef RAW_ENABLE
+
+void raw_hid_receive( uint8_t *data, uint8_t length )
+{
+ uint8_t *command_id = &(data[0]);
+ uint8_t *command_data = &(data[1]);
+ switch ( *command_id )
+ {
+ case id_get_protocol_version:
+ {
+ command_data[0] = PROTOCOL_VERSION >> 8;
+ command_data[1] = PROTOCOL_VERSION & 0xFF;
+ break;
+ }
+ case id_get_keyboard_value:
+ {
+ if ( command_data[0] == id_uptime )
+ {
+ uint32_t value = timer_read32();
+ command_data[1] = (value >> 24 ) & 0xFF;
+ command_data[2] = (value >> 16 ) & 0xFF;
+ command_data[3] = (value >> 8 ) & 0xFF;
+ command_data[4] = value & 0xFF;
+ }
+ else
+ {
+ *command_id = id_unhandled;
+ }
+ break;
+ }
+#ifdef DYNAMIC_KEYMAP_ENABLE
+ case id_dynamic_keymap_get_keycode:
+ {
+ uint16_t keycode = dynamic_keymap_get_keycode( command_data[0], command_data[1], command_data[2] );
+ command_data[3] = keycode >> 8;
+ command_data[4] = keycode & 0xFF;
+ break;
+ }
+ case id_dynamic_keymap_set_keycode:
+ {
+ dynamic_keymap_set_keycode( command_data[0], command_data[1], command_data[2], ( command_data[3] << 8 ) | command_data[4] );
+ break;
+ }
+ case id_dynamic_keymap_reset:
+ {
+ dynamic_keymap_reset();
+ break;
+ }
+#endif // DYNAMIC_KEYMAP_ENABLE
+#if RGB_BACKLIGHT_ENABLED
+ case id_backlight_config_set_value:
+ {
+ //backlight_config_set_value(command_data);
+ break;
+ }
+ case id_backlight_config_get_value:
+ {
+ //backlight_config_get_value(command_data);
+ break;
+ }
+ case id_backlight_config_save:
+ {
+ //backlight_config_save();
+ break;
+ }
+#endif // RGB_BACKLIGHT_ENABLED
+ case id_eeprom_reset:
+ {
+ eeprom_reset();
+ break;
+ }
+ case id_bootloader_jump:
+ {
+ // Need to send data back before the jump
+ // Informs host that the command is handled
+ raw_hid_send( data, length );
+ // Give host time to read it
+ wait_ms(100);
+ bootloader_jump();
+ break;
+ }
+ default:
+ {
+ // Unhandled message.
+ *command_id = id_unhandled;
+ break;
+ }
+ }
+
+ // Return same buffer with values changed
+ raw_hid_send( data, length );
+
+}
+
+#endif
+
+void main_init(void)
+{
+ // If the EEPROM has the magic, the data is good.
+ // OK to load from EEPROM.
+ if (eeprom_is_valid()) {
+#if RGB_BACKLIGHT_ENABLED
+ //backlight_config_load();
+#endif // RGB_BACKLIGHT_ENABLED
+ } else {
+#if RGB_BACKLIGHT_ENABLED
+ // If the EEPROM has not been saved before, or is out of date,
+ // save the default values to the EEPROM. Default values
+ // come from construction of the zeal_backlight_config instance.
+ //backlight_config_save();
+#endif // RGB_BACKLIGHT_ENABLED
+#ifdef DYNAMIC_KEYMAP_ENABLE
+ // This resets the keymaps in EEPROM to what is in flash.
+ dynamic_keymap_reset();
+#endif
+ // Save the magic number last, in case saving was interrupted
+ eeprom_set_valid(true);
+ }
+#if RGB_BACKLIGHT_ENABLED
+ // Initialize LED drivers for backlight.
+ backlight_init_drivers();
+
+ backlight_timer_init();
+ backlight_timer_enable();
+#endif // RGB_BACKLIGHT_ENABLED
+}
+
+void bootmagic_lite(void)
+{
+ // The lite version of TMK's bootmagic.
+ // 100% less potential for accidentally making the
+ // keyboard do stupid things.
+
+ // We need multiple scans because debouncing can't be turned off.
+ matrix_scan();
+ wait_ms(DEBOUNCING_DELAY);
+ wait_ms(DEBOUNCING_DELAY);
+ matrix_scan();
+
+ // If the Esc (matrix 0,0) is held down on power up,
+ // reset the EEPROM valid state and jump to bootloader.
+ if ( matrix_get_row(0) & (1<<0) ) {
+ eeprom_reset();
+ bootloader_jump();
+ }
+}
+
+void matrix_init_kb(void) {
+ bootmagic_lite();
+ main_init();
+ matrix_init_user();
+}
+
+void matrix_scan_kb(void) {
+#if RGB_BACKLIGHT_ENABLED
+ // This only updates the LED driver buffers if something has changed.
+ backlight_update_pwm_buffers();
+#endif // BACKLIGHT_ENABLED
+ matrix_scan_user();
+}
+
+bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
+ return process_record_user(keycode, record);
+}
+
+void led_set_kb(uint8_t usb_led) {
+ led_set_user(usb_led);
+}
+
+void suspend_power_down_kb(void)
+{
+#if RGB_BACKLIGHT_ENABLED
+ //backlight_set_suspend_state(true);
+#endif // BACKLIGHT_ENABLED
+}
+
+void suspend_wakeup_init_kb(void)
+{
+#if RGB_BACKLIGHT_ENABLED
+ //backlight_set_suspend_state(false);
+#endif // BACKLIGHT_ENABLED
+}
diff --git a/keyboards/rama/m6_b/m6_b.h b/keyboards/rama/m6_b/m6_b.h
new file mode 100644
index 0000000000..bd4158bcb1
--- /dev/null
+++ b/keyboards/rama/m6_b/m6_b.h
@@ -0,0 +1,28 @@
+/* Copyright 2018 Jason Williams (Wilba)
+ *
+ * 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 .
+ */
+#pragma once
+
+#include "quantum.h"
+
+// This a shortcut to help you visually see your layout.
+// The first section contains all of the arguments
+// The second converts the arguments into a two-dimensional array
+#define LAYOUT( \
+ K00, K01, K02, K03, K04, K05) \
+ { \
+ {K00, K01, K02, K03, K04, K05}, \
+ }
+
diff --git a/keyboards/rama/m6_b/m6_b_api.h b/keyboards/rama/m6_b/m6_b_api.h
new file mode 100644
index 0000000000..041fd6e6ee
--- /dev/null
+++ b/keyboards/rama/m6_b/m6_b_api.h
@@ -0,0 +1,39 @@
+/* Copyright 2017 Jason Williams (Wilba)
+ *
+ * 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 .
+ */
+#pragma once
+
+#define PROTOCOL_VERSION 0x0001
+
+enum m6_b_command_id
+{
+ id_get_protocol_version = 0x01, // always 0x01
+ id_get_keyboard_value,
+ id_set_keyboard_value,
+ id_dynamic_keymap_get_keycode,
+ id_dynamic_keymap_set_keycode,
+ id_dynamic_keymap_reset,
+ id_backlight_config_set_value,
+ id_backlight_config_get_value,
+ id_backlight_config_save,
+ id_eeprom_reset,
+ id_bootloader_jump,
+ id_unhandled = 0xFF,
+};
+
+enum m6_b_keyboard_value_id
+{
+ id_uptime = 0x01
+};
diff --git a/keyboards/rama/m6_b/readme.md b/keyboards/rama/m6_b/readme.md
new file mode 100644
index 0000000000..d6bdd0c4c2
--- /dev/null
+++ b/keyboards/rama/m6_b/readme.md
@@ -0,0 +1,15 @@
+# RAMA M6-B
+
+
+
+A 6-key companion keyboard. [More info at RAMA WORKS](https://rama.works/m6a)
+
+Keyboard Maintainer: [Wilba6582](https://github.com/Wilba6582)
+Hardware Supported: RAMA M6-B PCB
+Hardware Availability: [RAMA WORKS Store](https://ramaworks.store/)
+
+Make example for this keyboard (after setting up your build environment):
+
+ make rama/m6_b:default
+
+See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
\ No newline at end of file
diff --git a/keyboards/rama/m6_b/rgb_backlight.c b/keyboards/rama/m6_b/rgb_backlight.c
new file mode 100644
index 0000000000..8f7ac06303
--- /dev/null
+++ b/keyboards/rama/m6_b/rgb_backlight.c
@@ -0,0 +1,139 @@
+/* Copyright 2018 Jason Williams (Wilba)
+ *
+ * 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 .
+ */
+#if RGB_BACKLIGHT_ENABLED
+
+#include "rgb_backlight.h"
+//#include "rgb_backlight_api.h"
+
+#include
+#include
+#include
+#include "progmem.h"
+
+#include "quantum/color.h"
+#include "drivers/avr/i2c_master.h"
+#include "drivers/issi/is31fl3218.h"
+
+bool g_suspend_state = false;
+
+// Global tick at 20 Hz
+uint32_t g_tick = 0;
+uint8_t g_config_effect_speed = 0;
+uint8_t g_config_brightness = 255;
+
+void backlight_update_pwm_buffers(void)
+{
+ IS31FL3218_update_pwm_buffers();
+}
+
+void backlight_set_color( int index, uint8_t red, uint8_t green, uint8_t blue )
+{
+ IS31FL3218_set_color( index, red, green, blue );
+}
+
+void backlight_set_color_all( uint8_t red, uint8_t green, uint8_t blue )
+{
+ IS31FL3218_set_color_all( red, green, blue );
+}
+
+
+// This is (F_CPU/1024) / 20 Hz
+// = 15625 Hz / 20 Hz
+// = 781
+#define TIMER3_TOP 260
+
+void backlight_timer_init(void)
+{
+ static uint8_t backlight_timer_is_init = 0;
+ if ( backlight_timer_is_init )
+ {
+ return;
+ }
+ backlight_timer_is_init = 1;
+
+ // Timer 3 setup
+ TCCR3B = _BV(WGM32) | // CTC mode OCR3A as TOP
+ _BV(CS32) | _BV(CS30); // prescale by /1024
+ // Set TOP value
+ uint8_t sreg = SREG;
+ cli();
+
+ OCR3AH = (TIMER3_TOP >> 8) & 0xff;
+ OCR3AL = TIMER3_TOP & 0xff;
+ SREG = sreg;
+}
+
+void backlight_timer_enable(void)
+{
+ TIMSK3 |= _BV(OCIE3A);
+}
+
+void backlight_timer_disable(void)
+{
+ TIMSK3 &= ~_BV(OCIE3A);
+}
+
+void backlight_set_suspend_state(bool state)
+{
+ g_suspend_state = state;
+}
+
+void backlight_effect_cycle_all(void)
+{
+ uint8_t hueOffset = ( g_tick << g_config_effect_speed ) & 0xFF;
+ uint8_t satOffset = 127;
+ // Relies on hue being 8-bit and wrapping
+ for ( int i=0; i<6; i++ )
+ {
+ HSV hsv = { .h = hueOffset, .s = satOffset, .v = g_config_brightness };
+ RGB rgb = hsv_to_rgb( hsv );
+ backlight_set_color( i, rgb.r, rgb.g, rgb.b );
+ }
+}
+
+ISR(TIMER3_COMPA_vect)
+{
+ // delay 1 second before driving LEDs or doing anything else
+ static uint8_t startup_tick = 0;
+ if ( startup_tick < 20 )
+ {
+ startup_tick++;
+ return;
+ }
+
+ g_tick++;
+
+ if ( g_suspend_state )
+ {
+ backlight_set_color_all( 0, 0, 0 );
+ }
+ else
+ {
+ //HSV hsv = { .h = 240, .s = 255, .v = g_config_brightness };
+ //RGB rgb = hsv_to_rgb( hsv );
+ //backlight_set_color_all( rgb.r, rgb.g, rgb.b );
+ backlight_effect_cycle_all();
+ }
+}
+
+void backlight_init_drivers(void)
+{
+ // Initialize I2C
+ i2c_init();
+ IS31FL3218_init();
+}
+
+#endif // RGB_BACKLIGHT_ENABLED
diff --git a/keyboards/rama/m6_b/rgb_backlight.h b/keyboards/rama/m6_b/rgb_backlight.h
new file mode 100644
index 0000000000..bbf605284b
--- /dev/null
+++ b/keyboards/rama/m6_b/rgb_backlight.h
@@ -0,0 +1,34 @@
+/* Copyright 2018 Jason Williams (Wilba)
+ *
+ * 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 .
+ */
+#pragma once
+
+#if RGB_BACKLIGHT_ENABLED
+#else
+#error rgb_backlight.h included when RGB_BACKLIGHT_ENABLED == 0
+#endif // RGB_BACKLIGHT_ENABLED
+
+#include
+#include
+
+#include "quantum/color.h"
+
+void backlight_init_drivers(void);
+void backlight_update_pwm_buffers(void);
+void backlight_timer_init(void);
+void backlight_timer_enable(void);
+void backlight_timer_disable(void);
+void backlight_set_suspend_state(bool state);
+
diff --git a/keyboards/rama/m6_b/rules.mk b/keyboards/rama/m6_b/rules.mk
new file mode 100644
index 0000000000..8226debd45
--- /dev/null
+++ b/keyboards/rama/m6_b/rules.mk
@@ -0,0 +1,77 @@
+# project specific files
+SRC = rgb_backlight.c \
+ quantum/color.c \
+ drivers/issi/is31fl3218.c \
+ drivers/avr/i2c_master.c
+
+
+# MCU name
+MCU = atmega32u4
+
+# Processor frequency.
+# This will define a symbol, F_CPU, in all source code files equal to the
+# processor frequency in Hz. You can then use this symbol in your source code to
+# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+# automatically to create a 32-bit value in your source code.
+#
+# This will be an integer division of F_USB below, as it is sourced by
+# F_USB after it has run through any CPU prescalers. Note that this value
+# does not *change* the processor frequency - it should merely be updated to
+# reflect the processor speed set externally so that the code can use accurate
+# software delays.
+F_CPU = 16000000
+
+
+#
+# LUFA specific
+#
+# Target architecture (see library "Board Types" documentation).
+ARCH = AVR8
+
+# Input clock frequency.
+# This will define a symbol, F_USB, in all source code files equal to the
+# input clock frequency (before any prescaling is performed) in Hz. This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_USB = $(F_CPU)
+
+# Interrupt driven control endpoint task(+60)
+OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
+
+# Boot Section
+BOOTLOADER = atmel-dfu
+
+# Do not put the microcontroller into power saving mode
+# when we get USB suspend event. We want it to keep updating
+# backlight effects.
+OPT_DEFS += -DNO_SUSPEND_POWER_DOWN
+
+
+# Build Options
+# change yes to no to disable
+#
+BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE = no # Mouse keys(+4700)
+EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
+CONSOLE_ENABLE = no # Console for debug(+400)
+COMMAND_ENABLE = no # Commands for debug and configuration
+# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
+# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+NKRO_ENABLE = yes # USB Nkey Rollover
+BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default
+MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config)
+UNICODE_ENABLE = no # Unicode
+BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
+AUDIO_ENABLE = no # Audio output on port C6
+FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
+
+RAW_ENABLE = yes
+DYNAMIC_KEYMAP_ENABLE = yes
+CIE1931_CURVE = yes
diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c
index 2c989d6918..ee39a20251 100644
--- a/quantum/dynamic_keymap.c
+++ b/quantum/dynamic_keymap.c
@@ -17,7 +17,7 @@
#include "config.h"
#include "keymap.h" // to get keymaps[][][]
#include "tmk_core/common/eeprom.h"
-#include "progmem.h"// to read default from flash
+#include "progmem.h" // to read default from flash
#include "dynamic_keymap.h"
--
cgit v1.2.3
From d7f1e072a859d7fcbaccd675b4bad7d02d214e52 Mon Sep 17 00:00:00 2001
From: Wilba
Date: Sat, 1 Dec 2018 03:43:34 +1100
Subject: Added macros to Dynamic Keymaps, Zeal60 RGB backlight improvements
(#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
---
keyboards/rama/m60_a/config.h | 13 ++--
keyboards/rama/m60_a/rules.mk | 4 +-
keyboards/rama/m6_a/config.h | 14 +++-
keyboards/rama/m6_a/rules.mk | 2 +-
keyboards/rama/m6_b/config.h | 11 ++-
keyboards/rama/m6_b/rules.mk | 4 +-
keyboards/rama/u80_a/config.h | 10 ++-
keyboards/wilba_tech/wt60_a/config.h | 12 +--
keyboards/wilba_tech/wt65_a/config.h | 12 +--
keyboards/wilba_tech/wt80_a/config.h | 12 +--
keyboards/wilba_tech/wt_main.c | 92 ++++++++++++++++++++--
keyboards/zeal60/config.h | 10 ++-
keyboards/zeal60/rgb_backlight.c | 131 ++++++++++++++++++++++++++-----
keyboards/zeal60/rgb_backlight.h | 25 ++++--
keyboards/zeal60/rgb_backlight_api.h | 3 +-
keyboards/zeal60/zeal60.c | 88 +++++++++++++++------
keyboards/zeal60/zeal60_api.h | 10 ++-
keyboards/zeal60/zeal60_keycodes.h | 18 ++++-
keyboards/zeal65/config.h | 10 ++-
keyboards/zeal65/rules.mk | 4 +-
quantum/dynamic_keymap.c | 147 ++++++++++++++++++++++++++++++++++-
quantum/dynamic_keymap.h | 35 +++++++++
22 files changed, 561 insertions(+), 106 deletions(-)
(limited to 'quantum/dynamic_keymap.c')
diff --git a/keyboards/rama/m60_a/config.h b/keyboards/rama/m60_a/config.h
index 03794965fc..01cfe05a5f 100644
--- a/keyboards/rama/m60_a/config.h
+++ b/keyboards/rama/m60_a/config.h
@@ -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
@@ -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
diff --git a/keyboards/rama/m60_a/rules.mk b/keyboards/rama/m60_a/rules.mk
index 9c1a2d9df7..09ed03e951 100644
--- a/keyboards/rama/m60_a/rules.mk
+++ b/keyboards/rama/m60_a/rules.mk
@@ -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
diff --git a/keyboards/rama/m6_a/config.h b/keyboards/rama/m6_a/config.h
index 63da792745..049749bd7d 100644
--- a/keyboards/rama/m6_a/config.h
+++ b/keyboards/rama/m6_a/config.h
@@ -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
diff --git a/keyboards/rama/m6_a/rules.mk b/keyboards/rama/m6_a/rules.mk
index ff17069182..399e9e80d6 100644
--- a/keyboards/rama/m6_a/rules.mk
+++ b/keyboards/rama/m6_a/rules.mk
@@ -1,5 +1,5 @@
# project specific files
-SRC = ../zeal60/zeal60.c
+SRC = keyboards/zeal60/zeal60.c
# MCU name
MCU = atmega32u4
diff --git a/keyboards/rama/m6_b/config.h b/keyboards/rama/m6_b/config.h
index c016703e04..67034ef8ce 100644
--- a/keyboards/rama/m6_b/config.h
+++ b/keyboards/rama/m6_b/config.h
@@ -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
diff --git a/keyboards/rama/m6_b/rules.mk b/keyboards/rama/m6_b/rules.mk
index 1a7466af37..b7a76b8ddd 100644
--- a/keyboards/rama/m6_b/rules.mk
+++ b/keyboards/rama/m6_b/rules.mk
@@ -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
diff --git a/keyboards/rama/u80_a/config.h b/keyboards/rama/u80_a/config.h
index 9c74735ad5..b5dc27598a 100644
--- a/keyboards/rama/u80_a/config.h
+++ b/keyboards/rama/u80_a/config.h
@@ -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
diff --git a/keyboards/wilba_tech/wt60_a/config.h b/keyboards/wilba_tech/wt60_a/config.h
index 26f9ed2ba4..8c18582a88 100644
--- a/keyboards/wilba_tech/wt60_a/config.h
+++ b/keyboards/wilba_tech/wt60_a/config.h
@@ -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
diff --git a/keyboards/wilba_tech/wt65_a/config.h b/keyboards/wilba_tech/wt65_a/config.h
index 5f535c6a79..88e9023539 100644
--- a/keyboards/wilba_tech/wt65_a/config.h
+++ b/keyboards/wilba_tech/wt65_a/config.h
@@ -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
diff --git a/keyboards/wilba_tech/wt80_a/config.h b/keyboards/wilba_tech/wt80_a/config.h
index f78ce7fb34..ca03c366e9 100644
--- a/keyboards/wilba_tech/wt80_a/config.h
+++ b/keyboards/wilba_tech/wt80_a/config.h
@@ -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
diff --git a/keyboards/wilba_tech/wt_main.c b/keyboards/wilba_tech/wt_main.c
index 23f07d7eb1..de6d7b92c1 100644
--- a/keyboards/wilba_tech/wt_main.c
+++ b/keyboards/wilba_tech/wt_main.c
@@ -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"
@@ -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();
@@ -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);
@@ -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);
+}
diff --git a/keyboards/zeal60/config.h b/keyboards/zeal60/config.h
index baa4978a83..d1bd3f6a1a 100644
--- a/keyboards/zeal60/config.h
+++ b/keyboards/zeal60/config.h
@@ -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
diff --git a/keyboards/zeal60/rgb_backlight.c b/keyboards/zeal60/rgb_backlight.c
index c3dade123c..64b95059e1 100644
--- a/keyboards/zeal60/rgb_backlight.c
+++ b/keyboards/zeal60/rgb_backlight.c
@@ -15,9 +15,9 @@
*/
#if RGB_BACKLIGHT_ENABLED
-#if defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_ZEAL65) || defined (RGB_BACKLIGHT_M60_A) || defined(RGB_BACKLIGHT_M6_B)
+#if defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_ZEAL65) || defined (RGB_BACKLIGHT_M60_A) || defined(RGB_BACKLIGHT_M6_B) || defined(RGB_BACKLIGHT_KOYU)
#else
-#error None of the following was defined: RGB_BACKLIGHT_ZEAL60, RGB_BACKLIGHT_ZEAL65, RGB_BACKLIGHT_M60_A, RGB_BACKLIGHT_M6_B
+#error None of the following was defined: RGB_BACKLIGHT_ZEAL60, RGB_BACKLIGHT_ZEAL65, RGB_BACKLIGHT_M60_A, RGB_BACKLIGHT_M6_B, RGB_BACKLIGHT_KOYU
#endif
#include "quantum.h"
@@ -55,18 +55,21 @@ backlight_config g_config = {
.brightness = 255,
.effect = RGB_BACKLIGHT_EFFECT,
.effect_speed = 0,
- .color_1 = { .h = 0, .s = 255, .v = 255 },
- .color_2 = { .h = 127, .s = 255, .v = 255 },
- .caps_lock_indicator = { .color = { .h = 0, .s = 0, .v = 255 }, .index = 255 },
- .layer_1_indicator = { .color = { .h = 0, .s = 0, .v = 255 }, .index = 255 },
- .layer_2_indicator = { .color = { .h = 0, .s = 0, .v = 255 }, .index = 255 },
- .layer_3_indicator = { .color = { .h = 0, .s = 0, .v = 255 }, .index = 255 },
+ .color_1 = { .h = 0, .s = 255 },
+ .color_2 = { .h = 127, .s = 255 },
+ .caps_lock_indicator = { .color = { .h = 0, .s = 0 }, .index = 255 },
+ .layer_1_indicator = { .color = { .h = 0, .s = 0 }, .index = 255 },
+ .layer_2_indicator = { .color = { .h = 0, .s = 0 }, .index = 255 },
+ .layer_3_indicator = { .color = { .h = 0, .s = 0 }, .index = 255 },
.alphas_mods = {
RGB_BACKLIGHT_ALPHAS_MODS_ROW_0,
RGB_BACKLIGHT_ALPHAS_MODS_ROW_1,
RGB_BACKLIGHT_ALPHAS_MODS_ROW_2,
RGB_BACKLIGHT_ALPHAS_MODS_ROW_3,
- RGB_BACKLIGHT_ALPHAS_MODS_ROW_4 }
+ RGB_BACKLIGHT_ALPHAS_MODS_ROW_4 },
+#if defined(RGB_BACKLIGHT_M6_B)
+ .custom_color = { { 0, 255 }, { 43, 255 }, { 85, 255 }, { 128, 255 }, { 171, 255 }, { 213, 255 } }
+#endif
};
bool g_suspend_state = false;
@@ -199,7 +202,7 @@ const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
};
const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
// LA0..LA17
- {64,128}, {75,132}, {84,145}, {91,164}, {97,187}, {102,213}, {105,242}, {109,255}, {128,247},
+ {64,128}, {75,132}, {84,145}, {91,164}, {97,187}, {102,213}, {105,242}, {109,255}, {128,243},
{61,255}, {67,255}, {72,255}, {77,255}, {82,255}, {86,255}, {90,255}, {93,255}, {96,255},
// LB0..LB17
{56,255}, {51,255}, {46,255}, {42,255}, {37,255}, {35,255}, {32,255}, {19,255}, {0,255},
@@ -208,8 +211,37 @@ const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
{184,255}, {179,135}, {170,149}, {163,169}, {157,193}, {153,220}, {255,255}, {167,255}, {165,255},
{128,26}, {128,60}, {128,94}, {128,128}, {128,162}, {128,196}, {145,233}, {148,255}, {161,255},
// LD0..LD17
- {0,9}, {0,43}, {0,77}, {0,111}, {0,145}, {255,201}, {224,181}, {230,217}, {235,255},
- {189,128}, {200,131}, {210,141}, {218,159}, {201,228}, {201,228}, {206,255}, {213,255}, {218,255}
+ {0,9}, {0,43}, {0,77}, {0,111}, {0,145}, {0,201}, {224,181}, {230,217}, {235,255},
+ {189,128}, {200,131}, {210,141}, {218,159}, {255,255}, {201,228}, {206,255}, {213,255}, {218,255}
+};
+#elif defined (RGB_BACKLIGHT_KOYU)
+const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA0..LA17
+ {120,16}, {104,16}, {88,16}, {72,16}, {56,16}, {40,16}, {24,16}, {4,16}, {4,32},
+ {128,0}, {112,0}, {96,0}, {80,0}, {64,0}, {48,0}, {32,0}, {16,0}, {0,0},
+ // LB0..LB17
+ {144,0}, {160,0}, {176,0}, {192,0}, {208,0}, {224,0}, {240,0}, {240,16}, {240,32},
+ {136,16}, {152,16}, {168,16}, {184,16}, {200,16}, {220,16}, {240,48}, {240,64}, {224,64},
+ // LC0..LC17
+ {112,64}, {100,48}, {84,48}, {68,48}, {52,48}, {36,48}, {64,60}, {44,60}, {24,64},
+ {108,32}, {92,32}, {76,32}, {60,32}, {44,32}, {28,32}, {255,255}, {10,48}, {4,64},
+ // LD0..LD17
+ {124,32}, {140,32}, {156,32}, {172,32}, {188,32}, {214,32}, {180,48}, {202,48}, {224,48},
+ {116,48}, {132,48}, {148,48}, {164,48}, {255,255}, {160,60}, {180,64}, {208,64}, {255,255}
+};
+const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA0..LA17
+ {64,128}, {75,132}, {84,145}, {91,164}, {97,187}, {102,213}, {105,242}, {109,255}, {128,243},
+ {61,255}, {67,255}, {72,255}, {77,255}, {82,255}, {86,255}, {90,255}, {93,255}, {96,255},
+ // LB0..LB17
+ {56,255}, {51,255}, {46,255}, {42,255}, {38,255}, {35,255}, {32,255}, {19,255}, {0,255},
+ {53,132}, {44,145}, {37,164}, {31,187}, {26,213}, {22,249}, {237,255}, {224,255}, {221,255},
+ // LC0..LC17
+ {189,255}, {179,135}, {170,149}, {163,169}, {157,193}, {153,220}, {172,252}, {169,255}, {165,255},
+ {128,26}, {128,60}, {128,94}, {128,128}, {128,162}, {128,196}, {255,255}, {148,255}, {161,255},
+ // LD0..LD17
+ {0,9}, {0,43}, {0,77}, {0,111}, {0,145}, {0,201}, {224,181}, {230,217}, {235,255},
+ {189,128}, {200,131}, {210,141}, {218,159}, {255,255}, {207,238}, {211,255}, {218,255}, {255,255}
};
#elif defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_M60_A)
const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
@@ -248,7 +280,7 @@ const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
{0,0}, {0,16}, {16,16}, {16,0}, {32,16}, {32,0}
};
const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
- {0,0}, {0,16}, {16,16}, {16,0}, {32,16}, {32,0}
+ {160,255}, {96,255}, {77,255}, {179,255}, {51,255}, {205,255}
};
#endif
@@ -318,7 +350,7 @@ void map_led_to_point_polar( uint8_t index, Point *point )
#if defined (RGB_BACKLIGHT_ZEAL65)
-// Note: Left spacebar stab is at 4,3 (LC7)
+// Note: Left spacebar stab is at 4,2 (LC7)
// Right spacebar stab is at 4,9 (D14)
//
// A17, A16, A15, A14, A13, A12, A11, A10, A9, B0, B1, B2, B3, B4, B6
@@ -333,6 +365,22 @@ const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
{ 36+16, 36+15, 36+5, 36+4, 36+3, 36+2, 36+1, 54+9, 54+10, 54+11, 54+12, 54+6, 54+7, 54+8, 18+15 },
{ 36+17, 36+8, 36+7, 255, 255, 255, 255, 36+0, 255, 54+14, 54+15, 54+16, 54+17, 18+17, 18+16 }
};
+#elif defined(RGB_BACKLIGHT_KOYU)
+// Note: Left spacebar stab is at 4,4 (LC6)
+// Right spacebar stab is at 4,10 (D14)
+//
+// A17, A16, A15, A14, A13, A12, A11, A10, A9, B0, B1, B2, B3, B4, B6
+// A7, A6, A5, A4, A3, A2, A1, A0, B9, B10, B11, B12, B13, B14, B7
+// A8, C14, C13, C12, C11, C10, C9, D0, D1, D2, D3, D4, D5, B5, B8
+// C16, C15, C5, C4, C3, C2, C1, D9, D10, D11, D12, D6, D7, D8, B15
+// C17, C8, C7, C6, ---, ---, ---, C0, ---, ---, D14, D15, D16, B17, B16
+const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+ { 0+17, 0+16, 0+15, 0+14, 0+13, 0+12, 0+11, 0+10, 0+9, 18+0, 18+1, 18+2, 18+3, 18+4, 18+6 },
+ { 0+7, 0+6, 0+5, 0+4, 0+3, 0+2, 0+1, 0+0, 18+9, 18+10, 18+11, 18+12, 18+13, 18+14, 18+7 },
+ { 0+8, 36+14, 36+13, 36+12, 36+11, 36+10, 36+9, 54+0, 54+1, 54+2, 54+3, 54+4, 54+5, 18+5, 18+8 },
+ { 36+16, 36+15, 36+5, 36+4, 36+3, 36+2, 36+1, 54+9, 54+10, 54+11, 54+12, 54+6, 54+7, 54+8, 18+15 },
+ { 36+17, 36+8, 36+7, 36+6, 255, 255, 255, 36+0, 255, 255, 54+14, 54+15, 54+16, 18+17, 18+16 }
+};
#elif defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_M60_A)
// Note: Left spacebar stab is at 4,3 (LC6)
// Right spacebar stab is at 4,9 (LD13) or 4,10 (LD14)
@@ -781,8 +829,24 @@ void backlight_effect_cycle_radial2(void)
}
}
-void backlight_effect_indicators_set_colors( uint8_t index, HSV hsv )
+#if defined(RGB_BACKLIGHT_M6_B)
+void backlight_effect_custom_colors(void)
{
+ RGB rgb;
+ for ( uint8_t i = 0; i < 6; i++ )
+ {
+ HSV hsv = { .h = g_config.custom_color[i].h, .s = g_config.custom_color[i].s, .v = g_config.brightness };
+ rgb = hsv_to_rgb( hsv );
+ uint8_t led;
+ map_row_column_to_led( 0, i, &led );
+ backlight_set_color( led, rgb.r, rgb.g, rgb.b );
+ }
+}
+#endif
+
+void backlight_effect_indicators_set_colors( uint8_t index, HS color )
+{
+ HSV hsv = { .h = color.h, .s = color.s, .v = g_config.brightness };
RGB rgb = hsv_to_rgb( hsv );
if ( index == 254 )
{
@@ -799,6 +863,9 @@ void backlight_effect_indicators_set_colors( uint8_t index, HSV hsv )
#if defined (RGB_BACKLIGHT_ZEAL65)
backlight_set_color( 36+7, rgb.r, rgb.g, rgb.b ); // LC7
backlight_set_color( 54+14, rgb.r, rgb.g, rgb.b ); // LD14
+#elif defined (RGB_BACKLIGHT_KOYU)
+ backlight_set_color( 36+6, rgb.r, rgb.g, rgb.b ); // LC6
+ backlight_set_color( 54+14, rgb.r, rgb.g, rgb.b ); // LD14
#elif defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_M60_A)
backlight_set_color( 36+6, rgb.r, rgb.g, rgb.b ); // LC6
backlight_set_color( 54+13, rgb.r, rgb.g, rgb.b ); // LD13
@@ -911,7 +978,11 @@ ISR(TIMER3_COMPA_vect)
backlight_effect_solid_color();
break;
case 2:
+#if defined(RGB_BACKLIGHT_M6_B)
+ backlight_effect_custom_colors();
+#else
backlight_effect_alphas_mods();
+#endif
break;
case 3:
backlight_effect_gradient_up_down();
@@ -989,18 +1060,16 @@ void backlight_get_indicator_row_col( uint8_t index, uint8_t *row, uint8_t *colu
}
// Some helpers for setting/getting HSV
-void _set_color( HSV *color, uint8_t *data )
+void _set_color( HS *color, uint8_t *data )
{
color->h = data[0];
color->s = data[1];
- color->v = data[2];
}
-void _get_color( HSV *color, uint8_t *data )
+void _get_color( HS *color, uint8_t *data )
{
data[0] = color->h;
data[1] = color->s;
- data[2] = color->v;
}
void backlight_config_set_value( uint8_t *data )
@@ -1132,6 +1201,16 @@ void backlight_config_set_value( uint8_t *data )
g_config.alphas_mods[i] = ( *(value_data+i*2) << 8 ) | ( *(value_data+i*2+1) );
}
}
+#if defined(RGB_BACKLIGHT_M6_B)
+ case id_custom_color:
+ {
+ uint8_t index = value_data[0];
+ if ( index >= 0 && index <= 6 )
+ {
+ _set_color( &(g_config.custom_color[index]), &(value_data[1]) );
+ }
+ }
+#endif
}
if ( reinitialize )
@@ -1259,6 +1338,16 @@ void backlight_config_get_value( uint8_t *data )
*(value_data+i*2+1) = g_config.alphas_mods[i] & 0xFF;
}
}
+#if defined(RGB_BACKLIGHT_M6_B)
+ case id_custom_color:
+ {
+ uint8_t index = value_data[0];
+ if ( index >= 0 && index <= 6 )
+ {
+ _get_color( &(g_config.custom_color[index]), &(value_data[1]) );
+ }
+ }
+#endif
}
}
@@ -1301,6 +1390,10 @@ void backlight_init_drivers(void)
bool enabled = !( ( index == 18+5 && !g_config.use_split_backspace ) || // LB5
( index == 36+6 ) || // LC6
( index == 54+13 ) ); // LD13
+#elif defined (RGB_BACKLIGHT_KOYU)
+ bool enabled = !( ( index == 36+15 ) || // LC15
+ ( index == 54+13 ) || // LD13
+ ( index == 54+17 ) ); // LD17
#elif defined (RGB_BACKLIGHT_M60_A)
bool enabled = !(
// LB6 LB7 LB8 LB15 LB16 LB17 not present on M60-A
diff --git a/keyboards/zeal60/rgb_backlight.h b/keyboards/zeal60/rgb_backlight.h
index 60f2ace51a..aa24e3491d 100644
--- a/keyboards/zeal60/rgb_backlight.h
+++ b/keyboards/zeal60/rgb_backlight.h
@@ -25,9 +25,15 @@
#include "quantum/color.h"
+typedef struct PACKED
+{
+ uint8_t h;
+ uint8_t s;
+} HS;
+
typedef struct
{
- HSV color;
+ HS color;
uint8_t index;
} backlight_config_indicator;
@@ -45,14 +51,17 @@ typedef struct
uint8_t brightness; // 1 byte
uint8_t effect; // 1 byte
uint8_t effect_speed; // 1 byte
- HSV color_1; // 3 bytes
- HSV color_2; // 3 bytes
- backlight_config_indicator caps_lock_indicator; // 4 bytes
- backlight_config_indicator layer_1_indicator; // 4 bytes
- backlight_config_indicator layer_2_indicator; // 4 bytes
- backlight_config_indicator layer_3_indicator; // 4 bytes
+ HS color_1; // 2 bytes
+ HS color_2; // 2 bytes
+ backlight_config_indicator caps_lock_indicator; // 3 bytes
+ backlight_config_indicator layer_1_indicator; // 3 bytes
+ backlight_config_indicator layer_2_indicator; // 3 bytes
+ backlight_config_indicator layer_3_indicator; // 3 bytes
uint16_t alphas_mods[5]; // 10 bytes
-} backlight_config; // = 37 bytes
+#if defined(RGB_BACKLIGHT_M6_B)
+ HS custom_color[6]; // 12 bytes
+#endif
+} backlight_config; // = 31 bytes (M6-B = 43 bytes)
void backlight_config_load(void);
void backlight_config_save(void);
diff --git a/keyboards/zeal60/rgb_backlight_api.h b/keyboards/zeal60/rgb_backlight_api.h
index 01827e849f..680ba4d99c 100644
--- a/keyboards/zeal60/rgb_backlight_api.h
+++ b/keyboards/zeal60/rgb_backlight_api.h
@@ -38,5 +38,6 @@ enum backlight_config_value
id_layer_2_indicator_row_col = 0x13,
id_layer_3_indicator_color = 0x14,
id_layer_3_indicator_row_col = 0x15,
- id_alphas_mods = 0x16
+ id_alphas_mods = 0x16,
+ id_custom_color = 0x17
};
diff --git a/keyboards/zeal60/zeal60.c b/keyboards/zeal60/zeal60.c
index b3b5d03fd0..5f93c571ad 100644
--- a/keyboards/zeal60/zeal60.c
+++ b/keyboards/zeal60/zeal60.c
@@ -94,6 +94,56 @@ void raw_hid_receive( uint8_t *data, uint8_t length )
dynamic_keymap_reset();
break;
}
+ 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:
+ {
+ command_data[0] = dynamic_keymap_get_layer_count();
+ break;
+ }
+ case id_dynamic_keymap_get_buffer:
+ {
+ 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_dynamic_keymap_set_buffer:
+ {
+ 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
#if RGB_BACKLIGHT_ENABLED
case id_backlight_config_set_value:
@@ -160,6 +210,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);
@@ -238,7 +290,19 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record)
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);
}
@@ -263,28 +327,6 @@ uint16_t keymap_function_id_to_action( uint16_t function_id )
}
}
-#if USE_KEYMAPS_IN_EEPROM
-
-#if 0
- // This is how to implement actions stored in EEPROM.
- // Not yet implemented. Not sure if it's worth the trouble
- // before we have a nice GUI for keymap editing.
- if ( eeprom_is_valid() &&
- function_id < 32 ) // TODO: replace magic number
- {
- uint16_t action = keymap_action_load(function_id);
-
- // If action is not "empty", return it, otherwise
- // drop down to return the one in flash
- if ( action != 0x0000 ) // TODO: replace magic number
- {
- return action;
- }
- }
-#endif
-
-#endif // USE_KEYMAPS_IN_EEPROM
-
return pgm_read_word(&fn_actions[function_id]);
}
diff --git a/keyboards/zeal60/zeal60_api.h b/keyboards/zeal60/zeal60_api.h
index a65bf2f509..8061146fde 100644
--- a/keyboards/zeal60/zeal60_api.h
+++ b/keyboards/zeal60/zeal60_api.h
@@ -15,7 +15,7 @@
*/
#pragma once
-#define PROTOCOL_VERSION 0x0007
+#define PROTOCOL_VERSION 0x0008
enum zeal60_command_id
{
@@ -30,6 +30,14 @@ enum zeal60_command_id
id_backlight_config_save,
id_eeprom_reset,
id_bootloader_jump,
+ id_dynamic_keymap_macro_get_count,
+ id_dynamic_keymap_macro_get_buffer_size,
+ id_dynamic_keymap_macro_get_buffer,
+ id_dynamic_keymap_macro_set_buffer,
+ id_dynamic_keymap_macro_reset,
+ id_dynamic_keymap_get_layer_count,
+ id_dynamic_keymap_get_buffer,
+ id_dynamic_keymap_set_buffer,
id_unhandled = 0xFF,
};
diff --git a/keyboards/zeal60/zeal60_keycodes.h b/keyboards/zeal60/zeal60_keycodes.h
index 9511801eb2..d9abf602b6 100644
--- a/keyboards/zeal60/zeal60_keycodes.h
+++ b/keyboards/zeal60/zeal60_keycodes.h
@@ -22,7 +22,23 @@
// Backlight keycodes are in range 0x5F00-0x5F0F
enum zeal60_keycodes {
FN_MO13 = 0x5F10,
- FN_MO23
+ FN_MO23,
+ MACRO00,
+ MACRO01,
+ MACRO02,
+ MACRO03,
+ MACRO04,
+ MACRO05,
+ MACRO06,
+ MACRO07,
+ MACRO08,
+ MACRO09,
+ MACRO10,
+ MACRO11,
+ MACRO12,
+ MACRO13,
+ MACRO14,
+ MACRO15,
};
// Zeal60 specific "action functions"
diff --git a/keyboards/zeal65/config.h b/keyboards/zeal65/config.h
index 683df2038a..63ce1c12a2 100644
--- a/keyboards/zeal65/config.h
+++ b/keyboards/zeal65/config.h
@@ -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*15*2)) = (66+600)
+#define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 666
+#define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 358
+#define DYNAMIC_KEYMAP_MACRO_COUNT 16
diff --git a/keyboards/zeal65/rules.mk b/keyboards/zeal65/rules.mk
index 7ab1b7d3ba..596c1e6496 100644
--- a/keyboards/zeal65/rules.mk
+++ b/keyboards/zeal65/rules.mk
@@ -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
diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c
index ee39a20251..14627a93d6 100644
--- a/quantum/dynamic_keymap.c
+++ b/quantum/dynamic_keymap.c
@@ -18,7 +18,7 @@
#include "keymap.h" // to get keymaps[][][]
#include "tmk_core/common/eeprom.h"
#include "progmem.h" // to read default from flash
-
+#include "quantum.h" // for send_string()
#include "dynamic_keymap.h"
#ifdef DYNAMIC_KEYMAP_ENABLE
@@ -31,6 +31,23 @@
#error DYNAMIC_KEYMAP_LAYER_COUNT not defined
#endif
+#ifndef DYNAMIC_KEYMAP_MACRO_COUNT
+#error DYNAMIC_KEYMAP_MACRO_COUNT not defined
+#endif
+
+#ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR
+#error DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR not defined
+#endif
+
+#ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE
+#error DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE not defined
+#endif
+
+uint8_t dynamic_keymap_get_layer_count(void)
+{
+ return DYNAMIC_KEYMAP_LAYER_COUNT;
+}
+
void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column)
{
// TODO: optimize this with some left shifts
@@ -69,6 +86,36 @@ void dynamic_keymap_reset(void)
}
}
+void dynamic_keymap_get_buffer( uint16_t offset, uint16_t size, uint8_t *data )
+{
+ uint16_t dynamic_keymap_eeprom_size = DYNAMIC_KEYMAP_LAYER_COUNT * MATRIX_ROWS * MATRIX_COLS * 2;
+ void *source = (void*)(DYNAMIC_KEYMAP_EEPROM_ADDR+offset);
+ uint8_t *target = data;
+ for ( uint16_t i = 0; i < size; i++ ) {
+ if ( offset + i < dynamic_keymap_eeprom_size ) {
+ *target = eeprom_read_byte(source);
+ } else {
+ *target = 0x00;
+ }
+ source++;
+ target++;
+ }
+}
+
+void dynamic_keymap_set_buffer( uint16_t offset, uint16_t size, uint8_t *data )
+{
+ uint16_t dynamic_keymap_eeprom_size = DYNAMIC_KEYMAP_LAYER_COUNT * MATRIX_ROWS * MATRIX_COLS * 2;
+ void *target = (void*)(DYNAMIC_KEYMAP_EEPROM_ADDR+offset);
+ uint8_t *source = data;
+ for ( uint16_t i = 0; i < size; i++ ) {
+ if ( offset + i < dynamic_keymap_eeprom_size ) {
+ eeprom_update_byte(target, *source);
+ }
+ source++;
+ target++;
+ }
+}
+
// This overrides the one in quantum/keymap_common.c
uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
{
@@ -81,5 +128,103 @@ uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
}
}
+
+
+uint8_t dynamic_keymap_macro_get_count(void)
+{
+ return DYNAMIC_KEYMAP_MACRO_COUNT;
+}
+
+uint16_t dynamic_keymap_macro_get_buffer_size(void)
+{
+ return DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE;
+}
+
+void dynamic_keymap_macro_get_buffer( uint16_t offset, uint16_t size, uint8_t *data )
+{
+ void *source = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR+offset);
+ uint8_t *target = data;
+ for ( uint16_t i = 0; i < size; i++ ) {
+ if ( offset + i < DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE ) {
+ *target = eeprom_read_byte(source);
+ } else {
+ *target = 0x00;
+ }
+ source++;
+ target++;
+ }
+}
+
+void dynamic_keymap_macro_set_buffer( uint16_t offset, uint16_t size, uint8_t *data )
+{
+ void *target = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR+offset);
+ uint8_t *source = data;
+ for ( uint16_t i = 0; i < size; i++ ) {
+ if ( offset + i < DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE ) {
+ eeprom_update_byte(target, *source);
+ }
+ source++;
+ target++;
+ }
+}
+
+void dynamic_keymap_macro_reset(void)
+{
+ void *p = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR);
+ void *end = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR+DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE);
+ while ( p != end ) {
+ eeprom_update_byte(p, 0);
+ ++p;
+ }
+}
+
+void dynamic_keymap_macro_send( uint8_t id )
+{
+ if ( id >= DYNAMIC_KEYMAP_MACRO_COUNT ) {
+ return;
+ }
+
+ // Check the last byte of the buffer.
+ // If it's not zero, then we are in the middle
+ // of buffer writing, possibly an aborted buffer
+ // write. So do nothing.
+ void *p = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR+DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE-1);
+ if ( eeprom_read_byte(p) != 0 ) {
+ return;
+ }
+
+ // Skip N null characters
+ // p will then point to the Nth macro
+ p = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR);
+ void *end = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR+DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE);
+ while ( id > 0 ) {
+ // If we are past the end of the buffer, then the buffer
+ // contents are garbage, i.e. there were not DYNAMIC_KEYMAP_MACRO_COUNT
+ // nulls in the buffer.
+ if ( p == end ) {
+ return;
+ }
+ if ( eeprom_read_byte(p) == 0 ) {
+ --id;
+ }
+ ++p;
+ }
+
+ // Send the macro string one char at a time
+ // by making temporary 1 char strings
+ char data[2] = { 0, 0 };
+ // We already checked there was a null at the end of
+ // the buffer, so this cannot go past the end
+ while ( 1 ) {
+ data[0] = eeprom_read_byte(p);
+ // Stop at the null terminator of this macro string
+ if ( data[0] == 0 ) {
+ break;
+ }
+ send_string(data);
+ ++p;
+ }
+}
+
#endif // DYNAMIC_KEYMAP_ENABLE
diff --git a/quantum/dynamic_keymap.h b/quantum/dynamic_keymap.h
index bd76adae20..63653f6cb7 100644
--- a/quantum/dynamic_keymap.h
+++ b/quantum/dynamic_keymap.h
@@ -18,11 +18,46 @@
#include
#include
+uint8_t dynamic_keymap_get_layer_count(void);
void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column);
uint16_t dynamic_keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t column);
void dynamic_keymap_set_keycode(uint8_t layer, uint8_t row, uint8_t column, uint16_t keycode);
void dynamic_keymap_reset(void);
+// These get/set the keycodes as stored in the EEPROM buffer
+// Data is big-endian 16-bit values (the keycodes)
+// Order is by layer/row/column
+// Thus offset 0 = 0,0,0, offset MATRIX_COLS*2 = 0,1,0, offset MATRIX_ROWS*MATRIX_COLS*2 = 1,0,0
+// Note the *2, because offset is in bytes and keycodes are two bytes
+// This is only really useful for host applications that want to get a whole keymap fast,
+// by reading 14 keycodes (28 bytes) at a time, reducing the number of raw HID transfers by
+// a factor of 14.
+void dynamic_keymap_get_buffer( uint16_t offset, uint16_t size, uint8_t *data );
+void dynamic_keymap_set_buffer( uint16_t offset, uint16_t size, uint8_t *data );
// This overrides the one in quantum/keymap_common.c
// uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
+
+
+// Note regarding dynamic_keymap_macro_set_buffer():
+// The last byte of the buffer is used as a valid flag,
+// so macro sending is disabled during writing a new buffer,
+// should it happen during, or after an interrupted transfer.
+//
+// Users writing to the buffer must first set the last byte of the buffer
+// to non-zero (i.e. 0xFF). After (or during) the final write, set the
+// last byte of the buffer to zero.
+//
+// Since the contents of the buffer must be a list of null terminated
+// strings, the last byte must be a null when at maximum capacity,
+// and it not being null means the buffer can be considered in an
+// invalid state.
+
+uint8_t dynamic_keymap_macro_get_count(void);
+uint16_t dynamic_keymap_macro_get_buffer_size(void);
+void dynamic_keymap_macro_get_buffer( uint16_t offset, uint16_t size, uint8_t *data );
+void dynamic_keymap_macro_set_buffer( uint16_t offset, uint16_t size, uint8_t *data );
+void dynamic_keymap_macro_reset(void);
+
+void dynamic_keymap_macro_send( uint8_t id );
+
--
cgit v1.2.3