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:
		
							parent
							
								
									caa293a8f7
								
							
						
					
					
						commit
						2dea540afb
					
				
					 23 changed files with 468 additions and 607 deletions
				
			
		| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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),
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			@ -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 }  \
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue