1
0
Fork 0

Changed VID/PID, added commands, refactoring

This commit is contained in:
Wilba6582 2018-09-29 02:01:00 +10:00 committed by Jack Humbert
parent 7fe03d085c
commit daa11dc414
3 changed files with 80 additions and 79 deletions

View file

@ -18,8 +18,8 @@
#include "config_common.h" #include "config_common.h"
// USB Device descriptor parameter // USB Device descriptor parameter
#define VENDOR_ID 0xFEED // This is same as Zeal60 for now #define VENDOR_ID 0x5241 // "RW"
#define PRODUCT_ID 0x6060 // This is same as Zeal60 for now #define PRODUCT_ID 0x060A // 60-A
#define DEVICE_VER 0x0001 #define DEVICE_VER 0x0001
#define MANUFACTURER RAMA.WORKS #define MANUFACTURER RAMA.WORKS
#define PRODUCT RAMA M60-A #define PRODUCT RAMA M60-A

View file

@ -38,6 +38,14 @@ void eeprom_set_valid(bool valid)
eeprom_update_byte(((void*)EEPROM_VERSION_ADDR), valid ? EEPROM_VERSION : 0xFF); 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 #ifdef RAW_ENABLE
void raw_hid_receive( uint8_t *data, uint8_t length ) void raw_hid_receive( uint8_t *data, uint8_t length )
@ -54,7 +62,7 @@ void raw_hid_receive( uint8_t *data, uint8_t length )
} }
case id_get_keyboard_value: case id_get_keyboard_value:
{ {
if ( command_data[0] == 0x01 ) if ( command_data[0] == id_uptime )
{ {
uint32_t value = timer_read32(); uint32_t value = timer_read32();
command_data[1] = (value >> 24 ) & 0xFF; command_data[1] = (value >> 24 ) & 0xFF;
@ -104,6 +112,21 @@ void raw_hid_receive( uint8_t *data, uint8_t length )
break; break;
} }
#endif // RGB_BACKLIGHT_ENABLED #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: default:
{ {
// Unhandled message. // Unhandled message.
@ -119,6 +142,37 @@ void raw_hid_receive( uint8_t *data, uint8_t length )
#endif #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) void bootmagic_lite(void)
{ {
// The lite version of TMK's bootmagic. // The lite version of TMK's bootmagic.
@ -131,19 +185,10 @@ void bootmagic_lite(void)
wait_ms(DEBOUNCING_DELAY); wait_ms(DEBOUNCING_DELAY);
matrix_scan(); matrix_scan();
// If the Esc and space bar are held down on power up, // If the Esc (matrix 0,0) is held down on power up,
// reset the EEPROM valid state and jump to bootloader. // reset the EEPROM valid state and jump to bootloader.
// Assumes Esc is at [0,0] and spacebar is at [4,7]. if ( matrix_get_row(0) & (1<<0) ) {
// This isn't very generalized, but we need something that doesn't eeprom_reset();
// rely on user's keymaps in firmware or EEPROM.
if ( ( matrix_get_row(0) & (1<<0) ) &&
( matrix_get_row(4) & (1<<7) ) )
{
// Set the Zeal60 specific EEPROM state as invalid.
eeprom_set_valid(false);
// Set the TMK/QMK EEPROM state as invalid.
eeconfig_disable();
// Jump to bootloader.
bootloader_jump(); bootloader_jump();
} }
} }
@ -151,42 +196,7 @@ void bootmagic_lite(void)
void matrix_init_kb(void) void matrix_init_kb(void)
{ {
bootmagic_lite(); bootmagic_lite();
main_init();
// 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
// TODO: do something to "turn on" keymaps in EEPROM?
}
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
matrix_init_user(); matrix_init_user();
} }
@ -205,29 +215,22 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record)
process_record_backlight(keycode, record); process_record_backlight(keycode, record);
#endif // BACKLIGHT_ENABLED #endif // BACKLIGHT_ENABLED
switch(keycode) switch(keycode) {
{
case FN_MO13: case FN_MO13:
if (record->event.pressed) if (record->event.pressed) {
{
layer_on(1); layer_on(1);
update_tri_layer(1, 2, 3); update_tri_layer(1, 2, 3);
} } else {
else
{
layer_off(1); layer_off(1);
update_tri_layer(1, 2, 3); update_tri_layer(1, 2, 3);
} }
return false; return false;
break; break;
case FN_MO23: case FN_MO23:
if (record->event.pressed) if (record->event.pressed) {
{
layer_on(2); layer_on(2);
update_tri_layer(1, 2, 3); update_tri_layer(1, 2, 3);
} } else {
else
{
layer_off(2); layer_off(2);
update_tri_layer(1, 2, 3); update_tri_layer(1, 2, 3);
} }
@ -247,8 +250,7 @@ uint16_t keymap_function_id_to_action( uint16_t function_id )
if ( function_id >= 0x0F00 && function_id <= 0x0FFF ) if ( function_id >= 0x0F00 && function_id <= 0x0FFF )
{ {
uint8_t id = function_id & 0xFF; uint8_t id = function_id & 0xFF;
switch ( id ) switch ( id ) {
{
case TRIPLE_TAP_1_3: case TRIPLE_TAP_1_3:
case TRIPLE_TAP_2_3: case TRIPLE_TAP_2_3:
{ {
@ -293,24 +295,16 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{ {
case TRIPLE_TAP_1_3: case TRIPLE_TAP_1_3:
case TRIPLE_TAP_2_3: case TRIPLE_TAP_2_3:
if (record->event.pressed) if (record->event.pressed) {
{
layer_on( id == TRIPLE_TAP_1_3 ? 1 : 2 ); layer_on( id == TRIPLE_TAP_1_3 ? 1 : 2 );
if (record->tap.count && !record->tap.interrupted) {
if (record->tap.count && !record->tap.interrupted) if (record->tap.count >= 3) {
{
if (record->tap.count >= 3)
{
layer_invert(3); layer_invert(3);
} }
} } else {
else
{
record->tap.count = 0; record->tap.count = 0;
} }
} } else {
else
{
layer_off( id == TRIPLE_TAP_1_3 ? 1 : 2 ); layer_off( id == TRIPLE_TAP_1_3 ? 1 : 2 );
} }
break; break;

View file

@ -28,6 +28,13 @@ enum zeal60_command_id
id_backlight_config_set_value, id_backlight_config_set_value,
id_backlight_config_get_value, id_backlight_config_get_value,
id_backlight_config_save, id_backlight_config_save,
id_eeprom_reset,
id_bootloader_jump,
id_unhandled = 0xFF, id_unhandled = 0xFF,
}; };
enum zeal60_keyboard_value_id
{
id_uptime = 0x01
};