Browse Source

hooked-up keymap/matrix, compiling, not working

muon_light
Jack Humbert 5 years ago
parent
commit
2fccc1a064
10 changed files with 259 additions and 283 deletions
  1. +10
    -2
      common_features.mk
  2. +23
    -151
      drivers/arm/twi2c.c
  3. +11
    -14
      drivers/arm/twi2c.h
  4. +111
    -36
      drivers/qwiic/qwiic_keyboard.c
  5. +4
    -0
      drivers/qwiic/qwiic_keyboard.h
  6. +2
    -0
      keyboards/muon_light/config.h
  7. +7
    -0
      keyboards/muon_light/halconf.h
  8. +76
    -76
      keyboards/muon_light/muon_light.c
  9. +4
    -3
      keyboards/muon_light/rules.mk
  10. +11
    -1
      tmk_core/common/keyboard.c

+ 10
- 2
common_features.mk View File

@ -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 \


+ 23
- 151
drivers/arm/twi2c.c View File

@ -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);
}

+ 11
- 14
drivers/arm/twi2c.h View File

@ -14,6 +14,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#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

+ 111
- 36
drivers/qwiic/qwiic_keyboard.c View File

@ -17,82 +17,141 @@
#include "qwiic_keyboard.h"
#include "keymap.h"
#include "matrix.h"
#include "keyboard.h"
#include "twi2c.h"
#include <string.h>
#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<<c)) {
action_exec((keyevent_t){
.key = (keypos_t){ .row = r, .col = c },
.pressed = (matrix_row & ((qwiic_matrix_t)1<<c)),
.time = (timer_read() | 1) /* time should not be 0 */
});
// record a processed key
matrix_prev[r] ^= ((qwiic_matrix_t)1<<c);
#ifdef QMK_KEYS_PER_SCAN
// only jump out if we have processed "enough" keys.
if (++keys_processed >= 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)]);
}
}

+ 4
- 0
drivers/qwiic/qwiic_keyboard.h View File

@ -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

+ 2
- 0
keyboards/muon_light/config.h View File

@ -149,4 +149,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DRIVER_2_LED_TOTAL 24
#define DRIVER_LED_TOTAL DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL
#define NO_USB_STARTUP_CHECK
#endif

+ 7
- 0
keyboards/muon_light/halconf.h View File

@ -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.
*/


+ 76
- 76
keyboards/muon_light/muon_light.c View File

@ -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}
// };

+ 4
- 3
keyboards/muon_light/rules.mk View File

@ -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

+ 11
- 1
tmk_core/common/keyboard.c View File

@ -69,6 +69,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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();


Loading…
Cancel
Save