diff options
author | jecassis <jecassis@users.noreply.github.com> | 2022-01-11 01:39:10 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-10 17:39:10 -0800 |
commit | 8920db2b57b616e162e2d3162577db6f021e7658 (patch) | |
tree | 3fc960146f72f75231b70fc0a4c71c590b61355d /keyboards/system76 | |
parent | da1a01b811a382ac92b44558dc4f6eec9314571f (diff) |
[Keyboard] Add system76/launch_1 keyboard (#15395)
* WIP: virgo keyboard
* Finish layout
* Enable debugging and format
* Debug keypresses
* Add function layer
* Fix whitespace
* Fix some more whitespace
* Add Jeremy's map
* Add left split ortho 2U board
* Enabled extrakeys for volume & media control
* More work on split ortho 2U...
...but still not complete
* Finish default layout
* Fix many issues by renaming the keyboard
* Add right half as a keyboard
* Update config for right side
* WIP: Add split ortho 2U board
* WIP: Correct rules & config
* More work on split ortho
* More work on split ortho 2u
* Nearing completion on split ortho
* Remove left and right separate keyboards.
Split ortho 2U is complete and they are not needed.
* Add uglydense keyboard
* Rename directory for uglydense
* Swap right Fn and right ctrl keys
* Add jeremy's layout
* Add ian layout
* Add reset key, which is very useful for flashing.
* Add Levi's layout
* Update Levi's layout
* Fix Levi's Layout
* Fix Levi's layout again
* Add a README with some basic information
* Add keymap customization info to uglydense readme
* Make the readme make a little more sense.
* Make John a layout with left fn and left super swapped
* Update John's layout
* Add Carl's layout
* Add Sean's layout
* Add reset keys to all layouts
* Swap LALT & LGUI on default layout
* shpurk keyboard: initial commit
* Add nathaniel & shpurk layouts
* Update instructions to include necesarry dependencies
* Add Lrrr keyboard, ruler of Omicron Persei 8
* Update README for Lrrr
* Update Lrrr it uses Caterina bootloader
Also B1 wasn't working for Row 6, so I changed that to F6
* Swap RCTL & RALT
* Un-swap RCTL and RALT, making RCTL closer to right thumb
* Add printscreen to my layout
* Rename lrrr to Launch, enbiggen L-Shift to 2U
* Add layout files for Launch
* Rename launch to launch_1
* Add levi layout for ortho_split_2u
* Update carl keymap
* Add launch testboard
* Implement keyboard keycode reading using raw hid
* Enable dynamic keymap
* Add config support to launch_1
* Implement probe command, make logical key names match configurator
* Update logical key names again
* Add layout generator for keyboard configurator
* Add board name and version
* Add board name and version to test board
* Fix issues with compiling board and version commands
* Rename uglydense to launch_alpha_1 and launch_1 to launch_alpha_2
* Generate layouts for other launch prototypes
* Fix launch_alpha_1 logical names
* Add launch_beta_1
* Fix building production hex file with atmel-dfu bootloader
* Limit backlight brightness
* USB mux handling
* Allow repeat start
* Do USB MUX init before bootmagic
* Fixes for mux init
* Fix register write size for programmable function control
* Ensure bit shifts are correct
* Improve documentation
* Fix when i2c read ack condition happens
* Fix extra start in i2c_set
* Add ISP instructions
* Add fuse information
* Refactor
* Add RGB matrix support
* Fix RGB matrix
* Update Jeremy layout
* Enable audio controls
* Update Jeremy layout
* Ensure that n-key rollover is used
* Port changes to other launch boards
* Configuration values for starting HSV and speed (#7740)
* Define default HSV and speed for RGB matrix.
* Documentation for configuration values RGB_MATRIX_STARTUP_HUE, RGB_MATRIX_STARTUP_SAT and RGB_MATRIX_STARTUP_VAL.
* Document RGB_MATRIX_STARTUP_SPD.
* Preserve the ordering.
* Set default RGB mode, hue, and saturation
* Reduce AVR clock to 8MHz
* Update launch_beta_1 with new USB ID
* Update default LED mode
* Set default hue
* Disable RGB while suspended
* Add led value and color commands
* Add max value to CMD_LED_GET_VALUE
* Do not save custom mode to eeprom
* Add reset to bootloader command for Launch keyboard
* Rename launch_beta_1 to launch_1
* Enable LTO when compiling for launch_1
* Allow setting individual LED's
* Convert tabs to spaces
* Unlock on RESET keypress:
- Display unlock pattern
- Disable LED get/set functions
- Enable reset to bootloader function
* Reduce brightness of rainbow backdrop in unlock pattern
* Add hid commands for setting led matrix mode
This changes the color setting to not change the mode, and set the hue
and saturation for QMK effects.
* Fix `CMD_LED_GET_MODE`
* Add Levi's Launch layout
* Fix layer mistake in Levi's Launch layout
* Add matrix command
* Define default RGB matrix speed
* Add active_keys effect
* Move definition of RGB modes inside ifdef testing for custom RGB modes
* RGB parameters per layer
* fix: Call `system76_ec_rgb_layer` after setting mode
* Include layer 3 and 4 in default layout for launch_1
I added support for layer 3 and 4 to the Configurator, but it seems to
load bogus values.
`dynamic_keymap_reset()` has a comment saying:
```
// 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
```
Other keyboards seem to have default layouts that only list the first
two layers while setting `DYNAMIC_KEYMAP_LAYER_COUNT` to 4, but
whatever. This appears to make the Configurator behave as expected with
layer 3 and 4.
* Use EEPROM to store RGB parameters
* Add layer 2 and 3 to other keymaps
* Add LED_SAVE command
* Use eeprom_update_block to improve performance
* Revert "Configuration values for starting HSV and speed (#7740)"
This reverts commit de1f60fd370b4769336b8a707ee12657aee46412.
* Update launch_1 rules.mk for changes in Qmk
* WIP keycodes matching EC behavior
* Modify default layout to match design
* Apply updates to jeremy layout
* Improvements to RGB keycodes
* system76_ec: Add mode to disable layer backlight
* launch_1: Use `KC_NO` instead of `KC_TRNS` for default layout
* Revert "launch_1: Use `KC_NO` instead of `KC_TRNS` for default layout"
This reverts commit f71c5e7ac3cecbbb1a1f8934db1f329407fef041.
* Fix building bootloader
* Workaround for upstream orientation
* Custom USB IDs for USB hubs, disable USB hub feature controller
* Set USB mux orientation in a loop for one second
* Set mux orientation 100 times with 10 ms delay
* Update Jeremy's keymap
* Update Levi's Launch keymap
* Update flashing instructions and rewrite layout design instructions
* Update README.md
* Add a system76_ec command to disable input events
For testing purposes.
* Enable system76/launch_1 keyboard to work with QMK Firmware 0.15.3
- Migrate system76/launch_1 from 0.7.103:
- Explicitly enable used RGB matrix effects
- Initialize flags field of `rgb_config_t` union/struct
- Account for header and source file location changes
- Update AVR platform makefile with Atmel DFU bootloader option
- Update ATmega32U4 bootloader to latest from Microchip
- Format C sources with ClangFormat
- Format Markdown text with Prettier
* Remove System76 pre-release or test keyboards and keymaps
* Add licensing and replace guards in headers for system76/launch_1
* Remove options impact for system76/launch_1
* Revert AVR platform changes for `atmel-dfu` bootloader
* Update system76/launch_1 README
* Add system76/launch_1 information JSON file
* Replace `util/delay.h` timing abstractions in system76/launch_1
* Use I2C QMK abstractions in system76/launch_1
* Fully revert AVR platform changes for `atmel-dfu` bootloader
* Move `layouts.sh` into `keyboards/system76`
* Implement GitHub PR suggestions for system76/launch_1
* Make additional system76/launch_1 updates
* Implement minor system76/launch_1 change requests
* Add custom version of Bootmagic Lite and document fuse values for system76/launch_1
* Remove the RESET HID command from system76/launch_1
* Reorder `process_record_user` in system76/launch_1
* Add `post_rules.mk` to system76/launch_1
* Fix overlapping key in sytem76/launch_1
Diffstat (limited to 'keyboards/system76')
-rw-r--r-- | keyboards/system76/launch_1/config.h | 121 | ||||
-rw-r--r-- | keyboards/system76/launch_1/info.json | 94 | ||||
-rw-r--r-- | keyboards/system76/launch_1/keymaps/default/keymap.c | 104 | ||||
-rw-r--r-- | keyboards/system76/launch_1/launch_1.c | 240 | ||||
-rw-r--r-- | keyboards/system76/launch_1/launch_1.h | 38 | ||||
-rw-r--r-- | keyboards/system76/launch_1/post_rules.mk | 12 | ||||
-rw-r--r-- | keyboards/system76/launch_1/readme.md | 62 | ||||
-rw-r--r-- | keyboards/system76/launch_1/rgb_matrix_kb.inc | 157 | ||||
-rw-r--r-- | keyboards/system76/launch_1/rules.mk | 33 | ||||
-rw-r--r-- | keyboards/system76/launch_1/usb_mux.c | 478 | ||||
-rw-r--r-- | keyboards/system76/launch_1/usb_mux.h | 21 | ||||
-rwxr-xr-x | keyboards/system76/layouts.sh | 75 | ||||
-rw-r--r-- | keyboards/system76/readme.md | 5 | ||||
-rw-r--r-- | keyboards/system76/system76_ec.c | 416 |
14 files changed, 1856 insertions, 0 deletions
diff --git a/keyboards/system76/launch_1/config.h b/keyboards/system76/launch_1/config.h new file mode 100644 index 0000000000..19752d58de --- /dev/null +++ b/keyboards/system76/launch_1/config.h @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2021 System76 + * + * 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 3 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 <https://www.gnu.org/licenses/>. + */ + +#pragma once + +#include "config_common.h" + +// USB device descriptor parameter +#define VENDOR_ID 0x3384 +#define PRODUCT_ID 0x0001 +#define DEVICE_VER 0x0001 +#define MANUFACTURER System76 +#define PRODUCT Launch Configurable Keyboard (launch_1) + +// Key matrix size +#define MATRIX_ROWS 6 +#define MATRIX_COLS 14 + +/* + * Key matrix pins + * ROWS: AVR pins used for rows, top to bottom + * COLS: AVR pins used for columns, left to right + */ +#define MATRIX_ROW_PINS { F0, F1, F4, F5, F6, F7 } +#define MATRIX_COL_PINS { D7, C7, C6, B6, B5, B4, D6, D4, E6, D5, D3, D2, B7, B0 } +#define UNUSED_PINS + +/* + * Diode Direction + * COL2ROW = COL => Anode (+), ROW => Cathode (-) + * ROW2COL = ROW => Anode (+), COL => Cathode (-) + */ +#define DIODE_DIRECTION COL2ROW + +// Set 0 if debouncing isn't needed +#define DEBOUNCE 5 + +#ifdef RGB_MATRIX_ENABLE +# define RGB_DI_PIN E2 +# define DRIVER_LED_TOTAL 84 +# define RGB_MATRIX_KEYPRESSES // Reacts to keypresses +// # define RGB_MATRIX_KEYRELEASES // Reacts to keyreleases (instead of keypresses) +// # define RGB_MATRIX_FRAMEBUFFER_EFFECTS // Enables framebuffer effects +# define RGB_DISABLE_TIMEOUT 0 // Number of milliseconds to wait until RGB automatically turns off +# define RGB_DISABLE_AFTER_TIMEOUT 0 // OBSOLETE: Number of ticks to wait until disabling effects +# define RGB_DISABLE_WHEN_USB_SUSPENDED // Turns off effects when suspended +// Limit brightness to support USB-A at 0.5 A +// TODO: Do this dynamically based on power source +# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 176 // Limits maximum brightness of LEDs to 176 out of 255. If not defined, maximum brightness is set to 255 +# define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_RAINBOW_MOVING_CHEVRON // Sets the default mode, if none has been set +# define RGB_MATRIX_STARTUP_HUE 142 // Sets the default hue value, if none has been set +# define RGB_MATRIX_STARTUP_SAT 255 // Sets the default saturation value, if none has been set +# define RGB_MATRIX_STARTUP_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS // Sets the default brightness value, if none has been set +# define RGB_MATRIX_STARTUP_SPD 127 // Sets the default animation speed, if none has been set +# define RGB_MATRIX_DISABLE_KEYCODES // Disables control of rgb matrix by keycodes (must use code functions to control the feature) + +# define ENABLE_RGB_MATRIX_CYCLE_ALL +# define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT +# define ENABLE_RGB_MATRIX_CYCLE_UP_DOWN +# define ENABLE_RGB_MATRIX_CYCLE_OUT_IN +# define ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL +# define ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON +# define ENABLE_RGB_MATRIX_CYCLE_PINWHEEL +# define ENABLE_RGB_MATRIX_CYCLE_SPIRAL +# define ENABLE_RGB_MATRIX_RAINDROPS +# define ENABLE_RGB_MATRIX_SPLASH +# define ENABLE_RGB_MATRIX_MULTISPLASH +#endif // RGB_MATRIX_ENABLE + +// 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 + +// I2C { +#define F_SCL 100000UL // Run I2C bus at 100 kHz +#define I2C_START_RETRY_COUNT 20 +#define I2C_TIMEOUT 100 // milliseconds +// } I2C + +// EEPROM { +#define EEPROM_SIZE 1024 +// TODO: Refactor with new user EEPROM code (coming soon) +#define EEPROM_MAGIC 0x76EC +#define EEPROM_MAGIC_ADDR 64 +// 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 0x02 +#define EEPROM_VERSION_ADDR (EEPROM_MAGIC_ADDR + 2) +// } EEPROM + +// Dynamic keymap { +#define DYNAMIC_KEYMAP_LAYER_COUNT 4 +#define DYNAMIC_KEYMAP_MACRO_COUNT 0 +// Dynamic keymap starts after EEPROM version +#define DYNAMIC_KEYMAP_EEPROM_ADDR (EEPROM_VERSION_ADDR + 1) +// Dynamic macro starts after dynamic keymaps, it is disabled +#define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR (DYNAMIC_KEYMAP_EEPROM_ADDR + (DYNAMIC_KEYMAP_LAYER_COUNT * MATRIX_ROWS * MATRIX_COLS * 2)) +#define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 0 +// } Dynamic keymap + +// System76 EC { +#define SYSTEM76_EC_EEPROM_ADDR (DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE) +#define SYSTEM76_EC_EEPROM_SIZE (EEPROM_SIZE - SYSTEM76_EC_EEPROM_ADDR) +// } System76 EC diff --git a/keyboards/system76/launch_1/info.json b/keyboards/system76/launch_1/info.json new file mode 100644 index 0000000000..10d39cc758 --- /dev/null +++ b/keyboards/system76/launch_1/info.json @@ -0,0 +1,94 @@ +{ + "keyboard_name": "System76 Launch Configurable Keyboard (launch_1)", + "url": "https://system76.com/accessories/launch", + "layouts": { + "LAYOUT": { + "layout": [ + { "label": "Esc", "x": 0, "y": 0 }, + { "label": "F1", "x": 1, "y": 0 }, + { "label": "F2", "x": 2, "y": 0 }, + { "label": "F3", "x": 3, "y": 0 }, + { "label": "F4", "x": 4, "y": 0 }, + { "label": "F5", "x": 5, "y": 0 }, + { "label": "F6", "x": 6, "y": 0 }, + { "label": "F7", "x": 7, "y": 0 }, + { "label": "F8", "x": 8, "y": 0 }, + { "label": "F9", "x": 9, "y": 0 }, + { "label": "F10", "x": 10, "y": 0 }, + { "label": "F11", "x": 11, "y": 0 }, + { "label": "F12", "x": 12, "y": 0 }, + { "label": "Del", "x": 13, "y": 0, "w": 1.5 }, + { "label": "Home", "x": 14.75, "y": 0 }, + { "label": "`", "x": 0, "y": 1 }, + { "label": "1", "x": 1, "y": 1 }, + { "label": "2", "x": 2, "y": 1 }, + { "label": "3", "x": 3, "y": 1 }, + { "label": "4", "x": 4, "y": 1 }, + { "label": "5", "x": 5, "y": 1 }, + { "label": "6", "x": 6, "y": 1 }, + { "label": "7", "x": 7, "y": 1 }, + { "label": "8", "x": 8, "y": 1 }, + { "label": "9", "x": 9, "y": 1 }, + { "label": "0", "x": 10, "y": 1 }, + { "label": "-", "x": 11, "y": 1 }, + { "label": "=", "x": 12, "y": 1 }, + { "label": "Bksp", "x": 13, "y": 1, "w": 1.5 }, + { "label": "PgUp", "x": 14.75, "y": 1 }, + { "label": "Tab", "x": 0, "y": 2, "w": 1.5 }, + { "label": "Q", "x": 1.5, "y": 2 }, + { "label": "W", "x": 2.5, "y": 2 }, + { "label": "E", "x": 3.5, "y": 2 }, + { "label": "R", "x": 4.5, "y": 2 }, + { "label": "T", "x": 5.5, "y": 2 }, + { "label": "Y", "x": 6.5, "y": 2 }, + { "label": "U", "x": 7.5, "y": 2 }, + { "label": "I", "x": 8.5, "y": 2 }, + { "label": "O", "x": 9.5, "y": 2 }, + { "label": "P", "x": 10.5, "y": 2 }, + { "label": "[", "x": 11.5, "y": 2 }, + { "label": "]", "x": 12.5, "y": 2 }, + { "label": "\\", "x": 13.5, "y": 2 }, + { "label": "PgDn", "x": 14.75, "y": 2 }, + { "label": "Caps", "x": 0.25, "y": 3, "w": 1.5 }, + { "label": "A", "x": 1.75, "y": 3 }, + { "label": "S", "x": 2.75, "y": 3 }, + { "label": "D", "x": 3.75, "y": 3 }, + { "label": "F", "x": 4.75, "y": 3 }, + { "label": "G", "x": 5.75, "y": 3 }, + { "label": "H", "x": 6.75, "y": 3 }, + { "label": "J", "x": 7.75, "y": 3 }, + { "label": "K", "x": 8.75, "y": 3 }, + { "label": "L", "x": 9.75, "y": 3 }, + { "label": ";", "x": 10.75, "y": 3 }, + { "label": "'", "x": 11.75, "y": 3 }, + { "label": "Enter", "x": 12.75, "y": 3, "w": 1.5 }, + { "label": "End", "x": 14.75, "y": 3 }, + { "label": "LShift", "x": 0.25, "y": 4, "w": 2 }, + { "label": "Z", "x": 2.25, "y": 4 }, + { "label": "X", "x": 3.25, "y": 4 }, + { "label": "C", "x": 4.25, "y": 4 }, + { "label": "V", "x": 5.25, "y": 4 }, + { "label": "B", "x": 6.25, "y": 4 }, + { "label": "N", "x": 7.25, "y": 4 }, + { "label": "M", "x": 8.25, "y": 4 }, + { "label": ",", "x": 9.25, "y": 4 }, + { "label": ".", "x": 10.25, "y": 4 }, + { "label": "/", "x": 11.25, "y": 4 }, + { "label": "RShift", "x": 12.25, "y": 4, "w": 1.5 }, + { "label": "Up", "x": 13.75, "y": 4 }, + { "label": "LCtrl", "x": 0.25, "y": 5, "w": 1.5 }, + { "label": "LAlt", "x": 1.75, "y": 5 }, + { "label": "LFn", "x": 2.75, "y": 5 }, + { "label": "Super", "x": 3.75, "y": 5 }, + { "label": "Space", "x": 4.75, "y": 5, "w": 2 }, + { "label": "Space", "x": 6.75, "y": 5, "w": 2 }, + { "label": "RCtrl", "x": 8.75, "y": 5 }, + { "label": "RAlt", "x": 9.75, "y": 5 }, + { "label": "RFn", "x": 10.75, "y": 5, "w": 1.5 }, + { "label": "Left", "x": 12.75, "y": 5 }, + { "label": "Down", "x": 13.75, "y": 5 }, + { "label": "Right", "x": 14.75, "y": 5 } + ] + } + } +} diff --git a/keyboards/system76/launch_1/keymaps/default/keymap.c b/keyboards/system76/launch_1/keymaps/default/keymap.c new file mode 100644 index 0000000000..f9f86b6584 --- /dev/null +++ b/keyboards/system76/launch_1/keymaps/default/keymap.c @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2021 System76 + * + * 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 3 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 <https://www.gnu.org/licenses/>. + */ + +#include QMK_KEYBOARD_H + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + /* Layer 0, default layer + _________________________________________________________________________________________________________________________________ ________ +| | | | | | | | | | | | | | || | +| ESC | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE || HOME | +|________|________|________|________|________|________|________|________|________|________|________|________|________|____________||________| +| ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | _ | + | || | +| ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | BACKSPACE || PGUP | +|________|________|________|________|________|________|________|________|________|________|________|________|________|____________||________| +| | | | | | | | | | | | [ | ] | | || | +| TAB | Q | W | E | R | T | Y | U | I | O | P | { | } | \ || PGDN | +|____________|________|________|________|________|________|________|________|________|________|________|________|________|________||________| + | | | | | | | | | | | : | " | | | | + | CAPS | A | S | D | F | G | H | J | K | L | ; | ' | ENTER | | END | + |____________|________|________|________|________|________|________|________|________|________|________|________|____________|___|________| + | | | | | | | | | < | > | ? | | | + | SHIFT | Z | X | C | V | B | N | M | , | . | / | SHIFT | UP | + |________________|________|________|________|________|________|________|________|________|________|________|____________|________|________ + | | | | | | | | | | | | | | + | CTRL | LALT | FN | LGUI | SPACE | SPACE | RCTRL | RALT | FN | | LEFT | DOWN | RIGHT | + |____________|________|_______|________|_________________|_________________|________|________|_____________| |________|________|________| + */ + + [0] = LAYOUT( + KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_HOME, + KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_PGUP, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGDN, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_END, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, + KC_LCTL, KC_LALT, MO(1), KC_LGUI, KC_SPC, KC_SPC, KC_RCTL, KC_RALT, MO(1), KC_LEFT, KC_DOWN, KC_RGHT + ), + + /* Layer 1, function layer + _________________________________________________________________________________________________________________________________ ________ +| | | | | | | | | | | | | | || PLAY/ | +| RESET | | | | | | | | | | | | | || PAUSE | +|________|________|________|________|________|________|________|________|________|________|________|________|________|____________||________| +| | | | | | | | | | | LED | LED | LED | || VOLUME | +| | | | | | | | | | | TOGGLE | DOWN | UP | || UP | +|________|________|________|________|________|________|________|________|________|________|________|________|________|____________||________| +| | | | | | | | | | | | | | || VOLUME | +|PRINT SCREEN| | | | | | HOME | PGDN | PGUP | END | | | | || DOWN | +|____________|________|________|________|________|________|________|________|________|________|________|________|________|________||________| + | | | | | | | | | | | | | | | | + | | | | | | | LEFT | DOWN | UP | RIGHT | | | | | MUTE | + |____________|________|________|________|________|________|________|________|________|________|________|________|____________|___|________| + | | | | | | | | | | | | | | + | | | | | | | | | | | | | PGUP | + |________________|________|________|________|________|________|________|________|________|________|________|____________|________|________ + | | | | | | | | | | | | | | + | | | | | | | | | | | HOME | PGDN | END | + |____________|________|_______|________|_________________|_________________|________|________|_____________| |________|________|________| + + * `RESET' resets the controller and puts the board into firmware flashing mode. + * If this key is hit accidentally, just unplug the board and plug it back in. + */ + + [1] = LAYOUT( + RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_TOG, RGB_VAD, RGB_VAI, KC_TRNS, KC_VOLU, + KC_PSCR, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_PGDN, KC_PGUP, KC_END, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_VOLD, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_MUTE, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_PGDN, KC_END + ), + + [2] = LAYOUT( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + 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( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ), +}; diff --git a/keyboards/system76/launch_1/launch_1.c b/keyboards/system76/launch_1/launch_1.c new file mode 100644 index 0000000000..0250b9d9cc --- /dev/null +++ b/keyboards/system76/launch_1/launch_1.c @@ -0,0 +1,240 @@ +/* + * Copyright (C) 2021 System76 + * + * 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 3 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 <https://www.gnu.org/licenses/>. + */ + +#include "launch_1.h" + +#include "usb_mux.h" + +// clang-format off +#ifdef RGB_MATRIX_ENABLE +// LEDs by index +// 0 1 2 3 4 5 6 7 8 9 +// 00 LM4 LL4 LK4 LJ4 LI4 LH4 LG4 LF4 LE4 LD4 +// 10 LC4 LB4 LA4 LA5 LB5 LC5 LD5 LE5 LG5 LH5 +// 20 LI5 LJ5 LK5 LL5 LM5 LO3 LM3 LL3 LK3 LJ3 +// 30 LI3 LH3 LG3 LF3 LE3 LD3 LC3 LB3 LA3 LA2 +// 40 LB2 LC2 LD2 LE2 LF2 LG2 LH2 LI2 LJ2 LK2 +// 50 LL2 LM2 LN2 LO2 LO1 LN1 LM1 LL1 LK1 LJ1 +// 60 LI1 LH1 LG1 LF1 LE1 LD1 LC1 LB1 LA1 LA0 +// 70 LB0 LC0 LD0 LE0 LF0 LG0 LH0 LI0 LJ0 LK0 +// 80 LL0 LM0 LN0 LO0 +led_config_t g_led_config = { LAYOUT( + // Key matrix to LED index + /* A B C D E F G H I J K L M N O */ +/* 0 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, +/* 1 */ 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, +/* 2 */ 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, +/* 3 */ 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, +/* 4 */ 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, +/* 5 */ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 +), { + // LED index to physical position (see leds.sh in `launch' repo) +/* 00 */ {209, 51}, {190, 51}, {171, 51}, {156, 51}, {140, 51}, {125, 51}, {110, 51}, {95, 51}, {80, 51}, {65, 51}, +/* 10 */ {49, 51}, {34, 51}, {11, 51}, {8, 64}, {27, 64}, {42, 64}, {57, 64}, {80, 64}, {110, 64}, {133, 64}, +/* 20 */ {148, 64}, {167, 64}, {194, 64}, {209, 64}, {224, 64}, {224, 38}, {197, 38}, {178, 38}, {163, 38}, {148, 38}, +/* 30 */ {133, 38}, {118, 38}, {103, 38}, {87, 38}, {72, 38}, {57, 38}, {42, 38}, {27, 38}, {8, 38}, {4, 26}, +/* 40 */ {23, 26}, {38, 26}, {53, 26}, {68, 26}, {84, 26}, {99, 26}, {114, 26}, {129, 26}, {144, 26}, {159, 26}, +/* 50 */ {175, 26}, {190, 26}, {205, 26}, {224, 26}, {224, 13}, {201, 13}, {182, 13}, {167, 13}, {152, 13}, {137, 13}, +/* 60 */ {121, 13}, {106, 13}, {91, 13}, {76, 13}, {61, 13}, {46, 13}, {30, 13}, {15, 13}, {0, 13}, {0, 0}, +/* 70 */ {15, 0}, {30, 0}, {46, 0}, {61, 0}, {76, 0}, {91, 0}, {106, 0}, {121, 0}, {137, 0}, {152, 0}, +/* 80 */ {167, 0}, {182, 0}, {201, 0}, {224, 0} +}, { + // LED index to flags (set all to LED_FLAG_KEYLIGHT) + /* 0 1 2 3 4 5 6 7 8 9 */ +/* 00 */ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, +/* 10 */ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, +/* 20 */ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, +/* 30 */ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, +/* 40 */ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, +/* 50 */ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, +/* 60 */ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, +/* 70 */ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, +/* 80 */ 4, 4, 4, 4 +} }; +#endif // RGB_MATRIX_ENABLE + +bool eeprom_is_valid(void) { + return ( + eeprom_read_word(((void *)EEPROM_MAGIC_ADDR)) == EEPROM_MAGIC && + eeprom_read_byte(((void *)EEPROM_VERSION_ADDR)) == EEPROM_VERSION + ); +} +// clang-format on + +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 bootmagic_lite_reset_eeprom(void) { + // Set the keyboard-specific EEPROM state as invalid + eeprom_set_valid(false); + // Set the TMK/QMK EEPROM state as invalid + eeconfig_disable(); +} + +// The lite version of TMK's bootmagic based on Wilba. +// 100% less potential for accidentally making the keyboard do stupid things. +void bootmagic_lite(void) { + // Perform multiple scans because debouncing can't be turned off. + matrix_scan(); +#if defined(DEBOUNCE) && DEBOUNCE > 0 + wait_ms(DEBOUNCE * 2); +#else + wait_ms(30); +#endif + matrix_scan(); + + // If the configured key (commonly Esc) is held down on power up, + // reset the EEPROM valid state and jump to bootloader. + uint8_t row = 0; // BOOTMAGIC_LITE_ROW; + uint8_t col = 0; // BOOTMAGIC_LITE_COLUMN; + + if (matrix_get_row(row) & (1 << col)) { + bootmagic_lite_reset_eeprom(); + + // Jump to bootloader. + bootloader_jump(); + } +} + +void system76_ec_rgb_eeprom(bool write); +void system76_ec_rgb_layer(layer_state_t layer_state); +void system76_ec_unlock(void); +bool system76_ec_is_unlocked(void); + +rgb_config_t layer_rgb[DYNAMIC_KEYMAP_LAYER_COUNT]; + +void matrix_init_kb(void) { + usb_mux_init(); + + bootmagic_lite(); + if (!eeprom_is_valid()) { + dynamic_keymap_reset(); + dynamic_keymap_macro_reset(); + system76_ec_rgb_eeprom(true); + eeprom_set_valid(true); + } else { + system76_ec_rgb_eeprom(false); + } + + system76_ec_rgb_layer(layer_state); +} + +void matrix_scan_kb(void) { + usb_mux_event(); + + matrix_scan_user(); +} + +#define LEVEL(value) (uint8_t)(((uint16_t)value) * ((uint16_t)RGB_MATRIX_MAXIMUM_BRIGHTNESS) / ((uint16_t)255)) + +// clang-format off +static const uint8_t levels[] = { + LEVEL(48), + LEVEL(72), + LEVEL(96), + LEVEL(144), + LEVEL(192), + LEVEL(255) +}; +// clang-format on + +static uint8_t toggle_level = RGB_MATRIX_MAXIMUM_BRIGHTNESS; +extern bool input_disabled; + +static void set_value_all_layers(uint8_t value) { + if (!system76_ec_is_unlocked()) { + for (int8_t layer = 0; layer < DYNAMIC_KEYMAP_LAYER_COUNT; layer++) { + layer_rgb[layer].hsv.v = value; + } + system76_ec_rgb_layer(layer_state); + } +} + +bool process_record_kb(uint16_t keycode, keyrecord_t *record) { + if (input_disabled) { + return false; + } + + if (!process_record_user(keycode, record)) { + return false; + } + + switch (keycode) { + case RESET: + if (record->event.pressed) { + system76_ec_unlock(); + } +#ifdef SYSTEM76_EC + return false; +#else + return true; +#endif + case RGB_VAD: + if (record->event.pressed) { + uint8_t level = rgb_matrix_config.hsv.v; + for (int i = sizeof(levels) - 1; i >= 0; i--) { + if (levels[i] < level) { + level = levels[i]; + break; + } + } + set_value_all_layers(level); + } + return false; + case RGB_VAI: + if (record->event.pressed) { + uint8_t level = rgb_matrix_config.hsv.v; + for (int i = 0; i < sizeof(levels); i++) { + if (levels[i] > level) { + level = levels[i]; + break; + } + } + set_value_all_layers(level); + } + return false; + case RGB_TOG: + if (record->event.pressed) { + uint8_t level = 0; + if (rgb_matrix_config.hsv.v == 0) { + level = toggle_level; + } else { + toggle_level = rgb_matrix_config.hsv.v; + } + set_value_all_layers(level); + } + return false; + } + + return true; +} + +layer_state_t layer_state_set_kb(layer_state_t layer_state) { + system76_ec_rgb_layer(layer_state); + + return layer_state_set_user(layer_state); +} + +#ifdef CONSOLE_ENABLE +void keyboard_post_init_user(void) { + debug_enable = true; + debug_matrix = false; + debug_keyboard = false; +} +#endif // CONSOLE_ENABLE diff --git a/keyboards/system76/launch_1/launch_1.h b/keyboards/system76/launch_1/launch_1.h new file mode 100644 index 0000000000..335b8ecbdf --- /dev/null +++ b/keyboards/system76/launch_1/launch_1.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2021 System76 + * + * 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 3 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 <https://www.gnu.org/licenses/>. + */ + +#pragma once + +#include "quantum.h" + +// clang-format off +#define LAYOUT( \ + K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, \ + K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, \ + K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \ + K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4B, K4C, \ + K50, K51, K52, K53, K54, K55, K56, K57, K58, K59, K5A, K5B \ +) { \ + { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D }, \ + { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D }, \ + { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D }, \ + { K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K0E }, \ + { K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4B, K4C, K1E }, \ + { K50, K51, K52, K53, K54, K3D, K55, K56, K57, K5 |