Refactoring M6-A, M6-B, Zeal60, Zeal65, WT60-A, WT65-A, WT80-A (#4417)

* 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
This commit is contained in:
Wilba 2018-11-14 03:31:25 +11:00 committed by Drashna Jaelre
parent caa293a8f7
commit 2dea540afb
23 changed files with 468 additions and 607 deletions

View File

@ -1,20 +1,18 @@
/*
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 <http://www.gnu.org/licenses/>.
*/
/* 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "config_common.h"
@ -47,7 +45,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* COL2ROW, ROW2COL, or CUSTOM_MATRIX */
#define DIODE_DIRECTION COL2ROW
// #define BACKLIGHT_PIN B7
// #define BACKLIGHT_BREATHING
// #define BACKLIGHT_LEVELS 3
@ -109,88 +107,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)
/* control how magic key switches layers */
//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true
//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true
//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false
/* override magic key keymap */
//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
//#define MAGIC_KEY_HELP1 H
//#define MAGIC_KEY_HELP2 SLASH
//#define MAGIC_KEY_DEBUG D
//#define MAGIC_KEY_DEBUG_MATRIX X
//#define MAGIC_KEY_DEBUG_KBD K
//#define MAGIC_KEY_DEBUG_MOUSE M
//#define MAGIC_KEY_VERSION V
//#define MAGIC_KEY_STATUS S
//#define MAGIC_KEY_CONSOLE C
//#define MAGIC_KEY_LAYER0_ALT1 ESC
//#define MAGIC_KEY_LAYER0_ALT2 GRAVE
//#define MAGIC_KEY_LAYER0 0
//#define MAGIC_KEY_LAYER1 1
//#define MAGIC_KEY_LAYER2 2
//#define MAGIC_KEY_LAYER3 3
//#define MAGIC_KEY_LAYER4 4
//#define MAGIC_KEY_LAYER5 5
//#define MAGIC_KEY_LAYER6 6
//#define MAGIC_KEY_LAYER7 7
//#define MAGIC_KEY_LAYER8 8
//#define MAGIC_KEY_LAYER9 9
//#define MAGIC_KEY_BOOTLOADER PAUSE
//#define MAGIC_KEY_LOCK CAPS
//#define MAGIC_KEY_EEPROM E
//#define MAGIC_KEY_NKRO N
//#define MAGIC_KEY_SLEEP_LED Z
/*
* Feature disable options
* These options are also useful to firmware size reduction.
*/
/* disable debug print */
//#define NO_DEBUG
/* disable print */
//#define NO_PRINT
/* disable action features */
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION
/*
* MIDI options
*/
/* Prevent use of disabled MIDI features in the keymap */
//#define MIDI_ENABLE_STRICT 1
/* enable basic MIDI features:
- MIDI notes can be sent when in Music mode is on
*/
//#define MIDI_BASIC
/* enable advanced MIDI features:
- MIDI notes can be added to the keymap
- Octave shift and transpose
- Virtual sustain, portamento, and modulation wheel
- etc.
*/
//#define MIDI_ADVANCED
/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */
//#define MIDI_TONE_KEYCODE_OCTAVES 1
#define RGB_BACKLIGHT_ENABLED 0
#define DYNAMIC_KEYMAP_LAYER_COUNT 4
// EEPROM usage
// TODO: refactor with new user EEPROM code (coming soon)
@ -206,3 +126,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35
// Dynamic keymap starts after backlight config (35+37)
#define DYNAMIC_KEYMAP_EEPROM_ADDR 72

View File

@ -1,5 +1,5 @@
# project specific files
SRC = keyboards/rama/m6_b/m6_b.c
SRC = ../zeal60/zeal60.c
# MCU name
MCU = atmega32u4
@ -43,24 +43,32 @@ 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)
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)
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)
NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
MIDI_ENABLE = no # MIDI controls
AUDIO_ENABLE = no # Audio output on port C6
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
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
RAW_ENABLE = yes
DYNAMIC_KEYMAP_ENABLE = yes
DYNAMIC_KEYMAP_ENABLE = yes
CIE1931_CURVE = no

