From 2fccc1a0646827d6547cc5e3faa3934c4dd78dce Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Sat, 9 Jun 2018 02:03:32 -0400 Subject: [PATCH] hooked-up keymap/matrix, compiling, not working --- common_features.mk | 12 ++- drivers/arm/twi2c.c | 174 ++++-------------------------- drivers/arm/twi2c.h | 25 ++--- drivers/qwiic/qwiic_keyboard.c | 147 ++++++++++++++++++------- drivers/qwiic/qwiic_keyboard.h | 4 + keyboards/muon_light/config.h | 2 + keyboards/muon_light/halconf.h | 7 ++ keyboards/muon_light/muon_light.c | 152 +++++++++++++------------- keyboards/muon_light/rules.mk | 7 +- tmk_core/common/keyboard.c | 12 ++- 10 files changed, 259 insertions(+), 283 deletions(-) diff --git a/common_features.mk b/common_features.mk index a76c522bfc0..f5fce5441c7 100644 --- a/common_features.mk +++ b/common_features.mk @@ -124,7 +124,7 @@ endif ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes) OPT_DEFS += -DRGB_MATRIX_ENABLE SRC += is31fl3731.c - SRC += twi2c.c + I2C_ENABLE = yes SRC += $(QUANTUM_DIR)/color.c SRC += $(QUANTUM_DIR)/rgb_matrix.c CIE1931_CURVE = yes @@ -205,7 +205,7 @@ ifeq ($(strip $(USB_HID_ENABLE)), yes) endif ifeq ($(strip $(I2C_SLAVE_ENABLE)), yes) - SRC += twi2c.c + I2C_ENABLE = yes OPT_DEFS += -DI2C_SLAVE_ENABLE endif @@ -214,6 +214,14 @@ ifeq ($(strip $(ENCODER_ENABLE)), yes) SRC += $(QUANTUM_DIR)/encoder.c endif +ifeq ($(strip $(QWIIC_KEYBOARD_ENABLE)), yes) + SRC += qwiic/qwiic_keyboard.c + OPT_DEFS += -DQWIIC_KEYBOARD_ENABLE +endif + +ifeq ($(strip $(I2C_ENABLE)), yes) + SRC += twi2c.c +endif QUANTUM_SRC:= \ $(QUANTUM_DIR)/quantum.c \ diff --git a/drivers/arm/twi2c.c b/drivers/arm/twi2c.c index e3bed5db861..a4268d87e4f 100644 --- a/drivers/arm/twi2c.c +++ b/drivers/arm/twi2c.c @@ -20,10 +20,6 @@ #include "chprintf.h" #include "memstreams.h" #include "printf.h" -#include "matrix.h" - -#ifdef I2C_SLAVE_ENABLE - #include "hal_i2cslave.h" /** @@ -41,8 +37,7 @@ // }; I2CSlaveMsgCB twi2c_incoming_message_process, twi2c_catch_error, twi2c_clear_after_send; - -#endif +twi2c_message_received twi2c_message_received_callback; static uint8_t twi2c_address; @@ -54,68 +49,6 @@ static const I2CConfig i2cconfig = { 0 }; -char initialReplyBody[50] = "Initial reply"; // 'Status' response if read without preceding write - - -uint32_t messageCounter = 0; /* Counts number of messages received to return as part of response */ - -uint8_t rxBody[2]; /* stores last message master sent us (intentionally a few bytes smaller than txBody) */ -uint8_t txBody[MATRIX_ROWS/2]; /* Return message buffer for computed replies */ - -BaseSequentialStream *chp = NULL; // Used for serial logging - - -#ifdef I2C_SLAVE_ENABLE - - - - - - - -// Handler when something sent to us -const I2CSlaveMsg echoRx = -{ - sizeof(rxBody), /* max sizeof received msg body */ - rxBody, /* body of received msg */ - NULL, /* do nothing on address match */ - twi2c_slave_message_process, /* Routine to process received messages */ - twi2c_catch_error /* Error hook */ -}; - - -// // 'Empty' reply when nothing to say, and no message received. In RAM, to allow update -I2CSlaveMsg initialReply = -{ - sizeof(initialReplyBody), /* trailing zero byte will be repeated as needed */ - (uint8_t *)initialReplyBody, - NULL, /* do nothing on address match */ - NULL, /* do nothing after reply sent */ - twi2c_catch_error /* Error hook */ -}; - -// // 'Empty' reply when nothing to say, and no message received. In RAM, to allow update -// I2CSlaveMsg initialReply = -// { -// 0, /* trailing zero byte will be repeated as needed */ -// NULL, -// NULL, /* do nothing on address match */ -// NULL, /* do nothing after reply sent */ -// twi2c_catch_error /* Error hook */ -// }; - - -// Response to received messages -I2CSlaveMsg echoReply = { /* this is in RAM so size may be updated */ - MATRIX_ROWS / 2, /* filled in with the length of the message to send */ - txBody, /* Response message */ - NULL, /* do nothing special on address match */ - twi2c_clear_after_send, /* Clear receive buffer once replied */ - twi2c_catch_error /* Error hook */ -}; - - - /** * Track I2C errors */ @@ -129,8 +62,6 @@ void noteI2cError(uint32_t flags) gotI2cError = 1; } - - /** * Generic error handler * @@ -141,31 +72,6 @@ void twi2c_catch_error(I2CDriver *i2cp) noteI2cError(i2cp->errors); } -extern void matrix_copy(matrix_row_t * copy); - -const char hexString[16] = "0123456789abcdef"; - - - -/** - * Message processor - looks at received message, determines reply as quickly as possible - * - * Responds with the value of the messageCounter (in hex), followed by the received message in [..] - * - * Note: Called in interrupt context, so need to be quick! - */ -void twi2c_slave_message_process(I2CDriver *i2cp) { - - // size_t len = i2cSlaveBytes(i2cp); // Number of bytes received - - // memset(txBody, 0, MATRIX_ROWS / 2 * sizeof(matrix_row_t)); - matrix_copy(txBody); - - echoReply.size = MATRIX_ROWS / 2; - i2cSlaveReplyI(i2cp, &echoReply); -} - - /** * Callback after sending of response complete - restores default reply in case polled */ @@ -175,49 +81,7 @@ void twi2c_clear_after_send(I2CDriver *i2cp) // i2cSlaveReplyI(i2cp, &initialReply); } - -/** - * Start the I2C Slave port to accept comms from master CPU - * - * We then go into a loop checking for errors, and never return - */ - -void twi2c_slave_init(twi2c_message_received * cb, uint8_t address) { - - twi2c_init(); - - - i2cStart(&I2C_DRIVER, &i2cconfig); -#if HAL_USE_I2C_SLAVE - I2C_DRIVER.slaveTimeout = MS2ST(100); // Time for complete message -#endif - - // i2cSlaveConfigure(&I2C_DRIVER, &echoRx, &initialReply); - - memset(txBody, 0, MATRIX_ROWS / 2 * sizeof(matrix_row_t)); - - i2cSlaveConfigure(&I2C_DRIVER, &echoRx, &echoReply); - - // Enable match address after everything else set up - i2cMatchAddress(&I2C_DRIVER, address/2); -// i2cMatchAddress(&I2C_DRIVER, myOtherI2Caddress/2); - // i2cMatchAddress(&I2C_DRIVER, 0); /* "all call" */ - - printf("Slave I2C started\n\r"); - -} - -void twi2c_slave_task(void) { - if (gotI2cError) { - gotI2cError = 0; - printf("I2cError: %04x\r\n", lastI2cErrorFlags); - } -} - -#endif - -uint8_t twi2c_start(uint8_t address) { - twi2c_address = address; +uint8_t twi2c_start(void) { i2cStart(&I2C_DRIVER, &i2cconfig); return 0; } @@ -239,12 +103,15 @@ uint8_t twi2c_write(uint8_t data) { return i2cMasterTransmitTimeout(&I2C_DRIVER, twi2c_address/2, &data, 1, 0, 0, MS2ST(100)); } -uint8_t twi2c_transmit(uint8_t address, uint8_t* data, uint16_t length) { - twi2c_address = address; - i2cStart(&I2C_DRIVER, &i2cconfig); - return i2cMasterTransmitTimeout(&I2C_DRIVER, twi2c_address/2, data, length, 0, 0, MS2ST(100)); +uint8_t twi2c_transmit(uint8_t address, uint8_t * data, uint16_t length) { + return i2cMasterTransmitTimeout(&I2C_DRIVER, address/2, data, length, 0, 0, MS2ST(100)); +} + +uint8_t twi2c_receive(uint8_t address, uint8_t * data, uint16_t length) { + return i2cMasterReceiveTimeout(&I2C_DRIVER, address/2, data, length, MS2ST(100)); } + uint8_t twi2c_incoming_body[512]; uint8_t twi2c_outgoing_body[512]; @@ -257,35 +124,40 @@ I2CSlaveMsg twi2c_incoming_message = { twi2c_catch_error /* Error hook */ }; -void twi2c_incoming_message_process(I2CDriver *i2cp) { +void twi2c_incoming_message_process(I2CDriver * i2cp) { size_t len = i2cSlaveBytes(i2cp); - twi2c_message_received_callback(twi2c_incoming_body, len); + (*twi2c_message_received_callback)(i2cp, twi2c_incoming_body, len); } // Response to received messages -I2CSlaveMsg twi2c_outgoing_message = { /* this is in RAM so size may be updated */ - sizeof(twi2c_outgoing_body), /* filled in with the length of the message to send */ +I2CSlaveMsg twi2c_outgoing_message = { + sizeof(twi2c_outgoing_body), twi2c_outgoing_body, NULL, twi2c_clear_after_send, - twi2c_catch_error /* Error hook */ + twi2c_catch_error }; -uint8_t twi2c_reply(uint8_t * data, uint16_t length) { - twi2c_outgoing_body = data; +uint8_t twi2c_reply(I2CDriver * i2cp, uint8_t * data, uint16_t length) { + memcpy(twi2c_outgoing_body, data, length); twi2c_outgoing_message.size = length; i2cSlaveReplyI(i2cp, &twi2c_outgoing_message); + return 0; } -uint8_t twi2c_transmit_receive(uint8_t address, uint8_t * tx_body, uint16_t tx_length, uint8_t rx_body, uint16_t rx_length) { +uint8_t twi2c_transmit_receive(uint8_t address, uint8_t * tx_body, uint16_t tx_length, uint8_t * rx_body, uint16_t rx_length) { return i2cMasterTransmitTimeout(&I2C_DRIVER, address/2, tx_body, tx_length, rx_body, rx_length, MS2ST(100)); } uint8_t twi2c_start_listening(uint8_t address, twi2c_message_received callback) { twi2c_message_received_callback = callback; - i2cStart(&I2C_DRIVER, &i2cconfig); I2C_DRIVER.slaveTimeout = MS2ST(100); i2cSlaveConfigure(&I2C_DRIVER, &twi2c_incoming_message, &twi2c_outgoing_message); i2cMatchAddress(&I2C_DRIVER, address/2); return 0; } + +void twi2c_stop(void) { + i2cUnmatchAll(&I2C_DRIVER); + i2cStop(&I2C_DRIVER); +} diff --git a/drivers/arm/twi2c.h b/drivers/arm/twi2c.h index d3dc2a1572a..047c28e8b0f 100644 --- a/drivers/arm/twi2c.h +++ b/drivers/arm/twi2c.h @@ -14,6 +14,9 @@ * along with this program. If not, see . */ +#ifndef TWI2C_H +#define TWI2C_H + #include "ch.h" #include "hal.h" @@ -23,20 +26,11 @@ #define slaveI2Caddress 0x30 /* Address in our terms - halved by later code */ //#define myOtherI2Caddress 0x19 - -#ifdef I2C_SLAVE_ENABLE - -typedef void twi2c_message_received(uint8_t * body, uint16_t size); -twi2c_message_received twi2c_message_received_callback; - -I2CSlaveMsgCB twi2c_slave_message_process, catchError, clearAfterSend; - -void twi2c_slave_init(void); - -#endif +I2CSlaveMsgCB twi2c_incoming_message_process, twi2c_catch_error, twi2c_clear_after_send; +typedef void (*twi2c_message_received)(I2CDriver *, uint8_t *, uint16_t); void twi2c_init(void); -uint8_t twi2c_start(uint8_t address); +uint8_t twi2c_start(void); uint8_t twi2c_write(uint8_t data); uint8_t twi2c_read_ack(void); uint8_t twi2c_read_nack(void); @@ -45,6 +39,9 @@ uint8_t twi2c_receive(uint8_t address, uint8_t* data, uint16_t length); uint8_t twi2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length); uint8_t twi2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length); void twi2c_stop(void); -uint8_t twi2c_reply(uint8_t * data, uint16_t length); -uint8_t twi2c_transmit_receive(uint8_t address, uint8_t * tx_body, uint16_t tx_length, uint8_t rx_body, uint16_t rx_length); + +uint8_t twi2c_reply(I2CDriver * i2cp, uint8_t * data, uint16_t length); +uint8_t twi2c_transmit_receive(uint8_t address, uint8_t * tx_body, uint16_t tx_length, uint8_t * rx_body, uint16_t rx_length); uint8_t twi2c_start_listening(uint8_t address, twi2c_message_received callback); + +#endif diff --git a/drivers/qwiic/qwiic_keyboard.c b/drivers/qwiic/qwiic_keyboard.c index b9e01a7f03d..d6e2357c964 100644 --- a/drivers/qwiic/qwiic_keyboard.c +++ b/drivers/qwiic/qwiic_keyboard.c @@ -17,82 +17,141 @@ #include "qwiic_keyboard.h" #include "keymap.h" #include "matrix.h" +#include "keyboard.h" +#include "twi2c.h" +#include +#include "usb_main.h" +#include "usb_driver.h" #define QWIIC_KEYBOARD_LAYERS 16 #define QWIIC_KEYBOARD_ROWS 8 #define QWIIC_KEYBOARD_COLS 8 -#define QWIIC_KEYBOARD_HANDSHAKE_ADDRESS 0b01010100 +#define qwiic_matrix_t uint8_t + +#define QWIIC_KEYBOARD_HANDSHAKE_ADDRESS 0b01010100 #define QWIIC_KEYBOARD_LISTENING_ADDRESS_START 0b01010110 -#define QWIIC_KEYBOARD_HANDSHAKE_MESSAGE_SIZE (2 + (QWIIC_KEYBOARD_LAYERS * QWIIC_KEYBOARD_ROWS * QWIIC_KEYBOARD_COLS)) -#define QWIIC_KEYBOARD_MATRIX_MESSAGE_SIZE MATRIX_ROWS +#define QWIIC_KEYBOARD_HANDSHAKE_MESSAGE_SIZE (QWIIC_KEYBOARD_LAYERS * QWIIC_KEYBOARD_ROWS * QWIIC_KEYBOARD_COLS) +#define QWIIC_KEYBOARD_MATRIX_MESSAGE_SIZE MATRIX_ROWS + +void qwiic_keyboard_write_keymap(uint8_t * pointer); +void qwiic_keyboard_read_keymap(uint8_t * pointer); bool qwiic_keyboard_master = false; bool qwiic_keyboard_connected = false; -uint8_t * qwiic_keyboard_handshake_message = {0}; -uint8_t * qwiic_keyboard_matrix_message[QWIIC_KEYBOARD_ROWS] = {0}; +uint8_t qwiic_keyboard_handshake_message[QWIIC_KEYBOARD_HANDSHAKE_MESSAGE_SIZE] = {0}; +uint8_t qwiic_keyboard_matrix_message[QWIIC_KEYBOARD_ROWS] = {0}; +twi2c_message_received qwiic_keyboard_message_received_ptr = qwiic_keyboard_message_received; uint16_t qwiic_keyboard_keymap[QWIIC_KEYBOARD_LAYERS][QWIIC_KEYBOARD_ROWS][QWIIC_KEYBOARD_COLS] = {0}; uint8_t qwiic_keyboard_new_listening_address = QWIIC_KEYBOARD_LISTENING_ADDRESS_START; uint8_t qwiic_keyboard_listening_address = QWIIC_KEYBOARD_LISTENING_ADDRESS_START; -uint8_t qwiic_keyboard_matrix_rows; -uint8_t qwiic_keyboard_matrix_cols; +uint8_t qwiic_keyboard_processing_slave = false; -void qwiic_keyboard_setup(void) { - twi2c_start_listening(qwiic_keyboard_listening_address, qwiic_keyboard_message_received); +void qwiic_keyboard_init(void) { + twi2c_init(); + twi2c_start(); + twi2c_start_listening(qwiic_keyboard_listening_address, qwiic_keyboard_message_received_ptr); } -void qwiic_keyboard_set_master() { +void qwiic_keyboard_set_master(void) { twi2c_stop(); + twi2c_start(); qwiic_keyboard_master = true; } void qwiic_keyboard_task(void) { + if (USB_DRIVER.state == USB_ACTIVE) + qwiic_keyboard_master = true; + else + qwiic_keyboard_master = false; if (qwiic_keyboard_master) { if (qwiic_keyboard_connected) { - if (MSG_OK == twi2c_transmit_receive(qwiic_keyboard_listening_address, - NULL, 0, + // send empty message, expecting matrix info + twi2c_transmit(qwiic_keyboard_listening_address, NULL, 0); + if (MSG_OK == twi2c_receive(qwiic_keyboard_listening_address, qwiic_keyboard_matrix_message, QWIIC_KEYBOARD_MATRIX_MESSAGE_SIZE )) { - // process key event + // majority of this is pulled from keyboard.c:keyboard_task() + static qwiic_matrix_t matrix_prev[QWIIC_KEYBOARD_ROWS]; + qwiic_matrix_t matrix_row = 0; + qwiic_matrix_t matrix_change = 0; + qwiic_keyboard_processing_slave = true; + SEND_STRING("K."); + for (uint8_t r = 0; r < QWIIC_KEYBOARD_ROWS; r++) { + matrix_row = qwiic_keyboard_matrix_message[r]; + matrix_change = matrix_row ^ matrix_prev[r]; + if (matrix_change) { + for (uint8_t c = 0; c < MATRIX_COLS; c++) { + if (matrix_change & ((qwiic_matrix_t)1<= QMK_KEYS_PER_SCAN) + #endif + // process a key per task call + goto MATRIX_LOOP_END; + } + } + } + } + // call with pseudo tick event when no real key event. + #ifdef QMK_KEYS_PER_SCAN + // we can get here with some keys processed now. + if (!keys_processed) + #endif + action_exec(TICK); + MATRIX_LOOP_END: + qwiic_keyboard_processing_slave = false; } else { // disconnect + // qwiic_keyboard_connected = false; + } + } else { + // send new address to listen on, expect back keymap + twi2c_transmit(QWIIC_KEYBOARD_HANDSHAKE_ADDRESS, &qwiic_keyboard_new_listening_address, 1); + if (MSG_OK == twi2c_receive(QWIIC_KEYBOARD_HANDSHAKE_ADDRESS, + qwiic_keyboard_handshake_message, QWIIC_KEYBOARD_HANDSHAKE_MESSAGE_SIZE + )) { + qwiic_keyboard_connected = true; + // increment address (for future implemenations of supporting multiple devices) + qwiic_keyboard_new_listening_address+=2; + // load keymap into memory + qwiic_keyboard_read_keymap(qwiic_keyboard_handshake_message); } - } - if (MSG_OK == twi2c_transmit_receive(QWIIC_KEYBOARD_HANDSHAKE_ADDRESS, - qwiic_keyboard_new_listening_address, 1, - qwiic_keyboard_handshake_message, QWIIC_KEYBOARD_HANDSHAKE_MESSAGE_SIZE - )) { - qwiic_keyboard_new_listening_address+=2; - uint8_t * message_pointer = qwiic_keyboard_handshake_message; - qwiic_keyboard_matrix_rows = *message_pointer++; - qwiic_keyboard_matrix_cols = *message_pointer++; - qwiic_keyboard_read_keymap(message_pointer); } } } -twi2c_message_received qwiic_keyboard_message_received; -extern matrix_row_t matrix[MATRIX_ROWS]; -uint8_t * qwiic_keyboard_reply; +uint8_t qwiic_keyboard_reply[MATRIX_ROWS]; -void qwiic_keyboard_message_received(uint8_t * body, uint16_t size) { +void qwiic_keyboard_message_received(I2CDriver *i2cp, uint8_t * body, uint16_t size) { if (qwiic_keyboard_connected) { - memcpy(qwiic_keyboard_reply, matrix, QWIIC_KEYBOARD_MATRIX_MESSAGE_SIZE); - twi2c_reply(qwiic_keyboard_reply, QWIIC_KEYBOARD_MATRIX_MESSAGE_SIZE); + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + qwiic_keyboard_reply[row] = matrix_get_row(row); + } + twi2c_reply(i2cp, qwiic_keyboard_reply, QWIIC_KEYBOARD_MATRIX_MESSAGE_SIZE); } else { qwiic_keyboard_connected = true; - qwiic_keyboard_listening_address - uint8_t * message_pointer = qwiic_keyboard_reply; - *message_pointer++ = MATRIX_ROWS; - *message_pointer++ = MATRIX_COLS; - qwiic_keyboard_write_keymap(message_pointer); - twi2c_reply(qwiic_keyboard_reply, QWIIC_KEYBOARD_HANDSHAKE_MESSAGE_SIZE); + qwiic_keyboard_master = false; + qwiic_keyboard_listening_address = body[0]; + qwiic_keyboard_write_keymap(qwiic_keyboard_reply); + twi2c_reply(i2cp, qwiic_keyboard_reply, QWIIC_KEYBOARD_HANDSHAKE_MESSAGE_SIZE); twi2c_stop(); - twi2c_start_listening(qwiic_keyboard_listening_address, qwiic_keyboard_message_received); + twi2c_start(); + twi2c_start_listening(qwiic_keyboard_listening_address, qwiic_keyboard_message_received_ptr); } } +// qwiic_keyboard_message_received_ptr = qwiic_keyboard_message_received; + +__attribute__((optimize("O0"))) void qwiic_keyboard_write_keymap(uint8_t * pointer) { for (uint8_t layer = 0; layer < QWIIC_KEYBOARD_LAYERS; layer++) { for (uint8_t row = 0; row < QWIIC_KEYBOARD_ROWS; row++) { @@ -116,3 +175,19 @@ void qwiic_keyboard_read_keymap(uint8_t * pointer) { } } } + +// overwrite the built-in function - slaves don't need to process keycodes +bool is_keyboard_master(void) { + return qwiic_keyboard_master; +} + +// overwrite the built-in function +uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) { + if (qwiic_keyboard_processing_slave) { + // trick the built-in handling to accept our replacement keymap + return qwiic_keyboard_keymap[(layer)][(key.row)][(key.col)]; + } else { + // Read entire word (16bits) + return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]); + } +} diff --git a/drivers/qwiic/qwiic_keyboard.h b/drivers/qwiic/qwiic_keyboard.h index d73544a9a7b..813a02bb9e1 100644 --- a/drivers/qwiic/qwiic_keyboard.h +++ b/drivers/qwiic/qwiic_keyboard.h @@ -19,4 +19,8 @@ #include "quantum.h" +void qwiic_keyboard_init(void); +void qwiic_keyboard_task(void); +void qwiic_keyboard_message_received(I2CDriver *i2cp, uint8_t * body, uint16_t size); + #endif diff --git a/keyboards/muon_light/config.h b/keyboards/muon_light/config.h index b4c7b6051bd..b8df031a4ae 100644 --- a/keyboards/muon_light/config.h +++ b/keyboards/muon_light/config.h @@ -149,4 +149,6 @@ along with this program. If not, see . #define DRIVER_2_LED_TOTAL 24 #define DRIVER_LED_TOTAL DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL +#define NO_USB_STARTUP_CHECK + #endif diff --git a/keyboards/muon_light/halconf.h b/keyboards/muon_light/halconf.h index c3e0cbb728c..2e8eed14f41 100644 --- a/keyboards/muon_light/halconf.h +++ b/keyboards/muon_light/halconf.h @@ -79,6 +79,13 @@ #define HAL_USE_I2C TRUE #endif +/** + * @brief Enables the I2C Slave subsystem. + */ +#if !defined(HAL_USE_I2C_SLAVE) || defined(__DOXYGEN__) +#define HAL_USE_I2C_SLAVE TRUE +#endif + /** * @brief Enables the I2S subsystem. */ diff --git a/keyboards/muon_light/muon_light.c b/keyboards/muon_light/muon_light.c index 1896a40c0df..9b6cbb824ce 100644 --- a/keyboards/muon_light/muon_light.c +++ b/keyboards/muon_light/muon_light.c @@ -28,13 +28,13 @@ void matrix_scan_kb(void) { matrix_scan_user(); } -void suspend_power_down_kb(void) { - rgb_matrix_set_suspend_state(true); -} +// void suspend_power_down_kb(void) { +// rgb_matrix_set_suspend_state(true); +// } -void suspend_wakeup_init_kb(void) { - rgb_matrix_set_suspend_state(false); -} +// void suspend_wakeup_init_kb(void) { +// rgb_matrix_set_suspend_state(false); +// } const uint8_t music_map[MATRIX_ROWS][MATRIX_COLS] = LAYOUT_ortho_4x6( 18, 19, 20, 21, 22, 23, @@ -43,73 +43,73 @@ const uint8_t music_map[MATRIX_ROWS][MATRIX_COLS] = LAYOUT_ortho_4x6( 0, 1, 2, 3, 4, 5 ); -const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { -/* Refer to IS31 manual for these locations - * driver - * | R location - * | | G location - * | | | B location - * | | | | */ - {0, C1_3, C2_3, C3_3}, - {0, C1_4, C2_4, C3_4}, - {0, C1_5, C2_5, C3_5}, - {0, C1_11, C2_11, C3_11}, - {0, C1_12, C2_12, C3_12}, - {0, C1_13, C2_13, C3_13}, - - {0, C1_6, C2_6, C3_6}, - {0, C1_7, C2_7, C3_7}, - {0, C1_8, C2_8, C3_8}, - {0, C1_14, C2_14, C3_14}, - {0, C1_15, C2_15, C3_15}, - {0, C1_16, C2_16, C3_16}, - - {0, C9_1, C8_1, C7_1}, - {0, C9_2, C8_2, C7_2}, - {0, C9_3, C8_3, C7_3}, - {0, C9_9, C8_9, C7_9}, - {0, C9_10, C8_10, C7_10}, - {0, C9_11, C8_11, C7_11}, - - {0, C9_4, C8_4, C7_4}, - {0, C9_5, C8_5, C7_5}, - {0, C9_6, C8_6, C7_6}, - {0, C9_12, C8_12, C7_12}, - {0, C9_13, C8_13, C7_13}, - {0, C9_14, C8_14, C7_14} -}; - -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - - /*{row | col << 4} - | {x=0..224, y=0..64} - | | modifier - | | | */ - {{0|(0<<4)}, {20.36*0, 21.33*0}, 1}, - {{0|(1<<4)}, {20.36*1, 21.33*0}, 0}, - {{0|(2<<4)}, {20.36*2, 21.33*0}, 0}, - {{0|(3<<4)}, {20.36*3, 21.33*0}, 0}, - {{0|(4<<4)}, {20.36*4, 21.33*0}, 0}, - {{0|(5<<4)}, {20.36*5, 21.33*0}, 0}, - - {{1|(0<<4)}, {20.36*0, 21.33*1}, 1}, - {{1|(1<<4)}, {20.36*1, 21.33*1}, 0}, - {{1|(2<<4)}, {20.36*2, 21.33*1}, 0}, - {{1|(3<<4)}, {20.36*3, 21.33*1}, 0}, - {{1|(4<<4)}, {20.36*4, 21.33*1}, 0}, - {{1|(5<<4)}, {20.36*5, 21.33*1}, 0}, - - {{2|(0<<4)}, {20.36*0, 21.33*2}, 1}, - {{2|(1<<4)}, {20.36*1, 21.33*2}, 0}, - {{2|(2<<4)}, {20.36*2, 21.33*2}, 0}, - {{2|(3<<4)}, {20.36*3, 21.33*2}, 0}, - {{2|(4<<4)}, {20.36*4, 21.33*2}, 0}, - {{2|(5<<4)}, {20.36*5, 21.33*2}, 0}, - - {{3|(0<<4)}, {20.36*0, 21.33*3}, 1}, - {{3|(1<<4)}, {20.36*1, 21.33*3}, 1}, - {{3|(2<<4)}, {20.36*2, 21.33*3}, 1}, - {{3|(3<<4)}, {20.36*3, 21.33*3}, 1}, - {{3|(4<<4)}, {20.36*4, 21.33*3}, 1}, - {{3|(5<<4)}, {20.36*5, 21.33*3}, 0} -}; +// const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { +// /* Refer to IS31 manual for these locations +// * driver +// * | R location +// * | | G location +// * | | | B location +// * | | | | */ +// {0, C1_3, C2_3, C3_3}, +// {0, C1_4, C2_4, C3_4}, +// {0, C1_5, C2_5, C3_5}, +// {0, C1_11, C2_11, C3_11}, +// {0, C1_12, C2_12, C3_12}, +// {0, C1_13, C2_13, C3_13}, + +// {0, C1_6, C2_6, C3_6}, +// {0, C1_7, C2_7, C3_7}, +// {0, C1_8, C2_8, C3_8}, +// {0, C1_14, C2_14, C3_14}, +// {0, C1_15, C2_15, C3_15}, +// {0, C1_16, C2_16, C3_16}, + +// {0, C9_1, C8_1, C7_1}, +// {0, C9_2, C8_2, C7_2}, +// {0, C9_3, C8_3, C7_3}, +// {0, C9_9, C8_9, C7_9}, +// {0, C9_10, C8_10, C7_10}, +// {0, C9_11, C8_11, C7_11}, + +// {0, C9_4, C8_4, C7_4}, +// {0, C9_5, C8_5, C7_5}, +// {0, C9_6, C8_6, C7_6}, +// {0, C9_12, C8_12, C7_12}, +// {0, C9_13, C8_13, C7_13}, +// {0, C9_14, C8_14, C7_14} +// }; + +// const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { + +// {row | col << 4} +// | {x=0..224, y=0..64} +// | | modifier +// | | | +// {{0|(0<<4)}, {20.36*0, 21.33*0}, 1}, +// {{0|(1<<4)}, {20.36*1, 21.33*0}, 0}, +// {{0|(2<<4)}, {20.36*2, 21.33*0}, 0}, +// {{0|(3<<4)}, {20.36*3, 21.33*0}, 0}, +// {{0|(4<<4)}, {20.36*4, 21.33*0}, 0}, +// {{0|(5<<4)}, {20.36*5, 21.33*0}, 0}, + +// {{1|(0<<4)}, {20.36*0, 21.33*1}, 1}, +// {{1|(1<<4)}, {20.36*1, 21.33*1}, 0}, +// {{1|(2<<4)}, {20.36*2, 21.33*1}, 0}, +// {{1|(3<<4)}, {20.36*3, 21.33*1}, 0}, +// {{1|(4<<4)}, {20.36*4, 21.33*1}, 0}, +// {{1|(5<<4)}, {20.36*5, 21.33*1}, 0}, + +// {{2|(0<<4)}, {20.36*0, 21.33*2}, 1}, +// {{2|(1<<4)}, {20.36*1, 21.33*2}, 0}, +// {{2|(2<<4)}, {20.36*2, 21.33*2}, 0}, +// {{2|(3<<4)}, {20.36*3, 21.33*2}, 0}, +// {{2|(4<<4)}, {20.36*4, 21.33*2}, 0}, +// {{2|(5<<4)}, {20.36*5, 21.33*2}, 0}, + +// {{3|(0<<4)}, {20.36*0, 21.33*3}, 1}, +// {{3|(1<<4)}, {20.36*1, 21.33*3}, 1}, +// {{3|(2<<4)}, {20.36*2, 21.33*3}, 1}, +// {{3|(3<<4)}, {20.36*3, 21.33*3}, 1}, +// {{3|(4<<4)}, {20.36*4, 21.33*3}, 1}, +// {{3|(5<<4)}, {20.36*5, 21.33*3}, 0} +// }; diff --git a/keyboards/muon_light/rules.mk b/keyboards/muon_light/rules.mk index 7047f6566e7..4cca7a3b0c5 100644 --- a/keyboards/muon_light/rules.mk +++ b/keyboards/muon_light/rules.mk @@ -51,12 +51,13 @@ COMMAND_ENABLE = yes # Commands for debug and configuration NKRO_ENABLE = yes # USB Nkey Rollover CUSTOM_MATRIX = yes # Custom matrix file AUDIO_ENABLE = yes -RGB_MATRIX_ENABLE = yes -ENCODER_ENABLE = yes +# RGB_MATRIX_ENABLE = yes +# ENCODER_ENABLE = yes # SERIAL_LINK_ENABLE = yes +I2C_SLAVE_ENABLE = yes +QWIIC_KEYBOARD_ENABLE = yes # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend LAYOUTS = ortho_4x6 -LAYOUTS_HAS_RGB = no diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 4eff764e2d8..07f6c6eb33e 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -69,6 +69,9 @@ along with this program. If not, see . #ifdef MIDI_ENABLE # include "process_midi.h" #endif +#ifdef QWIIC_KEYBOARD_ENABLE +# include "qwiic/qwiic_keyboard.h" +#endif #ifdef MATRIX_HAS_GHOST extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; @@ -181,11 +184,14 @@ void keyboard_init(void) { #if defined(NKRO_ENABLE) && defined(FORCE_NKRO) keymap_config.nkro = 1; #endif +#ifdef QWIIC_KEYBOARD_ENABLE + qwiic_keyboard_init(); +#endif } /** \brief Keyboard task: Do keyboard routine jobs * - * Do routine keyboard jobs: + * Do routine keyboard jobs: * * * scan matrix * * handle mouse movements @@ -291,6 +297,10 @@ MATRIX_LOOP_END: midi_task(); #endif +#ifdef QWIIC_KEYBOARD_ENABLE + qwiic_keyboard_task(); +#endif + // update LED if (led_status != host_keyboard_leds()) { led_status = host_keyboard_leds();