diff options
| author | Wilba6582 <Jason.S.Wiliams@gmail.com> | 2018-09-29 02:01:00 +1000 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2018-09-28 12:36:55 -0400 |
| commit | daa11dc414d505076ebdf147a4e2c800b8a06190 (patch) | |
| tree | c6daaed2fe278769aa0ac0b16a2283bdd60c7331 | |
| parent | 7fe03d085c2ecaa324779093eceb1a12313ca25d (diff) | |
| download | qmk_firmware-daa11dc414d505076ebdf147a4e2c800b8a06190.tar.gz qmk_firmware-daa11dc414d505076ebdf147a4e2c800b8a06190.zip | |
Changed VID/PID, added commands, refactoring
| -rw-r--r-- | keyboards/rama/m60_a/config.h | 4 | ||||
| -rw-r--r-- | keyboards/zeal60/zeal60.c | 134 | ||||
| -rw-r--r-- | keyboards/zeal60/zeal60_api.h | 9 |
3 files changed, 74 insertions, 73 deletions
diff --git a/keyboards/rama/m60_a/config.h b/keyboards/rama/m60_a/config.h index 45e7d8896..03794965f 100644 --- a/keyboards/rama/m60_a/config.h +++ b/keyboards/rama/m60_a/config.h | |||
| @@ -18,8 +18,8 @@ | |||
| 18 | #include "config_common.h" | 18 | #include "config_common.h" |
| 19 | 19 | ||
| 20 | // USB Device descriptor parameter | 20 | // USB Device descriptor parameter |
| 21 | #define VENDOR_ID 0xFEED // This is same as Zeal60 for now | 21 | #define VENDOR_ID 0x5241 // "RW" |
| 22 | #define PRODUCT_ID 0x6060 // This is same as Zeal60 for now | 22 | #define PRODUCT_ID 0x060A // 60-A |
| 23 | #define DEVICE_VER 0x0001 | 23 | #define DEVICE_VER 0x0001 |
| 24 | #define MANUFACTURER RAMA.WORKS | 24 | #define MANUFACTURER RAMA.WORKS |
| 25 | #define PRODUCT RAMA M60-A | 25 | #define PRODUCT RAMA M60-A |
diff --git a/keyboards/zeal60/zeal60.c b/keyboards/zeal60/zeal60.c index 092235ca6..be54f75f3 100644 --- a/keyboards/zeal60/zeal60.c +++ b/keyboards/zeal60/zeal60.c | |||
| @@ -38,6 +38,14 @@ void eeprom_set_valid(bool valid) | |||
| 38 | eeprom_update_byte(((void*)EEPROM_VERSION_ADDR), valid ? EEPROM_VERSION : 0xFF); | 38 | eeprom_update_byte(((void*)EEPROM_VERSION_ADDR), valid ? EEPROM_VERSION : 0xFF); |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | void eeprom_reset(void) | ||
| 42 | { | ||
| 43 | // Set the Zeal60 specific EEPROM state as invalid. | ||
| 44 | eeprom_set_valid(false); | ||
| 45 | // Set the TMK/QMK EEPROM state as invalid. | ||
| 46 | eeconfig_disable(); | ||
| 47 | } | ||
| 48 | |||
| 41 | #ifdef RAW_ENABLE | 49 | #ifdef RAW_ENABLE |
| 42 | 50 | ||
| 43 | void raw_hid_receive( uint8_t *data, uint8_t length ) | 51 | void raw_hid_receive( uint8_t *data, uint8_t length ) |
| @@ -54,7 +62,7 @@ void raw_hid_receive( uint8_t *data, uint8_t length ) | |||
| 54 | } | 62 | } |
| 55 | case id_get_keyboard_value: | 63 | case id_get_keyboard_value: |
| 56 | { | 64 | { |
| 57 | if ( command_data[0] == 0x01 ) | 65 | if ( command_data[0] == id_uptime ) |
| 58 | { | 66 | { |
| 59 | uint32_t value = timer_read32(); | 67 | uint32_t value = timer_read32(); |
| 60 | command_data[1] = (value >> 24 ) & 0xFF; | 68 | command_data[1] = (value >> 24 ) & 0xFF; |
| @@ -104,6 +112,21 @@ void raw_hid_receive( uint8_t *data, uint8_t length ) | |||
| 104 | break; | 112 | break; |
| 105 | } | 113 | } |
| 106 | #endif // RGB_BACKLIGHT_ENABLED | 114 | #endif // RGB_BACKLIGHT_ENABLED |
| 115 | case id_eeprom_reset: | ||
| 116 | { | ||
| 117 | eeprom_reset(); | ||
| 118 | break; | ||
| 119 | } | ||
| 120 | case id_bootloader_jump: | ||
| 121 | { | ||
| 122 | // Need to send data back before the jump | ||
| 123 | // Informs host that the command is handled | ||
| 124 | raw_hid_send( data, length ); | ||
| 125 | // Give host time to read it | ||
| 126 | wait_ms(100); | ||
| 127 | bootloader_jump(); | ||
| 128 | break; | ||
| 129 | } | ||
| 107 | default: | 130 | default: |
| 108 | { | 131 | { |
| 109 | // Unhandled message. | 132 | // Unhandled message. |
| @@ -119,74 +142,61 @@ void raw_hid_receive( uint8_t *data, uint8_t length ) | |||
| 119 | 142 | ||
| 120 | #endif | 143 | #endif |
| 121 | 144 | ||
| 122 | void bootmagic_lite(void) | 145 | void main_init(void) |
| 123 | { | 146 | { |
| 124 | // The lite version of TMK's bootmagic. | ||
| 125 | // 100% less potential for accidentally making the | ||
| 126 | // keyboard do stupid things. | ||
| 127 | |||
| 128 | // We need multiple scans because debouncing can't be turned off. | ||
| 129 | matrix_scan(); | ||
| 130 | wait_ms(DEBOUNCING_DELAY); | ||
| 131 | wait_ms(DEBOUNCING_DELAY); | ||
| 132 | matrix_scan(); | ||
| 133 | |||
| 134 | // If the Esc and space bar are held down on power up, | ||
| 135 | // reset the EEPROM valid state and jump to bootloader. | ||
| 136 | // Assumes Esc is at [0,0] and spacebar is at [4,7]. | ||
| 137 | // This isn't very generalized, but we need something that doesn't | ||
| 138 | // rely on user's keymaps in firmware or EEPROM. | ||
| 139 | if ( ( matrix_get_row(0) & (1<<0) ) && | ||
| 140 | ( matrix_get_row(4) & (1<<7) ) ) | ||
| 141 | { | ||
| 142 | // Set the Zeal60 specific EEPROM state as invalid. | ||
| 143 | eeprom_set_valid(false); | ||
| 144 | // Set the TMK/QMK EEPROM state as invalid. | ||
| 145 | eeconfig_disable(); | ||
| 146 | // Jump to bootloader. | ||
| 147 | bootloader_jump(); | ||
| 148 | } | ||
| 149 | } | ||
| 150 | |||
| 151 | void matrix_init_kb(void) | ||
| 152 | { | ||
| 153 | bootmagic_lite(); | ||
| 154 | |||
| 155 | // If the EEPROM has the magic, the data is good. | 147 | // If the EEPROM has the magic, the data is good. |
| 156 | // OK to load from EEPROM. | 148 | // OK to load from EEPROM. |
| 157 | if (eeprom_is_valid()) | 149 | if (eeprom_is_valid()) { |
| 158 | { | ||
| 159 | #if RGB_BACKLIGHT_ENABLED | 150 | #if RGB_BACKLIGHT_ENABLED |
| 160 | backlight_config_load(); | 151 | backlight_config_load(); |
| 161 | #endif // RGB_BACKLIGHT_ENABLED | 152 | #endif // RGB_BACKLIGHT_ENABLED |
| 162 | // TODO: do something to "turn on" keymaps in EEPROM? | 153 | } else { |
| 163 | } | ||
| 164 | else | ||
| 165 | { | ||
| 166 | #if RGB_BACKLIGHT_ENABLED | 154 | #if RGB_BACKLIGHT_ENABLED |
| 167 | // If the EEPROM has not been saved before, or is out of date, | 155 | // If the EEPROM has not been saved before, or is out of date, |
| 168 | // save the default values to the EEPROM. Default values | 156 | // save the default values to the EEPROM. Default values |
| 169 | // come from construction of the zeal_backlight_config instance. | 157 | // come from construction of the zeal_backlight_config instance. |
| 170 | backlight_config_save(); | 158 | backlight_config_save(); |
| 171 | #endif // RGB_BACKLIGHT_ENABLED | 159 | #endif // RGB_BACKLIGHT_ENABLED |
| 172 | |||
| 173 | #ifdef DYNAMIC_KEYMAP_ENABLE | 160 | #ifdef DYNAMIC_KEYMAP_ENABLE |
| 174 | // This resets the keymaps in EEPROM to what is in flash. | 161 | // This resets the keymaps in EEPROM to what is in flash. |
| 175 | dynamic_keymap_reset(); | 162 | dynamic_keymap_reset(); |
| 176 | #endif | 163 | #endif |
| 177 | |||
| 178 | // Save the magic number last, in case saving was interrupted | 164 | // Save the magic number last, in case saving was interrupted |
| 179 | eeprom_set_valid(true); | 165 | eeprom_set_valid(true); |
| 180 | } | 166 | } |
| 181 | |||
| 182 | #if RGB_BACKLIGHT_ENABLED | 167 | #if RGB_BACKLIGHT_ENABLED |
| 183 | // Initialize LED drivers for backlight. | 168 | // Initialize LED drivers for backlight. |
| 184 | backlight_init_drivers(); | 169 | backlight_init_drivers(); |
| 185 | 170 | ||
| 186 | backlight_timer_init(); | 171 | backlight_timer_init(); |
| 187 | backlight_timer_enable(); | 172 | backlight_timer_enable(); |
| 188 | #endif // RGB_BACKLIGHT_ENABLED | 173 | #endif // RGB_BACKLIGHT_ENABLED |
| 174 | } | ||
| 189 | 175 | ||
| 176 | void bootmagic_lite(void) | ||
| 177 | { | ||
| 178 | // The lite version of TMK's bootmagic. | ||
| 179 | // 100% less potential for accidentally making the | ||
| 180 | // keyboard do stupid things. | ||
| 181 | |||
| 182 | // We need multiple scans because debouncing can't be turned off. | ||
| 183 | matrix_scan(); | ||
| 184 | wait_ms(DEBOUNCING_DELAY); | ||
| 185 | wait_ms(DEBOUNCING_DELAY); | ||
| 186 | matrix_scan(); | ||
| 187 | |||
| 188 | // If the Esc (matrix 0,0) is held down on power up, | ||
| 189 | // reset the EEPROM valid state and jump to bootloader. | ||
| 190 | if ( matrix_get_row(0) & (1<<0) ) { | ||
| 191 | eeprom_reset(); | ||
| 192 | bootloader_jump(); | ||
| 193 | } | ||
| 194 | } | ||
| 195 | |||
| 196 | void matrix_init_kb(void) | ||
| 197 | { | ||
| 198 | bootmagic_lite(); | ||
| 199 | main_init(); | ||
| 190 | matrix_init_user(); | 200 | matrix_init_user(); |
| 191 | } | 201 | } |
| 192 | 202 | ||
| @@ -205,29 +215,22 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) | |||
| 205 | process_record_backlight(keycode, record); | 215 | process_record_backlight(keycode, record); |
| 206 | #endif // BACKLIGHT_ENABLED | 216 | #endif // BACKLIGHT_ENABLED |
| 207 | 217 | ||
| 208 | switch(keycode) | 218 | switch(keycode) { |
| 209 | { | ||
| 210 | case FN_MO13: | 219 | case FN_MO13: |
| 211 | if (record->event.pressed) | 220 | if (record->event.pressed) { |
| 212 | { | ||
| 213 | layer_on(1); | 221 | layer_on(1); |
| 214 | update_tri_layer(1, 2, 3); | 222 | update_tri_layer(1, 2, 3); |
| 215 | } | 223 | } else { |
| 216 | else | ||
| 217 | { | ||
| 218 | layer_off(1); | 224 | layer_off(1); |
| 219 | update_tri_layer(1, 2, 3); | 225 | update_tri_layer(1, 2, 3); |
| 220 | } | 226 | } |
| 221 | return false; | 227 | return false; |
| 222 | break; | 228 | break; |
| 223 | case FN_MO23: | 229 | case FN_MO23: |
| 224 | if (record->event.pressed) | 230 | if (record->event.pressed) { |
| 225 | { | ||
| 226 | layer_on(2); | 231 | layer_on(2); |
| 227 | update_tri_layer(1, 2, 3); | 232 | update_tri_layer(1, 2, 3); |
| 228 | } | 233 | } else { |
| 229 | else | ||
| 230 | { | ||
| 231 | layer_off(2); | 234 | layer_off(2); |
| 232 | update_tri_layer(1, 2, 3); | 235 | update_tri_layer(1, 2, 3); |
| 233 | } | 236 | } |
| @@ -247,8 +250,7 @@ uint16_t keymap_function_id_to_action( uint16_t function_id ) | |||
| 247 | if ( function_id >= 0x0F00 && function_id <= 0x0FFF ) | 250 | if ( function_id >= 0x0F00 && function_id <= 0x0FFF ) |
| 248 | { | 251 | { |
| 249 | uint8_t id = function_id & 0xFF; | 252 | uint8_t id = function_id & 0xFF; |
| 250 | switch ( id ) | 253 | switch ( id ) { |
| 251 | { | ||
| 252 | case TRIPLE_TAP_1_3: | 254 | case TRIPLE_TAP_1_3: |
| 253 | case TRIPLE_TAP_2_3: | 255 | case TRIPLE_TAP_2_3: |
| 254 | { | 256 | { |
| @@ -293,24 +295,16 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) | |||
| 293 | { | 295 | { |
| 294 | case TRIPLE_TAP_1_3: | 296 | case TRIPLE_TAP_1_3: |
| 295 | case TRIPLE_TAP_2_3: | 297 | case TRIPLE_TAP_2_3: |
| 296 | if (record->event.pressed) | 298 | if (record->event.pressed) { |
| 297 | { | ||
| 298 | layer_on( id == TRIPLE_TAP_1_3 ? 1 : 2 ); | 299 | layer_on( id == TRIPLE_TAP_1_3 ? 1 : 2 ); |
| 299 | 300 | if (record->tap.count && !record->tap.interrupted) { | |
| 300 | if (record->tap.count && !record->tap.interrupted) | 301 | if (record->tap.count >= 3) { |
| 301 | { | ||
| 302 | if (record->tap.count >= 3) | ||
| 303 | { | ||
| 304 | layer_invert(3); | 302 | layer_invert(3); |
| 305 | } | 303 | } |
| 306 | } | 304 | } else { |
| 307 | else | ||
| 308 | { | ||
| 309 | record->tap.count = 0; | 305 | record->tap.count = 0; |
| 310 | } | 306 | } |
| 311 | } | 307 | } else { |
| 312 | else | ||
| 313 | { | ||
| 314 | layer_off( id == TRIPLE_TAP_1_3 ? 1 : 2 ); | 308 | layer_off( id == TRIPLE_TAP_1_3 ? 1 : 2 ); |
| 315 | } | 309 | } |
| 316 | break; | 310 | break; |
diff --git a/keyboards/zeal60/zeal60_api.h b/keyboards/zeal60/zeal60_api.h index eaac3ad7c..a65bf2f50 100644 --- a/keyboards/zeal60/zeal60_api.h +++ b/keyboards/zeal60/zeal60_api.h | |||
| @@ -28,6 +28,13 @@ enum zeal60_command_id | |||
| 28 | id_backlight_config_set_value, | 28 | id_backlight_config_set_value, |
| 29 | id_backlight_config_get_value, | 29 | id_backlight_config_get_value, |
| 30 | id_backlight_config_save, | 30 | id_backlight_config_save, |
| 31 | 31 | id_eeprom_reset, | |
| 32 | id_bootloader_jump, | ||
| 32 | id_unhandled = 0xFF, | 33 | id_unhandled = 0xFF, |
| 33 | }; | 34 | }; |
| 35 | |||
| 36 | enum zeal60_keyboard_value_id | ||
| 37 | { | ||
| 38 | id_uptime = 0x01 | ||
| 39 | }; | ||
| 40 | |||