View File

@ -109,8 +109,38 @@
#define RGB_BACKLIGHT_ENABLED 1
#define DYNAMIC_KEYMAP_LAYER_COUNT 4
// This conditionally compiles the backlight code for M6-B specifics
#define RGB_BACKLIGHT_M6_B
// enable/disable LEDs based on layout
#define RGB_BACKLIGHT_USE_SPLIT_BACKSPACE 0
#define RGB_BACKLIGHT_USE_SPLIT_LEFT_SHIFT 0
#define RGB_BACKLIGHT_USE_SPLIT_RIGHT_SHIFT 0
#define RGB_BACKLIGHT_USE_7U_SPACEBAR 0
#define RGB_BACKLIGHT_USE_ISO_ENTER 0
#define RGB_BACKLIGHT_DISABLE_HHKB_BLOCKER_LEDS 0
// disable backlight when USB suspended (PC sleep/hibernate/shutdown)
#define RGB_BACKLIGHT_DISABLE_WHEN_USB_SUSPENDED 0
// disable backlight after timeout in minutes, 0 = no timeout
#define RGB_BACKLIGHT_DISABLE_AFTER_TIMEOUT 0
// the default effect (RGB test)
#define RGB_BACKLIGHT_EFFECT 255
// These define which keys in the matrix are alphas/mods
// Used for backlight effects so colors are different for
// alphas vs. mods
// Each value is for a row, bit 0 is column 0
// Alpha=0 Mod=1
#define RGB_BACKLIGHT_ALPHAS_MODS_ROW_0 0
#define RGB_BACKLIGHT_ALPHAS_MODS_ROW_1 0
#define RGB_BACKLIGHT_ALPHAS_MODS_ROW_2 0
#define RGB_BACKLIGHT_ALPHAS_MODS_ROW_3 0
#define RGB_BACKLIGHT_ALPHAS_MODS_ROW_4 0
#define DYNAMIC_KEYMAP_LAYER_COUNT 4
// EEPROM usage
@ -127,3 +157,4 @@
#define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35
// Dynamic keymap starts after backlight config (35+37)
#define DYNAMIC_KEYMAP_EEPROM_ADDR 72

View File

@ -13,218 +13,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "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 );
}
#ifndef RGB_BACKLIGHT_M6_B
#error RGB_BACKLIGHT_M6_B not defined, you done goofed somehao, brah
#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
}

View File

@ -1,39 +0,0 @@
/* 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 <http://www.gnu.org/licenses/>.
*/
#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
};

View File

@ -1,139 +0,0 @@
/* 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 <http://www.gnu.org/licenses/>.
*/
#if RGB_BACKLIGHT_ENABLED
#include "rgb_backlight.h"
//#include "rgb_backlight_api.h"
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#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

View File

@ -1,34 +0,0 @@
/* 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#if RGB_BACKLIGHT_ENABLED
#else
#error rgb_backlight.h included when RGB_BACKLIGHT_ENABLED == 0
#endif // RGB_BACKLIGHT_ENABLED
#include <stdint.h>
#include <stdbool.h>
#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);

View File

@ -1,5 +1,6 @@
# project specific files
SRC = rgb_backlight.c \
SRC = ../zeal60/zeal60.c \
../zeal60/rgb_backlight.c \
quantum/color.c \
drivers/issi/is31fl3218.c \
drivers/avr/i2c_master.c
@ -56,22 +57,23 @@ OPT_DEFS += -DNO_SUSPEND_POWER_DOWN
# Build Options
# change yes to no to disable
#
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
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)
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)
NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
MIDI_ENABLE = no # MIDI controls
AUDIO_ENABLE = no # Audio output on port C6
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
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
RAW_ENABLE = yes
DYNAMIC_KEYMAP_ENABLE = yes
CIE1931_CURVE = yes

View File

@ -185,3 +185,20 @@
/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */
//#define MIDI_TONE_KEYCODE_OCTAVES 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

