diff options
Diffstat (limited to 'keyboards/system76')
-rw-r--r-- | keyboards/system76/launch_1/config.h | 29 | ||||
-rw-r--r-- | keyboards/system76/launch_1/info.json | 23 | ||||
-rw-r--r-- | keyboards/system76/launch_1/usb_mux.c | 81 |
3 files changed, 38 insertions, 95 deletions
diff --git a/keyboards/system76/launch_1/config.h b/keyboards/system76/launch_1/config.h index 27e3025fe3..986a4db76e 100644 --- a/keyboards/system76/launch_1/config.h +++ b/keyboards/system76/launch_1/config.h @@ -17,34 +17,7 @@ #pragma once -#ifdef RGB_MATRIX_ENABLE -# define RGB_MATRIX_LED_COUNT 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_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_DEFAULT_MODE RGB_MATRIX_RAINBOW_MOVING_CHEVRON // Sets the default mode, if none has been set -# define RGB_MATRIX_DEFAULT_HUE 142 // Sets the default hue value, if none has been set -# define RGB_MATRIX_DEFAULT_SAT 255 // Sets the default saturation value, if none has been set -# define RGB_MATRIX_DEFAULT_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS // Sets the default brightness value, if none has been set -# define RGB_MATRIX_DEFAULT_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 +#define RGB_MATRIX_DISABLE_KEYCODES // Disables control of rgb matrix by keycodes (must use code functions to control the feature) // Mechanical locking support; use KC_LCAP, KC_LNUM, or KC_LSCR instead in keymap #define LOCKING_SUPPORT_ENABLE diff --git a/keyboards/system76/launch_1/info.json b/keyboards/system76/launch_1/info.json index eba3a115b8..536b310cc0 100644 --- a/keyboards/system76/launch_1/info.json +++ b/keyboards/system76/launch_1/info.json @@ -11,7 +11,28 @@ "pin": "E2" }, "rgb_matrix": { - "driver": "ws2812" + "animations": { + "cycle_all": true, + "cycle_left_right": true, + "cycle_up_down": true, + "cycle_out_in": true, + "cycle_out_in_dual": true, + "rainbow_moving_chevron": true, + "cycle_pinwheel": true, + "cycle_spiral": true, + "raindrops": true, + "splash": true, + "multisplash": true + }, + "default": { + "animation": "rainbow_moving_chevron", + "hue": 142, + "sat": 255, + "speed": 127 + }, + "driver": "ws2812", + "max_brightness": 176, + "sleep": true }, "matrix_pins": { "cols": ["D7", "C7", "C6", "B6", "B5", "B4", "D6", "D4", "E6", "D5", "D3", "D2", "B7", "B0"], diff --git a/keyboards/system76/launch_1/usb_mux.c b/keyboards/system76/launch_1/usb_mux.c index 6cb04dcdd7..dd51b7c4b2 100644 --- a/keyboards/system76/launch_1/usb_mux.c +++ b/keyboards/system76/launch_1/usb_mux.c @@ -77,51 +77,14 @@ i2c_status_t usb7206_read_reg(struct USB7206* self, uint32_t addr, uint8_t* data return status; } - uint8_t read[2] = { - 0x00, // Buffer address MSB: always 0 - 0x06, // Buffer address LSB: 6 to skip header - }; - - status = i2c_start((self->addr << 1) | I2C_WRITE, I2C_TIMEOUT); - if (status >= 0) { - for (uint16_t i = 0; i < sizeof(read); i++) { - status = i2c_write(read[i], I2C_TIMEOUT); - if (status < 0) { - goto error; - } - } - } else { - goto error; - } - - status = i2c_start((self->addr << 1) | I2C_READ, I2C_TIMEOUT); - if (status < 0) { - goto error; - } - - // Read and ignore buffer length - status = i2c_read_ack(I2C_TIMEOUT); - if (status < 0) { - goto error; - } + uint16_t read = 0x0006; // Buffer address 6 to skip header + uint8_t data_with_buffer_length[length]; + status = i2c_readReg16((self->addr << 1), read, data_with_buffer_length, length, I2C_TIMEOUT); for (uint16_t i = 0; i < (length - 1) && status >= 0; i++) { - status = i2c_read_ack(I2C_TIMEOUT); - if (status >= 0) { - data[i] = (uint8_t)status; - } + data[i] = data_with_buffer_length[i+1]; } - if (status >= 0) { - status = i2c_read_nack(I2C_TIMEOUT); - if (status >= 0) { - data[(length - 1)] = (uint8_t)status; - } - } - -error: - i2c_stop(); - return (status < 0) ? status : length; } @@ -160,35 +123,21 @@ i2c_status_t usb7206_write_reg(struct USB7206* self, uint32_t addr, uint8_t* dat (uint8_t)(addr >> 8), // Register address byte 1 (uint8_t)(addr >> 0), // Register address byte 0 }; + uint8_t send_buffer_length = sizeof(register_write) + length; + uint8_t send_buffer[send_buffer_length]; + uint8_t j = 0; - status = i2c_start((self->addr << 1) | I2C_WRITE, I2C_TIMEOUT); - if (status >= 0) { - for (uint16_t i = 0; i < sizeof(register_write); i++) { - status = i2c_write(register_write[i], I2C_TIMEOUT); - if (status < 0) { - goto error; - } - } + for (uint16_t i = 0; i < sizeof(register_write); i++) { + send_buffer[j++] = register_write[i]; + } - for (uint16_t i = 0; i < length; i++) { - status = i2c_write(data[i], I2C_TIMEOUT); - if (status < 0) { - goto error; - } - } - } else { - goto error; + for (uint16_t i = 0; i < length; i++) { + send_buffer[j++] = data[i]; } - i2c_stop(); + status = i2c_transmit((self->addr << 1), send_buffer, send_buffer_length, I2C_TIMEOUT); status = usb7206_register_access(self); - if (status < 0) { - goto error; - } - -error: - i2c_stop(); return (status < 0) ? status : length; } @@ -354,7 +303,7 @@ i2c_status_t ptn5110_init(struct PTN5110* self) { // Read PTN5110 CC_STATUS. // Returns zero on success or a negative number on error. -i2c_status_t ptn5110_get_cc_status(struct PTN5110* self, uint8_t* cc) { return i2c_readReg(self->addr << 1, 0x1D, cc, 1, I2C_TIMEOUT); } +i2c_status_t ptn5110_get_cc_status(struct PTN5110* self, uint8_t* cc) { return i2c_read_register(self->addr << 1, 0x1D, cc, 1, I2C_TIMEOUT); } // Set PTN5110 SSMUX orientation. // Returns zero on success or a negative number on error. @@ -362,7 +311,7 @@ i2c_status_t ptn5110_set_ssmux(struct PTN5110* self, bool orientation) { return // Write PTN5110 COMMAND. // Returns zero on success or negative number on error. -i2c_status_t ptn5110_command(struct PTN5110* self, uint8_t command) { return i2c_writeReg(self->addr << 1, 0x23, &command, 1, I2C_TIMEOUT); } +i2c_status_t ptn5110_command(struct PTN5110* self, uint8_t command) { return i2c_write_register(self->addr << 1, 0x23, &command, 1, I2C_TIMEOUT); } // Set orientation of PTN5110 operating as a sink, call this once. // Returns zero on success or a negative number on error. |