Compare commits
7 Commits
muon_light
...
muon_light
Author | SHA1 | Date | |
---|---|---|---|
|
ec0f9db8ad | ||
|
8c36c83a84 | ||
|
cca90f4389 | ||
|
1b7efbc03b | ||
|
e54159d9e8 | ||
|
bcbc64aed8 | ||
|
e1e4a51472 |
17
Makefile
17
Makefile
@@ -67,7 +67,7 @@ $(eval $(call NEXT_PATH_ELEMENT))
|
|||||||
# It's really a very simple if else chain, if you squint enough,
|
# It's really a very simple if else chain, if you squint enough,
|
||||||
# but the makefile syntax makes it very verbose.
|
# but the makefile syntax makes it very verbose.
|
||||||
# If we are in a subfolder of keyboards
|
# If we are in a subfolder of keyboards
|
||||||
#
|
#
|
||||||
# *** No longer needed **
|
# *** No longer needed **
|
||||||
#
|
#
|
||||||
# ifeq ($(CURRENT_PATH_ELEMENT),keyboards)
|
# ifeq ($(CURRENT_PATH_ELEMENT),keyboards)
|
||||||
@@ -320,6 +320,14 @@ define PARSE_KEYBOARD
|
|||||||
KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/keymaps/*/.)))
|
KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/keymaps/*/.)))
|
||||||
KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/keymaps/*/.)))
|
KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/keymaps/*/.)))
|
||||||
KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/keymaps/*/.)))
|
KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/keymaps/*/.)))
|
||||||
|
|
||||||
|
# get subkeymaps too
|
||||||
|
KEYMAPS += $$(patsubst $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_1)/keymaps/%,%,$$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_1)/keymaps/*/*/.)))
|
||||||
|
KEYMAPS += $$(patsubst $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_2)/keymaps/%,%,$$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_2)/keymaps/*/*/.)))
|
||||||
|
KEYMAPS += $$(patsubst $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/keymaps/%,%,$$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/keymaps/*/*/.)))
|
||||||
|
KEYMAPS += $$(patsubst $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/keymaps/%,%,$$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/keymaps/*/*/.)))
|
||||||
|
KEYMAPS += $$(patsubst $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/keymaps/%,%,$$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/keymaps/*/*/.)))
|
||||||
|
|
||||||
# this might be needed, but in a different form
|
# this might be needed, but in a different form
|
||||||
#KEYMAPS := $$(sort $$(filter-out $$(KEYBOARD_FOLDER_1) $$(KEYBOARD_FOLDER_2) \
|
#KEYMAPS := $$(sort $$(filter-out $$(KEYBOARD_FOLDER_1) $$(KEYBOARD_FOLDER_2) \
|
||||||
$$(KEYBOARD_FOLDER_3) $$(KEYBOARD_FOLDER_4) $$(KEYBOARD_FOLDER_5), $$(KEYMAPS)))
|
$$(KEYBOARD_FOLDER_3) $$(KEYBOARD_FOLDER_4) $$(KEYBOARD_FOLDER_5), $$(KEYMAPS)))
|
||||||
@@ -353,9 +361,11 @@ define PARSE_KEYBOARD
|
|||||||
|
|
||||||
LAYOUT_KEYMAPS :=
|
LAYOUT_KEYMAPS :=
|
||||||
$$(foreach LAYOUT,$$(KEYBOARD_LAYOUTS),$$(eval LAYOUT_KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/layouts/*/$$(LAYOUT)/*/.)))))
|
$$(foreach LAYOUT,$$(KEYBOARD_LAYOUTS),$$(eval LAYOUT_KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/layouts/*/$$(LAYOUT)/*/.)))))
|
||||||
|
|
||||||
KEYMAPS := $$(sort $$(KEYMAPS) $$(LAYOUT_KEYMAPS))
|
KEYMAPS := $$(sort $$(KEYMAPS) $$(LAYOUT_KEYMAPS))
|
||||||
|
|
||||||
|
# $$(eval $$(info $$(KEYMAPS)))
|
||||||
|
|
||||||
# if the rule after removing the start of it is empty (we haven't specified a kemap or target)
|
# if the rule after removing the start of it is empty (we haven't specified a kemap or target)
|
||||||
# compile all the keymaps
|
# compile all the keymaps
|
||||||
ifeq ($$(RULE),)
|
ifeq ($$(RULE),)
|
||||||
@@ -411,7 +421,8 @@ define PARSE_KEYMAP
|
|||||||
MAKE_TARGET := $$(patsubst :%,%,$$(RULE))
|
MAKE_TARGET := $$(patsubst :%,%,$$(RULE))
|
||||||
# We need to generate an unique indentifer to append to the COMMANDS list
|
# We need to generate an unique indentifer to append to the COMMANDS list
|
||||||
CURRENT_KB_UNDER := $$(subst /,_,$$(CURRENT_KB))
|
CURRENT_KB_UNDER := $$(subst /,_,$$(CURRENT_KB))
|
||||||
COMMAND := COMMAND_KEYBOARD_$$(CURRENT_KB_UNDER)_KEYMAP_$$(CURRENT_KM)
|
CURRENT_KM_UNDER := $$(subst /,_,$$(CURRENT_KM))
|
||||||
|
COMMAND := COMMAND_KEYBOARD_$$(CURRENT_KB_UNDER)_KEYMAP_$$(CURRENT_KM_UNDER)
|
||||||
# If we are compiling a keyboard without a subproject, we want to display just the name
|
# If we are compiling a keyboard without a subproject, we want to display just the name
|
||||||
# of the keyboard, otherwise keyboard/subproject
|
# of the keyboard, otherwise keyboard/subproject
|
||||||
KB_SP := $$(CURRENT_KB)
|
KB_SP := $$(CURRENT_KB)
|
||||||
|
@@ -19,8 +19,9 @@ KEYBOARD_FOLDER_4 := $(notdir $(KEYBOARD_FOLDER_PATH_4))
|
|||||||
KEYBOARD_FOLDER_5 := $(notdir $(KEYBOARD_FOLDER_PATH_5))
|
KEYBOARD_FOLDER_5 := $(notdir $(KEYBOARD_FOLDER_PATH_5))
|
||||||
|
|
||||||
KEYBOARD_FILESAFE := $(subst /,_,$(KEYBOARD))
|
KEYBOARD_FILESAFE := $(subst /,_,$(KEYBOARD))
|
||||||
|
KEYMAP_FILESAFE := $(subst /,_,$(KEYMAP))
|
||||||
|
|
||||||
TARGET ?= $(KEYBOARD_FILESAFE)_$(KEYMAP)
|
TARGET ?= $(KEYBOARD_FILESAFE)_$(KEYMAP_FILESAFE)
|
||||||
KEYBOARD_OUTPUT := $(BUILD_DIR)/obj_$(KEYBOARD_FILESAFE)
|
KEYBOARD_OUTPUT := $(BUILD_DIR)/obj_$(KEYBOARD_FILESAFE)
|
||||||
|
|
||||||
# Force expansion
|
# Force expansion
|
||||||
@@ -176,26 +177,44 @@ MAIN_KEYMAP_PATH_3 := $(KEYBOARD_PATH_3)/keymaps/$(KEYMAP)
|
|||||||
MAIN_KEYMAP_PATH_4 := $(KEYBOARD_PATH_4)/keymaps/$(KEYMAP)
|
MAIN_KEYMAP_PATH_4 := $(KEYBOARD_PATH_4)/keymaps/$(KEYMAP)
|
||||||
MAIN_KEYMAP_PATH_5 := $(KEYBOARD_PATH_5)/keymaps/$(KEYMAP)
|
MAIN_KEYMAP_PATH_5 := $(KEYBOARD_PATH_5)/keymaps/$(KEYMAP)
|
||||||
|
|
||||||
|
PARENT_MAIN_KEYMAP_PATH_1 := $(patsubst %/,%,$(dir $(MAIN_KEYMAP_PATH_1)))
|
||||||
|
PARENT_MAIN_KEYMAP_PATH_2 := $(patsubst %/,%,$(dir $(MAIN_KEYMAP_PATH_2)))
|
||||||
|
PARENT_MAIN_KEYMAP_PATH_3 := $(patsubst %/,%,$(dir $(MAIN_KEYMAP_PATH_3)))
|
||||||
|
PARENT_MAIN_KEYMAP_PATH_4 := $(patsubst %/,%,$(dir $(MAIN_KEYMAP_PATH_4)))
|
||||||
|
PARENT_MAIN_KEYMAP_PATH_5 := $(patsubst %/,%,$(dir $(MAIN_KEYMAP_PATH_5)))
|
||||||
|
|
||||||
|
# $(info $(PARENT_MAIN_KEYMAP_PATH_1))
|
||||||
|
|
||||||
ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_5)/keymap.c)","")
|
ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_5)/keymap.c)","")
|
||||||
-include $(MAIN_KEYMAP_PATH_5)/rules.mk
|
|
||||||
KEYMAP_C := $(MAIN_KEYMAP_PATH_5)/keymap.c
|
KEYMAP_C := $(MAIN_KEYMAP_PATH_5)/keymap.c
|
||||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_5)
|
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_5)
|
||||||
|
else ifneq ("$(wildcard $(PARENT_MAIN_KEYMAP_PATH_5)/keymap.c)","")
|
||||||
|
KEYMAP_C := $(PARENT_MAIN_KEYMAP_PATH_5)/keymap.c
|
||||||
|
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_5)
|
||||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_4)/keymap.c)","")
|
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_4)/keymap.c)","")
|
||||||
-include $(MAIN_KEYMAP_PATH_4)/rules.mk
|
|
||||||
KEYMAP_C := $(MAIN_KEYMAP_PATH_4)/keymap.c
|
KEYMAP_C := $(MAIN_KEYMAP_PATH_4)/keymap.c
|
||||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_4)
|
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_4)
|
||||||
|
else ifneq ("$(wildcard $(PARENT_MAIN_KEYMAP_PATH_4)/keymap.c)","")
|
||||||
|
KEYMAP_C := $(PARENT_MAIN_KEYMAP_PATH_4)/keymap.c
|
||||||
|
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_4)
|
||||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_3)/keymap.c)","")
|
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_3)/keymap.c)","")
|
||||||
-include $(MAIN_KEYMAP_PATH_3)/rules.mk
|
|
||||||
KEYMAP_C := $(MAIN_KEYMAP_PATH_3)/keymap.c
|
KEYMAP_C := $(MAIN_KEYMAP_PATH_3)/keymap.c
|
||||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_3)
|
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_3)
|
||||||
|
else ifneq ("$(wildcard $(PARENT_MAIN_KEYMAP_PATH_3)/keymap.c)","")
|
||||||
|
KEYMAP_C := $(PARENT_MAIN_KEYMAP_PATH_3)/keymap.c
|
||||||
|
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_3)
|
||||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_2)/keymap.c)","")
|
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_2)/keymap.c)","")
|
||||||
-include $(MAIN_KEYMAP_PATH_2)/rules.mk
|
|
||||||
KEYMAP_C := $(MAIN_KEYMAP_PATH_2)/keymap.c
|
KEYMAP_C := $(MAIN_KEYMAP_PATH_2)/keymap.c
|
||||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_2)
|
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_2)
|
||||||
|
else ifneq ("$(wildcard $(PARENT_MAIN_KEYMAP_PATH_2)/keymap.c)","")
|
||||||
|
KEYMAP_C := $(PARENT_MAIN_KEYMAP_PATH_2)/keymap.c
|
||||||
|
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_2)
|
||||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_1)/keymap.c)","")
|
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_1)/keymap.c)","")
|
||||||
-include $(MAIN_KEYMAP_PATH_1)/rules.mk
|
|
||||||
KEYMAP_C := $(MAIN_KEYMAP_PATH_1)/keymap.c
|
KEYMAP_C := $(MAIN_KEYMAP_PATH_1)/keymap.c
|
||||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_1)
|
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_1)
|
||||||
|
else ifneq ("$(wildcard $(PARENT_MAIN_KEYMAP_PATH_1)/keymap.c)","")
|
||||||
|
KEYMAP_C := $(PARENT_MAIN_KEYMAP_PATH_1)/keymap.c
|
||||||
|
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_1)
|
||||||
else ifneq ($(LAYOUTS),)
|
else ifneq ($(LAYOUTS),)
|
||||||
include build_layout.mk
|
include build_layout.mk
|
||||||
else
|
else
|
||||||
@@ -203,26 +222,34 @@ else
|
|||||||
# this state should never be reached
|
# this state should never be reached
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
PARENT_KEYMAP_PATH := $(patsubst %/,%,$(dir $(KEYMAP_PATH)))
|
||||||
|
|
||||||
# User space stuff
|
# User space stuff
|
||||||
ifeq ("$(USER_NAME)","")
|
ifeq ("$(USER_NAME)","")
|
||||||
USER_NAME := $(KEYMAP)
|
USER_NAME := $(KEYMAP)
|
||||||
endif
|
endif
|
||||||
USER_PATH := users/$(USER_NAME)
|
USER_PATH := users/$(USER_NAME)
|
||||||
|
|
||||||
-include $(USER_PATH)/rules.mk
|
|
||||||
ifneq ("$(wildcard $(USER_PATH)/config.h)","")
|
|
||||||
CONFIG_H += $(USER_PATH)/config.h
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
# Object files directory
|
# Object files directory
|
||||||
# To put object files in current directory, use a dot (.), do NOT make
|
# To put object files in current directory, use a dot (.), do NOT make
|
||||||
# this an empty or blank macro!
|
# this an empty or blank macro!
|
||||||
KEYMAP_OUTPUT := $(BUILD_DIR)/obj_$(TARGET)
|
KEYMAP_OUTPUT := $(BUILD_DIR)/obj_$(TARGET)
|
||||||
|
|
||||||
|
-include $(PARENT_KEYMAP_PATH)/rules.mk
|
||||||
|
-include $(KEYMAP_PATH)/rules.mk
|
||||||
|
-include $(USER_PATH)/rules.mk
|
||||||
|
|
||||||
|
ifneq ("$(wildcard $(PARENT_KEYMAP_PATH)/config.h)","")
|
||||||
|
CONFIG_H += $(PARENT_KEYMAP_PATH)/config.h
|
||||||
|
endif
|
||||||
ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","")
|
ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","")
|
||||||
CONFIG_H += $(KEYMAP_PATH)/config.h
|
CONFIG_H += $(KEYMAP_PATH)/config.h
|
||||||
endif
|
endif
|
||||||
|
ifneq ("$(wildcard $(USER_PATH)/config.h)","")
|
||||||
|
CONFIG_H += $(USER_PATH)/config.h
|
||||||
|
endif
|
||||||
|
|
||||||
# # project specific files
|
# # project specific files
|
||||||
SRC += $(KEYBOARD_SRC) \
|
SRC += $(KEYBOARD_SRC) \
|
||||||
@@ -233,6 +260,7 @@ SRC += $(KEYBOARD_SRC) \
|
|||||||
#EXTRALDFLAGS = -Wl,--relax
|
#EXTRALDFLAGS = -Wl,--relax
|
||||||
|
|
||||||
# Search Path
|
# Search Path
|
||||||
|
VPATH += $(PARENT_KEYMAP_PATH)
|
||||||
VPATH += $(KEYMAP_PATH)
|
VPATH += $(KEYMAP_PATH)
|
||||||
VPATH += $(KEYBOARD_PATHS)
|
VPATH += $(KEYBOARD_PATHS)
|
||||||
VPATH += $(COMMON_VPATH)
|
VPATH += $(COMMON_VPATH)
|
||||||
|
@@ -3,11 +3,15 @@ LAYOUTS_REPOS := $(patsubst %/,%,$(sort $(dir $(wildcard $(LAYOUTS_PATH)/*/))))
|
|||||||
|
|
||||||
define SEARCH_LAYOUTS_REPO
|
define SEARCH_LAYOUTS_REPO
|
||||||
LAYOUT_KEYMAP_PATH := $$(LAYOUTS_REPO)/$$(LAYOUT)/$$(KEYMAP)
|
LAYOUT_KEYMAP_PATH := $$(LAYOUTS_REPO)/$$(LAYOUT)/$$(KEYMAP)
|
||||||
|
PARENT_LAYOUT_KEYMAP_PATH := $(patsubst %/,%,$(dir $(LAYOUT_KEYMAP_PATH)))
|
||||||
LAYOUT_KEYMAP_C := $$(LAYOUT_KEYMAP_PATH)/keymap.c
|
LAYOUT_KEYMAP_C := $$(LAYOUT_KEYMAP_PATH)/keymap.c
|
||||||
|
PARENT_LAYOUT_KEYMAP_C := $$(PARENT_LAYOUT_KEYMAP_PATH)/keymap.c
|
||||||
ifneq ("$$(wildcard $$(LAYOUT_KEYMAP_C))","")
|
ifneq ("$$(wildcard $$(LAYOUT_KEYMAP_C))","")
|
||||||
-include $$(LAYOUT_KEYMAP_PATH)/rules.mk
|
|
||||||
KEYMAP_C := $$(LAYOUT_KEYMAP_C)
|
KEYMAP_C := $$(LAYOUT_KEYMAP_C)
|
||||||
KEYMAP_PATH := $$(LAYOUT_KEYMAP_PATH)
|
KEYMAP_PATH := $$(LAYOUT_KEYMAP_PATH)
|
||||||
|
else ifneq ("$$(wildcard $$(PARENT_LAYOUT_KEYMAP_C))","")
|
||||||
|
KEYMAP_C := $$(PARENT_LAYOUT_KEYMAP_C)
|
||||||
|
KEYMAP_PATH := $$(LAYOUT_KEYMAP_PATH)
|
||||||
endif
|
endif
|
||||||
endef
|
endef
|
||||||
|
|
||||||
@@ -15,4 +19,4 @@ define SEARCH_LAYOUTS
|
|||||||
$$(foreach LAYOUTS_REPO,$$(LAYOUTS_REPOS),$$(eval $$(call SEARCH_LAYOUTS_REPO)))
|
$$(foreach LAYOUTS_REPO,$$(LAYOUTS_REPOS),$$(eval $$(call SEARCH_LAYOUTS_REPO)))
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(foreach LAYOUT,$(LAYOUTS),$(eval $(call SEARCH_LAYOUTS)))
|
$(foreach LAYOUT,$(LAYOUTS),$(eval $(call SEARCH_LAYOUTS)))
|
||||||
|
@@ -75,11 +75,6 @@ void twi2c_catch_error(I2CDriver *i2cp)
|
|||||||
/**
|
/**
|
||||||
* Callback after sending of response complete - restores default reply in case polled
|
* Callback after sending of response complete - restores default reply in case polled
|
||||||
*/
|
*/
|
||||||
void twi2c_clear_after_send(I2CDriver *i2cp)
|
|
||||||
{
|
|
||||||
// echoReply.size = 0; // Clear receive message
|
|
||||||
// i2cSlaveReplyI(i2cp, &initialReply);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t twi2c_start(void) {
|
uint8_t twi2c_start(void) {
|
||||||
i2cStart(&I2C_DRIVER, &i2cconfig);
|
i2cStart(&I2C_DRIVER, &i2cconfig);
|
||||||
@@ -100,11 +95,11 @@ void twi2c_init(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t twi2c_write(uint8_t data) {
|
uint8_t twi2c_write(uint8_t data) {
|
||||||
return i2cMasterTransmitTimeout(&I2C_DRIVER, twi2c_address/2, &data, 1, 0, 0, MS2ST(100));
|
return i2cMasterTransmitTimeout(&I2C_DRIVER, twi2c_address/2, &data, 1, NULL, 0, MS2ST(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t twi2c_transmit(uint8_t address, uint8_t * data, uint16_t length) {
|
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));
|
return i2cMasterTransmitTimeout(&I2C_DRIVER, address/2, data, length, NULL, 0, MS2ST(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t twi2c_receive(uint8_t address, uint8_t * data, uint16_t length) {
|
uint8_t twi2c_receive(uint8_t address, uint8_t * data, uint16_t length) {
|
||||||
@@ -112,8 +107,8 @@ uint8_t twi2c_receive(uint8_t address, uint8_t * data, uint16_t length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8_t twi2c_incoming_body[50];
|
uint8_t twi2c_incoming_body[50] = {0};
|
||||||
uint8_t twi2c_outgoing_body[1024];
|
uint8_t twi2c_outgoing_body[1024] = {0};
|
||||||
|
|
||||||
// Response to received messages
|
// Response to received messages
|
||||||
I2CSlaveMsg twi2c_incoming_message = {
|
I2CSlaveMsg twi2c_incoming_message = {
|
||||||
@@ -138,6 +133,11 @@ I2CSlaveMsg twi2c_outgoing_message = {
|
|||||||
twi2c_catch_error
|
twi2c_catch_error
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void twi2c_clear_after_send(I2CDriver *i2cp) {
|
||||||
|
twi2c_outgoing_message.size = 0; // Clear receive message
|
||||||
|
//i2cSlaveReplyI(i2cp, &initialReply);
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t twi2c_reply(I2CDriver * i2cp, uint8_t * data, uint16_t length) {
|
uint8_t twi2c_reply(I2CDriver * i2cp, uint8_t * data, uint16_t length) {
|
||||||
memcpy(twi2c_outgoing_body, data, length);
|
memcpy(twi2c_outgoing_body, data, length);
|
||||||
twi2c_outgoing_message.size = length;
|
twi2c_outgoing_message.size = length;
|
||||||
@@ -157,11 +157,26 @@ uint8_t twi2c_start_listening(uint8_t address, twi2c_message_received callback)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t twi2c_restart_listening(uint8_t address) {
|
uint8_t twi2c_remove_listening(uint8_t address) {
|
||||||
|
i2cUnmatchAddress(&I2C_DRIVER, address/2);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t twi2c_add_listening(uint8_t address) {
|
||||||
i2cMatchAddress(&I2C_DRIVER, address/2);
|
i2cMatchAddress(&I2C_DRIVER, address/2);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t twi2c_remove_listening_i(uint8_t address) {
|
||||||
|
i2cUnmatchAddressI(&I2C_DRIVER, address/2);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t twi2c_add_listening_i(uint8_t address) {
|
||||||
|
i2cMatchAddressI(&I2C_DRIVER, address/2);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void twi2c_stop(void) {
|
void twi2c_stop(void) {
|
||||||
i2cUnmatchAll(&I2C_DRIVER);
|
i2cUnmatchAll(&I2C_DRIVER);
|
||||||
i2cStop(&I2C_DRIVER);
|
i2cStop(&I2C_DRIVER);
|
||||||
|
@@ -43,6 +43,9 @@ void twi2c_stop(void);
|
|||||||
uint8_t twi2c_reply(I2CDriver * i2cp, uint8_t * data, uint16_t 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_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);
|
uint8_t twi2c_start_listening(uint8_t address, twi2c_message_received callback);
|
||||||
uint8_t twi2c_restart_listening(uint8_t address);
|
uint8_t twi2c_add_listening(uint8_t address);
|
||||||
|
uint8_t twi2c_remove_listening(uint8_t address);
|
||||||
|
uint8_t twi2c_add_listening_i(uint8_t address);
|
||||||
|
uint8_t twi2c_remove_listening_i(uint8_t address);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -24,28 +24,45 @@
|
|||||||
#include "usb_driver.h"
|
#include "usb_driver.h"
|
||||||
|
|
||||||
#define QWIIC_KEYBOARD_LAYERS 16
|
#define QWIIC_KEYBOARD_LAYERS 16
|
||||||
#define QWIIC_KEYBOARD_ROWS 8
|
#define QWIIC_KEYBOARD_ROWS 8
|
||||||
#define QWIIC_KEYBOARD_COLS 8
|
#define QWIIC_KEYBOARD_COLS 8
|
||||||
|
|
||||||
#define qwiic_matrix_t uint8_t
|
#if (QWIIC_KEYBOARD_COLS <= 8)
|
||||||
|
typedef uint8_t qwiic_row_t;
|
||||||
|
#elif (QWIIC_KEYBOARD_COLS <= 16)
|
||||||
|
typedef uint16_t qwiic_row_t;
|
||||||
|
#elif (QWIIC_KEYBOARD_COLS <= 32)
|
||||||
|
typedef uint32_t qwiic_row_t;
|
||||||
|
#else
|
||||||
|
#error "QWIIC_KEYBOARD_COLS: invalid value"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define QWIIC_KEYBOARD_HANDSHAKE_ADDRESS 0b01010100
|
#define QWIIC_KEYBOARD_HANDSHAKE_ADDRESS 0b01010100
|
||||||
#define QWIIC_KEYBOARD_LISTENING_ADDRESS_START 0b01010110
|
#define QWIIC_KEYBOARD_LISTENING_ADDRESS_START 0b01010110
|
||||||
#define QWIIC_KEYBOARD_HANDSHAKE_MESSAGE_SIZE (QWIIC_KEYBOARD_LAYERS * QWIIC_KEYBOARD_ROWS * QWIIC_KEYBOARD_COLS)
|
#define QWIIC_KEYBOARD_MAX_DEVICES 1
|
||||||
#define QWIIC_KEYBOARD_MATRIX_MESSAGE_SIZE MATRIX_ROWS
|
|
||||||
|
#define QWIIC_KEYBOARD_KEYMAP_MESSAGE_SIZE (QWIIC_KEYBOARD_LAYERS * QWIIC_KEYBOARD_ROWS * QWIIC_KEYBOARD_COLS)
|
||||||
|
#define QWIIC_KEYBOARD_MATRIX_MESSAGE_SIZE (QWIIC_KEYBOARD_ROWS)
|
||||||
|
|
||||||
void qwiic_keyboard_write_keymap(uint8_t * pointer);
|
void qwiic_keyboard_write_keymap(uint8_t * pointer);
|
||||||
void qwiic_keyboard_read_keymap(uint8_t * pointer);
|
void qwiic_keyboard_read_keymap(uint8_t * pointer, uint8_t index);
|
||||||
|
|
||||||
bool qwiic_keyboard_master = false;
|
bool qwiic_keyboard_master = false;
|
||||||
bool qwiic_keyboard_connected = false;
|
bool qwiic_keyboard_received_message = false;
|
||||||
uint8_t qwiic_keyboard_handshake_message[QWIIC_KEYBOARD_HANDSHAKE_MESSAGE_SIZE] = {0};
|
bool qwiic_keyboard_connected[QWIIC_KEYBOARD_MAX_DEVICES] = { false };
|
||||||
uint8_t qwiic_keyboard_matrix_message[QWIIC_KEYBOARD_ROWS] = {0};
|
uint8_t qwiic_keyboard_keymap_message[QWIIC_KEYBOARD_KEYMAP_MESSAGE_SIZE] = {0};
|
||||||
|
uint8_t qwiic_keyboard_matrix_message[QWIIC_KEYBOARD_MATRIX_MESSAGE_SIZE] = {0};
|
||||||
twi2c_message_received qwiic_keyboard_message_received_ptr = qwiic_keyboard_message_received;
|
twi2c_message_received qwiic_keyboard_message_received_ptr = qwiic_keyboard_message_received;
|
||||||
|
float song_one_up[][2] = SONG(ONE_UP_SOUND);
|
||||||
|
float song_zelda[][2] = SONG(ZELDA_PUZZLE);
|
||||||
|
uint8_t first_message = 0;
|
||||||
|
uint8_t first_message_slave = 0;
|
||||||
|
|
||||||
uint16_t qwiic_keyboard_keymap[QWIIC_KEYBOARD_LAYERS][QWIIC_KEYBOARD_ROWS][QWIIC_KEYBOARD_COLS] = {0};
|
uint16_t qwiic_keyboard_keymap[QWIIC_KEYBOARD_MAX_DEVICES][QWIIC_KEYBOARD_LAYERS][QWIIC_KEYBOARD_ROWS][QWIIC_KEYBOARD_COLS] = {0};
|
||||||
uint8_t qwiic_keyboard_listening_address = QWIIC_KEYBOARD_LISTENING_ADDRESS_START;
|
bool qwiic_keyboard_keymap_initialised[QWIIC_KEYBOARD_MAX_DEVICES] = { false };
|
||||||
uint8_t qwiic_keyboard_processing_slave = false;
|
uint8_t qwiic_keyboard_listening_address[QWIIC_KEYBOARD_MAX_DEVICES] = { 0 };
|
||||||
|
#define QWIIC_KEYBOARD_NOT_PROCESSING 255
|
||||||
|
uint8_t qwiic_keyboard_processing_slave = QWIIC_KEYBOARD_NOT_PROCESSING;
|
||||||
|
|
||||||
void qwiic_keyboard_init(void) {
|
void qwiic_keyboard_init(void) {
|
||||||
twi2c_init();
|
twi2c_init();
|
||||||
@@ -54,106 +71,179 @@ void qwiic_keyboard_init(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void qwiic_keyboard_set_master(void) {
|
void qwiic_keyboard_set_master(void) {
|
||||||
twi2c_stop();
|
if (!qwiic_keyboard_received_message) {
|
||||||
twi2c_start();
|
twi2c_stop();
|
||||||
qwiic_keyboard_master = true;
|
twi2c_start();
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t command[1] = { 0x00 };
|
|
||||||
|
|
||||||
void qwiic_keyboard_task(void) {
|
|
||||||
if (USB_DRIVER.state == USB_ACTIVE)
|
|
||||||
qwiic_keyboard_master = true;
|
qwiic_keyboard_master = true;
|
||||||
else
|
if (first_message == 0) {
|
||||||
qwiic_keyboard_master = false;
|
PLAY_SONG(song_one_up);
|
||||||
if (qwiic_keyboard_master) {
|
|
||||||
if (qwiic_keyboard_connected) {
|
|
||||||
// send empty message, expecting matrix info
|
|
||||||
if (MSG_OK == twi2c_transmit_receive(qwiic_keyboard_listening_address,
|
|
||||||
command, 1,
|
|
||||||
qwiic_keyboard_matrix_message, QWIIC_KEYBOARD_MATRIX_MESSAGE_SIZE
|
|
||||||
)) {
|
|
||||||
// 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;
|
|
||||||
#ifdef QMK_KEYS_PER_SCAN
|
|
||||||
uint8_t keys_processed = 0;
|
|
||||||
#endif
|
|
||||||
qwiic_keyboard_processing_slave = true;
|
|
||||||
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 < QWIIC_KEYBOARD_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 QWIIC_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);
|
|
||||||
QWIIC_MATRIX_LOOP_END:
|
|
||||||
qwiic_keyboard_processing_slave = false;
|
|
||||||
} else {
|
|
||||||
// disconnect
|
|
||||||
// qwiic_keyboard_connected = false;
|
|
||||||
}
|
|
||||||
} else { // if not connected
|
|
||||||
// send new address to listen on, expect back keymap
|
|
||||||
if (MSG_OK == twi2c_transmit_receive(QWIIC_KEYBOARD_HANDSHAKE_ADDRESS,
|
|
||||||
&qwiic_keyboard_listening_address, 1,
|
|
||||||
qwiic_keyboard_handshake_message, QWIIC_KEYBOARD_HANDSHAKE_MESSAGE_SIZE
|
|
||||||
)) {
|
|
||||||
qwiic_keyboard_connected = true;
|
|
||||||
// load keymap into memory
|
|
||||||
qwiic_keyboard_read_keymap(qwiic_keyboard_handshake_message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
first_message += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float song_one_up[][2] = SONG(ONE_UP_SOUND);
|
void qwiic_keyboard_set_slave(void) {
|
||||||
bool first_message = true;
|
qwiic_keyboard_received_message = true;
|
||||||
|
if (first_message_slave == 0) {
|
||||||
|
PLAY_SONG(song_zelda);
|
||||||
|
}
|
||||||
|
first_message_slave += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t keymap_command[1] = { 0x01 };
|
||||||
|
static uint8_t matrix_command[1] = { 0x02 };
|
||||||
|
static uint8_t look_counter = 0;
|
||||||
|
|
||||||
|
// uint8_t get_available_device_index(void) {
|
||||||
|
// for (uint8_t i = 0; i < QWIIC_KEYBOARD_MAX_DEVICES; i++) {
|
||||||
|
// if (!qwiic_keyboard_connected[i])
|
||||||
|
// return i;
|
||||||
|
// }
|
||||||
|
// return 255;
|
||||||
|
// }
|
||||||
|
|
||||||
|
void qwiic_keyboard_get_matrix(uint8_t device_i) {
|
||||||
|
// msg_t ret = twi2c_transmit_receive(qwiic_keyboard_listening_address[device_i],
|
||||||
|
// matrix_command, 1,
|
||||||
|
// qwiic_keyboard_matrix_message, QWIIC_KEYBOARD_MATRIX_MESSAGE_SIZE
|
||||||
|
// );
|
||||||
|
twi2c_transmit(qwiic_keyboard_listening_address[device_i], matrix_command, 1);
|
||||||
|
msg_t ret = twi2c_receive(qwiic_keyboard_listening_address[device_i],
|
||||||
|
qwiic_keyboard_matrix_message, QWIIC_KEYBOARD_MATRIX_MESSAGE_SIZE
|
||||||
|
);
|
||||||
|
switch (ret) {
|
||||||
|
// majority of this is pulled from keyboard.c:keyboard_task()
|
||||||
|
case I2C_OK:
|
||||||
|
qwiic_keyboard_processing_slave = device_i;
|
||||||
|
static qwiic_row_t matrix_prev[QWIIC_KEYBOARD_ROWS];
|
||||||
|
qwiic_row_t matrix_row = 0;
|
||||||
|
qwiic_row_t matrix_change = 0;
|
||||||
|
#ifdef QMK_KEYS_PER_SCAN
|
||||||
|
uint8_t keys_processed = 0;
|
||||||
|
#endif
|
||||||
|
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 < QWIIC_KEYBOARD_COLS; c++) {
|
||||||
|
if (matrix_change & ((qwiic_row_t)1<<c)) {
|
||||||
|
action_exec((keyevent_t){
|
||||||
|
.key = (keypos_t){ .row = r, .col = c },
|
||||||
|
.pressed = (matrix_row & ((qwiic_row_t)1<<c)),
|
||||||
|
.time = (timer_read() | 1) /* time should not be 0 */
|
||||||
|
});
|
||||||
|
// record a processed key
|
||||||
|
matrix_prev[r] ^= ((qwiic_row_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 QWIIC_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);
|
||||||
|
QWIIC_MATRIX_LOOP_END:
|
||||||
|
qwiic_keyboard_processing_slave = QWIIC_KEYBOARD_NOT_PROCESSING;
|
||||||
|
// if (first_message == 100) {
|
||||||
|
// PLAY_SONG(song_one_up);
|
||||||
|
// }
|
||||||
|
// first_message += 1;
|
||||||
|
break;
|
||||||
|
case I2C_ERROR:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
twi2c_start();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void qwiic_keyboard_task(void) {
|
||||||
|
if (USB_DRIVER.state == USB_ACTIVE)
|
||||||
|
qwiic_keyboard_set_master();
|
||||||
|
if (qwiic_keyboard_master) {
|
||||||
|
for (uint8_t device_i = 0; device_i < QWIIC_KEYBOARD_MAX_DEVICES; device_i++) {
|
||||||
|
if (qwiic_keyboard_connected[device_i]) {
|
||||||
|
// send empty message, expecting matrix info
|
||||||
|
if (!qwiic_keyboard_keymap_initialised[device_i]) {
|
||||||
|
// if (MSG_OK == twi2c_transmit_receive(qwiic_keyboard_listening_address[device_i],
|
||||||
|
// keymap_command, 1,
|
||||||
|
// qwiic_keyboard_keymap_message, QWIIC_KEYBOARD_KEYMAP_MESSAGE_SIZE
|
||||||
|
// )) {
|
||||||
|
twi2c_transmit(qwiic_keyboard_listening_address[device_i], keymap_command, 1);
|
||||||
|
if (MSG_OK == twi2c_receive(qwiic_keyboard_listening_address[device_i],
|
||||||
|
qwiic_keyboard_keymap_message, QWIIC_KEYBOARD_KEYMAP_MESSAGE_SIZE
|
||||||
|
)) {
|
||||||
|
// load keymap into memory
|
||||||
|
qwiic_keyboard_keymap_initialised[device_i] = true;
|
||||||
|
qwiic_keyboard_read_keymap(qwiic_keyboard_keymap_message, device_i);
|
||||||
|
qwiic_keyboard_get_matrix(device_i);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qwiic_keyboard_get_matrix(device_i);
|
||||||
|
} // end else - not init
|
||||||
|
} else { // if not connected
|
||||||
|
//if (look_counter == 0) {
|
||||||
|
// send new address to listen on, expect back keymap
|
||||||
|
uint8_t new_address = QWIIC_KEYBOARD_LISTENING_ADDRESS_START + (device_i*2);
|
||||||
|
uint8_t address_copy = 0;
|
||||||
|
twi2c_transmit(QWIIC_KEYBOARD_HANDSHAKE_ADDRESS, &new_address, 1);
|
||||||
|
if (MSG_OK == twi2c_receive(QWIIC_KEYBOARD_HANDSHAKE_ADDRESS,
|
||||||
|
&address_copy, 1
|
||||||
|
)) {
|
||||||
|
// if (MSG_OK == twi2c_transmit_receive(QWIIC_KEYBOARD_HANDSHAKE_ADDRESS,
|
||||||
|
// &new_address, 1,
|
||||||
|
// &address_copy, 1
|
||||||
|
// )) {
|
||||||
|
send_byte(address_copy);
|
||||||
|
//if (address_copy == new_address) {
|
||||||
|
PLAY_SONG(song_one_up);
|
||||||
|
qwiic_keyboard_connected[device_i] = true;
|
||||||
|
qwiic_keyboard_listening_address[device_i] = new_address;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
//} // end if - look for new
|
||||||
|
} // end else - connected
|
||||||
|
} // end for - devices
|
||||||
|
look_counter = ((look_counter + 1) % 150);
|
||||||
|
} // end if - master
|
||||||
|
}
|
||||||
|
|
||||||
void qwiic_keyboard_message_received(I2CDriver *i2cp, uint8_t * body, uint16_t size) {
|
void qwiic_keyboard_message_received(I2CDriver *i2cp, uint8_t * body, uint16_t size) {
|
||||||
if (qwiic_keyboard_connected) {
|
qwiic_keyboard_set_slave();
|
||||||
for (uint8_t row = 0; row < QWIIC_KEYBOARD_ROWS; row++) {
|
switch (body[0]) {
|
||||||
if (row < MATRIX_ROWS) {
|
// send keymap
|
||||||
qwiic_keyboard_matrix_message[row] = matrix_get_row(row);
|
case 0x01:
|
||||||
} else {
|
qwiic_keyboard_write_keymap(qwiic_keyboard_keymap_message);
|
||||||
qwiic_keyboard_matrix_message[row] = 0;
|
twi2c_reply(i2cp, qwiic_keyboard_keymap_message, QWIIC_KEYBOARD_KEYMAP_MESSAGE_SIZE);
|
||||||
|
break;
|
||||||
|
// send matrix
|
||||||
|
case 0x02:
|
||||||
|
case 0x00:
|
||||||
|
for (uint8_t row = 0; row < QWIIC_KEYBOARD_ROWS; row++) {
|
||||||
|
if (row < MATRIX_ROWS) {
|
||||||
|
qwiic_keyboard_matrix_message[row] = matrix_get_row(row);
|
||||||
|
} else {
|
||||||
|
qwiic_keyboard_matrix_message[row] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
twi2c_reply(i2cp, qwiic_keyboard_matrix_message, QWIIC_KEYBOARD_MATRIX_MESSAGE_SIZE);
|
||||||
twi2c_reply(i2cp, qwiic_keyboard_matrix_message, QWIIC_KEYBOARD_MATRIX_MESSAGE_SIZE);
|
break;
|
||||||
if (first_message) {
|
default:
|
||||||
PLAY_SONG(song_one_up);
|
qwiic_keyboard_listening_address[0] = body[0];
|
||||||
first_message = false;
|
twi2c_add_listening(body[0]);
|
||||||
}
|
twi2c_remove_listening(QWIIC_KEYBOARD_HANDSHAKE_ADDRESS);
|
||||||
} else {
|
qwiic_keyboard_connected[0] = true;
|
||||||
qwiic_keyboard_connected = true;
|
qwiic_keyboard_master = false;
|
||||||
qwiic_keyboard_master = false;
|
twi2c_reply(i2cp, qwiic_keyboard_listening_address, 1);
|
||||||
qwiic_keyboard_listening_address = body[0];
|
break;
|
||||||
twi2c_restart_listening(qwiic_keyboard_listening_address);
|
|
||||||
qwiic_keyboard_write_keymap(qwiic_keyboard_handshake_message);
|
|
||||||
twi2c_reply(i2cp, qwiic_keyboard_handshake_message, QWIIC_KEYBOARD_HANDSHAKE_MESSAGE_SIZE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +254,8 @@ void qwiic_keyboard_write_keymap(uint8_t * pointer) {
|
|||||||
for (uint8_t layer = 0; layer < QWIIC_KEYBOARD_LAYERS; layer++) {
|
for (uint8_t layer = 0; layer < QWIIC_KEYBOARD_LAYERS; layer++) {
|
||||||
for (uint8_t row = 0; row < QWIIC_KEYBOARD_ROWS; row++) {
|
for (uint8_t row = 0; row < QWIIC_KEYBOARD_ROWS; row++) {
|
||||||
for (uint8_t col = 0; col < QWIIC_KEYBOARD_COLS; col++) {
|
for (uint8_t col = 0; col < QWIIC_KEYBOARD_COLS; col++) {
|
||||||
uint16_t keycode = pgm_read_word(&keymaps[layer][row][col]);
|
uint16_t keycode = 0;
|
||||||
|
keycode = pgm_read_word(&keymaps[layer][row][col]);
|
||||||
*pointer++ = (keycode >> 8);
|
*pointer++ = (keycode >> 8);
|
||||||
*pointer++ = (keycode & 0xFF);
|
*pointer++ = (keycode & 0xFF);
|
||||||
}
|
}
|
||||||
@@ -172,13 +263,13 @@ void qwiic_keyboard_write_keymap(uint8_t * pointer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void qwiic_keyboard_read_keymap(uint8_t * pointer) {
|
void qwiic_keyboard_read_keymap(uint8_t * pointer, uint8_t index) {
|
||||||
for (uint8_t layer = 0; layer < QWIIC_KEYBOARD_LAYERS; layer++) {
|
for (uint8_t layer = 0; layer < QWIIC_KEYBOARD_LAYERS; layer++) {
|
||||||
for (uint8_t row = 0; row < QWIIC_KEYBOARD_ROWS; row++) {
|
for (uint8_t row = 0; row < QWIIC_KEYBOARD_ROWS; row++) {
|
||||||
for (uint8_t col = 0; col < QWIIC_KEYBOARD_COLS; col++) {
|
for (uint8_t col = 0; col < QWIIC_KEYBOARD_COLS; col++) {
|
||||||
uint16_t keycode = ((*pointer++) << 8);
|
uint16_t keycode = ((*pointer++) << 8);
|
||||||
keycode |= (*pointer++);
|
keycode |= (*pointer++);
|
||||||
qwiic_keyboard_keymap[layer][row][col] = keycode;
|
qwiic_keyboard_keymap[index][layer][row][col] = keycode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -191,12 +282,11 @@ bool is_keyboard_master(void) {
|
|||||||
|
|
||||||
// overwrite the built-in function
|
// overwrite the built-in function
|
||||||
uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) {
|
uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) {
|
||||||
if (qwiic_keyboard_processing_slave) {
|
if (qwiic_keyboard_processing_slave == QWIIC_KEYBOARD_NOT_PROCESSING) {
|
||||||
// trick the built-in handling to accept our replacement keymap
|
|
||||||
return qwiic_keyboard_keymap[(layer)][(key.row)][(key.col)];
|
|
||||||
//return KC_A;
|
|
||||||
} else {
|
|
||||||
// Read entire word (16bits)
|
// Read entire word (16bits)
|
||||||
return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]);
|
return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]);
|
||||||
|
} else {
|
||||||
|
// trick the built-in handling to accept our replacement keymap
|
||||||
|
return qwiic_keyboard_keymap[qwiic_keyboard_processing_slave][(layer)][(key.row)][(key.col)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -141,11 +141,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
// 0b1110111 AD <-> VCC
|
// 0b1110111 AD <-> VCC
|
||||||
// 0b1110101 AD <-> SCL
|
// 0b1110101 AD <-> SCL
|
||||||
// 0b1110110 AD <-> SDA
|
// 0b1110110 AD <-> SDA
|
||||||
#define DRIVER_ADDR_1 0b1110100
|
#define DRIVER_ADDR_1 0b1110111
|
||||||
#define DRIVER_ADDR_2 0b1110110
|
#define DRIVER_ADDR_2 0b1110101
|
||||||
|
|
||||||
#define DRIVER_COUNT 2
|
#define DRIVER_COUNT 2
|
||||||
#define DRIVER_1_LED_TOTAL 25
|
#define DRIVER_1_LED_TOTAL 24
|
||||||
#define DRIVER_2_LED_TOTAL 24
|
#define DRIVER_2_LED_TOTAL 24
|
||||||
#define DRIVER_LED_TOTAL DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL
|
#define DRIVER_LED_TOTAL DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL
|
||||||
|
|
||||||
|
@@ -43,73 +43,123 @@ const uint8_t music_map[MATRIX_ROWS][MATRIX_COLS] = LAYOUT_ortho_4x6(
|
|||||||
0, 1, 2, 3, 4, 5
|
0, 1, 2, 3, 4, 5
|
||||||
);
|
);
|
||||||
|
|
||||||
// const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
|
#ifdef RGB_MATRIX_ENABLE
|
||||||
// /* Refer to IS31 manual for these locations
|
const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
|
||||||
// * driver
|
/* Refer to IS31 manual for these locations
|
||||||
// * | R location
|
* driver
|
||||||
// * | | G location
|
* | R location
|
||||||
// * | | | B location
|
* | | G location
|
||||||
// * | | | | */
|
* | | | B location
|
||||||
// {0, C1_3, C2_3, C3_3},
|
* | | | | */
|
||||||
// {0, C1_4, C2_4, C3_4},
|
{0, C1_3, C2_3, C3_3},
|
||||||
// {0, C1_5, C2_5, C3_5},
|
{0, C1_4, C2_4, C3_4},
|
||||||
// {0, C1_11, C2_11, C3_11},
|
{0, C1_5, C2_5, C3_5},
|
||||||
// {0, C1_12, C2_12, C3_12},
|
{0, C1_11, C2_11, C3_11},
|
||||||
// {0, C1_13, C2_13, C3_13},
|
{0, C1_12, C2_12, C3_12},
|
||||||
|
{0, C1_13, C2_13, C3_13},
|
||||||
|
{1, C1_3, C2_3, C3_3},
|
||||||
|
{1, C1_4, C2_4, C3_4},
|
||||||
|
{1, C1_5, C2_5, C3_5},
|
||||||
|
{1, C1_11, C2_11, C3_11},
|
||||||
|
{1, C1_12, C2_12, C3_12},
|
||||||
|
{1, C1_13, C2_13, C3_13},
|
||||||
|
|
||||||
// {0, C1_6, C2_6, C3_6},
|
{0, C1_6, C2_6, C3_6},
|
||||||
// {0, C1_7, C2_7, C3_7},
|
{0, C1_7, C2_7, C3_7},
|
||||||
// {0, C1_8, C2_8, C3_8},
|
{0, C1_8, C2_8, C3_8},
|
||||||
// {0, C1_14, C2_14, C3_14},
|
{0, C1_14, C2_14, C3_14},
|
||||||
// {0, C1_15, C2_15, C3_15},
|
{0, C1_15, C2_15, C3_15},
|
||||||
// {0, C1_16, C2_16, C3_16},
|
{0, C1_16, C2_16, C3_16},
|
||||||
|
{1, C1_6, C2_6, C3_6},
|
||||||
|
{1, C1_7, C2_7, C3_7},
|
||||||
|
{1, C1_8, C2_8, C3_8},
|
||||||
|
{1, C1_14, C2_14, C3_14},
|
||||||
|
{1, C1_15, C2_15, C3_15},
|
||||||
|
{1, C1_16, C2_16, C3_16},
|
||||||
|
|
||||||
// {0, C9_1, C8_1, C7_1},
|
{0, C9_1, C8_1, C7_1},
|
||||||
// {0, C9_2, C8_2, C7_2},
|
{0, C9_2, C8_2, C7_2},
|
||||||
// {0, C9_3, C8_3, C7_3},
|
{0, C9_3, C8_3, C7_3},
|
||||||
// {0, C9_9, C8_9, C7_9},
|
{0, C9_9, C8_9, C7_9},
|
||||||
// {0, C9_10, C8_10, C7_10},
|
{0, C9_10, C8_10, C7_10},
|
||||||
// {0, C9_11, C8_11, C7_11},
|
{0, C9_11, C8_11, C7_11},
|
||||||
|
{1, C9_1, C8_1, C7_1},
|
||||||
|
{1, C9_2, C8_2, C7_2},
|
||||||
|
{1, C9_3, C8_3, C7_3},
|
||||||
|
{1, C9_9, C8_9, C7_9},
|
||||||
|
{1, C9_10, C8_10, C7_10},
|
||||||
|
{1, C9_11, C8_11, C7_11},
|
||||||
|
|
||||||
// {0, C9_4, C8_4, C7_4},
|
{0, C9_4, C8_4, C7_4},
|
||||||
// {0, C9_5, C8_5, C7_5},
|
{0, C9_5, C8_5, C7_5},
|
||||||
// {0, C9_6, C8_6, C7_6},
|
{0, C9_6, C8_6, C7_6},
|
||||||
// {0, C9_12, C8_12, C7_12},
|
{0, C9_12, C8_12, C7_12},
|
||||||
// {0, C9_13, C8_13, C7_13},
|
{0, C9_13, C8_13, C7_13},
|
||||||
// {0, C9_14, C8_14, C7_14}
|
{0, C9_14, C8_14, C7_14},
|
||||||
// };
|
{1, C9_4, C8_4, C7_4},
|
||||||
|
{1, C9_5, C8_5, C7_5},
|
||||||
|
{1, C9_6, C8_6, C7_6},
|
||||||
|
{1, C9_12, C8_12, C7_12},
|
||||||
|
{1, C9_13, C8_13, C7_13},
|
||||||
|
{1, C9_14, C8_14, C7_14}
|
||||||
|
};
|
||||||
|
|
||||||
// const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
|
const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
|
||||||
|
|
||||||
// {row | col << 4}
|
/*{row | col << 4}
|
||||||
// | {x=0..224, y=0..64}
|
| {x=0..224, y=0..64}
|
||||||
// | | modifier
|
| | modifier
|
||||||
// | | |
|
| | | */
|
||||||
// {{0|(0<<4)}, {20.36*0, 21.33*0}, 1},
|
{{0|(0<<4)}, {20.36*0, 21.33*0}, 1},
|
||||||
// {{0|(1<<4)}, {20.36*1, 21.33*0}, 0},
|
{{0|(1<<4)}, {20.36*1, 21.33*0}, 0},
|
||||||
// {{0|(2<<4)}, {20.36*2, 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|(3<<4)}, {20.36*3, 21.33*0}, 0},
|
||||||
// {{0|(4<<4)}, {20.36*4, 21.33*0}, 0},
|
{{0|(4<<4)}, {20.36*4, 21.33*0}, 0},
|
||||||
// {{0|(5<<4)}, {20.36*5, 21.33*0}, 0},
|
{{0|(5<<4)}, {20.36*5, 21.33*0}, 0},
|
||||||
|
{{0|(6<<4)}, {20.36*6, 21.33*0}, 0},
|
||||||
|
{{0|(7<<4)}, {20.36*7, 21.33*0}, 0},
|
||||||
|
{{0|(8<<4)}, {20.36*8, 21.33*0}, 0},
|
||||||
|
{{0|(9<<4)}, {20.36*9, 21.33*0}, 0},
|
||||||
|
{{0|(10<<4)}, {20.36*10,21.33*0}, 0},
|
||||||
|
{{0|(11<<4)}, {20.36*11,21.33*0}, 1},
|
||||||
|
|
||||||
// {{1|(0<<4)}, {20.36*0, 21.33*1}, 1},
|
{{1|(0<<4)}, {20.36*0, 21.33*1}, 1},
|
||||||
// {{1|(1<<4)}, {20.36*1, 21.33*1}, 0},
|
{{1|(1<<4)}, {20.36*1, 21.33*1}, 0},
|
||||||
// {{1|(2<<4)}, {20.36*2, 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|(3<<4)}, {20.36*3, 21.33*1}, 0},
|
||||||
// {{1|(4<<4)}, {20.36*4, 21.33*1}, 0},
|
{{1|(4<<4)}, {20.36*4, 21.33*1}, 0},
|
||||||
// {{1|(5<<4)}, {20.36*5, 21.33*1}, 0},
|
{{1|(5<<4)}, {20.36*5, 21.33*1}, 0},
|
||||||
|
{{1|(6<<4)}, {20.36*6, 21.33*1}, 0},
|
||||||
|
{{1|(7<<4)}, {20.36*7, 21.33*1}, 0},
|
||||||
|
{{1|(8<<4)}, {20.36*8, 21.33*1}, 0},
|
||||||
|
{{1|(9<<4)}, {20.36*9, 21.33*1}, 0},
|
||||||
|
{{1|(10<<4)}, {20.36*10,21.33*1}, 0},
|
||||||
|
{{1|(11<<4)}, {20.36*11,21.33*1}, 1},
|
||||||
|
|
||||||
// {{2|(0<<4)}, {20.36*0, 21.33*2}, 1},
|
{{2|(0<<4)}, {20.36*0, 21.33*2}, 1},
|
||||||
// {{2|(1<<4)}, {20.36*1, 21.33*2}, 0},
|
{{2|(1<<4)}, {20.36*1, 21.33*2}, 0},
|
||||||
// {{2|(2<<4)}, {20.36*2, 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|(3<<4)}, {20.36*3, 21.33*2}, 0},
|
||||||
// {{2|(4<<4)}, {20.36*4, 21.33*2}, 0},
|
{{2|(4<<4)}, {20.36*4, 21.33*2}, 0},
|
||||||
// {{2|(5<<4)}, {20.36*5, 21.33*2}, 0},
|
{{2|(5<<4)}, {20.36*5, 21.33*2}, 0},
|
||||||
|
{{2|(6<<4)}, {20.36*6, 21.33*2}, 0},
|
||||||
|
{{2|(7<<4)}, {20.36*7, 21.33*2}, 0},
|
||||||
|
{{2|(8<<4)}, {20.36*8, 21.33*2}, 0},
|
||||||
|
{{2|(9<<4)}, {20.36*9, 21.33*2}, 0},
|
||||||
|
{{2|(10<<4)}, {20.36*10,21.33*2}, 0},
|
||||||
|
{{2|(11<<4)}, {20.36*11,21.33*2}, 1},
|
||||||
|
|
||||||
// {{3|(0<<4)}, {20.36*0, 21.33*3}, 1},
|
{{3|(0<<4)}, {20.36*0, 21.33*3}, 1},
|
||||||
// {{3|(1<<4)}, {20.36*1, 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|(2<<4)}, {20.36*2, 21.33*3}, 1},
|
||||||
// {{3|(3<<4)}, {20.36*3, 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|(4<<4)}, {20.36*4, 21.33*3}, 1},
|
||||||
// {{3|(5<<4)}, {20.36*5, 21.33*3}, 0}
|
{{3|(5<<4)}, {20.36*5, 21.33*3}, 0},
|
||||||
// };
|
{{3|(6<<4)}, {20.36*6, 21.33*3}, 0},
|
||||||
|
{{3|(7<<4)}, {20.36*7, 21.33*3}, 1},
|
||||||
|
{{3|(8<<4)}, {20.36*8, 21.33*3}, 1},
|
||||||
|
{{3|(9<<4)}, {20.36*9, 21.33*3}, 1},
|
||||||
|
{{3|(10<<4)}, {20.36*10,21.33*3}, 1},
|
||||||
|
{{3|(11<<4)}, {20.36*11,21.33*3}, 1}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
Reference in New Issue
Block a user