View File

@ -18,5 +18,20 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
[2] = LAYOUT_all(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
[3] = LAYOUT_all(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
};

View File

@ -52,17 +52,21 @@ BOOTLOADER = atmel-dfu
# change yes to no to disable
#
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
MOUSEKEY_ENABLE = no # 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
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 = no # USB Nkey Rollover
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

View File

@ -185,3 +185,20 @@
/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */
//#define MIDI_TONE_KEYCODE_OCTAVES 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

View File

@ -52,17 +52,20 @@ BOOTLOADER = atmel-dfu
# change yes to no to disable
#
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
MOUSEKEY_ENABLE = no # 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
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 = no # USB Nkey Rollover
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

View File

@ -185,3 +185,20 @@
/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */
//#define MIDI_TONE_KEYCODE_OCTAVES 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

View File

@ -52,17 +52,20 @@ BOOTLOADER = atmel-dfu
# change yes to no to disable
#
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
MOUSEKEY_ENABLE = no # 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
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 = no # USB Nkey Rollover
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

View File

@ -185,3 +185,20 @@
/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */
//#define MIDI_TONE_KEYCODE_OCTAVES 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

View File

@ -18,5 +18,21 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
[2] = LAYOUT_all(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
[3] = LAYOUT_all(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
};

View File

@ -52,17 +52,20 @@ BOOTLOADER = atmel-dfu
# change yes to no to disable
#
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
MOUSEKEY_ENABLE = no # 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
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 = no # USB Nkey Rollover
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

View File

@ -41,3 +41,18 @@
{ K500, K501, K502, ____, ____, ____, K506, ____, ____, ____, K510, K511, K512, K513, K514, K515, K516 } \
}
#define LAYOUT_no_split( \
K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, K012, K014, K015, K016, \
K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, K113, K114, K115, K116, \
K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, K212, K213, K214, K215, K216, \
K300, K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311, K312, \
K400, K402, K403, K404, K405, K406, K407, K408, K409, K410, K411, K412, K415, \
K500, K501, K502, K506, K510, K511, K512, K513, K514, K515, K516 \
) { \
{ K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, K012, ____, K014, K015, K016 }, \
{ K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, K113, K114, K115, K116 }, \
{ K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, K212, K213, K214, K215, K216 }, \
{ K300, K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311, K312, K313, ____, ____, ____ }, \
{ K400, ____, K402, K403, K404, K405, K406, K407, K408, K409, K410, K411, K412, K413, ____, K415, ____ }, \
{ K500, K501, K502, ____, ____, ____, K506, ____, ____, ____, K510, K511, K512, K513, K514, K515, K516 } \
}

View File

@ -16,6 +16,152 @@
#include "quantum.h"
#include "keyboards/wilba_tech/wt_mono_backlight.h"
#include "keyboards/zeal60/zeal60_api.h" // Temporary hack
#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 Zeal60 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
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;
}
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()) {
//backlight_config_load();
} else {
// 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();
#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);
}
// Initialize LED drivers for backlight.
backlight_init_drivers();
backlight_timer_init();
backlight_timer_enable();
}
void bootmagic_lite(void)
{
@ -32,9 +178,7 @@ void bootmagic_lite(void)
// 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) ) {
// Set the TMK/QMK EEPROM state as invalid.
eeconfig_disable();
// Jump to bootloader.
eeprom_reset();
bootloader_jump();
}
}
@ -42,14 +186,13 @@ void bootmagic_lite(void)
void matrix_init_kb(void)
{
bootmagic_lite();
backlight_init_drivers();
backlight_timer_init();
backlight_timer_enable();
main_init();
matrix_init_user();
}
void matrix_scan_kb(void)
{
// This only updates the LED driver buffers if something has changed.
backlight_update_pwm_buffers();
matrix_scan_user();
}

View File

@ -15,12 +15,12 @@
*/
#if RGB_BACKLIGHT_ENABLED
#if defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_ZEAL65) || defined (RGB_BACKLIGHT_M60_A)
#if defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_ZEAL65) || defined (RGB_BACKLIGHT_M60_A) || defined(RGB_BACKLIGHT_M6_B)
#else
#error None of the following was defined: RGB_BACKLIGHT_ZEAL60, RGB_BACKLIGHT_ZEAL65, RGB_BACKLIGHT_M60_A
#error None of the following was defined: RGB_BACKLIGHT_ZEAL60, RGB_BACKLIGHT_ZEAL65, RGB_BACKLIGHT_M60_A, RGB_BACKLIGHT_M6_B
#endif
#include "zeal60.h"
#include "quantum.h"
#include "rgb_backlight.h"
#include "rgb_backlight_api.h"
#include "rgb_backlight_keycodes.h"
@ -32,7 +32,14 @@
#include "quantum/color.h"
#include "drivers/avr/i2c_master.h"
#if defined (RGB_BACKLIGHT_M6_B)
#include "drivers/issi/is31fl3218.h"
#define BACKLIGHT_LED_COUNT 6
#else
#include "drivers/issi/is31fl3731.h"
#define BACKLIGHT_LED_COUNT 72
#endif
#define BACKLIGHT_EFFECT_MAX 10
@ -69,11 +76,12 @@ uint8_t g_indicator_state = 0;
uint32_t g_tick = 0;
// Ticks since this key was last hit.
uint8_t g_key_hit[72];
uint8_t g_key_hit[BACKLIGHT_LED_COUNT];
// Ticks since any key was last hit.
uint32_t g_any_key_hit = 0;
#if !defined(RGB_BACKLIGHT_M6_B)
// This is a 7-bit address, that gets left-shifted and bit 0
// set to 0 for write, 1 for read (as per I2C protocol)
#define ISSI_ADDR_1 0x74
@ -162,7 +170,7 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
{1, C9_16, C7_15, C6_15}, // LD16
{1, C8_16, C7_16, C6_16}, // LD17
};
#endif // !defined(RGB_BACKLIGHT_M6_B)
typedef struct Point {
@ -175,7 +183,7 @@ typedef struct Point {
// point values in range x=0..224 y=0..64
// origin is center of top-left key (i.e Esc)
#if defined (RGB_BACKLIGHT_ZEAL65)
const Point g_map_led_to_point[72] PROGMEM = {
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},
@ -189,7 +197,7 @@ const Point g_map_led_to_point[72] PROGMEM = {
{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}, {144,60}, {164,64}, {188,64}, {208,64}
};
const Point g_map_led_to_point_polar[72] 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},
{61,255}, {67,255}, {72,255}, {77,255}, {82,255}, {86,255}, {90,255}, {93,255}, {96,255},
@ -204,7 +212,7 @@ const Point g_map_led_to_point_polar[72] PROGMEM = {
{189,128}, {200,131}, {210,141}, {218,159}, {201,228}, {201,228}, {206,255}, {213,255}, {218,255}
};
#elif defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_M60_A)
const Point g_map_led_to_point[72] PROGMEM = {
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},
@ -218,7 +226,7 @@ const Point g_map_led_to_point[72] PROGMEM = {
{124,32}, {140,32}, {156,32}, {172,32}, {188,32}, {214,32}, {180,48}, {210,48}, {224,48},
{116,48}, {132,48}, {148,48}, {164,48}, {144,64}, {161,64}, {181,64}, {201,64}, {221,64}
};
const Point g_map_led_to_point_polar[72] PROGMEM = {
const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
// LA0..LA17
{58,129}, {70,129}, {80,139}, {89,157}, {96,181}, {101,208}, {105,238}, {109,255}, {128,247}, {58,255},
{64,255}, {70,255}, {75,255}, {80,255}, {85,255}, {89,255}, {93,255}, {96,255},
@ -232,6 +240,16 @@ const Point g_map_led_to_point_polar[72] PROGMEM = {
{0,27}, {0,64}, {0,101}, {0,137}, {0,174}, {255,233}, {228,201}, {235,255}, {237,255},
{195,128}, {206,136}, {215,152}, {222,175}, {205,234}, {209,255}, {214,255}, {219,255}, {223,255}
};
#elif defined (RGB_BACKLIGHT_M6_B)
// M6-B is really simple:
// 0 3 5
// 1 2 4
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}
};
#endif
// This may seem counter-intuitive, but it's quite flexible.
@ -245,16 +263,30 @@ void map_led_to_point( uint8_t index, Point *point )
point->x = pgm_read_byte(addr);
point->y = pgm_read_byte(addr+1);
#if defined (RGB_BACKLIGHT_M6_B)
return;
#endif
switch (index)
{
case 18+4: // LB4A
if ( g_config.use_split_backspace )
point->x -= 8;
break;
#if defined (RGB_BACKLIGHT_ZEAL60)
case 18+14: // LB14A
if ( g_config.use_iso_enter )
point->y += 8; // extremely pedantic
break;
case 54+5: // LD5A
if ( !g_config.use_iso_enter )
point->x -= 10;
break;
case 36+16: // LC16A
if ( !g_config.use_split_left_shift )
point->x += 8;
break;
#endif
#if defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_M60_A)
case 36+0: // LC0A
if ( g_config.use_7u_spacebar )
@ -264,19 +296,11 @@ void map_led_to_point( uint8_t index, Point *point )
if ( g_config.use_7u_spacebar )
point->x += 4;
break;
#endif
case 36+16: // LC16A
if ( !g_config.use_split_left_shift )
point->x += 8;
break;
case 54+5: // LD5A
if ( !g_config.use_iso_enter )
point->x -= 10;
break;
case 54+7: // LD7A
if ( !g_config.use_split_right_shift )
point->x -= 8;
break;
#endif
}
}
@ -325,6 +349,13 @@ 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 },
{ 36+17, 36+8, 36+7, 36+6, 255, 255, 255, 36+0, 255, 54+13, 54+14, 54+15, 54+16, 54+17 }
};
#elif defined (RGB_BACKLIGHT_M6_B)
// M6-B is really simple:
// 0 3 5
// 1 2 4
const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
{ 0, 3, 5, 1, 2, 4 }
};
#endif
void map_row_column_to_led( uint8_t row, uint8_t column, uint8_t *led )
@ -338,18 +369,30 @@ void map_row_column_to_led( uint8_t row, uint8_t column, uint8_t *led )
void backlight_update_pwm_buffers(void)
{
#if defined (RGB_BACKLIGHT_M6_B)
IS31FL3218_update_pwm_buffers();
#else
IS31FL3731_update_pwm_buffers( ISSI_ADDR_1, ISSI_ADDR_2 );
IS31FL3731_update_led_control_registers( ISSI_ADDR_1, ISSI_ADDR_2 );
#endif
}
void backlight_set_color( int index, uint8_t red, uint8_t green, uint8_t blue )
{
#if defined (RGB_BACKLIGHT_M6_B)
IS31FL3218_set_color( index, red, green, blue );
#else
IS31FL3731_set_color( index, red, green, blue );
#endif
}
void backlight_set_color_all( uint8_t red, uint8_t green, uint8_t blue )
{
#if defined (RGB_BACKLIGHT_M6_B)
IS31FL3218_set_color_all( red, green, blue );
#else
IS31FL3731_set_color_all( red, green, blue );
#endif
}
void backlight_set_key_hit(uint8_t row, uint8_t column)
@ -436,6 +479,7 @@ void backlight_effect_rgb_test(void)
}
}
#if defined(RGB_DEBUGGING_ONLY)
// This tests the LEDs
// Note that it will change the LED control registers
// in the LED drivers, and leave them in an invalid
@ -475,6 +519,7 @@ void backlight_effect_single_LED_test(void)
backlight_set_color_all( 255, 255, 255 );
backlight_test_led( led, color==0, color==1, color==2 );
}
#endif // defined(RGB_DEBUGGING_ONLY)
// All LEDs off
void backlight_effect_all_off(void)
@ -502,7 +547,7 @@ void backlight_effect_alphas_mods(void)
{
uint8_t index;
map_row_column_to_led( row, column, &index );
if ( index < 72 )
if ( index < BACKLIGHT_LED_COUNT )
{
if ( ( g_config.alphas_mods[row] & (1<<column) ) == 0 )
{
@ -542,7 +587,7 @@ void backlight_effect_gradient_up_down(void)
HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness };
RGB rgb;
Point point;
for ( int i=0; i<72; i++ )
for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
{
map_led_to_point( i, &point );
// The y range will be 0..64, map this to 0..4
@ -580,9 +625,9 @@ void backlight_effect_raindrops(bool initialize)
RGB rgb;
// Change one LED every tick
uint8_t led_to_change = ( g_tick & 0x000 ) == 0 ? rand() % 72 : 255;
uint8_t led_to_change = ( g_tick & 0x000 ) == 0 ? rand() % BACKLIGHT_LED_COUNT : 255;
for ( int i=0; i<72; i++ )
for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
{
// If initialize, all get set to random colors
// If not, all but one will stay the same as before.
@ -604,7 +649,7 @@ void backlight_effect_cycle_all(void)
uint8_t offset = ( g_tick << g_config.effect_speed ) & 0xFF;
// Relies on hue being 8-bit and wrapping
for ( int i=0; i<72; i++ )
for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
{
uint16_t offset2 = g_key_hit[i]<<2;
// stabilizer LEDs use spacebar hits
@ -627,7 +672,7 @@ void backlight_effect_cycle_left_right(void)
HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness };
RGB rgb;
Point point;
for ( int i=0; i<72; i++ )
for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
{
uint16_t offset2 = g_key_hit[i]<<2;
// stabilizer LEDs use spacebar hits
@ -652,7 +697,7 @@ void backlight_effect_cycle_up_down(void)
HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness };
RGB rgb;
Point point;
for ( int i=0; i<72; i++ )
for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
{
uint16_t offset2 = g_key_hit[i]<<2;
// stabilizer LEDs use spacebar hits
@ -677,9 +722,9 @@ void backlight_effect_jellybean_raindrops( bool initialize )
RGB rgb;
// Change one LED every tick
uint8_t led_to_change = ( g_tick & 0x000 ) == 0 ? rand() % 72 : 255;
uint8_t led_to_change = ( g_tick & 0x000 ) == 0 ? rand() % BACKLIGHT_LED_COUNT : 255;
for ( int i=0; i<72; i++ )
for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
{
// If initialize, all get set to random colors
// If not, all but one will stay the same as before.
@ -702,7 +747,7 @@ void backlight_effect_cycle_radial1(void)
HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness };
RGB rgb;
Point point;
for ( int i=0; i<72; i++ )
for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
{
map_led_to_point_polar( i, &point );
// Relies on hue being 8-bit and wrapping
@ -720,7 +765,7 @@ void backlight_effect_cycle_radial2(void)
HSV hsv = { .h = 0, .s = g_config.color_1.s, .v = g_config.brightness };
RGB rgb;
Point point;
for ( int i=0; i<72; i++ )
for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
{
map_led_to_point_polar( i, &point );
uint8_t offset2 = offset + point.x;
@ -826,7 +871,7 @@ ISR(TIMER3_COMPA_vect)
g_any_key_hit++;
}
for ( int led = 0; led < 72; led++ )
for ( int led = 0; led < BACKLIGHT_LED_COUNT; led++ )
{
if ( g_key_hit[led] < 255 )
{
@ -899,7 +944,9 @@ ISR(TIMER3_COMPA_vect)
if ( ! suspend_backlight )
{
#if !defined(RGB_BACKLIGHT_M6_B)
backlight_effect_indicators();
#endif
}
}
@ -1239,17 +1286,19 @@ void backlight_init_drivers(void)
{
// Initialize I2C
i2c_init();
#if defined(RGB_BACKLIGHT_M6_B)
IS31FL3218_init();
#else
IS31FL3731_init( ISSI_ADDR_1 );
IS31FL3731_init( ISSI_ADDR_2 );
for ( int index = 0; index < 72; index++ )
for ( int index = 0; index < BACKLIGHT_LED_COUNT; index++ )
{
// OR the possible "disabled" cases together, then NOT the result to get the enabled state
// LC6 LD13 not present on Zeal65
#if defined (RGB_BACKLIGHT_ZEAL65)
bool enabled = !( ( index == 18+5 && !g_config.use_split_backspace ) || // LB5
( index == 36+15 && !g_config.use_split_left_shift ) || // LC15
( index == 54+8 && !g_config.use_split_right_shift ) || // LD8
( index == 36+6 ) || // LC6
( index == 54+13 ) ); // LD13
#elif defined (RGB_BACKLIGHT_M60_A)
@ -1286,11 +1335,12 @@ void backlight_init_drivers(void)
}
// This actually updates the LED drivers
IS31FL3731_update_led_control_registers( ISSI_ADDR_1, ISSI_ADDR_2 );
#endif // !defined(RGB_BACKLIGHT_M6_B)
// TODO: put the 1 second startup delay here?
// clear the key hits
for ( int led=0; led<72; led++ )
for ( int led=0; led<BACKLIGHT_LED_COUNT; led++ )
{
g_key_hit[led] = 255;
}
@ -1510,9 +1560,10 @@ void backlight_color_2_sat_decrease(void)
backlight_config_save();
}
#if defined(RGB_DEBUGGING_ONLY)
void backlight_test_led( uint8_t index, bool red, bool green, bool blue )
{
for ( int i=0; i<72; i++ )
for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
{
if ( i == index )
{
@ -1524,6 +1575,7 @@ void backlight_test_led( uint8_t index, bool red, bool green, bool blue )
}
}
}
#endif // defined(RGB_DEBUGGING_ONLY)
void backlight_debug_led( bool state )
{

View File

@ -164,6 +164,7 @@ void main_init(void)
// 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();

View File

@ -79,10 +79,10 @@
// enable/disable LEDs based on layout
#define RGB_BACKLIGHT_USE_SPLIT_BACKSPACE 0
#define RGB_BACKLIGHT_USE_SPLIT_LEFT_SHIFT 0
#define RGB_BACKLIGHT_USE_SPLIT_RIGHT_SHIFT 1
#define RGB_BACKLIGHT_USE_7U_SPACEBAR 0
#define RGB_BACKLIGHT_USE_ISO_ENTER 0
#define RGB_BACKLIGHT_USE_SPLIT_LEFT_SHIFT 0 // Unused
#define RGB_BACKLIGHT_USE_SPLIT_RIGHT_SHIFT 0 // Unused
#define RGB_BACKLIGHT_USE_7U_SPACEBAR 1 // Used only for stab LED matching spacebar LED
#define RGB_BACKLIGHT_USE_ISO_ENTER 0 // Unused
#define RGB_BACKLIGHT_DISABLE_HHKB_BLOCKER_LEDS 0
// disable backlight when USB suspended (PC sleep/hibernate/shutdown)