forked from mirrors/qmk_firmware
Merge branch 'develop'
This commit is contained in:
commit
4e369d405a
4850 changed files with 65114 additions and 191103 deletions
27
Makefile
27
Makefile
|
@ -337,24 +337,23 @@ define BUILD_TEST
|
|||
endif
|
||||
endef
|
||||
|
||||
define LIST_TEST
|
||||
include $(BUILDDEFS_PATH)/testlist.mk
|
||||
FOUND_TESTS := $$(patsubst ./tests/%,%,$$(TEST_LIST))
|
||||
$$(info $$(FOUND_TESTS))
|
||||
endef
|
||||
|
||||
define PARSE_TEST
|
||||
TESTS :=
|
||||
# list of possible targets, colon-delimited, to reassign to MAKE_TARGET and remove
|
||||
TARGETS := :clean:
|
||||
ifneq (,$$(findstring :$$(lastword $$(subst :, ,$$(RULE))):, $$(TARGETS)))
|
||||
MAKE_TARGET := $$(lastword $$(subst :, ,$$(RULE)))
|
||||
TEST_SUBPATH := $$(subst $$(eval) ,/,$$(wordlist 2, $$(words $$(subst :, ,$$(RULE))), _ $$(subst :, ,$$(RULE))))
|
||||
else
|
||||
MAKE_TARGET :=
|
||||
TEST_SUBPATH := $$(subst :,/,$$(RULE))
|
||||
endif
|
||||
TEST_NAME := $$(firstword $$(subst :, ,$$(RULE)))
|
||||
TEST_TARGET := $$(subst $$(TEST_NAME),,$$(subst $$(TEST_NAME):,,$$(RULE)))
|
||||
include $(BUILDDEFS_PATH)/testlist.mk
|
||||
ifeq ($$(RULE),all)
|
||||
ifeq ($$(TEST_NAME),all)
|
||||
MATCHED_TESTS := $$(TEST_LIST)
|
||||
else
|
||||
MATCHED_TESTS := $$(foreach TEST, $$(TEST_LIST),$$(if $$(findstring /$$(TEST_SUBPATH)/, $$(patsubst %,%/,$$(TEST))), $$(TEST),))
|
||||
MATCHED_TESTS := $$(foreach TEST, $$(TEST_LIST),$$(if $$(findstring x$$(TEST_NAME)x, x$$(patsubst ./tests/%,%,$$(TEST)x)), $$(TEST),))
|
||||
endif
|
||||
$$(foreach TEST,$$(MATCHED_TESTS),$$(eval $$(call BUILD_TEST,$$(TEST),$$(MAKE_TARGET))))
|
||||
$$(foreach TEST,$$(MATCHED_TESTS),$$(eval $$(call BUILD_TEST,$$(TEST),$$(TEST_TARGET))))
|
||||
endef
|
||||
|
||||
|
||||
|
@ -437,6 +436,10 @@ git-submodules: git-submodule
|
|||
list-keyboards:
|
||||
$(QMK_BIN) list-keyboards --no-resolve-defaults | tr '\n' ' '
|
||||
|
||||
.PHONY: list-tests
|
||||
list-tests:
|
||||
$(eval $(call LIST_TEST))
|
||||
|
||||
.PHONY: generate-keyboards-file
|
||||
generate-keyboards-file:
|
||||
$(QMK_BIN) list-keyboards --no-resolve-defaults
|
||||
|
|
|
@ -313,6 +313,7 @@ ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
|
|||
OPT_DEFS += -DRGBLIGHT_$(strip $(shell echo $(RGBLIGHT_DRIVER) | tr '[:lower:]' '[:upper:]'))
|
||||
SRC += $(QUANTUM_DIR)/color.c
|
||||
SRC += $(QUANTUM_DIR)/rgblight/rgblight.c
|
||||
SRC += $(QUANTUM_DIR)/rgblight/rgblight_drivers.c
|
||||
CIE1931_CURVE := yes
|
||||
RGB_KEYCODES_ENABLE := yes
|
||||
endif
|
||||
|
@ -339,7 +340,7 @@ LED_MATRIX_DRIVER := snled27351
|
|||
endif
|
||||
|
||||
LED_MATRIX_ENABLE ?= no
|
||||
VALID_LED_MATRIX_TYPES := is31fl3218 is31fl3731 is31fl3733 is31fl3736 is31fl3737 is31fl3741 is31fl3742a is31fl3743a is31fl3745 is31fl3746a snled27351 custom
|
||||
VALID_LED_MATRIX_TYPES := is31fl3218 is31fl3729 is31fl3731 is31fl3733 is31fl3736 is31fl3737 is31fl3741 is31fl3742a is31fl3743a is31fl3745 is31fl3746a snled27351 custom
|
||||
|
||||
ifeq ($(strip $(LED_MATRIX_ENABLE)), yes)
|
||||
ifeq ($(filter $(LED_MATRIX_DRIVER),$(VALID_LED_MATRIX_TYPES)),)
|
||||
|
@ -361,71 +362,73 @@ ifeq ($(strip $(LED_MATRIX_ENABLE)), yes)
|
|||
ifeq ($(strip $(LED_MATRIX_DRIVER)), is31fl3218)
|
||||
I2C_DRIVER_REQUIRED = yes
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31fl3218-simple.c
|
||||
SRC += is31fl3218-mono.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(LED_MATRIX_DRIVER)), is31fl3729)
|
||||
I2C_DRIVER_REQUIRED = yes
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31fl3729-mono.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(LED_MATRIX_DRIVER)), is31fl3731)
|
||||
I2C_DRIVER_REQUIRED = yes
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31fl3731-simple.c
|
||||
SRC += is31fl3731-mono.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(LED_MATRIX_DRIVER)), is31fl3733)
|
||||
I2C_DRIVER_REQUIRED = yes
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31fl3733-simple.c
|
||||
SRC += is31fl3733-mono.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(LED_MATRIX_DRIVER)), is31fl3736)
|
||||
I2C_DRIVER_REQUIRED = yes
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31fl3736-simple.c
|
||||
SRC += is31fl3736-mono.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(LED_MATRIX_DRIVER)), is31fl3737)
|
||||
I2C_DRIVER_REQUIRED = yes
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31fl3737-simple.c
|
||||
SRC += is31fl3737-mono.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(LED_MATRIX_DRIVER)), is31fl3741)
|
||||
I2C_DRIVER_REQUIRED = yes
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31fl3741-simple.c
|
||||
SRC += is31fl3741-mono.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(LED_MATRIX_DRIVER)), is31fl3742a)
|
||||
OPT_DEFS += -DIS31FLCOMMON
|
||||
I2C_DRIVER_REQUIRED = yes
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31flcommon.c
|
||||
SRC += is31fl3742a-mono.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(LED_MATRIX_DRIVER)), is31fl3743a)
|
||||
OPT_DEFS += -DIS31FLCOMMON
|
||||
I2C_DRIVER_REQUIRED = yes
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31flcommon.c
|
||||
SRC += is31fl3743a-mono.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(LED_MATRIX_DRIVER)), is31fl3745)
|
||||
OPT_DEFS += -DIS31FLCOMMON
|
||||
I2C_DRIVER_REQUIRED = yes
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31flcommon.c
|
||||
SRC += is31fl3745-mono.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(LED_MATRIX_DRIVER)), is31fl3746a)
|
||||
OPT_DEFS += -DIS31FLCOMMON
|
||||
I2C_DRIVER_REQUIRED = yes
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31flcommon.c
|
||||
SRC += is31fl3746a-mono.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(LED_MATRIX_DRIVER)), snled27351)
|
||||
I2C_DRIVER_REQUIRED = yes
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led
|
||||
SRC += snled27351-simple.c
|
||||
SRC += snled27351-mono.c
|
||||
endif
|
||||
|
||||
endif
|
||||
|
@ -440,7 +443,7 @@ endif
|
|||
|
||||
RGB_MATRIX_ENABLE ?= no
|
||||
|
||||
VALID_RGB_MATRIX_TYPES := aw20216s is31fl3218 is31fl3731 is31fl3733 is31fl3736 is31fl3737 is31fl3741 is31fl3742a is31fl3743a is31fl3745 is31fl3746a snled27351 ws2812 custom
|
||||
VALID_RGB_MATRIX_TYPES := aw20216s is31fl3218 is31fl3729 is31fl3731 is31fl3733 is31fl3736 is31fl3737 is31fl3741 is31fl3742a is31fl3743a is31fl3745 is31fl3746a snled27351 ws2812 custom
|
||||
ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
|
||||
ifeq ($(filter $(RGB_MATRIX_DRIVER),$(VALID_RGB_MATRIX_TYPES)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid RGB_MATRIX_DRIVER,RGB_MATRIX_DRIVER="$(RGB_MATRIX_DRIVER)" is not a valid matrix type)
|
||||
|
@ -471,6 +474,12 @@ ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
|
|||
SRC += is31fl3218.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_DRIVER)), is31fl3729)
|
||||
I2C_DRIVER_REQUIRED = yes
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31fl3729.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_DRIVER)), is31fl3731)
|
||||
I2C_DRIVER_REQUIRED = yes
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
|
@ -502,31 +511,27 @@ ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
|
|||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_DRIVER)), is31fl3742a)
|
||||
OPT_DEFS += -DIS31FLCOMMON
|
||||
I2C_DRIVER_REQUIRED = yes
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31flcommon.c
|
||||
SRC += is31fl3742a.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_DRIVER)), is31fl3743a)
|
||||
OPT_DEFS += -DIS31FLCOMMON
|
||||
I2C_DRIVER_REQUIRED = yes
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31flcommon.c
|
||||
SRC += is31fl3743a.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_DRIVER)), is31fl3745)
|
||||
OPT_DEFS += -DIS31FLCOMMON
|
||||
I2C_DRIVER_REQUIRED = yes
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31flcommon.c
|
||||
SRC += is31fl3745.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_DRIVER)), is31fl3746a)
|
||||
OPT_DEFS += -DIS31FLCOMMON
|
||||
I2C_DRIVER_REQUIRED = yes
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31flcommon.c
|
||||
SRC += is31fl3746a.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_DRIVER)), snled27351)
|
||||
|
@ -615,24 +620,9 @@ ifeq ($(strip $(VIA_ENABLE)), yes)
|
|||
TRI_LAYER_ENABLE := yes
|
||||
endif
|
||||
|
||||
VALID_MAGIC_TYPES := yes
|
||||
BOOTMAGIC_ENABLE ?= no
|
||||
ifneq ($(strip $(BOOTMAGIC_ENABLE)), no)
|
||||
ifeq ($(filter $(BOOTMAGIC_ENABLE),$(VALID_MAGIC_TYPES)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid BOOTMAGIC_ENABLE,BOOTMAGIC_ENABLE="$(BOOTMAGIC_ENABLE)" is not a valid type of magic)
|
||||
endif
|
||||
ifneq ($(strip $(BOOTMAGIC_ENABLE)), no)
|
||||
OPT_DEFS += -DBOOTMAGIC_LITE
|
||||
QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/bootmagic_lite.c
|
||||
endif
|
||||
endif
|
||||
COMMON_VPATH += $(QUANTUM_DIR)/bootmagic
|
||||
QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/magic.c
|
||||
|
||||
VALID_CUSTOM_MATRIX_TYPES:= yes lite no
|
||||
|
||||
CUSTOM_MATRIX ?= no
|
||||
|
||||
ifneq ($(strip $(CUSTOM_MATRIX)), yes)
|
||||
ifeq ($(filter $(CUSTOM_MATRIX),$(VALID_CUSTOM_MATRIX_TYPES)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid CUSTOM_MATRIX,CUSTOM_MATRIX="$(CUSTOM_MATRIX)" is not a valid custom matrix type)
|
||||
|
@ -837,15 +827,12 @@ ifeq ($(strip $(JOYSTICK_ENABLE)), yes)
|
|||
$(call CATASTROPHIC_ERROR,Invalid JOYSTICK_DRIVER,JOYSTICK_DRIVER="$(JOYSTICK_DRIVER)" is not a valid joystick driver)
|
||||
endif
|
||||
OPT_DEFS += -DJOYSTICK_ENABLE
|
||||
OPT_DEFS += -DJOYSTICK_$(strip $(shell echo $(JOYSTICK_DRIVER) | tr '[:lower:]' '[:upper:]'))
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_joystick.c
|
||||
SRC += $(QUANTUM_DIR)/joystick.c
|
||||
|
||||
ifeq ($(strip $(JOYSTICK_DRIVER)), analog)
|
||||
ANALOG_DRIVER_REQUIRED = yes
|
||||
OPT_DEFS += -DANALOG_JOYSTICK_ENABLE
|
||||
endif
|
||||
ifeq ($(strip $(JOYSTICK_DRIVER)), digital)
|
||||
OPT_DEFS += -DDIGITAL_JOYSTICK_ENABLE
|
||||
endif
|
||||
endif
|
||||
|
||||
|
@ -899,14 +886,35 @@ ifeq ($(strip $(BLUETOOTH_ENABLE)), yes)
|
|||
endif
|
||||
endif
|
||||
|
||||
ENCODER_ENABLE ?= no
|
||||
ENCODER_DRIVER ?= quadrature
|
||||
VALID_ENCODER_DRIVER_TYPES := quadrature custom
|
||||
ifeq ($(strip $(ENCODER_ENABLE)), yes)
|
||||
ifeq ($(filter $(ENCODER_DRIVER),$(VALID_ENCODER_DRIVER_TYPES)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid ENCODER_DRIVER,ENCODER_DRIVER="$(ENCODER_DRIVER)" is not a valid encoder driver)
|
||||
endif
|
||||
SRC += $(QUANTUM_DIR)/encoder.c
|
||||
OPT_DEFS += -DENCODER_ENABLE
|
||||
OPT_DEFS += -DENCODER_DRIVER_$(strip $(shell echo $(ENCODER_DRIVER) | tr '[:lower:]' '[:upper:]'))
|
||||
|
||||
COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/encoder
|
||||
COMMON_VPATH += $(DRIVER_PATH)/encoder
|
||||
|
||||
ifneq ($(strip $(ENCODER_DRIVER)), custom)
|
||||
SRC += encoder_$(strip $(ENCODER_DRIVER)).c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(ENCODER_MAP_ENABLE)), yes)
|
||||
OPT_DEFS += -DENCODER_MAP_ENABLE
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(DIP_SWITCH_ENABLE)), yes)
|
||||
ifeq ($(strip $(DIP_SWITCH_MAP_ENABLE)), yes)
|
||||
OPT_DEFS += -DDIP_SWITCH_MAP_ENABLE
|
||||
endif
|
||||
endif
|
||||
|
||||
VALID_WS2812_DRIVER_TYPES := bitbang custom i2c pwm spi vendor
|
||||
|
||||
WS2812_DRIVER ?= bitbang
|
||||
|
@ -952,6 +960,15 @@ ifeq ($(strip $(SPI_DRIVER_REQUIRED)), yes)
|
|||
endif
|
||||
|
||||
ifeq ($(strip $(UART_DRIVER_REQUIRED)), yes)
|
||||
OPT_DEFS += -DHAL_USE_SERIAL=TRUE
|
||||
QUANTUM_LIB_SRC += uart.c
|
||||
ifeq ($(strip $(PLATFORM)), CHIBIOS)
|
||||
ifneq ($(filter $(MCU_SERIES),RP2040),)
|
||||
OPT_DEFS += -DHAL_USE_SIO=TRUE
|
||||
QUANTUM_LIB_SRC += uart_sio.c
|
||||
else
|
||||
OPT_DEFS += -DHAL_USE_SERIAL=TRUE
|
||||
QUANTUM_LIB_SRC += uart_serial.c
|
||||
endif
|
||||
else
|
||||
QUANTUM_LIB_SRC += uart.c
|
||||
endif
|
||||
endif
|
||||
|
|
|
@ -21,6 +21,7 @@ SPACE_CADET_ENABLE ?= yes
|
|||
GENERIC_FEATURES = \
|
||||
AUTO_SHIFT \
|
||||
AUTOCORRECT \
|
||||
BOOTMAGIC \
|
||||
CAPS_WORD \
|
||||
COMBO \
|
||||
COMMAND \
|
||||
|
|
|
@ -0,0 +1,407 @@
|
|||
{
|
||||
"aliases": {
|
||||
/*
|
||||
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
|
||||
* │ # │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ │
|
||||
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
|
||||
* │ │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ ^ │ ¸ │ │
|
||||
* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
|
||||
* │ │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ` │ < │ │
|
||||
* ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
|
||||
* │ │ « │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ É │ │
|
||||
* ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
|
||||
* │ │ │ │ │ │ │ │ │
|
||||
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
|
||||
*/
|
||||
"KC_GRV": {
|
||||
"key": "FR_HASH",
|
||||
"label": "#",
|
||||
}
|
||||
"KC_1": {
|
||||
"key": "FR_1",
|
||||
"label": "1",
|
||||
}
|
||||
"KC_2": {
|
||||
"key": "FR_2",
|
||||
"label": "2",
|
||||
}
|
||||
"KC_3": {
|
||||
"key": "FR_3",
|
||||
"label": "3",
|
||||
}
|
||||
"KC_4": {
|
||||
"key": "FR_4",
|
||||
"label": "4",
|
||||
}
|
||||
"KC_5": {
|
||||
"key": "FR_5",
|
||||
"label": "5",
|
||||
}
|
||||
"KC_6": {
|
||||
"key": "FR_6",
|
||||
"label": "6",
|
||||
}
|
||||
"KC_7": {
|
||||
"key": "FR_7",
|
||||
"label": "7",
|
||||
}
|
||||
"KC_8": {
|
||||
"key": "FR_8",
|
||||
"label": "8",
|
||||
}
|
||||
"KC_9": {
|
||||
"key": "FR_9",
|
||||
"label": "9",
|
||||
}
|
||||
"KC_0": {
|
||||
"key": "FR_0",
|
||||
"label": "0",
|
||||
}
|
||||
"KC_MINS": {
|
||||
"key": "FR_MINS",
|
||||
"label": "-",
|
||||
}
|
||||
"KC_EQL": {
|
||||
"key": "FR_EQL",
|
||||
"label": "=",
|
||||
}
|
||||
"KC_Q": {
|
||||
"key": "FR_Q",
|
||||
"label": "Q",
|
||||
}
|
||||
"KC_W": {
|
||||
"key": "FR_W",
|
||||
"label": "W",
|
||||
}
|
||||
"KC_E": {
|
||||
"key": "FR_E",
|
||||
"label": "E",
|
||||
}
|
||||
"KC_R": {
|
||||
"key": "FR_R",
|
||||
"label": "R",
|
||||
}
|
||||
"KC_T": {
|
||||
"key": "FR_T",
|
||||
"label": "T",
|
||||
}
|
||||
"KC_Y": {
|
||||
"key": "FR_Y",
|
||||
"label": "Y",
|
||||
}
|
||||
"KC_U": {
|
||||
"key": "FR_U",
|
||||
"label": "U",
|
||||
}
|
||||
"KC_I": {
|
||||
"key": "FR_I",
|
||||
"label": "I",
|
||||
}
|
||||
"KC_O": {
|
||||
"key": "FR_O",
|
||||
"label": "O",
|
||||
}
|
||||
"KC_P": {
|
||||
"key": "FR_P",
|
||||
"label": "P",
|
||||
}
|
||||
"KC_LBRC": {
|
||||
"key": "FR_DCIR",
|
||||
"label": "^ (dead)",
|
||||
}
|
||||
"KC_RBRC": {
|
||||
"key": "FR_CEDL",
|
||||
"label": "¸ (dead)",
|
||||
}
|
||||
"KC_A": {
|
||||
"key": "FR_A",
|
||||
"label": "A",
|
||||
}
|
||||
"KC_S": {
|
||||
"key": "FR_S",
|
||||
"label": "S",
|
||||
}
|
||||
"KC_D": {
|
||||
"key": "FR_D",
|
||||
"label": "D",
|
||||
}
|
||||
"KC_F": {
|
||||
"key": "FR_F",
|
||||
"label": "F",
|
||||
}
|
||||
"KC_G": {
|
||||
"key": "FR_G",
|
||||
"label": "G",
|
||||
}
|
||||
"KC_H": {
|
||||
"key": "FR_H",
|
||||
"label": "H",
|
||||
}
|
||||
"KC_J": {
|
||||
"key": "FR_J",
|
||||
"label": "J",
|
||||
}
|
||||
"KC_K": {
|
||||
"key": "FR_K",
|
||||
"label": "K",
|
||||
}
|
||||
"KC_L": {
|
||||
"key": "FR_L",
|
||||
"label": "L",
|
||||
}
|
||||
"KC_SCLN": {
|
||||
"key": "FR_SCLN",
|
||||
"label": ";",
|
||||
}
|
||||
"KC_QUOT": {
|
||||
"key": "FR_DGRV",
|
||||
"label": "` (dead)",
|
||||
}
|
||||
"KC_NUHS": {
|
||||
"key": "FR_LABK",
|
||||
"label": "<",
|
||||
}
|
||||
"KC_NUBS": {
|
||||
"key": "FR_LDAQ",
|
||||
"label": "«",
|
||||
}
|
||||
"KC_Z": {
|
||||
"key": "FR_Z",
|
||||
"label": "Z",
|
||||
}
|
||||
"KC_X": {
|
||||
"key": "FR_X",
|
||||
"label": "X",
|
||||
}
|
||||
"KC_C": {
|
||||
"key": "FR_C",
|
||||
"label": "C",
|
||||
}
|
||||
"KC_V": {
|
||||
"key": "FR_V",
|
||||
"label": "V",
|
||||
}
|
||||
"KC_B": {
|
||||
"key": "FR_B",
|
||||
"label": "B",
|
||||
}
|
||||
"KC_N": {
|
||||
"key": "FR_N",
|
||||
"label": "N",
|
||||
}
|
||||
"KC_M": {
|
||||
"key": "FR_M",
|
||||
"label": "M",
|
||||
}
|
||||
"KC_COMM": {
|
||||
"key": "FR_COMM",
|
||||
"label": ",",
|
||||
}
|
||||
"KC_DOT": {
|
||||
"key": "FR_DOT",
|
||||
"label": ".",
|
||||
}
|
||||
"KC_SLSH": {
|
||||
"key": "FR_EACU",
|
||||
"label": "É",
|
||||
}
|
||||
/* Shifted symbols
|
||||
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
|
||||
* │ | │ ! │ " │ / │ $ │ % │ ? │ & │ * │ ( │ ) │ _ │ + │ │
|
||||
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
|
||||
* │ │ │ │ │ │ │ │ │ │ │ │ │ ¨ │ │
|
||||
* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
|
||||
* │ │ │ │ │ │ │ │ │ │ │ : │ │ > │ │
|
||||
* ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
|
||||
* │ │ » │ │ │ │ │ │ │ │ ' │ │ │ │
|
||||
* ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
|
||||
* │ │ │ │ │ │ │ │ │
|
||||
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
|
||||
*/
|
||||
"S(FR_HASH)": {
|
||||
"key": "FR_PIPE",
|
||||
"label": "|",
|
||||
}
|
||||
"S(FR_1)": {
|
||||
"key": "FR_EXLM",
|
||||
"label": "!",
|
||||
}
|
||||
"S(FR_2)": {
|
||||
"key": "FR_DQUO",
|
||||
"label": "\"",
|
||||
}
|
||||
"S(FR_3)": {
|
||||
"key": "FR_SLSH",
|
||||
"label": "/",
|
||||
}
|
||||
"S(FR_4)": {
|
||||
"key": "FR_DLR",
|
||||
"label": "$",
|
||||
}
|
||||
"S(FR_5)": {
|
||||
"key": "FR_PERC",
|
||||
"label": "%",
|
||||
}
|
||||
"S(FR_6)": {
|
||||
"key": "FR_QUES",
|
||||
"label": "?",
|
||||
}
|
||||
"S(FR_7)": {
|
||||
"key": "FR_AMPR",
|
||||
"label": "&",
|
||||
}
|
||||
"S(FR_8)": {
|
||||
"key": "FR_ASTR",
|
||||
"label": "*",
|
||||
}
|
||||
"S(FR_9)": {
|
||||
"key": "FR_LPRN",
|
||||
"label": "(",
|
||||
}
|
||||
"S(FR_0)": {
|
||||
"key": "FR_RPRN",
|
||||
"label": ")",
|
||||
}
|
||||
"S(FR_MINS)": {
|
||||
"key": "FR_UNDS",
|
||||
"label": "_",
|
||||
}
|
||||
"S(FR_EQL)": {
|
||||
"key": "FR_PLUS",
|
||||
"label": "+",
|
||||
}
|
||||
"S(FR_CEDL)": {
|
||||
"key": "FR_DIAE",
|
||||
"label": "¨ (dead)",
|
||||
}
|
||||
"S(FR_SCLN)": {
|
||||
"key": "FR_COLN",
|
||||
"label": ":",
|
||||
}
|
||||
"S(FR_LABK)": {
|
||||
"key": "FR_RABK",
|
||||
"label": ">",
|
||||
}
|
||||
"S(FR_LDAQ)": {
|
||||
"key": "FR_RDAQ",
|
||||
"label": "»",
|
||||
}
|
||||
"S(FR_COMM)": {
|
||||
"key": "FR_QUOT",
|
||||
"label": "'",
|
||||
}
|
||||
/* AltGr symbols
|
||||
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
|
||||
* │ \ │ ± │ @ │ £ │ ¢ │ ¤ │ ¬ │ ¦ │ ² │ ³ │ ¼ │ ½ │ ¾ │ │
|
||||
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
|
||||
* │ │ │ │ │ │ │ │ │ │ § │ ¶ │ [ │ ] │ │
|
||||
* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
|
||||
* │ │ │ │ │ │ │ │ │ │ │ ~ │ { │ } │ │
|
||||
* ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
|
||||
* │ │ ° │ │ │ │ │ │ │ µ │ ¯ │ - │ ´ │ │
|
||||
* ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
|
||||
* │ │ │ │ │ │ │ │ │
|
||||
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
|
||||
*/
|
||||
"ALGR(FR_HASH)": {
|
||||
"key": "FR_BSLS",
|
||||
"label": "\\",
|
||||
}
|
||||
"ALGR(FR_1)": {
|
||||
"key": "FR_PLMN",
|
||||
"label": "±",
|
||||
}
|
||||
"ALGR(FR_2)": {
|
||||
"key": "FR_AT",
|
||||
"label": "@",
|
||||
}
|
||||
"ALGR(FR_3)": {
|
||||
"key": "FR_PND",
|
||||
"label": "£",
|
||||
}
|
||||
"ALGR(FR_4)": {
|
||||
"key": "FR_CENT",
|
||||
"label": "¢",
|
||||
}
|
||||
"ALGR(FR_5)": {
|
||||
"key": "FR_CURR",
|
||||
"label": "¤",
|
||||
}
|
||||
"ALGR(FR_6)": {
|
||||
"key": "FR_NOT",
|
||||
"label": "¬",
|
||||
}
|
||||
"ALGR(FR_7)": {
|
||||
"key": "FR_BRKP",
|
||||
"label": "¦",
|
||||
}
|
||||
"ALGR(FR_8)": {
|
||||
"key": "FR_SUP2",
|
||||
"label": "²",
|
||||
}
|
||||
"ALGR(FR_9)": {
|
||||
"key": "FR_SUP3",
|
||||
"label": "³",
|
||||
}
|
||||
"ALGR(FR_0)": {
|
||||
"key": "FR_QRTR",
|
||||
"label": "¼",
|
||||
}
|
||||
"ALGR(FR_MINS)": {
|
||||
"key": "FR_HALF",
|
||||
"label": "½",
|
||||
}
|
||||
"ALGR(FR_EQL)": {
|
||||
"key": "FR_TQTR",
|
||||
"label": "¾",
|
||||
}
|
||||
"ALGR(FR_O)": {
|
||||
"key": "FR_SECT",
|
||||
"label": "§",
|
||||
}
|
||||
"ALGR(FR_P)": {
|
||||
"key": "FR_PARA",
|
||||
"label": "¶",
|
||||
}
|
||||
"ALGR(FR_DCIR)": {
|
||||
"key": "FR_LBRC",
|
||||
"label": "[",
|
||||
}
|
||||
"ALGR(FR_CEDL)": {
|
||||
"key": "FR_RBRC",
|
||||
"label": "]",
|
||||
}
|
||||
"ALGR(FR_SCLN)": {
|
||||
"key": "FR_TILD",
|
||||
"label": "~",
|
||||
}
|
||||
"ALGR(FR_DGRV)": {
|
||||
"key": "FR_LCBR",
|
||||
"label": "{",
|
||||
}
|
||||
"ALGR(FR_LABK)": {
|
||||
"key": "FR_RCBR",
|
||||
"label": "}",
|
||||
}
|
||||
"ALGR(FR_LDAQ)": {
|
||||
"key": "FR_DEG",
|
||||
"label": "°",
|
||||
}
|
||||
"ALGR(FR_M)": {
|
||||
"key": "FR_MICR",
|
||||
"label": "µ",
|
||||
}
|
||||
"ALGR(FR_COMM)": {
|
||||
"key": "FR_MACR",
|
||||
"label": "¯",
|
||||
}
|
||||
"ALGR(FR_DOT)": {
|
||||
"key": "FR_SHYP",
|
||||
"label": " (soft hyphen)",
|
||||
}
|
||||
"ALGR(FR_EACU)": {
|
||||
"key": "FR_ACUT",
|
||||
"label": "´ (dead)",
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,339 @@
|
|||
{
|
||||
"aliases": {
|
||||
/*
|
||||
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
|
||||
* │ | │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ ' │ ¿ │ │
|
||||
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
|
||||
* │ │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ ´ │ + │ │
|
||||
* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
|
||||
* │ │ A │ S │ D │ F │ G │ H │ J │ K │ L │ Ñ │ { │ } │ │
|
||||
* ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
|
||||
* │ │ < │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ - │ │
|
||||
* ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
|
||||
* │ │ │ │ │ │ │ │ │
|
||||
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
|
||||
*/
|
||||
"KC_GRV": {
|
||||
"key": "ES_PIPE",
|
||||
"label": "|",
|
||||
}
|
||||
"KC_1": {
|
||||
"key": "ES_1",
|
||||
"label": "1",
|
||||
}
|
||||
"KC_2": {
|
||||
"key": "ES_2",
|
||||
"label": "2",
|
||||
}
|
||||
"KC_3": {
|
||||
"key": "ES_3",
|
||||
"label": "3",
|
||||
}
|
||||
"KC_4": {
|
||||
"key": "ES_4",
|
||||
"label": "4",
|
||||
}
|
||||
"KC_5": {
|
||||
"key": "ES_5",
|
||||
"label": "5",
|
||||
}
|
||||
"KC_6": {
|
||||
"key": "ES_6",
|
||||
"label": "6",
|
||||
}
|
||||
"KC_7": {
|
||||
"key": "ES_7",
|
||||
"label": "7",
|
||||
}
|
||||
"KC_8": {
|
||||
"key": "ES_8",
|
||||
"label": "8",
|
||||
}
|
||||
"KC_9": {
|
||||
"key": "ES_9",
|
||||
"label": "9",
|
||||
}
|
||||
"KC_0": {
|
||||
"key": "ES_0",
|
||||
"label": "0",
|
||||
}
|
||||
"KC_MINS": {
|
||||
"key": "ES_QUOT",
|
||||
"label": "'",
|
||||
}
|
||||
"KC_EQL": {
|
||||
"key": "ES_IQUE",
|
||||
"label": "¿",
|
||||
}
|
||||
"KC_Q": {
|
||||
"key": "ES_Q",
|
||||
"label": "Q",
|
||||
}
|
||||
"KC_W": {
|
||||
"key": "ES_W",
|
||||
"label": "W",
|
||||
}
|
||||
"KC_E": {
|
||||
"key": "ES_E",
|
||||
"label": "E",
|
||||
}
|
||||
"KC_R": {
|
||||
"key": "ES_R",
|
||||
"label": "R",
|
||||
}
|
||||
"KC_T": {
|
||||
"key": "ES_T",
|
||||
"label": "T",
|
||||
}
|
||||
"KC_Y": {
|
||||
"key": "ES_Y",
|
||||
"label": "Y",
|
||||
}
|
||||
"KC_U": {
|
||||
"key": "ES_U",
|
||||
"label": "U",
|
||||
}
|
||||
"KC_I": {
|
||||
"key": "ES_I",
|
||||
"label": "I",
|
||||
}
|
||||
"KC_O": {
|
||||
"key": "ES_O",
|
||||
"label": "O",
|
||||
}
|
||||
"KC_P": {
|
||||
"key": "ES_P",
|
||||
"label": "P",
|
||||
}
|
||||
"KC_LBRC": {
|
||||
"key": "ES_ACUT",
|
||||
"label": "´ (dead)",
|
||||
}
|
||||
"KC_RBRC": {
|
||||
"key": "ES_PLUS",
|
||||
"label": "+",
|
||||
}
|
||||
"KC_A": {
|
||||
"key": "ES_A",
|
||||
"label": "A",
|
||||
}
|
||||
"KC_S": {
|
||||
"key": "ES_S",
|
||||
"label": "S",
|
||||
}
|
||||
"KC_D": {
|
||||
"key": "ES_D",
|
||||
"label": "D",
|
||||
}
|
||||
"KC_F": {
|
||||
"key": "ES_F",
|
||||
"label": "F",
|
||||
}
|
||||
"KC_G": {
|
||||
"key": "ES_G",
|
||||
"label": "G",
|
||||
}
|
||||
"KC_H": {
|
||||
"key": "ES_H",
|
||||
"label": "H",
|
||||
}
|
||||
"KC_J": {
|
||||
"key": "ES_J",
|
||||
"label": "J",
|
||||
}
|
||||
"KC_K": {
|
||||
"key": "ES_K",
|
||||
"label": "K",
|
||||
}
|
||||
"KC_L": {
|
||||
"key": "ES_L",
|
||||
"label": "L",
|
||||
}
|
||||
"KC_SCLN": {
|
||||
"key": "ES_NTIL",
|
||||
"label": "Ñ",
|
||||
}
|
||||
"KC_QUOT": {
|
||||
"key": "ES_LCBR",
|
||||
"label": "{",
|
||||
}
|
||||
"KC_NUHS": {
|
||||
"key": "ES_RCBR",
|
||||
"label": "}",
|
||||
}
|
||||
"KC_NUBS": {
|
||||
"key": "ES_LABK",
|
||||
"label": "<",
|
||||
}
|
||||
"KC_Z": {
|
||||
"key": "ES_Z",
|
||||
"label": "Z",
|
||||
}
|
||||
"KC_X": {
|
||||
"key": "ES_X",
|
||||
"label": "X",
|
||||
}
|
||||
"KC_C": {
|
||||
"key": "ES_C",
|
||||
"label": "C",
|
||||
}
|
||||
"KC_V": {
|
||||
"key": "ES_V",
|
||||
"label": "V",
|
||||
}
|
||||
"KC_B": {
|
||||
"key": "ES_B",
|
||||
"label": "B",
|
||||
}
|
||||
"KC_N": {
|
||||
"key": "ES_N",
|
||||
"label": "N",
|
||||
}
|
||||
"KC_M": {
|
||||
"key": "ES_M",
|
||||
"label": "M",
|
||||
}
|
||||
"KC_COMM": {
|
||||
"key": "ES_COMM",
|
||||
"label": ",",
|
||||
}
|
||||
"KC_DOT": {
|
||||
"key": "ES_DOT",
|
||||
"label": ".",
|
||||
}
|
||||
"KC_SLSH": {
|
||||
"key": "ES_MINS",
|
||||
"label": "-",
|
||||
}
|
||||
/* Shifted symbols
|
||||
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
|
||||
* │ ° │ ! │ " │ # │ $ │ % │ & │ / │ ( │ ) │ = │ ? │ ¡ │ │
|
||||
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
|
||||
* │ │ │ │ │ │ │ │ │ │ │ │ ¨ │ * │ │
|
||||
* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
|
||||
* │ │ │ │ │ │ │ │ │ │ │ │ [ │ ] │ │
|
||||
* ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
|
||||
* │ │ > │ │ │ │ │ │ │ │ ; │ : │ _ │ │
|
||||
* ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
|
||||
* │ │ │ │ │ │ │ │ │
|
||||
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
|
||||
*/
|
||||
"S(ES_PIPE)": {
|
||||
"key": "ES_MORD",
|
||||
"label": "°",
|
||||
}
|
||||
"S(ES_1)": {
|
||||
"key": "ES_EXLM",
|
||||
"label": "!",
|
||||
}
|
||||
"S(ES_2)": {
|
||||
"key": "ES_DQUO",
|
||||
"label": "\"",
|
||||
}
|
||||
"S(ES_3)": {
|
||||
"key": "ES_NUMB",
|
||||
"label": "#",
|
||||
}
|
||||
"S(ES_4)": {
|
||||
"key": "ES_DLR",
|
||||
"label": "$",
|
||||
}
|
||||
"S(ES_5)": {
|
||||
"key": "ES_PERC",
|
||||
"label": "%",
|
||||
}
|
||||
"S(ES_6)": {
|
||||
"key": "ES_AMPR",
|
||||
"label": "&",
|
||||
}
|
||||
"S(ES_7)": {
|
||||
"key": "ES_SLSH",
|
||||
"label": "/",
|
||||
}
|
||||
"S(ES_8)": {
|
||||
"key": "ES_LPRN",
|
||||
"label": "(",
|
||||
}
|
||||
"S(ES_9)": {
|
||||
"key": "ES_RPRN",
|
||||
"label": ")",
|
||||
}
|
||||
"S(ES_0)": {
|
||||
"key": "ES_EQL",
|
||||
"label": "=",
|
||||
}
|
||||
"S(ES_QUOT)": {
|
||||
"key": "ES_QUES",
|
||||
"label": "?",
|
||||
}
|
||||
"S(ES_IQUE)": {
|
||||
"key": "ES_IEXL",
|
||||
"label": "¡",
|
||||
}
|
||||
"S(ES_ACUT)": {
|
||||
"key": "ES_DIAE",
|
||||
"label": "¨ (dead)",
|
||||
}
|
||||
"S(ES_PLUS)": {
|
||||
"key": "ES_ASTR",
|
||||
"label": "*",
|
||||
}
|
||||
"S(ES_LCBR)": {
|
||||
"key": "ES_LBRC",
|
||||
"label": "[",
|
||||
}
|
||||
"S(ES_RCBR)": {
|
||||
"key": "ES_RBRC",
|
||||
"label": "]",
|
||||
}
|
||||
"S(ES_LABK)": {
|
||||
"key": "ES_RABK",
|
||||
"label": ">",
|
||||
}
|
||||
"S(ES_COMM)": {
|
||||
"key": "ES_SCLN",
|
||||
"label": ";",
|
||||
}
|
||||
"S(ES_DOT)": {
|
||||
"key": "ES_COLN",
|
||||
"label": ":",
|
||||
}
|
||||
"S(ES_MINS)": {
|
||||
"key": "ES_UNDS",
|
||||
"label": "_",
|
||||
}
|
||||
/* AltGr symbols
|
||||
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
|
||||
* │ ¬ │ │ │ │ │ │ │ │ │ │ │ \ │ │ │
|
||||
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
|
||||
* │ │ @ │ │ │ │ │ │ │ │ │ │ │ ~ │ │
|
||||
* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
|
||||
* │ │ │ │ │ │ │ │ │ │ │ │ ^ │ ` │ │
|
||||
* ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
|
||||
* │ │ │ │ │ │ │ │ │ │ │ │ │ │
|
||||
* ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
|
||||
* │ │ │ │ │ │ │ │ │
|
||||
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
|
||||
*/
|
||||
"ALGR(ES_PIPE)": {
|
||||
"key": "ES_NOT",
|
||||
"label": "¬",
|
||||
}
|
||||
"ALGR(ES_QUOT)": {
|
||||
"key": "ES_BSLS",
|
||||
"label": "\\",
|
||||
}
|
||||
"ALGR(ES_Q)": {
|
||||
"key": "ES_AT",
|
||||
"label": "@",
|
||||
}
|
||||
"ALGR(ES_PLUS)": {
|
||||
"key": "ES_TILD",
|
||||
"label": "~",
|
||||
}
|
||||
"ALGR(ES_LCBR)": {
|
||||
"key": "ES_CIRC",
|
||||
"label": "^",
|
||||
}
|
||||
}
|
||||
}
|
|
@ -45,6 +45,11 @@
|
|||
"bootloader": "rp2040",
|
||||
"processor": "RP2040"
|
||||
},
|
||||
"imera": {
|
||||
"processor": "RP2040",
|
||||
"bootloader": "rp2040",
|
||||
"board": "QMK_PM2040"
|
||||
},
|
||||
"kb2040": {
|
||||
"board": "QMK_PM2040",
|
||||
"bootloader": "rp2040",
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
{
|
||||
// Format:
|
||||
// <config.h key>: {"info_key": <info.json key>, ["value_type": <value_type>], ["to_json": <true/false>], ["to_c": <true/false>]}
|
||||
// value_type: one of "array", "array.int", "bool", "int", "hex", "list", "mapping", "str", "raw"
|
||||
// value_type: one of "array", "array.int", "bool, "flag", "int", "hex", "list", "mapping", "str", "raw"
|
||||
// to_json: Default `true`. Set to `false` to exclude this mapping from info.json
|
||||
// to_c: Default `true`. Set to `false` to exclude this mapping from config.h
|
||||
// warn_duplicate: Default `true`. Set to `false` to turn off warning when a value exists in both places
|
||||
|
@ -17,12 +17,14 @@
|
|||
"APA102_DI_PIN": {"info_key": "apa102.data_pin"},
|
||||
|
||||
// Audio
|
||||
"AUDIO_VOICES": {"info_key": "audio.voices", "value_type": "bool"},
|
||||
"SENDSTRING_BELL": {"info_key": "audio.macro_beep", "value_type": "bool"},
|
||||
"AUDIO_DEFAULT_ON": {"info_key": "audio.default.on", "value_type": "bool"},
|
||||
"AUDIO_DEFAULT_CLICKY_ON": {"info_key": "audio.default.clicky", "value_type": "bool"},
|
||||
"AUDIO_VOICES": {"info_key": "audio.voices", "value_type": "flag"},
|
||||
"SENDSTRING_BELL": {"info_key": "audio.macro_beep", "value_type": "flag"},
|
||||
|
||||
// Backlight
|
||||
"BACKLIGHT_BREATHING": {"info_key": "backlight.breathing", "value_type": "bool"},
|
||||
"BACKLIGHT_CAPS_LOCK": {"info_key": "backlight.as_caps_lock", "value_type": "bool"},
|
||||
"BACKLIGHT_BREATHING": {"info_key": "backlight.breathing", "value_type": "flag"},
|
||||
"BACKLIGHT_CAPS_LOCK": {"info_key": "backlight.as_caps_lock", "value_type": "flag"},
|
||||
"BACKLIGHT_LEVELS": {"info_key": "backlight.levels", "value_type": "int"},
|
||||
"BACKLIGHT_LIMIT_VAL": {"info_key": "backlight.max_brightness", "value_type": "int"},
|
||||
"BACKLIGHT_ON_STATE": {"info_key": "backlight.on_state", "value_type": "int"},
|
||||
|
@ -34,16 +36,16 @@
|
|||
"BACKLIGHT_DEFAULT_LEVEL": {"info_key": "backlight.default.brightness", "value_type": "int"},
|
||||
|
||||
// Bootmagic
|
||||
"BOOTMAGIC_LITE_COLUMN": {"info_key": "bootmagic.matrix.1", "value_type": "int"},
|
||||
"BOOTMAGIC_LITE_COLUMN_RIGHT": {"info_key": "split.bootmagic.matrix.1", "value_type": "int"},
|
||||
"BOOTMAGIC_LITE_ROW": {"info_key": "bootmagic.matrix.0", "value_type": "int"},
|
||||
"BOOTMAGIC_LITE_ROW_RIGHT": {"info_key": "split.bootmagic.matrix.0", "value_type": "int"},
|
||||
"BOOTMAGIC_COLUMN": {"info_key": "bootmagic.matrix.1", "value_type": "int"},
|
||||
"BOOTMAGIC_COLUMN_RIGHT": {"info_key": "split.bootmagic.matrix.1", "value_type": "int"},
|
||||
"BOOTMAGIC_ROW": {"info_key": "bootmagic.matrix.0", "value_type": "int"},
|
||||
"BOOTMAGIC_ROW_RIGHT": {"info_key": "split.bootmagic.matrix.0", "value_type": "int"},
|
||||
|
||||
// Caps Word
|
||||
"BOTH_SHIFTS_TURNS_ON_CAPS_WORD": {"info_key": "caps_word.both_shifts_turns_on", "value_type": "bool"},
|
||||
"BOTH_SHIFTS_TURNS_ON_CAPS_WORD": {"info_key": "caps_word.both_shifts_turns_on", "value_type": "flag"},
|
||||
"CAPS_WORD_IDLE_TIMEOUT": {"info_key": "caps_word.idle_timeout", "value_type": "int"},
|
||||
"CAPS_WORD_INVERT_ON_SHIFT": {"info_key": "caps_word.invert_on_shift", "value_type": "bool"},
|
||||
"DOUBLE_TAP_SHIFT_TURNS_ON_CAPS_WORD": {"info_key": "caps_word.double_tap_shift_turns_on", "value_type": "bool"},
|
||||
"CAPS_WORD_INVERT_ON_SHIFT": {"info_key": "caps_word.invert_on_shift", "value_type": "flag"},
|
||||
"DOUBLE_TAP_SHIFT_TURNS_ON_CAPS_WORD": {"info_key": "caps_word.double_tap_shift_turns_on", "value_type": "flag"},
|
||||
|
||||
// Combos
|
||||
"COMBO_TERM": {"info_key": "combo.term", "value_type": "int"},
|
||||
|
@ -69,17 +71,17 @@
|
|||
"LED_PIN_ON_STATE": {"info_key": "indicators.on_state", "value_type": "int"},
|
||||
|
||||
// Leader Key
|
||||
"LEADER_PER_KEY_TIMING": {"info_key": "leader_key.timing", "value_type": "bool"},
|
||||
"LEADER_KEY_STRICT_KEY_PROCESSING": {"info_key": "leader_key.strict_processing", "value_type": "bool"},
|
||||
"LEADER_PER_KEY_TIMING": {"info_key": "leader_key.timing", "value_type": "flag"},
|
||||
"LEADER_KEY_STRICT_KEY_PROCESSING": {"info_key": "leader_key.strict_processing", "value_type": "flag"},
|
||||
"LEADER_TIMEOUT": {"info_key": "leader_key.timeout", "value_type": "int"},
|
||||
|
||||
// LED Matrix
|
||||
"LED_DISABLE_WHEN_USB_SUSPENDED": {"info_key": "led_matrix.sleep", "value_type": "bool"},
|
||||
"LED_MATRIX_CENTER": {"info_key": "led_matrix.center_point", "value_type": "array.int"},
|
||||
"LED_MATRIX_KEYRELEASES": {"info_key": "led_matrix.react_on_keyup", "value_type": "bool"},
|
||||
"LED_MATRIX_KEYRELEASES": {"info_key": "led_matrix.react_on_keyup", "value_type": "flag"},
|
||||
"LED_MATRIX_LED_FLUSH_LIMIT": {"info_key": "led_matrix.led_flush_limit", "value_type": "int"},
|
||||
"LED_MATRIX_LED_PROCESS_LIMIT": {"info_key": "led_matrix.led_process_limit", "value_type": "int", "to_json": false},
|
||||
"LED_MATRIX_MAXIMUM_BRIGHTNESS": {"info_key": "led_matrix.max_brightness", "value_type": "int"},
|
||||
"LED_MATRIX_SLEEP": {"info_key": "led_matrix.sleep", "value_type": "flag"},
|
||||
"LED_MATRIX_SPD_STEP": {"info_key": "led_matrix.speed_steps", "value_type": "int"},
|
||||
"LED_MATRIX_SPLIT": {"info_key": "led_matrix.split_count", "value_type": "array.int"},
|
||||
"LED_MATRIX_TIMEOUT": {"info_key": "led_matrix.timeout", "value_type": "int"},
|
||||
|
@ -90,8 +92,8 @@
|
|||
"LED_MATRIX_DEFAULT_SPD": {"info_key": "led_matrix.default.speed", "value_type": "int"},
|
||||
|
||||
// Locking Switch
|
||||
"LOCKING_SUPPORT_ENABLE": {"info_key": "qmk.locking.enabled", "value_type": "bool"},
|
||||
"LOCKING_RESYNC_ENABLE": {"info_key": "qmk.locking.resync", "value_type": "bool"},
|
||||
"LOCKING_SUPPORT_ENABLE": {"info_key": "qmk.locking.enabled", "value_type": "flag"},
|
||||
"LOCKING_RESYNC_ENABLE": {"info_key": "qmk.locking.resync", "value_type": "flag"},
|
||||
|
||||
// LUFA Bootloader
|
||||
"QMK_ESC_INPUT": {"info_key": "qmk_lufa_bootloader.esc_input"},
|
||||
|
@ -102,7 +104,7 @@
|
|||
// Matrix
|
||||
"DEBOUNCE": {"info_key": "debounce", "value_type": "int"},
|
||||
"DIODE_DIRECTION": {"info_key": "diode_direction"},
|
||||
"MATRIX_HAS_GHOST": {"info_key": "matrix_pins.ghost", "value_type": "bool"},
|
||||
"MATRIX_HAS_GHOST": {"info_key": "matrix_pins.ghost", "value_type": "flag"},
|
||||
"MATRIX_INPUT_PRESSED_STATE": {"info_key": "matrix_pins.input_pressed_state", "value_type": "int"},
|
||||
"MATRIX_IO_DELAY": {"info_key": "matrix_pins.io_delay", "value_type": "int"},
|
||||
|
||||
|
@ -122,14 +124,14 @@
|
|||
"PS2_DATA_PIN": {"info_key": "ps2.data_pin"},
|
||||
|
||||
// RGB Matrix
|
||||
"RGB_DISABLE_WHEN_USB_SUSPENDED": {"info_key": "rgb_matrix.sleep", "value_type": "bool"},
|
||||
"RGB_MATRIX_CENTER": {"info_key": "rgb_matrix.center_point", "value_type": "array.int"},
|
||||
"RGB_MATRIX_HUE_STEP": {"info_key": "rgb_matrix.hue_steps", "value_type": "int"},
|
||||
"RGB_MATRIX_KEYRELEASES": {"info_key": "rgb_matrix.react_on_keyup", "value_type": "bool"},
|
||||
"RGB_MATRIX_KEYRELEASES": {"info_key": "rgb_matrix.react_on_keyup", "value_type": "flag"},
|
||||
"RGB_MATRIX_LED_FLUSH_LIMIT": {"info_key": "rgb_matrix.led_flush_limit", "value_type": "int"},
|
||||
"RGB_MATRIX_LED_PROCESS_LIMIT": {"info_key": "rgb_matrix.led_process_limit", "value_type": "int", "to_json": false},
|
||||
"RGB_MATRIX_MAXIMUM_BRIGHTNESS": {"info_key": "rgb_matrix.max_brightness", "value_type": "int"},
|
||||
"RGB_MATRIX_SAT_STEP": {"info_key": "rgb_matrix.sat_steps", "value_type": "int"},
|
||||
"RGB_MATRIX_SLEEP": {"info_key": "rgb_matrix.sleep", "value_type": "flag"},
|
||||
"RGB_MATRIX_SPD_STEP": {"info_key": "rgb_matrix.speed_steps", "value_type": "int"},
|
||||
"RGB_MATRIX_SPLIT": {"info_key": "rgb_matrix.split_count", "value_type": "array.int"},
|
||||
"RGB_MATRIX_TIMEOUT": {"info_key": "rgb_matrix.timeout", "value_type": "int"},
|
||||
|
@ -142,25 +144,25 @@
|
|||
"RGB_MATRIX_DEFAULT_SPD": {"info_key": "rgb_matrix.default.speed", "value_type": "int"},
|
||||
|
||||
// RGBLight
|
||||
"RGBLED_NUM": {"info_key": "rgblight.led_count", "value_type": "int"},
|
||||
"RGBLED_SPLIT": {"info_key": "rgblight.split_count", "value_type": "array.int"},
|
||||
"RGBLIGHT_HUE_STEP": {"info_key": "rgblight.hue_steps", "value_type": "int"},
|
||||
"RGBLIGHT_LAYER_BLINK": {"info_key": "rgblight.layers.blink", "value_type": "bool"},
|
||||
"RGBLIGHT_LAYERS": {"info_key": "rgblight.layers.enabled", "value_type": "bool"},
|
||||
"RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF": {"info_key": "rgblight.layers.override_rgb", "value_type": "bool"},
|
||||
"RGBLIGHT_LAYER_BLINK": {"info_key": "rgblight.layers.blink", "value_type": "flag"},
|
||||
"RGBLIGHT_LAYERS": {"info_key": "rgblight.layers.enabled", "value_type": "flag"},
|
||||
"RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF": {"info_key": "rgblight.layers.override_rgb", "value_type": "flag"},
|
||||
"RGBLIGHT_LED_COUNT": {"info_key": "rgblight.led_count", "value_type": "int"},
|
||||
"RGBLIGHT_LED_MAP": {"info_key": "rgblight.led_map", "value_type": "array.int"},
|
||||
"RGBLIGHT_LIMIT_VAL": {"info_key": "rgblight.max_brightness", "value_type": "int"},
|
||||
"RGBLIGHT_MAX_LAYERS": {"info_key": "rgblight.layers.max", "value_type": "int"},
|
||||
"RGBLIGHT_SAT_STEP": {"info_key": "rgblight.saturation_steps", "value_type": "int"},
|
||||
"RGBLIGHT_SLEEP": {"info_key": "rgblight.sleep", "value_type": "bool"},
|
||||
"RGBLIGHT_SPLIT": {"info_key": "rgblight.split", "value_type": "bool"},
|
||||
"RGBLIGHT_SLEEP": {"info_key": "rgblight.sleep", "value_type": "flag"},
|
||||
"RGBLIGHT_SPLIT": {"info_key": "rgblight.split", "value_type": "flag"},
|
||||
"RGBLIGHT_VAL_STEP": {"info_key": "rgblight.brightness_steps", "value_type": "int"},
|
||||
"RGBLIGHT_DEFAULT_ON": {"info_key": "rgblight.default.on", "value_type": "bool"},
|
||||
"RGBLIGHT_DEFAULT_HUE": {"info_key": "rgblight.default.hue", "value_type": "int"},
|
||||
"RGBLIGHT_DEFAULT_SAT": {"info_key": "rgblight.default.sat", "value_type": "int"},
|
||||
"RGBLIGHT_DEFAULT_VAL": {"info_key": "rgblight.default.val", "value_type": "int"},
|
||||
"RGBLIGHT_DEFAULT_SPD": {"info_key": "rgblight.default.speed", "value_type": "int"},
|
||||
"RGBW": {"info_key": "rgblight.rgbw", "value_type": "bool"},
|
||||
"RGBW": {"info_key": "rgblight.rgbw", "value_type": "flag"},
|
||||
|
||||
// Secure
|
||||
"SECURE_IDLE_TIMEOUT": {"info_key": "secure.idle_timeout", "value_type": "int"},
|
||||
|
@ -172,37 +174,37 @@
|
|||
"SOFT_SERIAL_SPEED": {"info_key": "split.soft_serial_speed"},
|
||||
"SPLIT_HAND_MATRIX_GRID": {"info_key": "split.handedness.matrix_grid", "value_type": "array", "to_c": false},
|
||||
"SPLIT_HAND_PIN": {"info_key": "split.handedness.pin"},
|
||||
"SPLIT_USB_DETECT": {"info_key": "split.usb_detect.enabled", "value_type": "bool"},
|
||||
"SPLIT_USB_DETECT": {"info_key": "split.usb_detect.enabled", "value_type": "flag"},
|
||||
"SPLIT_USB_TIMEOUT": {"info_key": "split.usb_detect.timeout", "value_type": "int"},
|
||||
"SPLIT_USB_TIMEOUT_POLL": {"info_key": "split.usb_detect.polling_interval", "value_type": "int"},
|
||||
"SPLIT_WATCHDOG_ENABLE": {"info_key": "split.transport.watchdog", "value_type": "bool"},
|
||||
"SPLIT_WATCHDOG_ENABLE": {"info_key": "split.transport.watchdog", "value_type": "flag"},
|
||||
"SPLIT_WATCHDOG_TIMEOUT": {"info_key": "split.transport.watchdog_timeout", "value_type": "int"},
|
||||
"SPLIT_ACTIVITY_ENABLE": {"info_key": "split.transport.sync.activity", "value_type": "bool"},
|
||||
"SPLIT_DETECTED_OS_ENABLE": {"info_key": "split.transport.sync.detected_os", "value_type": "bool"},
|
||||
"SPLIT_HAPTIC_ENABLE": {"info_key": "split.transport.sync.haptic", "value_type": "bool"},
|
||||
"SPLIT_LAYER_STATE_ENABLE": {"info_key": "split.transport.sync.layer_state", "value_type": "bool"},
|
||||
"SPLIT_LED_STATE_ENABLE": {"info_key": "split.transport.sync.indicators", "value_type": "bool"},
|
||||
"SPLIT_TRANSPORT_MIRROR": {"info_key": "split.transport.sync.matrix_state", "value_type": "bool"},
|
||||
"SPLIT_MODS_ENABLE": {"info_key": "split.transport.sync.modifiers", "value_type": "bool"},
|
||||
"SPLIT_OLED_ENABLE": {"info_key": "split.transport.sync.oled", "value_type": "bool"},
|
||||
"SPLIT_ST7565_ENABLE": {"info_key": "split.transport.sync.st7565", "value_type": "bool"},
|
||||
"SPLIT_WPM_ENABLE": {"info_key": "split.transport.sync.wpm", "value_type": "bool"},
|
||||
"SPLIT_ACTIVITY_ENABLE": {"info_key": "split.transport.sync.activity", "value_type": "flag"},
|
||||
"SPLIT_DETECTED_OS_ENABLE": {"info_key": "split.transport.sync.detected_os", "value_type": "flag"},
|
||||
"SPLIT_HAPTIC_ENABLE": {"info_key": "split.transport.sync.haptic", "value_type": "flag"},
|
||||
"SPLIT_LAYER_STATE_ENABLE": {"info_key": "split.transport.sync.layer_state", "value_type": "flag"},
|
||||
"SPLIT_LED_STATE_ENABLE": {"info_key": "split.transport.sync.indicators", "value_type": "flag"},
|
||||
"SPLIT_TRANSPORT_MIRROR": {"info_key": "split.transport.sync.matrix_state", "value_type": "flag"},
|
||||
"SPLIT_MODS_ENABLE": {"info_key": "split.transport.sync.modifiers", "value_type": "flag"},
|
||||
"SPLIT_OLED_ENABLE": {"info_key": "split.transport.sync.oled", "value_type": "flag"},
|
||||
"SPLIT_ST7565_ENABLE": {"info_key": "split.transport.sync.st7565", "value_type": "flag"},
|
||||
"SPLIT_WPM_ENABLE": {"info_key": "split.transport.sync.wpm", "value_type": "flag"},
|
||||
|
||||
// Tapping
|
||||
"HOLD_ON_OTHER_KEY_PRESS": {"info_key": "tapping.hold_on_other_key_press", "value_type": "bool"},
|
||||
"HOLD_ON_OTHER_KEY_PRESS_PER_KEY": {"info_key": "tapping.hold_on_other_key_press_per_key", "value_type": "bool"},
|
||||
"PERMISSIVE_HOLD": {"info_key": "tapping.permissive_hold", "value_type": "bool"},
|
||||
"PERMISSIVE_HOLD_PER_KEY": {"info_key": "tapping.permissive_hold_per_key", "value_type": "bool"},
|
||||
"RETRO_TAPPING": {"info_key": "tapping.retro", "value_type": "bool"},
|
||||
"RETRO_TAPPING_PER_KEY": {"info_key": "tapping.retro_per_key", "value_type": "bool"},
|
||||
"HOLD_ON_OTHER_KEY_PRESS": {"info_key": "tapping.hold_on_other_key_press", "value_type": "flag"},
|
||||
"HOLD_ON_OTHER_KEY_PRESS_PER_KEY": {"info_key": "tapping.hold_on_other_key_press_per_key", "value_type": "flag"},
|
||||
"PERMISSIVE_HOLD": {"info_key": "tapping.permissive_hold", "value_type": "flag"},
|
||||
"PERMISSIVE_HOLD_PER_KEY": {"info_key": "tapping.permissive_hold_per_key", "value_type": "flag"},
|
||||
"RETRO_TAPPING": {"info_key": "tapping.retro", "value_type": "flag"},
|
||||
"RETRO_TAPPING_PER_KEY": {"info_key": "tapping.retro_per_key", "value_type": "flag"},
|
||||
"TAP_CODE_DELAY": {"info_key": "qmk.tap_keycode_delay", "value_type": "int"},
|
||||
"TAP_HOLD_CAPS_DELAY": {"info_key": "qmk.tap_capslock_delay", "value_type": "int"},
|
||||
"TAPPING_TERM": {"info_key": "tapping.term", "value_type": "int"},
|
||||
"TAPPING_TERM_PER_KEY": {"info_key": "tapping.term_per_key", "value_type": "bool"},
|
||||
"TAPPING_TERM_PER_KEY": {"info_key": "tapping.term_per_key", "value_type": "flag"},
|
||||
"TAPPING_TOGGLE": {"info_key": "tapping.toggle", "value_type": "int"},
|
||||
|
||||
// USB
|
||||
"FORCE_NKRO": {"info_key": "usb.force_nkro", "value_type": "bool"},
|
||||
"FORCE_NKRO": {"info_key": "usb.force_nkro", "value_type": "flag"},
|
||||
"USB_MAX_POWER_CONSUMPTION": {"info_key": "usb.max_power", "value_type": "int"},
|
||||
"USB_POLLING_INTERVAL_MS": {"info_key": "usb.polling_interval", "value_type": "int"},
|
||||
"USB_SUSPEND_WAKEUP_DELAY": {"info_key": "usb.suspend_wakeup_delay", "value_type": "int"},
|
||||
|
@ -217,16 +219,18 @@
|
|||
// Items we want flagged in lint
|
||||
"DEBOUNCING_DELAY": {"info_key": "_invalid.debouncing_delay", "invalid": true, "replace_with": "DEBOUNCE"},
|
||||
"DESCRIPTION": {"info_key": "_invalid.usb_description", "invalid": true},
|
||||
"IGNORE_MOD_TAP_INTERRUPT": {"info_key": "_invalid.ignore_mod_tap_interrupt", "value_type": "bool", "invalid": true},
|
||||
"IGNORE_MOD_TAP_INTERRUPT_PER_KEY": {"info_key": "_invalid.ignore_mod_tap_interrupt_per_key", "invalid": true}
|
||||
"IGNORE_MOD_TAP_INTERRUPT": {"info_key": "_invalid.ignore_mod_tap_interrupt", "value_type": "flag", "invalid": true},
|
||||
"IGNORE_MOD_TAP_INTERRUPT_PER_KEY": {"info_key": "_invalid.ignore_mod_tap_interrupt_per_key", "invalid": true},
|
||||
"LED_DISABLE_WHEN_USB_SUSPENDED": {"info_key": "_invalid.led_matrix_sleep", "invalid": true, "replace_with": "LED_MATRIX_SLEEP"},
|
||||
"NO_ACTION_FUNCTION": {"info_key": "_invalid.no_action_function", "invalid": true},
|
||||
"NO_ACTION_MACRO": {"info_key": "_invalid.no_action_macro", "invalid": true},
|
||||
"PREVENT_STUCK_MODIFIERS": {"info_key": "_invalid.prevent_stuck_mods", "invalid": true},
|
||||
"QMK_KEYS_PER_SCAN": {"info_key": "qmk.keys_per_scan", "value_type": "int", "deprecated": true},
|
||||
"RGB_DI_PIN": {"info_key": "rgblight.pin", "invalid": true, "replace_with": "WS2812_DI_PIN or APA102_DI_PIN"},
|
||||
"RGBLIGHT_ANIMATIONS": {"info_key": "_invalid.rgblight.animations.all", "value_type": "bool", "invalid": true},
|
||||
"TAPPING_FORCE_HOLD": {"info_key": "tapping.force_hold", "value_type": "bool", "deprecated": true},
|
||||
"TAPPING_FORCE_HOLD_PER_KEY": {"info_key": "tapping.force_hold_per_key", "value_type": "bool", "deprecated": true},
|
||||
"RGB_DISABLE_WHEN_USB_SUSPENDED": {"info_key": "_invalid.rgb_matrix_sleep", "invalid": true, "replace_with": "RGB_MATRIX_SLEEP"},
|
||||
"RGBLIGHT_ANIMATIONS": {"info_key": "_invalid.rgblight.animations.all", "value_type": "flag", "invalid": true},
|
||||
"TAPPING_FORCE_HOLD": {"info_key": "tapping.force_hold", "value_type": "flag", "deprecated": true},
|
||||
"TAPPING_FORCE_HOLD_PER_KEY": {"info_key": "tapping.force_hold_per_key", "value_type": "flag", "deprecated": true},
|
||||
"UNUSED_PINS": {"info_key": "_invalid.unused_pins", "deprecated": true},
|
||||
"COMBO_COUNT": {"info_key": "_invalid.combo.count", "invalid": true},
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
"DEBOUNCE_TYPE": {"info_key": "build.debounce_type"},
|
||||
"EEPROM_DRIVER": {"info_key": "eeprom.driver"},
|
||||
"ENCODER_ENABLE": {"info_key": "encoder.enabled", "value_type": "bool"},
|
||||
"ENCODER_DRIVER": {"info_key": "encoder.driver"},
|
||||
"FIRMWARE_FORMAT": {"info_key": "build.firmware_format"},
|
||||
"KEYBOARD_SHARED_EP": {"info_key": "usb.shared_endpoint.keyboard", "value_type": "bool"},
|
||||
"LAYOUTS": {"info_key": "community_layouts", "value_type": "list"},
|
||||
|
|
|
@ -185,6 +185,12 @@
|
|||
"eek": {
|
||||
"target": "eek/silk_down"
|
||||
},
|
||||
"epoch80": {
|
||||
"target": "kbdfans/epoch80"
|
||||
},
|
||||
"era/klein": {
|
||||
"target": "era/sirind/klein_sd"
|
||||
},
|
||||
"ergodone": {
|
||||
"target": "ktec/ergodone"
|
||||
},
|
||||
|
@ -284,6 +290,12 @@
|
|||
"honeycomb": {
|
||||
"target": "keyhive/honeycomb"
|
||||
},
|
||||
"hub16": {
|
||||
"target": "joshajohnson/hub16"
|
||||
},
|
||||
"hub20": {
|
||||
"target": "joshajohnson/hub20"
|
||||
},
|
||||
"idb_60": {
|
||||
"target": "idb/idb_60"
|
||||
},
|
||||
|
@ -302,6 +314,9 @@
|
|||
"jj50": {
|
||||
"target": "kprepublic/jj50"
|
||||
},
|
||||
"jm60": {
|
||||
"target": "kbdfans/jm60"
|
||||
},
|
||||
"jones": {
|
||||
"target": "jones/v03_1"
|
||||
},
|
||||
|
@ -326,12 +341,48 @@
|
|||
"keycapsss/plaid_pad": {
|
||||
"target": "keycapsss/plaid_pad/rev1"
|
||||
},
|
||||
"kira75": {
|
||||
"target": "kira/kira75"
|
||||
},
|
||||
"kira80": {
|
||||
"target": "kira/kira80"
|
||||
},
|
||||
"kudox": {
|
||||
"target": "kudox/rev1"
|
||||
"target": "kumaokobo/kudox/rev1"
|
||||
},
|
||||
"kudox/columner": {
|
||||
"target": "kumaokobo/kudox/columner"
|
||||
},
|
||||
"kudox/rev1": {
|
||||
"target": "kumaokobo/kudox/rev1"
|
||||
},
|
||||
"kudox/rev2": {
|
||||
"target": "kumaokobo/kudox/rev2"
|
||||
},
|
||||
"kudox/rev3": {
|
||||
"target": "kumaokobo/kudox/rev3"
|
||||
},
|
||||
"kudox_full": {
|
||||
"target": "kumaokobo/kudox_full/rev1"
|
||||
},
|
||||
"kudox_full/rev1": {
|
||||
"target": "kumaokobo/kudox_full/rev1"
|
||||
},
|
||||
"kudox_game": {
|
||||
"target": "kumaokobo/kudox_game/rev1"
|
||||
},
|
||||
"kudox_game/rev1": {
|
||||
"target": "kumaokobo/kudox_game/rev1"
|
||||
},
|
||||
"kudox_game/rev2": {
|
||||
"target": "kumaokobo/kudox_game/rev2"
|
||||
},
|
||||
"kyria": {
|
||||
"target": "splitkb/kyria"
|
||||
},
|
||||
"laser_ninja/pumpkin_pad": {
|
||||
"target": "laser_ninja/pumpkinpad"
|
||||
},
|
||||
"lattice60": {
|
||||
"target": "keyhive/lattice60"
|
||||
},
|
||||
|
@ -446,6 +497,15 @@
|
|||
"minim": {
|
||||
"target": "matthewdias/minim"
|
||||
},
|
||||
"mnk1800s": {
|
||||
"target": "monokei/mnk1800s"
|
||||
},
|
||||
"mnk50": {
|
||||
"target": "monokei/mnk50"
|
||||
},
|
||||
"mnk75": {
|
||||
"target": "monokei/mnk75"
|
||||
},
|
||||
"model01": {
|
||||
"target": "keyboardio/model01"
|
||||
},
|
||||
|
@ -458,6 +518,9 @@
|
|||
"montsinger/rebound": {
|
||||
"target": "montsinger/rebound/rev1"
|
||||
},
|
||||
"moonlander": {
|
||||
"target": "zsa/moonlander"
|
||||
},
|
||||
"mschwingen/modelm": {
|
||||
"target": "ibm/model_m/mschwingen"
|
||||
},
|
||||
|
@ -485,6 +548,15 @@
|
|||
"peiorisboards/ixora": {
|
||||
"target": "coarse/ixora"
|
||||
},
|
||||
"pico": {
|
||||
"target": "kumaokobo/pico/65keys"
|
||||
},
|
||||
"pico/65keys": {
|
||||
"target": "kumaokobo/pico/65keys"
|
||||
},
|
||||
"pico/70keys": {
|
||||
"target": "kumaokobo/pico/70keys"
|
||||
},
|
||||
"plaid": {
|
||||
"target": "dm9records/plaid"
|
||||
},
|
||||
|
@ -530,6 +602,9 @@
|
|||
"ramonimbao/mona": {
|
||||
"target": "rmi_kb/mona/v1"
|
||||
},
|
||||
"redox_w": {
|
||||
"target": "redox/wireless"
|
||||
},
|
||||
"rgbkb/pan": {
|
||||
"target": "rgbkb/pan/rev1/32a"
|
||||
},
|
||||
|
@ -798,6 +873,12 @@
|
|||
"eggman": {
|
||||
"target": "qpockets/eggman"
|
||||
},
|
||||
"enter67": {
|
||||
"target": "kezewa/enter67"
|
||||
},
|
||||
"enter80": {
|
||||
"target": "kezewa/enter80"
|
||||
},
|
||||
"ergo42": {
|
||||
"target": "biacco42/ergo42"
|
||||
},
|
||||
|
@ -819,9 +900,15 @@
|
|||
"espectro": {
|
||||
"target": "mechkeys/espectro"
|
||||
},
|
||||
"eu_isolation": {
|
||||
"target": "p3d/eu_isolation"
|
||||
},
|
||||
"felix": {
|
||||
"target": "unikeyboard/felix"
|
||||
},
|
||||
"flygone60/rev3": {
|
||||
"target": "shandoncodes/flygone60/rev3"
|
||||
},
|
||||
"four_banger": {
|
||||
"target": "bpiphany/four_banger"
|
||||
},
|
||||
|
@ -915,6 +1002,12 @@
|
|||
"keychron/q4": {
|
||||
"target": "keychron/q4/ansi/v1"
|
||||
}
|
||||
"kmac": {
|
||||
"target": "kbdmania/kmac"
|
||||
}
|
||||
"kmac_pad": {
|
||||
"target": "kbdmania/kmac_pad"
|
||||
}
|
||||
"kprepublic/bm40hsrgb": {
|
||||
"target": "kprepublic/bm40hsrgb/rev1"
|
||||
},
|
||||
|
@ -924,6 +1017,9 @@
|
|||
"kprepublic/bm68hsrgb": {
|
||||
"target": "kprepublic/bm68hsrgb/rev1"
|
||||
},
|
||||
"late9/rev1": {
|
||||
"target": "rookiebwoy/late9/rev1"
|
||||
},
|
||||
"latin17rgb": {
|
||||
"target": "latincompass/latin17rgb"
|
||||
},
|
||||
|
@ -948,6 +1044,12 @@
|
|||
"launchpad/rev1": {
|
||||
"target": "maple_computing/launchpad/rev1"
|
||||
},
|
||||
"lefty": {
|
||||
"target": "smoll/lefty/rev2"
|
||||
},
|
||||
"lefty/rev1": {
|
||||
"target": "smoll/lefty/rev1"
|
||||
},
|
||||
"lck75": {
|
||||
"target": "lyso1/lck75"
|
||||
},
|
||||
|
@ -963,9 +1065,21 @@
|
|||
"ls_60": {
|
||||
"target": "weirdo/ls_60"
|
||||
},
|
||||
"lpad": {
|
||||
"target": "laneware/lpad"
|
||||
},
|
||||
"lw67": {
|
||||
"target": "laneware/lw67"
|
||||
},
|
||||
"lw75": {
|
||||
"target": "laneware/lw75"
|
||||
},
|
||||
"m3n3van": {
|
||||
"target": "matthewdias/m3n3van"
|
||||
},
|
||||
"macro1": {
|
||||
"target": "laneware/macro1"
|
||||
},
|
||||
"massdrop/thekey": {
|
||||
"target": "drop/thekey/v1"
|
||||
},
|
||||
|
@ -990,9 +1104,21 @@
|
|||
"melody96": {
|
||||
"target": "ymdk/melody96"
|
||||
},
|
||||
"miniaxe": {
|
||||
"target": "kagizaraya/miniaxe"
|
||||
},
|
||||
"minidox/rev1": {
|
||||
"target": "maple_computing/minidox/rev1"
|
||||
},
|
||||
"mino/hotswap": {
|
||||
"target": "shandoncodes/mino/hotswap"
|
||||
},
|
||||
"mino_plus/hotswap": {
|
||||
"target": "shandoncodes/mino_plus/hotswap"
|
||||
},
|
||||
"mino_plus/soldered": {
|
||||
"target": "shandoncodes/mino_plus/soldered"
|
||||
},
|
||||
"mio": {
|
||||
"target": "recompile_keys/mio"
|
||||
},
|
||||
|
@ -1047,6 +1173,9 @@
|
|||
"nebula68b": {
|
||||
"target": "spaceholdings/nebula68b"
|
||||
},
|
||||
"neopad/rev1": {
|
||||
"target": "rookiebwoy/neopad/rev1"
|
||||
},
|
||||
"niu_mini": {
|
||||
"target": "kbdfans/niu_mini"
|
||||
},
|
||||
|
@ -1101,6 +1230,12 @@
|
|||
"pursuit40": {
|
||||
"target": "checkerboards/pursuit40"
|
||||
},
|
||||
"pw88": {
|
||||
"target": "smoll/pw88"
|
||||
},
|
||||
"q4z": {
|
||||
"target": "p3d/q4z"
|
||||
},
|
||||
"qaz": {
|
||||
"target": "tominabox1/qaz"
|
||||
},
|
||||
|
@ -1110,6 +1245,9 @@
|
|||
"rabbit_capture_plan": {
|
||||
"target": "kakunpc/rabbit_capture_plan"
|
||||
},
|
||||
"raindrop": {
|
||||
"target": "laneware/raindrop"
|
||||
},
|
||||
"ramonimbao/aelith": {
|
||||
"target": "rmi_kb/aelith"
|
||||
},
|
||||
|
@ -1176,6 +1314,9 @@
|
|||
"reviung61": {
|
||||
"target": "reviung/reviung61"
|
||||
},
|
||||
"riot_pad": {
|
||||
"target": "shandoncodes/riot_pad"
|
||||
},
|
||||
"runner3680/3x6": {
|
||||
"target": "omkbd/runner3680/3x6"
|
||||
},
|
||||
|
@ -1230,6 +1371,9 @@
|
|||
"space_space/rev2": {
|
||||
"target": "qpockets/space_space/rev2"
|
||||
},
|
||||
"spacey": {
|
||||
"target": "p3d/spacey"
|
||||
},
|
||||
"spiderisland/winry25tc": {
|
||||
"target": "winry/winry25tc"
|
||||
},
|
||||
|
@ -1260,6 +1404,9 @@
|
|||
"suihankey/split": {
|
||||
"target": "kakunpc/suihankey/split"
|
||||
},
|
||||
"synapse": {
|
||||
"target": "p3d/synapse"
|
||||
},
|
||||
"the_ruler": {
|
||||
"target": "maple_computing/the_ruler"
|
||||
},
|
||||
|
@ -1281,6 +1428,9 @@
|
|||
"tronguylabs/m122_3270": {
|
||||
"target": "ibm/model_m_122/m122_3270/teensy"
|
||||
},
|
||||
"tw40": {
|
||||
"target": "p3d/tw40"
|
||||
},
|
||||
"ua62": {
|
||||
"target": "nacly/ua62"
|
||||
},
|
||||
|
@ -1299,6 +1449,9 @@
|
|||
"vn66": {
|
||||
"target": "hnahkb/vn66"
|
||||
},
|
||||
"w1_at": {
|
||||
"target": "geonworks/w1_at"
|
||||
},
|
||||
"wallaby": {
|
||||
"target": "kkatano/wallaby"
|
||||
},
|
||||
|
@ -1347,6 +1500,12 @@
|
|||
"yurei": {
|
||||
"target": "kkatano/yurei"
|
||||
},
|
||||
"z12": {
|
||||
"target": "zigotica/z12"
|
||||
},
|
||||
"z34": {
|
||||
"target": "zigotica/z34"
|
||||
},
|
||||
"zinc": {
|
||||
"target": "25keys/zinc"
|
||||
},
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
"encoder_config": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"driver": {
|
||||
"type": "string",
|
||||
"enum": ["custom", "quadrature"]
|
||||
},
|
||||
"rotary": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
|
@ -24,14 +28,12 @@
|
|||
"dip_switch_config": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"pins": {
|
||||
"$ref": "qmk.definitions.v1#/mcu_pin_array"
|
||||
}
|
||||
"pins": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"not": { "required": [ "vendorId", "productId" ] }, // reject via keys...
|
||||
"not": {"required": ["vendorId", "productId"]}, // reject via keys...
|
||||
"properties": {
|
||||
"keyboard_name": {"$ref": "qmk.definitions.v1#/text_identifier"},
|
||||
"keyboard_folder": {"$ref": "qmk.definitions.v1#/keyboard"},
|
||||
|
@ -43,7 +45,7 @@
|
|||
},
|
||||
"development_board": {
|
||||
"type": "string",
|
||||
"enum": ["promicro", "elite_c", "elite_pi", "proton_c", "kb2040", "promicro_rp2040", "blok", "michi", "bit_c_pro", "stemcell", "bluepill", "blackpill_f401", "blackpill_f411", "bonsai_c4", "helios", "liatris"]
|
||||
"enum": ["promicro", "elite_c", "elite_pi", "proton_c", "kb2040", "promicro_rp2040", "blok", "michi", "bit_c_pro", "stemcell", "bluepill", "blackpill_f401", "blackpill_f411", "bonsai_c4", "helios", "liatris", "imera"]
|
||||
},
|
||||
"pin_compatible": {
|
||||
"type": "string",
|
||||
|
@ -123,6 +125,14 @@
|
|||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"default": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"on": {"type": "boolean"},
|
||||
"clicky": {"type": "boolean"}
|
||||
}
|
||||
},
|
||||
"macro_beep": {"type": "boolean"},
|
||||
"pins": {"$ref": "qmk.definitions.v1#/mcu_pin_array"},
|
||||
"voices": {"type": "boolean"}
|
||||
|
@ -134,7 +144,7 @@
|
|||
"properties": {
|
||||
"driver": {
|
||||
"type": "string",
|
||||
"enum": ["pwm", "software", "timer", "custom"]
|
||||
"enum": ["custom", "pwm", "software", "timer"]
|
||||
},
|
||||
"default": {
|
||||
"type": "object",
|
||||
|
@ -306,8 +316,8 @@
|
|||
},
|
||||
"features": {
|
||||
"$ref": "qmk.definitions.v1#/boolean_array",
|
||||
"propertyNames": { "$ref": "qmk.definitions.v1#/snake_case" }
|
||||
|
||||
"propertyNames": {"$ref": "qmk.definitions.v1#/snake_case"},
|
||||
"not": {"required": ["lto"]}
|
||||
},
|
||||
"indicators": {
|
||||
"type": "object",
|
||||
|
@ -332,15 +342,9 @@
|
|||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"filename": {
|
||||
"type": "string"
|
||||
},
|
||||
"c_macro": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"json_layout": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"filename": {"type": "string"},
|
||||
"c_macro": {"type": "boolean"},
|
||||
"json_layout": {"type": "boolean"},
|
||||
"layout": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
|
@ -423,10 +427,8 @@
|
|||
"properties": {
|
||||
"animations": {
|
||||
"type": "object",
|
||||
"propertyNames": { "$ref": "qmk.definitions.v1#/snake_case" }
|
||||
"additionalProperties": {
|
||||
"type": "boolean"
|
||||
}
|
||||
"propertyNames": {"$ref": "qmk.definitions.v1#/snake_case"},
|
||||
"additionalProperties": {"type": "boolean"}
|
||||
},
|
||||
"default": {
|
||||
"type": "object",
|
||||
|
@ -438,7 +440,24 @@
|
|||
"speed": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}
|
||||
}
|
||||
},
|
||||
"driver": {"type": "string"},
|
||||
"driver": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"custom",
|
||||
"is31fl3218",
|
||||
"is31fl3729",
|
||||
"is31fl3731",
|
||||
"is31fl3733",
|
||||
"is31fl3736",
|
||||
"is31fl3737",
|
||||
"is31fl3741",
|
||||
"is31fl3742a",
|
||||
"is31fl3743a",
|
||||
"is31fl3745",
|
||||
"is31fl3746a",
|
||||
"snled27351"
|
||||
]
|
||||
},
|
||||
"center_point": {
|
||||
"type": "array",
|
||||
"minItems": 2,
|
||||
|
@ -487,10 +506,8 @@
|
|||
"properties": {
|
||||
"animations": {
|
||||
"type": "object",
|
||||
"propertyNames": { "$ref": "qmk.definitions.v1#/snake_case" }
|
||||
"additionalProperties": {
|
||||
"type": "boolean"
|
||||
}
|
||||
"propertyNames": {"$ref": "qmk.definitions.v1#/snake_case"},
|
||||
"additionalProperties": {"type": "boolean"}
|
||||
},
|
||||
"default": {
|
||||
"type": "object",
|
||||
|
@ -504,7 +521,26 @@
|
|||
"speed": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}
|
||||
}
|
||||
},
|
||||
"driver": {"type": "string"},
|
||||
"driver": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"aw20216s",
|
||||
"custom",
|
||||
"is31fl3218",
|
||||
"is31fl3729",
|
||||
"is31fl3731",
|
||||
"is31fl3733",
|
||||
"is31fl3736",
|
||||
"is31fl3737",
|
||||
"is31fl3741",
|
||||
"is31fl3742a",
|
||||
"is31fl3743a",
|
||||
"is31fl3745",
|
||||
"is31fl3746a",
|
||||
"snled27351",
|
||||
"ws2812"
|
||||
]
|
||||
},
|
||||
"center_point": {
|
||||
"type": "array",
|
||||
"minItems": 2,
|
||||
|
@ -556,10 +592,8 @@
|
|||
"properties": {
|
||||
"animations": {
|
||||
"type": "object",
|
||||
"propertyNames": { "$ref": "qmk.definitions.v1#/snake_case" }
|
||||
"additionalProperties": {
|
||||
"type": "boolean"
|
||||
}
|
||||
"propertyNames": {"$ref": "qmk.definitions.v1#/snake_case"},
|
||||
"additionalProperties": {"type": "boolean"}
|
||||
},
|
||||
"brightness_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"},
|
||||
"default": {
|
||||
|
@ -762,7 +796,7 @@
|
|||
"st7565": {"type": "boolean"},
|
||||
"wpm": {"type": "boolean"}
|
||||
}
|
||||
}
|
||||
},
|
||||
"watchdog": {"type": "boolean"},
|
||||
"watchdog_timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"},
|
||||
"sync_matrix_state": {
|
||||
|
|
367
docs/ChangeLog/20240225.md
Normal file
367
docs/ChangeLog/20240225.md
Normal file
|
@ -0,0 +1,367 @@
|
|||
# QMK Breaking Changes - 2024 February 25 Changelog
|
||||
|
||||
## Notable Features :id=notable-features
|
||||
|
||||
_0.24.0_ is mainly a maintenance release of QMK Firmware -- as per last few breaking changes cycles, there have been a lot of behind-the-scenes changes, mainly:
|
||||
|
||||
* continued purge of user keymaps
|
||||
* migration of RGB matrix configuration into `info.json` files
|
||||
* standardisation of `LAYOUT` naming
|
||||
* keyboard relocations
|
||||
* addressing technical debt
|
||||
|
||||
## Changes Requiring User Action :id=changes-requiring-user-action
|
||||
|
||||
### Windows Driver Changes ([QMK Toolbox 0.3.0 Release](https://github.com/qmk/qmk_toolbox/releases/tag/0.3.0))
|
||||
|
||||
Flashing keyboards that target `atmel-dfu` or `qmk-dfu` on Windows using `qmk flash` or QMK Toolbox have traditionally used _libusb_ for access to the DFU USB device. Since QMK Toolbox 0.3.0, this has changed to WinUSB.
|
||||
|
||||
If you update QMK Toolbox or update QMK MSYS, you may find that flashing Atmel DFU keyboards no longer functions as intended. If you strike such issues when flashing new firmware, you will need to replace the _libusb_ driver with _WinUSB_ using Zadig. You can follow the [Recovering from Installation to Wrong Device](driver_installation_zadig.md#recovering-from-installation-to-wrong-device) instructions to replace the driver associated with the Atmel DFU bootloader, skipping the section about removal as Zadig will safely replace the driver instead. Please ensure your keyboard is in bootloader mode and has _libusb_ as the existing driver before attempting to use Zadig to replace the driver. If instead you see _HidUsb_ you're not in bootloader mode and should not continue with driver replacement.
|
||||
|
||||
### Updated Keyboard Codebases :id=updated-keyboard-codebases
|
||||
|
||||
One note with updated keyboard names -- historical keyboard names are still considered valid when using [External Userspace](newbs_external_userspace.md) for builds. If you're already using External Userspace, you do not need to move your keymap inside your repository.
|
||||
|
||||
| Old Keyboard Name | New Keyboard Name |
|
||||
|-------------------------|---------------------------------|
|
||||
| enter67 | kezewa/enter67 |
|
||||
| enter80 | kezewa/enter80 |
|
||||
| epoch80 | kbdfans/epoch80 |
|
||||
| eu_isolation | p3d/eu_isolation |
|
||||
| flygone60/rev3 | shandoncodes/flygone60/rev3 |
|
||||
| hub16 | joshajohnson/hub16 |
|
||||
| hub20 | joshajohnson/hub20 |
|
||||
| jm60 | kbdfans/jm60 |
|
||||
| kira75 | kira/kira75 |
|
||||
| kira80 | kira/kira80 |
|
||||
| kmac | kbdmania/kmac |
|
||||
| kmac_pad | kbdmania/kmac_pad |
|
||||
| kudox/columner | kumaokobo/kudox/columner |
|
||||
| kudox/rev1 | kumaokobo/kudox/rev1 |
|
||||
| kudox/rev2 | kumaokobo/kudox/rev2 |
|
||||
| kudox/rev3 | kumaokobo/kudox/rev3 |
|
||||
| kudox_full/rev1 | kumaokobo/kudox_full/rev1 |
|
||||
| kudox_game | kumaokobo/kudox_game |
|
||||
| kudox_game/rev1 | kumaokobo/kudox_game/rev1 |
|
||||
| kudox_game/rev2 | kumaokobo/kudox_game/rev2 |
|
||||
| laser_ninja/pumpkin_pad | laser_ninja/pumpkinpad |
|
||||
| late9/rev1 | rookiebwoy/late9/rev1 |
|
||||
| lefty | smoll/lefty |
|
||||
| lefty/rev1 | smoll/lefty/rev1 |
|
||||
| lefty/rev2 | smoll/lefty/rev2 |
|
||||
| lpad | laneware/lpad |
|
||||
| lw67 | laneware/lw67 |
|
||||
| lw75 | laneware/lw75 |
|
||||
| macro1 | laneware/macro1 |
|
||||
| macro3 | handwired/macro3 |
|
||||
| miniaxe | kagizaraya/miniaxe |
|
||||
| mino/hotswap | shandoncodes/mino/hotswap |
|
||||
| mino_plus/hotswap | shandoncodes/mino_plus/hotswap |
|
||||
| mino_plus/soldered | shandoncodes/mino_plus/soldered |
|
||||
| mnk1800s | monokei/mnk1800s |
|
||||
| mnk50 | monokei/mnk50 |
|
||||
| mnk75 | monokei/mnk75 |
|
||||
| moonlander | zsa/moonlander |
|
||||
| neopad/rev1 | rookiebwoy/neopad/rev1 |
|
||||
| pico/65keys | kumaokobo/pico/65keys |
|
||||
| pico/70keys | kumaokobo/pico/70keys |
|
||||
| pw88 | smoll/pw88 |
|
||||
| q4z | p3d/q4z |
|
||||
| raindrop | laneware/raindrop |
|
||||
| redox_w | redox/wireless |
|
||||
| riot_pad | shandoncodes/riot_pad |
|
||||
| spacey | p3d/spacey |
|
||||
| synapse | p3d/synapse |
|
||||
| tw40 | p3d/tw40 |
|
||||
| w1_at | geonworks/w1_at |
|
||||
| z12 | zigotica/z12 |
|
||||
| z34 | zigotica/z34 |
|
||||
|
||||
## Notable core changes :id=notable-core
|
||||
|
||||
### Renaming Arduino-style GPIO pin functions ([#23085](https://github.com/qmk/qmk_firmware/pull/23085), [#23093](https://github.com/qmk/qmk_firmware/pull/23093)) :id=gpio-rename
|
||||
|
||||
QMK has long used Arduino-style GPIO naming conventions. This has been confusing for users, as over time they've had new variations added, as well as users mistakenly thinking that QMK supports the rest of the Arduino ecosystem.
|
||||
|
||||
The decision was made to rename the GPIO manipulation functions with ones matching QMK Firmware's code styling.
|
||||
|
||||
| Old | New |
|
||||
|------------------------------|---------------------------------------|
|
||||
| `setPinInput(pin)` | `gpio_set_pin_input(pin)` |
|
||||
| `setPinInputHigh(pin)` | `gpio_set_pin_input_high(pin)` |
|
||||
| `setPinInputLow(pin)` | `gpio_set_pin_input_low(pin)` |
|
||||
| `setPinOutput(pin)` | `gpio_set_pin_output(pin)` |
|
||||
| `setPinOutputPushPull(pin)` | `gpio_set_pin_output_push_pull(pin)` |
|
||||
| `setPinOutputOpenDrain(pin)` | `gpio_set_pin_output_open_drain(pin)` |
|
||||
| `writePinHigh(pin)` | `gpio_write_pin_high(pin)` |
|
||||
| `writePinLow(pin)` | `gpio_write_pin_low(pin)` |
|
||||
| `writePin(pin, level)` | `gpio_write_pin(pin, level)` |
|
||||
| `readPin(pin)` | `gpio_read_pin(pin)` |
|
||||
| `togglePin(pin)` | `gpio_toggle_pin(pin)` |
|
||||
|
||||
### I2C driver API Changes ([#22905](https://github.com/qmk/qmk_firmware/pull/22905))
|
||||
|
||||
Much like the GPIO refactoring, I2C APIs were also updated to conform to QMK naming standards. This is largely irrelevant to people using subsystem abstractions such as touchpads or RGB lighting, and only affects people manually communicating with other peripherals.
|
||||
|
||||
| Old API | New API |
|
||||
|--------------------|--------------------------|
|
||||
| `i2c_readReg()` | `i2c_read_register()` |
|
||||
| `i2c_readReg16()` | `i2c_read_register16()` |
|
||||
| `i2c_writeReg()` | `i2c_write_register()` |
|
||||
| `i2c_writeReg16()` | `i2c_write_register16()` |
|
||||
|
||||
### Renaming _Bootmagic Lite_ => _Bootmagic_ ([#22970](https://github.com/qmk/qmk_firmware/pull/22970), [#22979](https://github.com/qmk/qmk_firmware/pull/22979)) :id=bootmagic-rename
|
||||
|
||||
Bootmagic "Lite" had no real meaning once the historical Bootmagic "Full" was deprecated and removed. Any references to _Bootmagic Lite_ should now just refer to _Bootmagic_. We hope we got the majority of the code and the documentation, so if you find any more, let us know!
|
||||
|
||||
### Threshold for automatic mouse layer activation ([#21398](https://github.com/qmk/qmk_firmware/pull/21398)) :id=auto-mouse-layer
|
||||
|
||||
In some cases, accidental automatic activation of the mouse layer made it difficult to continue typing, such as when brushing across a trackball. `AUTO_MOUSE_THRESHOLD` is now a configurable option in `config.h` which allows for specifying what the movement threshold is before automatically activating the mouse layer.
|
||||
|
||||
### DIP Switch Mapping ([#22543](https://github.com/qmk/qmk_firmware/pull/22543)) :id=dip-switch-map
|
||||
|
||||
Much like Encoder Mapping, DIP Switch Mapping allows for specifying a table of actions to execute when a DIP switch state changes. See the [DIP Switch Documentation](feature_dip_switch.md#dip-switch-map) for more information.
|
||||
|
||||
```c
|
||||
#if defined(DIP_SWITCH_MAP_ENABLE)
|
||||
const uint16_t PROGMEM dip_switch_map[NUM_DIP_SWITCHES][NUM_DIP_STATES] = {
|
||||
DIP_SWITCH_OFF_ON(DF(0), DF(1)),
|
||||
DIP_SWITCH_OFF_ON(EC_NORM, EC_SWAP)
|
||||
};
|
||||
#endif
|
||||
```
|
||||
|
||||
### Quantum Painter updates ([#18521](https://github.com/qmk/qmk_firmware/pull/18521), [#20645](https://github.com/qmk/qmk_firmware/pull/20645), [#22358](https://github.com/qmk/qmk_firmware/pull/22358)) :id=qp-updates
|
||||
|
||||
Quantum Painter picked up support for the following:
|
||||
|
||||
* ILI9486 displays
|
||||
* SSD1306 displays, including smaller OLEDs
|
||||
* Native panel pixel format support for fonts
|
||||
|
||||
Quantum Painter now supports the majority of common OLED panels supported by the basic OLED driver, so if you're using an ARM-based board you may find Quantum Painter a much more feature-rich API in comparison.
|
||||
|
||||
## Full changelist :id=full-changelist
|
||||
|
||||
Core:
|
||||
* [Driver] ILI9486 on Quantum Painter ([#18521](https://github.com/qmk/qmk_firmware/pull/18521))
|
||||
* Insert delay between shifted chars in send_string_with_delay ([#19280](https://github.com/qmk/qmk_firmware/pull/19280))
|
||||
* [QP] Native palette support for fonts ([#20645](https://github.com/qmk/qmk_firmware/pull/20645))
|
||||
* I2C driver cleanup ([#21273](https://github.com/qmk/qmk_firmware/pull/21273))
|
||||
* Add option for auto mouse movement threshold ([#21398](https://github.com/qmk/qmk_firmware/pull/21398))
|
||||
* Add Canadian French input locale ([#21456](https://github.com/qmk/qmk_firmware/pull/21456))
|
||||
* Add encoder abstraction. ([#21548](https://github.com/qmk/qmk_firmware/pull/21548))
|
||||
* Converted RGB matrix to use last_input_activity_elapsed(). ([#21687](https://github.com/qmk/qmk_firmware/pull/21687))
|
||||
* Ignore space cadet key release when caps word is active ([#21721](https://github.com/qmk/qmk_firmware/pull/21721))
|
||||
* Add OS detection callbacks ([#21777](https://github.com/qmk/qmk_firmware/pull/21777))
|
||||
* joystick weights ([#21883](https://github.com/qmk/qmk_firmware/pull/21883))
|
||||
* Add RGB matrix & LED Matrix support for IS31FL3729 ([#21944](https://github.com/qmk/qmk_firmware/pull/21944))
|
||||
* dac_additive: Decouple the buffer length from the waveform length ([#22276](https://github.com/qmk/qmk_firmware/pull/22276))
|
||||
* Add missing rgb matrix default parameters ([#22281](https://github.com/qmk/qmk_firmware/pull/22281))
|
||||
* Remove console out endpoint ([#22304](https://github.com/qmk/qmk_firmware/pull/22304))
|
||||
* Add ADC support STM32L4xx and STM32G4xx series MCUs ([#22341](https://github.com/qmk/qmk_firmware/pull/22341))
|
||||
* Add QP support for smaller OLED displays and SSD1306 ([#22358](https://github.com/qmk/qmk_firmware/pull/22358))
|
||||
* Add Imera converter ([#22419](https://github.com/qmk/qmk_firmware/pull/22419))
|
||||
* LED drivers: refactor page selection ([#22518](https://github.com/qmk/qmk_firmware/pull/22518))
|
||||
* Rework RGBLight driver system ([#22529](https://github.com/qmk/qmk_firmware/pull/22529))
|
||||
* Add `APA102_LED_COUNT` define ([#22530](https://github.com/qmk/qmk_firmware/pull/22530))
|
||||
* Add latam spanish headers ([#22542](https://github.com/qmk/qmk_firmware/pull/22542))
|
||||
* Keymap introspection for Dip Switches ([#22543](https://github.com/qmk/qmk_firmware/pull/22543))
|
||||
* Add basic presence check for cirque trackpad. ([#22546](https://github.com/qmk/qmk_firmware/pull/22546))
|
||||
* Rename `RGBLED_NUM` -> `RGBLIGHT_LED_COUNT` ([#22570](https://github.com/qmk/qmk_firmware/pull/22570))
|
||||
* LED drivers: change "TWI" to "I2C" ([#22617](https://github.com/qmk/qmk_firmware/pull/22617))
|
||||
* LED drivers: extract IS31FL3742A from IS31COMMON ([#22620](https://github.com/qmk/qmk_firmware/pull/22620))
|
||||
* Align Dip Switch feature ([#22625](https://github.com/qmk/qmk_firmware/pull/22625))
|
||||
* LED/RGB Matrix: add header for drivers ([#22628](https://github.com/qmk/qmk_firmware/pull/22628))
|
||||
* LED drivers: extract IS31FL3743A from IS31COMMON ([#22635](https://github.com/qmk/qmk_firmware/pull/22635))
|
||||
* LED drivers: extract IS31FL3745 from IS31COMMON ([#22636](https://github.com/qmk/qmk_firmware/pull/22636))
|
||||
* LED drivers: extract IS31FL3746A from IS31COMMON ([#22637](https://github.com/qmk/qmk_firmware/pull/22637))
|
||||
* Update keyboard LED driver configs ([#22638](https://github.com/qmk/qmk_firmware/pull/22638))
|
||||
* Solid reactive: improve fading effect ([#22656](https://github.com/qmk/qmk_firmware/pull/22656))
|
||||
* Remove redundant RGB/LED matrix eeconfig init ([#22673](https://github.com/qmk/qmk_firmware/pull/22673))
|
||||
* Remove redundant rgblight eeconfig init ([#22674](https://github.com/qmk/qmk_firmware/pull/22674))
|
||||
* Remove redundant steno eeconfig init ([#22680](https://github.com/qmk/qmk_firmware/pull/22680))
|
||||
* Rename `LED_DISABLE_WHEN_USB_SUSPENDED` -> `LED_MATRIX_SLEEP` ([#22681](https://github.com/qmk/qmk_firmware/pull/22681))
|
||||
* Rename `RGB_DISABLE_WHEN_USB_SUSPENDED` -> `RGB_MATRIX_SLEEP` ([#22682](https://github.com/qmk/qmk_firmware/pull/22682))
|
||||
* Align VUSB suspend protocol logic ([#22688](https://github.com/qmk/qmk_firmware/pull/22688))
|
||||
* [Audio] Enable Complementary output for PWM Hardware driver ([#22726](https://github.com/qmk/qmk_firmware/pull/22726))
|
||||
* Remove redundant audio eeconfig init ([#22736](https://github.com/qmk/qmk_firmware/pull/22736))
|
||||
* Align location of tap dance keycode ([#22742](https://github.com/qmk/qmk_firmware/pull/22742))
|
||||
* Align `SPLIT_HAND_MATRIX_GRID` left/right logic with `SPLIT_HAND_PIN` ([#22775](https://github.com/qmk/qmk_firmware/pull/22775))
|
||||
* [CI] Regenerate Files ([#22795](https://github.com/qmk/qmk_firmware/pull/22795))
|
||||
* Remove IS31FLCOMMON code ([#22800](https://github.com/qmk/qmk_firmware/pull/22800))
|
||||
* Cirque reachable calibration aide ([#22803](https://github.com/qmk/qmk_firmware/pull/22803))
|
||||
* LED drivers: rename "simple" to "mono" ([#22814](https://github.com/qmk/qmk_firmware/pull/22814))
|
||||
* is31fl3733: change `write_register()` return type to `void` ([#22824](https://github.com/qmk/qmk_firmware/pull/22824))
|
||||
* snled27351: change `write_register()` return type to `void` ([#22825](https://github.com/qmk/qmk_firmware/pull/22825))
|
||||
* apa102: cleanups ([#22826](https://github.com/qmk/qmk_firmware/pull/22826))
|
||||
* Remove PWM advanced check for WS2812 driver ([#22830](https://github.com/qmk/qmk_firmware/pull/22830))
|
||||
* Allow ChibiOS `SIO` driver for `UART` driver ([#22839](https://github.com/qmk/qmk_firmware/pull/22839))
|
||||
* LED drivers: more formatting ([#22865](https://github.com/qmk/qmk_firmware/pull/22865))
|
||||
* LED drivers: change `write_pwm_buffer()` return type to `void` ([#22869](https://github.com/qmk/qmk_firmware/pull/22869))
|
||||
* [CI] Regenerate Files ([#22872](https://github.com/qmk/qmk_firmware/pull/22872))
|
||||
* LED drivers: switch to i2c_writeReg() ([#22878](https://github.com/qmk/qmk_firmware/pull/22878))
|
||||
* LED drivers: remove `write_pwm_buffer()` from public API ([#22884](https://github.com/qmk/qmk_firmware/pull/22884))
|
||||
* i2c: rename read/write register functions ([#22905](https://github.com/qmk/qmk_firmware/pull/22905))
|
||||
* LED drivers: update I2C API usage ([#22951](https://github.com/qmk/qmk_firmware/pull/22951))
|
||||
* LED drivers: create structs to hold PWM/scaling buffers ([#22955](https://github.com/qmk/qmk_firmware/pull/22955))
|
||||
* Migrate and remove deprecated debug utils ([#22961](https://github.com/qmk/qmk_firmware/pull/22961))
|
||||
* Remove call to removed i2c function in azoteq driver ([#22966](https://github.com/qmk/qmk_firmware/pull/22966))
|
||||
* Tidy up print/debug logging headers ([#22969](https://github.com/qmk/qmk_firmware/pull/22969))
|
||||
* Begin removal of bootmagic lite terminology ([#22970](https://github.com/qmk/qmk_firmware/pull/22970))
|
||||
* LED drivers: place I2C addresses into an array ([#22975](https://github.com/qmk/qmk_firmware/pull/22975))
|
||||
* Removal of bootmagic lite terminology ([#22979](https://github.com/qmk/qmk_firmware/pull/22979))
|
||||
* Init pins for Analog Joystick sensor ([#22985](https://github.com/qmk/qmk_firmware/pull/22985))
|
||||
* Workaround for G431 eeprom emulation ([#23002](https://github.com/qmk/qmk_firmware/pull/23002))
|
||||
* is31fl3741: split PWM and scaling buffers ([#23049](https://github.com/qmk/qmk_firmware/pull/23049))
|
||||
* LED drivers: update PWM register defines for `g_<driver>_leds` ([#23052](https://github.com/qmk/qmk_firmware/pull/23052))
|
||||
* LED drivers: add support for shutdown pin ([#23058](https://github.com/qmk/qmk_firmware/pull/23058))
|
||||
* AW20216S: combine EN pin defines ([#23067](https://github.com/qmk/qmk_firmware/pull/23067))
|
||||
* Update naming convention for GPIO control macros ([#23085](https://github.com/qmk/qmk_firmware/pull/23085))
|
||||
* Update GPIO macro usages in core ([#23093](https://github.com/qmk/qmk_firmware/pull/23093))
|
||||
* OS Detection - Entire file should not be wrapped with ifdef ([#23108](https://github.com/qmk/qmk_firmware/pull/23108))
|
||||
* IS31FL3729 updates ([#23109](https://github.com/qmk/qmk_firmware/pull/23109))
|
||||
* Nix shell updates (Nixpkgs 2024-02-23, QMK CLI 1.1.5) ([#23143](https://github.com/qmk/qmk_firmware/pull/23143))
|
||||
|
||||
CLI:
|
||||
* [Refactor] `qmk find` ([#21096](https://github.com/qmk/qmk_firmware/pull/21096))
|
||||
* [Refactor] Break `QGFImageFile`'s `_save` function into smaller pieces ([#21124](https://github.com/qmk/qmk_firmware/pull/21124))
|
||||
* [Enhancement] Prepare for `SyntaxWarning` ([#22562](https://github.com/qmk/qmk_firmware/pull/22562))
|
||||
* Flag invalid keyboard features during lint ([#22832](https://github.com/qmk/qmk_firmware/pull/22832))
|
||||
|
||||
Submodule updates:
|
||||
* chore(chibios-contrib): sync with chibios-21.11.x ([#22560](https://github.com/qmk/qmk_firmware/pull/22560))
|
||||
|
||||
Keyboards:
|
||||
* Move `redox_w` into `redox` ([#21448](https://github.com/qmk/qmk_firmware/pull/21448))
|
||||
* null ST110R2.1 (SaikouType) basic support with layouts ([#21623](https://github.com/qmk/qmk_firmware/pull/21623))
|
||||
* New keyboard addition: Orthograph ([#21770](https://github.com/qmk/qmk_firmware/pull/21770))
|
||||
* Add Olly JF Rev.2 ([#21775](https://github.com/qmk/qmk_firmware/pull/21775))
|
||||
* Cleanup Satisfaction75 Firmware and add new revisions ([#22082](https://github.com/qmk/qmk_firmware/pull/22082))
|
||||
* Migrate dynamic_keymap.layer_count < 4 where requried ([#22091](https://github.com/qmk/qmk_firmware/pull/22091))
|
||||
* Bastard Keyboards: Add support for Dilemma v2 (3x5+3) ([#22185](https://github.com/qmk/qmk_firmware/pull/22185))
|
||||
* Karn: correct layout data ([#22201](https://github.com/qmk/qmk_firmware/pull/22201))
|
||||
* zk3mod : added OLED ([#22303](https://github.com/qmk/qmk_firmware/pull/22303))
|
||||
* Adds support for the Iron180 V2 PCBs ([#22314](https://github.com/qmk/qmk_firmware/pull/22314))
|
||||
* Add 5x13 and 6x13 ortho community layouts ([#22315](https://github.com/qmk/qmk_firmware/pull/22315))
|
||||
* Cipulot refactoring ([#22368](https://github.com/qmk/qmk_firmware/pull/22368))
|
||||
* Remove era/klein ([#22384](https://github.com/qmk/qmk_firmware/pull/22384))
|
||||
* consolidate firmware folder in smoll parent folder ([#22401](https://github.com/qmk/qmk_firmware/pull/22401))
|
||||
* `keycapsss/plaid_pad`: switch to encoder map ([#22474](https://github.com/qmk/qmk_firmware/pull/22474))
|
||||
* Add EE-AT and move W1-AT under geonworks ([#22526](https://github.com/qmk/qmk_firmware/pull/22526))
|
||||
* refactor: projectcain/vault35 ([#22558](https://github.com/qmk/qmk_firmware/pull/22558))
|
||||
* Update Q5 ([#22575](https://github.com/qmk/qmk_firmware/pull/22575))
|
||||
* Update Q7 ([#22577](https://github.com/qmk/qmk_firmware/pull/22577))
|
||||
* Update Q8 ([#22578](https://github.com/qmk/qmk_firmware/pull/22578))
|
||||
* Update Q9 ([#22579](https://github.com/qmk/qmk_firmware/pull/22579))
|
||||
* Remove "empty" files ([#22603](https://github.com/qmk/qmk_firmware/pull/22603))
|
||||
* Rename Pumpkin Pad to Pumkinpad ([#22651](https://github.com/qmk/qmk_firmware/pull/22651))
|
||||
* Noodlepad Additions and Updates ([#22701](https://github.com/qmk/qmk_firmware/pull/22701))
|
||||
* Refactor: move miniaxe into kagizaraya ([#22708](https://github.com/qmk/qmk_firmware/pull/22708))
|
||||
* Refactor: move keyboards into zigotica folder ([#22709](https://github.com/qmk/qmk_firmware/pull/22709))
|
||||
* Refactor: move keyboards into laneware folder ([#22710](https://github.com/qmk/qmk_firmware/pull/22710))
|
||||
* Refactor: move keyboards into kezewa ([#22712](https://github.com/qmk/qmk_firmware/pull/22712))
|
||||
* Refactor: move keyboards into kbdmania folder ([#22714](https://github.com/qmk/qmk_firmware/pull/22714))
|
||||
* Refactor: move keyboards into monokei folder ([#22715](https://github.com/qmk/qmk_firmware/pull/22715))
|
||||
* Refactor: move keyboards into kumaokobo ([#22719](https://github.com/qmk/qmk_firmware/pull/22719))
|
||||
* Updating NCC1701KB and adding via support ([#22721](https://github.com/qmk/qmk_firmware/pull/22721))
|
||||
* Move Moonlander to ZSA folder ([#22740](https://github.com/qmk/qmk_firmware/pull/22740))
|
||||
* Refactor: group shandoncodes keyboards ([#22743](https://github.com/qmk/qmk_firmware/pull/22743))
|
||||
* Refactor: group rookiebwoy keyboards ([#22745](https://github.com/qmk/qmk_firmware/pull/22745))
|
||||
* Default folder correction for kumaokobo ([#22750](https://github.com/qmk/qmk_firmware/pull/22750))
|
||||
* Default folder correction for rookiebwoy ([#22753](https://github.com/qmk/qmk_firmware/pull/22753))
|
||||
* Refactor: move macro3 into handwired folder ([#22759](https://github.com/qmk/qmk_firmware/pull/22759))
|
||||
* Refactor: group kira keyboards ([#22760](https://github.com/qmk/qmk_firmware/pull/22760))
|
||||
* Refactor: group hub keyboards ([#22762](https://github.com/qmk/qmk_firmware/pull/22762))
|
||||
* Refactor: move p3d keyboards ([#22763](https://github.com/qmk/qmk_firmware/pull/22763))
|
||||
* Refactor: group kbdfans keyboards ([#22764](https://github.com/qmk/qmk_firmware/pull/22764))
|
||||
* Remove incorrect use of WS2812_PIO_USE_PIO1 ([#22771](https://github.com/qmk/qmk_firmware/pull/22771))
|
||||
* Migrate LED Matrix config to info.json ([#22792](https://github.com/qmk/qmk_firmware/pull/22792))
|
||||
* Migrate RGB Matrix config to info.json - [0-9] ([#22797](https://github.com/qmk/qmk_firmware/pull/22797))
|
||||
* Migrate RGB Matrix config to info.json - A ([#22798](https://github.com/qmk/qmk_firmware/pull/22798))
|
||||
* Late9 keymaps update, added VIA support ([#22801](https://github.com/qmk/qmk_firmware/pull/22801))
|
||||
* Migrate RGB Matrix config to info.json - B ([#22806](https://github.com/qmk/qmk_firmware/pull/22806))
|
||||
* Migrate RGB Matrix config to info.json - C ([#22807](https://github.com/qmk/qmk_firmware/pull/22807))
|
||||
* Migrate RGB Matrix config to info.json - EF ([#22808](https://github.com/qmk/qmk_firmware/pull/22808))
|
||||
* Migrate RGB Matrix config to info.json - D ([#22811](https://github.com/qmk/qmk_firmware/pull/22811))
|
||||
* H87g2 updates ([#22819](https://github.com/qmk/qmk_firmware/pull/22819))
|
||||
* WT boards: extract `g_is31fl3736_leds` from wt_mono_backlight ([#22823](https://github.com/qmk/qmk_firmware/pull/22823))
|
||||
* Migrate RGB Matrix config to info.json - G ([#22859](https://github.com/qmk/qmk_firmware/pull/22859))
|
||||
* Use existing columns for 3x5 layout ([#22860](https://github.com/qmk/qmk_firmware/pull/22860))
|
||||
* Migrate RGB Matrix config to info.json - H ([#22861](https://github.com/qmk/qmk_firmware/pull/22861))
|
||||
* Migrate RGB Matrix config to info.json - J ([#22862](https://github.com/qmk/qmk_firmware/pull/22862))
|
||||
* Migrate RGB Matrix config to info.json - I ([#22863](https://github.com/qmk/qmk_firmware/pull/22863))
|
||||
* Migrate RGB Matrix config to info.json - L ([#22864](https://github.com/qmk/qmk_firmware/pull/22864))
|
||||
* Migrate RGB Matrix config to info.json - NOPQ ([#22866](https://github.com/qmk/qmk_firmware/pull/22866))
|
||||
* Migrate RGB Matrix config to info.json - XZY ([#22879](https://github.com/qmk/qmk_firmware/pull/22879))
|
||||
* Zed65/no_backlight/cor65 correct data layout ([#22898](https://github.com/qmk/qmk_firmware/pull/22898))
|
||||
* Migrate RGB Matrix config to info.json - M ([#22908](https://github.com/qmk/qmk_firmware/pull/22908))
|
||||
* Migrate RGB Matrix config to info.json - RS ([#22909](https://github.com/qmk/qmk_firmware/pull/22909))
|
||||
* Migrate RGB Matrix config to info.json - TUVW ([#22910](https://github.com/qmk/qmk_firmware/pull/22910))
|
||||
* Migrate RGB Matrix config to info.json - K ([#22911](https://github.com/qmk/qmk_firmware/pull/22911))
|
||||
* Remove `LAYOUTS_HAS_RGB` ([#22917](https://github.com/qmk/qmk_firmware/pull/22917))
|
||||
* Migrate lighting defaults to info.json ([#22920](https://github.com/qmk/qmk_firmware/pull/22920))
|
||||
* Ensure LTO is enabled as a `info.json` build config option ([#22932](https://github.com/qmk/qmk_firmware/pull/22932))
|
||||
* refactor(keyboard): quokka ([#22942](https://github.com/qmk/qmk_firmware/pull/22942))
|
||||
* Sango Keyboard ([#22971](https://github.com/qmk/qmk_firmware/pull/22971))
|
||||
* Add FS streampad ([#22991](https://github.com/qmk/qmk_firmware/pull/22991))
|
||||
* Remove always enabled effects from lighting animation list ([#22992](https://github.com/qmk/qmk_firmware/pull/22992))
|
||||
* Migrate RGB Matrix config to info.json - keychron ([#22998](https://github.com/qmk/qmk_firmware/pull/22998))
|
||||
* Migrate RGB Matrix config to info.json - Misc ([#23000](https://github.com/qmk/qmk_firmware/pull/23000))
|
||||
* Remove ee_hands config from ferris/sweep firmware ([#23029](https://github.com/qmk/qmk_firmware/pull/23029))
|
||||
* Migrate dip switch config to info.json - keychron ([#23037](https://github.com/qmk/qmk_firmware/pull/23037))
|
||||
* [unicorne] Add a layout alias ([#23056](https://github.com/qmk/qmk_firmware/pull/23056))
|
||||
* nacly/sodium62: Update vid, pid, and add via keymap ([#23063](https://github.com/qmk/qmk_firmware/pull/23063))
|
||||
* LED drivers: update keyboard LED configs ([#23073](https://github.com/qmk/qmk_firmware/pull/23073))
|
||||
* Remove invalid keyboard level features ([#23074](https://github.com/qmk/qmk_firmware/pull/23074))
|
||||
* Migrate WEAR_LEVELING_* to info.json ([#23077](https://github.com/qmk/qmk_firmware/pull/23077))
|
||||
* [Keymap Removal] keyboard with most keymaps ([#23081](https://github.com/qmk/qmk_firmware/pull/23081))
|
||||
* Remove obvious user keymaps, keyboards/{v,x,y,z}* edition. ([#23083](https://github.com/qmk/qmk_firmware/pull/23083))
|
||||
* Remove obvious user keymaps, keyboards/{s,t}* edition. ([#23084](https://github.com/qmk/qmk_firmware/pull/23084))
|
||||
* [Keymap Removal] keyboard with most keymaps ([#23092](https://github.com/qmk/qmk_firmware/pull/23092))
|
||||
* Fiuxup takashicompany/heavy_left ([#23094](https://github.com/qmk/qmk_firmware/pull/23094))
|
||||
* Remove obvious user keymaps, keyboards/{i,j,k}* edition ([#23102](https://github.com/qmk/qmk_firmware/pull/23102))
|
||||
* Manual user keymap removal ([#23104](https://github.com/qmk/qmk_firmware/pull/23104))
|
||||
* Manual user keymap removal ([#23119](https://github.com/qmk/qmk_firmware/pull/23119))
|
||||
* Migrate `RGBLED_NUM` -> `RGBLIGHT_LED_COUNT` in remaining non-user keymaps ([#23128](https://github.com/qmk/qmk_firmware/pull/23128))
|
||||
|
||||
Keyboard fixes:
|
||||
* Fix VID and PID for AnnePro2 ([#22263](https://github.com/qmk/qmk_firmware/pull/22263))
|
||||
* fix(kikoslab/kl90): Fix firmware to support encoder knobs properly ([#22649](https://github.com/qmk/qmk_firmware/pull/22649))
|
||||
* fix: improper usage of keyboard/user-level functions ([#22652](https://github.com/qmk/qmk_firmware/pull/22652))
|
||||
* Temporary fix for mechlovin/olly/octagon ([#22796](https://github.com/qmk/qmk_firmware/pull/22796))
|
||||
* Keychron Q11 usb poweron fix ([#22799](https://github.com/qmk/qmk_firmware/pull/22799))
|
||||
* capsunlocked/cu80/v2: Fix invalid RGB matrix config ([#22873](https://github.com/qmk/qmk_firmware/pull/22873))
|
||||
* Fix typo in Redox config ([#22899](https://github.com/qmk/qmk_firmware/pull/22899))
|
||||
* Fixup doio/kb16 ([#22921](https://github.com/qmk/qmk_firmware/pull/22921))
|
||||
* Fixup takashicompany/minizone ([#22922](https://github.com/qmk/qmk_firmware/pull/22922))
|
||||
* Fixup sofle ([#22934](https://github.com/qmk/qmk_firmware/pull/22934))
|
||||
* Fix Issue with RGB Matrix not understanding the split keyboard ([#22997](https://github.com/qmk/qmk_firmware/pull/22997))
|
||||
* Fixup sawnsprojects/krush60 ([#23095](https://github.com/qmk/qmk_firmware/pull/23095))
|
||||
* Fixup kbd67/rev1 ([#23096](https://github.com/qmk/qmk_firmware/pull/23096))
|
||||
* Fixup boardsource/equals ([#23106](https://github.com/qmk/qmk_firmware/pull/23106))
|
||||
* Fixup inett_studio/sq80 ([#23121](https://github.com/qmk/qmk_firmware/pull/23121))
|
||||
* Add LED/RGB Matrix drivers to info.json schema ([#23127](https://github.com/qmk/qmk_firmware/pull/23127))
|
||||
* Fix for multiple AMUX usage ([#23155](https://github.com/qmk/qmk_firmware/pull/23155))
|
||||
|
||||
Bugs:
|
||||
* MIDI sustain effect fix on qmk 0.22.2 ([#22114](https://github.com/qmk/qmk_firmware/pull/22114))
|
||||
* Prevent `qmk migrate` processing unparsed info.json values ([#22374](https://github.com/qmk/qmk_firmware/pull/22374))
|
||||
* Remove redundant backlight eeconfig init ([#22675](https://github.com/qmk/qmk_firmware/pull/22675))
|
||||
* pointing_device ifdef indentation fix ([#22802](https://github.com/qmk/qmk_firmware/pull/22802))
|
||||
* Ensure LED config is extracted when feature is disabled ([#22809](https://github.com/qmk/qmk_firmware/pull/22809))
|
||||
* Generate true/false for _DEFAULT_ON options ([#22829](https://github.com/qmk/qmk_firmware/pull/22829))
|
||||
* is31fl3733: fix driver sync backwards compatibility defines ([#22851](https://github.com/qmk/qmk_firmware/pull/22851))
|
||||
* LED drivers: misc formatting and typos ([#22857](https://github.com/qmk/qmk_firmware/pull/22857))
|
||||
* Allow generation of both LED and RGB Matrix config ([#22896](https://github.com/qmk/qmk_firmware/pull/22896))
|
||||
* LED drivers: remove PWM register offsets ([#22897](https://github.com/qmk/qmk_firmware/pull/22897))
|
||||
* `qmk format-json`: Force Unix line endings and ensure LF at EOF ([#22901](https://github.com/qmk/qmk_firmware/pull/22901))
|
||||
* Fix cirque connected check ([#22948](https://github.com/qmk/qmk_firmware/pull/22948))
|
||||
* Fix joystick initialization ([#22953](https://github.com/qmk/qmk_firmware/pull/22953))
|
||||
* Workaround for `make test:all DEBUG=1` ([#23047](https://github.com/qmk/qmk_firmware/pull/23047))
|
||||
* Fix unit test execution ([#23048](https://github.com/qmk/qmk_firmware/pull/23048))
|
||||
* Fix git-submodule running in wrong location ([#23059](https://github.com/qmk/qmk_firmware/pull/23059))
|
||||
* WS2812 bitbang: prefix for `NOP_FUDGE` define ([#23110](https://github.com/qmk/qmk_firmware/pull/23110))
|
||||
* Fix make clean test:os_detection ([#23112](https://github.com/qmk/qmk_firmware/pull/23112))
|
||||
* Fix pmw33xx sensor corruption on get-cpi call ([#23116](https://github.com/qmk/qmk_firmware/pull/23116))
|
||||
* Ensure `qmk generate-compilation-database` copies to userspace as well. ([#23129](https://github.com/qmk/qmk_firmware/pull/23129))
|
|
@ -138,7 +138,7 @@
|
|||
* Breaking Changes
|
||||
* [Overview](breaking_changes.md)
|
||||
* [My Pull Request Was Flagged](breaking_changes_instructions.md)
|
||||
* [Most Recent ChangeLog](ChangeLog/20231126.md "QMK v0.23.0 - 2023 Nov 26")
|
||||
* [Most Recent ChangeLog](ChangeLog/20240225.md "QMK v0.24.0 - 2024 Feb 25")
|
||||
* [Past Breaking Changes](breaking_changes_history.md)
|
||||
|
||||
* C Development
|
||||
|
|
|
@ -116,19 +116,32 @@ Additionally, in the board config, you'll want to make changes to enable the DAC
|
|||
| Define | Defaults | Description |
|
||||
| -------------------------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `AUDIO_DAC_SAMPLE_MAX` | `4095U` | Highest value allowed. Lower value means lower volume. And 4095U is the upper limit, since this is limited to a 12 bit value. Only effects non-pregenerated samples. |
|
||||
| `AUDIO_DAC_OFF_VALUE` | `AUDIO_DAC_SAMPLE_MAX / 2` | The value of the DAC when notplaying anything. Some setups may require a high (`AUDIO_DAC_SAMPLE_MAX`) or low (`0`) value here. |
|
||||
| `AUDIO_DAC_OFF_VALUE` | `AUDIO_DAC_SAMPLE_MAX / 2` | The value of the DAC when not playing anything. Some setups may require a high (`AUDIO_DAC_SAMPLE_MAX`) or low (`0`) value here. |
|
||||
| `AUDIO_MAX_SIMULTANEOUS_TONES` | __see next table__ | The number of tones that can be played simultaneously. A value that is too high may freeze the controller or glitch out when too many tones are being played. |
|
||||
| `AUDIO_DAC_SAMPLE_RATE` | __see next table__ | Effective bit rate of the DAC (in hertz), higher limits simultaneous tones, and lower sacrifices quality. |
|
||||
| `AUDIO_DAC_BUFFER_SIZE` | __see next table__ | Number of samples generated every refill. Too few may cause excessive CPU load; too many may cause freezes, RAM or flash exhaustion or lags during matrix scanning. |
|
||||
|
||||
There are a number of predefined quality settings that you can use, with "sane minimum" being the default. You can use custom values by simply defining the sample rate and number of simultaneous tones, instead of using one of the listed presets.
|
||||
There are a number of predefined quality settings that you can use, with "sane minimum" being the default. You can use custom values by simply defining the sample rate, number of simultaneous tones and buffer size, instead of using one of the listed presets.
|
||||
|
||||
| Define | Sample Rate | Simultaneous tones |
|
||||
| --------------------------------- | ----------- | ------------------- |
|
||||
| `AUDIO_DAC_QUALITY_VERY_LOW` | `11025U` | `8` |
|
||||
| `AUDIO_DAC_QUALITY_LOW` | `22040U` | `4` |
|
||||
| `AUDIO_DAC_QUALITY_HIGH` | `44100U` | `2` |
|
||||
| `AUDIO_DAC_QUALITY_VERY_HIGH` | `88200U` | `1` |
|
||||
| `AUDIO_DAC_QUALITY_SANE_MINIMUM` | `16384U` | `8` |
|
||||
| Define | Sample Rate | Simultaneous tones | Buffer size |
|
||||
| --------------------------------- | ----------- | ------------------- | ----------- |
|
||||
| `AUDIO_DAC_QUALITY_VERY_LOW` | `11025U` | `8` | `64U` |
|
||||
| `AUDIO_DAC_QUALITY_LOW` | `22050U` | `4` | `128U` |
|
||||
| `AUDIO_DAC_QUALITY_HIGH` | `44100U` | `2` | `256U` |
|
||||
| `AUDIO_DAC_QUALITY_VERY_HIGH` | `88200U` | `1` | `256U` |
|
||||
| `AUDIO_DAC_QUALITY_SANE_MINIMUM` | `16384U` | `8` | `64U` |
|
||||
|
||||
#### Notes on buffer size :id=buffer-size
|
||||
|
||||
By default, the buffer size attempts to keep to these constraints:
|
||||
|
||||
* The interval between buffer refills can't be too short, since the microcontroller would then only be servicing buffer refills and would freeze up.
|
||||
* On the additive driver, the interval between buffer refills can't be too long, since matrix scanning would suffer lengthy pauses every so often, which would delay key presses or releases or lose some short taps altogether.
|
||||
* The interval between buffer refills is kept to a minimum, which allows notes to stop as soon as possible after they should.
|
||||
* For greater compatibility, the buffer size should be a power of 2.
|
||||
* The buffer size being too large causes resource exhaustion leading to build failures or freezing at runtime: RAM usage (on the additive driver) or flash usage (on the basic driver).
|
||||
|
||||
You can lower the buffer size if you need a bit more space in your firmware, or raise it if your keyboard freezes up.
|
||||
|
||||
|
||||
```c
|
||||
|
@ -186,6 +199,11 @@ with all this information, the configuration would contain these lines:
|
|||
ChibiOS uses GPIOv1 for the F103, which only knows of one alternate function.
|
||||
On 'larger' STM32s, GPIOv2 or GPIOv3 are used; with them it is also necessary to configure `AUDIO_PWM_PAL_MODE` to the correct alternate function for the selected pin, timer and timer-channel.
|
||||
|
||||
You can also use the Complementary output (`TIMx_CHyN`) for PWM on supported controllers. To enable this functionality, you will need to make the following changes:
|
||||
```c
|
||||
// config.h:
|
||||
#define AUDIO_PWM_COMPLEMENTARY_OUTPUT
|
||||
```
|
||||
|
||||
### PWM software :id=pwm-software
|
||||
|
||||
|
|
|
@ -10,25 +10,25 @@ Practically, this means QMK merges the `develop` branch into the `master` branch
|
|||
|
||||
## What has been included in past Breaking Changes?
|
||||
|
||||
* [2024 Feb 25](ChangeLog/20240225.md)
|
||||
* [2023 Nov 26](ChangeLog/20231126.md)
|
||||
* [2023 Aug 27](ChangeLog/20230827.md)
|
||||
* [2023 May 28](ChangeLog/20230528.md)
|
||||
* [Older Breaking Changes](breaking_changes_history.md)
|
||||
|
||||
## When is the next Breaking Change?
|
||||
|
||||
The next Breaking Change is scheduled for November 26, 2023.
|
||||
The next Breaking Change is scheduled for May 26, 2024.
|
||||
|
||||
### Important Dates
|
||||
|
||||
* 2023 Nov 26 - `develop` is tagged with a new release version. Each push to `master` is subsequently merged to `develop` by GitHub actions.
|
||||
* 2024 Jan 28 - `develop` closed to new PRs.
|
||||
* 2024 Jan 28 - Call for testers.
|
||||
* 2024 Feb 4 - Last day for merges -- after this point `develop` is locked for testing and accepts only bugfixes
|
||||
* 2024 Feb 18 - `develop` is locked, only critical bugfix PRs merged.
|
||||
* 2024 Feb 22 - `master` is locked, no PRs merged.
|
||||
* 2024 Feb 25 - Merge `develop` to `master`.
|
||||
* 2024 Feb 25 - `master` is unlocked. PRs can be merged again.
|
||||
* 2024 Feb 25 - `develop` is tagged with a new release version. Each push to `master` is subsequently merged to `develop` by GitHub actions.
|
||||
* 2024 Apr 28 - `develop` closed to new PRs.
|
||||
* 2024 Apr 28 - Call for testers.
|
||||
* 2024 May 5 - Last day for merges -- after this point `develop` is locked for testing and accepts only bugfixes
|
||||
* 2024 May 19 - `develop` is locked, only critical bugfix PRs merged.
|
||||
* 2024 May 23 - `master` is locked, no PRs merged.
|
||||
* 2024 May 26 - Merge `develop` to `master`.
|
||||
* 2024 May 26 - `master` is unlocked. PRs can be merged again.
|
||||
|
||||
## What changes will be included?
|
||||
|
||||
|
@ -48,7 +48,7 @@ Criteria for acceptance:
|
|||
|
||||
Strongly suggested:
|
||||
|
||||
* The PR has a ChangeLog file describing the changes under `<qmk_firmware>/docs/Changelog/20240225`.
|
||||
* The PR has a ChangeLog file describing the changes under `<qmk_firmware>/docs/Changelog/20240526`.
|
||||
* This should be in Markdown format, with a name in the format `PR12345.md`, substituting the digits for your PRs ID.
|
||||
* One strong recommendation that the ChangeLog document matches the PR description on GitHub, so as to ensure traceability.
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
This page links to all previous changelogs from the QMK Breaking Changes process.
|
||||
|
||||
* [2024 Feb 25](ChangeLog/20240225.md) - version 0.24.0
|
||||
* [2023 Nov 26](ChangeLog/20231126.md) - version 0.23.0
|
||||
* [2023 Aug 27](ChangeLog/20230827.md) - version 0.22.0
|
||||
* [2023 May 28](ChangeLog/20230528.md) - version 0.21.0
|
||||
|
|
|
@ -223,7 +223,7 @@ If you define these options you will enable the associated feature, which may in
|
|||
* Adds ability to [blink](feature_rgblight.md?id=lighting-layer-blink) a lighting layer for a specified number of milliseconds (e.g. to acknowledge an action).
|
||||
* `#define RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF`
|
||||
* If defined, then [lighting layers](feature_rgblight?id=overriding-rgb-lighting-onoff-status) will be shown even if RGB Light is off.
|
||||
* `#define RGBLED_NUM 12`
|
||||
* `#define RGBLIGHT_LED_COUNT 12`
|
||||
* number of LEDs
|
||||
* `#define RGBLIGHT_SPLIT`
|
||||
* Needed if both halves of the board have RGB LEDs wired directly to the RGB output pin on the controllers instead of passing the output of the left half to the input of the right half
|
||||
|
@ -275,7 +275,7 @@ There are a few different ways to set handedness for split keyboards (listed in
|
|||
* For using high/low pin to determine handedness, low = right hand, high = left hand. Replace `B7` with the pin you are using. This is optional, and if you leave `SPLIT_HAND_PIN` undefined, then you can still use the EE_HANDS method or MASTER_LEFT / MASTER_RIGHT defines like the stock Let's Split uses.
|
||||
|
||||
* `#define SPLIT_HAND_MATRIX_GRID <out_pin>,<in_pin>`
|
||||
* The handedness is determined by using the intersection of the keyswitches in the key matrix, which does not exist. Normally, when this intersection is shorted (level low), it is considered left. If you define `#define SPLIT_HAND_MATRIX_GRID_LOW_IS_RIGHT`, it is determined to be right when the level is low.
|
||||
* The handedness is determined by using the intersection of the keyswitches in the key matrix, which does not exist. Normally, when this intersection is shorted (level low), it is considered right. If you define `#define SPLIT_HAND_MATRIX_GRID_LOW_IS_LEFT`, it is determined to be left when the level is low.
|
||||
|
||||
* `#define EE_HANDS` (only works if `SPLIT_HAND_PIN` and `SPLIT_HAND_MATRIX_GRID` are not defined)
|
||||
* Reads the handedness value stored in the EEPROM after `eeprom-lefthand.eep`/`eeprom-righthand.eep` has been flashed to their respective halves.
|
||||
|
|
|
@ -119,11 +119,11 @@ void keyboard_pre_init_user(void) {
|
|||
// Call the keyboard pre init code.
|
||||
|
||||
// Set our LED pins as output
|
||||
setPinOutput(B0);
|
||||
setPinOutput(B1);
|
||||
setPinOutput(B2);
|
||||
setPinOutput(B3);
|
||||
setPinOutput(B4);
|
||||
gpio_set_pin_output(B0);
|
||||
gpio_set_pin_output(B1);
|
||||
gpio_set_pin_output(B2);
|
||||
gpio_set_pin_output(B3);
|
||||
gpio_set_pin_output(B4);
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -70,13 +70,13 @@ The device name here is the name that appears in Zadig, and may not be what the
|
|||
|
||||
|Bootloader |Device Name |VID/PID |Driver |
|
||||
|--------------|------------------------------|--------------|-------|
|
||||
|`atmel-dfu` |ATmega16u2 DFU |`03EB:2FEF` |libusb0|
|
||||
|`atmel-dfu` |ATmega32U2 DFU |`03EB:2FF0` |libusb0|
|
||||
|`atmel-dfu` |ATm16U4 DFU V1.0.2 |`03EB:2FF3` |libusb0|
|
||||
|`atmel-dfu` |ATm32U4DFU |`03EB:2FF4` |libusb0|
|
||||
|`atmel-dfu` |*none* (AT90USB64) |`03EB:2FF9` |libusb0|
|
||||
|`atmel-dfu` |AT90USB128 DFU |`03EB:2FFB` |libusb0|
|
||||
|`qmk-dfu` |(keyboard name) Bootloader |As `atmel-dfu`|libusb0|
|
||||
|`atmel-dfu` |ATmega16u2 DFU |`03EB:2FEF` |WinUSB |
|
||||
|`atmel-dfu` |ATmega32U2 DFU |`03EB:2FF0` |WinUSB |
|
||||
|`atmel-dfu` |ATm16U4 DFU V1.0.2 |`03EB:2FF3` |WinUSB |
|
||||
|`atmel-dfu` |ATm32U4DFU |`03EB:2FF4` |WinUSB |
|
||||
|`atmel-dfu` |*none* (AT90USB64) |`03EB:2FF9` |WinUSB |
|
||||
|`atmel-dfu` |AT90USB128 DFU |`03EB:2FFB` |WinUSB |
|
||||
|`qmk-dfu` |(keyboard name) Bootloader |As `atmel-dfu`|WinUSB |
|
||||
|`halfkay` |*none* |`16C0:0478` |HidUsb |
|
||||
|`caterina` |Pro Micro 3.3V |`1B4F:9203` |usbser |
|
||||
|`caterina` |Pro Micro 5V |`1B4F:9205` |usbser |
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# Bootmagic Lite :id=bootmagic-lite
|
||||
# Bootmagic :id=bootmagic
|
||||
|
||||
The Bootmagic Lite feature that only handles jumping into the bootloader. This is great for boards that don't have a physical reset button, giving you a way to jump into the bootloader
|
||||
The Bootmagic feature that only handles jumping into the bootloader. This is great for boards that don't have a physical reset button, giving you a way to jump into the bootloader
|
||||
|
||||
On some keyboards Bootmagic Lite is disabled by default. If this is the case, it must be explicitly enabled in your `rules.mk` with:
|
||||
On some keyboards Bootmagic is disabled by default. If this is the case, it must be explicitly enabled in your `rules.mk` with:
|
||||
|
||||
```make
|
||||
BOOTMAGIC_ENABLE = yes
|
||||
|
@ -11,15 +11,15 @@ BOOTMAGIC_ENABLE = yes
|
|||
Additionally, you may want to specify which key to use. This is especially useful for keyboards that have unusual matrices. To do so, you need to specify the row and column of the key that you want to use. Add these entries to your `config.h` file:
|
||||
|
||||
```c
|
||||
#define BOOTMAGIC_LITE_ROW 0
|
||||
#define BOOTMAGIC_LITE_COLUMN 1
|
||||
#define BOOTMAGIC_ROW 0
|
||||
#define BOOTMAGIC_COLUMN 1
|
||||
```
|
||||
|
||||
By default, these are set to 0 and 0, which is usually the "ESC" key on a majority of keyboards.
|
||||
|
||||
And to trigger the bootloader, you hold this key down when plugging the keyboard in. Just the single key.
|
||||
|
||||
!> Using Bootmagic Lite will **always reset** the EEPROM, so you will lose any settings that have been saved.
|
||||
!> Using Bootmagic will **always reset** the EEPROM, so you will lose any settings that have been saved.
|
||||
|
||||
## Split Keyboards
|
||||
|
||||
|
@ -44,35 +44,35 @@ When [handedness](feature_split_keyboard.md#setting-handedness) is predetermined
|
|||
}
|
||||
```
|
||||
|
||||
If you pick the top right key for the right half, it is `R05` on the top layout. Within the key matrix below, `R05` is located on row 4 columnn 4. To use that key as the right half's Bootmagic Lite trigger, add these entries to your `config.h` file:
|
||||
If you pick the top right key for the right half, it is `R05` on the top layout. Within the key matrix below, `R05` is located on row 4 columnn 4. To use that key as the right half's Bootmagic trigger, add these entries to your `config.h` file:
|
||||
|
||||
```c
|
||||
#define BOOTMAGIC_LITE_ROW_RIGHT 4
|
||||
#define BOOTMAGIC_LITE_COLUMN_RIGHT 4
|
||||
#define BOOTMAGIC_ROW_RIGHT 4
|
||||
#define BOOTMAGIC_COLUMN_RIGHT 4
|
||||
```
|
||||
|
||||
?> These values are not set by default.
|
||||
|
||||
## Advanced Bootmagic Lite
|
||||
## Advanced Bootmagic
|
||||
|
||||
The `bootmagic_lite` function is defined weakly, so that you can replace this in your code, if you need. A great example of this is the Zeal60 boards that have some additional handling needed.
|
||||
The `bootmagic_scan` function is defined weakly, so that you can replace this in your code, if you need. A great example of this is the Zeal60 boards that have some additional handling needed.
|
||||
|
||||
To replace the function, all you need to do is add something like this to your code:
|
||||
|
||||
```c
|
||||
void bootmagic_lite(void) {
|
||||
void bootmagic_scan(void) {
|
||||
matrix_scan();
|
||||
wait_ms(DEBOUNCE * 2);
|
||||
matrix_scan();
|
||||
|
||||
if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) {
|
||||
if (matrix_get_row(BOOTMAGIC_ROW) & (1 << BOOTMAGIC_COLUMN)) {
|
||||
// Jump to bootloader.
|
||||
bootloader_jump();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You can define additional logic here. For instance, resetting the EEPROM or requiring additional keys to be pressed to trigger Bootmagic Lite. Keep in mind that `bootmagic_lite` is called before a majority of features are initialized in the firmware.
|
||||
You can define additional logic here. For instance, resetting the EEPROM or requiring additional keys to be pressed to trigger Bootmagic. Keep in mind that `bootmagic_scan` is called before a majority of features are initialized in the firmware.
|
||||
|
||||
## Addenda
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ The following converters are available at this time:
|
|||
| `promicro` | `elite_pi` |
|
||||
| `promicro` | `helios` |
|
||||
| `promicro` | `liatris` |
|
||||
| `promicro` | `imera` |
|
||||
| `promicro` | `michi` |
|
||||
| `elite_c` | `stemcell` |
|
||||
| `elite_c` | `rp2040_ce` |
|
||||
|
@ -82,6 +83,7 @@ If a board currently supported in QMK uses a [Pro Micro](https://www.sparkfun.co
|
|||
| [Elite-Pi](https://keeb.io/products/elite-pi-usb-c-pro-micro-replacement-rp2040) | `elite_pi` |
|
||||
| [0xCB Helios](https://keeb.supply/products/0xcb-helios) | `helios` |
|
||||
| [Liatris](https://splitkb.com/products/liatris) | `liatris` |
|
||||
| [Imera](https://splitkb.com/products/imera) | `imera` |
|
||||
| [Michi](https://github.com/ci-bus/michi-promicro-rp2040) | `michi` |
|
||||
|
||||
Converter summary:
|
||||
|
@ -99,6 +101,7 @@ Converter summary:
|
|||
| `elite_pi` | `-e CONVERT_TO=elite_pi` | `CONVERT_TO=elite_pi` | `#ifdef CONVERT_TO_ELITE_PI` |
|
||||
| `helios` | `-e CONVERT_TO=helios` | `CONVERT_TO=helios` | `#ifdef CONVERT_TO_HELIOS` |
|
||||
| `liatris` | `-e CONVERT_TO=liatris` | `CONVERT_TO=liatris` | `#ifdef CONVERT_TO_LIATRIS` |
|
||||
| `imera` | `-e CONVERT_TO=imera` | `CONVERT_TO=imera` | `#ifdef CONVERT_TO_IMERA` |
|
||||
| `michi` | `-e CONVERT_TO=michi` | `CONVERT_TO=michi` | `#ifdef CONVERT_TO_MICHI` |
|
||||
|
||||
### Proton C :id=proton_c
|
||||
|
|
|
@ -20,6 +20,27 @@ or
|
|||
#define DIP_SWITCH_MATRIX_GRID { {0,6}, {1,6}, {2,6} } // List of row and col pairs
|
||||
```
|
||||
|
||||
## DIP Switch map :id=dip-switch-map
|
||||
|
||||
DIP Switch mapping may be added to your `keymap.c`, which replicates the normal keyswitch functionality, but with dip switches. Add this to your keymap's `rules.mk`:
|
||||
|
||||
```make
|
||||
DIP_SWITCH_MAP_ENABLE = yes
|
||||
```
|
||||
|
||||
Your `keymap.c` will then need a dip switch mapping defined (for two dip switches):
|
||||
|
||||
```c
|
||||
#if defined(DIP_SWITCH_MAP_ENABLE)
|
||||
const uint16_t PROGMEM dip_switch_map[NUM_DIP_SWITCHES][NUM_DIP_STATES] = {
|
||||
DIP_SWITCH_OFF_ON(DF(0), DF(1)),
|
||||
DIP_SWITCH_OFF_ON(EC_NORM, EC_SWAP)
|
||||
};
|
||||
#endif
|
||||
```
|
||||
|
||||
?> This should only be enabled at the keymap level.
|
||||
|
||||
## Callbacks
|
||||
|
||||
The callback functions can be inserted into your `<keyboard>.c`:
|
||||
|
|
|
@ -50,10 +50,6 @@ Axes can be configured using one of the following macros:
|
|||
|
||||
* `JOYSTICK_AXIS_IN(input_pin, low, rest, high)`
|
||||
The ADC samples the provided pin. `low`, `high` and `rest` correspond to the minimum, maximum, and resting (or centered) analog values of the axis, respectively.
|
||||
* `JOYSTICK_AXIS_IN_OUT(input_pin, output_pin, low, rest, high)`
|
||||
Same as `JOYSTICK_AXIS_IN()`, but the provided `output_pin` will be pulled high before `input_pin` is read.
|
||||
* `JOYSTICK_AXIS_IN_OUT_GROUND(input_pin, output_pin, ground_pin, low, rest, high)`
|
||||
Same as `JOYSTICK_AXIS_IN_OUT()`, but the provided `ground_pin` will be pulled low before reading from `input_pin`.
|
||||
* `JOYSTICK_AXIS_VIRTUAL`
|
||||
No ADC reading is performed. The value should be provided by user code.
|
||||
|
||||
|
@ -160,12 +156,8 @@ Describes a single axis.
|
|||
|
||||
#### Members :id=api-joystick-config-t-members
|
||||
|
||||
- `pin_t output_pin`
|
||||
A pin to set as output high when reading the analog value, or `JS_VIRTUAL_AXIS`.
|
||||
- `pin_t input_pin`
|
||||
The pin to read the analog value from, or `JS_VIRTUAL_AXIS`.
|
||||
- `pin_t ground_pin`
|
||||
A pin to set as output low when reading the analog value, or `JS_VIRTUAL_AXIS`.
|
||||
- `uint16_t min_digit`
|
||||
The minimum analog value.
|
||||
- `uint16_t mid_digit`
|
||||
|
|
|
@ -56,16 +56,16 @@ This is a template indicator function that can be implemented on keyboard level
|
|||
bool led_update_kb(led_t led_state) {
|
||||
bool res = led_update_user(led_state);
|
||||
if(res) {
|
||||
// writePin sets the pin high for 1 and low for 0.
|
||||
// gpio_write_pin sets the pin high for 1 and low for 0.
|
||||
// In this example the pins are inverted, setting
|
||||
// it low/0 turns it on, and high/1 turns the LED off.
|
||||
// This behavior depends on whether the LED is between the pin
|
||||
// and VCC or the pin and GND.
|
||||
writePin(B0, !led_state.num_lock);
|
||||
writePin(B1, !led_state.caps_lock);
|
||||
writePin(B2, !led_state.scroll_lock);
|
||||
writePin(B3, !led_state.compose);
|
||||
writePin(B4, !led_state.kana);
|
||||
gpio_write_pin(B0, !led_state.num_lock);
|
||||
gpio_write_pin(B1, !led_state.caps_lock);
|
||||
gpio_write_pin(B2, !led_state.scroll_lock);
|
||||
gpio_write_pin(B3, !led_state.compose);
|
||||
gpio_write_pin(B4, !led_state.kana);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ For split keyboards using `LED_MATRIX_SPLIT` with an LED driver, you can either
|
|||
Define these arrays listing all the LEDs in your `<keyboard>.c`:
|
||||
|
||||
```c
|
||||
const is31fl3731_led_t PROGMEM g_is31fl3731_leds[LED_MATRIX_LED_COUNT] = {
|
||||
const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = {
|
||||
/* Refer to IS31 manual for these locations
|
||||
* driver
|
||||
* | LED address
|
||||
|
@ -65,7 +65,7 @@ const is31fl3731_led_t PROGMEM g_is31fl3731_leds[LED_MATRIX_LED_COUNT] = {
|
|||
}
|
||||
```
|
||||
|
||||
Where `Cx_y` is the location of the LED in the matrix defined by [the datasheet](https://www.issi.com/WW/pdf/31FL3731.pdf) and the header file `drivers/led/issi/is31fl3731-simple.h`. The `driver` is the index of the driver you defined in your `config.h` (`0`, `1`, `2`, or `3` ).
|
||||
Where `Cx_y` is the location of the LED in the matrix defined by [the datasheet](https://www.issi.com/WW/pdf/31FL3731.pdf) and the header file `drivers/led/issi/is31fl3731-mono.h`. The `driver` is the index of the driver you defined in your `config.h` (`0`, `1`, `2`, or `3` ).
|
||||
|
||||
---
|
||||
### IS31FLCOMMON :id=is31flcommon
|
||||
|
@ -142,8 +142,8 @@ const is31_led PROGMEM g_is31_leds[LED_MATRIX_LED_COUNT] = {
|
|||
* driver
|
||||
* | LED address
|
||||
* | | */
|
||||
{ 0, CS1_SW1 },
|
||||
{ 0, CS2_SW1 },
|
||||
{ 0, SW1_CS1 },
|
||||
{ 0, SW1_CS2 },
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
@ -357,7 +357,7 @@ For inspiration and examples, check out the built-in effects under `quantum/led_
|
|||
```c
|
||||
#define LED_MATRIX_KEYRELEASES // reactive effects respond to keyreleases (instead of keypresses)
|
||||
#define LED_MATRIX_TIMEOUT 0 // number of milliseconds to wait until led automatically turns off
|
||||
#define LED_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
|
||||
#define LED_MATRIX_SLEEP // turn off effects when suspended
|
||||
#define LED_MATRIX_LED_PROCESS_LIMIT (LED_MATRIX_LED_COUNT + 4) / 5 // limits the number of LEDs to process in an animation per task run (increases keyboard responsiveness)
|
||||
#define LED_MATRIX_LED_FLUSH_LIMIT 16 // limits in milliseconds how frequently an animation will update the LEDs. 16 (16ms) is equivalent to limiting to 60fps (increases keyboard responsiveness)
|
||||
#define LED_MATRIX_MAXIMUM_BRIGHTNESS 255 // limits maximum brightness of LEDs
|
||||
|
@ -365,6 +365,7 @@ For inspiration and examples, check out the built-in effects under `quantum/led_
|
|||
#define LED_MATRIX_DEFAULT_MODE LED_MATRIX_SOLID // Sets the default mode, if none has been set
|
||||
#define LED_MATRIX_DEFAULT_VAL LED_MATRIX_MAXIMUM_BRIGHTNESS // Sets the default brightness value, if none has been set
|
||||
#define LED_MATRIX_DEFAULT_SPD 127 // Sets the default animation speed, if none has been set
|
||||
#define LED_MATRIX_DEFAULT_FLAGS LED_FLAG_ALL // Sets the default LED flags, if none has been set
|
||||
#define LED_MATRIX_SPLIT { X, Y } // (Optional) For split keyboards, the number of LEDs connected on each half. X = left, Y = Right.
|
||||
// If reactive effects are enabled, you also will want to enable SPLIT_TRANSPORT_MIRROR
|
||||
```
|
||||
|
|
|
@ -69,9 +69,9 @@ The current list of available languages is:
|
|||
| **italian_osx_iso** | **jis** | **latvian** | **lithuanian_azerty** |
|
||||
| **lithuanian_qwerty** | **norman** | **norwegian** | **portuguese** |
|
||||
| **portuguese_osx_iso** | **romanian** | **serbian_latin** | **slovak** |
|
||||
| **slovenian** | **spanish_dvorak** | **spanish** | **swedish** |
|
||||
| **turkish_f** | **turkish_q** | **uk** | **us_international** |
|
||||
| **workman** | **workman_zxcvm** |
|
||||
| **slovenian** | **spanish_dvorak** | **spanish_latin_america** | **spanish** |
|
||||
| **swedish** | **turkish_f** | **turkish_q** | **uk** |
|
||||
| **us_international** | **workman** | **workman_zxcvm** |
|
||||
|
||||
### Macro Basics
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ In your `rules.mk` add:
|
|||
OS_DETECTION_ENABLE = yes
|
||||
```
|
||||
|
||||
Include `"os_detection.h"` in your `keymap.c`.
|
||||
It will automatically include the required headers file.
|
||||
It declares `os_variant_t detected_host_os(void);` which you can call to get detected OS.
|
||||
|
||||
It returns one of the following values:
|
||||
|
@ -32,6 +32,54 @@ enum {
|
|||
?> Note that it takes some time after firmware is booted to detect the OS.
|
||||
This time is quite short, probably hundreds of milliseconds, but this data may be not ready in keyboard and layout setup functions which run very early during firmware startup.
|
||||
|
||||
## Callbacks :id=callbacks
|
||||
|
||||
If you want to perform custom actions when the OS is detected, then you can use the `process_detected_host_os_kb` function on the keyboard level source file, or `process_detected_host_os_user` function in the user `keymap.c`.
|
||||
|
||||
```c
|
||||
bool process_detected_host_os_kb(os_variant_t detected_os) {
|
||||
if (!process_detected_host_os_user(detected_os)) {
|
||||
return false;
|
||||
}
|
||||
switch (detected_os) {
|
||||
case OS_MACOS:
|
||||
case OS_IOS:
|
||||
rgb_matrix_set_color_all(RGB_WHITE);
|
||||
break;
|
||||
case OS_WINDOWS:
|
||||
rgb_matrix_set_color_all(RGB_BLUE);
|
||||
break;
|
||||
case OS_LINUX:
|
||||
rgb_matrix_set_color_all(RGB_ORANGE);
|
||||
break;
|
||||
case OS_UNSURE:
|
||||
rgb_matrix_set_color_all(RGB_RED);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
```
|
||||
|
||||
## OS detection stability
|
||||
|
||||
The OS detection is currently handled while the USB device descriptor is being assembled.
|
||||
The process is done in steps, generating a number of intermediate results until it stabilizes.
|
||||
We therefore resort to debouncing the result until it has been stable for a given amount of milliseconds.
|
||||
This amount can be configured, in case your board is not stable within the default debouncing time of 200ms.
|
||||
|
||||
## KVM and USB switches
|
||||
|
||||
Some KVM and USB switches may not trigger the USB controller on the keyboard to fully reset upon switching machines.
|
||||
If your keyboard does not redetect the OS in this situation, you can force the keyboard to reset when the USB initialization event is detected, forcing the USB controller to be reconfigured.
|
||||
|
||||
## Configuration Options
|
||||
|
||||
* `#define OS_DETECTION_DEBOUNCE 200`
|
||||
* defined the debounce time for OS detection, in milliseconds
|
||||
* `#define OS_DETECTION_KEYBOARD_RESET`
|
||||
* enables the keyboard reset upon a USB device reinitilization, such as switching devices on some KVMs
|
||||
|
||||
## Debug
|
||||
|
||||
If OS is guessed incorrectly, you may want to collect data about USB setup packets to refine the detection logic.
|
||||
|
|
|
@ -69,10 +69,29 @@ The Analog Joystick is an analog (ADC) driven sensor. There are a variety of jo
|
|||
| `ANALOG_JOYSTICK_Y_AXIS_PIN` | (Required) The pin used for the horizontal/Y axis. | _not defined_ |
|
||||
| `ANALOG_JOYSTICK_AXIS_MIN` | (Optional) Sets the lower range to be considered movement. | `0` |
|
||||
| `ANALOG_JOYSTICK_AXIS_MAX` | (Optional) Sets the upper range to be considered movement. | `1023` |
|
||||
| `ANALOG_JOYSTICK_AUTO_AXIS` | (Optional) Sets ranges to be considered movement automatically. | _not defined_ |
|
||||
| `ANALOG_JOYSTICK_SPEED_REGULATOR` | (Optional) The divisor used to slow down movement. (lower makes it faster) | `20` |
|
||||
| `ANALOG_JOYSTICK_READ_INTERVAL` | (Optional) The interval in milliseconds between reads. | `10` |
|
||||
| `ANALOG_JOYSTICK_SPEED_MAX` | (Optional) The maximum value used for motion. | `2` |
|
||||
| `ANALOG_JOYSTICK_CLICK_PIN` | (Optional) The pin wired up to the press switch of the analog stick. | _not defined_ |
|
||||
| `ANALOG_JOYSTICK_WEIGHTS` | (Optional) Use custom weights for lever positions. | _not defined_ |
|
||||
| `ANALOG_JOYSTICK_CUTOFF` | (Optional) Cut off movement when joystick returns to start position. | _not defined_ |
|
||||
|
||||
If `ANALOG_JOYSTICK_AUTO_AXIS` is used, then `ANALOG_JOYSTICK_AXIS_MIN` and `ANALOG_JOYSTICK_AXIS_MAX` are ignored.
|
||||
|
||||
By default analog joystick implementation uses `x^2` weighting for lever positions. `ANALOG_JOYSTICK_WEIGHTS` allows to experiment with different configurations that might feel better.
|
||||
|
||||
E.g. This is weights for `((x-0.4)^3+0.064)/0.282`:
|
||||
|
||||
```c
|
||||
#define ANALOG_JOYSTICK_WEIGHTS {0,2,4,5,7,8,9,10,12,13,14,15,15,16,17,18,18,19,19,20,20,21,21,21,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,25,25,25,26,26,26,27,28,28,29,29,30,31,32,33,34,35,36,37,38,40,41,43,44,46,48,49,51,53,56,58,60,62,65,68,70,73,76,79,82,85,89,92,96,100}
|
||||
```
|
||||
|
||||
You can use following JS code to generate weights for different formulas:
|
||||
|
||||
```js
|
||||
JSON.stringify(Array.from(Array(101).keys()).map(x => Math.ceil((((x/100-0.4)**3+0.064)/0.282*100))))
|
||||
```
|
||||
|
||||
### Azoteq IQS5XX Trackpad
|
||||
|
||||
|
@ -158,12 +177,13 @@ This supports the Cirque Pinnacle 1CA027 Touch Controller, which is used in the
|
|||
|
||||
#### Common settings
|
||||
|
||||
| Setting | Description | Default |
|
||||
| -------------------------------- | ---------------------------------------------------------- | ------------------------------------------- |
|
||||
| `CIRQUE_PINNACLE_DIAMETER_MM` | (Optional) Diameter of the trackpad sensor in millimeters. | `40` |
|
||||
| `CIRQUE_PINNACLE_ATTENUATION` | (Optional) Sets the attenuation of the sensor data. | `EXTREG__TRACK_ADCCONFIG__ADC_ATTENUATE_4X` |
|
||||
| `CIRQUE_PINNACLE_CURVED_OVERLAY` | (Optional) Applies settings tuned for curved overlay. | _not defined_ |
|
||||
| `CIRQUE_PINNACLE_POSITION_MODE` | (Optional) Mode of operation. | _not defined_ |
|
||||
| Setting | Description | Default |
|
||||
| ------------------------------------ | ---------------------------------------------------------- | ------------------------------------------- |
|
||||
| `CIRQUE_PINNACLE_DIAMETER_MM` | (Optional) Diameter of the trackpad sensor in millimeters. | `40` |
|
||||
| `CIRQUE_PINNACLE_ATTENUATION` | (Optional) Sets the attenuation of the sensor data. | `EXTREG__TRACK_ADCCONFIG__ADC_ATTENUATE_4X` |
|
||||
| `CIRQUE_PINNACLE_CURVED_OVERLAY` | (Optional) Applies settings tuned for curved overlay. | _not defined_ |
|
||||
| `CIRQUE_PINNACLE_POSITION_MODE` | (Optional) Mode of operation. | _not defined_ |
|
||||
| `CIRQUE_PINNACLE_SKIP_SENSOR_CHECK` | (Optional) Skips sensor presence check | _not defined_ |
|
||||
|
||||
**`CIRQUE_PINNACLE_ATTENUATION`** is a measure of how much data is suppressed in regards to sensitivity. The higher the attenuation, the less sensitive the touchpad will be.
|
||||
|
||||
|
@ -197,12 +217,13 @@ Also see the `POINTING_DEVICE_TASK_THROTTLE_MS`, which defaults to 10ms when usi
|
|||
|
||||
#### Absolute mode settings
|
||||
|
||||
| Setting | Description | Default |
|
||||
| -------------------------------- | ---------------------------------------------------------- | ------------------ |
|
||||
| `CIRQUE_PINNACLE_X_LOWER` | (Optional) The minimum reachable X value on the sensor. | `127` |
|
||||
| `CIRQUE_PINNACLE_X_UPPER` | (Optional) The maximum reachable X value on the sensor. | `1919` |
|
||||
| `CIRQUE_PINNACLE_Y_LOWER` | (Optional) The minimum reachable Y value on the sensor. | `63` |
|
||||
| `CIRQUE_PINNACLE_Y_UPPER` | (Optional) The maximum reachable Y value on the sensor. | `1471` |
|
||||
| Setting | Description | Default |
|
||||
|-----------------------------------------|-------------------------------------------------------------------------|-------------|
|
||||
| `CIRQUE_PINNACLE_X_LOWER` | (Optional) The minimum reachable X value on the sensor. | `127` |
|
||||
| `CIRQUE_PINNACLE_X_UPPER` | (Optional) The maximum reachable X value on the sensor. | `1919` |
|
||||
| `CIRQUE_PINNACLE_Y_LOWER` | (Optional) The minimum reachable Y value on the sensor. | `63` |
|
||||
| `CIRQUE_PINNACLE_Y_UPPER` | (Optional) The maximum reachable Y value on the sensor. | `1471` |
|
||||
| `CIRQUE_PINNACLE_REACHABLE_CALIBRATION` | (Optional) Enable console messages to aide in calibrating above values. | not defined |
|
||||
|
||||
#### Absolute mode gestures
|
||||
|
||||
|
@ -708,6 +729,7 @@ There are a few ways to control the auto mouse feature with both `config.h` opti
|
|||
| `AUTO_MOUSE_TIME` | (Optional) Time layer remains active after activation | _ideally_ (250-1000) | _ms_ | `650 ms` |
|
||||
| `AUTO_MOUSE_DELAY` | (Optional) Lockout time after non-mouse key is pressed | _ideally_ (100-1000) | _ms_ | `TAPPING_TERM` or `200 ms` |
|
||||
| `AUTO_MOUSE_DEBOUNCE` | (Optional) Time delay from last activation to next update | _ideally_ (10 - 100) | _ms_ | `25 ms` |
|
||||
| `AUTO_MOUSE_THRESHOLD` | (Optional) Amount of mouse movement required to switch layers | 0 - | _units_ | `10 units` |
|
||||
|
||||
### Adding mouse keys
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ For split keyboards using `RGB_MATRIX_SPLIT` with an LED driver, you can either
|
|||
Define these arrays listing all the LEDs in your `<keyboard>.c`:
|
||||
|
||||
```c
|
||||
const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = {
|
||||
const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = {
|
||||
/* Refer to IS31 manual for these locations
|
||||
* driver
|
||||
* | R location
|
||||
|
@ -139,19 +139,19 @@ Currently only 4 drivers are supported, but it would be trivial to support all 8
|
|||
Define these arrays listing all the LEDs in your `<keyboard>.c`:
|
||||
|
||||
```c
|
||||
const is31fl3733_led_t PROGMEM g_is31fl3733_leds[RGB_MATRIX_LED_COUNT] = {
|
||||
const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT] = {
|
||||
/* Refer to IS31 manual for these locations
|
||||
* driver
|
||||
* | R location
|
||||
* | | G location
|
||||
* | | | B location
|
||||
* | | | | */
|
||||
{0, B_1, A_1, C_1},
|
||||
* | | G location
|
||||
* | | | B location
|
||||
* | | | | */
|
||||
{0, SW1_CS1, SW1_CS2, SW1_CS3},
|
||||
....
|
||||
}
|
||||
```
|
||||
|
||||
Where `X_Y` is the location of the LED in the matrix defined by [the datasheet](https://www.issi.com/WW/pdf/31FL3733.pdf) and the header file `drivers/led/issi/is31fl3733.h`. The `driver` is the index of the driver you defined in your `config.h` (`0`, `1`, `2`, or `3` for now).
|
||||
Where `SWx_CSy` is the location of the LED in the matrix defined by [the datasheet](https://www.issi.com/WW/pdf/31FL3733.pdf) and the header file `drivers/led/issi/is31fl3733.h`. The `driver` is the index of the driver you defined in your `config.h` (`0`, `1`, `2`, or `3` for now).
|
||||
|
||||
---
|
||||
### IS31FL3736 :id=is31fl3736
|
||||
|
@ -218,14 +218,14 @@ Here is an example using 2 drivers.
|
|||
Define these arrays listing all the LEDs in your `<keyboard>.c`:
|
||||
|
||||
```c
|
||||
const is31fl3736_led_t PROGMEM g_is31fl3736_leds[RGB_MATRIX_LED_COUNT] = {
|
||||
const is31fl3736_led_t PROGMEM g_is31fl3736_leds[IS31FL3736_LED_COUNT] = {
|
||||
/* Refer to IS31 manual for these locations
|
||||
* driver
|
||||
* | R location
|
||||
* | | G location
|
||||
* | | | B location
|
||||
* | | | | */
|
||||
{0, B_1, A_1, C_1},
|
||||
* | | G location
|
||||
* | | | B location
|
||||
* | | | | */
|
||||
{0, SW1_CS1, SW1_CS2, SW1_CS3},
|
||||
....
|
||||
}
|
||||
```
|
||||
|
@ -292,19 +292,19 @@ Here is an example using 2 drivers.
|
|||
Define these arrays listing all the LEDs in your `<keyboard>.c`:
|
||||
|
||||
```c
|
||||
const is31fl3737_led_t PROGMEM g_is31fl3737_leds[RGB_MATRIX_LED_COUNT] = {
|
||||
const is31fl3737_led_t PROGMEM g_is31fl3737_leds[IS31FL3737_LED_COUNT] = {
|
||||
/* Refer to IS31 manual for these locations
|
||||
* driver
|
||||
* | R location
|
||||
* | | G location
|
||||
* | | | B location
|
||||
* | | | | */
|
||||
{0, B_1, A_1, C_1},
|
||||
* | | G location
|
||||
* | | | B location
|
||||
* | | | | */
|
||||
{0, SW1_CS1, SW1_CS2, SW1_CS3},
|
||||
....
|
||||
}
|
||||
```
|
||||
|
||||
Where `X_Y` is the location of the LED in the matrix defined by [the datasheet](https://www.issi.com/WW/pdf/31FL3737.pdf) and the header file `drivers/led/issi/is31fl3737.h`. The `driver` is the index of the driver you defined in your `config.h` (Only `0`, `1`, `2`, or `3` for now).
|
||||
Where `SWx_CSy` is the location of the LED in the matrix defined by [the datasheet](https://www.issi.com/WW/pdf/31FL3737.pdf) and the header file `drivers/led/issi/is31fl3737.h`. The `driver` is the index of the driver you defined in your `config.h` (Only `0`, `1`, `2`, or `3` for now).
|
||||
|
||||
---
|
||||
### IS31FLCOMMON :id=is31flcommon
|
||||
|
@ -386,7 +386,7 @@ const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT] = {
|
|||
* | | G location
|
||||
* | | | B location
|
||||
* | | | | */
|
||||
{0, CS1_SW1, CS2_SW1, CS3_SW1},
|
||||
{0, SW1_CS1, SW1_CS2, SW1_CS3},
|
||||
....
|
||||
}
|
||||
```
|
||||
|
@ -501,7 +501,7 @@ Here is an example using 2 drivers.
|
|||
Define these arrays listing all the LEDs in your `<keyboard>.c`:
|
||||
|
||||
```c
|
||||
const aw20216s_led_t PROGMEM g_aw20216s_leds[RGB_MATRIX_LED_COUNT] = {
|
||||
const aw20216s_led_t PROGMEM g_aw20216s_leds[AW20216S_LED_COUNT] = {
|
||||
/* Each AW20216S channel is controlled by a register at some offset between 0x00
|
||||
* and 0xD7 inclusive.
|
||||
* See drivers/led/aw20216s.h for the mapping between register offsets and
|
||||
|
@ -511,16 +511,16 @@ const aw20216s_led_t PROGMEM g_aw20216s_leds[RGB_MATRIX_LED_COUNT] = {
|
|||
* | | G location
|
||||
* | | | B location
|
||||
* | | | | */
|
||||
{ 0, CS1_SW1, CS2_SW1, CS3_SW1 },
|
||||
{ 0, CS4_SW1, CS5_SW1, CS6_SW1 },
|
||||
{ 0, CS7_SW1, CS8_SW1, CS9_SW1 },
|
||||
{ 0, CS10_SW1, CS11_SW1, CS12_SW1 },
|
||||
{ 0, CS13_SW1, CS14_SW1, CS15_SW1 },
|
||||
{ 0, SW1_CS1, SW1_CS2, SW1_CS3 },
|
||||
{ 0, SW1_CS4, SW1_CS5, SW1_CS6 },
|
||||
{ 0, SW1_CS7, SW1_CS8, SW1_CS9 },
|
||||
{ 0, SW1_CS10, SW1_CS11, SW1_CS12 },
|
||||
{ 0, SW1_CS13, SW1_CS14, SW1_CS15 },
|
||||
...
|
||||
{ 1, CS1_SW1, CS2_SW1, CS3_SW1 },
|
||||
{ 1, CS13_SW1, CS14_SW1, CS15_SW1 },
|
||||
{ 1, CS16_SW1, CS17_SW1, CS18_SW1 },
|
||||
{ 1, CS4_SW2, CS5_SW2, CS6_SW2 },
|
||||
{ 1, SW1_CS1, SW1_CS2, SW1_CS3 },
|
||||
{ 1, SW1_CS13, SW1_CS14, SW1_CS15 },
|
||||
{ 1, SW1_CS16, SW1_CS17, SW1_CS18 },
|
||||
{ 1, SW2_CS4, SW2_CS5, SW2_CS6 },
|
||||
...
|
||||
};
|
||||
```
|
||||
|
@ -869,16 +869,17 @@ These are defined in [`color.h`](https://github.com/qmk/qmk_firmware/blob/master
|
|||
```c
|
||||
#define RGB_MATRIX_KEYRELEASES // reactive effects respond to keyreleases (instead of keypresses)
|
||||
#define RGB_MATRIX_TIMEOUT 0 // number of milliseconds to wait until rgb automatically turns off
|
||||
#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
|
||||
#define RGB_MATRIX_SLEEP // turn off effects when suspended
|
||||
#define RGB_MATRIX_LED_PROCESS_LIMIT (RGB_MATRIX_LED_COUNT + 4) / 5 // limits the number of LEDs to process in an animation per task run (increases keyboard responsiveness)
|
||||
#define RGB_MATRIX_LED_FLUSH_LIMIT 16 // limits in milliseconds how frequently an animation will update the LEDs. 16 (16ms) is equivalent to limiting to 60fps (increases keyboard responsiveness)
|
||||
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
|
||||
#define RGB_MATRIX_DEFAULT_ON true // Sets the default enabled state, if none has been set
|
||||
#define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT // Sets the default mode, if none has been set
|
||||
#define RGB_MATRIX_DEFAULT_HUE 0 // Sets the default hue value, if none has been set
|
||||
#define RGB_MATRIX_DEFAULT_SAT 255 // Sets the default saturation value, if none has been set
|
||||
#define RGB_MATRIX_DEFAULT_ON true // Sets the default enabled state, if none has been set
|
||||
#define RGB_MATRIX_DEFAULT_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS // Sets the default brightness value, if none has been set
|
||||
#define RGB_MATRIX_DEFAULT_SPD 127 // Sets the default animation speed, if none has been set
|
||||
#define RGB_MATRIX_DEFAULT_FLAGS LED_FLAG_ALL // Sets the default LED flags, if none has been set
|
||||
#define RGB_MATRIX_DISABLE_KEYCODES // disables control of rgb matrix by keycodes (must use code functions to control the feature)
|
||||
#define RGB_MATRIX_SPLIT { X, Y } // (Optional) For split keyboards, the number of LEDs connected on each half. X = left, Y = Right.
|
||||
// If reactive effects are enabled, you also will want to enable SPLIT_TRANSPORT_MIRROR
|
||||
|
|
|
@ -33,13 +33,13 @@ RGBLIGHT_DRIVER = apa102
|
|||
|
||||
At minimum you must define the data pin your LED strip is connected to, and the number of LEDs in the strip, in your `config.h`. For APA102 LEDs, you must also define the clock pin. If your keyboard has onboard RGB LEDs, and you are simply creating a keymap, you usually won't need to modify these.
|
||||
|
||||
|Define |Description |
|
||||
|---------------|-------------------------------------------------------------------------|
|
||||
|`WS2812_DI_PIN`|The pin connected to the data pin of the LEDs (WS2812) |
|
||||
|`APA102_DI_PIN`|The pin connected to the data pin of the LEDs (APA102) |
|
||||
|`APA102_CI_PIN`|The pin connected to the clock pin of the LEDs (APA102) |
|
||||
|`RGBLED_NUM` |The number of LEDs connected |
|
||||
|`RGBLED_SPLIT` |(Optional) For split keyboards, the number of LEDs connected on each half|
|
||||
|Define |Description |
|
||||
|--------------------|-------------------------------------------------------------------------|
|
||||
|`WS2812_DI_PIN` |The pin connected to the data pin of the LEDs (WS2812) |
|
||||
|`APA102_DI_PIN` |The pin connected to the data pin of the LEDs (APA102) |
|
||||
|`APA102_CI_PIN` |The pin connected to the clock pin of the LEDs (APA102) |
|
||||
|`RGBLIGHT_LED_COUNT`|The number of LEDs connected |
|
||||
|`RGBLED_SPLIT` |(Optional) For split keyboards, the number of LEDs connected on each half|
|
||||
|
||||
Then you should be able to use the keycodes below to change the RGB lighting to your liking.
|
||||
|
||||
|
@ -152,28 +152,28 @@ Use these defines to add or remove animations from the firmware. When you are ru
|
|||
|
||||
The following options are used to tweak the various animations:
|
||||
|
||||
|Define |Default |Description |
|
||||
|------------------------------------|-------------|-----------------------------------------------------------------------------------------------|
|
||||
|`RGBLIGHT_EFFECT_BREATHE_CENTER` |*Not defined*|If defined, used to calculate the curve for the breathing animation. Valid values are 1.0 to 2.7 |
|
||||
|`RGBLIGHT_EFFECT_BREATHE_MAX` |`255` |The maximum brightness for the breathing mode. Valid values are 1 to 255 |
|
||||
|`RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL`|`40` |How long (in milliseconds) to wait between animation steps for the "Christmas" animation |
|
||||
|`RGBLIGHT_EFFECT_CHRISTMAS_STEP` |`2` |The number of LEDs to group the red/green colors by for the "Christmas" animation |
|
||||
|`RGBLIGHT_EFFECT_KNIGHT_LED_NUM` |`RGBLED_NUM` |The number of LEDs to have the "Knight" animation travel |
|
||||
|`RGBLIGHT_EFFECT_KNIGHT_LENGTH` |`3` |The number of LEDs to light up for the "Knight" animation |
|
||||
|`RGBLIGHT_EFFECT_KNIGHT_OFFSET` |`0` |The number of LEDs to start the "Knight" animation from the start of the strip by |
|
||||
|`RGBLIGHT_RAINBOW_SWIRL_RANGE` |`255` |Range adjustment for the rainbow swirl effect to get different swirls |
|
||||
|`RGBLIGHT_EFFECT_SNAKE_LENGTH` |`4` |The number of LEDs to light up for the "Snake" animation |
|
||||
|`RGBLIGHT_EFFECT_TWINKLE_LIFE` |`200` |Adjusts how quickly each LED brightens and dims when twinkling (in animation steps) |
|
||||
|`RGBLIGHT_EFFECT_TWINKLE_PROBABILITY`|`1/127` |Adjusts how likely each LED is to twinkle (on each animation step) |
|
||||
|Define |Default |Description |
|
||||
|------------------------------------|--------------------|-----------------------------------------------------------------------------------------------|
|
||||
|`RGBLIGHT_EFFECT_BREATHE_CENTER` |*Not defined* |If defined, used to calculate the curve for the breathing animation. Valid values are 1.0 to 2.7 |
|
||||
|`RGBLIGHT_EFFECT_BREATHE_MAX` |`255` |The maximum brightness for the breathing mode. Valid values are 1 to 255 |
|
||||
|`RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL`|`40` |How long (in milliseconds) to wait between animation steps for the "Christmas" animation |
|
||||
|`RGBLIGHT_EFFECT_CHRISTMAS_STEP` |`2` |The number of LEDs to group the red/green colors by for the "Christmas" animation |
|
||||
|`RGBLIGHT_EFFECT_KNIGHT_LED_NUM` |`RGBLIGHT_LED_COUNT`|The number of LEDs to have the "Knight" animation travel |
|
||||
|`RGBLIGHT_EFFECT_KNIGHT_LENGTH` |`3` |The number of LEDs to light up for the "Knight" animation |
|
||||
|`RGBLIGHT_EFFECT_KNIGHT_OFFSET` |`0` |The number of LEDs to start the "Knight" animation from the start of the strip by |
|
||||
|`RGBLIGHT_RAINBOW_SWIRL_RANGE` |`255` |Range adjustment for the rainbow swirl effect to get different swirls |
|
||||
|`RGBLIGHT_EFFECT_SNAKE_LENGTH` |`4` |The number of LEDs to light up for the "Snake" animation |
|
||||
|`RGBLIGHT_EFFECT_TWINKLE_LIFE` |`200` |Adjusts how quickly each LED brightens and dims when twinkling (in animation steps) |
|
||||
|`RGBLIGHT_EFFECT_TWINKLE_PROBABILITY`|`1/127` |Adjusts how likely each LED is to twinkle (on each animation step) |
|
||||
|
||||
### Example Usage to Reduce Memory Footprint
|
||||
1. Use `#undef` to selectively disable animations. The following would disable two animations and save about 4KiB:
|
||||
|
||||
```diff
|
||||
#undef RGBLED_NUM
|
||||
#undef RGBLIGHT_LED_COUNT
|
||||
+#undef RGBLIGHT_EFFECT_STATIC_GRADIENT
|
||||
+#undef RGBLIGHT_EFFECT_RAINBOW_SWIRL
|
||||
#define RGBLED_NUM 12
|
||||
#define RGBLIGHT_LED_COUNT 12
|
||||
#define RGBLIGHT_HUE_STEP 8
|
||||
#define RGBLIGHT_SAT_STEP 8
|
||||
```
|
||||
|
@ -386,10 +386,10 @@ rgblight_set(); // Utility functions do not call rgblight_set() automatically, s
|
|||
#### direct operation
|
||||
|Function |Description |
|
||||
|--------------------------------------------|-------------|
|
||||
|`rgblight_setrgb_at(r, g, b, index)` |Set a single LED to the given RGB value, where `r`/`g`/`b` are between 0 and 255 and `index` is between 0 and `RGBLED_NUM` (not written to EEPROM) |
|
||||
|`rgblight_sethsv_at(h, s, v, index)` |Set a single LED to the given HSV value, where `h`/`s`/`v` are between 0 and 255, and `index` is between 0 and `RGBLED_NUM` (not written to EEPROM) |
|
||||
|`rgblight_setrgb_range(r, g, b, start, end)`|Set a continuous range of LEDs to the given RGB value, where `r`/`g`/`b` are between 0 and 255 and `start`(included) and `stop`(excluded) are between 0 and `RGBLED_NUM` (not written to EEPROM)|
|
||||
|`rgblight_sethsv_range(h, s, v, start, end)`|Set a continuous range of LEDs to the given HSV value, where `h`/`s`/`v` are between 0 and 255, and `start`(included) and `stop`(excluded) are between 0 and `RGBLED_NUM` (not written to EEPROM)|
|
||||
|`rgblight_setrgb_at(r, g, b, index)` |Set a single LED to the given RGB value, where `r`/`g`/`b` are between 0 and 255 and `index` is between 0 and `RGBLIGHT_LED_COUNT` (not written to EEPROM) |
|
||||
|`rgblight_sethsv_at(h, s, v, index)` |Set a single LED to the given HSV value, where `h`/`s`/`v` are between 0 and 255, and `index` is between 0 and `RGBLIGHT_LED_COUNT` (not written to EEPROM) |
|
||||
|`rgblight_setrgb_range(r, g, b, start, end)`|Set a continuous range of LEDs to the given RGB value, where `r`/`g`/`b` are between 0 and 255 and `start`(included) and `stop`(excluded) are between 0 and `RGBLIGHT_LED_COUNT` (not written to EEPROM)|
|
||||
|`rgblight_sethsv_range(h, s, v, start, end)`|Set a continuous range of LEDs to the given HSV value, where `h`/`s`/`v` are between 0 and 255, and `start`(included) and `stop`(excluded) are between 0 and `RGBLIGHT_LED_COUNT` (not written to EEPROM)|
|
||||
|`rgblight_setrgb(r, g, b)` |Set effect range LEDs to the given RGB value where `r`/`g`/`b` are between 0 and 255 (not written to EEPROM) |
|
||||
|`rgblight_setrgb_master(r, g, b)` |Set the LEDs on the master side to the given RGB value, where `r`/`g`/`b` are between 0 and 255 (not written to EEPROM) |
|
||||
|`rgblight_setrgb_slave(r, g, b)` |Set the LEDs on the slave side to the given RGB value, where `r`/`g`/`b` are between 0 and 255 (not written to EEPROM) |
|
||||
|
@ -519,7 +519,7 @@ By defining `RGBLIGHT_LED_MAP` as in the example below, you can specify the LED
|
|||
```c
|
||||
// config.h
|
||||
|
||||
#define RGBLED_NUM 4
|
||||
#define RGBLIGHT_LED_COUNT 4
|
||||
#define RGBLIGHT_LED_MAP { 3, 2, 1, 0 }
|
||||
|
||||
```
|
||||
|
@ -541,7 +541,7 @@ In addition to setting the Clipping Range, you can use `RGBLIGHT_LED_MAP` togeth
|
|||
|
||||
```c
|
||||
// config.h
|
||||
#define RGBLED_NUM 8
|
||||
#define RGBLIGHT_LED_COUNT 8
|
||||
#define RGBLIGHT_LED_MAP { 7, 6, 5, 4, 3, 2, 1, 0 }
|
||||
|
||||
// some source
|
||||
|
|
|
@ -119,12 +119,12 @@ You can configure the firmware to read key matrix pins on the controller to dete
|
|||
|
||||
The first pin is the output pin and the second is the input pin.
|
||||
|
||||
Some keyboards have unused intersections in the key matrix. This setting uses one of these unused intersections to determine the handness.
|
||||
Some keyboards have unused intersections in the key matrix. This setting uses one of these unused intersections to determine the handedness.
|
||||
|
||||
Normally, when a diode is connected to an intersection, it is judged to be left. If you add the following definition, it will be judged to be right.
|
||||
Normally, when a diode is connected to an intersection, it is judged to be right. If you add the following definition, it will be judged to be left.
|
||||
|
||||
```c
|
||||
#define SPLIT_HAND_MATRIX_GRID_LOW_IS_RIGHT
|
||||
#define SPLIT_HAND_MATRIX_GRID_LOW_IS_LEFT
|
||||
```
|
||||
|
||||
Note that adding a diode at a previously unused intersection will effectively tell the firmware that there is a key held down at that point. You can instruct qmk to ignore that intersection by defining `MATRIX_MASKED` and then defining a `matrix_row_t matrix_mask[MATRIX_ROWS]` array in your keyboard config. Each bit of a single value (starting form the least-significant bit) is used to tell qmk whether or not to pay attention to key presses at that intersection.
|
||||
|
|
|
@ -173,7 +173,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|||
|
||||
switch (keycode) {
|
||||
case TD(CT_CLN): // list all tap dance keycodes with tap-hold configurations
|
||||
action = &tap_dance_actions[TD_INDEX(keycode)];
|
||||
action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(keycode)];
|
||||
if (!record->event.pressed && action->state.count && !action->state.finished) {
|
||||
tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data;
|
||||
tap_code16(tap_hold->tap);
|
||||
|
|
|
@ -2,29 +2,29 @@
|
|||
|
||||
QMK has a GPIO control abstraction layer which is microcontroller agnostic. This is done to allow easy access to pin control across different platforms.
|
||||
|
||||
## Functions :id=functions
|
||||
## Macros :id=macros
|
||||
|
||||
The following functions provide basic control of GPIOs and are found in `platforms/<platform>/gpio.h`.
|
||||
The following macros provide basic control of GPIOs and are found in `platforms/<platform>/gpio.h`.
|
||||
|
||||
| Function | Description | Old AVR Examples | Old ChibiOS/ARM Examples |
|
||||
|------------------------------|-----------------------------------------------------|-------------------------------------------------|--------------------------------------------------|
|
||||
| `setPinInput(pin)` | Set pin as input with high impedance (High-Z) | `DDRB &= ~(1<<2)` | `palSetLineMode(pin, PAL_MODE_INPUT)` |
|
||||
| `setPinInputHigh(pin)` | Set pin as input with builtin pull-up resistor | `DDRB &= ~(1<<2); PORTB \|= (1<<2)` | `palSetLineMode(pin, PAL_MODE_INPUT_PULLUP)` |
|
||||
| `setPinInputLow(pin)` | Set pin as input with builtin pull-down resistor | N/A (Not supported on AVR) | `palSetLineMode(pin, PAL_MODE_INPUT_PULLDOWN)` |
|
||||
| `setPinOutput(pin)` | Set pin as output (alias of `setPinOutputPushPull`) | `DDRB \|= (1<<2)` | `palSetLineMode(pin, PAL_MODE_OUTPUT_PUSHPULL)` |
|
||||
| `setPinOutputPushPull(pin)` | Set pin as output, push/pull mode | `DDRB \|= (1<<2)` | `palSetLineMode(pin, PAL_MODE_OUTPUT_PUSHPULL)` |
|
||||
| `setPinOutputOpenDrain(pin)` | Set pin as output, open-drain mode | N/A (Not implemented on AVR) | `palSetLineMode(pin, PAL_MODE_OUTPUT_OPENDRAIN)` |
|
||||
| `writePinHigh(pin)` | Set pin level as high, assuming it is an output | `PORTB \|= (1<<2)` | `palSetLine(pin)` |
|
||||
| `writePinLow(pin)` | Set pin level as low, assuming it is an output | `PORTB &= ~(1<<2)` | `palClearLine(pin)` |
|
||||
| `writePin(pin, level)` | Set pin level, assuming it is an output | `(level) ? PORTB \|= (1<<2) : PORTB &= ~(1<<2)` | `(level) ? palSetLine(pin) : palClearLine(pin)` |
|
||||
| `readPin(pin)` | Returns the level of the pin | `_SFR_IO8(pin >> 4) & _BV(pin & 0xF)` | `palReadLine(pin)` |
|
||||
| `togglePin(pin)` | Invert pin level, assuming it is an output | `PORTB ^= (1<<2)` | `palToggleLine(pin)` |
|
||||
|Macro |Description |
|
||||
|-------------------------------------|---------------------------------------------------------------------|
|
||||
|`gpio_set_pin_input(pin)` |Set pin as input with high impedance (High-Z) |
|
||||
|`gpio_set_pin_input_high(pin)` |Set pin as input with builtin pull-up resistor |
|
||||
|`gpio_set_pin_input_low(pin)` |Set pin as input with builtin pull-down resistor (unavailable on AVR)|
|
||||
|`gpio_set_pin_output(pin)` |Set pin as output (alias of `gpio_set_pin_output_push_pull`) |
|
||||
|`gpio_set_pin_output_push_pull(pin)` |Set pin as output, push/pull mode |
|
||||
|`gpio_set_pin_output_open_drain(pin)`|Set pin as output, open-drain mode (unavailable on AVR and ATSAM) |
|
||||
|`gpio_write_pin_high(pin)` |Set pin level as high, assuming it is an output |
|
||||
|`gpio_write_pin_low(pin)` |Set pin level as low, assuming it is an output |
|
||||
|`gpio_write_pin(pin, level)` |Set pin level, assuming it is an output |
|
||||
|`gpio_read_pin(pin)` |Returns the level of the pin |
|
||||
|`gpio_toggle_pin(pin)` |Invert pin level, assuming it is an output |
|
||||
|
||||
## Advanced Settings :id=advanced-settings
|
||||
|
||||
Each microcontroller can have multiple advanced settings regarding its GPIO. This abstraction layer does not limit the use of architecture-specific functions. Advanced users should consult the datasheet of their desired device and include any needed libraries. For AVR, the standard avr/io.h library is used; for STM32, the ChibiOS [PAL library](https://chibios.sourceforge.net/docs3/hal/group___p_a_l.html) is used.
|
||||
Each microcontroller can have multiple advanced settings regarding its GPIO. This abstraction layer does not limit the use of architecture-specific functions. Advanced users should consult the datasheet of their desired device. For AVR, the standard `avr/io.h` library is used; for STM32, the ChibiOS [PAL library](https://chibios.sourceforge.net/docs3/hal/group___p_a_l.html) is used.
|
||||
|
||||
## Atomic Operation
|
||||
## Atomic Operation :id=atomic-operation
|
||||
|
||||
The above functions are not always guaranteed to work atomically. Therefore, if you want to prevent interruptions in the middle of operations when using multiple combinations of the above functions, use the following `ATOMIC_BLOCK_FORCEON` macro.
|
||||
|
||||
|
|
|
@ -169,11 +169,11 @@ The `post_rules.mk` file can interpret `features` of a keyboard-level before `co
|
|||
|
||||
ifeq ($(strip $(RGBLED_OPTION_TYPE)),backlight)
|
||||
RGBLIGHT_ENABLE = yes
|
||||
OPT_DEFS += -DRGBLED_NUM=30
|
||||
OPT_DEFS += -DRGBLIGHT_LED_COUNT=30
|
||||
endif
|
||||
ifeq ($(strip $(RGBLED_OPTION_TYPE)),underglow)
|
||||
RGBLIGHT_ENABLE = yes
|
||||
OPT_DEFS += -DRGBLED_NUM=6
|
||||
OPT_DEFS += -DRGBLIGHT_LED_COUNT=6
|
||||
endif
|
||||
```
|
||||
|
||||
|
|
|
@ -127,8 +127,8 @@ This function is weakly defined, meaning it can be overridden if necessary for y
|
|||
|
||||
```c
|
||||
void i2c_init(void) {
|
||||
setPinInput(B6); // Try releasing special pins for a short time
|
||||
setPinInput(B7);
|
||||
gpio_set_pin_input(B6); // Try releasing special pins for a short time
|
||||
gpio_set_pin_input(B7);
|
||||
wait_ms(10); // Wait for the release to happen
|
||||
|
||||
palSetPadMode(GPIOB, 6, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP); // Set B6 to I2C function
|
||||
|
@ -138,23 +138,6 @@ void i2c_init(void) {
|
|||
|
||||
---
|
||||
|
||||
### `i2c_status_t i2c_start(uint8_t address, uint16_t timeout)` :id=api-i2c-start
|
||||
|
||||
Start an I2C transaction.
|
||||
|
||||
#### Arguments :id=api-i2c-start-arguments
|
||||
|
||||
- `uint8_t address`
|
||||
The 7-bit I2C address of the device (ie. without the read/write bit - this will be set automatically).
|
||||
- `uint16_t timeout`
|
||||
The time in milliseconds to wait for a response from the target device.
|
||||
|
||||
#### Return Value :id=api-i2c-start-return
|
||||
|
||||
`I2C_STATUS_TIMEOUT` if the timeout period elapses, `I2C_STATUS_ERROR` if some other error occurs, otherwise `I2C_STATUS_SUCCESS`.
|
||||
|
||||
---
|
||||
|
||||
### `i2c_status_t i2c_transmit(uint8_t address, uint8_t *data, uint16_t length, uint16_t timeout)` :id=api-i2c-transmit
|
||||
|
||||
Send multiple bytes to the selected I2C device.
|
||||
|
@ -197,11 +180,11 @@ Receive multiple bytes from the selected I2C device.
|
|||
|
||||
---
|
||||
|
||||
### `i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)` :id=api-i2c-writereg
|
||||
### `i2c_status_t i2c_write_register(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)` :id=api-i2c-write-register
|
||||
|
||||
Writes to a register with an 8-bit address on the I2C device.
|
||||
|
||||
#### Arguments :id=api-i2c-writereg-arguments
|
||||
#### Arguments :id=api-i2c-write-register-arguments
|
||||
|
||||
- `uint8_t devaddr`
|
||||
The 7-bit I2C address of the device.
|
||||
|
@ -214,17 +197,17 @@ Writes to a register with an 8-bit address on the I2C device.
|
|||
- `uint16_t timeout`
|
||||
The time in milliseconds to wait for a response from the target device.
|
||||
|
||||
#### Return Value :id=api-i2c-writereg-return
|
||||
#### Return Value :id=api-i2c-write-register-return
|
||||
|
||||
`I2C_STATUS_TIMEOUT` if the timeout period elapses, `I2C_STATUS_ERROR` if some other error occurs, otherwise `I2C_STATUS_SUCCESS`.
|
||||
|
||||
---
|
||||
|
||||
### `i2c_status_t i2c_writeReg16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)` :id=api-i2c-writereg16
|
||||
### `i2c_status_t i2c_write_register16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)` :id=api-i2c-write-register16
|
||||
|
||||
Writes to a register with a 16-bit address (big endian) on the I2C device.
|
||||
|
||||
#### Arguments :id=api-i2c-writereg16-arguments
|
||||
#### Arguments :id=api-i2c-write-register16-arguments
|
||||
|
||||
- `uint8_t devaddr`
|
||||
The 7-bit I2C address of the device.
|
||||
|
@ -237,17 +220,17 @@ Writes to a register with a 16-bit address (big endian) on the I2C device.
|
|||
- `uint16_t timeout`
|
||||
The time in milliseconds to wait for a response from the target device.
|
||||
|
||||
#### Return Value :id=api-i2c-writereg16-return
|
||||
#### Return Value :id=api-i2c-write-register16-return
|
||||
|
||||
`I2C_STATUS_TIMEOUT` if the timeout period elapses, `I2C_STATUS_ERROR` if some other error occurs, otherwise `I2C_STATUS_SUCCESS`.
|
||||
|
||||
---
|
||||
|
||||
### `i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)` :id=api-i2c-readreg
|
||||
### `i2c_status_t i2c_read_register(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)` :id=api-i2c-read-register
|
||||
|
||||
Reads from a register with an 8-bit address on the I2C device.
|
||||
|
||||
#### Arguments :id=api-i2c-readreg-arguments
|
||||
#### Arguments :id=api-i2c-read-register-arguments
|
||||
|
||||
- `uint8_t devaddr`
|
||||
The 7-bit I2C address of the device.
|
||||
|
@ -258,17 +241,17 @@ Reads from a register with an 8-bit address on the I2C device.
|
|||
- `uint16_t timeout`
|
||||
The time in milliseconds to wait for a response from the target device.
|
||||
|
||||
#### Return Value :id=api-i2c-readreg-return
|
||||
#### Return Value :id=api-i2c-read-register-return
|
||||
|
||||
`I2C_STATUS_TIMEOUT` if the timeout period elapses, `I2C_STATUS_ERROR` if some other error occurs, otherwise `I2C_STATUS_SUCCESS`.
|
||||
|
||||
---
|
||||
|
||||
### `i2c_status_t i2c_readReg16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)`
|
||||
### `i2c_status_t i2c_read_register16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)` :id=api-i2c-read-register16
|
||||
|
||||
Reads from a register with a 16-bit address (big endian) on the I2C device.
|
||||
|
||||
#### Arguments :id=api-i2c-readreg16-arguments
|
||||
#### Arguments :id=api-i2c-read-register16-arguments
|
||||
|
||||
- `uint8_t devaddr`
|
||||
The 7-bit I2C address of the device.
|
||||
|
@ -279,12 +262,27 @@ Reads from a register with a 16-bit address (big endian) on the I2C device.
|
|||
- `uint16_t timeout`
|
||||
The time in milliseconds to wait for a response from the target device.
|
||||
|
||||
#### Return Value :id=api-i2c-readreg16-return
|
||||
#### Return Value :id=api-i2c-read-register16-return
|
||||
|
||||
`I2C_STATUS_TIMEOUT` if the timeout period elapses, `I2C_STATUS_ERROR` if some other error occurs, otherwise `I2C_STATUS_SUCCESS`.
|
||||
|
||||
---
|
||||
|
||||
### `i2c_status_t i2c_stop(void)` :id=api-i2c-stop
|
||||
### `i2c_status_t i2c_ping_address(uint8_t address, uint16_t timeout)` :id=api-i2c-ping-address
|
||||
|
||||
Stop the current I2C transaction.
|
||||
Pings the I2C bus for a specific address.
|
||||
|
||||
On ChibiOS a "best effort" attempt is made by reading a single byte from register 0 at the requested address. This should generally work except for I2C devices that do not not respond to a register 0 read request, which will result in a false negative result (unsucessful response to ping attempt).
|
||||
|
||||
This function is weakly defined, meaning it can be overridden if necessary for your particular use case:
|
||||
|
||||
#### Arguments
|
||||
|
||||
- `uint8_t address`
|
||||
The 7-bit I2C address of the device (ie. without the read/write bit - this will be set automatically).
|
||||
- `uint16_t timeout`
|
||||
The time in milliseconds to wait for a response from the target device.
|
||||
|
||||
#### Return Value
|
||||
|
||||
`I2C_STATUS_TIMEOUT` if the timeout period elapses, `I2C_STATUS_ERROR` if some other error occurs, otherwise `I2C_STATUS_SUCCESS`.
|
||||
|
|
|
@ -248,7 +248,7 @@ QMK での全ての利用可能な設定にはデフォルトがあります。
|
|||
* high/low ピンを使って左右を決定します。low = 右手、high = 左手。`B7` を使っているピンに置き換えます。これはオプションで、`SPLIT_HAND_PIN` が未定義のままである場合、EE_HANDS メソッドまたは標準の Let's Splitが使っている MASTER_LEFT / MASTER_RIGHT 定義をまだ使うことができます。
|
||||
|
||||
* `#define SPLIT_HAND_MATRIX_GRID <out_pin>,<in_pin>`
|
||||
* 左右はキーマトリックスのキースイッチが存在しない交点を使って決定されます。通常、この交点が短絡している(ローレベル)のときに左側と見なされます。もし `#define SPLIT_HAND_MATRIX_GRID_LOW_IS_RIGHT` が定義されている場合は、ローレベルの時に右側と決定されます。
|
||||
* 左右はキーマトリックスのキースイッチが存在しない交点を使って決定されます。通常、この交点が短絡している(ローレベル)のときに右側と見なされます。もし `#define SPLIT_HAND_MATRIX_GRID_LOW_IS_LEFT` が定義されている場合は、ローレベルの時に左側と決定されます。
|
||||
|
||||
* `#define EE_HANDS` (`SPLIT_HAND_PIN` と `SPLIT_HAND_MATRIX_GRID` が定義されていない場合のみ動作します)
|
||||
* `eeprom-lefthand.eep`/`eeprom-righthand.eep` がそれぞれの半分に書き込まれた後で、EEPROM 内に格納されている左右の設定の値を読み込みます。
|
||||
|
|
|
@ -139,8 +139,8 @@ BOOTMAGIC_ENABLE = lite
|
|||
さらに、どのキーを使うかを指定したほうが良いかもしれません。これは普通ではないマトリックスを持つキーボードで特に便利です。そのためには、使いたいキーの行と列を指定する必要があります。`config.h` ファイルにこれらのエントリを追加します:
|
||||
|
||||
```c
|
||||
#define BOOTMAGIC_LITE_ROW 0
|
||||
#define BOOTMAGIC_LITE_COLUMN 1
|
||||
#define BOOTMAGIC_ROW 0
|
||||
#define BOOTMAGIC_COLUMN 1
|
||||
```
|
||||
|
||||
デフォルトでは、これらは 0 と 0 に設定されます。これは通常はほとんどのキーボードで "ESC" キーです。
|
||||
|
@ -154,8 +154,8 @@ BOOTMAGIC_ENABLE = lite
|
|||
`SPLIT_HAND_PIN` のようなオプションで、左右の設定があらかじめ決められている場合は、キーボードの左右で別のキーを設定する必要があるかもしれません。これを行うには、`config.h` ファイルに以下のエントリを追加します。
|
||||
|
||||
```c
|
||||
#define BOOTMAGIC_LITE_ROW_RIGHT 4
|
||||
#define BOOTMAGIC_LITE_COLUMN_RIGHT 1
|
||||
#define BOOTMAGIC_ROW_RIGHT 4
|
||||
#define BOOTMAGIC_COLUMN_RIGHT 1
|
||||
```
|
||||
|
||||
デフォルトでは、これらの値は設定されていません。
|
||||
|
@ -172,7 +172,7 @@ void bootmagic_lite(void) {
|
|||
wait_ms(DEBOUNCE * 2);
|
||||
matrix_scan();
|
||||
|
||||
if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) {
|
||||
if (matrix_get_row(BOOTMAGIC_ROW) & (1 << BOOTMAGIC_COLUMN)) {
|
||||
// ブートローダにジャンプする。
|
||||
bootloader_jump();
|
||||
}
|
||||
|
|
|
@ -108,10 +108,10 @@ SPLIT_TRANSPORT = custom
|
|||
|
||||
キーマトリックスに未使用の交点があるキーボードがあります。この設定は、左右の決定にこれらの未使用の交点の1つを使用します。
|
||||
|
||||
通常、ダイオードが交点に接続されている場合、左側と判断されます。次の定義を追加すると、右側と判断されます。
|
||||
通常、ダイオードが交点に接続されている場合、右側と判断されます。次の定義を追加すると、左側と判断されます。
|
||||
|
||||
```c
|
||||
#define SPLIT_HAND_MATRIX_GRID_LOW_IS_RIGHT
|
||||
#define SPLIT_HAND_MATRIX_GRID_LOW_IS_LEFT
|
||||
```
|
||||
|
||||
#### EEPROM による左右の設定
|
||||
|
|
|
@ -23,12 +23,11 @@ I2C アドレスと他の技術詳細について、さらなる情報を得る
|
|||
| 関数 | 説明 |
|
||||
|-------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `void i2c_init(void);` | I2C ドライバを初期化します。他のあらゆるトランザクションを開始する前に、この関数を一度だけ呼ぶ必要があります。 |
|
||||
| `i2c_status_t i2c_start(uint8_t address, uint16_t timeout);` | I2C トランザクションを開始します。アドレスは方向ビットのない7ビットスレーブアドレスです。 |
|
||||
| `i2c_status_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);` | I2C 経由でデータを送信します。アドレスは方向ビットのない7ビットスレーブアドレスです。トランザクションのステータスを返します。 |
|
||||
| `i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);` | I2C 経由でデータを受信します。アドレスは方向ビットのない7ビットスレーブアドレスです。 `length` で指定した長さのバイト列を `data` に保存し、トランザクションのステータスを返します。 |
|
||||
| `i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout);` | `i2c_transmit` と同様ですが、 `regaddr` でスレーブのデータ書き込み先のレジスタを指定します。 |
|
||||
| `i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout);` | `i2c_receive` と同様ですが、 `regaddr` でスレーブのデータ読み込み先のレジスタを指定します。 |
|
||||
| `i2c_status_t i2c_stop(void);` | I2C トランザクションを終了します。 |
|
||||
| `i2c_status_t i2c_ping_address(uint8_t address, uint16_t timeout);` | I2C アドレスをテストします。アドレスは方向ビットのない7ビットスレーブアドレスです。 |
|
||||
|
||||
### 関数の戻り値 :id=function-return
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
The following table shows the current driver status for peripherals on RP2040 MCUs:
|
||||
|
||||
| System | Support |
|
||||
| System | Support |
|
||||
| ---------------------------------------------------------------- | ---------------------------------------------- |
|
||||
| [ADC driver](adc_driver.md) | :heavy_check_mark: |
|
||||
| [Audio](audio_driver.md#pwm-hardware) | :heavy_check_mark: |
|
||||
|
@ -13,7 +13,7 @@ The following table shows the current driver status for peripherals on RP2040 MC
|
|||
| [External EEPROMs](eeprom_driver.md) | :heavy_check_mark: using `I2C` or `SPI` driver |
|
||||
| [EEPROM emulation](eeprom_driver.md#wear_leveling-configuration) | :heavy_check_mark: |
|
||||
| [serial driver](serial_driver.md) | :heavy_check_mark: using `SIO` or `PIO` driver |
|
||||
| [UART driver](uart_driver.md) | Support planned (no ETA) |
|
||||
| [UART driver](uart_driver.md) | :heavy_check_mark: using `SIO` driver |
|
||||
|
||||
## GPIO
|
||||
|
||||
|
@ -52,6 +52,13 @@ To configure the I2C driver please read the [ChibiOS/ARM](i2c_driver.md#arm-conf
|
|||
|
||||
To configure the SPI driver please read the [ChibiOS/ARM](spi_driver.md#chibiosarm-configuration) section.
|
||||
|
||||
### UART Driver
|
||||
|
||||
| RP2040 Peripheral | `mcuconf.h` values | `UART_DRIVER` |
|
||||
| ----------------- | ------------------ | ------------- |
|
||||
| `UART0` | `RP_SIO_USE_UART0` | `SIOD0` |
|
||||
| `UART1` | `RP_SIO_USE_UART1` | `SIOD1` |
|
||||
|
||||
## Double-tap reset boot-loader entry :id=double-tap
|
||||
|
||||
The double-tap reset mechanism is an alternate way in QMK to enter the embedded mass storage UF2 boot-loader of the RP2040. It enables bootloader entry by a fast double-tap of the reset pin on start up, which is similar to the behavior of AVR Pro Micros. This feature activated by default for the Pro Micro RP2040 board, but has to be configured for other boards. To activate it, add the following options to your keyboards `config.h` file:
|
||||
|
@ -87,6 +94,10 @@ This is the default board that is chosen, unless any other RP2040 board is selec
|
|||
| `SOFT_SERIAL_PIN` | undefined, use `SERIAL_USART_TX_PIN` |
|
||||
| `SERIAL_USART_TX_PIN` | `GP0` |
|
||||
| `SERIAL_USART_RX_PIN` | `GP1` |
|
||||
| **UART driver** | |
|
||||
| `UART_DRIVER` | `SIOD0` |
|
||||
| `UART_TX_PIN` | `GP0` |
|
||||
| `UART_RX_PIN` | `GP1` |
|
||||
|
||||
?> The pin-outs of Adafruit's KB2040 and Boardsource's Blok both deviate from the Sparkfun Pro Micro RP2040. Lookup the pin-out of these boards and adjust your keyboards pin definition accordingly if you want to use these boards.
|
||||
|
||||
|
|
|
@ -19,18 +19,21 @@ The QMK CLI can be used to convert from normal images such as PNG files or anima
|
|||
|
||||
Supported devices:
|
||||
|
||||
| Display Panel | Panel Type | Size | Comms Transport | Driver |
|
||||
|---------------|--------------------|------------------|-----------------|------------------------------------------|
|
||||
| GC9A01 | RGB LCD (circular) | 240x240 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += gc9a01_spi` |
|
||||
| ILI9163 | RGB LCD | 128x128 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += ili9163_spi` |
|
||||
| ILI9341 | RGB LCD | 240x320 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += ili9341_spi` |
|
||||
| ILI9488 | RGB LCD | 320x480 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += ili9488_spi` |
|
||||
| SSD1351 | RGB OLED | 128x128 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += ssd1351_spi` |
|
||||
| ST7735 | RGB LCD | 132x162, 80x160 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += st7735_spi` |
|
||||
| ST7789 | RGB LCD | 240x320, 240x240 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += st7789_spi` |
|
||||
| SH1106 (SPI) | Monochrome OLED | 128x64 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += sh1106_spi` |
|
||||
| SH1106 (I2C) | Monochrome OLED | 128x64 | I2C | `QUANTUM_PAINTER_DRIVERS += sh1106_i2c` |
|
||||
| Surface | Virtual | User-defined | None | `QUANTUM_PAINTER_DRIVERS += surface` |
|
||||
| Display Panel | Panel Type | Size | Comms Transport | Driver |
|
||||
|----------------|--------------------|------------------|-----------------|------------------------------------------|
|
||||
| GC9A01 | RGB LCD (circular) | 240x240 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += gc9a01_spi` |
|
||||
| ILI9163 | RGB LCD | 128x128 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += ili9163_spi` |
|
||||
| ILI9341 | RGB LCD | 240x320 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += ili9341_spi` |
|
||||
| ILI9486 | RGB LCD | 320x480 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += ili9486_spi` |
|
||||
| ILI9488 | RGB LCD | 320x480 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += ili9488_spi` |
|
||||
| SSD1351 | RGB OLED | 128x128 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += ssd1351_spi` |
|
||||
| ST7735 | RGB LCD | 132x162, 80x160 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += st7735_spi` |
|
||||
| ST7789 | RGB LCD | 240x320, 240x240 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += st7789_spi` |
|
||||
| SH1106 (SPI) | Monochrome OLED | 128x64 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += sh1106_spi` |
|
||||
| SH1106 (I2C) | Monochrome OLED | 128x64 | I2C | `QUANTUM_PAINTER_DRIVERS += sh1106_i2c` |
|
||||
| SSD1306 (SPI) | Monochrome OLED | 128x64 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS += sh1106_spi` |
|
||||
| SSD1306 (I2C) | Monochrome OLED | 128x32 | I2C | `QUANTUM_PAINTER_DRIVERS += sh1106_i2c` |
|
||||
| Surface | Virtual | User-defined | None | `QUANTUM_PAINTER_DRIVERS += surface` |
|
||||
|
||||
## Quantum Painter Configuration :id=quantum-painter-config
|
||||
|
||||
|
@ -279,6 +282,39 @@ The maximum number of displays can be configured by changing the following in yo
|
|||
|
||||
Native color format rgb565 is compatible with ILI9341
|
||||
|
||||
#### ** ILI9486 **
|
||||
|
||||
Enabling support for the ILI9486 in Quantum Painter is done by adding the following to `rules.mk`:
|
||||
|
||||
```make
|
||||
QUANTUM_PAINTER_ENABLE = yes
|
||||
QUANTUM_PAINTER_DRIVERS += ili9486_spi
|
||||
```
|
||||
|
||||
Creating a ILI9486 device in firmware can then be done with the following API:
|
||||
|
||||
```c
|
||||
painter_device_t qp_ili9486_make_spi_device(uint16_t panel_width, uint16_t panel_height, pin_t chip_select_pin, pin_t dc_pin, pin_t reset_pin, uint16_t spi_divisor, int spi_mode);
|
||||
```
|
||||
|
||||
There's another variant for this [Waveshare module](https://www.waveshare.com/wiki/3.5inch_TFT_Touch_Shield), because it has a quirky SPI->Parallel converter. You can create it with:
|
||||
|
||||
```c
|
||||
painter_device_t qp_ili9486_make_spi_waveshare_device(uint16_t panel_width, uint16_t panel_height, pin_t chip_select_pin, pin_t dc_pin, pin_t reset_pin, uint16_t spi_divisor, int spi_mode);
|
||||
```
|
||||
|
||||
The device handle returned from these functions can be used to perform all other drawing operations.
|
||||
|
||||
The maximum number of displays can be configured by changing the following in your `config.h` (default is 1):
|
||||
|
||||
```c
|
||||
// 3 displays:
|
||||
#define ILI9486_NUM_DEVICES 3
|
||||
```
|
||||
|
||||
Native color format rgb888 is compatible with ILI9486
|
||||
Native color format rgb565 is compatible with ILI9486 Waveshare
|
||||
|
||||
#### ** ILI9488 **
|
||||
|
||||
Enabling support for the ILI9488 in Quantum Painter is done by adding the following to `rules.mk`:
|
||||
|
@ -433,6 +469,10 @@ The maximum number of displays of each type can be configured by changing the fo
|
|||
|
||||
Native color format mono2 is compatible with SH1106
|
||||
|
||||
#### ** SSD1306 **
|
||||
|
||||
SSD1306 and SH1106 are almost entirely identical, to the point of being indisinguishable by Quantum Painter. Enable SH1106 support in Quantum Painter and create SH1106 devices in firmware to perform drawing operations on SSD1306 displays.
|
||||
|
||||
<!-- tabs:end -->
|
||||
|
||||
### ** Surface **
|
||||
|
|
|
@ -111,6 +111,13 @@ Configures the [APA102](apa102_driver.md) driver.
|
|||
Configures the [Audio](feature_audio.md) feature.
|
||||
|
||||
* `audio`
|
||||
* `default`
|
||||
* `on`
|
||||
* The default audio enabled state.
|
||||
* Default: `true`
|
||||
* `clicky`
|
||||
* The default audio clicky enabled state.
|
||||
* Default: `true`
|
||||
* `macro_beep`
|
||||
* Play a short beep for `\a` (ASCII `BEL`) characters in Send String macros.
|
||||
* Default: `false`
|
||||
|
@ -626,7 +633,7 @@ Configures the [RGB Matrix](feature_rgb_matrix.md) feature.
|
|||
* The default animation speed.
|
||||
* Default: `128`
|
||||
* `driver` (Required)
|
||||
* The driver to use. Must be one of `aw20216s`, `custom`, `is31fl3218`, `is31fl3731`, `is31fl3733`, `is31fl3736`, `is31fl3737`, `is31fl3741`, `is31fl3742a`, `is31fl3743a`, `is31fl3745`, `is31fl3746a`, `snled27351`, `ws2812`.
|
||||
* The driver to use. Must be one of `aw20216s`, `custom`, `is31fl3218`, `is31fl3729`, `is31fl3731`, `is31fl3733`, `is31fl3736`, `is31fl3737`, `is31fl3741`, `is31fl3742a`, `is31fl3743a`, `is31fl3745`, `is31fl3746a`, `snled27351`, `ws2812`.
|
||||
* `hue_steps`
|
||||
* The number of hue adjustment steps.
|
||||
* Default: `8`
|
||||
|
|
|
@ -36,6 +36,7 @@ These headers are located in [`quantum/keymap_extras/`](https://github.com/qmk/q
|
|||
|French (AFNOR) |`keymap_french_afnor.h` |`sendstring_french_afnor.h` |
|
||||
|French (BÉPO) |`keymap_bepo.h` |`sendstring_bepo.h` |
|
||||
|French (Belgium) |`keymap_belgian.h` |`sendstring_belgian.h` |
|
||||
|French (Canada) |`keymap_canadian_french.h` |`sendstring_canadian_french.h` |
|
||||
|French (Switzerland) |`keymap_swiss_fr.h` |`sendstring_swiss_fr.h` |
|
||||
|French (macOS, ISO) |`keymap_french_mac_iso.h` |`sendstring_french_mac_iso.h` |
|
||||
|German |`keymap_german.h` |`sendstring_german.h` |
|
||||
|
@ -67,6 +68,7 @@ These headers are located in [`quantum/keymap_extras/`](https://github.com/qmk/q
|
|||
|Slovenian |`keymap_slovenian.h` |`sendstring_slovenian.h` |
|
||||
|Spanish |`keymap_spanish.h` |`sendstring_spanish.h` |
|
||||
|Spanish (Dvorak) |`keymap_spanish_dvorak.h` |`sendstring_spanish_dvorak.h` |
|
||||
|Spanish (Latin America) |`keymap_spanish_latin_america.h` |`sendstring_spanish_latin_america.h`|
|
||||
|Swedish |`keymap_swedish.h` |`sendstring_swedish.h` |
|
||||
|Swedish (macOS, ANSI) |`keymap_swedish_mac_ansi.h` | |
|
||||
|Swedish (macOS, ISO) |`keymap_swedish_mac_iso.h` | |
|
||||
|
|
|
@ -210,6 +210,7 @@ That said, there are a number of Pro Micro replacements with ARM controllers:
|
|||
* [Elite-Pi](https://keeb.io/products/elite-pi-usb-c-pro-micro-replacement-rp2040)
|
||||
* [0xCB Helios](https://keeb.supply/products/0xcb-helios) ([Open Source](https://github.com/0xCB-dev/0xCB-Helios), DIY/PCBA/Shop)
|
||||
* [Liatris](https://splitkb.com/products/liatris)
|
||||
* [Imera](https://splitkb.com/products/imera)
|
||||
* [Michi](https://github.com/ci-bus/michi-promicro-rp2040)
|
||||
|
||||
There are other, non-Pro Micro compatible boards out there. The most popular being:
|
||||
|
|
|
@ -32,13 +32,7 @@ No special setup is required - just connect the `RX` and `TX` pins of your UART
|
|||
|
||||
You'll need to determine which pins can be used for UART -- as an example, STM32 parts generally have multiple UART peripherals, labeled USART1, USART2, USART3 etc.
|
||||
|
||||
To enable UART, modify your board's `halconf.h` to enable the serial driver:
|
||||
|
||||
```c
|
||||
#define HAL_USE_SERIAL TRUE
|
||||
```
|
||||
|
||||
Then, modify your board's `mcuconf.h` to enable the peripheral you've chosen, for example:
|
||||
To enable UART, modify your board's `mcuconf.h` to enable the peripheral you've chosen, for example:
|
||||
|
||||
```c
|
||||
#undef STM32_SERIAL_USE_USART2
|
||||
|
@ -47,17 +41,17 @@ Then, modify your board's `mcuconf.h` to enable the peripheral you've chosen, fo
|
|||
|
||||
Configuration-wise, you'll need to set up the peripheral as per your MCU's datasheet -- the defaults match the pins for a Proton-C, i.e. STM32F303.
|
||||
|
||||
|`config.h` override |Description |Default Value|
|
||||
|--------------------------|---------------------------------------------------------------|-------------|
|
||||
|`#define SERIAL_DRIVER` |USART peripheral to use - USART1 -> `SD1`, USART2 -> `SD2` etc.|`SD1` |
|
||||
|`#define SD1_TX_PIN` |The pin to use for TX |`A9` |
|
||||
|`#define SD1_TX_PAL_MODE` |The alternate function mode for TX |`7` |
|
||||
|`#define SD1_RX_PIN` |The pin to use for RX |`A10` |
|
||||
|`#define SD1_RX_PAL_MODE` |The alternate function mode for RX |`7` |
|
||||
|`#define SD1_CTS_PIN` |The pin to use for CTS |`A11` |
|
||||
|`#define SD1_CTS_PAL_MODE`|The alternate function mode for CTS |`7` |
|
||||
|`#define SD1_RTS_PIN` |The pin to use for RTS |`A12` |
|
||||
|`#define SD1_RTS_PAL_MODE`|The alternate function mode for RTS |`7` |
|
||||
| `config.h` override | Description | Default Value |
|
||||
| --------------------------- | --------------------------------------------------------------- | ------------- |
|
||||
| `#define UART_DRIVER` | USART peripheral to use - USART1 -> `SD1`, USART2 -> `SD2` etc. | `SD1` |
|
||||
| `#define UART_TX_PIN` | The pin to use for TX | `A9` |
|
||||
| `#define UART_TX_PAL_MODE` | The alternate function mode for TX | `7` |
|
||||
| `#define UART_RX_PIN` | The pin to use for RX | `A10` |
|
||||
| `#define UART_RX_PAL_MODE` | The alternate function mode for RX | `7` |
|
||||
| `#define UART_CTS_PIN` | The pin to use for CTS | `A11` |
|
||||
| `#define UART_CTS_PAL_MODE` | The alternate function mode for CTS | `7` |
|
||||
| `#define UART_RTS_PIN` | The pin to use for RTS | `A12` |
|
||||
| `#define UART_RTS_PAL_MODE` | The alternate function mode for RTS | `7` |
|
||||
|
||||
## API :id=api
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ static bool sdep_recv_pkt(struct sdep_msg *msg, uint16_t timeout) {
|
|||
bool ready = false;
|
||||
|
||||
do {
|
||||
ready = readPin(BLUEFRUIT_LE_IRQ_PIN);
|
||||
ready = gpio_read_pin(BLUEFRUIT_LE_IRQ_PIN);
|
||||
if (ready) {
|
||||
break;
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ static void resp_buf_read_one(bool greedy) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (readPin(BLUEFRUIT_LE_IRQ_PIN)) {
|
||||
if (gpio_read_pin(BLUEFRUIT_LE_IRQ_PIN)) {
|
||||
struct sdep_msg msg;
|
||||
|
||||
again:
|
||||
|
@ -242,7 +242,7 @@ static void resp_buf_read_one(bool greedy) {
|
|||
dprintf("recv latency %dms\n", TIMER_DIFF_16(timer_read(), last_send));
|
||||
}
|
||||
|
||||
if (greedy && resp_buf.peek(last_send) && readPin(BLUEFRUIT_LE_IRQ_PIN)) {
|
||||
if (greedy && resp_buf.peek(last_send) && gpio_read_pin(BLUEFRUIT_LE_IRQ_PIN)) {
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
|
@ -293,16 +293,16 @@ void bluefruit_le_init(void) {
|
|||
state.configured = false;
|
||||
state.is_connected = false;
|
||||
|
||||
setPinInput(BLUEFRUIT_LE_IRQ_PIN);
|
||||
gpio_set_pin_input(BLUEFRUIT_LE_IRQ_PIN);
|
||||
|
||||
spi_init();
|
||||
|
||||
// Perform a hardware reset
|
||||
setPinOutput(BLUEFRUIT_LE_RST_PIN);
|
||||
writePinHigh(BLUEFRUIT_LE_RST_PIN);
|
||||
writePinLow(BLUEFRUIT_LE_RST_PIN);
|
||||
gpio_set_pin_output(BLUEFRUIT_LE_RST_PIN);
|
||||
gpio_write_pin_high(BLUEFRUIT_LE_RST_PIN);
|
||||
gpio_write_pin_low(BLUEFRUIT_LE_RST_PIN);
|
||||
wait_ms(10);
|
||||
writePinHigh(BLUEFRUIT_LE_RST_PIN);
|
||||
gpio_write_pin_high(BLUEFRUIT_LE_RST_PIN);
|
||||
|
||||
wait_ms(1000); // Give it a second to initialize
|
||||
|
||||
|
@ -508,7 +508,7 @@ void bluefruit_le_task(void) {
|
|||
resp_buf_read_one(true);
|
||||
send_buf_send_one(SdepShortTimeout);
|
||||
|
||||
if (resp_buf.empty() && (state.event_flags & UsingEvents) && readPin(BLUEFRUIT_LE_IRQ_PIN)) {
|
||||
if (resp_buf.empty() && (state.event_flags & UsingEvents) && gpio_read_pin(BLUEFRUIT_LE_IRQ_PIN)) {
|
||||
// Must be an event update
|
||||
if (at_command_P(PSTR("AT+EVENTSTATUS"), resbuf, sizeof(resbuf))) {
|
||||
uint32_t mask = strtoul(resbuf, NULL, 16);
|
||||
|
|
|
@ -57,8 +57,8 @@ void eeprom_driver_init(void) {
|
|||
i2c_init();
|
||||
#if defined(EXTERNAL_EEPROM_WP_PIN)
|
||||
/* We are setting the WP pin to high in a way that requires at least two bit-flips to change back to 0 */
|
||||
writePin(EXTERNAL_EEPROM_WP_PIN, 1);
|
||||
setPinInputHigh(EXTERNAL_EEPROM_WP_PIN);
|
||||
gpio_write_pin(EXTERNAL_EEPROM_WP_PIN, 1);
|
||||
gpio_set_pin_input_high(EXTERNAL_EEPROM_WP_PIN);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -100,8 +100,8 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) {
|
|||
uintptr_t target_addr = (uintptr_t)addr;
|
||||
|
||||
#if defined(EXTERNAL_EEPROM_WP_PIN)
|
||||
setPinOutput(EXTERNAL_EEPROM_WP_PIN);
|
||||
writePin(EXTERNAL_EEPROM_WP_PIN, 0);
|
||||
gpio_set_pin_output(EXTERNAL_EEPROM_WP_PIN);
|
||||
gpio_write_pin(EXTERNAL_EEPROM_WP_PIN, 0);
|
||||
#endif
|
||||
|
||||
while (len > 0) {
|
||||
|
@ -134,7 +134,7 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) {
|
|||
|
||||
#if defined(EXTERNAL_EEPROM_WP_PIN)
|
||||
/* We are setting the WP pin to high in a way that requires at least two bit-flips to change back to 0 */
|
||||
writePin(EXTERNAL_EEPROM_WP_PIN, 1);
|
||||
setPinInputHigh(EXTERNAL_EEPROM_WP_PIN);
|
||||
gpio_write_pin(EXTERNAL_EEPROM_WP_PIN, 1);
|
||||
gpio_set_pin_input_high(EXTERNAL_EEPROM_WP_PIN);
|
||||
#endif
|
||||
}
|
||||
|
|
213
drivers/encoder/encoder_quadrature.c
Normal file
213
drivers/encoder/encoder_quadrature.c
Normal file
|
@ -0,0 +1,213 @@
|
|||
// Copyright 2018 Jack Humbert <jack.humb@gmail.com>
|
||||
// Copyright 2018-2023 Nick Brassel (@tzarc)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <stdint.h>
|
||||
#include "encoder.h"
|
||||
#include "gpio.h"
|
||||
#include "keyboard.h"
|
||||
#include "action.h"
|
||||
#include "keycodes.h"
|
||||
#include "wait.h"
|
||||
|
||||
#ifdef SPLIT_KEYBOARD
|
||||
# include "split_util.h"
|
||||
#endif
|
||||
|
||||
// for memcpy
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(ENCODER_RESOLUTIONS) && !defined(ENCODER_RESOLUTION)
|
||||
# define ENCODER_RESOLUTION 4
|
||||
#endif
|
||||
|
||||
#undef ENCODER_DEFAULT_PIN_API_IMPL
|
||||
#if defined(ENCODERS_PAD_A) && defined(ENCODERS_PAD_B)
|
||||
// Inform the quadrature driver that it needs to implement pin init/read functions
|
||||
# define ENCODER_DEFAULT_PIN_API_IMPL
|
||||
#endif
|
||||
|
||||
extern volatile bool isLeftHand;
|
||||
|
||||
__attribute__((weak)) void encoder_quadrature_init_pin(uint8_t index, bool pad_b);
|
||||
__attribute__((weak)) uint8_t encoder_quadrature_read_pin(uint8_t index, bool pad_b);
|
||||
|
||||
#ifdef ENCODER_DEFAULT_PIN_API_IMPL
|
||||
|
||||
static pin_t encoders_pad_a[NUM_ENCODERS_MAX_PER_SIDE] = ENCODERS_PAD_A;
|
||||
static pin_t encoders_pad_b[NUM_ENCODERS_MAX_PER_SIDE] = ENCODERS_PAD_B;
|
||||
|
||||
__attribute__((weak)) void encoder_wait_pullup_charge(void) {
|
||||
wait_us(100);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void encoder_quadrature_init_pin(uint8_t index, bool pad_b) {
|
||||
pin_t pin = pad_b ? encoders_pad_b[index] : encoders_pad_a[index];
|
||||
if (pin != NO_PIN) {
|
||||
gpio_set_pin_input_high(pin);
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((weak)) uint8_t encoder_quadrature_read_pin(uint8_t index, bool pad_b) {
|
||||
pin_t pin = pad_b ? encoders_pad_b[index] : encoders_pad_a[index];
|
||||
if (pin != NO_PIN) {
|
||||
return gpio_read_pin(pin) ? 1 : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // ENCODER_DEFAULT_PIN_API_IMPL
|
||||
|
||||
#ifdef ENCODER_RESOLUTIONS
|
||||
static uint8_t encoder_resolutions[NUM_ENCODERS] = ENCODER_RESOLUTIONS;
|
||||
#endif
|
||||
|
||||
#ifndef ENCODER_DIRECTION_FLIP
|
||||
# define ENCODER_CLOCKWISE true
|
||||
# define ENCODER_COUNTER_CLOCKWISE false
|
||||
#else
|
||||
# define ENCODER_CLOCKWISE false
|
||||
# define ENCODER_COUNTER_CLOCKWISE true
|
||||
#endif
|
||||
static int8_t encoder_LUT[] = {0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0};
|
||||
|
||||
static uint8_t encoder_state[NUM_ENCODERS] = {0};
|
||||
static int8_t encoder_pulses[NUM_ENCODERS] = {0};
|
||||
|
||||
// encoder counts
|
||||
static uint8_t thisCount;
|
||||
#ifdef SPLIT_KEYBOARD
|
||||
// encoder offsets for each hand
|
||||
static uint8_t thisHand, thatHand;
|
||||
// encoder counts for each hand
|
||||
static uint8_t thatCount;
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) void encoder_quadrature_post_init_kb(void) {
|
||||
extern void encoder_quadrature_handle_read(uint8_t index, uint8_t pin_a_state, uint8_t pin_b_state);
|
||||
// Unused normally, but can be used for things like setting up pin-change interrupts in keyboard code.
|
||||
// During the interrupt, read the pins then call `encoder_handle_read()` with the pin states and it'll queue up an encoder event if needed.
|
||||
}
|
||||
|
||||
void encoder_quadrature_post_init(void) {
|
||||
#ifdef ENCODER_DEFAULT_PIN_API_IMPL
|
||||
for (uint8_t i = 0; i < thisCount; i++) {
|
||||
encoder_quadrature_init_pin(i, false);
|
||||
encoder_quadrature_init_pin(i, true);
|
||||
}
|
||||
encoder_wait_pullup_charge();
|
||||
for (uint8_t i = 0; i < thisCount; i++) {
|
||||
encoder_state[i] = (encoder_quadrature_read_pin(i, false) << 0) | (encoder_quadrature_read_pin(i, true) << 1);
|
||||
}
|
||||
#else
|
||||
memset(encoder_state, 0, sizeof(encoder_state));
|
||||
#endif
|
||||
|
||||
encoder_quadrature_post_init_kb();
|
||||
}
|
||||
|
||||
void encoder_driver_init(void) {
|
||||
#ifdef SPLIT_KEYBOARD
|
||||
thisHand = isLeftHand ? 0 : NUM_ENCODERS_LEFT;
|
||||
thatHand = NUM_ENCODERS_LEFT - thisHand;
|
||||
thisCount = isLeftHand ? NUM_ENCODERS_LEFT : NUM_ENCODERS_RIGHT;
|
||||
thatCount = isLeftHand ? NUM_ENCODERS_RIGHT : NUM_ENCODERS_LEFT;
|
||||
#else // SPLIT_KEYBOARD
|
||||
thisCount = NUM_ENCODERS;
|
||||
#endif
|
||||
|
||||
#ifdef ENCODER_TESTS
|
||||
// Annoying that we have to clear out values during initialisation here, but
|
||||
// because all the arrays are static locals, rerunning tests in the same
|
||||
// executable doesn't reset any of these. Kinda crappy having test-only code
|
||||
// here, but it's the simplest solution.
|
||||
memset(encoder_state, 0, sizeof(encoder_state));
|
||||
memset(encoder_pulses, 0, sizeof(encoder_pulses));
|
||||
const pin_t encoders_pad_a_left[] = ENCODERS_PAD_A;
|
||||
const pin_t encoders_pad_b_left[] = ENCODERS_PAD_B;
|
||||
for (uint8_t i = 0; i < thisCount; i++) {
|
||||
encoders_pad_a[i] = encoders_pad_a_left[i];
|
||||
encoders_pad_b[i] = encoders_pad_b_left[i];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SPLIT_KEYBOARD) && defined(ENCODERS_PAD_A_RIGHT) && defined(ENCODERS_PAD_B_RIGHT)
|
||||
// Re-initialise the pads if it's the right-hand side
|
||||
if (!isLeftHand) {
|
||||
const pin_t encoders_pad_a_right[] = ENCODERS_PAD_A_RIGHT;
|
||||
const pin_t encoders_pad_b_right[] = ENCODERS_PAD_B_RIGHT;
|
||||
for (uint8_t i = 0; i < thisCount; i++) {
|
||||
encoders_pad_a[i] = encoders_pad_a_right[i];
|
||||
encoders_pad_b[i] = encoders_pad_b_right[i];
|
||||
}
|
||||
}
|
||||
#endif // defined(SPLIT_KEYBOARD) && defined(ENCODERS_PAD_A_RIGHT) && defined(ENCODERS_PAD_B_RIGHT)
|
||||
|
||||
// Encoder resolutions is defined differently in config.h, so concatenate
|
||||
#if defined(SPLIT_KEYBOARD) && defined(ENCODER_RESOLUTIONS)
|
||||
# if defined(ENCODER_RESOLUTIONS_RIGHT)
|
||||
static const uint8_t encoder_resolutions_right[NUM_ENCODERS_RIGHT] = ENCODER_RESOLUTIONS_RIGHT;
|
||||
# else // defined(ENCODER_RESOLUTIONS_RIGHT)
|
||||
static const uint8_t encoder_resolutions_right[NUM_ENCODERS_RIGHT] = ENCODER_RESOLUTIONS;
|
||||
# endif // defined(ENCODER_RESOLUTIONS_RIGHT)
|
||||
for (uint8_t i = 0; i < NUM_ENCODERS_RIGHT; i++) {
|
||||
encoder_resolutions[NUM_ENCODERS_LEFT + i] = encoder_resolutions_right[i];
|
||||
}
|
||||
#endif // defined(SPLIT_KEYBOARD) && defined(ENCODER_RESOLUTIONS)
|
||||
|
||||
encoder_quadrature_post_init();
|
||||
}
|
||||
|
||||
static void encoder_handle_state_change(uint8_t index, uint8_t state) {
|
||||
uint8_t i = index;
|
||||
|
||||
#ifdef SPLIT_KEYBOARD
|
||||
index += thisHand;
|
||||
#endif
|
||||
|
||||
#ifdef ENCODER_RESOLUTIONS
|
||||
const uint8_t resolution = encoder_resolutions[index];
|
||||
#else
|
||||
const uint8_t resolution = ENCODER_RESOLUTION;
|
||||
#endif
|
||||
|
||||
encoder_pulses[i] += encoder_LUT[state & 0xF];
|
||||
|
||||
#ifdef ENCODER_DEFAULT_POS
|
||||
if ((encoder_pulses[i] >= resolution) || (encoder_pulses[i] <= -resolution) || ((state & 0x3) == ENCODER_DEFAULT_POS)) {
|
||||
if (encoder_pulses[i] >= 1) {
|
||||
#else
|
||||
if (encoder_pulses[i] >= resolution) {
|
||||
#endif
|
||||
|
||||
encoder_queue_event(index, ENCODER_COUNTER_CLOCKWISE);
|
||||
}
|
||||
|
||||
#ifdef ENCODER_DEFAULT_POS
|
||||
if (encoder_pulses[i] <= -1) {
|
||||
#else
|
||||
if (encoder_pulses[i] <= -resolution) { // direction is arbitrary here, but this clockwise
|
||||
#endif
|
||||
encoder_queue_event(index, ENCODER_CLOCKWISE);
|
||||
}
|
||||
encoder_pulses[i] %= resolution;
|
||||
#ifdef ENCODER_DEFAULT_POS
|
||||
encoder_pulses[i] = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void encoder_quadrature_handle_read(uint8_t index, uint8_t pin_a_state, uint8_t pin_b_state) {
|
||||
uint8_t state = pin_a_state | (pin_b_state << 1);
|
||||
if ((encoder_state[index] & 0x3) != state) {
|
||||
encoder_state[index] <<= 2;
|
||||
encoder_state[index] |= state;
|
||||
encoder_handle_state_change(index, encoder_state[index]);
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((weak)) void encoder_driver_task(void) {
|
||||
for (uint8_t i = 0; i < thisCount; i++) {
|
||||
encoder_quadrature_handle_read(i, encoder_quadrature_read_pin(i, false), encoder_quadrature_read_pin(i, true));
|
||||
}
|
||||
}
|
|
@ -33,13 +33,13 @@ bool mcp23018_set_config(uint8_t slave_addr, mcp23018_port_t port, uint8_t conf)
|
|||
uint8_t cmdDirection = port ? CMD_IODIRB : CMD_IODIRA;
|
||||
uint8_t cmdPullup = port ? CMD_GPPUB : CMD_GPPUA;
|
||||
|
||||
i2c_status_t ret = i2c_writeReg(addr, cmdDirection, &conf, sizeof(conf), TIMEOUT);
|
||||
i2c_status_t ret = i2c_write_register(addr, cmdDirection, &conf, sizeof(conf), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
dprintf("mcp23018_set_config::directionFAILED::%u\n", ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = i2c_writeReg(addr, cmdPullup, &conf, sizeof(conf), TIMEOUT);
|
||||
ret = i2c_write_register(addr, cmdPullup, &conf, sizeof(conf), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
dprintf("mcp23018_set_config::pullupFAILED::%u\n", ret);
|
||||
return false;
|
||||
|
@ -52,7 +52,7 @@ bool mcp23018_set_output(uint8_t slave_addr, mcp23018_port_t port, uint8_t conf)
|
|||
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
|
||||
uint8_t cmd = port ? CMD_GPIOB : CMD_GPIOA;
|
||||
|
||||
i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
|
||||
i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
dprintf("mcp23018_set_output::FAILED::%u\n", ret);
|
||||
return false;
|
||||
|
@ -65,7 +65,7 @@ bool mcp23018_set_output_all(uint8_t slave_addr, uint8_t confA, uint8_t confB) {
|
|||
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
|
||||
uint8_t conf[2] = {confA, confB};
|
||||
|
||||
i2c_status_t ret = i2c_writeReg(addr, CMD_GPIOA, &conf[0], sizeof(conf), TIMEOUT);
|
||||
i2c_status_t ret = i2c_write_register(addr, CMD_GPIOA, &conf[0], sizeof(conf), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
dprintf("mcp23018_set_output::FAILED::%u\n", ret);
|
||||
return false;
|
||||
|
@ -78,7 +78,7 @@ bool mcp23018_readPins(uint8_t slave_addr, mcp23018_port_t port, uint8_t* out) {
|
|||
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
|
||||
uint8_t cmd = port ? CMD_GPIOB : CMD_GPIOA;
|
||||
|
||||
i2c_status_t ret = i2c_readReg(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
|
||||
i2c_status_t ret = i2c_read_register(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
dprintf("mcp23018_readPins::FAILED::%u\n", ret);
|
||||
return false;
|
||||
|
@ -97,7 +97,7 @@ bool mcp23018_readPins_all(uint8_t slave_addr, uint16_t* out) {
|
|||
|
||||
data16 data = {.u16 = 0};
|
||||
|
||||
i2c_status_t ret = i2c_readReg(addr, CMD_GPIOA, &data.u8[0], sizeof(data), TIMEOUT);
|
||||
i2c_status_t ret = i2c_read_register(addr, CMD_GPIOA, &data.u8[0], sizeof(data), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
dprintf("mcp23018_readPins::FAILED::%u\n", ret);
|
||||
return false;
|
||||
|
|
|
@ -41,8 +41,6 @@ void pca9505_init(uint8_t slave_addr) {
|
|||
}
|
||||
|
||||
// TODO: could check device connected
|
||||
// i2c_start(SLAVE_TO_ADDR(slave) | I2C_WRITE);
|
||||
// i2c_stop();
|
||||
}
|
||||
|
||||
bool pca9505_set_config(uint8_t slave_addr, pca9505_port_t port, uint8_t conf) {
|
||||
|
@ -66,7 +64,7 @@ bool pca9505_set_config(uint8_t slave_addr, pca9505_port_t port, uint8_t conf) {
|
|||
break;
|
||||
}
|
||||
|
||||
i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
|
||||
i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
print("pca9505_set_config::FAILED\n");
|
||||
return false;
|
||||
|
@ -96,7 +94,7 @@ bool pca9505_set_polarity(uint8_t slave_addr, pca9505_port_t port, uint8_t conf)
|
|||
break;
|
||||
}
|
||||
|
||||
i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
|
||||
i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
print("pca9505_set_polarity::FAILED\n");
|
||||
return false;
|
||||
|
@ -126,7 +124,7 @@ bool pca9505_set_output(uint8_t slave_addr, pca9505_port_t port, uint8_t conf) {
|
|||
break;
|
||||
}
|
||||
|
||||
i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
|
||||
i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
print("pca9505_set_output::FAILED\n");
|
||||
return false;
|
||||
|
@ -156,7 +154,7 @@ bool pca9505_readPins(uint8_t slave_addr, pca9505_port_t port, uint8_t* out) {
|
|||
break;
|
||||
}
|
||||
|
||||
i2c_status_t ret = i2c_readReg(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
|
||||
i2c_status_t ret = i2c_read_register(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
print("pca9505_readPins::FAILED\n");
|
||||
return false;
|
||||
|
|
|
@ -29,15 +29,13 @@ void pca9555_init(uint8_t slave_addr) {
|
|||
}
|
||||
|
||||
// TODO: could check device connected
|
||||
// i2c_start(SLAVE_TO_ADDR(slave) | I2C_WRITE);
|
||||
// i2c_stop();
|
||||
}
|
||||
|
||||
bool pca9555_set_config(uint8_t slave_addr, pca9555_port_t port, uint8_t conf) {
|
||||
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
|
||||
uint8_t cmd = port ? CMD_CONFIG_1 : CMD_CONFIG_0;
|
||||
|
||||
i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
|
||||
i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
print("pca9555_set_config::FAILED\n");
|
||||
return false;
|
||||
|
@ -50,7 +48,7 @@ bool pca9555_set_output(uint8_t slave_addr, pca9555_port_t port, uint8_t conf) {
|
|||
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
|
||||
uint8_t cmd = port ? CMD_OUTPUT_1 : CMD_OUTPUT_0;
|
||||
|
||||
i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
|
||||
i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
print("pca9555_set_output::FAILED\n");
|
||||
return false;
|
||||
|
@ -63,7 +61,7 @@ bool pca9555_set_output_all(uint8_t slave_addr, uint8_t confA, uint8_t confB) {
|
|||
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
|
||||
uint8_t conf[2] = {confA, confB};
|
||||
|
||||
i2c_status_t ret = i2c_writeReg(addr, CMD_OUTPUT_0, &conf[0], sizeof(conf), TIMEOUT);
|
||||
i2c_status_t ret = i2c_write_register(addr, CMD_OUTPUT_0, &conf[0], sizeof(conf), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
dprintf("pca9555_set_output::FAILED::%u\n", ret);
|
||||
return false;
|
||||
|
@ -76,7 +74,7 @@ bool pca9555_readPins(uint8_t slave_addr, pca9555_port_t port, uint8_t* out) {
|
|||
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
|
||||
uint8_t cmd = port ? CMD_INPUT_1 : CMD_INPUT_0;
|
||||
|
||||
i2c_status_t ret = i2c_readReg(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
|
||||
i2c_status_t ret = i2c_read_register(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
print("pca9555_readPins::FAILED\n");
|
||||
return false;
|
||||
|
@ -95,7 +93,7 @@ bool pca9555_readPins_all(uint8_t slave_addr, uint16_t* out) {
|
|||
|
||||
data16 data = {.u16 = 0};
|
||||
|
||||
i2c_status_t ret = i2c_readReg(addr, CMD_INPUT_0, &data.u8[0], sizeof(data), TIMEOUT);
|
||||
i2c_status_t ret = i2c_read_register(addr, CMD_INPUT_0, &data.u8[0], sizeof(data), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
print("pca9555_readPins_all::FAILED\n");
|
||||
return false;
|
||||
|
|
|
@ -27,39 +27,39 @@ static const pin_t address_pins[ADDRESS_PIN_COUNT] = SN74X138_ADDRESS_PINS;
|
|||
|
||||
void sn74x138_init(void) {
|
||||
for (int i = 0; i < ADDRESS_PIN_COUNT; i++) {
|
||||
setPinOutput(address_pins[i]);
|
||||
writePinLow(address_pins[i]);
|
||||
gpio_set_pin_output(address_pins[i]);
|
||||
gpio_write_pin_low(address_pins[i]);
|
||||
}
|
||||
|
||||
#if defined(SN74X138_E1_PIN)
|
||||
setPinOutput(SN74X138_E1_PIN);
|
||||
writePinHigh(SN74X138_E1_PIN);
|
||||
gpio_set_pin_output(SN74X138_E1_PIN);
|
||||
gpio_write_pin_high(SN74X138_E1_PIN);
|
||||
#endif
|
||||
|
||||
#if defined(SN74X138_E2_PIN)
|
||||
setPinOutput(SN74X138_E2_PIN);
|
||||
writePinHigh(SN74X138_E2_PIN);
|
||||
gpio_set_pin_output(SN74X138_E2_PIN);
|
||||
gpio_write_pin_high(SN74X138_E2_PIN);
|
||||
#endif
|
||||
#if defined(SN74X138_E3_PIN)
|
||||
setPinOutput(SN74X138_E3_PIN);
|
||||
writePinLow(SN74X138_E3_PIN);
|
||||
gpio_set_pin_output(SN74X138_E3_PIN);
|
||||
gpio_write_pin_low(SN74X138_E3_PIN);
|
||||
#endif
|
||||
}
|
||||
|
||||
void sn74x138_set_enabled(bool enabled) {
|
||||
#if defined(SN74X138_E1_PIN)
|
||||
writePin(SN74X138_E1_PIN, !enabled);
|
||||
gpio_write_pin(SN74X138_E1_PIN, !enabled);
|
||||
#endif
|
||||
#if defined(SN74X138_E2_PIN)
|
||||
writePin(SN74X138_E2_PIN, !enabled);
|
||||
gpio_write_pin(SN74X138_E2_PIN, !enabled);
|
||||
#endif
|
||||
#if defined(SN74X138_E3_PIN)
|
||||
writePin(SN74X138_E3_PIN, enabled);
|
||||
gpio_write_pin(SN74X138_E3_PIN, enabled);
|
||||
#endif
|
||||
}
|
||||
|
||||
void sn74x138_set_addr(uint8_t address) {
|
||||
for (int i = 0; i < ADDRESS_PIN_COUNT; i++) {
|
||||
writePin(address_pins[i], address & (1 << i));
|
||||
gpio_write_pin(address_pins[i], address & (1 << i));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,32 +27,32 @@ static const pin_t address_pins[ADDRESS_PIN_COUNT] = SN74X154_ADDRESS_PINS;
|
|||
|
||||
void sn74x154_init(void) {
|
||||
for (int i = 0; i < ADDRESS_PIN_COUNT; i++) {
|
||||
setPinOutput(address_pins[i]);
|
||||
writePinLow(address_pins[i]);
|
||||
gpio_set_pin_output(address_pins[i]);
|
||||
gpio_write_pin_low(address_pins[i]);
|
||||
}
|
||||
|
||||
#if defined(SN74X154_E0_PIN)
|
||||
setPinOutput(SN74X154_E0_PIN);
|
||||
writePinHigh(SN74X154_E0_PIN);
|
||||
gpio_set_pin_output(SN74X154_E0_PIN);
|
||||
gpio_write_pin_high(SN74X154_E0_PIN);
|
||||
#endif
|
||||
|
||||
#if defined(SN74X154_E1_PIN)
|
||||
setPinOutput(SN74X154_E1_PIN);
|
||||
writePinHigh(SN74X154_E1_PIN);
|
||||
gpio_set_pin_output(SN74X154_E1_PIN);
|
||||
gpio_write_pin_high(SN74X154_E1_PIN);
|
||||
#endif
|
||||
}
|
||||
|
||||
void sn74x154_set_enabled(bool enabled) {
|
||||
#if defined(SN74X154_E0_PIN)
|
||||
writePin(SN74X154_E0_PIN, !enabled);
|
||||
gpio_write_pin(SN74X154_E0_PIN, !enabled);
|
||||
#endif
|
||||
#if defined(SN74X154_E1_PIN)
|
||||
writePin(SN74X154_E1_PIN, !enabled);
|
||||
gpio_write_pin(SN74X154_E1_PIN, !enabled);
|
||||
#endif
|
||||
}
|
||||
|
||||
void sn74x154_set_addr(uint8_t address) {
|
||||
for (int i = 0; i < ADDRESS_PIN_COUNT; i++) {
|
||||
writePin(address_pins[i], address & (1 << i));
|
||||
gpio_write_pin(address_pins[i], address & (1 << i));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ void drv2605l_write(uint8_t reg_addr, uint8_t data) {
|
|||
}
|
||||
|
||||
uint8_t drv2605l_read(uint8_t reg_addr) {
|
||||
i2c_readReg(DRV2605L_I2C_ADDRESS << 1, reg_addr, &drv2605l_read_buffer, 1, 100);
|
||||
i2c_read_register(DRV2605L_I2C_ADDRESS << 1, reg_addr, &drv2605l_read_buffer, 1, 100);
|
||||
|
||||
return drv2605l_read_buffer;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ void solenoid_set_dwell(uint8_t dwell) {
|
|||
* @param index select which solenoid to check/stop
|
||||
*/
|
||||
void solenoid_stop(uint8_t index) {
|
||||
writePin(solenoid_pads[index], !solenoid_active_state[index]);
|
||||
gpio_write_pin(solenoid_pads[index], !solenoid_active_state[index]);
|
||||
solenoid_on[index] = false;
|
||||
solenoid_buzzing[index] = false;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ void solenoid_fire(uint8_t index) {
|
|||
solenoid_on[index] = true;
|
||||
solenoid_buzzing[index] = true;
|
||||
solenoid_start[index] = timer_read();
|
||||
writePin(solenoid_pads[index], solenoid_active_state[index]);
|
||||
gpio_write_pin(solenoid_pads[index], solenoid_active_state[index]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,12 +128,12 @@ void solenoid_check(void) {
|
|||
if ((elapsed[i] % (SOLENOID_BUZZ_ACTUATED + SOLENOID_BUZZ_NONACTUATED)) < SOLENOID_BUZZ_ACTUATED) {
|
||||
if (!solenoid_buzzing[i]) {
|
||||
solenoid_buzzing[i] = true;
|
||||
writePin(solenoid_pads[i], solenoid_active_state[i]);
|
||||
gpio_write_pin(solenoid_pads[i], solenoid_active_state[i]);
|
||||
}
|
||||
} else {
|
||||
if (solenoid_buzzing[i]) {
|
||||
solenoid_buzzing[i] = false;
|
||||
writePin(solenoid_pads[i], !solenoid_active_state[i]);
|
||||
gpio_write_pin(solenoid_pads[i], !solenoid_active_state[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,8 +156,8 @@ void solenoid_setup(void) {
|
|||
#else
|
||||
solenoid_active_state[i] = high;
|
||||
#endif
|
||||
writePin(solenoid_pads[i], !solenoid_active_state[i]);
|
||||
setPinOutput(solenoid_pads[i]);
|
||||
gpio_write_pin(solenoid_pads[i], !solenoid_active_state[i]);
|
||||
gpio_set_pin_output(solenoid_pads[i]);
|
||||
if ((!HAPTIC_OFF_IN_LOW_POWER) || (usb_device_state == USB_DEVICE_STATE_CONFIGURED)) {
|
||||
solenoid_fire(i);
|
||||
}
|
||||
|
@ -170,6 +170,6 @@ void solenoid_setup(void) {
|
|||
*/
|
||||
void solenoid_shutdown(void) {
|
||||
for (uint8_t i = 0; i < NUMBER_OF_SOLENOIDS; i++) {
|
||||
writePin(solenoid_pads[i], !solenoid_active_state[i]);
|
||||
gpio_write_pin(solenoid_pads[i], !solenoid_active_state[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,67 +57,67 @@ static const pin_t data_pins[4] = HD44780_DATA_PINS;
|
|||
#define HD44780_ENABLE_DELAY_US 1
|
||||
|
||||
static void hd44780_latch(void) {
|
||||
writePinHigh(HD44780_E_PIN);
|
||||
gpio_write_pin_high(HD44780_E_PIN);
|
||||
wait_us(HD44780_ENABLE_DELAY_US);
|
||||
writePinLow(HD44780_E_PIN);
|
||||
gpio_write_pin_low(HD44780_E_PIN);
|
||||
}
|
||||
|
||||
void hd44780_write(uint8_t data, bool isData) {
|
||||
writePin(HD44780_RS_PIN, isData);
|
||||
writePinLow(HD44780_RW_PIN);
|
||||
gpio_write_pin(HD44780_RS_PIN, isData);
|
||||
gpio_write_pin_low(HD44780_RW_PIN);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
setPinOutput(data_pins[i]);
|
||||
gpio_set_pin_output(data_pins[i]);
|
||||
}
|
||||
|
||||
// Write high nibble
|
||||
for (int i = 0; i < 4; i++) {
|
||||
writePin(data_pins[i], (data >> 4) & (1 << i));
|
||||
gpio_write_pin(data_pins[i], (data >> 4) & (1 << i));
|
||||
}
|
||||
hd44780_latch();
|
||||
|
||||
// Write low nibble
|
||||
for (int i = 0; i < 4; i++) {
|
||||
writePin(data_pins[i], data & (1 << i));
|
||||
gpio_write_pin(data_pins[i], data & (1 << i));
|
||||
}
|
||||
hd44780_latch();
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
writePinHigh(data_pins[i]);
|
||||
gpio_write_pin_high(data_pins[i]);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t hd44780_read(bool isData) {
|
||||
uint8_t data = 0;
|
||||
|
||||
writePin(HD44780_RS_PIN, isData);
|
||||
writePinHigh(HD44780_RW_PIN);
|
||||
gpio_write_pin(HD44780_RS_PIN, isData);
|
||||
gpio_write_pin_high(HD44780_RW_PIN);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
setPinInput(data_pins[i]);
|
||||
gpio_set_pin_input(data_pins[i]);
|
||||
}
|
||||
|
||||
writePinHigh(HD44780_E_PIN);
|
||||
gpio_write_pin_high(HD44780_E_PIN);
|
||||
wait_us(HD44780_ENABLE_DELAY_US);
|
||||
|
||||
// Read high nibble
|
||||
for (int i = 0; i < 4; i++) {
|
||||
data |= (readPin(data_pins[i]) << i);
|
||||
data |= (gpio_read_pin(data_pins[i]) << i);
|
||||
}
|
||||
|
||||
data <<= 4;
|
||||
|
||||
writePinLow(HD44780_E_PIN);
|
||||
gpio_write_pin_low(HD44780_E_PIN);
|
||||
wait_us(HD44780_ENABLE_DELAY_US);
|
||||
writePinHigh(HD44780_E_PIN);
|
||||
gpio_write_pin_high(HD44780_E_PIN);
|
||||
wait_us(HD44780_ENABLE_DELAY_US);
|
||||
|
||||
// Read low nibble
|
||||
for (int i = 0; i < 4; i++) {
|
||||
data |= (readPin(data_pins[i]) << i);
|
||||
data |= (gpio_read_pin(data_pins[i]) << i);
|
||||
}
|
||||
|
||||
writePinLow(HD44780_E_PIN);
|
||||
gpio_write_pin_low(HD44780_E_PIN);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
@ -171,20 +171,20 @@ void hd44780_set_ddram_address(uint8_t address) {
|
|||
}
|
||||
|
||||
void hd44780_init(bool cursor, bool blink) {
|
||||
setPinOutput(HD44780_RS_PIN);
|
||||
setPinOutput(HD44780_RW_PIN);
|
||||
setPinOutput(HD44780_E_PIN);
|
||||
gpio_set_pin_output(HD44780_RS_PIN);
|
||||
gpio_set_pin_output(HD44780_RW_PIN);
|
||||
gpio_set_pin_output(HD44780_E_PIN);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
setPinOutput(data_pins[i]);
|
||||
gpio_set_pin_output(data_pins[i]);
|
||||
}
|
||||
|
||||
wait_ms(HD44780_INIT_DELAY_MS);
|
||||
|
||||
// Manually configure for 4-bit mode - can't use hd44780_command() yet
|
||||
// HD44780U datasheet, Fig. 24 (p46)
|
||||
writePinHigh(data_pins[0]); // Function set
|
||||
writePinHigh(data_pins[1]); // DL = 1
|
||||
gpio_write_pin_high(data_pins[0]); // Function set
|
||||
gpio_write_pin_high(data_pins[1]); // DL = 1
|
||||
hd44780_latch();
|
||||
wait_ms(5);
|
||||
// Send again
|
||||
|
@ -194,7 +194,7 @@ void hd44780_init(bool cursor, bool blink) {
|
|||
hd44780_latch();
|
||||
wait_us(64);
|
||||
|
||||
writePinLow(data_pins[0]); // DL = 0
|
||||
gpio_write_pin_low(data_pins[0]); // DL = 0
|
||||
hd44780_latch();
|
||||
wait_us(64);
|
||||
|
||||
|
|
|
@ -92,10 +92,10 @@ static void InvertCharacter(uint8_t *cursor) {
|
|||
}
|
||||
|
||||
bool st7565_init(display_rotation_t rotation) {
|
||||
setPinOutput(ST7565_A0_PIN);
|
||||
writePinHigh(ST7565_A0_PIN);
|
||||
setPinOutput(ST7565_RST_PIN);
|
||||
writePinHigh(ST7565_RST_PIN);
|
||||
gpio_set_pin_output(ST7565_A0_PIN);
|
||||
gpio_write_pin_high(ST7565_A0_PIN);
|
||||
gpio_set_pin_output(ST7565_RST_PIN);
|
||||
gpio_write_pin_high(ST7565_RST_PIN);
|
||||
|
||||
st7565_rotation = st7565_init_user(rotation);
|
||||
|
||||
|
@ -488,18 +488,18 @@ void st7565_task(void) {
|
|||
__attribute__((weak)) void st7565_task_user(void) {}
|
||||
|
||||
void st7565_reset(void) {
|
||||
writePinLow(ST7565_RST_PIN);
|
||||
gpio_write_pin_low(ST7565_RST_PIN);
|
||||
wait_ms(20);
|
||||
writePinHigh(ST7565_RST_PIN);
|
||||
gpio_write_pin_high(ST7565_RST_PIN);
|
||||
wait_ms(20);
|
||||
}
|
||||
|
||||
spi_status_t st7565_send_cmd(uint8_t cmd) {
|
||||
writePinLow(ST7565_A0_PIN);
|
||||
gpio_write_pin_low(ST7565_A0_PIN);
|
||||
return spi_write(cmd);
|
||||
}
|
||||
|
||||
spi_status_t st7565_send_data(uint8_t *data, uint16_t length) {
|
||||
writePinHigh(ST7565_A0_PIN);
|
||||
gpio_write_pin_high(ST7565_A0_PIN);
|
||||
return spi_transmit(data, length);
|
||||
}
|
||||
|
|
|
@ -43,72 +43,37 @@
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define APA102_SEND_BIT(byte, bit) \
|
||||
do { \
|
||||
writePin(APA102_DI_PIN, (byte >> bit) & 1); \
|
||||
io_wait; \
|
||||
writePinHigh(APA102_CI_PIN); \
|
||||
io_wait; \
|
||||
writePinLow(APA102_CI_PIN); \
|
||||
io_wait; \
|
||||
#define APA102_SEND_BIT(byte, bit) \
|
||||
do { \
|
||||
gpio_write_pin(APA102_DI_PIN, (byte >> bit) & 1); \
|
||||
io_wait; \
|
||||
gpio_write_pin_high(APA102_CI_PIN); \
|
||||
io_wait; \
|
||||
gpio_write_pin_low(APA102_CI_PIN); \
|
||||
io_wait; \
|
||||
} while (0)
|
||||
|
||||
uint8_t apa102_led_brightness = APA102_DEFAULT_BRIGHTNESS;
|
||||
|
||||
void static apa102_start_frame(void);
|
||||
void static apa102_end_frame(uint16_t num_leds);
|
||||
|
||||
void static apa102_send_frame(uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness);
|
||||
void static apa102_send_byte(uint8_t byte);
|
||||
|
||||
void apa102_setleds(rgb_led_t *start_led, uint16_t num_leds) {
|
||||
rgb_led_t *end = start_led + num_leds;
|
||||
|
||||
apa102_start_frame();
|
||||
for (rgb_led_t *led = start_led; led < end; led++) {
|
||||
apa102_send_frame(led->r, led->g, led->b, apa102_led_brightness);
|
||||
}
|
||||
apa102_end_frame(num_leds);
|
||||
static void apa102_send_byte(uint8_t byte) {
|
||||
APA102_SEND_BIT(byte, 7);
|
||||
APA102_SEND_BIT(byte, 6);
|
||||
APA102_SEND_BIT(byte, 5);
|
||||
APA102_SEND_BIT(byte, 4);
|
||||
APA102_SEND_BIT(byte, 3);
|
||||
APA102_SEND_BIT(byte, 2);
|
||||
APA102_SEND_BIT(byte, 1);
|
||||
APA102_SEND_BIT(byte, 0);
|
||||
}
|
||||
|
||||
// Overwrite the default rgblight_call_driver to use apa102 driver
|
||||
void rgblight_call_driver(rgb_led_t *start_led, uint8_t num_leds) {
|
||||
apa102_setleds(start_led, num_leds);
|
||||
}
|
||||
|
||||
void static apa102_init(void) {
|
||||
setPinOutput(APA102_DI_PIN);
|
||||
setPinOutput(APA102_CI_PIN);
|
||||
|
||||
writePinLow(APA102_DI_PIN);
|
||||
writePinLow(APA102_CI_PIN);
|
||||
}
|
||||
|
||||
void apa102_set_brightness(uint8_t brightness) {
|
||||
if (brightness > APA102_MAX_BRIGHTNESS) {
|
||||
apa102_led_brightness = APA102_MAX_BRIGHTNESS;
|
||||
} else if (brightness < 0) {
|
||||
apa102_led_brightness = 0;
|
||||
} else {
|
||||
apa102_led_brightness = brightness;
|
||||
}
|
||||
}
|
||||
|
||||
void static apa102_send_frame(uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness) {
|
||||
apa102_send_byte(0b11100000 | brightness);
|
||||
apa102_send_byte(blue);
|
||||
apa102_send_byte(green);
|
||||
apa102_send_byte(red);
|
||||
}
|
||||
|
||||
void static apa102_start_frame(void) {
|
||||
static void apa102_start_frame(void) {
|
||||
apa102_init();
|
||||
for (uint16_t i = 0; i < 4; i++) {
|
||||
apa102_send_byte(0);
|
||||
}
|
||||
}
|
||||
|
||||
void static apa102_end_frame(uint16_t num_leds) {
|
||||
static void apa102_end_frame(uint16_t num_leds) {
|
||||
// This function has been taken from: https://github.com/pololu/apa102-arduino/blob/master/APA102.h
|
||||
// and adapted. The code is MIT licensed. I think thats compatible?
|
||||
//
|
||||
|
@ -141,13 +106,37 @@ void static apa102_end_frame(uint16_t num_leds) {
|
|||
apa102_init();
|
||||
}
|
||||
|
||||
void static apa102_send_byte(uint8_t byte) {
|
||||
APA102_SEND_BIT(byte, 7);
|
||||
APA102_SEND_BIT(byte, 6);
|
||||
APA102_SEND_BIT(byte, 5);
|
||||
APA102_SEND_BIT(byte, 4);
|
||||
APA102_SEND_BIT(byte, 3);
|
||||
APA102_SEND_BIT(byte, 2);
|
||||
APA102_SEND_BIT(byte, 1);
|
||||
APA102_SEND_BIT(byte, 0);
|
||||
static void apa102_send_frame(uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness) {
|
||||
apa102_send_byte(0b11100000 | brightness);
|
||||
apa102_send_byte(blue);
|
||||
apa102_send_byte(green);
|
||||
apa102_send_byte(red);
|
||||
}
|
||||
|
||||
void apa102_init(void) {
|
||||
gpio_set_pin_output(APA102_DI_PIN);
|
||||
gpio_set_pin_output(APA102_CI_PIN);
|
||||
|
||||
gpio_write_pin_low(APA102_DI_PIN);
|
||||
gpio_write_pin_low(APA102_CI_PIN);
|
||||
}
|
||||
|
||||
void apa102_setleds(rgb_led_t *start_led, uint16_t num_leds) {
|
||||
rgb_led_t *end = start_led + num_leds;
|
||||
|
||||
apa102_start_frame();
|
||||
for (rgb_led_t *led = start_led; led < end; led++) {
|
||||
apa102_send_frame(led->r, led->g, led->b, apa102_led_brightness);
|
||||
}
|
||||
apa102_end_frame(num_leds);
|
||||
}
|
||||
|
||||
void apa102_set_brightness(uint8_t brightness) {
|
||||
if (brightness > APA102_MAX_BRIGHTNESS) {
|
||||
apa102_led_brightness = APA102_MAX_BRIGHTNESS;
|
||||
} else if (brightness < 0) {
|
||||
apa102_led_brightness = 0;
|
||||
} else {
|
||||
apa102_led_brightness = brightness;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,13 +19,19 @@
|
|||
|
||||
#include "color.h"
|
||||
|
||||
#if defined(RGBLIGHT_APA102)
|
||||
# define APA102_LED_COUNT RGBLIGHT_LED_COUNT
|
||||
#elif defined(RGB_MATRIX_APA102)
|
||||
# define APA102_LED_COUNT RGB_MATRIX_LED_COUNT
|
||||
#endif
|
||||
|
||||
#ifndef APA102_DEFAULT_BRIGHTNESS
|
||||
# define APA102_DEFAULT_BRIGHTNESS 31
|
||||
#endif
|
||||
|
||||
#define APA102_MAX_BRIGHTNESS 31
|
||||
|
||||
extern uint8_t apa102_led_brightness;
|
||||
void apa102_init(void);
|
||||
|
||||
/* User Interface
|
||||
*
|
||||
|
@ -38,4 +44,5 @@ extern uint8_t apa102_led_brightness;
|
|||
* - Send out the LED data
|
||||
*/
|
||||
void apa102_setleds(rgb_led_t *start_led, uint16_t num_leds);
|
||||
|
||||
void apa102_set_brightness(uint8_t brightness);
|
||||
|
|
|
@ -45,8 +45,15 @@
|
|||
# define AW20216S_SPI_DIVISOR 4
|
||||
#endif
|
||||
|
||||
uint8_t g_pwm_buffer[AW20216S_DRIVER_COUNT][AW20216S_PWM_REGISTER_COUNT];
|
||||
bool g_pwm_buffer_update_required[AW20216S_DRIVER_COUNT] = {false};
|
||||
typedef struct aw20216s_driver_t {
|
||||
uint8_t pwm_buffer[AW20216S_PWM_REGISTER_COUNT];
|
||||
bool pwm_buffer_dirty;
|
||||
} PACKED aw20216s_driver_t;
|
||||
|
||||
aw20216s_driver_t driver_buffers[AW20216S_DRIVER_COUNT] = {{
|
||||
.pwm_buffer = {0},
|
||||
.pwm_buffer_dirty = false,
|
||||
}};
|
||||
|
||||
bool aw20216s_write(pin_t cs_pin, uint8_t page, uint8_t reg, uint8_t* data, uint8_t len) {
|
||||
static uint8_t s_spi_transfer_buffer[2] = {0};
|
||||
|
@ -106,16 +113,18 @@ static inline void aw20216s_auto_lowpower(pin_t cs_pin) {
|
|||
void aw20216s_init_drivers(void) {
|
||||
spi_init();
|
||||
|
||||
aw20216s_init(AW20216S_CS_PIN_1, AW20216S_EN_PIN_1);
|
||||
#if defined(AW20216S_EN_PIN)
|
||||
gpio_set_pin_output(AW20216S_EN_PIN);
|
||||
gpio_write_pin_high(AW20216S_EN_PIN);
|
||||
#endif
|
||||
|
||||
aw20216s_init(AW20216S_CS_PIN_1);
|
||||
#if defined(AW20216S_CS_PIN_2)
|
||||
aw20216s_init(AW20216S_CS_PIN_2, AW20216S_EN_PIN_2);
|
||||
aw20216s_init(AW20216S_CS_PIN_2);
|
||||
#endif
|
||||
}
|
||||
|
||||
void aw20216s_init(pin_t cs_pin, pin_t en_pin) {
|
||||
setPinOutput(en_pin);
|
||||
writePinHigh(en_pin);
|
||||
|
||||
void aw20216s_init(pin_t cs_pin) {
|
||||
aw20216s_soft_reset(cs_pin);
|
||||
wait_ms(2);
|
||||
|
||||
|
@ -131,13 +140,14 @@ void aw20216s_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
|||
aw20216s_led_t led;
|
||||
memcpy_P(&led, (&g_aw20216s_leds[index]), sizeof(led));
|
||||
|
||||
if (g_pwm_buffer[led.driver][led.r] == red && g_pwm_buffer[led.driver][led.g] == green && g_pwm_buffer[led.driver][led.b] == blue) {
|
||||
if (driver_buffers[led.driver].pwm_buffer[led.r] == red && driver_buffers[led.driver].pwm_buffer[led.g] == green && driver_buffers[led.driver].pwm_buffer[led.b] == blue) {
|
||||
return;
|
||||
}
|
||||
g_pwm_buffer[led.driver][led.r] = red;
|
||||
g_pwm_buffer[led.driver][led.g] = green;
|
||||
g_pwm_buffer[led.driver][led.b] = blue;
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
|
||||
driver_buffers[led.driver].pwm_buffer[led.r] = red;
|
||||
driver_buffers[led.driver].pwm_buffer[led.g] = green;
|
||||
driver_buffers[led.driver].pwm_buffer[led.b] = blue;
|
||||
driver_buffers[led.driver].pwm_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void aw20216s_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
|
@ -147,10 +157,10 @@ void aw20216s_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
|
|||
}
|
||||
|
||||
void aw20216s_update_pwm_buffers(pin_t cs_pin, uint8_t index) {
|
||||
if (g_pwm_buffer_update_required[index]) {
|
||||
aw20216s_write(cs_pin, AW20216S_PAGE_PWM, 0, g_pwm_buffer[index], AW20216S_PWM_REGISTER_COUNT);
|
||||
if (driver_buffers[index].pwm_buffer_dirty) {
|
||||
aw20216s_write(cs_pin, AW20216S_PAGE_PWM, 0, driver_buffers[index].pwm_buffer, AW20216S_PWM_REGISTER_COUNT);
|
||||
driver_buffers[index].pwm_buffer_dirty = false;
|
||||
}
|
||||
g_pwm_buffer_update_required[index] = false;
|
||||
}
|
||||
|
||||
void aw20216s_flush(void) {
|
||||
|
|
|
@ -42,10 +42,10 @@
|
|||
# define AW20216S_CS_PIN_2 DRIVER_2_CS
|
||||
#endif
|
||||
#ifdef DRIVER_1_EN
|
||||
# define AW20216S_EN_PIN_1 DRIVER_1_EN
|
||||
# define AW20216S_EN_PIN DRIVER_1_EN
|
||||
#endif
|
||||
#ifdef DRIVER_2_EN
|
||||
# define AW20216S_EN_PIN_2 DRIVER_2_EN
|
||||
#ifdef AW20216S_EN_PIN_1
|
||||
# define AW20216S_EN_PIN AW20216S_EN_PIN_1
|
||||
#endif
|
||||
|
||||
#define aw_led aw20216s_led_t
|
||||
|
@ -94,226 +94,467 @@ typedef struct aw20216s_led_t {
|
|||
extern const aw20216s_led_t PROGMEM g_aw20216s_leds[AW20216S_LED_COUNT];
|
||||
|
||||
void aw20216s_init_drivers(void);
|
||||
void aw20216s_init(pin_t cs_pin, pin_t en_pin);
|
||||
void aw20216s_init(pin_t cs_pin);
|
||||
void aw20216s_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
|
||||
void aw20216s_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
|
||||
void aw20216s_update_pwm_buffers(pin_t cs_pin, uint8_t index);
|
||||
|
||||
void aw20216s_flush(void);
|
||||
|
||||
#define CS1_SW1 0x00
|
||||
#define CS2_SW1 0x01
|
||||
#define CS3_SW1 0x02
|
||||
#define CS4_SW1 0x03
|
||||
#define CS5_SW1 0x04
|
||||
#define CS6_SW1 0x05
|
||||
#define CS7_SW1 0x06
|
||||
#define CS8_SW1 0x07
|
||||
#define CS9_SW1 0x08
|
||||
#define CS10_SW1 0x09
|
||||
#define CS11_SW1 0x0A
|
||||
#define CS12_SW1 0x0B
|
||||
#define CS13_SW1 0x0C
|
||||
#define CS14_SW1 0x0D
|
||||
#define CS15_SW1 0x0E
|
||||
#define CS16_SW1 0x0F
|
||||
#define CS17_SW1 0x10
|
||||
#define CS18_SW1 0x11
|
||||
#define CS1_SW2 0x12
|
||||
#define CS2_SW2 0x13
|
||||
#define CS3_SW2 0x14
|
||||
#define CS4_SW2 0x15
|
||||
#define CS5_SW2 0x16
|
||||
#define CS6_SW2 0x17
|
||||
#define CS7_SW2 0x18
|
||||
#define CS8_SW2 0x19
|
||||
#define CS9_SW2 0x1A
|
||||
#define CS10_SW2 0x1B
|
||||
#define CS11_SW2 0x1C
|
||||
#define CS12_SW2 0x1D
|
||||
#define CS13_SW2 0x1E
|
||||
#define CS14_SW2 0x1F
|
||||
#define CS15_SW2 0x20
|
||||
#define CS16_SW2 0x21
|
||||
#define CS17_SW2 0x22
|
||||
#define CS18_SW2 0x23
|
||||
#define CS1_SW3 0x24
|
||||
#define CS2_SW3 0x25
|
||||
#define CS3_SW3 0x26
|
||||
#define CS4_SW3 0x27
|
||||
#define CS5_SW3 0x28
|
||||
#define CS6_SW3 0x29
|
||||
#define CS7_SW3 0x2A
|
||||
#define CS8_SW3 0x2B
|
||||
#define CS9_SW3 0x2C
|
||||
#define CS10_SW3 0x2D
|
||||
#define CS11_SW3 0x2E
|
||||
#define CS12_SW3 0x2F
|
||||
#define CS13_SW3 0x30
|
||||
#define CS14_SW3 0x31
|
||||
#define CS15_SW3 0x32
|
||||
#define CS16_SW3 0x33
|
||||
#define CS17_SW3 0x34
|
||||
#define CS18_SW3 0x35
|
||||
#define CS1_SW4 0x36
|
||||
#define CS2_SW4 0x37
|
||||
#define CS3_SW4 0x38
|
||||
#define CS4_SW4 0x39
|
||||
#define CS5_SW4 0x3A
|
||||
#define CS6_SW4 0x3B
|
||||
#define CS7_SW4 0x3C
|
||||
#define CS8_SW4 0x3D
|
||||
#define CS9_SW4 0x3E
|
||||
#define CS10_SW4 0x3F
|
||||
#define CS11_SW4 0x40
|
||||
#define CS12_SW4 0x41
|
||||
#define CS13_SW4 0x42
|
||||
#define CS14_SW4 0x43
|
||||
#define CS15_SW4 0x44
|
||||
#define CS16_SW4 0x45
|
||||
#define CS17_SW4 0x46
|
||||
#define CS18_SW4 0x47
|
||||
#define CS1_SW5 0x48
|
||||
#define CS2_SW5 0x49
|
||||
#define CS3_SW5 0x4A
|
||||
#define CS4_SW5 0x4B
|
||||
#define CS5_SW5 0x4C
|
||||
#define CS6_SW5 0x4D
|
||||
#define CS7_SW5 0x4E
|
||||
#define CS8_SW5 0x4F
|
||||
#define CS9_SW5 0x50
|
||||
#define CS10_SW5 0x51
|
||||
#define CS11_SW5 0x52
|
||||
#define CS12_SW5 0x53
|
||||
#define CS13_SW5 0x54
|
||||
#define CS14_SW5 0x55
|
||||
#define CS15_SW5 0x56
|
||||
#define CS16_SW5 0x57
|
||||
#define CS17_SW5 0x58
|
||||
#define CS18_SW5 0x59
|
||||
#define CS1_SW6 0x5A
|
||||
#define CS2_SW6 0x5B
|
||||
#define CS3_SW6 0x5C
|
||||
#define CS4_SW6 0x5D
|
||||
#define CS5_SW6 0x5E
|
||||
#define CS6_SW6 0x5F
|
||||
#define CS7_SW6 0x60
|
||||
#define CS8_SW6 0x61
|
||||
#define CS9_SW6 0x62
|
||||
#define CS10_SW6 0x63
|
||||
#define CS11_SW6 0x64
|
||||
#define CS12_SW6 0x65
|
||||
#define CS13_SW6 0x66
|
||||
#define CS14_SW6 0x67
|
||||
#define CS15_SW6 0x68
|
||||
#define CS16_SW6 0x69
|
||||
#define CS17_SW6 0x6A
|
||||
#define CS18_SW6 0x6B
|
||||
#define CS1_SW7 0x6C
|
||||
#define CS2_SW7 0x6D
|
||||
#define CS3_SW7 0x6E
|
||||
#define CS4_SW7 0x6F
|
||||
#define CS5_SW7 0x70
|
||||
#define CS6_SW7 0x71
|
||||
#define CS7_SW7 0x72
|
||||
#define CS8_SW7 0x73
|
||||
#define CS9_SW7 0x74
|
||||
#define CS10_SW7 0x75
|
||||
#define CS11_SW7 0x76
|
||||
#define CS12_SW7 0x77
|
||||
#define CS13_SW7 0x78
|
||||
#define CS14_SW7 0x79
|
||||
#define CS15_SW7 0x7A
|
||||
#define CS16_SW7 0x7B
|
||||
#define CS17_SW7 0x7C
|
||||
#define CS18_SW7 0x7D
|
||||
#define CS1_SW8 0x7E
|
||||
#define CS2_SW8 0x7F
|
||||
#define CS3_SW8 0x80
|
||||
#define CS4_SW8 0x81
|
||||
#define CS5_SW8 0x82
|
||||
#define CS6_SW8 0x83
|
||||
#define CS7_SW8 0x84
|
||||
#define CS8_SW8 0x85
|
||||
#define CS9_SW8 0x86
|
||||
#define CS10_SW8 0x87
|
||||
#define CS11_SW8 0x88
|
||||
#define CS12_SW8 0x89
|
||||
#define CS13_SW8 0x8A
|
||||
#define CS14_SW8 0x8B
|
||||
#define CS15_SW8 0x8C
|
||||
#define CS16_SW8 0x8D
|
||||
#define CS17_SW8 0x8E
|
||||
#define CS18_SW8 0x8F
|
||||
#define CS1_SW9 0x90
|
||||
#define CS2_SW9 0x91
|
||||
#define CS3_SW9 0x92
|
||||
#define CS4_SW9 0x93
|
||||
#define CS5_SW9 0x94
|
||||
#define CS6_SW9 0x95
|
||||
#define CS7_SW9 0x96
|
||||
#define CS8_SW9 0x97
|
||||
#define CS9_SW9 0x98
|
||||
#define CS10_SW9 0x99
|
||||
#define CS11_SW9 0x9A
|
||||
#define CS12_SW9 0x9B
|
||||
#define CS13_SW9 0x9C
|
||||
#define CS14_SW9 0x9D
|
||||
#define CS15_SW9 0x9E
|
||||
#define CS16_SW9 0x9F
|
||||
#define CS17_SW9 0xA0
|
||||
#define CS18_SW9 0xA1
|
||||
#define CS1_SW10 0xA2
|
||||
#define CS2_SW10 0xA3
|
||||
#define CS3_SW10 0xA4
|
||||
#define CS4_SW10 0xA5
|
||||
#define CS5_SW10 0xA6
|
||||
#define CS6_SW10 0xA7
|
||||
#define CS7_SW10 0xA8
|
||||
#define CS8_SW10 0xA9
|
||||
#define CS9_SW10 0xAA
|
||||
#define CS10_SW10 0xAB
|
||||
#define CS11_SW10 0xAC
|
||||
#define CS12_SW10 0xAD
|
||||
#define CS13_SW10 0xAE
|
||||
#define CS14_SW10 0xAF
|
||||
#define CS15_SW10 0xB0
|
||||
#define CS16_SW10 0xB1
|
||||
#define CS17_SW10 0xB2
|
||||
#define CS18_SW10 0xB3
|
||||
#define CS1_SW11 0xB4
|
||||
#define CS2_SW11 0xB5
|
||||
#define CS3_SW11 0xB6
|
||||
#define CS4_SW11 0xB7
|
||||
#define CS5_SW11 0xB8
|
||||
#define CS6_SW11 0xB9
|
||||
#define CS7_SW11 0xBA
|
||||
#define CS8_SW11 0xBB
|
||||
#define CS9_SW11 0xBC
|
||||
#define CS10_SW11 0xBD
|
||||
#define CS11_SW11 0xBE
|
||||
#define CS12_SW11 0xBF
|
||||
#define CS13_SW11 0xC0
|
||||
#define CS14_SW11 0xC1
|
||||
#define CS15_SW11 0xC2
|
||||
#define CS16_SW11 0xC3
|
||||
#define CS17_SW11 0xC4
|
||||
#define CS18_SW11 0xC5
|
||||
#define CS1_SW12 0xC6
|
||||
#define CS2_SW12 0xC7
|
||||
#define CS3_SW12 0xC8
|
||||
#define CS4_SW12 0xC9
|
||||
#define CS5_SW12 0xCA
|
||||
#define CS6_SW12 0xCB
|
||||
#define CS7_SW12 0xCC
|
||||
#define CS8_SW12 0xCD
|
||||
#define CS9_SW12 0xCE
|
||||
#define CS10_SW12 0xCF
|
||||
#define CS11_SW12 0xD0
|
||||
#define CS12_SW12 0xD1
|
||||
#define CS13_SW12 0xD2
|
||||
#define CS14_SW12 0xD3
|
||||
#define CS15_SW12 0xD4
|
||||
#define CS16_SW12 0xD5
|
||||
#define CS17_SW12 0xD6
|
||||
#define CS18_SW12 0xD7
|
||||
#define SW1_CS1 0x00
|
||||
#define SW1_CS2 0x01
|
||||
#define SW1_CS3 0x02
|
||||
#define SW1_CS4 0x03
|
||||
#define SW1_CS5 0x04
|
||||
#define SW1_CS6 0x05
|
||||
#define SW1_CS7 0x06
|
||||
#define SW1_CS8 0x07
|
||||
#define SW1_CS9 0x08
|
||||
#define SW1_CS10 0x09
|
||||
#define SW1_CS11 0x0A
|
||||
#define SW1_CS12 0x0B
|
||||
#define SW1_CS13 0x0C
|
||||
#define SW1_CS14 0x0D
|
||||
#define SW1_CS15 0x0E
|
||||
#define SW1_CS16 0x0F
|
||||
#define SW1_CS17 0x10
|
||||
#define SW1_CS18 0x11
|
||||
|
||||
#define SW2_CS1 0x12
|
||||
#define SW2_CS2 0x13
|
||||
#define SW2_CS3 0x14
|
||||
#define SW2_CS4 0x15
|
||||
#define SW2_CS5 0x16
|
||||
#define SW2_CS6 0x17
|
||||
#define SW2_CS7 0x18
|
||||
#define SW2_CS8 0x19
|
||||
#define SW2_CS9 0x1A
|
||||
#define SW2_CS10 0x1B
|
||||
#define SW2_CS11 0x1C
|
||||
#define SW2_CS12 0x1D
|
||||
#define SW2_CS13 0x1E
|
||||
#define SW2_CS14 0x1F
|
||||
#define SW2_CS15 0x20
|
||||
#define SW2_CS16 0x21
|
||||
#define SW2_CS17 0x22
|
||||
#define SW2_CS18 0x23
|
||||
|
||||
#define SW3_CS1 0x24
|
||||
#define SW3_CS2 0x25
|
||||
#define SW3_CS3 0x26
|
||||
#define SW3_CS4 0x27
|
||||
#define SW3_CS5 0x28
|
||||
#define SW3_CS6 0x29
|
||||
#define SW3_CS7 0x2A
|
||||
#define SW3_CS8 0x2B
|
||||
#define SW3_CS9 0x2C
|
||||
#define SW3_CS10 0x2D
|
||||
#define SW3_CS11 0x2E
|
||||
#define SW3_CS12 0x2F
|
||||
#define SW3_CS13 0x30
|
||||
#define SW3_CS14 0x31
|
||||
#define SW3_CS15 0x32
|
||||
#define SW3_CS16 0x33
|
||||
#define SW3_CS17 0x34
|
||||
#define SW3_CS18 0x35
|
||||
|
||||
#define SW4_CS1 0x36
|
||||
#define SW4_CS2 0x37
|
||||
#define SW4_CS3 0x38
|
||||
#define SW4_CS4 0x39
|
||||
#define SW4_CS5 0x3A
|
||||
#define SW4_CS6 0x3B
|
||||
#define SW4_CS7 0x3C
|
||||
#define SW4_CS8 0x3D
|
||||
#define SW4_CS9 0x3E
|
||||
#define SW4_CS10 0x3F
|
||||
#define SW4_CS11 0x40
|
||||
#define SW4_CS12 0x41
|
||||
#define SW4_CS13 0x42
|
||||
#define SW4_CS14 0x43
|
||||
#define SW4_CS15 0x44
|
||||
#define SW4_CS16 0x45
|
||||
#define SW4_CS17 0x46
|
||||
#define SW4_CS18 0x47
|
||||
|
||||
#define SW5_CS1 0x48
|
||||
#define SW5_CS2 0x49
|
||||
#define SW5_CS3 0x4A
|
||||
#define SW5_CS4 0x4B
|
||||
#define SW5_CS5 0x4C
|
||||
#define SW5_CS6 0x4D
|
||||
#define SW5_CS7 0x4E
|
||||
#define SW5_CS8 0x4F
|
||||
#define SW5_CS9 0x50
|
||||
#define SW5_CS10 0x51
|
||||
#define SW5_CS11 0x52
|
||||
#define SW5_CS12 0x53
|
||||
#define SW5_CS13 0x54
|
||||
#define SW5_CS14 0x55
|
||||
#define SW5_CS15 0x56
|
||||
#define SW5_CS16 0x57
|
||||
#define SW5_CS17 0x58
|
||||
#define SW5_CS18 0x59
|
||||
|
||||
#define SW6_CS1 0x5A
|
||||
#define SW6_CS2 0x5B
|
||||
#define SW6_CS3 0x5C
|
||||
#define SW6_CS4 0x5D
|
||||
#define SW6_CS5 0x5E
|
||||
#define SW6_CS6 0x5F
|
||||
#define SW6_CS7 0x60
|
||||
#define SW6_CS8 0x61
|
||||
#define SW6_CS9 0x62
|
||||
#define SW6_CS10 0x63
|
||||
#define SW6_CS11 0x64
|
||||
#define SW6_CS12 0x65
|
||||
#define SW6_CS13 0x66
|
||||
#define SW6_CS14 0x67
|
||||
#define SW6_CS15 0x68
|
||||
#define SW6_CS16 0x69
|
||||
#define SW6_CS17 0x6A
|
||||
#define SW6_CS18 0x6B
|
||||
|
||||
#define SW7_CS1 0x6C
|
||||
#define SW7_CS2 0x6D
|
||||
#define SW7_CS3 0x6E
|
||||
#define SW7_CS4 0x6F
|
||||
#define SW7_CS5 0x70
|
||||
#define SW7_CS6 0x71
|
||||
#define SW7_CS7 0x72
|
||||
#define SW7_CS8 0x73
|
||||
#define SW7_CS9 0x74
|
||||
#define SW7_CS10 0x75
|
||||
#define SW7_CS11 0x76
|
||||
#define SW7_CS12 0x77
|
||||
#define SW7_CS13 0x78
|
||||
#define SW7_CS14 0x79
|
||||
#define SW7_CS15 0x7A
|
||||
#define SW7_CS16 0x7B
|
||||
#define SW7_CS17 0x7C
|
||||
#define SW7_CS18 0x7D
|
||||
|
||||
#define SW8_CS1 0x7E
|
||||
#define SW8_CS2 0x7F
|
||||
#define SW8_CS3 0x80
|
||||
#define SW8_CS4 0x81
|
||||
#define SW8_CS5 0x82
|
||||
#define SW8_CS6 0x83
|
||||
#define SW8_CS7 0x84
|
||||
#define SW8_CS8 0x85
|
||||
#define SW8_CS9 0x86
|
||||
#define SW8_CS10 0x87
|
||||
#define SW8_CS11 0x88
|
||||
#define SW8_CS12 0x89
|
||||
#define SW8_CS13 0x8A
|
||||
#define SW8_CS14 0x8B
|
||||
#define SW8_CS15 0x8C
|
||||
#define SW8_CS16 0x8D
|
||||
#define SW8_CS17 0x8E
|
||||
#define SW8_CS18 0x8F
|
||||
|
||||
#define SW9_CS1 0x90
|
||||
#define SW9_CS2 0x91
|
||||
#define SW9_CS3 0x92
|
||||
#define SW9_CS4 0x93
|
||||
#define SW9_CS5 0x94
|
||||
#define SW9_CS6 0x95
|
||||
#define SW9_CS7 0x96
|
||||
#define SW9_CS8 0x97
|
||||
#define SW9_CS9 0x98
|
||||
#define SW9_CS10 0x99
|
||||
#define SW9_CS11 0x9A
|
||||
#define SW9_CS12 0x9B
|
||||
#define SW9_CS13 0x9C
|
||||
#define SW9_CS14 0x9D
|
||||
#define SW9_CS15 0x9E
|
||||
#define SW9_CS16 0x9F
|
||||
#define SW9_CS17 0xA0
|
||||
#define SW9_CS18 0xA1
|
||||
|
||||
#define SW10_CS1 0xA2
|
||||
#define SW10_CS2 0xA3
|
||||
#define SW10_CS3 0xA4
|
||||
#define SW10_CS4 0xA5
|
||||
#define SW10_CS5 0xA6
|
||||
#define SW10_CS6 0xA7
|
||||
#define SW10_CS7 0xA8
|
||||
#define SW10_CS8 0xA9
|
||||
#define SW10_CS9 0xAA
|
||||
#define SW10_CS10 0xAB
|
||||
#define SW10_CS11 0xAC
|
||||
#define SW10_CS12 0xAD
|
||||
#define SW10_CS13 0xAE
|
||||
#define SW10_CS14 0xAF
|
||||
#define SW10_CS15 0xB0
|
||||
#define SW10_CS16 0xB1
|
||||
#define SW10_CS17 0xB2
|
||||
#define SW10_CS18 0xB3
|
||||
|
||||
#define SW11_CS1 0xB4
|
||||
#define SW11_CS2 0xB5
|
||||
#define SW11_CS3 0xB6
|
||||
#define SW11_CS4 0xB7
|
||||
#define SW11_CS5 0xB8
|
||||
#define SW11_CS6 0xB9
|
||||
#define SW11_CS7 0xBA
|
||||
#define SW11_CS8 0xBB
|
||||
#define SW11_CS9 0xBC
|
||||
#define SW11_CS10 0xBD
|
||||
#define SW11_CS11 0xBE
|
||||
#define SW11_CS12 0xBF
|
||||
#define SW11_CS13 0xC0
|
||||
#define SW11_CS14 0xC1
|
||||
#define SW11_CS15 0xC2
|
||||
#define SW11_CS16 0xC3
|
||||
#define SW11_CS17 0xC4
|
||||
#define SW11_CS18 0xC5
|
||||
|
||||
#define SW12_CS1 0xC6
|
||||
#define SW12_CS2 0xC7
|
||||
#define SW12_CS3 0xC8
|
||||
#define SW12_CS4 0xC9
|
||||
#define SW12_CS5 0xCA
|
||||
#define SW12_CS6 0xCB
|
||||
#define SW12_CS7 0xCC
|
||||
#define SW12_CS8 0xCD
|
||||
#define SW12_CS9 0xCE
|
||||
#define SW12_CS10 0xCF
|
||||
#define SW12_CS11 0xD0
|
||||
#define SW12_CS12 0xD1
|
||||
#define SW12_CS13 0xD2
|
||||
#define SW12_CS14 0xD3
|
||||
#define SW12_CS15 0xD4
|
||||
#define SW12_CS16 0xD5
|
||||
#define SW12_CS17 0xD6
|
||||
#define SW12_CS18 0xD7
|
||||
|
||||
// DEPRECATED - DO NOT USE
|
||||
|
||||
#define CS1_SW1 SW1_CS1
|
||||
#define CS2_SW1 SW1_CS2
|
||||
#define CS3_SW1 SW1_CS3
|
||||
#define CS4_SW1 SW1_CS4
|
||||
#define CS5_SW1 SW1_CS5
|
||||
#define CS6_SW1 SW1_CS6
|
||||
#define CS7_SW1 SW1_CS7
|
||||
#define CS8_SW1 SW1_CS8
|
||||
#define CS9_SW1 SW1_CS9
|
||||
#define CS10_SW1 SW1_CS10
|
||||
#define CS11_SW1 SW1_CS11
|
||||
#define CS12_SW1 SW1_CS12
|
||||
#define CS13_SW1 SW1_CS13
|
||||
#define CS14_SW1 SW1_CS14
|
||||
#define CS15_SW1 SW1_CS15
|
||||
#define CS16_SW1 SW1_CS16
|
||||
#define CS17_SW1 SW1_CS17
|
||||
#define CS18_SW1 SW1_CS18
|
||||
|
||||
#define CS1_SW2 SW2_CS1
|
||||
#define CS2_SW2 SW2_CS2
|
||||
#define CS3_SW2 SW2_CS3
|
||||
#define CS4_SW2 SW2_CS4
|
||||
#define CS5_SW2 SW2_CS5
|
||||
#define CS6_SW2 SW2_CS6
|
||||
#define CS7_SW2 SW2_CS7
|
||||
#define CS8_SW2 SW2_CS8
|
||||
#define CS9_SW2 SW2_CS9
|
||||
#define CS10_SW2 SW2_CS10
|
||||
#define CS11_SW2 SW2_CS11
|
||||
#define CS12_SW2 SW2_CS12
|
||||
#define CS13_SW2 SW2_CS13
|
||||
#define CS14_SW2 SW2_CS14
|
||||
#define CS15_SW2 SW2_CS15
|
||||
#define CS16_SW2 SW2_CS16
|
||||
#define CS17_SW2 SW2_CS17
|
||||
#define CS18_SW2 SW2_CS18
|
||||
|
||||
#define CS1_SW3 SW3_CS1
|
||||
#define CS2_SW3 SW3_CS2
|
||||
#define CS3_SW3 SW3_CS3
|
||||
#define CS4_SW3 SW3_CS4
|
||||
#define CS5_SW3 SW3_CS5
|
||||
#define CS6_SW3 SW3_CS6
|
||||
#define CS7_SW3 SW3_CS7
|
||||
#define CS8_SW3 SW3_CS8
|
||||
#define CS9_SW3 SW3_CS9
|
||||
#define CS10_SW3 SW3_CS10
|
||||
#define CS11_SW3 SW3_CS11
|
||||
#define CS12_SW3 SW3_CS12
|
||||
#define CS13_SW3 SW3_CS13
|
||||
#define CS14_SW3 SW3_CS14
|
||||
#define CS15_SW3 SW3_CS15
|
||||
#define CS16_SW3 SW3_CS16
|
||||
#define CS17_SW3 SW3_CS17
|
||||
#define CS18_SW3 SW3_CS18
|
||||
|
||||
#define CS1_SW4 SW4_CS1
|
||||
#define CS2_SW4 SW4_CS2
|
||||
#define CS3_SW4 SW4_CS3
|
||||
#define CS4_SW4 SW4_CS4
|
||||
#define CS5_SW4 SW4_CS5
|
||||
#define CS6_SW4 SW4_CS6
|
||||
#define CS7_SW4 SW4_CS7
|
||||
#define CS8_SW4 SW4_CS8
|
||||
#define CS9_SW4 SW4_CS9
|
||||
#define CS10_SW4 SW4_CS10
|
||||
#define CS11_SW4 SW4_CS11
|
||||
#define CS12_SW4 SW4_CS12
|
||||
#define CS13_SW4 SW4_CS13
|
||||
#define CS14_SW4 SW4_CS14
|
||||
#define CS15_SW4 SW4_CS15
|
||||
#define CS16_SW4 SW4_CS16
|
||||
#define CS17_SW4 SW4_CS17
|
||||
#define CS18_SW4 SW4_CS18
|
||||
|
||||
#define CS1_SW5 SW5_CS1
|
||||
#define CS2_SW5 SW5_CS2
|
||||
#define CS3_SW5 SW5_CS3
|
||||
#define CS4_SW5 SW5_CS4
|
||||
#define CS5_SW5 SW5_CS5
|
||||
#define CS6_SW5 SW5_CS6
|
||||
#define CS7_SW5 SW5_CS7
|
||||
#define CS8_SW5 SW5_CS8
|
||||
#define CS9_SW5 SW5_CS9
|
||||
#define CS10_SW5 SW5_CS10
|
||||
#define CS11_SW5 SW5_CS11
|
||||
#define CS12_SW5 SW5_CS12
|
||||
#define CS13_SW5 SW5_CS13
|
||||
#define CS14_SW5 SW5_CS14
|
||||
#define CS15_SW5 SW5_CS15
|
||||
#define CS16_SW5 SW5_CS16
|
||||
#define CS17_SW5 SW5_CS17
|
||||
#define CS18_SW5 SW5_CS18
|
||||
|
||||
#define CS1_SW6 SW6_CS1
|
||||
#define CS2_SW6 SW6_CS2
|
||||
#define CS3_SW6 SW6_CS3
|
||||
#define CS4_SW6 SW6_CS4
|
||||
#define CS5_SW6 SW6_CS5
|
||||
#define CS6_SW6 SW6_CS6
|
||||
#define CS7_SW6 SW6_CS7
|
||||
#define CS8_SW6 SW6_CS8
|
||||
#define CS9_SW6 SW6_CS9
|
||||
#define CS10_SW6 SW6_CS10
|
||||
#define CS11_SW6 SW6_CS11
|
||||
#define CS12_SW6 SW6_CS12
|
||||
#define CS13_SW6 SW6_CS13
|
||||
#define CS14_SW6 SW6_CS14
|
||||
#define CS15_SW6 SW6_CS15
|
||||
#define CS16_SW6 SW6_CS16
|
||||
#define CS17_SW6 SW6_CS17
|
||||
#define CS18_SW6 SW6_CS18
|
||||
|
||||
#define CS1_SW7 SW7_CS1
|
||||
#define CS2_SW7 SW7_CS2
|
||||
#define CS3_SW7 SW7_CS3
|
||||
#define CS4_SW7 SW7_CS4
|
||||
#define CS5_SW7 SW7_CS5
|
||||
#define CS6_SW7 SW7_CS6
|
||||
#define CS7_SW7 SW7_CS7
|
||||
#define CS8_SW7 SW7_CS8
|
||||
#define CS9_SW7 SW7_CS9
|
||||
#define CS10_SW7 SW7_CS10
|
||||
#define CS11_SW7 SW7_CS11
|
||||
#define CS12_SW7 SW7_CS12
|
||||
#define CS13_SW7 SW7_CS13
|
||||
#define CS14_SW7 SW7_CS14
|
||||
#define CS15_SW7 SW7_CS15
|
||||
#define CS16_SW7 SW7_CS16
|
||||
#define CS17_SW7 SW7_CS17
|
||||
#define CS18_SW7 SW7_CS18
|
||||
|
||||
#define CS1_SW8 SW8_CS1
|
||||
#define CS2_SW8 SW8_CS2
|
||||
#define CS3_SW8 SW8_CS3
|
||||
#define CS4_SW8 SW8_CS4
|
||||
#define CS5_SW8 SW8_CS5
|
||||
#define CS6_SW8 SW8_CS6
|
||||
#define CS7_SW8 SW8_CS7
|
||||
#define CS8_SW8 SW8_CS8
|
||||
#define CS9_SW8 SW8_CS9
|
||||
#define CS10_SW8 SW8_CS10
|
||||
#define CS11_SW8 SW8_CS11
|
||||
#define CS12_SW8 SW8_CS12
|
||||
#define CS13_SW8 SW8_CS13
|
||||
#define CS14_SW8 SW8_CS14
|
||||
#define CS15_SW8 SW8_CS15
|
||||
#define CS16_SW8 SW8_CS16
|
||||
#define CS17_SW8 SW8_CS17
|
||||
#define CS18_SW8 SW8_CS18
|
||||
|
||||
#define CS1_SW9 SW9_CS1
|
||||
#define CS2_SW9 SW9_CS2
|
||||
#define CS3_SW9 SW9_CS3
|
||||
#define CS4_SW9 SW9_CS4
|
||||
#define CS5_SW9 SW9_CS5
|
||||
#define CS6_SW9 SW9_CS6
|
||||
#define CS7_SW9 SW9_CS7
|
||||
#define CS8_SW9 SW9_CS8
|
||||
#define CS9_SW9 SW9_CS9
|
||||
#define CS10_SW9 SW9_CS10
|
||||
#define CS11_SW9 SW9_CS11
|
||||
#define CS12_SW9 SW9_CS12
|
||||
#define CS13_SW9 SW9_CS13
|
||||
#define CS14_SW9 SW9_CS14
|
||||
#define CS15_SW9 SW9_CS15
|
||||
#define CS16_SW9 SW9_CS16
|
||||
#define CS17_SW9 SW9_CS17
|
||||
#define CS18_SW9 SW9_CS18
|
||||
|
||||
#define CS1_SW10 SW10_CS1
|
||||
#define CS2_SW10 SW10_CS2
|
||||
#define CS3_SW10 SW10_CS3
|
||||
#define CS4_SW10 SW10_CS4
|
||||
#define CS5_SW10 SW10_CS5
|
||||
#define CS6_SW10 SW10_CS6
|
||||
#define CS7_SW10 SW10_CS7
|
||||
#define CS8_SW10 SW10_CS8
|
||||
#define CS9_SW10 SW10_CS9
|
||||
#define CS10_SW10 SW10_CS10
|
||||
#define CS11_SW10 SW10_CS11
|
||||
#define CS12_SW10 SW10_CS12
|
||||
#define CS13_SW10 SW10_CS13
|
||||
#define CS14_SW10 SW10_CS14
|
||||
#define CS15_SW10 SW10_CS15
|
||||
#define CS16_SW10 SW10_CS16
|
||||
#define CS17_SW10 SW10_CS17
|
||||
#define CS18_SW10 SW10_CS18
|
||||
|
||||
#define CS1_SW11 SW11_CS1
|
||||
#define CS2_SW11 SW11_CS2
|
||||
#define CS3_SW11 SW11_CS3
|
||||
#define CS4_SW11 SW11_CS4
|
||||
#define CS5_SW11 SW11_CS5
|
||||
#define CS6_SW11 SW11_CS6
|
||||
#define CS7_SW11 SW11_CS7
|
||||
#define CS8_SW11 SW11_CS8
|
||||
#define CS9_SW11 SW11_CS9
|
||||
#define CS10_SW11 SW11_CS10
|
||||
#define CS11_SW11 SW11_CS11
|
||||
#define CS12_SW11 SW11_CS12
|
||||
#define CS13_SW11 SW11_CS13
|
||||
#define CS14_SW11 SW11_CS14
|
||||
#define CS15_SW11 SW11_CS15
|
||||
#define CS16_SW11 SW11_CS16
|
||||
#define CS17_SW11 SW11_CS17
|
||||
#define CS18_SW11 SW11_CS18
|
||||
|
||||
#define CS1_SW12 SW12_CS1
|
||||
#define CS2_SW12 SW12_CS2
|
||||
#define CS3_SW12 SW12_CS3
|
||||
#define CS4_SW12 SW12_CS4
|
||||
#define CS5_SW12 SW12_CS5
|
||||
#define CS6_SW12 SW12_CS6
|
||||
#define CS7_SW12 SW12_CS7
|
||||
#define CS8_SW12 SW12_CS8
|
||||
#define CS9_SW12 SW12_CS9
|
||||
#define CS10_SW12 SW12_CS10
|
||||
#define CS11_SW12 SW12_CS11
|
||||
#define CS12_SW12 SW12_CS12
|
||||
#define CS13_SW12 SW12_CS13
|
||||
#define CS14_SW12 SW12_CS14
|
||||
#define CS15_SW12 SW12_CS15
|
||||
#define CS16_SW12 SW12_CS16
|
||||
#define CS17_SW12 SW12_CS17
|
||||
#define CS18_SW12 SW12_CS18
|
||||
|
|
|
@ -13,9 +13,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "is31fl3218.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "is31fl3218-mono.h"
|
||||
#include "i2c_master.h"
|
||||
#include "gpio.h"
|
||||
|
||||
#define IS31FL3218_PWM_REGISTER_COUNT 18
|
||||
#define IS31FL3218_LED_CONTROL_REGISTER_COUNT 3
|
||||
|
@ -28,44 +29,49 @@
|
|||
# define IS31FL3218_I2C_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
// Reusable buffer for transfers
|
||||
uint8_t g_twi_transfer_buffer[20];
|
||||
typedef struct is31fl3218_driver_t {
|
||||
uint8_t pwm_buffer[IS31FL3218_PWM_REGISTER_COUNT];
|
||||
bool pwm_buffer_dirty;
|
||||
uint8_t led_control_buffer[IS31FL3218_LED_CONTROL_REGISTER_COUNT];
|
||||
bool led_control_buffer_dirty;
|
||||
} PACKED is31fl3218_driver_t;
|
||||
|
||||
// IS31FL3218 has 18 PWM outputs and a fixed I2C address, so no chaining.
|
||||
uint8_t g_pwm_buffer[IS31FL3218_PWM_REGISTER_COUNT];
|
||||
bool g_pwm_buffer_update_required = false;
|
||||
|
||||
uint8_t g_led_control_registers[IS31FL3218_LED_CONTROL_REGISTER_COUNT] = {0};
|
||||
bool g_led_control_registers_update_required = false;
|
||||
is31fl3218_driver_t driver_buffers = {
|
||||
.pwm_buffer = {0},
|
||||
.pwm_buffer_dirty = false,
|
||||
.led_control_buffer = {0},
|
||||
.led_control_buffer_dirty = false,
|
||||
};
|
||||
|
||||
void is31fl3218_write_register(uint8_t reg, uint8_t data) {
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
#if IS31FL3218_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3218_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 2, IS31FL3218_I2C_TIMEOUT) == 0) break;
|
||||
if (i2c_write_register(IS31FL3218_I2C_ADDRESS << 1, reg, &data, 1, IS31FL3218_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 2, IS31FL3218_I2C_TIMEOUT);
|
||||
i2c_write_register(IS31FL3218_I2C_ADDRESS << 1, reg, &data, 1, IS31FL3218_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3218_write_pwm_buffer(uint8_t *pwm_buffer) {
|
||||
g_twi_transfer_buffer[0] = IS31FL3218_REG_PWM;
|
||||
memcpy(g_twi_transfer_buffer + 1, pwm_buffer, 18);
|
||||
|
||||
void is31fl3218_write_pwm_buffer(void) {
|
||||
#if IS31FL3218_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3218_I2C_PERSISTENCE; i++) {
|
||||
i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 19, IS31FL3218_I2C_TIMEOUT);
|
||||
if (i2c_write_register(IS31FL3218_I2C_ADDRESS << 1, IS31FL3218_REG_PWM, driver_buffers.pwm_buffer, 18, IS31FL3218_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 19, IS31FL3218_I2C_TIMEOUT);
|
||||
i2c_write_register(IS31FL3218_I2C_ADDRESS << 1, IS31FL3218_REG_PWM, driver_buffers.pwm_buffer, 18, IS31FL3218_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3218_init(void) {
|
||||
i2c_init();
|
||||
|
||||
#if defined(IS31FL3218_SDB_PIN)
|
||||
gpio_set_pin_output(IS31FL3218_SDB_PIN);
|
||||
gpio_write_pin_high(IS31FL3218_SDB_PIN);
|
||||
#endif
|
||||
|
||||
// In case we ever want to reinitialize (?)
|
||||
is31fl3218_write_register(IS31FL3218_REG_RESET, 0x00);
|
||||
|
||||
|
@ -94,14 +100,17 @@ void is31fl3218_init(void) {
|
|||
|
||||
void is31fl3218_set_value(int index, uint8_t value) {
|
||||
is31fl3218_led_t led;
|
||||
|
||||
if (index >= 0 && index < IS31FL3218_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3218_leds[index]), sizeof(led));
|
||||
|
||||
if (driver_buffers.pwm_buffer[led.v] == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
driver_buffers.pwm_buffer[led.v] = value;
|
||||
driver_buffers.pwm_buffer_dirty = true;
|
||||
}
|
||||
if (g_pwm_buffer[led.v - IS31FL3218_REG_PWM] == value) {
|
||||
return;
|
||||
}
|
||||
g_pwm_buffer[led.v - IS31FL3218_REG_PWM] = value;
|
||||
g_pwm_buffer_update_required = true;
|
||||
}
|
||||
|
||||
void is31fl3218_set_value_all(uint8_t value) {
|
||||
|
@ -114,34 +123,34 @@ void is31fl3218_set_led_control_register(uint8_t index, bool value) {
|
|||
is31fl3218_led_t led;
|
||||
memcpy_P(&led, (&g_is31fl3218_leds[index]), sizeof(led));
|
||||
|
||||
uint8_t control_register = (led.v - IS31FL3218_REG_PWM) / 6;
|
||||
uint8_t bit_value = (led.v - IS31FL3218_REG_PWM) % 6;
|
||||
uint8_t control_register = led.v / 6;
|
||||
uint8_t bit_value = led.v % 6;
|
||||
|
||||
if (value) {
|
||||
g_led_control_registers[control_register] |= (1 << bit_value);
|
||||
driver_buffers.led_control_buffer[control_register] |= (1 << bit_value);
|
||||
} else {
|
||||
g_led_control_registers[control_register] &= ~(1 << bit_value);
|
||||
driver_buffers.led_control_buffer[control_register] &= ~(1 << bit_value);
|
||||
}
|
||||
|
||||
g_led_control_registers_update_required = true;
|
||||
driver_buffers.led_control_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3218_update_pwm_buffers(void) {
|
||||
if (g_pwm_buffer_update_required) {
|
||||
is31fl3218_write_pwm_buffer(g_pwm_buffer);
|
||||
if (driver_buffers.pwm_buffer_dirty) {
|
||||
is31fl3218_write_pwm_buffer();
|
||||
// Load PWM registers and LED Control register data
|
||||
is31fl3218_write_register(IS31FL3218_REG_UPDATE, 0x01);
|
||||
|
||||
g_pwm_buffer_update_required = false;
|
||||
driver_buffers.pwm_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3218_update_led_control_registers(void) {
|
||||
if (g_led_control_registers_update_required) {
|
||||
for (int i = 0; i < IS31FL3218_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3218_write_register(IS31FL3218_REG_LED_CONTROL_1 + i, g_led_control_registers[i]);
|
||||
if (driver_buffers.led_control_buffer_dirty) {
|
||||
for (uint8_t i = 0; i < IS31FL3218_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3218_write_register(IS31FL3218_REG_LED_CONTROL_1 + i, driver_buffers.led_control_buffer[i]);
|
||||
}
|
||||
|
||||
g_led_control_registers_update_required = false;
|
||||
driver_buffers.led_control_buffer_dirty = false;
|
||||
}
|
||||
}
|
|
@ -43,6 +43,8 @@ extern const is31fl3218_led_t PROGMEM g_is31fl3218_leds[IS31FL3218_LED_COUNT];
|
|||
|
||||
void is31fl3218_init(void);
|
||||
|
||||
void is31fl3218_write_register(uint8_t reg, uint8_t data);
|
||||
|
||||
void is31fl3218_set_value(int index, uint8_t value);
|
||||
|
||||
void is31fl3218_set_value_all(uint8_t value);
|
||||
|
@ -53,21 +55,21 @@ void is31fl3218_update_pwm_buffers(void);
|
|||
|
||||
void is31fl3218_update_led_control_registers(void);
|
||||
|
||||
#define OUT1 0x01
|
||||
#define OUT2 0x02
|
||||
#define OUT3 0x03
|
||||
#define OUT4 0x04
|
||||
#define OUT5 0x05
|
||||
#define OUT6 0x06
|
||||
#define OUT7 0x07
|
||||
#define OUT8 0x08
|
||||
#define OUT9 0x09
|
||||
#define OUT10 0x0A
|
||||
#define OUT11 0x0B
|
||||
#define OUT12 0x0C
|
||||
#define OUT13 0x0D
|
||||
#define OUT14 0x0E
|
||||
#define OUT15 0x0F
|
||||
#define OUT16 0x10
|
||||
#define OUT17 0x11
|
||||
#define OUT18 0x12
|
||||
#define OUT1 0x00
|
||||
#define OUT2 0x01
|
||||
#define OUT3 0x02
|
||||
#define OUT4 0x03
|
||||
#define OUT5 0x04
|
||||
#define OUT6 0x05
|
||||
#define OUT7 0x06
|
||||
#define OUT8 0x07
|
||||
#define OUT9 0x08
|
||||
#define OUT10 0x09
|
||||
#define OUT11 0x0A
|
||||
#define OUT12 0x0B
|
||||
#define OUT13 0x0C
|
||||
#define OUT14 0x0D
|
||||
#define OUT15 0x0E
|
||||
#define OUT16 0x0F
|
||||
#define OUT17 0x10
|
||||
#define OUT18 0x11
|
|
@ -13,9 +13,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "is31fl3218.h"
|
||||
#include <string.h>
|
||||
#include "i2c_master.h"
|
||||
#include "gpio.h"
|
||||
|
||||
#define IS31FL3218_PWM_REGISTER_COUNT 18
|
||||
#define IS31FL3218_LED_CONTROL_REGISTER_COUNT 3
|
||||
|
@ -28,44 +29,49 @@
|
|||
# define IS31FL3218_I2C_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
// Reusable buffer for transfers
|
||||
uint8_t g_twi_transfer_buffer[20];
|
||||
typedef struct is31fl3218_driver_t {
|
||||
uint8_t pwm_buffer[IS31FL3218_PWM_REGISTER_COUNT];
|
||||
bool pwm_buffer_dirty;
|
||||
uint8_t led_control_buffer[IS31FL3218_LED_CONTROL_REGISTER_COUNT];
|
||||
bool led_control_buffer_dirty;
|
||||
} PACKED is31fl3218_driver_t;
|
||||
|
||||
// IS31FL3218 has 18 PWM outputs and a fixed I2C address, so no chaining.
|
||||
uint8_t g_pwm_buffer[IS31FL3218_PWM_REGISTER_COUNT];
|
||||
bool g_pwm_buffer_update_required = false;
|
||||
|
||||
uint8_t g_led_control_registers[IS31FL3218_LED_CONTROL_REGISTER_COUNT] = {0};
|
||||
bool g_led_control_registers_update_required = false;
|
||||
is31fl3218_driver_t driver_buffers = {
|
||||
.pwm_buffer = {0},
|
||||
.pwm_buffer_dirty = false,
|
||||
.led_control_buffer = {0},
|
||||
.led_control_buffer_dirty = false,
|
||||
};
|
||||
|
||||
void is31fl3218_write_register(uint8_t reg, uint8_t data) {
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
#if IS31FL3218_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3218_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 2, IS31FL3218_I2C_TIMEOUT) == 0) break;
|
||||
if (i2c_write_register(IS31FL3218_I2C_ADDRESS << 1, reg, &data, 1, IS31FL3218_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 2, IS31FL3218_I2C_TIMEOUT);
|
||||
i2c_write_register(IS31FL3218_I2C_ADDRESS << 1, reg, &data, 1, IS31FL3218_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3218_write_pwm_buffer(uint8_t *pwm_buffer) {
|
||||
g_twi_transfer_buffer[0] = IS31FL3218_REG_PWM;
|
||||
memcpy(g_twi_transfer_buffer + 1, pwm_buffer, 18);
|
||||
|
||||
void is31fl3218_write_pwm_buffer(void) {
|
||||
#if IS31FL3218_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3218_I2C_PERSISTENCE; i++) {
|
||||
i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 19, IS31FL3218_I2C_TIMEOUT);
|
||||
if (i2c_write_register(IS31FL3218_I2C_ADDRESS << 1, IS31FL3218_REG_PWM, driver_buffers.pwm_buffer, 18, IS31FL3218_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 19, IS31FL3218_I2C_TIMEOUT);
|
||||
i2c_write_register(IS31FL3218_I2C_ADDRESS << 1, IS31FL3218_REG_PWM, driver_buffers.pwm_buffer, 18, IS31FL3218_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3218_init(void) {
|
||||
i2c_init();
|
||||
|
||||
#if defined(IS31FL3218_SDB_PIN)
|
||||
gpio_set_pin_output(IS31FL3218_SDB_PIN);
|
||||
gpio_write_pin_high(IS31FL3218_SDB_PIN);
|
||||
#endif
|
||||
|
||||
// In case we ever want to reinitialize (?)
|
||||
is31fl3218_write_register(IS31FL3218_REG_RESET, 0x00);
|
||||
|
||||
|
@ -94,16 +100,19 @@ void is31fl3218_init(void) {
|
|||
|
||||
void is31fl3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
is31fl3218_led_t led;
|
||||
|
||||
if (index >= 0 && index < IS31FL3218_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3218_leds[index]), sizeof(led));
|
||||
|
||||
if (driver_buffers.pwm_buffer[led.r] == red && driver_buffers.pwm_buffer[led.g] == green && driver_buffers.pwm_buffer[led.b] == blue) {
|
||||
return;
|
||||
}
|
||||
|
||||
driver_buffers.pwm_buffer[led.r] = red;
|
||||
driver_buffers.pwm_buffer[led.g] = green;
|
||||
driver_buffers.pwm_buffer[led.b] = blue;
|
||||
driver_buffers.pwm_buffer_dirty = true;
|
||||
}
|
||||
if (g_pwm_buffer[led.r - IS31FL3218_REG_PWM] == red && g_pwm_buffer[led.g - IS31FL3218_REG_PWM] == green && g_pwm_buffer[led.b - IS31FL3218_REG_PWM] == blue) {
|
||||
return;
|
||||
}
|
||||
g_pwm_buffer[led.r - IS31FL3218_REG_PWM] = red;
|
||||
g_pwm_buffer[led.g - IS31FL3218_REG_PWM] = green;
|
||||
g_pwm_buffer[led.b - IS31FL3218_REG_PWM] = blue;
|
||||
g_pwm_buffer_update_required = true;
|
||||
}
|
||||
|
||||
void is31fl3218_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
|
@ -116,48 +125,48 @@ void is31fl3218_set_led_control_register(uint8_t index, bool red, bool green, bo
|
|||
is31fl3218_led_t led;
|
||||
memcpy_P(&led, (&g_is31fl3218_leds[index]), sizeof(led));
|
||||
|
||||
uint8_t control_register_r = (led.r - IS31FL3218_REG_PWM) / 6;
|
||||
uint8_t control_register_g = (led.g - IS31FL3218_REG_PWM) / 6;
|
||||
uint8_t control_register_b = (led.b - IS31FL3218_REG_PWM) / 6;
|
||||
uint8_t bit_r = (led.r - IS31FL3218_REG_PWM) % 6;
|
||||
uint8_t bit_g = (led.g - IS31FL3218_REG_PWM) % 6;
|
||||
uint8_t bit_b = (led.b - IS31FL3218_REG_PWM) % 6;
|
||||
uint8_t control_register_r = led.r / 6;
|
||||
uint8_t control_register_g = led.g / 6;
|
||||
uint8_t control_register_b = led.b / 6;
|
||||
uint8_t bit_r = led.r % 6;
|
||||
uint8_t bit_g = led.g % 6;
|
||||
uint8_t bit_b = led.b % 6;
|
||||
|
||||
if (red) {
|
||||
g_led_control_registers[control_register_r] |= (1 << bit_r);
|
||||
driver_buffers.led_control_buffer[control_register_r] |= (1 << bit_r);
|
||||
} else {
|
||||
g_led_control_registers[control_register_r] &= ~(1 << bit_r);
|
||||
driver_buffers.led_control_buffer[control_register_r] &= ~(1 << bit_r);
|
||||
}
|
||||
if (green) {
|
||||
g_led_control_registers[control_register_g] |= (1 << bit_g);
|
||||
driver_buffers.led_control_buffer[control_register_g] |= (1 << bit_g);
|
||||
} else {
|
||||
g_led_control_registers[control_register_g] &= ~(1 << bit_g);
|
||||
driver_buffers.led_control_buffer[control_register_g] &= ~(1 << bit_g);
|
||||
}
|
||||
if (blue) {
|
||||
g_led_control_registers[control_register_b] |= (1 << bit_b);
|
||||
driver_buffers.led_control_buffer[control_register_b] |= (1 << bit_b);
|
||||
} else {
|
||||
g_led_control_registers[control_register_b] &= ~(1 << bit_b);
|
||||
driver_buffers.led_control_buffer[control_register_b] &= ~(1 << bit_b);
|
||||
}
|
||||
|
||||
g_led_control_registers_update_required = true;
|
||||
driver_buffers.led_control_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3218_update_pwm_buffers(void) {
|
||||
if (g_pwm_buffer_update_required) {
|
||||
is31fl3218_write_pwm_buffer(g_pwm_buffer);
|
||||
if (driver_buffers.pwm_buffer_dirty) {
|
||||
is31fl3218_write_pwm_buffer();
|
||||
// Load PWM registers and LED Control register data
|
||||
is31fl3218_write_register(IS31FL3218_REG_UPDATE, 0x01);
|
||||
|
||||
g_pwm_buffer_update_required = false;
|
||||
driver_buffers.pwm_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3218_update_led_control_registers(void) {
|
||||
if (g_led_control_registers_update_required) {
|
||||
for (int i = 0; i < IS31FL3218_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3218_write_register(IS31FL3218_REG_LED_CONTROL_1 + i, g_led_control_registers[i]);
|
||||
if (driver_buffers.led_control_buffer_dirty) {
|
||||
for (uint8_t i = 0; i < IS31FL3218_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3218_write_register(IS31FL3218_REG_LED_CONTROL_1 + i, driver_buffers.led_control_buffer[i]);
|
||||
}
|
||||
|
||||
g_led_control_registers_update_required = false;
|
||||
driver_buffers.led_control_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@ extern const is31fl3218_led_t PROGMEM g_is31fl3218_leds[IS31FL3218_LED_COUNT];
|
|||
|
||||
void is31fl3218_init(void);
|
||||
|
||||
void is31fl3218_write_register(uint8_t reg, uint8_t data);
|
||||
|
||||
void is31fl3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
||||
void is31fl3218_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
@ -55,21 +57,21 @@ void is31fl3218_update_pwm_buffers(void);
|
|||
|
||||
void is31fl3218_update_led_control_registers(void);
|
||||
|
||||
#define OUT1 0x01
|
||||
#define OUT2 0x02
|
||||
#define OUT3 0x03
|
||||
#define OUT4 0x04
|
||||
#define OUT5 0x05
|
||||
#define OUT6 0x06
|
||||
#define OUT7 0x07
|
||||
#define OUT8 0x08
|
||||
#define OUT9 0x09
|
||||
#define OUT10 0x0A
|
||||
#define OUT11 0x0B
|
||||
#define OUT12 0x0C
|
||||
#define OUT13 0x0D
|
||||
#define OUT14 0x0E
|
||||
#define OUT15 0x0F
|
||||
#define OUT16 0x10
|
||||
#define OUT17 0x11
|
||||
#define OUT18 0x12
|
||||
#define OUT1 0x00
|
||||
#define OUT2 0x01
|
||||
#define OUT3 0x02
|
||||
#define OUT4 0x03
|
||||
#define OUT5 0x04
|
||||
#define OUT6 0x05
|
||||
#define OUT7 0x06
|
||||
#define OUT8 0x07
|
||||
#define OUT9 0x08
|
||||
#define OUT10 0x09
|
||||
#define OUT11 0x0A
|
||||
#define OUT12 0x0B
|
||||
#define OUT13 0x0C
|
||||
#define OUT14 0x0D
|
||||
#define OUT15 0x0E
|
||||
#define OUT16 0x0F
|
||||
#define OUT17 0x10
|
||||
#define OUT18 0x11
|
||||
|
|
213
drivers/led/issi/is31fl3729-mono.c
Normal file
213
drivers/led/issi/is31fl3729-mono.c
Normal file
|
@ -0,0 +1,213 @@
|
|||
/* Copyright 2024 HorrorTroll <https://github.com/HorrorTroll>
|
||||
* Copyright 2024 Harrison Chan (Xelus)
|
||||
* Copyright 2024 Dimitris Mantzouranis <d3xter93@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "is31fl3729-mono.h"
|
||||
#include "i2c_master.h"
|
||||
#include "gpio.h"
|
||||
#include "wait.h"
|
||||
|
||||
#define IS31FL3729_PWM_REGISTER_COUNT 143
|
||||
#define IS31FL3729_SCALING_REGISTER_COUNT 16
|
||||
|
||||
#ifndef IS31FL3729_I2C_TIMEOUT
|
||||
# define IS31FL3729_I2C_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3729_I2C_PERSISTENCE
|
||||
# define IS31FL3729_I2C_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3729_CONFIGURATION
|
||||
# define IS31FL3729_CONFIGURATION IS31FL3729_CONFIG_SWS_15_9
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3729_GLOBAL_CURRENT
|
||||
# define IS31FL3729_GLOBAL_CURRENT 0x40
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3729_SW_PULLDOWN
|
||||
# define IS31FL3729_SW_PULLDOWN IS31FL3729_SW_PULLDOWN_2K_OHM_SW_OFF
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3729_CS_PULLUP
|
||||
# define IS31FL3729_CS_PULLUP IS31FL3729_CS_PULLUP_2K_OHM_CS_OFF
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3729_SPREAD_SPECTRUM
|
||||
# define IS31FL3729_SPREAD_SPECTRUM IS31FL3729_SPREAD_SPECTRUM_DISABLE
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3729_SPREAD_SPECTRUM_RANGE
|
||||
# define IS31FL3729_SPREAD_SPECTRUM_RANGE IS31FL3729_SPREAD_SPECTRUM_RANGE_5_PERCENT
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3729_SPREAD_SPECTRUM_CYCLE_TIME
|
||||
# define IS31FL3729_SPREAD_SPECTRUM_CYCLE_TIME IS31FL3729_SPREAD_SPECTRUM_CYCLE_TIME_1980_US
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3729_PWM_FREQUENCY
|
||||
# define IS31FL3729_PWM_FREQUENCY IS31FL3729_PWM_FREQUENCY_32K_HZ
|
||||
#endif
|
||||
|
||||
const uint8_t i2c_addresses[IS31FL3729_DRIVER_COUNT] = {
|
||||
IS31FL3729_I2C_ADDRESS_1,
|
||||
#ifdef IS31FL3729_I2C_ADDRESS_2
|
||||
IS31FL3729_I2C_ADDRESS_2,
|
||||
# ifdef IS31FL3729_I2C_ADDRESS_3
|
||||
IS31FL3729_I2C_ADDRESS_3,
|
||||
# ifdef IS31FL3729_I2C_ADDRESS_4
|
||||
IS31FL3729_I2C_ADDRESS_4,
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
// These buffers match the PWM & scaling registers.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
typedef struct is31fl3729_driver_t {
|
||||
uint8_t pwm_buffer[IS31FL3729_PWM_REGISTER_COUNT];
|
||||
bool pwm_buffer_dirty;
|
||||
uint8_t scaling_buffer[IS31FL3729_SCALING_REGISTER_COUNT];
|
||||
bool scaling_buffer_dirty;
|
||||
} PACKED is31fl3729_driver_t;
|
||||
|
||||
is31fl3729_driver_t driver_buffers[IS31FL3729_DRIVER_COUNT] = {{
|
||||
.pwm_buffer = {0},
|
||||
.pwm_buffer_dirty = false,
|
||||
.scaling_buffer = {0},
|
||||
.scaling_buffer_dirty = false,
|
||||
}};
|
||||
|
||||
void is31fl3729_write_register(uint8_t index, uint8_t reg, uint8_t data) {
|
||||
#if IS31FL3729_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3729_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3729_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3729_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3729_write_pwm_buffer(uint8_t index) {
|
||||
// Transmit PWM registers in 11 transfers of 13 bytes.
|
||||
|
||||
// Iterate over the pwm_buffer contents at 13 byte intervals.
|
||||
for (uint8_t i = 0; i <= IS31FL3729_PWM_REGISTER_COUNT; i += 13) {
|
||||
#if IS31FL3729_I2C_PERSISTENCE > 0
|
||||
for (uint8_t j = 0; j < IS31FL3729_I2C_PERSISTENCE; j++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, IS31FL3729_REG_PWM + i, driver_buffers[index].pwm_buffer + i, 13, IS31FL3729_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, IS31FL3729_REG_PWM + i, driver_buffers[index].pwm_buffer + i, 13, IS31FL3729_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3729_init_drivers(void) {
|
||||
i2c_init();
|
||||
|
||||
#if defined(IS31FL3729_SDB_PIN)
|
||||
gpio_set_pin_output(IS31FL3729_SDB_PIN);
|
||||
gpio_write_pin_high(IS31FL3729_SDB_PIN);
|
||||
#endif
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3729_DRIVER_COUNT; i++) {
|
||||
is31fl3729_init(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < IS31FL3729_LED_COUNT; i++) {
|
||||
is31fl3729_set_scaling_register(i, 0xFF);
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3729_DRIVER_COUNT; i++) {
|
||||
is31fl3729_update_scaling_registers(i);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3729_init(uint8_t index) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
|
||||
is31fl3729_write_register(index, IS31FL3729_REG_PULLDOWNUP, ((IS31FL3729_SW_PULLDOWN & 0b111) << 4) | (IS31FL3729_CS_PULLUP & 0b111));
|
||||
is31fl3729_write_register(index, IS31FL3729_REG_SPREAD_SPECTRUM, ((IS31FL3729_SPREAD_SPECTRUM & 0b1) << 4) | ((IS31FL3729_SPREAD_SPECTRUM_RANGE & 0b11) << 2) | (IS31FL3729_SPREAD_SPECTRUM_CYCLE_TIME & 0b11));
|
||||
is31fl3729_write_register(index, IS31FL3729_REG_PWM_FREQUENCY, IS31FL3729_PWM_FREQUENCY);
|
||||
is31fl3729_write_register(index, IS31FL3729_REG_GLOBAL_CURRENT, IS31FL3729_GLOBAL_CURRENT);
|
||||
is31fl3729_write_register(index, IS31FL3729_REG_CONFIGURATION, IS31FL3729_CONFIGURATION);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
wait_ms(10);
|
||||
}
|
||||
|
||||
void is31fl3729_set_value(int index, uint8_t value) {
|
||||
is31fl3729_led_t led;
|
||||
if (index >= 0 && index < IS31FL3729_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3729_leds[index]), sizeof(led));
|
||||
|
||||
if (driver_buffers[led.driver].pwm_buffer[led.v] == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
driver_buffers[led.driver].pwm_buffer[led.v] = value;
|
||||
driver_buffers[led.driver].pwm_buffer_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3729_set_value_all(uint8_t value) {
|
||||
for (int i = 0; i < IS31FL3729_LED_COUNT; i++) {
|
||||
is31fl3729_set_value(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3729_set_scaling_register(uint8_t index, uint8_t value) {
|
||||
is31fl3729_led_t led;
|
||||
memcpy_P(&led, (&g_is31fl3729_leds[index]), sizeof(led));
|
||||
|
||||
// need to do a bit of checking here since 3729 scaling is per CS pin.
|
||||
// not the usual per single LED key as per other ISSI drivers
|
||||
// only enable them, since they should be default disabled
|
||||
int cs_value = (led.v & 0x0F) - 1;
|
||||
|
||||
driver_buffers[led.driver].scaling_buffer[cs_value] = value;
|
||||
driver_buffers[led.driver].scaling_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3729_update_pwm_buffers(uint8_t index) {
|
||||
if (driver_buffers[index].pwm_buffer_dirty) {
|
||||
is31fl3729_write_pwm_buffer(index);
|
||||
|
||||
driver_buffers[index].pwm_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3729_update_scaling_registers(uint8_t index) {
|
||||
if (driver_buffers[index].scaling_buffer_dirty) {
|
||||
for (uint8_t i = 0; i < IS31FL3729_SCALING_REGISTER_COUNT; i++) {
|
||||
is31fl3729_write_register(index, IS31FL3729_REG_SCALING + i, driver_buffers[index].scaling_buffer[i]);
|
||||
}
|
||||
|
||||
driver_buffers[index].scaling_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3729_flush(void) {
|
||||
for (uint8_t i = 0; i < IS31FL3729_DRIVER_COUNT; i++) {
|
||||
is31fl3729_update_pwm_buffers(i);
|
||||
}
|
||||
}
|
278
drivers/led/issi/is31fl3729-mono.h
Normal file
278
drivers/led/issi/is31fl3729-mono.h
Normal file
|
@ -0,0 +1,278 @@
|
|||
/* Copyright 2024 HorrorTroll <https://github.com/HorrorTroll>
|
||||
* Copyright 2024 Harrison Chan (Xelus)
|
||||
* Copyright 2024 Dimitris Mantzouranis <d3xter93@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "progmem.h"
|
||||
#include "util.h"
|
||||
|
||||
#define IS31FL3729_REG_PWM 0x01
|
||||
#define IS31FL3729_REG_SCALING 0x90
|
||||
#define IS31FL3729_REG_CONFIGURATION 0xA0
|
||||
#define IS31FL3729_REG_GLOBAL_CURRENT 0xA1
|
||||
#define IS31FL3729_REG_PULLDOWNUP 0xB0
|
||||
#define IS31FL3729_REG_SPREAD_SPECTRUM 0xB1
|
||||
#define IS31FL3729_REG_PWM_FREQUENCY 0xB2
|
||||
#define IS31FL3729_REG_RESET 0xCF
|
||||
|
||||
#define IS31FL3729_I2C_ADDRESS_GND 0x34
|
||||
#define IS31FL3729_I2C_ADDRESS_SCL 0x35
|
||||
#define IS31FL3729_I2C_ADDRESS_SDA 0x36
|
||||
#define IS31FL3729_I2C_ADDRESS_VCC 0x37
|
||||
|
||||
#if defined(LED_MATRIX_IS31FL3729)
|
||||
# define IS31FL3729_LED_COUNT LED_MATRIX_LED_COUNT
|
||||
#endif
|
||||
|
||||
#if defined(IS31FL3729_I2C_ADDRESS_4)
|
||||
# define IS31FL3729_DRIVER_COUNT 4
|
||||
#elif defined(IS31FL3729_I2C_ADDRESS_3)
|
||||
# define IS31FL3729_DRIVER_COUNT 3
|
||||
#elif defined(IS31FL3729_I2C_ADDRESS_2)
|
||||
# define IS31FL3729_DRIVER_COUNT 2
|
||||
#elif defined(IS31FL3729_I2C_ADDRESS_1)
|
||||
# define IS31FL3729_DRIVER_COUNT 1
|
||||
#endif
|
||||
|
||||
typedef struct is31fl3729_led_t {
|
||||
uint8_t driver : 2;
|
||||
uint8_t v;
|
||||
} PACKED is31fl3729_led_t;
|
||||
|
||||
extern const is31fl3729_led_t PROGMEM g_is31fl3729_leds[IS31FL3729_LED_COUNT];
|
||||
|
||||
void is31fl3729_init_drivers(void);
|
||||
void is31fl3729_init(uint8_t index);
|
||||
void is31fl3729_write_register(uint8_t index, uint8_t reg, uint8_t data);
|
||||
|
||||
void is31fl3729_set_value(int index, uint8_t value);
|
||||
void is31fl3729_set_value_all(uint8_t value);
|
||||
|
||||
void is31fl3729_set_scaling_register(uint8_t index, uint8_t value);
|
||||
|
||||
// This should not be called from an interrupt
|
||||
// (eg. from a timer interrupt).
|
||||
// Call this while idle (in between matrix scans).
|
||||
// If the buffer is dirty, it will update the driver with the buffer.
|
||||
void is31fl3729_update_pwm_buffers(uint8_t index);
|
||||
void is31fl3729_update_scaling_registers(uint8_t index);
|
||||
|
||||
void is31fl3729_flush(void);
|
||||
|
||||
#define IS31FL3729_SW_PULLDOWN_0_OHM 0b000
|
||||
#define IS31FL3729_SW_PULLDOWN_0K5_OHM_SW_OFF 0b001
|
||||
#define IS31FL3729_SW_PULLDOWN_1K_OHM_SW_OFF 0b010
|
||||
#define IS31FL3729_SW_PULLDOWN_2K_OHM_SW_OFF 0b011
|
||||
#define IS31FL3729_SW_PULLDOWN_1K_OHM 0b100
|
||||
#define IS31FL3729_SW_PULLDOWN_2K_OHM 0b101
|
||||
#define IS31FL3729_SW_PULLDOWN_4K_OHM 0b110
|
||||
#define IS31FL3729_SW_PULLDOWN_8K_OHM 0b111
|
||||
|
||||
#define IS31FL3729_CS_PULLUP_0_OHM 0b000
|
||||
#define IS31FL3729_CS_PULLUP_0K5_OHM_CS_OFF 0b001
|
||||
#define IS31FL3729_CS_PULLUP_1K_OHM_CS_OFF 0b010
|
||||
#define IS31FL3729_CS_PULLUP_2K_OHM_CS_OFF 0b011
|
||||
#define IS31FL3729_CS_PULLUP_1K_OHM 0b100
|
||||
#define IS31FL3729_CS_PULLUP_2K_OHM 0b101
|
||||
#define IS31FL3729_CS_PULLUP_4K_OHM 0b110
|
||||
#define IS31FL3729_CS_PULLUP_8K_OHM 0b111
|
||||
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_DISABLE 0b0
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_ENABLE 0b1
|
||||
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_RANGE_5_PERCENT 0b00
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_RANGE_15_PERCENT 0b01
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_RANGE_24_PERCENT 0b10
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_RANGE_34_PERCENT 0b11
|
||||
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_CYCLE_TIME_1980_US 0b00
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_CYCLE_TIME_1200_US 0b01
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_CYCLE_TIME_820_US 0b10
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_CYCLE_TIME_660_US 0b11
|
||||
|
||||
#define IS31FL3729_PWM_FREQUENCY_55K_HZ 0b000
|
||||
#define IS31FL3729_PWM_FREQUENCY_32K_HZ 0b001
|
||||
#define IS31FL3729_PWM_FREQUENCY_4K_HZ 0b010
|
||||
#define IS31FL3729_PWM_FREQUENCY_2K_HZ 0b011
|
||||
#define IS31FL3729_PWM_FREQUENCY_1K_HZ 0b100
|
||||
#define IS31FL3729_PWM_FREQUENCY_500_HZ 0b101
|
||||
#define IS31FL3729_PWM_FREQUENCY_250_HZ 0b110
|
||||
#define IS31FL3729_PWM_FREQUENCY_80K_HZ 0b111
|
||||
|
||||
#define IS31FL3729_CONFIG_SWS_15_9 0x01 // 15 CS x 9 SW matrix
|
||||
#define IS31FL3729_CONFIG_SWS_16_8 0x11 // 16 CS x 8 SW matrix
|
||||
#define IS31FL3729_CONFIG_SWS_16_7 0x21 // 16 CS x 7 SW matrix
|
||||
#define IS31FL3729_CONFIG_SWS_16_6 0x31 // 16 CS x 6 SW matrix
|
||||
#define IS31FL3729_CONFIG_SWS_16_5 0x41 // 16 CS x 5 SW matrix
|
||||
#define IS31FL3729_CONFIG_SWS_16_4 0x51 // 16 CS x 4 SW matrix
|
||||
#define IS31FL3729_CONFIG_SWS_16_3 0x61 // 16 CS x 3 SW matrix
|
||||
#define IS31FL3729_CONFIG_SWS_16_2 0x71 // 16 CS x 2 SW matrix
|
||||
|
||||
#define SW1_CS1 0x00
|
||||
#define SW1_CS2 0x01
|
||||
#define SW1_CS3 0x02
|
||||
#define SW1_CS4 0x03
|
||||
#define SW1_CS5 0x04
|
||||
#define SW1_CS6 0x05
|
||||
#define SW1_CS7 0x06
|
||||
#define SW1_CS8 0x07
|
||||
#define SW1_CS9 0x08
|
||||
#define SW1_CS10 0x09
|
||||
#define SW1_CS11 0x0A
|
||||
#define SW1_CS12 0x0B
|
||||
#define SW1_CS13 0x0C
|
||||
#define SW1_CS14 0x0D
|
||||
#define SW1_CS15 0x0E
|
||||
#define SW1_CS16 0x0F
|
||||
|
||||
#define SW2_CS1 0x10
|
||||
#define SW2_CS2 0x11
|
||||
#define SW2_CS3 0x12
|
||||
#define SW2_CS4 0x13
|
||||
#define SW2_CS5 0x14
|
||||
#define SW2_CS6 0x15
|
||||
#define SW2_CS7 0x16
|
||||
#define SW2_CS8 0x17
|
||||
#define SW2_CS9 0x18
|
||||
#define SW2_CS10 0x19
|
||||
#define SW2_CS11 0x1A
|
||||
#define SW2_CS12 0x1B
|
||||
#define SW2_CS13 0x1C
|
||||
#define SW2_CS14 0x1D
|
||||
#define SW2_CS15 0x1E
|
||||
#define SW2_CS16 0x1F
|
||||
|
||||
#define SW3_CS1 0x20
|
||||
#define SW3_CS2 0x21
|
||||
#define SW3_CS3 0x22
|
||||
#define SW3_CS4 0x23
|
||||
#define SW3_CS5 0x24
|
||||
#define SW3_CS6 0x25
|
||||
#define SW3_CS7 0x26
|
||||
#define SW3_CS8 0x27
|
||||
#define SW3_CS9 0x28
|
||||
#define SW3_CS10 0x29
|
||||
#define SW3_CS11 0x2A
|
||||
#define SW3_CS12 0x2B
|
||||
#define SW3_CS13 0x2C
|
||||
#define SW3_CS14 0x2D
|
||||
#define SW3_CS15 0x2E
|
||||
#define SW3_CS16 0x2F
|
||||
|
||||
#define SW4_CS1 0x30
|
||||
#define SW4_CS2 0x31
|
||||
#define SW4_CS3 0x32
|
||||
#define SW4_CS4 0x33
|
||||
#define SW4_CS5 0x34
|
||||
#define SW4_CS6 0x35
|
||||
#define SW4_CS7 0x36
|
||||
#define SW4_CS8 0x37
|
||||
#define SW4_CS9 0x38
|
||||
#define SW4_CS10 0x39
|
||||
#define SW4_CS11 0x3A
|
||||
#define SW4_CS12 0x3B
|
||||
#define SW4_CS13 0x3C
|
||||
#define SW4_CS14 0x3D
|
||||
#define SW4_CS15 0x3E
|
||||
#define SW4_CS16 0x3F
|
||||
|
||||
#define SW5_CS1 0x40
|
||||
#define SW5_CS2 0x41
|
||||
#define SW5_CS3 0x42
|
||||
#define SW5_CS4 0x43
|
||||
#define SW5_CS5 0x44
|
||||
#define SW5_CS6 0x45
|
||||
#define SW5_CS7 0x46
|
||||
#define SW5_CS8 0x47
|
||||
#define SW5_CS9 0x48
|
||||
#define SW5_CS10 0x49
|
||||
#define SW5_CS11 0x4A
|
||||
#define SW5_CS12 0x4B
|
||||
#define SW5_CS13 0x4C
|
||||
#define SW5_CS14 0x4D
|
||||
#define SW5_CS15 0x4E
|
||||
#define SW5_CS16 0x4F
|
||||
|
||||
#define SW6_CS1 0x50
|
||||
#define SW6_CS2 0x51
|
||||
#define SW6_CS3 0x52
|
||||
#define SW6_CS4 0x53
|
||||
#define SW6_CS5 0x54
|
||||
#define SW6_CS6 0x55
|
||||
#define SW6_CS7 0x56
|
||||
#define SW6_CS8 0x57
|
||||
#define SW6_CS9 0x58
|
||||
#define SW6_CS10 0x59
|
||||
#define SW6_CS11 0x5A
|
||||
#define SW6_CS12 0x5B
|
||||
#define SW6_CS13 0x5C
|
||||
#define SW6_CS14 0x5D
|
||||
#define SW6_CS15 0x5E
|
||||
#define SW6_CS16 0x5F
|
||||
|
||||
#define SW7_CS1 0x60
|
||||
#define SW7_CS2 0x61
|
||||
#define SW7_CS3 0x62
|
||||
#define SW7_CS4 0x63
|
||||
#define SW7_CS5 0x64
|
||||
#define SW7_CS6 0x65
|
||||
#define SW7_CS7 0x66
|
||||
#define SW7_CS8 0x67
|
||||
#define SW7_CS9 0x68
|
||||
#define SW7_CS10 0x69
|
||||
#define SW7_CS11 0x6A
|
||||
#define SW7_CS12 0x6B
|
||||
#define SW7_CS13 0x6C
|
||||
#define SW7_CS14 0x6D
|
||||
#define SW7_CS15 0x6E
|
||||
#define SW7_CS16 0x6F
|
||||
|
||||
#define SW8_CS1 0x70
|
||||
#define SW8_CS2 0x71
|
||||
#define SW8_CS3 0x72
|
||||
#define SW8_CS4 0x73
|
||||
#define SW8_CS5 0x74
|
||||
#define SW8_CS6 0x75
|
||||
#define SW8_CS7 0x76
|
||||
#define SW8_CS8 0x77
|
||||
#define SW8_CS9 0x78
|
||||
#define SW8_CS10 0x79
|
||||
#define SW8_CS11 0x7A
|
||||
#define SW8_CS12 0x7B
|
||||
#define SW8_CS13 0x7C
|
||||
#define SW8_CS14 0x7D
|
||||
#define SW8_CS15 0x7E
|
||||
#define SW8_CS16 0x7F
|
||||
|
||||
#define SW9_CS1 0x80
|
||||
#define SW9_CS2 0x81
|
||||
#define SW9_CS3 0x82
|
||||
#define SW9_CS4 0x83
|
||||
#define SW9_CS5 0x84
|
||||
#define SW9_CS6 0x85
|
||||
#define SW9_CS7 0x86
|
||||
#define SW9_CS8 0x87
|
||||
#define SW9_CS9 0x88
|
||||
#define SW9_CS10 0x89
|
||||
#define SW9_CS11 0x8A
|
||||
#define SW9_CS12 0x8B
|
||||
#define SW9_CS13 0x8C
|
||||
#define SW9_CS14 0x8D
|
||||
#define SW9_CS15 0x8E
|
219
drivers/led/issi/is31fl3729.c
Normal file
219
drivers/led/issi/is31fl3729.c
Normal file
|
@ -0,0 +1,219 @@
|
|||
/* Copyright 2024 HorrorTroll <https://github.com/HorrorTroll>
|
||||
* Copyright 2024 Harrison Chan (Xelus)
|
||||
* Copyright 2024 Dimitris Mantzouranis <d3xter93@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "is31fl3729.h"
|
||||
#include "i2c_master.h"
|
||||
#include "gpio.h"
|
||||
#include "wait.h"
|
||||
|
||||
#define IS31FL3729_PWM_REGISTER_COUNT 143
|
||||
#define IS31FL3729_SCALING_REGISTER_COUNT 16
|
||||
|
||||
#ifndef IS31FL3729_I2C_TIMEOUT
|
||||
# define IS31FL3729_I2C_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3729_I2C_PERSISTENCE
|
||||
# define IS31FL3729_I2C_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3729_CONFIGURATION
|
||||
# define IS31FL3729_CONFIGURATION IS31FL3729_CONFIG_SWS_15_9
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3729_GLOBAL_CURRENT
|
||||
# define IS31FL3729_GLOBAL_CURRENT 0x40
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3729_SW_PULLDOWN
|
||||
# define IS31FL3729_SW_PULLDOWN IS31FL3729_SW_PULLDOWN_2K_OHM_SW_OFF
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3729_CS_PULLUP
|
||||
# define IS31FL3729_CS_PULLUP IS31FL3729_CS_PULLUP_2K_OHM_CS_OFF
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3729_SPREAD_SPECTRUM
|
||||
# define IS31FL3729_SPREAD_SPECTRUM IS31FL3729_SPREAD_SPECTRUM_DISABLE
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3729_SPREAD_SPECTRUM_RANGE
|
||||
# define IS31FL3729_SPREAD_SPECTRUM_RANGE IS31FL3729_SPREAD_SPECTRUM_RANGE_5_PERCENT
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3729_SPREAD_SPECTRUM_CYCLE_TIME
|
||||
# define IS31FL3729_SPREAD_SPECTRUM_CYCLE_TIME IS31FL3729_SPREAD_SPECTRUM_CYCLE_TIME_1980_US
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3729_PWM_FREQUENCY
|
||||
# define IS31FL3729_PWM_FREQUENCY IS31FL3729_PWM_FREQUENCY_32K_HZ
|
||||
#endif
|
||||
|
||||
const uint8_t i2c_addresses[IS31FL3729_DRIVER_COUNT] = {
|
||||
IS31FL3729_I2C_ADDRESS_1,
|
||||
#ifdef IS31FL3729_I2C_ADDRESS_2
|
||||
IS31FL3729_I2C_ADDRESS_2,
|
||||
# ifdef IS31FL3729_I2C_ADDRESS_3
|
||||
IS31FL3729_I2C_ADDRESS_3,
|
||||
# ifdef IS31FL3729_I2C_ADDRESS_4
|
||||
IS31FL3729_I2C_ADDRESS_4,
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
// These buffers match the PWM & scaling registers.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
typedef struct is31fl3729_driver_t {
|
||||
uint8_t pwm_buffer[IS31FL3729_PWM_REGISTER_COUNT];
|
||||
bool pwm_buffer_dirty;
|
||||
uint8_t scaling_buffer[IS31FL3729_SCALING_REGISTER_COUNT];
|
||||
bool scaling_buffer_dirty;
|
||||
} PACKED is31fl3729_driver_t;
|
||||
|
||||
is31fl3729_driver_t driver_buffers[IS31FL3729_DRIVER_COUNT] = {{
|
||||
.pwm_buffer = {0},
|
||||
.pwm_buffer_dirty = false,
|
||||
.scaling_buffer = {0},
|
||||
.scaling_buffer_dirty = false,
|
||||
}};
|
||||
|
||||
void is31fl3729_write_register(uint8_t index, uint8_t reg, uint8_t data) {
|
||||
#if IS31FL3729_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3729_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3729_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3729_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3729_write_pwm_buffer(uint8_t index) {
|
||||
// Transmit PWM registers in 11 transfers of 13 bytes.
|
||||
|
||||
// Iterate over the pwm_buffer contents at 13 byte intervals.
|
||||
for (uint8_t i = 0; i <= IS31FL3729_PWM_REGISTER_COUNT; i += 13) {
|
||||
#if IS31FL3729_I2C_PERSISTENCE > 0
|
||||
for (uint8_t j = 0; j < IS31FL3729_I2C_PERSISTENCE; j++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, IS31FL3729_REG_PWM + i, driver_buffers[index].pwm_buffer + i, 13, IS31FL3729_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, IS31FL3729_REG_PWM + i, driver_buffers[index].pwm_buffer + i, 13, IS31FL3729_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3729_init_drivers(void) {
|
||||
i2c_init();
|
||||
|
||||
#if defined(IS31FL3729_SDB_PIN)
|
||||
gpio_set_pin_output(IS31FL3729_SDB_PIN);
|
||||
gpio_write_pin_high(IS31FL3729_SDB_PIN);
|
||||
#endif
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3729_DRIVER_COUNT; i++) {
|
||||
is31fl3729_init(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < IS31FL3729_LED_COUNT; i++) {
|
||||
is31fl3729_set_scaling_register(i, 0xFF, 0xFF, 0xFF);
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3729_DRIVER_COUNT; i++) {
|
||||
is31fl3729_update_scaling_registers(i);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3729_init(uint8_t index) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
|
||||
is31fl3729_write_register(index, IS31FL3729_REG_PULLDOWNUP, ((IS31FL3729_SW_PULLDOWN & 0b111) << 4) | (IS31FL3729_CS_PULLUP & 0b111));
|
||||
is31fl3729_write_register(index, IS31FL3729_REG_SPREAD_SPECTRUM, ((IS31FL3729_SPREAD_SPECTRUM & 0b1) << 4) | ((IS31FL3729_SPREAD_SPECTRUM_RANGE & 0b11) << 2) | (IS31FL3729_SPREAD_SPECTRUM_CYCLE_TIME & 0b11));
|
||||
is31fl3729_write_register(index, IS31FL3729_REG_PWM_FREQUENCY, IS31FL3729_PWM_FREQUENCY);
|
||||
is31fl3729_write_register(index, IS31FL3729_REG_GLOBAL_CURRENT, IS31FL3729_GLOBAL_CURRENT);
|
||||
is31fl3729_write_register(index, IS31FL3729_REG_CONFIGURATION, IS31FL3729_CONFIGURATION);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
wait_ms(10);
|
||||
}
|
||||
|
||||
void is31fl3729_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
is31fl3729_led_t led;
|
||||
if (index >= 0 && index < IS31FL3729_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3729_leds[index]), sizeof(led));
|
||||
|
||||
if (driver_buffers[led.driver].pwm_buffer[led.r] == red && driver_buffers[led.driver].pwm_buffer[led.g] == green && driver_buffers[led.driver].pwm_buffer[led.b] == blue) {
|
||||
return;
|
||||
}
|
||||
|
||||
driver_buffers[led.driver].pwm_buffer[led.r] = red;
|
||||
driver_buffers[led.driver].pwm_buffer[led.g] = green;
|
||||
driver_buffers[led.driver].pwm_buffer[led.b] = blue;
|
||||
driver_buffers[led.driver].pwm_buffer_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3729_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
for (int i = 0; i < IS31FL3729_LED_COUNT; i++) {
|
||||
is31fl3729_set_color(i, red, green, blue);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3729_set_scaling_register(uint8_t index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
is31fl3729_led_t led;
|
||||
memcpy_P(&led, (&g_is31fl3729_leds[index]), sizeof(led));
|
||||
|
||||
// need to do a bit of checking here since 3729 scaling is per CS pin.
|
||||
// not the usual per RGB key as per other ISSI drivers
|
||||
// only enable them, since they should be default disabled
|
||||
int cs_red = (led.r & 0x0F) - 1;
|
||||
int cs_green = (led.g & 0x0F) - 1;
|
||||
int cs_blue = (led.b & 0x0F) - 1;
|
||||
|
||||
driver_buffers[led.driver].scaling_buffer[cs_red] = red;
|
||||
driver_buffers[led.driver].scaling_buffer[cs_green] = green;
|
||||
driver_buffers[led.driver].scaling_buffer[cs_blue] = blue;
|
||||
driver_buffers[led.driver].scaling_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3729_update_pwm_buffers(uint8_t index) {
|
||||
if (driver_buffers[index].pwm_buffer_dirty) {
|
||||
is31fl3729_write_pwm_buffer(index);
|
||||
|
||||
driver_buffers[index].pwm_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3729_update_scaling_registers(uint8_t index) {
|
||||
if (driver_buffers[index].scaling_buffer_dirty) {
|
||||
for (uint8_t i = 0; i < IS31FL3729_SCALING_REGISTER_COUNT; i++) {
|
||||
is31fl3729_write_register(index, IS31FL3729_REG_SCALING + i, driver_buffers[index].scaling_buffer[i]);
|
||||
}
|
||||
|
||||
driver_buffers[index].scaling_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3729_flush(void) {
|
||||
for (uint8_t i = 0; i < IS31FL3729_DRIVER_COUNT; i++) {
|
||||
is31fl3729_update_pwm_buffers(i);
|
||||
}
|
||||
}
|
280
drivers/led/issi/is31fl3729.h
Normal file
280
drivers/led/issi/is31fl3729.h
Normal file
|
@ -0,0 +1,280 @@
|
|||
/* Copyright 2024 HorrorTroll <https://github.com/HorrorTroll>
|
||||
* Copyright 2024 Harrison Chan (Xelus)
|
||||
* Copyright 2024 Dimitris Mantzouranis <d3xter93@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "progmem.h"
|
||||
#include "util.h"
|
||||
|
||||
#define IS31FL3729_REG_PWM 0x01
|
||||
#define IS31FL3729_REG_SCALING 0x90
|
||||
#define IS31FL3729_REG_CONFIGURATION 0xA0
|
||||
#define IS31FL3729_REG_GLOBAL_CURRENT 0xA1
|
||||
#define IS31FL3729_REG_PULLDOWNUP 0xB0
|
||||
#define IS31FL3729_REG_SPREAD_SPECTRUM 0xB1
|
||||
#define IS31FL3729_REG_PWM_FREQUENCY 0xB2
|
||||
#define IS31FL3729_REG_RESET 0xCF
|
||||
|
||||
#define IS31FL3729_I2C_ADDRESS_GND 0x34
|
||||
#define IS31FL3729_I2C_ADDRESS_SCL 0x35
|
||||
#define IS31FL3729_I2C_ADDRESS_SDA 0x36
|
||||
#define IS31FL3729_I2C_ADDRESS_VCC 0x37
|
||||
|
||||
#if defined(RGB_MATRIX_IS31FL3729)
|
||||
# define IS31FL3729_LED_COUNT RGB_MATRIX_LED_COUNT
|
||||
#endif
|
||||
|
||||
#if defined(IS31FL3729_I2C_ADDRESS_4)
|
||||
# define IS31FL3729_DRIVER_COUNT 4
|
||||
#elif defined(IS31FL3729_I2C_ADDRESS_3)
|
||||
# define IS31FL3729_DRIVER_COUNT 3
|
||||
#elif defined(IS31FL3729_I2C_ADDRESS_2)
|
||||
# define IS31FL3729_DRIVER_COUNT 2
|
||||
#elif defined(IS31FL3729_I2C_ADDRESS_1)
|
||||
# define IS31FL3729_DRIVER_COUNT 1
|
||||
#endif
|
||||
|
||||
typedef struct is31fl3729_led_t {
|
||||
uint8_t driver : 2;
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
} PACKED is31fl3729_led_t;
|
||||
|
||||
extern const is31fl3729_led_t PROGMEM g_is31fl3729_leds[IS31FL3729_LED_COUNT];
|
||||
|
||||
void is31fl3729_init_drivers(void);
|
||||
void is31fl3729_init(uint8_t index);
|
||||
void is31fl3729_write_register(uint8_t index, uint8_t reg, uint8_t data);
|
||||
|
||||
void is31fl3729_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
|
||||
void is31fl3729_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
||||
void is31fl3729_set_scaling_register(uint8_t index, uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
||||
// This should not be called from an interrupt
|
||||
// (eg. from a timer interrupt).
|
||||
// Call this while idle (in between matrix scans).
|
||||
// If the buffer is dirty, it will update the driver with the buffer.
|
||||
void is31fl3729_update_pwm_buffers(uint8_t index);
|
||||
void is31fl3729_update_scaling_registers(uint8_t index);
|
||||
|
||||
void is31fl3729_flush(void);
|
||||
|
||||
#define IS31FL3729_SW_PULLDOWN_0_OHM 0b000
|
||||
#define IS31FL3729_SW_PULLDOWN_0K5_OHM_SW_OFF 0b001
|
||||
#define IS31FL3729_SW_PULLDOWN_1K_OHM_SW_OFF 0b010
|
||||
#define IS31FL3729_SW_PULLDOWN_2K_OHM_SW_OFF 0b011
|
||||
#define IS31FL3729_SW_PULLDOWN_1K_OHM 0b100
|
||||
#define IS31FL3729_SW_PULLDOWN_2K_OHM 0b101
|
||||
#define IS31FL3729_SW_PULLDOWN_4K_OHM 0b110
|
||||
#define IS31FL3729_SW_PULLDOWN_8K_OHM 0b111
|
||||
|
||||
#define IS31FL3729_CS_PULLUP_0_OHM 0b000
|
||||
#define IS31FL3729_CS_PULLUP_0K5_OHM_CS_OFF 0b001
|
||||
#define IS31FL3729_CS_PULLUP_1K_OHM_CS_OFF 0b010
|
||||
#define IS31FL3729_CS_PULLUP_2K_OHM_CS_OFF 0b011
|
||||
#define IS31FL3729_CS_PULLUP_1K_OHM 0b100
|
||||
#define IS31FL3729_CS_PULLUP_2K_OHM 0b101
|
||||
#define IS31FL3729_CS_PULLUP_4K_OHM 0b110
|
||||
#define IS31FL3729_CS_PULLUP_8K_OHM 0b111
|
||||
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_DISABLE 0b0
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_ENABLE 0b1
|
||||
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_RANGE_5_PERCENT 0b00
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_RANGE_15_PERCENT 0b01
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_RANGE_24_PERCENT 0b10
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_RANGE_34_PERCENT 0b11
|
||||
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_CYCLE_TIME_1980_US 0b00
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_CYCLE_TIME_1200_US 0b01
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_CYCLE_TIME_820_US 0b10
|
||||
#define IS31FL3729_SPREAD_SPECTRUM_CYCLE_TIME_660_US 0b11
|
||||
|
||||
#define IS31FL3729_PWM_FREQUENCY_55K_HZ 0b000
|
||||
#define IS31FL3729_PWM_FREQUENCY_32K_HZ 0b001
|
||||
#define IS31FL3729_PWM_FREQUENCY_4K_HZ 0b010
|
||||
#define IS31FL3729_PWM_FREQUENCY_2K_HZ 0b011
|
||||
#define IS31FL3729_PWM_FREQUENCY_1K_HZ 0b100
|
||||
#define IS31FL3729_PWM_FREQUENCY_500_HZ 0b101
|
||||
#define IS31FL3729_PWM_FREQUENCY_250_HZ 0b110
|
||||
#define IS31FL3729_PWM_FREQUENCY_80K_HZ 0b111
|
||||
|
||||
#define IS31FL3729_CONFIG_SWS_15_9 0x01 // 15 CS x 9 SW matrix
|
||||
#define IS31FL3729_CONFIG_SWS_16_8 0x11 // 16 CS x 8 SW matrix
|
||||
#define IS31FL3729_CONFIG_SWS_16_7 0x21 // 16 CS x 7 SW matrix
|
||||
#define IS31FL3729_CONFIG_SWS_16_6 0x31 // 16 CS x 6 SW matrix
|
||||
#define IS31FL3729_CONFIG_SWS_16_5 0x41 // 16 CS x 5 SW matrix
|
||||
#define IS31FL3729_CONFIG_SWS_16_4 0x51 // 16 CS x 4 SW matrix
|
||||
#define IS31FL3729_CONFIG_SWS_16_3 0x61 // 16 CS x 3 SW matrix
|
||||
#define IS31FL3729_CONFIG_SWS_16_2 0x71 // 16 CS x 2 SW matrix
|
||||
|
||||
#define SW1_CS1 0x00
|
||||
#define SW1_CS2 0x01
|
||||
#define SW1_CS3 0x02
|
||||
#define SW1_CS4 0x03
|
||||
#define SW1_CS5 0x04
|
||||
#define SW1_CS6 0x05
|
||||
#define SW1_CS7 0x06
|
||||
#define SW1_CS8 0x07
|
||||
#define SW1_CS9 0x08
|
||||
#define SW1_CS10 0x09
|
||||
#define SW1_CS11 0x0A
|
||||
#define SW1_CS12 0x0B
|
||||
#define SW1_CS13 0x0C
|
||||
#define SW1_CS14 0x0D
|
||||
#define SW1_CS15 0x0E
|
||||
#define SW1_CS16 0x0F
|
||||
|
||||
#define SW2_CS1 0x10
|
||||
#define SW2_CS2 0x11
|
||||
#define SW2_CS3 0x12
|
||||
#define SW2_CS4 0x13
|
||||
#define SW2_CS5 0x14
|
||||
#define SW2_CS6 0x15
|
||||
#define SW2_CS7 0x16
|
||||
#define SW2_CS8 0x17
|
||||
#define SW2_CS9 0x18
|
||||
#define SW2_CS10 0x19
|
||||
#define SW2_CS11 0x1A
|
||||
#define SW2_CS12 0x1B
|
||||
#define SW2_CS13 0x1C
|
||||
#define SW2_CS14 0x1D
|
||||
#define SW2_CS15 0x1E
|
||||
#define SW2_CS16 0x1F
|
||||
|
||||
#define SW3_CS1 0x20
|
||||
#define SW3_CS2 0x21
|
||||
#define SW3_CS3 0x22
|
||||
#define SW3_CS4 0x23
|
||||
#define SW3_CS5 0x24
|
||||
#define SW3_CS6 0x25
|
||||
#define SW3_CS7 0x26
|
||||
#define SW3_CS8 0x27
|
||||
#define SW3_CS9 0x28
|
||||
#define SW3_CS10 0x29
|
||||
#define SW3_CS11 0x2A
|
||||
#define SW3_CS12 0x2B
|
||||
#define SW3_CS13 0x2C
|
||||
#define SW3_CS14 0x2D
|
||||
#define SW3_CS15 0x2E
|
||||
#define SW3_CS16 0x2F
|
||||
|
||||
#define SW4_CS1 0x30
|
||||
#define SW4_CS2 0x31
|
||||
#define SW4_CS3 0x32
|
||||
#define SW4_CS4 0x33
|
||||
#define SW4_CS5 0x34
|
||||
#define SW4_CS6 0x35
|
||||
#define SW4_CS7 0x36
|
||||
#define SW4_CS8 0x37
|
||||
#define SW4_CS9 0x38
|
||||
#define SW4_CS10 0x39
|
||||
#define SW4_CS11 0x3A
|
||||
#define SW4_CS12 0x3B
|
||||
#define SW4_CS13 0x3C
|
||||
#define SW4_CS14 0x3D
|
||||
#define SW4_CS15 0x3E
|
||||
#define SW4_CS16 0x3F
|
||||
|
||||
#define SW5_CS1 0x40
|
||||
#define SW5_CS2 0x41
|
||||
#define SW5_CS3 0x42
|
||||
#define SW5_CS4 0x43
|
||||
#define SW5_CS5 0x44
|
||||
#define SW5_CS6 0x45
|
||||
#define SW5_CS7 0x46
|
||||
#define SW5_CS8 0x47
|
||||
#define SW5_CS9 0x48
|
||||
#define SW5_CS10 0x49
|
||||
#define SW5_CS11 0x4A
|
||||
#define SW5_CS12 0x4B
|
||||
#define SW5_CS13 0x4C
|
||||
#define SW5_CS14 0x4D
|
||||
#define SW5_CS15 0x4E
|
||||
#define SW5_CS16 0x4F
|
||||
|
||||
#define SW6_CS1 0x50
|
||||
#define SW6_CS2 0x51
|
||||
#define SW6_CS3 0x52
|
||||
#define SW6_CS4 0x53
|
||||
#define SW6_CS5 0x54
|
||||
#define SW6_CS6 0x55
|
||||
#define SW6_CS7 0x56
|
||||
#define SW6_CS8 0x57
|
||||
#define SW6_CS9 0x58
|
||||
#define SW6_CS10 0x59
|
||||
#define SW6_CS11 0x5A
|
||||
#define SW6_CS12 0x5B
|
||||
#define SW6_CS13 0x5C
|
||||
#define SW6_CS14 0x5D
|
||||
#define SW6_CS15 0x5E
|
||||
#define SW6_CS16 0x5F
|
||||
|
||||
#define SW7_CS1 0x60
|
||||
#define SW7_CS2 0x61
|
||||
#define SW7_CS3 0x62
|
||||
#define SW7_CS4 0x63
|
||||
#define SW7_CS5 0x64
|
||||
#define SW7_CS6 0x65
|
||||
#define SW7_CS7 0x66
|
||||
#define SW7_CS8 0x67
|
||||
#define SW7_CS9 0x68
|
||||
#define SW7_CS10 0x69
|
||||
#define SW7_CS11 0x6A
|
||||
#define SW7_CS12 0x6B
|
||||
#define SW7_CS13 0x6C
|
||||
#define SW7_CS14 0x6D
|
||||
#define SW7_CS15 0x6E
|
||||
#define SW7_CS16 0x6F
|
||||
|
||||
#define SW8_CS1 0x70
|
||||
#define SW8_CS2 0x71
|
||||
#define SW8_CS3 0x72
|
||||
#define SW8_CS4 0x73
|
||||
#define SW8_CS5 0x74
|
||||
#define SW8_CS6 0x75
|
||||
#define SW8_CS7 0x76
|
||||
#define SW8_CS8 0x77
|
||||
#define SW8_CS9 0x78
|
||||
#define SW8_CS10 0x79
|
||||
#define SW8_CS11 0x7A
|
||||
#define SW8_CS12 0x7B
|
||||
#define SW8_CS13 0x7C
|
||||
#define SW8_CS14 0x7D
|
||||
#define SW8_CS15 0x7E
|
||||
#define SW8_CS16 0x7F
|
||||
|
||||
#define SW9_CS1 0x80
|
||||
#define SW9_CS2 0x81
|
||||
#define SW9_CS3 0x82
|
||||
#define SW9_CS4 0x83
|
||||
#define SW9_CS5 0x84
|
||||
#define SW9_CS6 0x85
|
||||
#define SW9_CS7 0x86
|
||||
#define SW9_CS8 0x87
|
||||
#define SW9_CS9 0x88
|
||||
#define SW9_CS10 0x89
|
||||
#define SW9_CS11 0x8A
|
||||
#define SW9_CS12 0x8B
|
||||
#define SW9_CS13 0x8C
|
||||
#define SW9_CS14 0x8D
|
||||
#define SW9_CS15 0x8E
|
230
drivers/led/issi/is31fl3731-mono.c
Normal file
230
drivers/led/issi/is31fl3731-mono.c
Normal file
|
@ -0,0 +1,230 @@
|
|||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2019 Clueboard
|
||||
* Copyright 2021 Doni Crosby
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "is31fl3731-mono.h"
|
||||
#include "i2c_master.h"
|
||||
#include "gpio.h"
|
||||
#include "wait.h"
|
||||
|
||||
#define IS31FL3731_PWM_REGISTER_COUNT 144
|
||||
#define IS31FL3731_LED_CONTROL_REGISTER_COUNT 18
|
||||
|
||||
#ifndef IS31FL3731_I2C_TIMEOUT
|
||||
# define IS31FL3731_I2C_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3731_I2C_PERSISTENCE
|
||||
# define IS31FL3731_I2C_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
const uint8_t i2c_addresses[IS31FL3731_DRIVER_COUNT] = {
|
||||
IS31FL3731_I2C_ADDRESS_1,
|
||||
#ifdef IS31FL3731_I2C_ADDRESS_2
|
||||
IS31FL3731_I2C_ADDRESS_2,
|
||||
# ifdef IS31FL3731_I2C_ADDRESS_3
|
||||
IS31FL3731_I2C_ADDRESS_3,
|
||||
# ifdef IS31FL3731_I2C_ADDRESS_4
|
||||
IS31FL3731_I2C_ADDRESS_4,
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
// These buffers match the IS31FL3731 PWM registers 0x24-0xB3.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
// We could optimize this and take out the unused registers from these
|
||||
// buffers and the transfers in is31fl3731_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
typedef struct is31fl3731_driver_t {
|
||||
uint8_t pwm_buffer[IS31FL3731_PWM_REGISTER_COUNT];
|
||||
bool pwm_buffer_dirty;
|
||||
uint8_t led_control_buffer[IS31FL3731_LED_CONTROL_REGISTER_COUNT];
|
||||
bool led_control_buffer_dirty;
|
||||
} PACKED is31fl3731_driver_t;
|
||||
|
||||
is31fl3731_driver_t driver_buffers[IS31FL3731_DRIVER_COUNT] = {{
|
||||
.pwm_buffer = {0},
|
||||
.pwm_buffer_dirty = false,
|
||||
.led_control_buffer = {0},
|
||||
.led_control_buffer_dirty = false,
|
||||
}};
|
||||
|
||||
void is31fl3731_write_register(uint8_t index, uint8_t reg, uint8_t data) {
|
||||
#if IS31FL3731_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3731_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3731_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3731_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3731_select_page(uint8_t index, uint8_t page) {
|
||||
is31fl3731_write_register(index, IS31FL3731_REG_COMMAND, page);
|
||||
}
|
||||
|
||||
void is31fl3731_write_pwm_buffer(uint8_t index) {
|
||||
// Assumes page 0 is already selected.
|
||||
// Transmit PWM registers in 9 transfers of 16 bytes.
|
||||
|
||||
// Iterate over the pwm_buffer contents at 16 byte intervals.
|
||||
for (uint8_t i = 0; i < IS31FL3731_PWM_REGISTER_COUNT; i += 16) {
|
||||
#if IS31FL3731_I2C_PERSISTENCE > 0
|
||||
for (uint8_t j = 0; j < IS31FL3731_I2C_PERSISTENCE; j++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, IS31FL3731_FRAME_REG_PWM + i, driver_buffers[index].pwm_buffer + i, 16, IS31FL3731_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, IS31FL3731_FRAME_REG_PWM + i, driver_buffers[index].pwm_buffer + i, 16, IS31FL3731_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3731_init_drivers(void) {
|
||||
i2c_init();
|
||||
|
||||
#if defined(IS31FL3731_SDB_PIN)
|
||||
gpio_set_pin_output(IS31FL3731_SDB_PIN);
|
||||
gpio_write_pin_high(IS31FL3731_SDB_PIN);
|
||||
#endif
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3731_DRIVER_COUNT; i++) {
|
||||
is31fl3731_init(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < IS31FL3731_LED_COUNT; i++) {
|
||||
is31fl3731_set_led_control_register(i, true);
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3731_DRIVER_COUNT; i++) {
|
||||
is31fl3731_update_led_control_registers(i);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3731_init(uint8_t index) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, first enable software shutdown,
|
||||
// then set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
|
||||
is31fl3731_select_page(index, IS31FL3731_COMMAND_FUNCTION);
|
||||
|
||||
// enable software shutdown
|
||||
is31fl3731_write_register(index, IS31FL3731_FUNCTION_REG_SHUTDOWN, 0x00);
|
||||
#ifdef IS31FL3731_DEGHOST // set to enable de-ghosting of the array
|
||||
is31fl3731_write_register(index, IS31FL3731_FUNCTION_REG_GHOST_IMAGE_PREVENTION, IS31FL3731_GHOST_IMAGE_PREVENTION_GEN);
|
||||
#endif
|
||||
|
||||
// this delay was copied from other drivers, might not be needed
|
||||
wait_ms(10);
|
||||
|
||||
// picture mode
|
||||
is31fl3731_write_register(index, IS31FL3731_FUNCTION_REG_CONFIG, IS31FL3731_CONFIG_MODE_PICTURE);
|
||||
// display frame 0
|
||||
is31fl3731_write_register(index, IS31FL3731_FUNCTION_REG_PICTURE_DISPLAY, 0x00);
|
||||
// audio sync off
|
||||
is31fl3731_write_register(index, IS31FL3731_FUNCTION_REG_AUDIO_SYNC, 0x00);
|
||||
|
||||
is31fl3731_select_page(index, IS31FL3731_COMMAND_FRAME_1);
|
||||
|
||||
// turn off all LEDs in the LED control register
|
||||
for (uint8_t i = 0; i < IS31FL3731_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3731_write_register(index, IS31FL3731_FRAME_REG_LED_CONTROL + i, 0x00);
|
||||
}
|
||||
|
||||
// turn off all LEDs in the blink control register (not really needed)
|
||||
for (uint8_t i = 0; i < IS31FL3731_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3731_write_register(index, IS31FL3731_FRAME_REG_BLINK_CONTROL + i, 0x00);
|
||||
}
|
||||
|
||||
// set PWM on all LEDs to 0
|
||||
for (uint8_t i = 0; i < IS31FL3731_PWM_REGISTER_COUNT; i++) {
|
||||
is31fl3731_write_register(index, IS31FL3731_FRAME_REG_PWM + i, 0x00);
|
||||
}
|
||||
|
||||
is31fl3731_select_page(index, IS31FL3731_COMMAND_FUNCTION);
|
||||
|
||||
// disable software shutdown
|
||||
is31fl3731_write_register(index, IS31FL3731_FUNCTION_REG_SHUTDOWN, 0x01);
|
||||
|
||||
// select page 0 and leave it selected.
|
||||
// most usage after initialization is just writing PWM buffers in page 0
|
||||
// as there's not much point in double-buffering
|
||||
is31fl3731_select_page(index, IS31FL3731_COMMAND_FRAME_1);
|
||||
}
|
||||
|
||||
void is31fl3731_set_value(int index, uint8_t value) {
|
||||
is31fl3731_led_t led;
|
||||
|
||||
if (index >= 0 && index < IS31FL3731_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3731_leds[index]), sizeof(led));
|
||||
|
||||
if (driver_buffers[led.driver].pwm_buffer[led.v] == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
driver_buffers[led.driver].pwm_buffer[led.v] = value;
|
||||
driver_buffers[led.driver].pwm_buffer_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3731_set_value_all(uint8_t value) {
|
||||
for (int i = 0; i < IS31FL3731_LED_COUNT; i++) {
|
||||
is31fl3731_set_value(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3731_set_led_control_register(uint8_t index, bool value) {
|
||||
is31fl3731_led_t led;
|
||||
memcpy_P(&led, (&g_is31fl3731_leds[index]), sizeof(led));
|
||||
|
||||
uint8_t control_register = led.v / 8;
|
||||
uint8_t bit_value = led.v % 8;
|
||||
|
||||
if (value) {
|
||||
driver_buffers[led.driver].led_control_buffer[control_register] |= (1 << bit_value);
|
||||
} else {
|
||||
driver_buffers[led.driver].led_control_buffer[control_register] &= ~(1 << bit_value);
|
||||
}
|
||||
|
||||
driver_buffers[led.driver].led_control_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3731_update_pwm_buffers(uint8_t index) {
|
||||
if (driver_buffers[index].pwm_buffer_dirty) {
|
||||
is31fl3731_write_pwm_buffer(index);
|
||||
|
||||
driver_buffers[index].pwm_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3731_update_led_control_registers(uint8_t index) {
|
||||
if (driver_buffers[index].led_control_buffer_dirty) {
|
||||
for (uint8_t i = 0; i < IS31FL3731_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3731_write_register(index, i, driver_buffers[index].led_control_buffer[i]);
|
||||
}
|
||||
|
||||
driver_buffers[index].led_control_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3731_flush(void) {
|
||||
for (uint8_t i = 0; i < IS31FL3731_DRIVER_COUNT; i++) {
|
||||
is31fl3731_update_pwm_buffers(i);
|
||||
}
|
||||
}
|
|
@ -61,6 +61,10 @@
|
|||
#define IS31FL3731_COMMAND_FRAME_8 0x07
|
||||
#define IS31FL3731_COMMAND_FUNCTION 0x0B
|
||||
|
||||
#define IS31FL3731_FRAME_REG_LED_CONTROL 0x00
|
||||
#define IS31FL3731_FRAME_REG_BLINK_CONTROL 0x12
|
||||
#define IS31FL3731_FRAME_REG_PWM 0x24
|
||||
|
||||
#define IS31FL3731_FUNCTION_REG_CONFIG 0x00
|
||||
#define IS31FL3731_CONFIG_MODE_PICTURE 0x00
|
||||
#define IS31FL3731_CONFIG_MODE_AUTO_PLAY 0x08
|
||||
|
@ -101,9 +105,9 @@ typedef struct is31fl3731_led_t {
|
|||
extern const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT];
|
||||
|
||||
void is31fl3731_init_drivers(void);
|
||||
void is31fl3731_init(uint8_t addr);
|
||||
void is31fl3731_write_register(uint8_t addr, uint8_t reg, uint8_t data);
|
||||
void is31fl3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
|
||||
void is31fl3731_init(uint8_t index);
|
||||
void is31fl3731_write_register(uint8_t index, uint8_t reg, uint8_t data);
|
||||
void is31fl3731_select_page(uint8_t index, uint8_t page);
|
||||
|
||||
void is31fl3731_set_value(int index, uint8_t value);
|
||||
void is31fl3731_set_value_all(uint8_t value);
|
||||
|
@ -114,169 +118,169 @@ void is31fl3731_set_led_control_register(uint8_t index, bool value);
|
|||
// (eg. from a timer interrupt).
|
||||
// Call this while idle (in between matrix scans).
|
||||
// If the buffer is dirty, it will update the driver with the buffer.
|
||||
void is31fl3731_update_pwm_buffers(uint8_t addr, uint8_t index);
|
||||
void is31fl3731_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
void is31fl3731_update_pwm_buffers(uint8_t index);
|
||||
void is31fl3731_update_led_control_registers(uint8_t index);
|
||||
|
||||
void is31fl3731_flush(void);
|
||||
|
||||
#define C1_1 0x24
|
||||
#define C1_2 0x25
|
||||
#define C1_3 0x26
|
||||
#define C1_4 0x27
|
||||
#define C1_5 0x28
|
||||
#define C1_6 0x29
|
||||
#define C1_7 0x2A
|
||||
#define C1_8 0x2B
|
||||
#define C1_1 0x00
|
||||
#define C1_2 0x01
|
||||
#define C1_3 0x02
|
||||
#define C1_4 0x03
|
||||
#define C1_5 0x04
|
||||
#define C1_6 0x05
|
||||
#define C1_7 0x06
|
||||
#define C1_8 0x07
|
||||
|
||||
#define C1_9 0x2C
|
||||
#define C1_10 0x2D
|
||||
#define C1_11 0x2E
|
||||
#define C1_12 0x2F
|
||||
#define C1_13 0x30
|
||||
#define C1_14 0x31
|
||||
#define C1_15 0x32
|
||||
#define C1_16 0x33
|
||||
#define C1_9 0x08
|
||||
#define C1_10 0x09
|
||||
#define C1_11 0x0A
|
||||
#define C1_12 0x0B
|
||||
#define C1_13 0x0C
|
||||
#define C1_14 0x0D
|
||||
#define C1_15 0x0E
|
||||
#define C1_16 0x0F
|
||||
|
||||
#define C2_1 0x34
|
||||
#define C2_2 0x35
|
||||
#define C2_3 0x36
|
||||
#define C2_4 0x37
|
||||
#define C2_5 0x38
|
||||
#define C2_6 0x39
|
||||
#define C2_7 0x3A
|
||||
#define C2_8 0x3B
|
||||
#define C2_1 0x10
|
||||
#define C2_2 0x11
|
||||
#define C2_3 0x12
|
||||
#define C2_4 0x13
|
||||
#define C2_5 0x14
|
||||
#define C2_6 0x15
|
||||
#define C2_7 0x16
|
||||
#define C2_8 0x17
|
||||
|
||||
#define C2_9 0x3C
|
||||
#define C2_10 0x3D
|
||||
#define C2_11 0x3E
|
||||
#define C2_12 0x3F
|
||||
#define C2_13 0x40
|
||||
#define C2_14 0x41
|
||||
#define C2_15 0x42
|
||||
#define C2_16 0x43
|
||||
#define C2_9 0x18
|
||||
#define C2_10 0x19
|
||||
#define C2_11 0x1A
|
||||
#define C2_12 0x1B
|
||||
#define C2_13 0x1C
|
||||
#define C2_14 0x1D
|
||||
#define C2_15 0x1E
|
||||
#define C2_16 0x1F
|
||||
|
||||
#define C3_1 0x44
|
||||
#define C3_2 0x45
|
||||
#define C3_3 0x46
|
||||
#define C3_4 0x47
|
||||
#define C3_5 0x48
|
||||
#define C3_6 0x49
|
||||
#define C3_7 0x4A
|
||||
#define C3_8 0x4B
|
||||
#define C3_1 0x20
|
||||
#define C3_2 0x21
|
||||
#define C3_3 0x22
|
||||
#define C3_4 0x23
|
||||
#define C3_5 0x24
|
||||
#define C3_6 0x25
|
||||
#define C3_7 0x26
|
||||
#define C3_8 0x27
|
||||
|
||||
#define C3_9 0x4C
|
||||
#define C3_10 0x4D
|
||||
#define C3_11 0x4E
|
||||
#define C3_12 0x4F
|
||||
#define C3_13 0x50
|
||||
#define C3_14 0x51
|
||||
#define C3_15 0x52
|
||||
#define C3_16 0x53
|
||||
#define C3_9 0x28
|
||||
#define C3_10 0x29
|
||||
#define C3_11 0x2A
|
||||
#define C3_12 0x2B
|
||||
#define C3_13 0x2C
|
||||
#define C3_14 0x2D
|
||||
#define C3_15 0x2E
|
||||
#define C3_16 0x2F
|
||||
|
||||
#define C4_1 0x54
|
||||
#define C4_2 0x55
|
||||
#define C4_3 0x56
|
||||
#define C4_4 0x57
|
||||
#define C4_5 0x58
|
||||
#define C4_6 0x59
|
||||
#define C4_7 0x5A
|
||||
#define C4_8 0x5B
|
||||
#define C4_1 0x30
|
||||
#define C4_2 0x31
|
||||
#define C4_3 0x32
|
||||
#define C4_4 0x33
|
||||
#define C4_5 0x34
|
||||
#define C4_6 0x35
|
||||
#define C4_7 0x36
|
||||
#define C4_8 0x37
|
||||
|
||||
#define C4_9 0x5C
|
||||
#define C4_10 0x5D
|
||||
#define C4_11 0x5E
|
||||
#define C4_12 0x5F
|
||||
#define C4_13 0x60
|
||||
#define C4_14 0x61
|
||||
#define C4_15 0x62
|
||||
#define C4_16 0x63
|
||||
#define C4_9 0x38
|
||||
#define C4_10 0x39
|
||||
#define C4_11 0x3A
|
||||
#define C4_12 0x3B
|
||||
#define C4_13 0x3C
|
||||
#define C4_14 0x3D
|
||||
#define C4_15 0x3E
|
||||
#define C4_16 0x3F
|
||||
|
||||
#define C5_1 0x64
|
||||
#define C5_2 0x65
|
||||
#define C5_3 0x66
|
||||
#define C5_4 0x67
|
||||
#define C5_5 0x68
|
||||
#define C5_6 0x69
|
||||
#define C5_7 0x6A
|
||||
#define C5_8 0x6B
|
||||
#define C5_1 0x40
|
||||
#define C5_2 0x41
|
||||
#define C5_3 0x42
|
||||
#define C5_4 0x43
|
||||
#define C5_5 0x44
|
||||
#define C5_6 0x45
|
||||
#define C5_7 0x46
|
||||
#define C5_8 0x47
|
||||
|
||||
#define C5_9 0x6C
|
||||
#define C5_10 0x6D
|
||||
#define C5_11 0x6E
|
||||
#define C5_12 0x6F
|
||||
#define C5_13 0x70
|
||||
#define C5_14 0x71
|
||||
#define C5_15 0x72
|
||||
#define C5_16 0x73
|
||||
#define C5_9 0x48
|
||||
#define C5_10 0x49
|
||||
#define C5_11 0x4A
|
||||
#define C5_12 0x4B
|
||||
#define C5_13 0x4C
|
||||
#define C5_14 0x4D
|
||||
#define C5_15 0x4E
|
||||
#define C5_16 0x4F
|
||||
|
||||
#define C6_1 0x74
|
||||
#define C6_2 0x75
|
||||
#define C6_3 0x76
|
||||
#define C6_4 0x77
|
||||
#define C6_5 0x78
|
||||
#define C6_6 0x79
|
||||
#define C6_7 0x7A
|
||||
#define C6_8 0x7B
|
||||
#define C6_1 0x50
|
||||
#define C6_2 0x51
|
||||
#define C6_3 0x52
|
||||
#define C6_4 0x53
|
||||
#define C6_5 0x54
|
||||
#define C6_6 0x55
|
||||
#define C6_7 0x56
|
||||
#define C6_8 0x57
|
||||
|
||||
#define C6_9 0x7C
|
||||
#define C6_10 0x7D
|
||||
#define C6_11 0x7E
|
||||
#define C6_12 0x7F
|
||||
#define C6_13 0x80
|
||||
#define C6_14 0x81
|
||||
#define C6_15 0x82
|
||||
#define C6_16 0x83
|
||||
#define C6_9 0x58
|
||||
#define C6_10 0x59
|
||||
#define C6_11 0x5A
|
||||
#define C6_12 0x5B
|
||||
#define C6_13 0x5C
|
||||
#define C6_14 0x5D
|
||||
#define C6_15 0x5E
|
||||
#define C6_16 0x5F
|
||||
|
||||
#define C7_1 0x84
|
||||
#define C7_2 0x85
|
||||
#define C7_3 0x86
|
||||
#define C7_4 0x87
|
||||
#define C7_5 0x88
|
||||
#define C7_6 0x89
|
||||
#define C7_7 0x8A
|
||||
#define C7_8 0x8B
|
||||
#define C7_1 0x60
|
||||
#define C7_2 0x61
|
||||
#define C7_3 0x62
|
||||
#define C7_4 0x63
|
||||
#define C7_5 0x64
|
||||
#define C7_6 0x65
|
||||
#define C7_7 0x66
|
||||
#define C7_8 0x67
|
||||
|
||||
#define C7_9 0x8C
|
||||
#define C7_10 0x8D
|
||||
#define C7_11 0x8E
|
||||
#define C7_12 0x8F
|
||||
#define C7_13 0x90
|
||||
#define C7_14 0x91
|
||||
#define C7_15 0x92
|
||||
#define C7_16 0x93
|
||||
#define C7_9 0x68
|
||||
#define C7_10 0x69
|
||||
#define C7_11 0x6A
|
||||
#define C7_12 0x6B
|
||||
#define C7_13 0x6C
|
||||
#define C7_14 0x6D
|
||||
#define C7_15 0x6E
|
||||
#define C7_16 0x6F
|
||||
|
||||
#define C8_1 0x94
|
||||
#define C8_2 0x95
|
||||
#define C8_3 0x96
|
||||
#define C8_4 0x97
|
||||
#define C8_5 0x98
|
||||
#define C8_6 0x99
|
||||
#define C8_7 0x9A
|
||||
#define C8_8 0x9B
|
||||
#define C8_1 0x70
|
||||
#define C8_2 0x71
|
||||
#define C8_3 0x72
|
||||
#define C8_4 0x73
|
||||
#define C8_5 0x74
|
||||
#define C8_6 0x75
|
||||
#define C8_7 0x76
|
||||
#define C8_8 0x77
|
||||
|
||||
#define C8_9 0x9C
|
||||
#define C8_10 0x9D
|
||||
#define C8_11 0x9E
|
||||
#define C8_12 0x9F
|
||||
#define C8_13 0xA0
|
||||
#define C8_14 0xA1
|
||||
#define C8_15 0xA2
|
||||
#define C8_16 0xA3
|
||||
#define C8_9 0x78
|
||||
#define C8_10 0x79
|
||||
#define C8_11 0x7A
|
||||
#define C8_12 0x7B
|
||||
#define C8_13 0x7C
|
||||
#define C8_14 0x7D
|
||||
#define C8_15 0x7E
|
||||
#define C8_16 0x7F
|
||||
|
||||
#define C9_1 0xA4
|
||||
#define C9_2 0xA5
|
||||
#define C9_3 0xA6
|
||||
#define C9_4 0xA7
|
||||
#define C9_5 0xA8
|
||||
#define C9_6 0xA9
|
||||
#define C9_7 0xAA
|
||||
#define C9_8 0xAB
|
||||
#define C9_1 0x80
|
||||
#define C9_2 0x81
|
||||
#define C9_3 0x82
|
||||
#define C9_4 0x83
|
||||
#define C9_5 0x84
|
||||
#define C9_6 0x85
|
||||
#define C9_7 0x86
|
||||
#define C9_8 0x87
|
||||
|
||||
#define C9_9 0xAC
|
||||
#define C9_10 0xAD
|
||||
#define C9_11 0xAE
|
||||
#define C9_12 0xAF
|
||||
#define C9_13 0xB0
|
||||
#define C9_14 0xB1
|
||||
#define C9_15 0xB2
|
||||
#define C9_16 0xB3
|
||||
#define C9_9 0x88
|
||||
#define C9_10 0x89
|
||||
#define C9_11 0x8A
|
||||
#define C9_12 0x8B
|
||||
#define C9_13 0x8C
|
||||
#define C9_14 0x8D
|
||||
#define C9_15 0x8E
|
||||
#define C9_16 0x8F
|
|
@ -1,239 +0,0 @@
|
|||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2019 Clueboard
|
||||
* Copyright 2021 Doni Crosby
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "is31fl3731-simple.h"
|
||||
#include <string.h>
|
||||
#include "i2c_master.h"
|
||||
#include "wait.h"
|
||||
|
||||
#define IS31FL3731_PWM_REGISTER_COUNT 144
|
||||
#define IS31FL3731_LED_CONTROL_REGISTER_COUNT 18
|
||||
|
||||
#ifndef IS31FL3731_I2C_TIMEOUT
|
||||
# define IS31FL3731_I2C_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3731_I2C_PERSISTENCE
|
||||
# define IS31FL3731_I2C_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
// Transfer buffer for TWITransmitData()
|
||||
uint8_t g_twi_transfer_buffer[20];
|
||||
|
||||
// These buffers match the IS31FL3731 PWM registers 0x24-0xB3.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
// We could optimize this and take out the unused registers from these
|
||||
// buffers and the transfers in is31fl3731_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
uint8_t g_pwm_buffer[IS31FL3731_DRIVER_COUNT][IS31FL3731_PWM_REGISTER_COUNT];
|
||||
bool g_pwm_buffer_update_required[IS31FL3731_DRIVER_COUNT] = {false};
|
||||
|
||||
uint8_t g_led_control_registers[IS31FL3731_DRIVER_COUNT][IS31FL3731_LED_CONTROL_REGISTER_COUNT] = {0};
|
||||
bool g_led_control_registers_update_required[IS31FL3731_DRIVER_COUNT] = {false};
|
||||
|
||||
void is31fl3731_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
|
||||
#if IS31FL3731_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3731_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3731_I2C_TIMEOUT) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3731_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
||||
// assumes bank is already selected
|
||||
|
||||
// transmit PWM registers in 9 transfers of 16 bytes
|
||||
// g_twi_transfer_buffer[] is 20 bytes
|
||||
|
||||
// iterate over the pwm_buffer contents at 16 byte intervals
|
||||
for (int i = 0; i < IS31FL3731_PWM_REGISTER_COUNT; i += 16) {
|
||||
// set the first register, e.g. 0x24, 0x34, 0x44, etc.
|
||||
g_twi_transfer_buffer[0] = 0x24 + i;
|
||||
// copy the data from i to i+15
|
||||
// device will auto-increment register for data after the first byte
|
||||
// thus this sets registers 0x24-0x33, 0x34-0x43, etc. in one transfer
|
||||
memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 16);
|
||||
|
||||
#if IS31FL3731_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3731_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3731_I2C_TIMEOUT) == 0) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3731_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3731_init_drivers(void) {
|
||||
i2c_init();
|
||||
|
||||
is31fl3731_init(IS31FL3731_I2C_ADDRESS_1);
|
||||
#if defined(IS31FL3731_I2C_ADDRESS_2)
|
||||
is31fl3731_init(IS31FL3731_I2C_ADDRESS_2);
|
||||
# if defined(IS31FL3731_I2C_ADDRESS_3)
|
||||
is31fl3731_init(IS31FL3731_I2C_ADDRESS_3);
|
||||
# if defined(IS31FL3731_I2C_ADDRESS_4)
|
||||
is31fl3731_init(IS31FL3731_I2C_ADDRESS_4);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < IS31FL3731_LED_COUNT; i++) {
|
||||
is31fl3731_set_led_control_register(i, true);
|
||||
}
|
||||
|
||||
is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3731_I2C_ADDRESS_2)
|
||||
is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3731_I2C_ADDRESS_3)
|
||||
is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3731_I2C_ADDRESS_4)
|
||||
is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3731_init(uint8_t addr) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, first enable software shutdown,
|
||||
// then set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
|
||||
// select "function register" bank
|
||||
is31fl3731_write_register(addr, IS31FL3731_REG_COMMAND, IS31FL3731_COMMAND_FUNCTION);
|
||||
|
||||
// enable software shutdown
|
||||
is31fl3731_write_register(addr, IS31FL3731_FUNCTION_REG_SHUTDOWN, 0x00);
|
||||
#ifdef IS31FL3731_DEGHOST // set to enable de-ghosting of the array
|
||||
is31fl3731_write_register(addr, IS31FL3731_FUNCTION_REG_GHOST_IMAGE_PREVENTION, IS31FL3731_GHOST_IMAGE_PREVENTION_GEN);
|
||||
#endif
|
||||
|
||||
// this delay was copied from other drivers, might not be needed
|
||||
wait_ms(10);
|
||||
|
||||
// picture mode
|
||||
is31fl3731_write_register(addr, IS31FL3731_FUNCTION_REG_CONFIG, IS31FL3731_CONFIG_MODE_PICTURE);
|
||||
// display frame 0
|
||||
is31fl3731_write_register(addr, IS31FL3731_FUNCTION_REG_PICTURE_DISPLAY, 0x00);
|
||||
// audio sync off
|
||||
is31fl3731_write_register(addr, IS31FL3731_FUNCTION_REG_AUDIO_SYNC, 0x00);
|
||||
|
||||
// select bank 0
|
||||
is31fl3731_write_register(addr, IS31FL3731_REG_COMMAND, IS31FL3731_COMMAND_FRAME_1);
|
||||
|
||||
// turn off all LEDs in the LED control register
|
||||
for (int i = 0; i < IS31FL3731_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3731_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// turn off all LEDs in the blink control register (not really needed)
|
||||
for (int i = 0x12; i <= 0x23; i++) {
|
||||
is31fl3731_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// set PWM on all LEDs to 0
|
||||
for (int i = 0x24; i <= 0xB3; i++) {
|
||||
is31fl3731_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// select "function register" bank
|
||||
is31fl3731_write_register(addr, IS31FL3731_REG_COMMAND, IS31FL3731_COMMAND_FUNCTION);
|
||||
|
||||
// disable software shutdown
|
||||
is31fl3731_write_register(addr, IS31FL3731_FUNCTION_REG_SHUTDOWN, 0x01);
|
||||
|
||||
// select bank 0 and leave it selected.
|
||||
// most usage after initialization is just writing PWM buffers in bank 0
|
||||
// as there's not much point in double-buffering
|
||||
is31fl3731_write_register(addr, IS31FL3731_REG_COMMAND, IS31FL3731_COMMAND_FRAME_1);
|
||||
}
|
||||
|
||||
void is31fl3731_set_value(int index, uint8_t value) {
|
||||
is31fl3731_led_t led;
|
||||
if (index >= 0 && index < IS31FL3731_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3731_leds[index]), sizeof(led));
|
||||
|
||||
// Subtract 0x24 to get the second index of g_pwm_buffer
|
||||
|
||||
if (g_pwm_buffer[led.driver][led.v - 0x24] == value) {
|
||||
return;
|
||||
}
|
||||
g_pwm_buffer[led.driver][led.v - 0x24] = value;
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3731_set_value_all(uint8_t value) {
|
||||
for (int i = 0; i < IS31FL3731_LED_COUNT; i++) {
|
||||
is31fl3731_set_value(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3731_set_led_control_register(uint8_t index, bool value) {
|
||||
is31fl3731_led_t led;
|
||||
memcpy_P(&led, (&g_is31fl3731_leds[index]), sizeof(led));
|
||||
|
||||
uint8_t control_register = (led.v - 0x24) / 8;
|
||||
uint8_t bit_value = (led.v - 0x24) % 8;
|
||||
|
||||
if (value) {
|
||||
g_led_control_registers[led.driver][control_register] |= (1 << bit_value);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register] &= ~(1 << bit_value);
|
||||
}
|
||||
|
||||
g_led_control_registers_update_required[led.driver] = true;
|
||||
}
|
||||
|
||||
void is31fl3731_update_pwm_buffers(uint8_t addr, uint8_t index) {
|
||||
if (g_pwm_buffer_update_required[index]) {
|
||||
is31fl3731_write_pwm_buffer(addr, g_pwm_buffer[index]);
|
||||
g_pwm_buffer_update_required[index] = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3731_update_led_control_registers(uint8_t addr, uint8_t index) {
|
||||
if (g_led_control_registers_update_required[index]) {
|
||||
for (int i = 0; i < IS31FL3731_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3731_write_register(addr, i, g_led_control_registers[index][i]);
|
||||
}
|
||||
g_led_control_registers_update_required[index] = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3731_flush(void) {
|
||||
is31fl3731_update_pwm_buffers(IS31FL3731_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3731_I2C_ADDRESS_2)
|
||||
is31fl3731_update_pwm_buffers(IS31FL3731_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3731_I2C_ADDRESS_3)
|
||||
is31fl3731_update_pwm_buffers(IS31FL3731_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3731_I2C_ADDRESS_4)
|
||||
is31fl3731_update_pwm_buffers(IS31FL3731_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
}
|
|
@ -17,8 +17,8 @@
|
|||
*/
|
||||
|
||||
#include "is31fl3731.h"
|
||||
#include <string.h>
|
||||
#include "i2c_master.h"
|
||||
#include "gpio.h"
|
||||
#include "wait.h"
|
||||
|
||||
#define IS31FL3731_PWM_REGISTER_COUNT 144
|
||||
|
@ -32,54 +32,64 @@
|
|||
# define IS31FL3731_I2C_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
// Transfer buffer for TWITransmitData()
|
||||
uint8_t g_twi_transfer_buffer[20];
|
||||
const uint8_t i2c_addresses[IS31FL3731_DRIVER_COUNT] = {
|
||||
IS31FL3731_I2C_ADDRESS_1,
|
||||
#ifdef IS31FL3731_I2C_ADDRESS_2
|
||||
IS31FL3731_I2C_ADDRESS_2,
|
||||
# ifdef IS31FL3731_I2C_ADDRESS_3
|
||||
IS31FL3731_I2C_ADDRESS_3,
|
||||
# ifdef IS31FL3731_I2C_ADDRESS_4
|
||||
IS31FL3731_I2C_ADDRESS_4,
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
// These buffers match the IS31FL3731 PWM registers 0x24-0xB3.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
// We could optimize this and take out the unused registers from these
|
||||
// buffers and the transfers in is31fl3731_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
uint8_t g_pwm_buffer[IS31FL3731_DRIVER_COUNT][IS31FL3731_PWM_REGISTER_COUNT];
|
||||
bool g_pwm_buffer_update_required[IS31FL3731_DRIVER_COUNT] = {false};
|
||||
typedef struct is31fl3731_driver_t {
|
||||
uint8_t pwm_buffer[IS31FL3731_PWM_REGISTER_COUNT];
|
||||
bool pwm_buffer_dirty;
|
||||
uint8_t led_control_buffer[IS31FL3731_LED_CONTROL_REGISTER_COUNT];
|
||||
bool led_control_buffer_dirty;
|
||||
} PACKED is31fl3731_driver_t;
|
||||
|
||||
uint8_t g_led_control_registers[IS31FL3731_DRIVER_COUNT][IS31FL3731_LED_CONTROL_REGISTER_COUNT] = {0};
|
||||
bool g_led_control_registers_update_required[IS31FL3731_DRIVER_COUNT] = {false};
|
||||
|
||||
void is31fl3731_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
is31fl3731_driver_t driver_buffers[IS31FL3731_DRIVER_COUNT] = {{
|
||||
.pwm_buffer = {0},
|
||||
.pwm_buffer_dirty = false,
|
||||
.led_control_buffer = {0},
|
||||
.led_control_buffer_dirty = false,
|
||||
}};
|
||||
|
||||
void is31fl3731_write_register(uint8_t index, uint8_t reg, uint8_t data) {
|
||||
#if IS31FL3731_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3731_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3731_I2C_TIMEOUT) == 0) break;
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3731_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3731_I2C_TIMEOUT);
|
||||
i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3731_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
||||
// assumes bank is already selected
|
||||
void is31fl3731_select_page(uint8_t index, uint8_t page) {
|
||||
is31fl3731_write_register(index, IS31FL3731_REG_COMMAND, page);
|
||||
}
|
||||
|
||||
// transmit PWM registers in 9 transfers of 16 bytes
|
||||
// g_twi_transfer_buffer[] is 20 bytes
|
||||
|
||||
// iterate over the pwm_buffer contents at 16 byte intervals
|
||||
for (int i = 0; i < IS31FL3731_PWM_REGISTER_COUNT; i += 16) {
|
||||
// set the first register, e.g. 0x24, 0x34, 0x44, etc.
|
||||
g_twi_transfer_buffer[0] = 0x24 + i;
|
||||
// copy the data from i to i+15
|
||||
// device will auto-increment register for data after the first byte
|
||||
// thus this sets registers 0x24-0x33, 0x34-0x43, etc. in one transfer
|
||||
memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 16);
|
||||
void is31fl3731_write_pwm_buffer(uint8_t index) {
|
||||
// Assumes page 0 is already selected.
|
||||
// Transmit PWM registers in 9 transfers of 16 bytes.
|
||||
|
||||
// Iterate over the pwm_buffer contents at 16 byte intervals.
|
||||
for (uint8_t i = 0; i < IS31FL3731_PWM_REGISTER_COUNT; i += 16) {
|
||||
#if IS31FL3731_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3731_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3731_I2C_TIMEOUT) == 0) break;
|
||||
for (uint8_t j = 0; j < IS31FL3731_I2C_PERSISTENCE; j++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, IS31FL3731_FRAME_REG_PWM + i, driver_buffers[index].pwm_buffer + i, 16, IS31FL3731_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3731_I2C_TIMEOUT);
|
||||
i2c_write_register(i2c_addresses[index] << 1, IS31FL3731_FRAME_REG_PWM + i, driver_buffers[index].pwm_buffer + i, 16, IS31FL3731_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -87,101 +97,90 @@ void is31fl3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
|||
void is31fl3731_init_drivers(void) {
|
||||
i2c_init();
|
||||
|
||||
is31fl3731_init(IS31FL3731_I2C_ADDRESS_1);
|
||||
#if defined(IS31FL3731_I2C_ADDRESS_2)
|
||||
is31fl3731_init(IS31FL3731_I2C_ADDRESS_2);
|
||||
# if defined(IS31FL3731_I2C_ADDRESS_3)
|
||||
is31fl3731_init(IS31FL3731_I2C_ADDRESS_3);
|
||||
# if defined(IS31FL3731_I2C_ADDRESS_4)
|
||||
is31fl3731_init(IS31FL3731_I2C_ADDRESS_4);
|
||||
# endif
|
||||
# endif
|
||||
#if defined(IS31FL3731_SDB_PIN)
|
||||
gpio_set_pin_output(IS31FL3731_SDB_PIN);
|
||||
gpio_write_pin_high(IS31FL3731_SDB_PIN);
|
||||
#endif
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3731_DRIVER_COUNT; i++) {
|
||||
is31fl3731_init(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < IS31FL3731_LED_COUNT; i++) {
|
||||
is31fl3731_set_led_control_register(i, true, true, true);
|
||||
}
|
||||
|
||||
is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3731_I2C_ADDRESS_2)
|
||||
is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3731_I2C_ADDRESS_3)
|
||||
is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3731_I2C_ADDRESS_4)
|
||||
is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
for (uint8_t i = 0; i < IS31FL3731_DRIVER_COUNT; i++) {
|
||||
is31fl3731_update_led_control_registers(i);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3731_init(uint8_t addr) {
|
||||
void is31fl3731_init(uint8_t index) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, first enable software shutdown,
|
||||
// then set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
|
||||
// select "function register" bank
|
||||
is31fl3731_write_register(addr, IS31FL3731_REG_COMMAND, IS31FL3731_COMMAND_FUNCTION);
|
||||
is31fl3731_select_page(index, IS31FL3731_COMMAND_FUNCTION);
|
||||
|
||||
// enable software shutdown
|
||||
is31fl3731_write_register(addr, IS31FL3731_FUNCTION_REG_SHUTDOWN, 0x00);
|
||||
is31fl3731_write_register(index, IS31FL3731_FUNCTION_REG_SHUTDOWN, 0x00);
|
||||
#ifdef IS31FL3731_DEGHOST // set to enable de-ghosting of the array
|
||||
is31fl3731_write_register(addr, IS31FL3731_FUNCTION_REG_GHOST_IMAGE_PREVENTION, IS31FL3731_GHOST_IMAGE_PREVENTION_GEN);
|
||||
is31fl3731_write_register(index, IS31FL3731_FUNCTION_REG_GHOST_IMAGE_PREVENTION, IS31FL3731_GHOST_IMAGE_PREVENTION_GEN);
|
||||
#endif
|
||||
|
||||
// this delay was copied from other drivers, might not be needed
|
||||
wait_ms(10);
|
||||
|
||||
// picture mode
|
||||
is31fl3731_write_register(addr, IS31FL3731_FUNCTION_REG_CONFIG, IS31FL3731_CONFIG_MODE_PICTURE);
|
||||
is31fl3731_write_register(index, IS31FL3731_FUNCTION_REG_CONFIG, IS31FL3731_CONFIG_MODE_PICTURE);
|
||||
// display frame 0
|
||||
is31fl3731_write_register(addr, IS31FL3731_FUNCTION_REG_PICTURE_DISPLAY, 0x00);
|
||||
is31fl3731_write_register(index, IS31FL3731_FUNCTION_REG_PICTURE_DISPLAY, 0x00);
|
||||
// audio sync off
|
||||
is31fl3731_write_register(addr, IS31FL3731_FUNCTION_REG_AUDIO_SYNC, 0x00);
|
||||
is31fl3731_write_register(index, IS31FL3731_FUNCTION_REG_AUDIO_SYNC, 0x00);
|
||||
|
||||
// select bank 0
|
||||
is31fl3731_write_register(addr, IS31FL3731_REG_COMMAND, IS31FL3731_COMMAND_FRAME_1);
|
||||
is31fl3731_select_page(index, IS31FL3731_COMMAND_FRAME_1);
|
||||
|
||||
// turn off all LEDs in the LED control register
|
||||
for (int i = 0; i < IS31FL3731_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3731_write_register(addr, i, 0x00);
|
||||
for (uint8_t i = 0; i < IS31FL3731_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3731_write_register(index, IS31FL3731_FRAME_REG_LED_CONTROL + i, 0x00);
|
||||
}
|
||||
|
||||
// turn off all LEDs in the blink control register (not really needed)
|
||||
for (int i = 0x12; i <= 0x23; i++) {
|
||||
is31fl3731_write_register(addr, i, 0x00);
|
||||
for (uint8_t i = 0; i < IS31FL3731_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3731_write_register(index, IS31FL3731_FRAME_REG_BLINK_CONTROL + i, 0x00);
|
||||
}
|
||||
|
||||
// set PWM on all LEDs to 0
|
||||
for (int i = 0x24; i <= 0xB3; i++) {
|
||||
is31fl3731_write_register(addr, i, 0x00);
|
||||
for (uint8_t i = 0; i < IS31FL3731_PWM_REGISTER_COUNT; i++) {
|
||||
is31fl3731_write_register(index, IS31FL3731_FRAME_REG_PWM + i, 0x00);
|
||||
}
|
||||
|
||||
// select "function register" bank
|
||||
is31fl3731_write_register(addr, IS31FL3731_REG_COMMAND, IS31FL3731_COMMAND_FUNCTION);
|
||||
is31fl3731_select_page(index, IS31FL3731_COMMAND_FUNCTION);
|
||||
|
||||
// disable software shutdown
|
||||
is31fl3731_write_register(addr, IS31FL3731_FUNCTION_REG_SHUTDOWN, 0x01);
|
||||
is31fl3731_write_register(index, IS31FL3731_FUNCTION_REG_SHUTDOWN, 0x01);
|
||||
|
||||
// select bank 0 and leave it selected.
|
||||
// most usage after initialization is just writing PWM buffers in bank 0
|
||||
// select page 0 and leave it selected.
|
||||
// most usage after initialization is just writing PWM buffers in page 0
|
||||
// as there's not much point in double-buffering
|
||||
is31fl3731_write_register(addr, IS31FL3731_REG_COMMAND, IS31FL3731_COMMAND_FRAME_1);
|
||||
is31fl3731_select_page(index, IS31FL3731_COMMAND_FRAME_1);
|
||||
}
|
||||
|
||||
void is31fl3731_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
is31fl3731_led_t led;
|
||||
|
||||
if (index >= 0 && index < IS31FL3731_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3731_leds[index]), sizeof(led));
|
||||
|
||||
// Subtract 0x24 to get the second index of g_pwm_buffer
|
||||
if (g_pwm_buffer[led.driver][led.r - 0x24] == red && g_pwm_buffer[led.driver][led.g - 0x24] == green && g_pwm_buffer[led.driver][led.b - 0x24] == blue) {
|
||||
if (driver_buffers[led.driver].pwm_buffer[led.r] == red && driver_buffers[led.driver].pwm_buffer[led.g] == green && driver_buffers[led.driver].pwm_buffer[led.b] == blue) {
|
||||
return;
|
||||
}
|
||||
g_pwm_buffer[led.driver][led.r - 0x24] = red;
|
||||
g_pwm_buffer[led.driver][led.g - 0x24] = green;
|
||||
g_pwm_buffer[led.driver][led.b - 0x24] = blue;
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
|
||||
driver_buffers[led.driver].pwm_buffer[led.r] = red;
|
||||
driver_buffers[led.driver].pwm_buffer[led.g] = green;
|
||||
driver_buffers[led.driver].pwm_buffer[led.b] = blue;
|
||||
driver_buffers[led.driver].pwm_buffer_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -195,57 +194,52 @@ void is31fl3731_set_led_control_register(uint8_t index, bool red, bool green, bo
|
|||
is31fl3731_led_t led;
|
||||
memcpy_P(&led, (&g_is31fl3731_leds[index]), sizeof(led));
|
||||
|
||||
uint8_t control_register_r = (led.r - 0x24) / 8;
|
||||
uint8_t control_register_g = (led.g - 0x24) / 8;
|
||||
uint8_t control_register_b = (led.b - 0x24) / 8;
|
||||
uint8_t bit_r = (led.r - 0x24) % 8;
|
||||
uint8_t bit_g = (led.g - 0x24) % 8;
|
||||
uint8_t bit_b = (led.b - 0x24) % 8;
|
||||
uint8_t control_register_r = led.r / 8;
|
||||
uint8_t control_register_g = led.g / 8;
|
||||
uint8_t control_register_b = led.b / 8;
|
||||
uint8_t bit_r = led.r % 8;
|
||||
uint8_t bit_g = led.g % 8;
|
||||
uint8_t bit_b = led.b % 8;
|
||||
|
||||
if (red) {
|
||||
g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_r] |= (1 << bit_r);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_r] &= ~(1 << bit_r);
|
||||
}
|
||||
if (green) {
|
||||
g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_g] |= (1 << bit_g);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_g] &= ~(1 << bit_g);
|
||||
}
|
||||
if (blue) {
|
||||
g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_b] |= (1 << bit_b);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_b] &= ~(1 << bit_b);
|
||||
}
|
||||
|
||||
g_led_control_registers_update_required[led.driver] = true;
|
||||
driver_buffers[led.driver].led_control_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3731_update_pwm_buffers(uint8_t addr, uint8_t index) {
|
||||
if (g_pwm_buffer_update_required[index]) {
|
||||
is31fl3731_write_pwm_buffer(addr, g_pwm_buffer[index]);
|
||||
void is31fl3731_update_pwm_buffers(uint8_t index) {
|
||||
if (driver_buffers[index].pwm_buffer_dirty) {
|
||||
is31fl3731_write_pwm_buffer(index);
|
||||
|
||||
driver_buffers[index].pwm_buffer_dirty = false;
|
||||
}
|
||||
g_pwm_buffer_update_required[index] = false;
|
||||
}
|
||||
|
||||
void is31fl3731_update_led_control_registers(uint8_t addr, uint8_t index) {
|
||||
if (g_led_control_registers_update_required[index]) {
|
||||
for (int i = 0; i < IS31FL3731_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3731_write_register(addr, i, g_led_control_registers[index][i]);
|
||||
void is31fl3731_update_led_control_registers(uint8_t index) {
|
||||
if (driver_buffers[index].led_control_buffer_dirty) {
|
||||
for (uint8_t i = 0; i < IS31FL3731_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3731_write_register(index, i, driver_buffers[index].led_control_buffer[i]);
|
||||
}
|
||||
|
||||
driver_buffers[index].led_control_buffer_dirty = false;
|
||||
}
|
||||
g_led_control_registers_update_required[index] = false;
|
||||
}
|
||||
|
||||
void is31fl3731_flush(void) {
|
||||
is31fl3731_update_pwm_buffers(IS31FL3731_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3731_I2C_ADDRESS_2)
|
||||
is31fl3731_update_pwm_buffers(IS31FL3731_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3731_I2C_ADDRESS_3)
|
||||
is31fl3731_update_pwm_buffers(IS31FL3731_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3731_I2C_ADDRESS_4)
|
||||
is31fl3731_update_pwm_buffers(IS31FL3731_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
for (uint8_t i = 0; i < IS31FL3731_DRIVER_COUNT; i++) {
|
||||
is31fl3731_update_pwm_buffers(i);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,10 @@
|
|||
#define IS31FL3731_COMMAND_FRAME_8 0x07
|
||||
#define IS31FL3731_COMMAND_FUNCTION 0x0B
|
||||
|
||||
#define IS31FL3731_FRAME_REG_LED_CONTROL 0x00
|
||||
#define IS31FL3731_FRAME_REG_BLINK_CONTROL 0x12
|
||||
#define IS31FL3731_FRAME_REG_PWM 0x24
|
||||
|
||||
#define IS31FL3731_FUNCTION_REG_CONFIG 0x00
|
||||
#define IS31FL3731_CONFIG_MODE_PICTURE 0x00
|
||||
#define IS31FL3731_CONFIG_MODE_AUTO_PLAY 0x08
|
||||
|
@ -102,9 +106,9 @@ typedef struct is31fl3731_led_t {
|
|||
extern const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT];
|
||||
|
||||
void is31fl3731_init_drivers(void);
|
||||
void is31fl3731_init(uint8_t addr);
|
||||
void is31fl3731_write_register(uint8_t addr, uint8_t reg, uint8_t data);
|
||||
void is31fl3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
|
||||
void is31fl3731_init(uint8_t index);
|
||||
void is31fl3731_write_register(uint8_t index, uint8_t reg, uint8_t data);
|
||||
void is31fl3731_select_page(uint8_t index, uint8_t page);
|
||||
|
||||
void is31fl3731_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
|
||||
void is31fl3731_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
@ -115,169 +119,169 @@ void is31fl3731_set_led_control_register(uint8_t index, bool red, bool green, bo
|
|||
// (eg. from a timer interrupt).
|
||||
// Call this while idle (in between matrix scans).
|
||||
// If the buffer is dirty, it will update the driver with the buffer.
|
||||
void is31fl3731_update_pwm_buffers(uint8_t addr, uint8_t index);
|
||||
void is31fl3731_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
void is31fl3731_update_pwm_buffers(uint8_t index);
|
||||
void is31fl3731_update_led_control_registers(uint8_t index);
|
||||
|
||||
void is31fl3731_flush(void);
|
||||
|
||||
#define C1_1 0x24
|
||||
#define C1_2 0x25
|
||||
#define C1_3 0x26
|
||||
#define C1_4 0x27
|
||||
#define C1_5 0x28
|
||||
#define C1_6 0x29
|
||||
#define C1_7 0x2A
|
||||
#define C1_8 0x2B
|
||||
#define C1_1 0x00
|
||||
#define C1_2 0x01
|
||||
#define C1_3 0x02
|
||||
#define C1_4 0x03
|
||||
#define C1_5 0x04
|
||||
#define C1_6 0x05
|
||||
#define C1_7 0x06
|
||||
#define C1_8 0x07
|
||||
|
||||
#define C1_9 0x2C
|
||||
#define C1_10 0x2D
|
||||
#define C1_11 0x2E
|
||||
#define C1_12 0x2F
|
||||
#define C1_13 0x30
|
||||
#define C1_14 0x31
|
||||
#define C1_15 0x32
|
||||
#define C1_16 0x33
|
||||
#define C1_9 0x08
|
||||
#define C1_10 0x09
|
||||
#define C1_11 0x0A
|
||||
#define C1_12 0x0B
|
||||
#define C1_13 0x0C
|
||||
#define C1_14 0x0D
|
||||
#define C1_15 0x0E
|
||||
#define C1_16 0x0F
|
||||
|
||||
#define C2_1 0x34
|
||||
#define C2_2 0x35
|
||||
#define C2_3 0x36
|
||||
#define C2_4 0x37
|
||||
#define C2_5 0x38
|
||||
#define C2_6 0x39
|
||||
#define C2_7 0x3A
|
||||
#define C2_8 0x3B
|
||||
#define C2_1 0x10
|
||||
#define C2_2 0x11
|
||||
#define C2_3 0x12
|
||||
#define C2_4 0x13
|
||||
#define C2_5 0x14
|
||||
#define C2_6 0x15
|
||||
#define C2_7 0x16
|
||||
#define C2_8 0x17
|
||||
|
||||
#define C2_9 0x3C
|
||||
#define C2_10 0x3D
|
||||
#define C2_11 0x3E
|
||||
#define C2_12 0x3F
|
||||
#define C2_13 0x40
|
||||
#define C2_14 0x41
|
||||
#define C2_15 0x42
|
||||
#define C2_16 0x43
|
||||
#define C2_9 0x18
|
||||
#define C2_10 0x19
|
||||
#define C2_11 0x1A
|
||||
#define C2_12 0x1B
|
||||
#define C2_13 0x1C
|
||||
#define C2_14 0x1D
|
||||
#define C2_15 0x1E
|
||||
#define C2_16 0x1F
|
||||
|
||||
#define C3_1 0x44
|
||||
#define C3_2 0x45
|
||||
#define C3_3 0x46
|
||||
#define C3_4 0x47
|
||||
#define C3_5 0x48
|
||||
#define C3_6 0x49
|
||||
#define C3_7 0x4A
|
||||
#define C3_8 0x4B
|
||||
#define C3_1 0x20
|
||||
#define C3_2 0x21
|
||||
#define C3_3 0x22
|
||||
#define C3_4 0x23
|
||||
#define C3_5 0x24
|
||||
#define C3_6 0x25
|
||||
#define C3_7 0x26
|
||||
#define C3_8 0x27
|
||||
|
||||
#define C3_9 0x4C
|
||||
#define C3_10 0x4D
|
||||
#define C3_11 0x4E
|
||||
#define C3_12 0x4F
|
||||
#define C3_13 0x50
|
||||
#define C3_14 0x51
|
||||
#define C3_15 0x52
|
||||
#define C3_16 0x53
|
||||
#define C3_9 0x28
|
||||
#define C3_10 0x29
|
||||
#define C3_11 0x2A
|
||||
#define C3_12 0x2B
|
||||
#define C3_13 0x2C
|
||||
#define C3_14 0x2D
|
||||
#define C3_15 0x2E
|
||||
#define C3_16 0x2F
|
||||
|
||||
#define C4_1 0x54
|
||||
#define C4_2 0x55
|
||||
#define C4_3 0x56
|
||||
#define C4_4 0x57
|
||||
#define C4_5 0x58
|
||||
#define C4_6 0x59
|
||||
#define C4_7 0x5A
|
||||
#define C4_8 0x5B
|
||||
#define C4_1 0x30
|
||||
#define C4_2 0x31
|
||||
#define C4_3 0x32
|
||||
#define C4_4 0x33
|
||||
#define C4_5 0x34
|
||||
#define C4_6 0x35
|
||||
#define C4_7 0x36
|
||||
#define C4_8 0x37
|
||||
|
||||
#define C4_9 0x5C
|
||||
#define C4_10 0x5D
|
||||
#define C4_11 0x5E
|
||||
#define C4_12 0x5F
|
||||
#define C4_13 0x60
|
||||
#define C4_14 0x61
|
||||
#define C4_15 0x62
|
||||
#define C4_16 0x63
|
||||
#define C4_9 0x38
|
||||
#define C4_10 0x39
|
||||
#define C4_11 0x3A
|
||||
#define C4_12 0x3B
|
||||
#define C4_13 0x3C
|
||||
#define C4_14 0x3D
|
||||
#define C4_15 0x3E
|
||||
#define C4_16 0x3F
|
||||
|
||||
#define C5_1 0x64
|
||||
#define C5_2 0x65
|
||||
#define C5_3 0x66
|
||||
#define C5_4 0x67
|
||||
#define C5_5 0x68
|
||||
#define C5_6 0x69
|
||||
#define C5_7 0x6A
|
||||
#define C5_8 0x6B
|
||||
#define C5_1 0x40
|
||||
#define C5_2 0x41
|
||||
#define C5_3 0x42
|
||||
#define C5_4 0x43
|
||||
#define C5_5 0x44
|
||||
#define C5_6 0x45
|
||||
#define C5_7 0x46
|
||||
#define C5_8 0x47
|
||||
|
||||
#define C5_9 0x6C
|
||||
#define C5_10 0x6D
|
||||
#define C5_11 0x6E
|
||||
#define C5_12 0x6F
|
||||
#define C5_13 0x70
|
||||
#define C5_14 0x71
|
||||
#define C5_15 0x72
|
||||
#define C5_16 0x73
|
||||
#define C5_9 0x48
|
||||
#define C5_10 0x49
|
||||
#define C5_11 0x4A
|
||||
#define C5_12 0x4B
|
||||
#define C5_13 0x4C
|
||||
#define C5_14 0x4D
|
||||
#define C5_15 0x4E
|
||||
#define C5_16 0x4F
|
||||
|
||||
#define C6_1 0x74
|
||||
#define C6_2 0x75
|
||||
#define C6_3 0x76
|
||||
#define C6_4 0x77
|
||||
#define C6_5 0x78
|
||||
#define C6_6 0x79
|
||||
#define C6_7 0x7A
|
||||
#define C6_8 0x7B
|
||||
#define C6_1 0x50
|
||||
#define C6_2 0x51
|
||||
#define C6_3 0x52
|
||||
#define C6_4 0x53
|
||||
#define C6_5 0x54
|
||||
#define C6_6 0x55
|
||||
#define C6_7 0x56
|
||||
#define C6_8 0x57
|
||||
|
||||
#define C6_9 0x7C
|
||||
#define C6_10 0x7D
|
||||
#define C6_11 0x7E
|
||||
#define C6_12 0x7F
|
||||
#define C6_13 0x80
|
||||
#define C6_14 0x81
|
||||
#define C6_15 0x82
|
||||
#define C6_16 0x83
|
||||
#define C6_9 0x58
|
||||
#define C6_10 0x59
|
||||
#define C6_11 0x5A
|
||||
#define C6_12 0x5B
|
||||
#define C6_13 0x5C
|
||||
#define C6_14 0x5D
|
||||
#define C6_15 0x5E
|
||||
#define C6_16 0x5F
|
||||
|
||||
#define C7_1 0x84
|
||||
#define C7_2 0x85
|
||||
#define C7_3 0x86
|
||||
#define C7_4 0x87
|
||||
#define C7_5 0x88
|
||||
#define C7_6 0x89
|
||||
#define C7_7 0x8A
|
||||
#define C7_8 0x8B
|
||||
#define C7_1 0x60
|
||||
#define C7_2 0x61
|
||||
#define C7_3 0x62
|
||||
#define C7_4 0x63
|
||||
#define C7_5 0x64
|
||||
#define C7_6 0x65
|
||||
#define C7_7 0x66
|
||||
#define C7_8 0x67
|
||||
|
||||
#define C7_9 0x8C
|
||||
#define C7_10 0x8D
|
||||
#define C7_11 0x8E
|
||||
#define C7_12 0x8F
|
||||
#define C7_13 0x90
|
||||
#define C7_14 0x91
|
||||
#define C7_15 0x92
|
||||
#define C7_16 0x93
|
||||
#define C7_9 0x68
|
||||
#define C7_10 0x69
|
||||
#define C7_11 0x6A
|
||||
#define C7_12 0x6B
|
||||
#define C7_13 0x6C
|
||||
#define C7_14 0x6D
|
||||
#define C7_15 0x6E
|
||||
#define C7_16 0x6F
|
||||
|
||||
#define C8_1 0x94
|
||||
#define C8_2 0x95
|
||||
#define C8_3 0x96
|
||||
#define C8_4 0x97
|
||||
#define C8_5 0x98
|
||||
#define C8_6 0x99
|
||||
#define C8_7 0x9A
|
||||
#define C8_8 0x9B
|
||||
#define C8_1 0x70
|
||||
#define C8_2 0x71
|
||||
#define C8_3 0x72
|
||||
#define C8_4 0x73
|
||||
#define C8_5 0x74
|
||||
#define C8_6 0x75
|
||||
#define C8_7 0x76
|
||||
#define C8_8 0x77
|
||||
|
||||
#define C8_9 0x9C
|
||||
#define C8_10 0x9D
|
||||
#define C8_11 0x9E
|
||||
#define C8_12 0x9F
|
||||
#define C8_13 0xA0
|
||||
#define C8_14 0xA1
|
||||
#define C8_15 0xA2
|
||||
#define C8_16 0xA3
|
||||
#define C8_9 0x78
|
||||
#define C8_10 0x79
|
||||
#define C8_11 0x7A
|
||||
#define C8_12 0x7B
|
||||
#define C8_13 0x7C
|
||||
#define C8_14 0x7D
|
||||
#define C8_15 0x7E
|
||||
#define C8_16 0x7F
|
||||
|
||||
#define C9_1 0xA4
|
||||
#define C9_2 0xA5
|
||||
#define C9_3 0xA6
|
||||
#define C9_4 0xA7
|
||||
#define C9_5 0xA8
|
||||
#define C9_6 0xA9
|
||||
#define C9_7 0xAA
|
||||
#define C9_8 0xAB
|
||||
#define C9_1 0x80
|
||||
#define C9_2 0x81
|
||||
#define C9_3 0x82
|
||||
#define C9_4 0x83
|
||||
#define C9_5 0x84
|
||||
#define C9_6 0x85
|
||||
#define C9_7 0x86
|
||||
#define C9_8 0x87
|
||||
|
||||
#define C9_9 0xAC
|
||||
#define C9_10 0xAD
|
||||
#define C9_11 0xAE
|
||||
#define C9_12 0xAF
|
||||
#define C9_13 0xB0
|
||||
#define C9_14 0xB1
|
||||
#define C9_15 0xB2
|
||||
#define C9_16 0xB3
|
||||
#define C9_9 0x88
|
||||
#define C9_10 0x89
|
||||
#define C9_11 0x8A
|
||||
#define C9_12 0x8B
|
||||
#define C9_13 0x8C
|
||||
#define C9_14 0x8D
|
||||
#define C9_15 0x8E
|
||||
#define C9_16 0x8F
|
||||
|
|
265
drivers/led/issi/is31fl3733-mono.c
Normal file
265
drivers/led/issi/is31fl3733-mono.c
Normal file
|
@ -0,0 +1,265 @@
|
|||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2021 Doni Crosby
|
||||
* Copyright 2021 Leo Deng
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "is31fl3733-mono.h"
|
||||
#include "i2c_master.h"
|
||||
#include "gpio.h"
|
||||
#include "wait.h"
|
||||
|
||||
#define IS31FL3733_PWM_REGISTER_COUNT 192
|
||||
#define IS31FL3733_LED_CONTROL_REGISTER_COUNT 24
|
||||
|
||||
#ifndef IS31FL3733_I2C_TIMEOUT
|
||||
# define IS31FL3733_I2C_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3733_I2C_PERSISTENCE
|
||||
# define IS31FL3733_I2C_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3733_PWM_FREQUENCY
|
||||
# define IS31FL3733_PWM_FREQUENCY IS31FL3733_PWM_FREQUENCY_8K4_HZ // PFS - IS31FL3733B only
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3733_SW_PULLUP
|
||||
# define IS31FL3733_SW_PULLUP IS31FL3733_PUR_0_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3733_CS_PULLDOWN
|
||||
# define IS31FL3733_CS_PULLDOWN IS31FL3733_PDR_0_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3733_GLOBAL_CURRENT
|
||||
# define IS31FL3733_GLOBAL_CURRENT 0xFF
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3733_SYNC_1
|
||||
# define IS31FL3733_SYNC_1 IS31FL3733_SYNC_NONE
|
||||
#endif
|
||||
#ifndef IS31FL3733_SYNC_2
|
||||
# define IS31FL3733_SYNC_2 IS31FL3733_SYNC_NONE
|
||||
#endif
|
||||
#ifndef IS31FL3733_SYNC_3
|
||||
# define IS31FL3733_SYNC_3 IS31FL3733_SYNC_NONE
|
||||
#endif
|
||||
#ifndef IS31FL3733_SYNC_4
|
||||
# define IS31FL3733_SYNC_4 IS31FL3733_SYNC_NONE
|
||||
#endif
|
||||
|
||||
const uint8_t i2c_addresses[IS31FL3733_DRIVER_COUNT] = {
|
||||
IS31FL3733_I2C_ADDRESS_1,
|
||||
#ifdef IS31FL3733_I2C_ADDRESS_2
|
||||
IS31FL3733_I2C_ADDRESS_2,
|
||||
# ifdef IS31FL3733_I2C_ADDRESS_3
|
||||
IS31FL3733_I2C_ADDRESS_3,
|
||||
# ifdef IS31FL3733_I2C_ADDRESS_4
|
||||
IS31FL3733_I2C_ADDRESS_4,
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
const uint8_t driver_sync[IS31FL3733_DRIVER_COUNT] = {
|
||||
IS31FL3733_SYNC_1,
|
||||
#ifdef IS31FL3733_I2C_ADDRESS_2
|
||||
IS31FL3733_SYNC_2,
|
||||
# ifdef IS31FL3733_I2C_ADDRESS_3
|
||||
IS31FL3733_SYNC_3,
|
||||
# ifdef IS31FL3733_I2C_ADDRESS_4
|
||||
IS31FL3733_SYNC_4,
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
// These buffers match the IS31FL3733 PWM registers.
|
||||
// The control buffers match the page 0 LED On/Off registers.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
// We could optimize this and take out the unused registers from these
|
||||
// buffers and the transfers in is31fl3733_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
typedef struct is31fl3733_driver_t {
|
||||
uint8_t pwm_buffer[IS31FL3733_PWM_REGISTER_COUNT];
|
||||
bool pwm_buffer_dirty;
|
||||
uint8_t led_control_buffer[IS31FL3733_LED_CONTROL_REGISTER_COUNT];
|
||||
bool led_control_buffer_dirty;
|
||||
} PACKED is31fl3733_driver_t;
|
||||
|
||||
is31fl3733_driver_t driver_buffers[IS31FL3733_DRIVER_COUNT] = {{
|
||||
.pwm_buffer = {0},
|
||||
.pwm_buffer_dirty = false,
|
||||
.led_control_buffer = {0},
|
||||
.led_control_buffer_dirty = false,
|
||||
}};
|
||||
|
||||
void is31fl3733_write_register(uint8_t index, uint8_t reg, uint8_t data) {
|
||||
#if IS31FL3733_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3733_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3733_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3733_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3733_select_page(uint8_t index, uint8_t page) {
|
||||
is31fl3733_write_register(index, IS31FL3733_REG_COMMAND_WRITE_LOCK, IS31FL3733_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3733_write_register(index, IS31FL3733_REG_COMMAND, page);
|
||||
}
|
||||
|
||||
void is31fl3733_write_pwm_buffer(uint8_t index) {
|
||||
// Assumes page 1 is already selected.
|
||||
// Transmit PWM registers in 12 transfers of 16 bytes.
|
||||
|
||||
// Iterate over the pwm_buffer contents at 16 byte intervals.
|
||||
for (uint8_t i = 0; i < IS31FL3733_PWM_REGISTER_COUNT; i += 16) {
|
||||
#if IS31FL3733_I2C_PERSISTENCE > 0
|
||||
for (uint8_t j = 0; j < IS31FL3733_I2C_PERSISTENCE; j++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer + i, 16, IS31FL3733_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer + i, 16, IS31FL3733_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3733_init_drivers(void) {
|
||||
i2c_init();
|
||||
|
||||
#if defined(IS31FL3733_SDB_PIN)
|
||||
gpio_set_pin_output(IS31FL3733_SDB_PIN);
|
||||
gpio_write_pin_high(IS31FL3733_SDB_PIN);
|
||||
#endif
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3733_DRIVER_COUNT; i++) {
|
||||
is31fl3733_init(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < IS31FL3733_LED_COUNT; i++) {
|
||||
is31fl3733_set_led_control_register(i, true);
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3733_DRIVER_COUNT; i++) {
|
||||
is31fl3733_update_led_control_registers(i);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3733_init(uint8_t index) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
|
||||
is31fl3733_select_page(index, IS31FL3733_COMMAND_LED_CONTROL);
|
||||
|
||||
// Turn off all LEDs.
|
||||
for (uint8_t i = 0; i < IS31FL3733_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3733_write_register(index, i, 0x00);
|
||||
}
|
||||
|
||||
is31fl3733_select_page(index, IS31FL3733_COMMAND_PWM);
|
||||
|
||||
// Set PWM on all LEDs to 0
|
||||
// No need to setup Breath registers to PWM as that is the default.
|
||||
for (uint8_t i = 0; i < IS31FL3733_PWM_REGISTER_COUNT; i++) {
|
||||
is31fl3733_write_register(index, i, 0x00);
|
||||
}
|
||||
|
||||
is31fl3733_select_page(index, IS31FL3733_COMMAND_FUNCTION);
|
||||
|
||||
uint8_t sync = driver_sync[index];
|
||||
|
||||
// Set de-ghost pull-up resistors (SWx)
|
||||
is31fl3733_write_register(index, IS31FL3733_FUNCTION_REG_SW_PULLUP, IS31FL3733_SW_PULLUP);
|
||||
// Set de-ghost pull-down resistors (CSx)
|
||||
is31fl3733_write_register(index, IS31FL3733_FUNCTION_REG_CS_PULLDOWN, IS31FL3733_CS_PULLDOWN);
|
||||
// Set global current to maximum.
|
||||
is31fl3733_write_register(index, IS31FL3733_FUNCTION_REG_GLOBAL_CURRENT, IS31FL3733_GLOBAL_CURRENT);
|
||||
// Disable software shutdown.
|
||||
is31fl3733_write_register(index, IS31FL3733_FUNCTION_REG_CONFIGURATION, ((sync & 0b11) << 6) | ((IS31FL3733_PWM_FREQUENCY & 0b111) << 3) | 0x01);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
wait_ms(10);
|
||||
}
|
||||
|
||||
void is31fl3733_set_value(int index, uint8_t value) {
|
||||
is31fl3733_led_t led;
|
||||
|
||||
if (index >= 0 && index < IS31FL3733_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3733_leds[index]), sizeof(led));
|
||||
|
||||
if (driver_buffers[led.driver].pwm_buffer[led.v] == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
driver_buffers[led.driver].pwm_buffer[led.v] = value;
|
||||
driver_buffers[led.driver].pwm_buffer_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3733_set_value_all(uint8_t value) {
|
||||
for (int i = 0; i < IS31FL3733_LED_COUNT; i++) {
|
||||
is31fl3733_set_value(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3733_set_led_control_register(uint8_t index, bool value) {
|
||||
is31fl3733_led_t led;
|
||||
memcpy_P(&led, (&g_is31fl3733_leds[index]), sizeof(led));
|
||||
|
||||
uint8_t control_register = led.v / 8;
|
||||
uint8_t bit_value = led.v % 8;
|
||||
|
||||
if (value) {
|
||||
driver_buffers[led.driver].led_control_buffer[control_register] |= (1 << bit_value);
|
||||
} else {
|
||||
driver_buffers[led.driver].led_control_buffer[control_register] &= ~(1 << bit_value);
|
||||
}
|
||||
|
||||
driver_buffers[led.driver].led_control_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3733_update_pwm_buffers(uint8_t index) {
|
||||
if (driver_buffers[index].pwm_buffer_dirty) {
|
||||
is31fl3733_select_page(index, IS31FL3733_COMMAND_PWM);
|
||||
|
||||
is31fl3733_write_pwm_buffer(index);
|
||||
|
||||
driver_buffers[index].pwm_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3733_update_led_control_registers(uint8_t index) {
|
||||
if (driver_buffers[index].led_control_buffer_dirty) {
|
||||
is31fl3733_select_page(index, IS31FL3733_COMMAND_LED_CONTROL);
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3733_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3733_write_register(index, i, driver_buffers[index].led_control_buffer[i]);
|
||||
}
|
||||
|
||||
driver_buffers[index].led_control_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3733_flush(void) {
|
||||
for (uint8_t i = 0; i < IS31FL3733_DRIVER_COUNT; i++) {
|
||||
is31fl3733_update_pwm_buffers(i);
|
||||
}
|
||||
}
|
|
@ -115,9 +115,9 @@ typedef struct is31fl3733_led_t {
|
|||
extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT];
|
||||
|
||||
void is31fl3733_init_drivers(void);
|
||||
void is31fl3733_init(uint8_t addr, uint8_t sync);
|
||||
bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data);
|
||||
bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
|
||||
void is31fl3733_init(uint8_t index);
|
||||
void is31fl3733_write_register(uint8_t index, uint8_t reg, uint8_t data);
|
||||
void is31fl3733_select_page(uint8_t index, uint8_t page);
|
||||
|
||||
void is31fl3733_set_value(int index, uint8_t value);
|
||||
void is31fl3733_set_value_all(uint8_t value);
|
||||
|
@ -128,8 +128,8 @@ void is31fl3733_set_led_control_register(uint8_t index, bool value);
|
|||
// (eg. from a timer interrupt).
|
||||
// Call this while idle (in between matrix scans).
|
||||
// If the buffer is dirty, it will update the driver with the buffer.
|
||||
void is31fl3733_update_pwm_buffers(uint8_t addr, uint8_t index);
|
||||
void is31fl3733_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
void is31fl3733_update_pwm_buffers(uint8_t index);
|
||||
void is31fl3733_update_led_control_registers(uint8_t index);
|
||||
|
||||
void is31fl3733_flush(void);
|
||||
|
||||
|
@ -161,206 +161,206 @@ void is31fl3733_flush(void);
|
|||
#define IS31FL3733_SYNC_MASTER 0b01
|
||||
#define IS31FL3733_SYNC_SLAVE 0b10
|
||||
|
||||
#define A_1 0x00
|
||||
#define A_2 0x01
|
||||
#define A_3 0x02
|
||||
#define A_4 0x03
|
||||
#define A_5 0x04
|
||||
#define A_6 0x05
|
||||
#define A_7 0x06
|
||||
#define A_8 0x07
|
||||
#define A_9 0x08
|
||||
#define A_10 0x09
|
||||
#define A_11 0x0A
|
||||
#define A_12 0x0B
|
||||
#define A_13 0x0C
|
||||
#define A_14 0x0D
|
||||
#define A_15 0x0E
|
||||
#define A_16 0x0F
|
||||
#define SW1_CS1 0x00
|
||||
#define SW1_CS2 0x01
|
||||
#define SW1_CS3 0x02
|
||||
#define SW1_CS4 0x03
|
||||
#define SW1_CS5 0x04
|
||||
#define SW1_CS6 0x05
|
||||
#define SW1_CS7 0x06
|
||||
#define SW1_CS8 0x07
|
||||
#define SW1_CS9 0x08
|
||||
#define SW1_CS10 0x09
|
||||
#define SW1_CS11 0x0A
|
||||
#define SW1_CS12 0x0B
|
||||
#define SW1_CS13 0x0C
|
||||
#define SW1_CS14 0x0D
|
||||
#define SW1_CS15 0x0E
|
||||
#define SW1_CS16 0x0F
|
||||
|
||||
#define B_1 0x10
|
||||
#define B_2 0x11
|
||||
#define B_3 0x12
|
||||
#define B_4 0x13
|
||||
#define B_5 0x14
|
||||
#define B_6 0x15
|
||||
#define B_7 0x16
|
||||
#define B_8 0x17
|
||||
#define B_9 0x18
|
||||
#define B_10 0x19
|
||||
#define B_11 0x1A
|
||||
#define B_12 0x1B
|
||||
#define B_13 0x1C
|
||||
#define B_14 0x1D
|
||||
#define B_15 0x1E
|
||||
#define B_16 0x1F
|
||||
#define SW2_CS1 0x10
|
||||
#define SW2_CS2 0x11
|
||||
#define SW2_CS3 0x12
|
||||
#define SW2_CS4 0x13
|
||||
#define SW2_CS5 0x14
|
||||
#define SW2_CS6 0x15
|
||||
#define SW2_CS7 0x16
|
||||
#define SW2_CS8 0x17
|
||||
#define SW2_CS9 0x18
|
||||
#define SW2_CS10 0x19
|
||||
#define SW2_CS11 0x1A
|
||||
#define SW2_CS12 0x1B
|
||||
#define SW2_CS13 0x1C
|
||||
#define SW2_CS14 0x1D
|
||||
#define SW2_CS15 0x1E
|
||||
#define SW2_CS16 0x1F
|
||||
|
||||
#define C_1 0x20
|
||||
#define C_2 0x21
|
||||
#define C_3 0x22
|
||||
#define C_4 0x23
|
||||
#define C_5 0x24
|
||||
#define C_6 0x25
|
||||
#define C_7 0x26
|
||||
#define C_8 0x27
|
||||
#define C_9 0x28
|
||||
#define C_10 0x29
|
||||
#define C_11 0x2A
|
||||
#define C_12 0x2B
|
||||
#define C_13 0x2C
|
||||
#define C_14 0x2D
|
||||
#define C_15 0x2E
|
||||
#define C_16 0x2F
|
||||
#define SW3_CS1 0x20
|
||||
#define SW3_CS2 0x21
|
||||
#define SW3_CS3 0x22
|
||||
#define SW3_CS4 0x23
|
||||
#define SW3_CS5 0x24
|
||||
#define SW3_CS6 0x25
|
||||
#define SW3_CS7 0x26
|
||||
#define SW3_CS8 0x27
|
||||
#define SW3_CS9 0x28
|
||||
#define SW3_CS10 0x29
|
||||
#define SW3_CS11 0x2A
|
||||
#define SW3_CS12 0x2B
|
||||
#define SW3_CS13 0x2C
|
||||
#define SW3_CS14 0x2D
|
||||
#define SW3_CS15 0x2E
|
||||
#define SW3_CS16 0x2F
|
||||
|
||||
#define D_1 0x30
|
||||
#define D_2 0x31
|
||||
#define D_3 0x32
|
||||
#define D_4 0x33
|
||||
#define D_5 0x34
|
||||
#define D_6 0x35
|
||||
#define D_7 0x36
|
||||
#define D_8 0x37
|
||||
#define D_9 0x38
|
||||
#define D_10 0x39
|
||||
#define D_11 0x3A
|
||||
#define D_12 0x3B
|
||||
#define D_13 0x3C
|
||||
#define D_14 0x3D
|
||||
#define D_15 0x3E
|
||||
#define D_16 0x3F
|
||||
#define SW4_CS1 0x30
|
||||
#define SW4_CS2 0x31
|
||||
#define SW4_CS3 0x32
|
||||
#define SW4_CS4 0x33
|
||||
#define SW4_CS5 0x34
|
||||
#define SW4_CS6 0x35
|
||||
#define SW4_CS7 0x36
|
||||
#define SW4_CS8 0x37
|
||||
#define SW4_CS9 0x38
|
||||
#define SW4_CS10 0x39
|
||||
#define SW4_CS11 0x3A
|
||||
#define SW4_CS12 0x3B
|
||||
#define SW4_CS13 0x3C
|
||||
#define SW4_CS14 0x3D
|
||||
#define SW4_CS15 0x3E
|
||||
#define SW4_CS16 0x3F
|
||||
|
||||
#define E_1 0x40
|
||||
#define E_2 0x41
|
||||
#define E_3 0x42
|
||||
#define E_4 0x43
|
||||
#define E_5 0x44
|
||||
#define E_6 0x45
|
||||
#define E_7 0x46
|
||||
#define E_8 0x47
|
||||
#define E_9 0x48
|
||||
#define E_10 0x49
|
||||
#define E_11 0x4A
|
||||
#define E_12 0x4B
|
||||
#define E_13 0x4C
|
||||
#define E_14 0x4D
|
||||
#define E_15 0x4E
|
||||
#define E_16 0x4F
|
||||
#define SW5_CS1 0x40
|
||||
#define SW5_CS2 0x41
|
||||
#define SW5_CS3 0x42
|
||||
#define SW5_CS4 0x43
|
||||
#define SW5_CS5 0x44
|
||||
#define SW5_CS6 0x45
|
||||
#define SW5_CS7 0x46
|
||||
#define SW5_CS8 0x47
|
||||
#define SW5_CS9 0x48
|
||||
#define SW5_CS10 0x49
|
||||
#define SW5_CS11 0x4A
|
||||
#define SW5_CS12 0x4B
|
||||
#define SW5_CS13 0x4C
|
||||
#define SW5_CS14 0x4D
|
||||
#define SW5_CS15 0x4E
|
||||
#define SW5_CS16 0x4F
|
||||
|
||||
#define F_1 0x50
|
||||
#define F_2 0x51
|
||||
#define F_3 0x52
|
||||
#define F_4 0x53
|
||||
#define F_5 0x54
|
||||
#define F_6 0x55
|
||||
#define F_7 0x56
|
||||
#define F_8 0x57
|
||||
#define F_9 0x58
|
||||
#define F_10 0x59
|
||||
#define F_11 0x5A
|
||||
#define F_12 0x5B
|
||||
#define F_13 0x5C
|
||||
#define F_14 0x5D
|
||||
#define F_15 0x5E
|
||||
#define F_16 0x5F
|
||||
#define SW6_CS1 0x50
|
||||
#define SW6_CS2 0x51
|
||||
#define SW6_CS3 0x52
|
||||
#define SW6_CS4 0x53
|
||||
#define SW6_CS5 0x54
|
||||
#define SW6_CS6 0x55
|
||||
#define SW6_CS7 0x56
|
||||
#define SW6_CS8 0x57
|
||||
#define SW6_CS9 0x58
|
||||
#define SW6_CS10 0x59
|
||||
#define SW6_CS11 0x5A
|
||||
#define SW6_CS12 0x5B
|
||||
#define SW6_CS13 0x5C
|
||||
#define SW6_CS14 0x5D
|
||||
#define SW6_CS15 0x5E
|
||||
#define SW6_CS16 0x5F
|
||||
|
||||
#define G_1 0x60
|
||||
#define G_2 0x61
|
||||
#define G_3 0x62
|
||||
#define G_4 0x63
|
||||
#define G_5 0x64
|
||||
#define G_6 0x65
|
||||
#define G_7 0x66
|
||||
#define G_8 0x67
|
||||
#define G_9 0x68
|
||||
#define G_10 0x69
|
||||
#define G_11 0x6A
|
||||
#define G_12 0x6B
|
||||
#define G_13 0x6C
|
||||
#define G_14 0x6D
|
||||
#define G_15 0x6E
|
||||
#define G_16 0x6F
|
||||
#define SW7_CS1 0x60
|
||||
#define SW7_CS2 0x61
|
||||
#define SW7_CS3 0x62
|
||||
#define SW7_CS4 0x63
|
||||
#define SW7_CS5 0x64
|
||||
#define SW7_CS6 0x65
|
||||
#define SW7_CS7 0x66
|
||||
#define SW7_CS8 0x67
|
||||
#define SW7_CS9 0x68
|
||||
#define SW7_CS10 0x69
|
||||
#define SW7_CS11 0x6A
|
||||
#define SW7_CS12 0x6B
|
||||
#define SW7_CS13 0x6C
|
||||
#define SW7_CS14 0x6D
|
||||
#define SW7_CS15 0x6E
|
||||
#define SW7_CS16 0x6F
|
||||
|
||||
#define H_1 0x70
|
||||
#define H_2 0x71
|
||||
#define H_3 0x72
|
||||
#define H_4 0x73
|
||||
#define H_5 0x74
|
||||
#define H_6 0x75
|
||||
#define H_7 0x76
|
||||
#define H_8 0x77
|
||||
#define H_9 0x78
|
||||
#define H_10 0x79
|
||||
#define H_11 0x7A
|
||||
#define H_12 0x7B
|
||||
#define H_13 0x7C
|
||||
#define H_14 0x7D
|
||||
#define H_15 0x7E
|
||||
#define H_16 0x7F
|
||||
#define SW8_CS1 0x70
|
||||
#define SW8_CS2 0x71
|
||||
#define SW8_CS3 0x72
|
||||
#define SW8_CS4 0x73
|
||||
#define SW8_CS5 0x74
|
||||
#define SW8_CS6 0x75
|
||||
#define SW8_CS7 0x76
|
||||
#define SW8_CS8 0x77
|
||||
#define SW8_CS9 0x78
|
||||
#define SW8_CS10 0x79
|
||||
#define SW8_CS11 0x7A
|
||||
#define SW8_CS12 0x7B
|
||||
#define SW8_CS13 0x7C
|
||||
#define SW8_CS14 0x7D
|
||||
#define SW8_CS15 0x7E
|
||||
#define SW8_CS16 0x7F
|
||||
|
||||
#define I_1 0x80
|
||||
#define I_2 0x81
|
||||
#define I_3 0x82
|
||||
#define I_4 0x83
|
||||
#define I_5 0x84
|
||||
#define I_6 0x85
|
||||
#define I_7 0x86
|
||||
#define I_8 0x87
|
||||
#define I_9 0x88
|
||||
#define I_10 0x89
|
||||
#define I_11 0x8A
|
||||
#define I_12 0x8B
|
||||
#define I_13 0x8C
|
||||
#define I_14 0x8D
|
||||
#define I_15 0x8E
|
||||
#define I_16 0x8F
|
||||
#define SW9_CS1 0x80
|
||||
#define SW9_CS2 0x81
|
||||
#define SW9_CS3 0x82
|
||||
#define SW9_CS4 0x83
|
||||
#define SW9_CS5 0x84
|
||||
#define SW9_CS6 0x85
|
||||
#define SW9_CS7 0x86
|
||||
#define SW9_CS8 0x87
|
||||
#define SW9_CS9 0x88
|
||||
#define SW9_CS10 0x89
|
||||
#define SW9_CS11 0x8A
|
||||
#define SW9_CS12 0x8B
|
||||
#define SW9_CS13 0x8C
|
||||
#define SW9_CS14 0x8D
|
||||
#define SW9_CS15 0x8E
|
||||
#define SW9_CS16 0x8F
|
||||
|
||||
#define J_1 0x90
|
||||
#define J_2 0x91
|
||||
#define J_3 0x92
|
||||
#define J_4 0x93
|
||||
#define J_5 0x94
|
||||
#define J_6 0x95
|
||||
#define J_7 0x96
|
||||
#define J_8 0x97
|
||||
#define J_9 0x98
|
||||
#define J_10 0x99
|
||||
#define J_11 0x9A
|
||||
#define J_12 0x9B
|
||||
#define J_13 0x9C
|
||||
#define J_14 0x9D
|
||||
#define J_15 0x9E
|
||||
#define J_16 0x9F
|
||||
#define SW10_CS1 0x90
|
||||
#define SW10_CS2 0x91
|
||||
#define SW10_CS3 0x92
|
||||
#define SW10_CS4 0x93
|
||||
#define SW10_CS5 0x94
|
||||
#define SW10_CS6 0x95
|
||||
#define SW10_CS7 0x96
|
||||
#define SW10_CS8 0x97
|
||||
#define SW10_CS9 0x98
|
||||
#define SW10_CS10 0x99
|
||||
#define SW10_CS11 0x9A
|
||||
#define SW10_CS12 0x9B
|
||||
#define SW10_CS13 0x9C
|
||||
#define SW10_CS14 0x9D
|
||||
#define SW10_CS15 0x9E
|
||||
#define SW10_CS16 0x9F
|
||||
|
||||
#define K_1 0xA0
|
||||
#define K_2 0xA1
|
||||
#define K_3 0xA2
|
||||
#define K_4 0xA3
|
||||
#define K_5 0xA4
|
||||
#define K_6 0xA5
|
||||
#define K_7 0xA6
|
||||
#define K_8 0xA7
|
||||
#define K_9 0xA8
|
||||
#define K_10 0xA9
|
||||
#define K_11 0xAA
|
||||
#define K_12 0xAB
|
||||
#define K_13 0xAC
|
||||
#define K_14 0xAD
|
||||
#define K_15 0xAE
|
||||
#define K_16 0xAF
|
||||
#define SW11_CS1 0xA0
|
||||
#define SW11_CS2 0xA1
|
||||
#define SW11_CS3 0xA2
|
||||
#define SW11_CS4 0xA3
|
||||
#define SW11_CS5 0xA4
|
||||
#define SW11_CS6 0xA5
|
||||
#define SW11_CS7 0xA6
|
||||
#define SW11_CS8 0xA7
|
||||
#define SW11_CS9 0xA8
|
||||
#define SW11_CS10 0xA9
|
||||
#define SW11_CS11 0xAA
|
||||
#define SW11_CS12 0xAB
|
||||
#define SW11_CS13 0xAC
|
||||
#define SW11_CS14 0xAD
|
||||
#define SW11_CS15 0xAE
|
||||
#define SW11_CS16 0xAF
|
||||
|
||||
#define L_1 0xB0
|
||||
#define L_2 0xB1
|
||||
#define L_3 0xB2
|
||||
#define L_4 0xB3
|
||||
#define L_5 0xB4
|
||||
#define L_6 0xB5
|
||||
#define L_7 0xB6
|
||||
#define L_8 0xB7
|
||||
#define L_9 0xB8
|
||||
#define L_10 0xB9
|
||||
#define L_11 0xBA
|
||||
#define L_12 0xBB
|
||||
#define L_13 0xBC
|
||||
#define L_14 0xBD
|
||||
#define L_15 0xBE
|
||||
#define L_16 0xBF
|
||||
#define SW12_CS1 0xB0
|
||||
#define SW12_CS2 0xB1
|
||||
#define SW12_CS3 0xB2
|
||||
#define SW12_CS4 0xB3
|
||||
#define SW12_CS5 0xB4
|
||||
#define SW12_CS6 0xB5
|
||||
#define SW12_CS7 0xB6
|
||||
#define SW12_CS8 0xB7
|
||||
#define SW12_CS9 0xB8
|
||||
#define SW12_CS10 0xB9
|
||||
#define SW12_CS11 0xBA
|
||||
#define SW12_CS12 0xBB
|
||||
#define SW12_CS13 0xBC
|
||||
#define SW12_CS14 0xBD
|
||||
#define SW12_CS15 0xBE
|
||||
#define SW12_CS16 0xBF
|
|
@ -1,278 +0,0 @@
|
|||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2021 Doni Crosby
|
||||
* Copyright 2021 Leo Deng
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "is31fl3733-simple.h"
|
||||
#include <string.h>
|
||||
#include "i2c_master.h"
|
||||
#include "wait.h"
|
||||
|
||||
#define IS31FL3733_PWM_REGISTER_COUNT 192
|
||||
#define IS31FL3733_LED_CONTROL_REGISTER_COUNT 24
|
||||
|
||||
#ifndef IS31FL3733_I2C_TIMEOUT
|
||||
# define IS31FL3733_I2C_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3733_I2C_PERSISTENCE
|
||||
# define IS31FL3733_I2C_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3733_PWM_FREQUENCY
|
||||
# define IS31FL3733_PWM_FREQUENCY IS31FL3733_PWM_FREQUENCY_8K4_HZ // PFS - IS31FL3733B only
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3733_SW_PULLUP
|
||||
# define IS31FL3733_SW_PULLUP IS31FL3733_PUR_0_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3733_CS_PULLDOWN
|
||||
# define IS31FL3733_CSPULLDOWN IS31FL3733_PDR_0_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3733_GLOBAL_CURRENT
|
||||
# define IS31FL3733_GLOBAL_CURRENT 0xFF
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3733_SYNC_1
|
||||
# define IS31FL3733_SYNC_1 IS31FL3733_SYNC_NONE
|
||||
#endif
|
||||
#ifndef IS31FL3733_SYNC_2
|
||||
# define IS31FL3733_SYNC_2 IS31FL3733_SYNC_NONE
|
||||
#endif
|
||||
#ifndef IS31FL3733_SYNC_3
|
||||
# define IS31FL3733_SYNC_3 IS31FL3733_SYNC_NONE
|
||||
#endif
|
||||
#ifndef IS31FL3733_SYNC_4
|
||||
# define IS31FL3733_SYNC_4 IS31FL3733_SYNC_NONE
|
||||
#endif
|
||||
|
||||
// Transfer buffer for TWITransmitData()
|
||||
uint8_t g_twi_transfer_buffer[20];
|
||||
|
||||
// These buffers match the IS31FL3733 PWM registers.
|
||||
// The control buffers match the PG0 LED On/Off registers.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
// We could optimize this and take out the unused registers from these
|
||||
// buffers and the transfers in is31fl3733_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
uint8_t g_pwm_buffer[IS31FL3733_DRIVER_COUNT][IS31FL3733_PWM_REGISTER_COUNT];
|
||||
bool g_pwm_buffer_update_required[IS31FL3733_DRIVER_COUNT] = {false};
|
||||
|
||||
uint8_t g_led_control_registers[IS31FL3733_DRIVER_COUNT][IS31FL3733_LED_CONTROL_REGISTER_COUNT] = {0};
|
||||
bool g_led_control_registers_update_required[IS31FL3733_DRIVER_COUNT] = {false};
|
||||
|
||||
bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
|
||||
// If the transaction fails function returns false.
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
|
||||
#if IS31FL3733_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3733_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
||||
// Assumes PG1 is already selected.
|
||||
// If any of the transactions fails function returns false.
|
||||
// Transmit PWM registers in 12 transfers of 16 bytes.
|
||||
// g_twi_transfer_buffer[] is 20 bytes
|
||||
|
||||
// Iterate over the pwm_buffer contents at 16 byte intervals.
|
||||
for (int i = 0; i < IS31FL3733_PWM_REGISTER_COUNT; i += 16) {
|
||||
g_twi_transfer_buffer[0] = i;
|
||||
// Copy the data from i to i+15.
|
||||
// Device will auto-increment register for data after the first byte
|
||||
// Thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer.
|
||||
memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 16);
|
||||
|
||||
#if IS31FL3733_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3733_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void is31fl3733_init_drivers(void) {
|
||||
i2c_init();
|
||||
|
||||
is31fl3733_init(IS31FL3733_I2C_ADDRESS_1, IS31FL3733_SYNC_1);
|
||||
#if defined(IS31FL3733_I2C_ADDRESS_2)
|
||||
is31fl3733_init(IS31FL3733_I2C_ADDRESS_2, IS31FL3733_SYNC_2);
|
||||
# if defined(IS31FL3733_I2C_ADDRESS_3)
|
||||
is31fl3733_init(IS31FL3733_I2C_ADDRESS_3, IS31FL3733_SYNC_3);
|
||||
# if defined(IS31FL3733_I2C_ADDRESS_4)
|
||||
is31fl3733_init(IS31FL3733_I2C_ADDRESS_4, IS31FL3733_SYNC_4);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < IS31FL3733_LED_COUNT; i++) {
|
||||
is31fl3733_set_led_control_register(i, true);
|
||||
}
|
||||
|
||||
is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3733_I2C_ADDRESS_2)
|
||||
is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3733_I2C_ADDRESS_3)
|
||||
is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3733_I2C_ADDRESS_4)
|
||||
is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3733_init(uint8_t addr, uint8_t sync) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
// Sync is passed so set it according to the datasheet.
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND_WRITE_LOCK, IS31FL3733_COMMAND_WRITE_LOCK_MAGIC);
|
||||
|
||||
// Select PG0
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND, IS31FL3733_COMMAND_LED_CONTROL);
|
||||
// Turn off all LEDs.
|
||||
for (int i = 0; i < IS31FL3733_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3733_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND_WRITE_LOCK, IS31FL3733_COMMAND_WRITE_LOCK_MAGIC);
|
||||
|
||||
// Select PG1
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND, IS31FL3733_COMMAND_PWM);
|
||||
// Set PWM on all LEDs to 0
|
||||
// No need to setup Breath registers to PWM as that is the default.
|
||||
for (int i = 0; i < IS31FL3733_PWM_REGISTER_COUNT; i++) {
|
||||
is31fl3733_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND_WRITE_LOCK, IS31FL3733_COMMAND_WRITE_LOCK_MAGIC);
|
||||
|
||||
// Select PG3
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND, IS31FL3733_COMMAND_FUNCTION);
|
||||
// Set de-ghost pull-up resistors (SWx)
|
||||
is31fl3733_write_register(addr, IS31FL3733_FUNCTION_REG_SW_PULLUP, IS31FL3733_SW_PULLUP);
|
||||
// Set de-ghost pull-down resistors (CSx)
|
||||
is31fl3733_write_register(addr, IS31FL3733_FUNCTION_REG_CS_PULLDOWN, IS31FL3733_CS_PULLDOWN);
|
||||
// Set global current to maximum.
|
||||
is31fl3733_write_register(addr, IS31FL3733_FUNCTION_REG_GLOBAL_CURRENT, IS31FL3733_GLOBAL_CURRENT);
|
||||
// Disable software shutdown.
|
||||
is31fl3733_write_register(addr, IS31FL3733_FUNCTION_REG_CONFIGURATION, ((sync & 0b11) << 6) | ((IS31FL3733_PWM_FREQUENCY & 0b111) << 3) | 0x01);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
wait_ms(10);
|
||||
}
|
||||
|
||||
void is31fl3733_set_value(int index, uint8_t value) {
|
||||
is31fl3733_led_t led;
|
||||
if (index >= 0 && index < IS31FL3733_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3733_leds[index]), sizeof(led));
|
||||
|
||||
if (g_pwm_buffer[led.driver][led.v] == value) {
|
||||
return;
|
||||
}
|
||||
g_pwm_buffer[led.driver][led.v] = value;
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3733_set_value_all(uint8_t value) {
|
||||
for (int i = 0; i < IS31FL3733_LED_COUNT; i++) {
|
||||
is31fl3733_set_value(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3733_set_led_control_register(uint8_t index, bool value) {
|
||||
is31fl3733_led_t led;
|
||||
memcpy_P(&led, (&g_is31fl3733_leds[index]), sizeof(led));
|
||||
|
||||
uint8_t control_register = led.v / 8;
|
||||
uint8_t bit_value = led.v % 8;
|
||||
|
||||
if (value) {
|
||||
g_led_control_registers[led.driver][control_register] |= (1 << bit_value);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register] &= ~(1 << bit_value);
|
||||
}
|
||||
|
||||
g_led_control_registers_update_required[led.driver] = true;
|
||||
}
|
||||
|
||||
void is31fl3733_update_pwm_buffers(uint8_t addr, uint8_t index) {
|
||||
if (g_pwm_buffer_update_required[index]) {
|
||||
// Firstly we need to unlock the command register and select PG1.
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND_WRITE_LOCK, IS31FL3733_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND, IS31FL3733_COMMAND_PWM);
|
||||
|
||||
// If any of the transactions fail we risk writing dirty PG0,
|
||||
// refresh page 0 just in case.
|
||||
if (!is31fl3733_write_pwm_buffer(addr, g_pwm_buffer[index])) {
|
||||
g_led_control_registers_update_required[index] = true;
|
||||
}
|
||||
g_pwm_buffer_update_required[index] = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3733_update_led_control_registers(uint8_t addr, uint8_t index) {
|
||||
if (g_led_control_registers_update_required[index]) {
|
||||
// Firstly we need to unlock the command register and select PG0
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND_WRITE_LOCK, IS31FL3733_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND, IS31FL3733_COMMAND_LED_CONTROL);
|
||||
for (int i = 0; i < IS31FL3733_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3733_write_register(addr, i, g_led_control_registers[index][i]);
|
||||
}
|
||||
g_led_control_registers_update_required[index] = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3733_flush(void) {
|
||||
is31fl3733_update_pwm_buffers(IS31FL3733_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3733_I2C_ADDRESS_2)
|
||||
is31fl3733_update_pwm_buffers(IS31FL3733_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3733_I2C_ADDRESS_3)
|
||||
is31fl3733_update_pwm_buffers(IS31FL3733_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3733_I2C_ADDRESS_4)
|
||||
is31fl3733_update_pwm_buffers(IS31FL3733_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
}
|
|
@ -18,8 +18,8 @@
|
|||
*/
|
||||
|
||||
#include "is31fl3733.h"
|
||||
#include <string.h>
|
||||
#include "i2c_master.h"
|
||||
#include "gpio.h"
|
||||
#include "wait.h"
|
||||
|
||||
#define IS31FL3733_PWM_REGISTER_COUNT 192
|
||||
|
@ -62,140 +62,137 @@
|
|||
# define IS31FL3733_SYNC_4 IS31FL3733_SYNC_NONE
|
||||
#endif
|
||||
|
||||
// Transfer buffer for TWITransmitData()
|
||||
uint8_t g_twi_transfer_buffer[20];
|
||||
const uint8_t i2c_addresses[IS31FL3733_DRIVER_COUNT] = {
|
||||
IS31FL3733_I2C_ADDRESS_1,
|
||||
#ifdef IS31FL3733_I2C_ADDRESS_2
|
||||
IS31FL3733_I2C_ADDRESS_2,
|
||||
# ifdef IS31FL3733_I2C_ADDRESS_3
|
||||
IS31FL3733_I2C_ADDRESS_3,
|
||||
# ifdef IS31FL3733_I2C_ADDRESS_4
|
||||
IS31FL3733_I2C_ADDRESS_4,
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
const uint8_t driver_sync[IS31FL3733_DRIVER_COUNT] = {
|
||||
IS31FL3733_SYNC_1,
|
||||
#ifdef IS31FL3733_I2C_ADDRESS_2
|
||||
IS31FL3733_SYNC_2,
|
||||
# ifdef IS31FL3733_I2C_ADDRESS_3
|
||||
IS31FL3733_SYNC_3,
|
||||
# ifdef IS31FL3733_I2C_ADDRESS_4
|
||||
IS31FL3733_SYNC_4,
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
// These buffers match the IS31FL3733 PWM registers.
|
||||
// The control buffers match the PG0 LED On/Off registers.
|
||||
// The control buffers match the page 0 LED On/Off registers.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
// We could optimize this and take out the unused registers from these
|
||||
// buffers and the transfers in is31fl3733_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
uint8_t g_pwm_buffer[IS31FL3733_DRIVER_COUNT][IS31FL3733_PWM_REGISTER_COUNT];
|
||||
bool g_pwm_buffer_update_required[IS31FL3733_DRIVER_COUNT] = {false};
|
||||
typedef struct is31fl3733_driver_t {
|
||||
uint8_t pwm_buffer[IS31FL3733_PWM_REGISTER_COUNT];
|
||||
bool pwm_buffer_dirty;
|
||||
uint8_t led_control_buffer[IS31FL3733_LED_CONTROL_REGISTER_COUNT];
|
||||
bool led_control_buffer_dirty;
|
||||
} PACKED is31fl3733_driver_t;
|
||||
|
||||
uint8_t g_led_control_registers[IS31FL3733_DRIVER_COUNT][IS31FL3733_LED_CONTROL_REGISTER_COUNT] = {0};
|
||||
bool g_led_control_registers_update_required[IS31FL3733_DRIVER_COUNT] = {false};
|
||||
|
||||
bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
|
||||
// If the transaction fails function returns false.
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
is31fl3733_driver_t driver_buffers[IS31FL3733_DRIVER_COUNT] = {{
|
||||
.pwm_buffer = {0},
|
||||
.pwm_buffer_dirty = false,
|
||||
.led_control_buffer = {0},
|
||||
.led_control_buffer_dirty = false,
|
||||
}};
|
||||
|
||||
void is31fl3733_write_register(uint8_t index, uint8_t reg, uint8_t data) {
|
||||
#if IS31FL3733_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3733_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3733_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3733_I2C_TIMEOUT);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
||||
// Assumes PG1 is already selected.
|
||||
// If any of the transactions fails function returns false.
|
||||
void is31fl3733_select_page(uint8_t index, uint8_t page) {
|
||||
is31fl3733_write_register(index, IS31FL3733_REG_COMMAND_WRITE_LOCK, IS31FL3733_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3733_write_register(index, IS31FL3733_REG_COMMAND, page);
|
||||
}
|
||||
|
||||
void is31fl3733_write_pwm_buffer(uint8_t index) {
|
||||
// Assumes page 1 is already selected.
|
||||
// Transmit PWM registers in 12 transfers of 16 bytes.
|
||||
// g_twi_transfer_buffer[] is 20 bytes
|
||||
|
||||
// Iterate over the pwm_buffer contents at 16 byte intervals.
|
||||
for (int i = 0; i < IS31FL3733_PWM_REGISTER_COUNT; i += 16) {
|
||||
g_twi_transfer_buffer[0] = i;
|
||||
// Copy the data from i to i+15.
|
||||
// Device will auto-increment register for data after the first byte
|
||||
// Thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer.
|
||||
memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 16);
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3733_PWM_REGISTER_COUNT; i += 16) {
|
||||
#if IS31FL3733_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3733_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
for (uint8_t j = 0; j < IS31FL3733_I2C_PERSISTENCE; j++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer + i, 16, IS31FL3733_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer + i, 16, IS31FL3733_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void is31fl3733_init_drivers(void) {
|
||||
i2c_init();
|
||||
|
||||
is31fl3733_init(IS31FL3733_I2C_ADDRESS_1, IS31FL3733_SYNC_1);
|
||||
#if defined(IS31FL3733_I2C_ADDRESS_2)
|
||||
is31fl3733_init(IS31FL3733_I2C_ADDRESS_2, IS31FL3733_SYNC_2);
|
||||
# if defined(IS31FL3733_I2C_ADDRESS_3)
|
||||
is31fl3733_init(IS31FL3733_I2C_ADDRESS_3, IS31FL3733_SYNC_3);
|
||||
# if defined(IS31FL3733_I2C_ADDRESS_4)
|
||||
is31fl3733_init(IS31FL3733_I2C_ADDRESS_4, IS31FL3733_SYNC_4);
|
||||
# endif
|
||||
# endif
|
||||
#if defined(IS31FL3733_SDB_PIN)
|
||||
gpio_set_pin_output(IS31FL3733_SDB_PIN);
|
||||
gpio_write_pin_high(IS31FL3733_SDB_PIN);
|
||||
#endif
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3733_DRIVER_COUNT; i++) {
|
||||
is31fl3733_init(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < IS31FL3733_LED_COUNT; i++) {
|
||||
is31fl3733_set_led_control_register(i, true, true, true);
|
||||
}
|
||||
|
||||
is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3733_I2C_ADDRESS_2)
|
||||
is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3733_I2C_ADDRESS_3)
|
||||
is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3733_I2C_ADDRESS_4)
|
||||
is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
for (uint8_t i = 0; i < IS31FL3733_DRIVER_COUNT; i++) {
|
||||
is31fl3733_update_led_control_registers(i);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3733_init(uint8_t addr, uint8_t sync) {
|
||||
void is31fl3733_init(uint8_t index) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
// Sync is passed so set it according to the datasheet.
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND_WRITE_LOCK, IS31FL3733_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3733_select_page(index, IS31FL3733_COMMAND_LED_CONTROL);
|
||||
|
||||
// Select PG0
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND, IS31FL3733_COMMAND_LED_CONTROL);
|
||||
// Turn off all LEDs.
|
||||
for (int i = 0; i < IS31FL3733_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3733_write_register(addr, i, 0x00);
|
||||
for (uint8_t i = 0; i < IS31FL3733_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3733_write_register(index, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND_WRITE_LOCK, IS31FL3733_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3733_select_page(index, IS31FL3733_COMMAND_PWM);
|
||||
|
||||
// Select PG1
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND, IS31FL3733_COMMAND_PWM);
|
||||
// Set PWM on all LEDs to 0
|
||||
// No need to setup Breath registers to PWM as that is the default.
|
||||
for (int i = 0; i < IS31FL3733_PWM_REGISTER_COUNT; i++) {
|
||||
is31fl3733_write_register(addr, i, 0x00);
|
||||
for (uint8_t i = 0; i < IS31FL3733_PWM_REGISTER_COUNT; i++) {
|
||||
is31fl3733_write_register(index, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND_WRITE_LOCK, IS31FL3733_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3733_select_page(index, IS31FL3733_COMMAND_FUNCTION);
|
||||
|
||||
uint8_t sync = driver_sync[index];
|
||||
|
||||
// Select PG3
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND, IS31FL3733_COMMAND_FUNCTION);
|
||||
// Set de-ghost pull-up resistors (SWx)
|
||||
is31fl3733_write_register(addr, IS31FL3733_FUNCTION_REG_SW_PULLUP, IS31FL3733_SW_PULLUP);
|
||||
is31fl3733_write_register(index, IS31FL3733_FUNCTION_REG_SW_PULLUP, IS31FL3733_SW_PULLUP);
|
||||
// Set de-ghost pull-down resistors (CSx)
|
||||
is31fl3733_write_register(addr, IS31FL3733_FUNCTION_REG_CS_PULLDOWN, IS31FL3733_CS_PULLDOWN);
|
||||
is31fl3733_write_register(index, IS31FL3733_FUNCTION_REG_CS_PULLDOWN, IS31FL3733_CS_PULLDOWN);
|
||||
// Set global current to maximum.
|
||||
is31fl3733_write_register(addr, IS31FL3733_FUNCTION_REG_GLOBAL_CURRENT, IS31FL3733_GLOBAL_CURRENT);
|
||||
is31fl3733_write_register(index, IS31FL3733_FUNCTION_REG_GLOBAL_CURRENT, IS31FL3733_GLOBAL_CURRENT);
|
||||
// Disable software shutdown.
|
||||
is31fl3733_write_register(addr, IS31FL3733_FUNCTION_REG_CONFIGURATION, ((sync & 0b11) << 6) | ((IS31FL3733_PWM_FREQUENCY & 0b111) << 3) | 0x01);
|
||||
is31fl3733_write_register(index, IS31FL3733_FUNCTION_REG_CONFIGURATION, ((sync & 0b11) << 6) | ((IS31FL3733_PWM_FREQUENCY & 0b111) << 3) | 0x01);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
wait_ms(10);
|
||||
|
@ -203,16 +200,18 @@ void is31fl3733_init(uint8_t addr, uint8_t sync) {
|
|||
|
||||
void is31fl3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
is31fl3733_led_t led;
|
||||
|
||||
if (index >= 0 && index < IS31FL3733_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3733_leds[index]), sizeof(led));
|
||||
|
||||
if (g_pwm_buffer[led.driver][led.r] == red && g_pwm_buffer[led.driver][led.g] == green && g_pwm_buffer[led.driver][led.b] == blue) {
|
||||
if (driver_buffers[led.driver].pwm_buffer[led.r] == red && driver_buffers[led.driver].pwm_buffer[led.g] == green && driver_buffers[led.driver].pwm_buffer[led.b] == blue) {
|
||||
return;
|
||||
}
|
||||
g_pwm_buffer[led.driver][led.r] = red;
|
||||
g_pwm_buffer[led.driver][led.g] = green;
|
||||
g_pwm_buffer[led.driver][led.b] = blue;
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
|
||||
driver_buffers[led.driver].pwm_buffer[led.r] = red;
|
||||
driver_buffers[led.driver].pwm_buffer[led.g] = green;
|
||||
driver_buffers[led.driver].pwm_buffer[led.b] = blue;
|
||||
driver_buffers[led.driver].pwm_buffer_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,60 +233,48 @@ void is31fl3733_set_led_control_register(uint8_t index, bool red, bool green, bo
|
|||
uint8_t bit_b = led.b % 8;
|
||||
|
||||
if (red) {
|
||||
g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_r] |= (1 << bit_r);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_r] &= ~(1 << bit_r);
|
||||
}
|
||||
if (green) {
|
||||
g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_g] |= (1 << bit_g);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_g] &= ~(1 << bit_g);
|
||||
}
|
||||
if (blue) {
|
||||
g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_b] |= (1 << bit_b);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_b] &= ~(1 << bit_b);
|
||||
}
|
||||
|
||||
g_led_control_registers_update_required[led.driver] = true;
|
||||
driver_buffers[led.driver].led_control_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3733_update_pwm_buffers(uint8_t addr, uint8_t index) {
|
||||
if (g_pwm_buffer_update_required[index]) {
|
||||
// Firstly we need to unlock the command register and select PG1.
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND_WRITE_LOCK, IS31FL3733_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND, IS31FL3733_COMMAND_PWM);
|
||||
void is31fl3733_update_pwm_buffers(uint8_t index) {
|
||||
if (driver_buffers[index].pwm_buffer_dirty) {
|
||||
is31fl3733_select_page(index, IS31FL3733_COMMAND_PWM);
|
||||
|
||||
// If any of the transactions fail we risk writing dirty PG0,
|
||||
// refresh page 0 just in case.
|
||||
if (!is31fl3733_write_pwm_buffer(addr, g_pwm_buffer[index])) {
|
||||
g_led_control_registers_update_required[index] = true;
|
||||
}
|
||||
g_pwm_buffer_update_required[index] = false;
|
||||
is31fl3733_write_pwm_buffer(index);
|
||||
|
||||
driver_buffers[index].pwm_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3733_update_led_control_registers(uint8_t addr, uint8_t index) {
|
||||
if (g_led_control_registers_update_required[index]) {
|
||||
// Firstly we need to unlock the command register and select PG0
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND_WRITE_LOCK, IS31FL3733_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND, IS31FL3733_COMMAND_LED_CONTROL);
|
||||
for (int i = 0; i < IS31FL3733_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3733_write_register(addr, i, g_led_control_registers[index][i]);
|
||||
void is31fl3733_update_led_control_registers(uint8_t index) {
|
||||
if (driver_buffers[index].led_control_buffer_dirty) {
|
||||
is31fl3733_select_page(index, IS31FL3733_COMMAND_LED_CONTROL);
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3733_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3733_write_register(index, i, driver_buffers[index].led_control_buffer[i]);
|
||||
}
|
||||
g_led_control_registers_update_required[index] = false;
|
||||
|
||||
driver_buffers[index].led_control_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3733_flush(void) {
|
||||
is31fl3733_update_pwm_buffers(IS31FL3733_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3733_I2C_ADDRESS_2)
|
||||
is31fl3733_update_pwm_buffers(IS31FL3733_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3733_I2C_ADDRESS_3)
|
||||
is31fl3733_update_pwm_buffers(IS31FL3733_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3733_I2C_ADDRESS_4)
|
||||
is31fl3733_update_pwm_buffers(IS31FL3733_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
for (uint8_t i = 0; i < IS31FL3733_DRIVER_COUNT; i++) {
|
||||
is31fl3733_update_pwm_buffers(i);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,13 +40,13 @@
|
|||
#ifdef DRIVER_SYNC_1
|
||||
# define IS31FL3733_SYNC_1 DRIVER_SYNC_1
|
||||
#endif
|
||||
#ifdef DRIVER_ADDR_2
|
||||
#ifdef DRIVER_SYNC_2
|
||||
# define IS31FL3733_SYNC_2 DRIVER_SYNC_2
|
||||
#endif
|
||||
#ifdef DRIVER_ADDR_3
|
||||
#ifdef DRIVER_SYNC_3
|
||||
# define IS31FL3733_SYNC_3 DRIVER_SYNC_3
|
||||
#endif
|
||||
#ifdef DRIVER_ADDR_4
|
||||
#ifdef DRIVER_SYNC_4
|
||||
# define IS31FL3733_SYNC_4 DRIVER_SYNC_4
|
||||
#endif
|
||||
#ifdef ISSI_TIMEOUT
|
||||
|
@ -140,9 +140,9 @@ typedef struct is31fl3733_led_t {
|
|||
extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT];
|
||||
|
||||
void is31fl3733_init_drivers(void);
|
||||
void is31fl3733_init(uint8_t addr, uint8_t sync);
|
||||
bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data);
|
||||
bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
|
||||
void is31fl3733_init(uint8_t index);
|
||||
void is31fl3733_write_register(uint8_t index, uint8_t reg, uint8_t data);
|
||||
void is31fl3733_select_page(uint8_t index, uint8_t page);
|
||||
|
||||
void is31fl3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
|
||||
void is31fl3733_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
@ -153,8 +153,8 @@ void is31fl3733_set_led_control_register(uint8_t index, bool red, bool green, bo
|
|||
// (eg. from a timer interrupt).
|
||||
// Call this while idle (in between matrix scans).
|
||||
// If the buffer is dirty, it will update the driver with the buffer.
|
||||
void is31fl3733_update_pwm_buffers(uint8_t addr, uint8_t index);
|
||||
void is31fl3733_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
void is31fl3733_update_pwm_buffers(uint8_t index);
|
||||
void is31fl3733_update_led_control_registers(uint8_t index);
|
||||
|
||||
void is31fl3733_flush(void);
|
||||
|
||||
|
@ -186,206 +186,412 @@ void is31fl3733_flush(void);
|
|||
#define IS31FL3733_SYNC_MASTER 0b01
|
||||
#define IS31FL3733_SYNC_SLAVE 0b10
|
||||
|
||||
#define A_1 0x00
|
||||
#define A_2 0x01
|
||||
#define A_3 0x02
|
||||
#define A_4 0x03
|
||||
#define A_5 0x04
|
||||
#define A_6 0x05
|
||||
#define A_7 0x06
|
||||
#define A_8 0x07
|
||||
#define A_9 0x08
|
||||
#define A_10 0x09
|
||||
#define A_11 0x0A
|
||||
#define A_12 0x0B
|
||||
#define A_13 0x0C
|
||||
#define A_14 0x0D
|
||||
#define A_15 0x0E
|
||||
#define A_16 0x0F
|
||||
#define SW1_CS1 0x00
|
||||
#define SW1_CS2 0x01
|
||||
#define SW1_CS3 0x02
|
||||
#define SW1_CS4 0x03
|
||||
#define SW1_CS5 0x04
|
||||
#define SW1_CS6 0x05
|
||||
#define SW1_CS7 0x06
|
||||
#define SW1_CS8 0x07
|
||||
#define SW1_CS9 0x08
|
||||
#define SW1_CS10 0x09
|
||||
#define SW1_CS11 0x0A
|
||||
#define SW1_CS12 0x0B
|
||||
#define SW1_CS13 0x0C
|
||||
#define SW1_CS14 0x0D
|
||||
#define SW1_CS15 0x0E
|
||||
#define SW1_CS16 0x0F
|
||||
|
||||
#define B_1 0x10
|
||||
#define B_2 0x11
|
||||
#define B_3 0x12
|
||||
#define B_4 0x13
|
||||
#define B_5 0x14
|
||||
#define B_6 0x15
|
||||
#define B_7 0x16
|
||||
#define B_8 0x17
|
||||
#define B_9 0x18
|
||||
#define B_10 0x19
|
||||
#define B_11 0x1A
|
||||
#define B_12 0x1B
|
||||
#define B_13 0x1C
|
||||
#define B_14 0x1D
|
||||
#define B_15 0x1E
|
||||
#define B_16 0x1F
|
||||
#define SW2_CS1 0x10
|
||||
#define SW2_CS2 0x11
|
||||
#define SW2_CS3 0x12
|
||||
#define SW2_CS4 0x13
|
||||
#define SW2_CS5 0x14
|
||||
#define SW2_CS6 0x15
|
||||
#define SW2_CS7 0x16
|
||||
#define SW2_CS8 0x17
|
||||
#define SW2_CS9 0x18
|
||||
#define SW2_CS10 0x19
|
||||
#define SW2_CS11 0x1A
|
||||
#define SW2_CS12 0x1B
|
||||
#define SW2_CS13 0x1C
|
||||
#define SW2_CS14 0x1D
|
||||
#define SW2_CS15 0x1E
|
||||
#define SW2_CS16 0x1F
|
||||
|
||||
#define C_1 0x20
|
||||
#define C_2 0x21
|
||||
#define C_3 0x22
|
||||
#define C_4 0x23
|
||||
#define C_5 0x24
|
||||
#define C_6 0x25
|
||||
#define C_7 0x26
|
||||
#define C_8 0x27
|
||||
#define C_9 0x28
|
||||
#define C_10 0x29
|
||||
#define C_11 0x2A
|
||||
#define C_12 0x2B
|
||||
#define C_13 0x2C
|
||||
#define C_14 0x2D
|
||||
#define C_15 0x2E
|
||||
#define C_16 0x2F
|
||||
#define SW3_CS1 0x20
|
||||
#define SW3_CS2 0x21
|
||||
#define SW3_CS3 0x22
|
||||
#define SW3_CS4 0x23
|
||||
#define SW3_CS5 0x24
|
||||
#define SW3_CS6 0x25
|
||||
#define SW3_CS7 0x26
|
||||
#define SW3_CS8 0x27
|
||||
#define SW3_CS9 0x28
|
||||
#define SW3_CS10 0x29
|
||||
#define SW3_CS11 0x2A
|
||||
#define SW3_CS12 0x2B
|
||||
#define SW3_CS13 0x2C
|
||||
#define SW3_CS14 0x2D
|
||||
#define SW3_CS15 0x2E
|
||||
#define SW3_CS16 0x2F
|
||||
|
||||
#define D_1 0x30
|
||||
#define D_2 0x31
|
||||
#define D_3 0x32
|
||||
#define D_4 0x33
|
||||
#define D_5 0x34
|
||||
#define D_6 0x35
|
||||
#define D_7 0x36
|
||||
#define D_8 0x37
|
||||
#define D_9 0x38
|
||||
#define D_10 0x39
|
||||
#define D_11 0x3A
|
||||
#define D_12 0x3B
|
||||
#define D_13 0x3C
|
||||
#define D_14 0x3D
|
||||
#define D_15 0x3E
|
||||
#define D_16 0x3F
|
||||
#define SW4_CS1 0x30
|
||||
#define SW4_CS2 0x31
|
||||
#define SW4_CS3 0x32
|
||||
#define SW4_CS4 0x33
|
||||
#define SW4_CS5 0x34
|
||||
#define SW4_CS6 0x35
|
||||
#define SW4_CS7 0x36
|
||||
#define SW4_CS8 0x37
|
||||
#define SW4_CS9 0x38
|
||||
#define SW4_CS10 0x39
|
||||
#define SW4_CS11 0x3A
|
||||
#define SW4_CS12 0x3B
|
||||
#define SW4_CS13 0x3C
|
||||
#define SW4_CS14 0x3D
|
||||
#define SW4_CS15 0x3E
|
||||
#define SW4_CS16 0x3F
|
||||
|
||||
#define E_1 0x40
|
||||
#define E_2 0x41
|
||||
#define E_3 0x42
|
||||
#define E_4 0x43
|
||||
#define E_5 0x44
|
||||
#define E_6 0x45
|
||||
#define E_7 0x46
|
||||
#define E_8 0x47
|
||||
#define E_9 0x48
|
||||
#define E_10 0x49
|
||||
#define E_11 0x4A
|
||||
#define E_12 0x4B
|
||||
#define E_13 0x4C
|
||||
#define E_14 0x4D
|
||||
#define E_15 0x4E
|
||||
#define E_16 0x4F
|
||||
#define SW5_CS1 0x40
|
||||
#define SW5_CS2 0x41
|
||||
#define SW5_CS3 0x42
|
||||
#define SW5_CS4 0x43
|
||||
#define SW5_CS5 0x44
|
||||
#define SW5_CS6 0x45
|
||||
#define SW5_CS7 0x46
|
||||
#define SW5_CS8 0x47
|
||||
#define SW5_CS9 0x48
|
||||
#define SW5_CS10 0x49
|
||||
#define SW5_CS11 0x4A
|
||||
#define SW5_CS12 0x4B
|
||||
#define SW5_CS13 0x4C
|
||||
#define SW5_CS14 0x4D
|
||||
#define SW5_CS15 0x4E
|
||||
#define SW5_CS16 0x4F
|
||||
|
||||
#define F_1 0x50
|
||||
#define F_2 0x51
|
||||
#define F_3 0x52
|
||||
#define F_4 0x53
|
||||
#define F_5 0x54
|
||||
#define F_6 0x55
|
||||
#define F_7 0x56
|
||||
#define F_8 0x57
|
||||
#define F_9 0x58
|
||||
#define F_10 0x59
|
||||
#define F_11 0x5A
|
||||
#define F_12 0x5B
|
||||
#define F_13 0x5C
|
||||
#define F_14 0x5D
|
||||
#define F_15 0x5E
|
||||
#define F_16 0x5F
|
||||
#define SW6_CS1 0x50
|
||||
#define SW6_CS2 0x51
|
||||
#define SW6_CS3 0x52
|
||||
#define SW6_CS4 0x53
|
||||
#define SW6_CS5 0x54
|
||||
#define SW6_CS6 0x55
|
||||
#define SW6_CS7 0x56
|
||||
#define SW6_CS8 0x57
|
||||
#define SW6_CS9 0x58
|
||||
#define SW6_CS10 0x59
|
||||
#define SW6_CS11 0x5A
|
||||
#define SW6_CS12 0x5B
|
||||
#define SW6_CS13 0x5C
|
||||
#define SW6_CS14 0x5D
|
||||
#define SW6_CS15 0x5E
|
||||
#define SW6_CS16 0x5F
|
||||
|
||||
#define G_1 0x60
|
||||
#define G_2 0x61
|
||||
#define G_3 0x62
|
||||
#define G_4 0x63
|
||||
#define G_5 0x64
|
||||
#define G_6 0x65
|
||||
#define G_7 0x66
|
||||
#define G_8 0x67
|
||||
#define G_9 0x68
|
||||
#define G_10 0x69
|
||||
#define G_11 0x6A
|
||||
#define G_12 0x6B
|
||||
#define G_13 0x6C
|
||||
#define G_14 0x6D
|
||||
#define G_15 0x6E
|
||||
#define G_16 0x6F
|
||||
#define SW7_CS1 0x60
|
||||
#define SW7_CS2 0x61
|
||||
#define SW7_CS3 0x62
|
||||
#define SW7_CS4 0x63
|
||||
#define SW7_CS5 0x64
|
||||
#define SW7_CS6 0x65
|
||||
#define SW7_CS7 0x66
|
||||
#define SW7_CS8 0x67
|
||||
#define SW7_CS9 0x68
|
||||
#define SW7_CS10 0x69
|
||||
#define SW7_CS11 0x6A
|
||||
#define SW7_CS12 0x6B
|
||||
#define SW7_CS13 0x6C
|
||||
#define SW7_CS14 0x6D
|
||||
#define SW7_CS15 0x6E
|
||||
#define SW7_CS16 0x6F
|
||||
|
||||
#define H_1 0x70
|
||||
#define H_2 0x71
|
||||
#define H_3 0x72
|
||||
#define H_4 0x73
|
||||
#define H_5 0x74
|
||||
#define H_6 0x75
|
||||
#define H_7 0x76
|
||||
#define H_8 0x77
|
||||
#define H_9 0x78
|
||||
#define H_10 0x79
|
||||
#define H_11 0x7A
|
||||
#define H_12 0x7B
|
||||
#define H_13 0x7C
|
||||
#define H_14 0x7D
|
||||
#define H_15 0x7E
|
||||
#define H_16 0x7F
|
||||
#define SW8_CS1 0x70
|
||||
#define SW8_CS2 0x71
|
||||
#define SW8_CS3 0x72
|
||||
#define SW8_CS4 0x73
|
||||
#define SW8_CS5 0x74
|
||||
#define SW8_CS6 0x75
|
||||
#define SW8_CS7 0x76
|
||||
#define SW8_CS8 0x77
|
||||
#define SW8_CS9 0x78
|
||||
#define SW8_CS10 0x79
|
||||
#define SW8_CS11 0x7A
|
||||
#define SW8_CS12 0x7B
|
||||
#define SW8_CS13 0x7C
|
||||
#define SW8_CS14 0x7D
|
||||
#define SW8_CS15 0x7E
|
||||
#define SW8_CS16 0x7F
|
||||
|
||||
#define I_1 0x80
|
||||
#define I_2 0x81
|
||||
#define I_3 0x82
|
||||
#define I_4 0x83
|
||||
#define I_5 0x84
|
||||
#define I_6 0x85
|
||||
#define I_7 0x86
|
||||
#define I_8 0x87
|
||||
#define I_9 0x88
|
||||
#define I_10 0x89
|
||||
#define I_11 0x8A
|
||||
#define I_12 0x8B
|
||||
#define I_13 0x8C
|
||||
#define I_14 0x8D
|
||||
#define I_15 0x8E
|
||||
#define I_16 0x8F
|
||||
#define SW9_CS1 0x80
|
||||
#define SW9_CS2 0x81
|
||||
#define SW9_CS3 0x82
|
||||
#define SW9_CS4 0x83
|
||||
#define SW9_CS5 0x84
|
||||
#define SW9_CS6 0x85
|
||||
#define SW9_CS7 0x86
|
||||
#define SW9_CS8 0x87
|
||||
#define SW9_CS9 0x88
|
||||
#define SW9_CS10 0x89
|
||||
#define SW9_CS11 0x8A
|
||||
#define SW9_CS12 0x8B
|
||||
#define SW9_CS13 0x8C
|
||||
#define SW9_CS14 0x8D
|
||||
#define SW9_CS15 0x8E
|
||||
#define SW9_CS16 0x8F
|
||||
|
||||
#define J_1 0x90
|
||||
#define J_2 0x91
|
||||
#define J_3 0x92
|
||||
#define J_4 0x93
|
||||
#define J_5 0x94
|
||||
#define J_6 0x95
|
||||
#define J_7 0x96
|
||||
#define J_8 0x97
|
||||
#define J_9 0x98
|
||||
#define J_10 0x99
|
||||
#define J_11 0x9A
|
||||
#define J_12 0x9B
|
||||
#define J_13 0x9C
|
||||
#define J_14 0x9D
|
||||
#define J_15 0x9E
|
||||
#define J_16 0x9F
|
||||
#define SW10_CS1 0x90
|
||||
#define SW10_CS2 0x91
|
||||
#define SW10_CS3 0x92
|
||||
#define SW10_CS4 0x93
|
||||
#define SW10_CS5 0x94
|
||||
#define SW10_CS6 0x95
|
||||
#define SW10_CS7 0x96
|
||||
#define SW10_CS8 0x97
|
||||
#define SW10_CS9 0x98
|
||||
#define SW10_CS10 0x99
|
||||
#define SW10_CS11 0x9A
|
||||
#define SW10_CS12 0x9B
|
||||
#define SW10_CS13 0x9C
|
||||
#define SW10_CS14 0x9D
|
||||
#define SW10_CS15 0x9E
|
||||
#define SW10_CS16 0x9F
|
||||
|
||||
#define K_1 0xA0
|
||||
#define K_2 0xA1
|
||||
#define K_3 0xA2
|
||||
#define K_4 0xA3
|
||||
#define K_5 0xA4
|
||||
#define K_6 0xA5
|
||||
#define K_7 0xA6
|
||||
#define K_8 0xA7
|
||||
#define K_9 0xA8
|
||||
#define K_10 0xA9
|
||||
#define K_11 0xAA
|
||||
#define K_12 0xAB
|
||||
#define K_13 0xAC
|
||||
#define K_14 0xAD
|
||||
#define K_15 0xAE
|
||||
#define K_16 0xAF
|
||||
#define SW11_CS1 0xA0
|
||||
#define SW11_CS2 0xA1
|
||||
#define SW11_CS3 0xA2
|
||||
#define SW11_CS4 0xA3
|
||||
#define SW11_CS5 0xA4
|
||||
#define SW11_CS6 0xA5
|
||||
#define SW11_CS7 0xA6
|
||||
#define SW11_CS8 0xA7
|
||||
#define SW11_CS9 0xA8
|
||||
#define SW11_CS10 0xA9
|
||||
#define SW11_CS11 0xAA
|
||||
#define SW11_CS12 0xAB
|
||||
#define SW11_CS13 0xAC
|
||||
#define SW11_CS14 0xAD
|
||||
#define SW11_CS15 0xAE
|
||||
#define SW11_CS16 0xAF
|
||||
|
||||
#define L_1 0xB0
|
||||
#define L_2 0xB1
|
||||
#define L_3 0xB2
|
||||
#define L_4 0xB3
|
||||
#define L_5 0xB4
|
||||
#define L_6 0xB5
|
||||
#define L_7 0xB6
|
||||
#define L_8 0xB7
|
||||
#define L_9 0xB8
|
||||
#define L_10 0xB9
|
||||
#define L_11 0xBA
|
||||
#define L_12 0xBB
|
||||
#define L_13 0xBC
|
||||
#define L_14 0xBD
|
||||
#define L_15 0xBE
|
||||
#define L_16 0xBF
|
||||
#define SW12_CS1 0xB0
|
||||
#define SW12_CS2 0xB1
|
||||
#define SW12_CS3 0xB2
|
||||
#define SW12_CS4 0xB3
|
||||
#define SW12_CS5 0xB4
|
||||
#define SW12_CS6 0xB5
|
||||
#define SW12_CS7 0xB6
|
||||
#define SW12_CS8 0xB7
|
||||
#define SW12_CS9 0xB8
|
||||
#define SW12_CS10 0xB9
|
||||
#define SW12_CS11 0xBA
|
||||
#define SW12_CS12 0xBB
|
||||
#define SW12_CS13 0xBC
|
||||
#define SW12_CS14 0xBD
|
||||
#define SW12_CS15 0xBE
|
||||
#define SW12_CS16 0xBF
|
||||
|
||||
// DEPRECATED - DO NOT USE
|
||||
|
||||
#define A_1 SW1_CS1
|
||||
#define A_2 SW1_CS2
|
||||
#define A_3 SW1_CS3
|
||||
#define A_4 SW1_CS4
|
||||
#define A_5 SW1_CS5
|
||||
#define A_6 SW1_CS6
|
||||
#define A_7 SW1_CS7
|
||||
#define A_8 SW1_CS8
|
||||
#define A_9 SW1_CS9
|
||||
#define A_10 SW1_CS10
|
||||
#define A_11 SW1_CS11
|
||||
#define A_12 SW1_CS12
|
||||
#define A_13 SW1_CS13
|
||||
#define A_14 SW1_CS14
|
||||
#define A_15 SW1_CS15
|
||||
#define A_16 SW1_CS16
|
||||
|
||||
#define B_1 SW2_CS1
|
||||
#define B_2 SW2_CS2
|
||||
#define B_3 SW2_CS3
|
||||
#define B_4 SW2_CS4
|
||||
#define B_5 SW2_CS5
|
||||
#define B_6 SW2_CS6
|
||||
#define B_7 SW2_CS7
|
||||
#define B_8 SW2_CS8
|
||||
#define B_9 SW2_CS9
|
||||
#define B_10 SW2_CS10
|
||||
#define B_11 SW2_CS11
|
||||
#define B_12 SW2_CS12
|
||||
#define B_13 SW2_CS13
|
||||
#define B_14 SW2_CS14
|
||||
#define B_15 SW2_CS15
|
||||
#define B_16 SW2_CS16
|
||||
|
||||
#define C_1 SW3_CS1
|
||||
#define C_2 SW3_CS2
|
||||
#define C_3 SW3_CS3
|
||||
#define C_4 SW3_CS4
|
||||
#define C_5 SW3_CS5
|
||||
#define C_6 SW3_CS6
|
||||
#define C_7 SW3_CS7
|
||||
#define C_8 SW3_CS8
|
||||
#define C_9 SW3_CS9
|
||||
#define C_10 SW3_CS10
|
||||
#define C_11 SW3_CS11
|
||||
#define C_12 SW3_CS12
|
||||
#define C_13 SW3_CS13
|
||||
#define C_14 SW3_CS14
|
||||
#define C_15 SW3_CS15
|
||||
#define C_16 SW3_CS16
|
||||
|
||||
#define D_1 SW4_CS1
|
||||
#define D_2 SW4_CS2
|
||||
#define D_3 SW4_CS3
|
||||
#define D_4 SW4_CS4
|
||||
#define D_5 SW4_CS5
|
||||
#define D_6 SW4_CS6
|
||||
#define D_7 SW4_CS7
|
||||
#define D_8 SW4_CS8
|
||||
#define D_9 SW4_CS9
|
||||
#define D_10 SW4_CS10
|
||||
#define D_11 SW4_CS11
|
||||
#define D_12 SW4_CS12
|
||||
#define D_13 SW4_CS13
|
||||
#define D_14 SW4_CS14
|
||||
#define D_15 SW4_CS15
|
||||
#define D_16 SW4_CS16
|
||||
|
||||
#define E_1 SW5_CS1
|
||||
#define E_2 SW5_CS2
|
||||
#define E_3 SW5_CS3
|
||||
#define E_4 SW5_CS4
|
||||
#define E_5 SW5_CS5
|
||||
#define E_6 SW5_CS6
|
||||
#define E_7 SW5_CS7
|
||||
#define E_8 SW5_CS8
|
||||
#define E_9 SW5_CS9
|
||||
#define E_10 SW5_CS10
|
||||
#define E_11 SW5_CS11
|
||||
#define E_12 SW5_CS12
|
||||
#define E_13 SW5_CS13
|
||||
#define E_14 SW5_CS14
|
||||
#define E_15 SW5_CS15
|
||||
#define E_16 SW5_CS16
|
||||
|
||||
#define F_1 SW6_CS1
|
||||
#define F_2 SW6_CS2
|
||||
#define F_3 SW6_CS3
|
||||
#define F_4 SW6_CS4
|
||||
#define F_5 SW6_CS5
|
||||
#define F_6 SW6_CS6
|
||||
#define F_7 SW6_CS7
|
||||
#define F_8 SW6_CS8
|
||||
#define F_9 SW6_CS9
|
||||
#define F_10 SW6_CS10
|
||||
#define F_11 SW6_CS11
|
||||
#define F_12 SW6_CS12
|
||||
#define F_13 SW6_CS13
|
||||
#define F_14 SW6_CS14
|
||||
#define F_15 SW6_CS15
|
||||
#define F_16 SW6_CS16
|
||||
|
||||
#define G_1 SW7_CS1
|
||||
#define G_2 SW7_CS2
|
||||
#define G_3 SW7_CS3
|
||||
#define G_4 SW7_CS4
|
||||
#define G_5 SW7_CS5
|
||||
#define G_6 SW7_CS6
|
||||
#define G_7 SW7_CS7
|
||||
#define G_8 SW7_CS8
|
||||
#define G_9 SW7_CS9
|
||||
#define G_10 SW7_CS10
|
||||
#define G_11 SW7_CS11
|
||||
#define G_12 SW7_CS12
|
||||
#define G_13 SW7_CS13
|
||||
#define G_14 SW7_CS14
|
||||
#define G_15 SW7_CS15
|
||||
#define G_16 SW7_CS16
|
||||
|
||||
#define H_1 SW8_CS1
|
||||
#define H_2 SW8_CS2
|
||||
#define H_3 SW8_CS3
|
||||
#define H_4 SW8_CS4
|
||||
#define H_5 SW8_CS5
|
||||
#define H_6 SW8_CS6
|
||||
#define H_7 SW8_CS7
|
||||
#define H_8 SW8_CS8
|
||||
#define H_9 SW8_CS9
|
||||
#define H_10 SW8_CS10
|
||||
#define H_11 SW8_CS11
|
||||
#define H_12 SW8_CS12
|
||||
#define H_13 SW8_CS13
|
||||
#define H_14 SW8_CS14
|
||||
#define H_15 SW8_CS15
|
||||
#define H_16 SW8_CS16
|
||||
|
||||
#define I_1 SW9_CS1
|
||||
#define I_2 SW9_CS2
|
||||
#define I_3 SW9_CS3
|
||||
#define I_4 SW9_CS4
|
||||
#define I_5 SW9_CS5
|
||||
#define I_6 SW9_CS6
|
||||
#define I_7 SW9_CS7
|
||||
#define I_8 SW9_CS8
|
||||
#define I_9 SW9_CS9
|
||||
#define I_10 SW9_CS10
|
||||
#define I_11 SW9_CS11
|
||||
#define I_12 SW9_CS12
|
||||
#define I_13 SW9_CS13
|
||||
#define I_14 SW9_CS14
|
||||
#define I_15 SW9_CS15
|
||||
#define I_16 SW9_CS16
|
||||
|
||||
#define J_1 SW10_CS1
|
||||
#define J_2 SW10_CS2
|
||||
#define J_3 SW10_CS3
|
||||
#define J_4 SW10_CS4
|
||||
#define J_5 SW10_CS5
|
||||
#define J_6 SW10_CS6
|
||||
#define J_7 SW10_CS7
|
||||
#define J_8 SW10_CS8
|
||||
#define J_9 SW10_CS9
|
||||
#define J_10 SW10_CS10
|
||||
#define J_11 SW10_CS11
|
||||
#define J_12 SW10_CS12
|
||||
#define J_13 SW10_CS13
|
||||
#define J_14 SW10_CS14
|
||||
#define J_15 SW10_CS15
|
||||
#define J_16 SW10_CS16
|
||||
|
||||
#define K_1 SW11_CS1
|
||||
#define K_2 SW11_CS2
|
||||
#define K_3 SW11_CS3
|
||||
#define K_4 SW11_CS4
|
||||
#define K_5 SW11_CS5
|
||||
#define K_6 SW11_CS6
|
||||
#define K_7 SW11_CS7
|
||||
#define K_8 SW11_CS8
|
||||
#define K_9 SW11_CS9
|
||||
#define K_10 SW11_CS10
|
||||
#define K_11 SW11_CS11
|
||||
#define K_12 SW11_CS12
|
||||
#define K_13 SW11_CS13
|
||||
#define K_14 SW11_CS14
|
||||
#define K_15 SW11_CS15
|
||||
#define K_16 SW11_CS16
|
||||
|
||||
#define L_1 SW12_CS1
|
||||
#define L_2 SW12_CS2
|
||||
#define L_3 SW12_CS3
|
||||
#define L_4 SW12_CS4
|
||||
#define L_5 SW12_CS5
|
||||
#define L_6 SW12_CS6
|
||||
#define L_7 SW12_CS7
|
||||
#define L_8 SW12_CS8
|
||||
#define L_9 SW12_CS9
|
||||
#define L_10 SW12_CS10
|
||||
#define L_11 SW12_CS11
|
||||
#define L_12 SW12_CS12
|
||||
#define L_13 SW12_CS13
|
||||
#define L_14 SW12_CS14
|
||||
#define L_15 SW12_CS15
|
||||
#define L_16 SW12_CS16
|
||||
|
|
240
drivers/led/issi/is31fl3736-mono.c
Normal file
240
drivers/led/issi/is31fl3736-mono.c
Normal file
|
@ -0,0 +1,240 @@
|
|||
/* Copyright 2018 Jason Williams (Wilba)
|
||||
* Copyright 2021 Doni Crosby
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "is31fl3736-mono.h"
|
||||
#include "i2c_master.h"
|
||||
#include "gpio.h"
|
||||
#include "wait.h"
|
||||
|
||||
#define IS31FL3736_PWM_REGISTER_COUNT 192 // actually 96
|
||||
#define IS31FL3736_LED_CONTROL_REGISTER_COUNT 24
|
||||
|
||||
#ifndef IS31FL3736_I2C_TIMEOUT
|
||||
# define IS31FL3736_I2C_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3736_I2C_PERSISTENCE
|
||||
# define IS31FL3736_I2C_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3736_PWM_FREQUENCY
|
||||
# define IS31FL3736_PWM_FREQUENCY IS31FL3736_PWM_FREQUENCY_8K4_HZ // PFS - IS31FL3736B only
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3736_SW_PULLUP
|
||||
# define IS31FL3736_SW_PULLUP IS31FL3736_PUR_0_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3736_CS_PULLDOWN
|
||||
# define IS31FL3736_CS_PULLDOWN IS31FL3736_PDR_0_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3736_GLOBAL_CURRENT
|
||||
# define IS31FL3736_GLOBAL_CURRENT 0xFF
|
||||
#endif
|
||||
|
||||
const uint8_t i2c_addresses[IS31FL3736_DRIVER_COUNT] = {
|
||||
IS31FL3736_I2C_ADDRESS_1,
|
||||
#ifdef IS31FL3736_I2C_ADDRESS_2
|
||||
IS31FL3736_I2C_ADDRESS_2,
|
||||
# ifdef IS31FL3736_I2C_ADDRESS_3
|
||||
IS31FL3736_I2C_ADDRESS_3,
|
||||
# ifdef IS31FL3736_I2C_ADDRESS_4
|
||||
IS31FL3736_I2C_ADDRESS_4,
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
// These buffers match the IS31FL3736 PWM registers.
|
||||
// The control buffers match the page 0 LED On/Off registers.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
// We could optimize this and take out the unused registers from these
|
||||
// buffers and the transfers in is31fl3736_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
typedef struct is31fl3736_driver_t {
|
||||
uint8_t pwm_buffer[IS31FL3736_PWM_REGISTER_COUNT];
|
||||
bool pwm_buffer_dirty;
|
||||
uint8_t led_control_buffer[IS31FL3736_LED_CONTROL_REGISTER_COUNT];
|
||||
bool led_control_buffer_dirty;
|
||||
} PACKED is31fl3736_driver_t;
|
||||
|
||||
is31fl3736_driver_t driver_buffers[IS31FL3736_DRIVER_COUNT] = {{
|
||||
.pwm_buffer = {0},
|
||||
.pwm_buffer_dirty = false,
|
||||
.led_control_buffer = {0},
|
||||
.led_control_buffer_dirty = false,
|
||||
}};
|
||||
|
||||
void is31fl3736_write_register(uint8_t index, uint8_t reg, uint8_t data) {
|
||||
#if IS31FL3736_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3736_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3736_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3736_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3736_select_page(uint8_t index, uint8_t page) {
|
||||
is31fl3736_write_register(index, IS31FL3736_REG_COMMAND_WRITE_LOCK, IS31FL3736_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3736_write_register(index, IS31FL3736_REG_COMMAND, page);
|
||||
}
|
||||
|
||||
void is31fl3736_write_pwm_buffer(uint8_t index) {
|
||||
// Assumes page 1 is already selected.
|
||||
// Transmit PWM registers in 12 transfers of 16 bytes.
|
||||
|
||||
// Iterate over the pwm_buffer contents at 16 byte intervals.
|
||||
for (uint8_t i = 0; i < IS31FL3736_PWM_REGISTER_COUNT; i += 16) {
|
||||
#if IS31FL3736_I2C_PERSISTENCE > 0
|
||||
for (uint8_t j = 0; j < IS31FL3736_I2C_PERSISTENCE; j++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer + i, 16, IS31FL3736_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer + i, 16, IS31FL3736_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3736_init_drivers(void) {
|
||||
i2c_init();
|
||||
|
||||
#if defined(IS31FL3736_SDB_PIN)
|
||||
gpio_set_pin_output(IS31FL3736_SDB_PIN);
|
||||
gpio_write_pin_high(IS31FL3736_SDB_PIN);
|
||||
#endif
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3736_DRIVER_COUNT; i++) {
|
||||
is31fl3736_init(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < IS31FL3736_LED_COUNT; i++) {
|
||||
is31fl3736_set_led_control_register(i, true);
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3736_DRIVER_COUNT; i++) {
|
||||
is31fl3736_update_led_control_registers(i);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3736_init(uint8_t index) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
|
||||
is31fl3736_select_page(index, IS31FL3736_COMMAND_LED_CONTROL);
|
||||
|
||||
// Turn off all LEDs.
|
||||
for (uint8_t i = 0; i < IS31FL3736_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3736_write_register(index, i, 0x00);
|
||||
}
|
||||
|
||||
is31fl3736_select_page(index, IS31FL3736_COMMAND_PWM);
|
||||
|
||||
// Set PWM on all LEDs to 0
|
||||
// No need to setup Breath registers to PWM as that is the default.
|
||||
for (uint8_t i = 0; i < IS31FL3736_PWM_REGISTER_COUNT; i++) {
|
||||
is31fl3736_write_register(index, i, 0x00);
|
||||
}
|
||||
|
||||
is31fl3736_select_page(index, IS31FL3736_COMMAND_FUNCTION);
|
||||
|
||||
// Set de-ghost pull-up resistors (SWx)
|
||||
is31fl3736_write_register(index, IS31FL3736_FUNCTION_REG_SW_PULLUP, IS31FL3736_SW_PULLUP);
|
||||
// Set de-ghost pull-down resistors (CSx)
|
||||
is31fl3736_write_register(index, IS31FL3736_FUNCTION_REG_CS_PULLDOWN, IS31FL3736_CS_PULLDOWN);
|
||||
// Set global current to maximum.
|
||||
is31fl3736_write_register(index, IS31FL3736_FUNCTION_REG_GLOBAL_CURRENT, IS31FL3736_GLOBAL_CURRENT);
|
||||
// Disable software shutdown.
|
||||
is31fl3736_write_register(index, IS31FL3736_FUNCTION_REG_CONFIGURATION, ((IS31FL3736_PWM_FREQUENCY & 0b111) << 3) | 0x01);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
wait_ms(10);
|
||||
}
|
||||
|
||||
void is31fl3736_set_value(int index, uint8_t value) {
|
||||
is31fl3736_led_t led;
|
||||
|
||||
if (index >= 0 && index < IS31FL3736_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3736_leds[index]), sizeof(led));
|
||||
|
||||
if (driver_buffers[led.driver].pwm_buffer[led.v] == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
driver_buffers[led.driver].pwm_buffer[led.v] = value;
|
||||
driver_buffers[led.driver].pwm_buffer_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3736_set_value_all(uint8_t value) {
|
||||
for (int i = 0; i < IS31FL3736_LED_COUNT; i++) {
|
||||
is31fl3736_set_value(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3736_set_led_control_register(uint8_t index, bool value) {
|
||||
is31fl3736_led_t led;
|
||||
memcpy_P(&led, (&g_is31fl3736_leds[index]), sizeof(led));
|
||||
|
||||
// The PWM register for a matrix position (0x00 to 0xBF) is interleaved, so:
|
||||
// A1=0x00 A2=0x02 A3=0x04 A4=0x06 A5=0x08 A6=0x0A A7=0x0C A8=0x0E
|
||||
// B1=0x10 B2=0x12 B3=0x14
|
||||
// But also, the LED control registers (0x00 to 0x17) are also interleaved, so:
|
||||
// A1-A4=0x00 A5-A8=0x01
|
||||
|
||||
uint8_t control_register = led.v / 8;
|
||||
uint8_t bit_value = led.v % 8;
|
||||
|
||||
if (value) {
|
||||
driver_buffers[led.driver].led_control_buffer[control_register] |= (1 << bit_value);
|
||||
} else {
|
||||
driver_buffers[led.driver].led_control_buffer[control_register] &= ~(1 << bit_value);
|
||||
}
|
||||
|
||||
driver_buffers[led.driver].led_control_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3736_update_pwm_buffers(uint8_t index) {
|
||||
if (driver_buffers[index].pwm_buffer_dirty) {
|
||||
is31fl3736_select_page(index, IS31FL3736_COMMAND_PWM);
|
||||
|
||||
is31fl3736_write_pwm_buffer(index);
|
||||
|
||||
driver_buffers[index].pwm_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3736_update_led_control_registers(uint8_t index) {
|
||||
if (driver_buffers[index].led_control_buffer_dirty) {
|
||||
is31fl3736_select_page(index, IS31FL3736_COMMAND_LED_CONTROL);
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3736_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3736_write_register(index, i, driver_buffers[index].led_control_buffer[i]);
|
||||
}
|
||||
|
||||
driver_buffers[index].led_control_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3736_flush(void) {
|
||||
for (uint8_t i = 0; i < IS31FL3736_DRIVER_COUNT; i++) {
|
||||
is31fl3736_update_pwm_buffers(i);
|
||||
}
|
||||
}
|
|
@ -110,9 +110,9 @@ typedef struct is31fl3736_led_t {
|
|||
extern const is31fl3736_led_t PROGMEM g_is31fl3736_leds[IS31FL3736_LED_COUNT];
|
||||
|
||||
void is31fl3736_init_drivers(void);
|
||||
void is31fl3736_init(uint8_t addr);
|
||||
void is31fl3736_write_register(uint8_t addr, uint8_t reg, uint8_t data);
|
||||
void is31fl3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
|
||||
void is31fl3736_init(uint8_t index);
|
||||
void is31fl3736_write_register(uint8_t index, uint8_t reg, uint8_t data);
|
||||
void is31fl3736_select_page(uint8_t index, uint8_t page);
|
||||
|
||||
void is31fl3736_set_value(int index, uint8_t value);
|
||||
void is31fl3736_set_value_all(uint8_t value);
|
||||
|
@ -123,8 +123,8 @@ void is31fl3736_set_led_control_register(uint8_t index, bool value);
|
|||
// (eg. from a timer interrupt).
|
||||
// Call this while idle (in between matrix scans).
|
||||
// If the buffer is dirty, it will update the driver with the buffer.
|
||||
void is31fl3736_update_pwm_buffers(uint8_t addr, uint8_t index);
|
||||
void is31fl3736_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
void is31fl3736_update_pwm_buffers(uint8_t index);
|
||||
void is31fl3736_update_led_control_registers(uint8_t index);
|
||||
|
||||
void is31fl3736_flush(void);
|
||||
|
||||
|
@ -152,110 +152,220 @@ void is31fl3736_flush(void);
|
|||
#define IS31FL3736_PWM_FREQUENCY_2K1_HZ 0b011
|
||||
#define IS31FL3736_PWM_FREQUENCY_1K05_HZ 0b100
|
||||
|
||||
#define A_1 0x00
|
||||
#define A_2 0x02
|
||||
#define A_3 0x04
|
||||
#define A_4 0x06
|
||||
#define A_5 0x08
|
||||
#define A_6 0x0A
|
||||
#define A_7 0x0C
|
||||
#define A_8 0x0E
|
||||
#define SW1_CS1 0x00
|
||||
#define SW1_CS2 0x02
|
||||
#define SW1_CS3 0x04
|
||||
#define SW1_CS4 0x06
|
||||
#define SW1_CS5 0x08
|
||||
#define SW1_CS6 0x0A
|
||||
#define SW1_CS7 0x0C
|
||||
#define SW1_CS8 0x0E
|
||||
|
||||
#define B_1 0x10
|
||||
#define B_2 0x12
|
||||
#define B_3 0x14
|
||||
#define B_4 0x16
|
||||
#define B_5 0x18
|
||||
#define B_6 0x1A
|
||||
#define B_7 0x1C
|
||||
#define B_8 0x1E
|
||||
#define SW2_CS1 0x10
|
||||
#define SW2_CS2 0x12
|
||||
#define SW2_CS3 0x14
|
||||
#define SW2_CS4 0x16
|
||||
#define SW2_CS5 0x18
|
||||
#define SW2_CS6 0x1A
|
||||
#define SW2_CS7 0x1C
|
||||
#define SW2_CS8 0x1E
|
||||
|
||||
#define C_1 0x20
|
||||
#define C_2 0x22
|
||||
#define C_3 0x24
|
||||
#define C_4 0x26
|
||||
#define C_5 0x28
|
||||
#define C_6 0x2A
|
||||
#define C_7 0x2C
|
||||
#define C_8 0x2E
|
||||
#define SW3_CS1 0x20
|
||||
#define SW3_CS2 0x22
|
||||
#define SW3_CS3 0x24
|
||||
#define SW3_CS4 0x26
|
||||
#define SW3_CS5 0x28
|
||||
#define SW3_CS6 0x2A
|
||||
#define SW3_CS7 0x2C
|
||||
#define SW3_CS8 0x2E
|
||||
|
||||
#define D_1 0x30
|
||||
#define D_2 0x32
|
||||
#define D_3 0x34
|
||||
#define D_4 0x36
|
||||
#define D_5 0x38
|
||||
#define D_6 0x3A
|
||||
#define D_7 0x3C
|
||||
#define D_8 0x3E
|
||||
#define SW4_CS1 0x30
|
||||
#define SW4_CS2 0x32
|
||||
#define SW4_CS3 0x34
|
||||
#define SW4_CS4 0x36
|
||||
#define SW4_CS5 0x38
|
||||
#define SW4_CS6 0x3A
|
||||
#define SW4_CS7 0x3C
|
||||
#define SW4_CS8 0x3E
|
||||
|
||||
#define E_1 0x40
|
||||
#define E_2 0x42
|
||||
#define E_3 0x44
|
||||
#define E_4 0x46
|
||||
#define E_5 0x48
|
||||
#define E_6 0x4A
|
||||
#define E_7 0x4C
|
||||
#define E_8 0x4E
|
||||
#define SW5_CS1 0x40
|
||||
#define SW5_CS2 0x42
|
||||
#define SW5_CS3 0x44
|
||||
#define SW5_CS4 0x46
|
||||
#define SW5_CS5 0x48
|
||||
#define SW5_CS6 0x4A
|
||||
#define SW5_CS7 0x4C
|
||||
#define SW5_CS8 0x4E
|
||||
|
||||
#define F_1 0x50
|
||||
#define F_2 0x52
|
||||
#define F_3 0x54
|
||||
#define F_4 0x56
|
||||
#define F_5 0x58
|
||||
#define F_6 0x5A
|
||||
#define F_7 0x5C
|
||||
#define F_8 0x5E
|
||||
#define SW6_CS1 0x50
|
||||
#define SW6_CS2 0x52
|
||||
#define SW6_CS3 0x54
|
||||
#define SW6_CS4 0x56
|
||||
#define SW6_CS5 0x58
|
||||
#define SW6_CS6 0x5A
|
||||
#define SW6_CS7 0x5C
|
||||
#define SW6_CS8 0x5E
|
||||
|
||||
#define G_1 0x60
|
||||
#define G_2 0x62
|
||||
#define G_3 0x64
|
||||
#define G_4 0x66
|
||||
#define G_5 0x68
|
||||
#define G_6 0x6A
|
||||
#define G_7 0x6C
|
||||
#define G_8 0x6E
|
||||
#define SW7_CS1 0x60
|
||||
#define SW7_CS2 0x62
|
||||
#define SW7_CS3 0x64
|
||||
#define SW7_CS4 0x66
|
||||
#define SW7_CS5 0x68
|
||||
#define SW7_CS6 0x6A
|
||||
#define SW7_CS7 0x6C
|
||||
#define SW7_CS8 0x6E
|
||||
|
||||
#define H_1 0x70
|
||||
#define H_2 0x72
|
||||
#define H_3 0x74
|
||||
#define H_4 0x76
|
||||
#define H_5 0x78
|
||||
#define H_6 0x7A
|
||||
#define H_7 0x7C
|
||||
#define H_8 0x7E
|
||||
#define SW8_CS1 0x70
|
||||
#define SW8_CS2 0x72
|
||||
#define SW8_CS3 0x74
|
||||
#define SW8_CS4 0x76
|
||||
#define SW8_CS5 0x78
|
||||
#define SW8_CS6 0x7A
|
||||
#define SW8_CS7 0x7C
|
||||
#define SW8_CS8 0x7E
|
||||
|
||||
#define I_1 0x80
|
||||
#define I_2 0x82
|
||||
#define I_3 0x84
|
||||
#define I_4 0x86
|
||||
#define I_5 0x88
|
||||
#define I_6 0x8A
|
||||
#define I_7 0x8C
|
||||
#define I_8 0x8E
|
||||
#define SW9_CS1 0x80
|
||||
#define SW9_CS2 0x82
|
||||
#define SW9_CS3 0x84
|
||||
#define SW9_CS4 0x86
|
||||
#define SW9_CS5 0x88
|
||||
#define SW9_CS6 0x8A
|
||||
#define SW9_CS7 0x8C
|
||||
#define SW9_CS8 0x8E
|
||||
|
||||
#define J_1 0x90
|
||||
#define J_2 0x92
|
||||
#define J_3 0x94
|
||||
#define J_4 0x96
|
||||
#define J_5 0x98
|
||||
#define J_6 0x9A
|
||||
#define J_7 0x9C
|
||||
#define J_8 0x9E
|
||||
#define SW10_CS1 0x90
|
||||
#define SW10_CS2 0x92
|
||||
#define SW10_CS3 0x94
|
||||
#define SW10_CS4 0x96
|
||||
#define SW10_CS5 0x98
|
||||
#define SW10_CS6 0x9A
|
||||
#define SW10_CS7 0x9C
|
||||
#define SW10_CS8 0x9E
|
||||
|
||||
#define K_1 0xA0
|
||||
#define K_2 0xA2
|
||||
#define K_3 0xA4
|
||||
#define K_4 0xA6
|
||||
#define K_5 0xA8
|
||||
#define K_6 0xAA
|
||||
#define K_7 0xAC
|
||||
#define K_8 0xAE
|
||||
#define SW11_CS1 0xA0
|
||||
#define SW11_CS2 0xA2
|
||||
#define SW11_CS3 0xA4
|
||||
#define SW11_CS4 0xA6
|
||||
#define SW11_CS5 0xA8
|
||||
#define SW11_CS6 0xAA
|
||||
#define SW11_CS7 0xAC
|
||||
#define SW11_CS8 0xAE
|
||||
|
||||
#define L_1 0xB0
|
||||
#define L_2 0xB2
|
||||
#define L_3 0xB4
|
||||
#define L_4 0xB6
|
||||
#define L_5 0xB8
|
||||
#define L_6 0xBA
|
||||
#define L_7 0xBC
|
||||
#define L_8 0xBE
|
||||
#define SW12_CS1 0xB0
|
||||
#define SW12_CS2 0xB2
|
||||
#define SW12_CS3 0xB4
|
||||
#define SW12_CS4 0xB6
|
||||
#define SW12_CS5 0xB8
|
||||
#define SW12_CS6 0xBA
|
||||
#define SW12_CS7 0xBC
|
||||
#define SW12_CS8 0xBE
|
||||
|
||||
// DEPRECATED - DO NOT USE
|
||||
|
||||
#define A_1 SW1_CS1
|
||||
#define A_2 SW1_CS2
|
||||
#define A_3 SW1_CS3
|
||||
#define A_4 SW1_CS4
|
||||
#define A_5 SW1_CS5
|
||||
#define A_6 SW1_CS6
|
||||
#define A_7 SW1_CS7
|
||||
#define A_8 SW1_CS8
|
||||
|
||||
#define B_1 SW2_CS1
|
||||
#define B_2 SW2_CS2
|
||||
#define B_3 SW2_CS3
|
||||
#define B_4 SW2_CS4
|
||||
#define B_5 SW2_CS5
|
||||
#define B_6 SW2_CS6
|
||||
#define B_7 SW2_CS7
|
||||
#define B_8 SW2_CS8
|
||||
|
||||
#define C_1 SW3_CS1
|
||||
#define C_2 SW3_CS2
|
||||
#define C_3 SW3_CS3
|
||||
#define C_4 SW3_CS4
|
||||
#define C_5 SW3_CS5
|
||||
#define C_6 SW3_CS6
|
||||
#define C_7 SW3_CS7
|
||||
#define C_8 SW3_CS8
|
||||
|
||||
#define D_1 SW4_CS1
|
||||
#define D_2 SW4_CS2
|
||||
#define D_3 SW4_CS3
|
||||
#define D_4 SW4_CS4
|
||||
#define D_5 SW4_CS5
|
||||
#define D_6 SW4_CS6
|
||||
#define D_7 SW4_CS7
|
||||
#define D_8 SW4_CS8
|
||||
|
||||
#define E_1 SW5_CS1
|
||||
#define E_2 SW5_CS2
|
||||
#define E_3 SW5_CS3
|
||||
#define E_4 SW5_CS4
|
||||
#define E_5 SW5_CS5
|
||||
#define E_6 SW5_CS6
|
||||
#define E_7 SW5_CS7
|
||||
#define E_8 SW5_CS8
|
||||
|
||||
#define F_1 SW6_CS1
|
||||
#define F_2 SW6_CS2
|
||||
#define F_3 SW6_CS3
|
||||
#define F_4 SW6_CS4
|
||||
#define F_5 SW6_CS5
|
||||
#define F_6 SW6_CS6
|
||||
#define F_7 SW6_CS7
|
||||
#define F_8 SW6_CS8
|
||||
|
||||
#define G_1 SW7_CS1
|
||||
#define G_2 SW7_CS2
|
||||
#define G_3 SW7_CS3
|
||||
#define G_4 SW7_CS4
|
||||
#define G_5 SW7_CS5
|
||||
#define G_6 SW7_CS6
|
||||
#define G_7 SW7_CS7
|
||||
#define G_8 SW7_CS8
|
||||
|
||||
#define H_1 SW8_CS1
|
||||
#define H_2 SW8_CS2
|
||||
#define H_3 SW8_CS3
|
||||
#define H_4 SW8_CS4
|
||||
#define H_5 SW8_CS5
|
||||
#define H_6 SW8_CS6
|
||||
#define H_7 SW8_CS7
|
||||
#define H_8 SW8_CS8
|
||||
|
||||
#define I_1 SW9_CS1
|
||||
#define I_2 SW9_CS2
|
||||
#define I_3 SW9_CS3
|
||||
#define I_4 SW9_CS4
|
||||
#define I_5 SW9_CS5
|
||||
#define I_6 SW9_CS6
|
||||
#define I_7 SW9_CS7
|
||||
#define I_8 SW9_CS8
|
||||
|
||||
#define J_1 SW10_CS1
|
||||
#define J_2 SW10_CS2
|
||||
#define J_3 SW10_CS3
|
||||
#define J_4 SW10_CS4
|
||||
#define J_5 SW10_CS5
|
||||
#define J_6 SW10_CS6
|
||||
#define J_7 SW10_CS7
|
||||
#define J_8 SW10_CS8
|
||||
|
||||
#define K_1 SW11_CS1
|
||||
#define K_2 SW11_CS2
|
||||
#define K_3 SW11_CS3
|
||||
#define K_4 SW11_CS4
|
||||
#define K_5 SW11_CS5
|
||||
#define K_6 SW11_CS6
|
||||
#define K_7 SW11_CS7
|
||||
#define K_8 SW11_CS8
|
||||
|
||||
#define L_1 SW12_CS1
|
||||
#define L_2 SW12_CS2
|
||||
#define L_3 SW12_CS3
|
||||
#define L_4 SW12_CS4
|
||||
#define L_5 SW12_CS5
|
||||
#define L_6 SW12_CS6
|
||||
#define L_7 SW12_CS7
|
||||
#define L_8 SW12_CS8
|
|
@ -1,252 +0,0 @@
|
|||
/* Copyright 2018 Jason Williams (Wilba)
|
||||
* Copyright 2021 Doni Crosby
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "is31fl3736-simple.h"
|
||||
#include <string.h>
|
||||
#include "i2c_master.h"
|
||||
#include "wait.h"
|
||||
|
||||
#define IS31FL3736_PWM_REGISTER_COUNT 192 // actually 96
|
||||
#define IS31FL3736_LED_CONTROL_REGISTER_COUNT 24
|
||||
|
||||
#ifndef IS31FL3736_I2C_TIMEOUT
|
||||
# define IS31FL3736_I2C_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3736_I2C_PERSISTENCE
|
||||
# define IS31FL3736_I2C_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3736_PWM_FREQUENCY
|
||||
# define IS31FL3736_PWM_FREQUENCY IS31FL3736_PWM_FREQUENCY_8K4_HZ // PFS - IS31FL3736B only
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3736_SW_PULLUP
|
||||
# define IS31FL3736_SW_PULLUP IS31FL3736_PUR_0_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3736_CS_PULLDOWN
|
||||
# define IS31FL3736_CS_PULLDOWN IS31FL3736_PDR_0_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3736_GLOBAL_CURRENT
|
||||
# define IS31FL3736_GLOBAL_CURRENT 0xFF
|
||||
#endif
|
||||
|
||||
// Transfer buffer for TWITransmitData()
|
||||
uint8_t g_twi_transfer_buffer[20];
|
||||
|
||||
// These buffers match the IS31FL3736 PWM registers.
|
||||
// The control buffers match the PG0 LED On/Off registers.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
// We could optimize this and take out the unused registers from these
|
||||
// buffers and the transfers in is31fl3736_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
uint8_t g_pwm_buffer[IS31FL3736_DRIVER_COUNT][IS31FL3736_PWM_REGISTER_COUNT];
|
||||
bool g_pwm_buffer_update_required[IS31FL3736_DRIVER_COUNT] = {false};
|
||||
|
||||
uint8_t g_led_control_registers[IS31FL3736_DRIVER_COUNT][IS31FL3736_LED_CONTROL_REGISTER_COUNT] = {0};
|
||||
bool g_led_control_registers_update_required[IS31FL3736_DRIVER_COUNT] = {false};
|
||||
|
||||
void is31fl3736_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
|
||||
#if IS31FL3736_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3736_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3736_I2C_TIMEOUT) == 0) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3736_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
||||
// assumes PG1 is already selected
|
||||
|
||||
// transmit PWM registers in 12 transfers of 16 bytes
|
||||
// g_twi_transfer_buffer[] is 20 bytes
|
||||
|
||||
// iterate over the pwm_buffer contents at 16 byte intervals
|
||||
for (int i = 0; i < IS31FL3736_PWM_REGISTER_COUNT; i += 16) {
|
||||
g_twi_transfer_buffer[0] = i;
|
||||
// copy the data from i to i+15
|
||||
// device will auto-increment register for data after the first byte
|
||||
// thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer
|
||||
memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 16);
|
||||
|
||||
#if IS31FL3736_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3736_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3736_I2C_TIMEOUT) == 0) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3736_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3736_init_drivers(void) {
|
||||
i2c_init();
|
||||
|
||||
is31fl3736_init(IS31FL3736_I2C_ADDRESS_1);
|
||||
#if defined(IS31FL3736_I2C_ADDRESS_2)
|
||||
is31fl3736_init(IS31FL3736_I2C_ADDRESS_2);
|
||||
# if defined(IS31FL3736_I2C_ADDRESS_3)
|
||||
is31fl3736_init(IS31FL3736_I2C_ADDRESS_3);
|
||||
# if defined(IS31FL3736_I2C_ADDRESS_4)
|
||||
is31fl3736_init(IS31FL3736_I2C_ADDRESS_4);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < IS31FL3736_LED_COUNT; i++) {
|
||||
is31fl3736_set_led_control_register(i, true);
|
||||
}
|
||||
|
||||
is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3736_I2C_ADDRESS_2)
|
||||
is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3736_I2C_ADDRESS_3)
|
||||
is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3736_I2C_ADDRESS_4)
|
||||
is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3736_init(uint8_t addr) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND_WRITE_LOCK, IS31FL3736_COMMAND_WRITE_LOCK_MAGIC);
|
||||
|
||||
// Select PG0
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND, IS31FL3736_COMMAND_LED_CONTROL);
|
||||
// Turn off all LEDs.
|
||||
for (int i = 0; i < IS31FL3736_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3736_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND_WRITE_LOCK, IS31FL3736_COMMAND_WRITE_LOCK_MAGIC);
|
||||
|
||||
// Select PG1
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND, IS31FL3736_COMMAND_PWM);
|
||||
// Set PWM on all LEDs to 0
|
||||
// No need to setup Breath registers to PWM as that is the default.
|
||||
for (int i = 0; i < IS31FL3736_PWM_REGISTER_COUNT; i++) {
|
||||
is31fl3736_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND_WRITE_LOCK, IS31FL3736_COMMAND_WRITE_LOCK_MAGIC);
|
||||
|
||||
// Select PG3
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND, IS31FL3736_COMMAND_FUNCTION);
|
||||
// Set de-ghost pull-up resistors (SWx)
|
||||
is31fl3736_write_register(addr, IS31FL3736_FUNCTION_REG_SW_PULLUP, IS31FL3736_SW_PULLUP);
|
||||
// Set de-ghost pull-down resistors (CSx)
|
||||
is31fl3736_write_register(addr, IS31FL3736_FUNCTION_REG_CS_PULLDOWN, IS31FL3736_CS_PULLDOWN);
|
||||
// Set global current to maximum.
|
||||
is31fl3736_write_register(addr, IS31FL3736_FUNCTION_REG_GLOBAL_CURRENT, IS31FL3736_GLOBAL_CURRENT);
|
||||
// Disable software shutdown.
|
||||
is31fl3736_write_register(addr, IS31FL3736_FUNCTION_REG_CONFIGURATION, ((IS31FL3736_PWM_FREQUENCY & 0b111) << 3) | 0x01);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
wait_ms(10);
|
||||
}
|
||||
|
||||
void is31fl3736_set_value(int index, uint8_t value) {
|
||||
is31fl3736_led_t led;
|
||||
if (index >= 0 && index < IS31FL3736_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3736_leds[index]), sizeof(led));
|
||||
|
||||
if (g_pwm_buffer[led.driver][led.v] == value) {
|
||||
return;
|
||||
}
|
||||
g_pwm_buffer[led.driver][led.v] = value;
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3736_set_value_all(uint8_t value) {
|
||||
for (int i = 0; i < IS31FL3736_LED_COUNT; i++) {
|
||||
is31fl3736_set_value(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3736_set_led_control_register(uint8_t index, bool value) {
|
||||
is31fl3736_led_t led;
|
||||
memcpy_P(&led, (&g_is31fl3736_leds[index]), sizeof(led));
|
||||
|
||||
// The PWM register for a matrix position (0x00 to 0xBF) is interleaved, so:
|
||||
// A1=0x00 A2=0x02 A3=0x04 A4=0x06 A5=0x08 A6=0x0A A7=0x0C A8=0x0E
|
||||
// B1=0x10 B2=0x12 B3=0x14
|
||||
// But also, the LED control registers (0x00 to 0x17) are also interleaved, so:
|
||||
// A1-A4=0x00 A5-A8=0x01
|
||||
|
||||
uint8_t control_register = led.v / 8;
|
||||
uint8_t bit_value = led.v % 8;
|
||||
|
||||
if (value) {
|
||||
g_led_control_registers[led.driver][control_register] |= (1 << bit_value);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register] &= ~(1 << bit_value);
|
||||
}
|
||||
|
||||
g_led_control_registers_update_required[led.driver] = true;
|
||||
}
|
||||
|
||||
void is31fl3736_update_pwm_buffers(uint8_t addr, uint8_t index) {
|
||||
if (g_pwm_buffer_update_required[index]) {
|
||||
// Firstly we need to unlock the command register and select PG1
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND_WRITE_LOCK, IS31FL3736_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND, IS31FL3736_COMMAND_PWM);
|
||||
|
||||
is31fl3736_write_pwm_buffer(addr, g_pwm_buffer[index]);
|
||||
g_pwm_buffer_update_required[index] = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3736_update_led_control_registers(uint8_t addr, uint8_t index) {
|
||||
if (g_led_control_registers_update_required[index]) {
|
||||
// Firstly we need to unlock the command register and select PG0
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND_WRITE_LOCK, IS31FL3736_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND, IS31FL3736_COMMAND_LED_CONTROL);
|
||||
for (int i = 0; i < IS31FL3736_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3736_write_register(addr, i, g_led_control_registers[index][i]);
|
||||
}
|
||||
g_led_control_registers_update_required[index] = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3736_flush(void) {
|
||||
is31fl3736_update_pwm_buffers(IS31FL3736_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3736_I2C_ADDRESS_2)
|
||||
is31fl3736_update_pwm_buffers(IS31FL3736_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3736_I2C_ADDRESS_3)
|
||||
is31fl3736_update_pwm_buffers(IS31FL3736_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3736_I2C_ADDRESS_4)
|
||||
is31fl3736_update_pwm_buffers(IS31FL3736_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
}
|
|
@ -16,8 +16,8 @@
|
|||
*/
|
||||
|
||||
#include "is31fl3736.h"
|
||||
#include <string.h>
|
||||
#include "i2c_master.h"
|
||||
#include "gpio.h"
|
||||
#include "wait.h"
|
||||
|
||||
#define IS31FL3736_PWM_REGISTER_COUNT 192 // actually 96
|
||||
|
@ -47,54 +47,66 @@
|
|||
# define IS31FL3736_GLOBAL_CURRENT 0xFF
|
||||
#endif
|
||||
|
||||
// Transfer buffer for TWITransmitData()
|
||||
uint8_t g_twi_transfer_buffer[20];
|
||||
const uint8_t i2c_addresses[IS31FL3736_DRIVER_COUNT] = {
|
||||
IS31FL3736_I2C_ADDRESS_1,
|
||||
#ifdef IS31FL3736_I2C_ADDRESS_2
|
||||
IS31FL3736_I2C_ADDRESS_2,
|
||||
# ifdef IS31FL3736_I2C_ADDRESS_3
|
||||
IS31FL3736_I2C_ADDRESS_3,
|
||||
# ifdef IS31FL3736_I2C_ADDRESS_4
|
||||
IS31FL3736_I2C_ADDRESS_4,
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
// These buffers match the IS31FL3736 PWM registers.
|
||||
// The control buffers match the PG0 LED On/Off registers.
|
||||
// The control buffers match the page 0 LED On/Off registers.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
// We could optimize this and take out the unused registers from these
|
||||
// buffers and the transfers in is31fl3736_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
uint8_t g_pwm_buffer[IS31FL3736_DRIVER_COUNT][IS31FL3736_PWM_REGISTER_COUNT];
|
||||
bool g_pwm_buffer_update_required[IS31FL3736_DRIVER_COUNT] = {false};
|
||||
typedef struct is31fl3736_driver_t {
|
||||
uint8_t pwm_buffer[IS31FL3736_PWM_REGISTER_COUNT];
|
||||
bool pwm_buffer_dirty;
|
||||
uint8_t led_control_buffer[IS31FL3736_LED_CONTROL_REGISTER_COUNT];
|
||||
bool led_control_buffer_dirty;
|
||||
} PACKED is31fl3736_driver_t;
|
||||
|
||||
uint8_t g_led_control_registers[IS31FL3736_DRIVER_COUNT][IS31FL3736_LED_CONTROL_REGISTER_COUNT] = {0};
|
||||
bool g_led_control_registers_update_required[IS31FL3736_DRIVER_COUNT] = {false};
|
||||
|
||||
void is31fl3736_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
is31fl3736_driver_t driver_buffers[IS31FL3736_DRIVER_COUNT] = {{
|
||||
.pwm_buffer = {0},
|
||||
.pwm_buffer_dirty = false,
|
||||
.led_control_buffer = {0},
|
||||
.led_control_buffer_dirty = false,
|
||||
}};
|
||||
|
||||
void is31fl3736_write_register(uint8_t index, uint8_t reg, uint8_t data) {
|
||||
#if IS31FL3736_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3736_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3736_I2C_TIMEOUT) == 0) break;
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3736_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3736_I2C_TIMEOUT);
|
||||
i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3736_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
||||
// assumes PG1 is already selected
|
||||
void is31fl3736_select_page(uint8_t index, uint8_t page) {
|
||||
is31fl3736_write_register(index, IS31FL3736_REG_COMMAND_WRITE_LOCK, IS31FL3736_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3736_write_register(index, IS31FL3736_REG_COMMAND, page);
|
||||
}
|
||||
|
||||
// transmit PWM registers in 12 transfers of 16 bytes
|
||||
// g_twi_transfer_buffer[] is 20 bytes
|
||||
|
||||
// iterate over the pwm_buffer contents at 16 byte intervals
|
||||
for (int i = 0; i < IS31FL3736_PWM_REGISTER_COUNT; i += 16) {
|
||||
g_twi_transfer_buffer[0] = i;
|
||||
// copy the data from i to i+15
|
||||
// device will auto-increment register for data after the first byte
|
||||
// thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer
|
||||
memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 16);
|
||||
void is31fl3736_write_pwm_buffer(uint8_t index) {
|
||||
// Assumes page 1 is already selected.
|
||||
// Transmit PWM registers in 12 transfers of 16 bytes.
|
||||
|
||||
// Iterate over the pwm_buffer contents at 16 byte intervals.
|
||||
for (uint8_t i = 0; i < IS31FL3736_PWM_REGISTER_COUNT; i += 16) {
|
||||
#if IS31FL3736_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3736_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3736_I2C_TIMEOUT) == 0) break;
|
||||
for (uint8_t j = 0; j < IS31FL3736_I2C_PERSISTENCE; j++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer + i, 16, IS31FL3736_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3736_I2C_TIMEOUT);
|
||||
i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer + i, 16, IS31FL3736_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -102,73 +114,55 @@ void is31fl3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
|||
void is31fl3736_init_drivers(void) {
|
||||
i2c_init();
|
||||
|
||||
is31fl3736_init(IS31FL3736_I2C_ADDRESS_1);
|
||||
#if defined(IS31FL3736_I2C_ADDRESS_2)
|
||||
is31fl3736_init(IS31FL3736_I2C_ADDRESS_2);
|
||||
# if defined(IS31FL3736_I2C_ADDRESS_3)
|
||||
is31fl3736_init(IS31FL3736_I2C_ADDRESS_3);
|
||||
# if defined(IS31FL3736_I2C_ADDRESS_4)
|
||||
is31fl3736_init(IS31FL3736_I2C_ADDRESS_4);
|
||||
# endif
|
||||
# endif
|
||||
#if defined(IS31FL3736_SDB_PIN)
|
||||
gpio_set_pin_output(IS31FL3736_SDB_PIN);
|
||||
gpio_write_pin_high(IS31FL3736_SDB_PIN);
|
||||
#endif
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3736_DRIVER_COUNT; i++) {
|
||||
is31fl3736_init(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < IS31FL3736_LED_COUNT; i++) {
|
||||
is31fl3736_set_led_control_register(i, true, true, true);
|
||||
}
|
||||
|
||||
is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3736_I2C_ADDRESS_2)
|
||||
is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3736_I2C_ADDRESS_3)
|
||||
is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3736_I2C_ADDRESS_4)
|
||||
is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
for (uint8_t i = 0; i < IS31FL3736_DRIVER_COUNT; i++) {
|
||||
is31fl3736_update_led_control_registers(i);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3736_init(uint8_t addr) {
|
||||
void is31fl3736_init(uint8_t index) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND_WRITE_LOCK, IS31FL3736_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3736_select_page(index, IS31FL3736_COMMAND_LED_CONTROL);
|
||||
|
||||
// Select PG0
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND, IS31FL3736_REG_LED_CONTROL);
|
||||
// Turn off all LEDs.
|
||||
for (int i = 0; i < IS31FL3736_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3736_write_register(addr, i, 0x00);
|
||||
for (uint8_t i = 0; i < IS31FL3736_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3736_write_register(index, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND_WRITELOCK, IS31FL3736_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3736_select_page(index, IS31FL3736_COMMAND_PWM);
|
||||
|
||||
// Select PG1
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND, IS31FL3736_COMMAND_PWM);
|
||||
// Set PWM on all LEDs to 0
|
||||
// No need to setup Breath registers to PWM as that is the default.
|
||||
for (int i = 0; i < IS31FL3736_PWM_REGISTER_COUNT; i++) {
|
||||
is31fl3736_write_register(addr, i, 0x00);
|
||||
for (uint8_t i = 0; i < IS31FL3736_PWM_REGISTER_COUNT; i++) {
|
||||
is31fl3736_write_register(index, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND_WRITE_LOCK, IS31FL3736_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3736_select_page(index, IS31FL3736_COMMAND_FUNCTION);
|
||||
|
||||
// Select PG3
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND, IS31FL3736_COMMAND_FUNCTION);
|
||||
// Set de-ghost pull-up resistors (SWx)
|
||||
is31fl3736_write_register(addr, IS31FL3736_FUNCTION_REG_SW_PULLUP, IS31FL3736_SW_PULLUP);
|
||||
is31fl3736_write_register(index, IS31FL3736_FUNCTION_REG_SW_PULLUP, IS31FL3736_SW_PULLUP);
|
||||
// Set de-ghost pull-down resistors (CSx)
|
||||
is31fl3736_write_register(addr, IS31FL3736_FUNCTION_REG_CS_PULLDOWN, IS31FL3736_CS_PULLDOWN);
|
||||
is31fl3736_write_register(index, IS31FL3736_FUNCTION_REG_CS_PULLDOWN, IS31FL3736_CS_PULLDOWN);
|
||||
// Set global current to maximum.
|
||||
is31fl3736_write_register(addr, IS31FL3736_FUNCTION_REG_GLOBAL_CURRENT, IS31FL3736_GLOBAL_CURRENT);
|
||||
is31fl3736_write_register(index, IS31FL3736_FUNCTION_REG_GLOBAL_CURRENT, IS31FL3736_GLOBAL_CURRENT);
|
||||
// Disable software shutdown.
|
||||
is31fl3736_write_register(addr, IS31FL3736_FUNCTION_REG_CONFIGURATION, ((IS31FL3736_PWM_FREQUENCY & 0b111) << 3) | 0x01);
|
||||
is31fl3736_write_register(index, IS31FL3736_FUNCTION_REG_CONFIGURATION, ((IS31FL3736_PWM_FREQUENCY & 0b111) << 3) | 0x01);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
wait_ms(10);
|
||||
|
@ -176,16 +170,18 @@ void is31fl3736_init(uint8_t addr) {
|
|||
|
||||
void is31fl3736_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
is31fl3736_led_t led;
|
||||
|
||||
if (index >= 0 && index < IS31FL3736_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3736_leds[index]), sizeof(led));
|
||||
|
||||
if (g_pwm_buffer[led.driver][led.r] == red && g_pwm_buffer[led.driver][led.g] == green && g_pwm_buffer[led.driver][led.b] == blue) {
|
||||
if (driver_buffers[led.driver].pwm_buffer[led.r] == red && driver_buffers[led.driver].pwm_buffer[led.g] == green && driver_buffers[led.driver].pwm_buffer[led.b] == blue) {
|
||||
return;
|
||||
}
|
||||
g_pwm_buffer[led.driver][led.r] = red;
|
||||
g_pwm_buffer[led.driver][led.g] = green;
|
||||
g_pwm_buffer[led.driver][led.b] = blue;
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
|
||||
driver_buffers[led.driver].pwm_buffer[led.r] = red;
|
||||
driver_buffers[led.driver].pwm_buffer[led.g] = green;
|
||||
driver_buffers[led.driver].pwm_buffer[led.b] = blue;
|
||||
driver_buffers[led.driver].pwm_buffer_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,56 +210,48 @@ void is31fl3736_set_led_control_register(uint8_t index, bool red, bool green, bo
|
|||
uint8_t bit_b = led.b % 8;
|
||||
|
||||
if (red) {
|
||||
g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_r] |= (1 << bit_r);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_r] &= ~(1 << bit_r);
|
||||
}
|
||||
if (green) {
|
||||
g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_g] |= (1 << bit_g);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_g] &= ~(1 << bit_g);
|
||||
}
|
||||
if (blue) {
|
||||
g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_b] |= (1 << bit_b);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_b] &= ~(1 << bit_b);
|
||||
}
|
||||
|
||||
g_led_control_registers_update_required[led.driver] = true;
|
||||
driver_buffers[led.driver].led_control_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3736_update_pwm_buffers(uint8_t addr, uint8_t index) {
|
||||
if (g_pwm_buffer_update_required[index]) {
|
||||
// Firstly we need to unlock the command register and select PG1
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND_WRITE_LOCK, IS31FL3736_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND, IS31FL3736_COMMAND_PWM);
|
||||
void is31fl3736_update_pwm_buffers(uint8_t index) {
|
||||
if (driver_buffers[index].pwm_buffer_dirty) {
|
||||
is31fl3736_select_page(index, IS31FL3736_COMMAND_PWM);
|
||||
|
||||
is31fl3736_write_pwm_buffer(addr, g_pwm_buffer[index]);
|
||||
g_pwm_buffer_update_required[index] = false;
|
||||
is31fl3736_write_pwm_buffer(index);
|
||||
|
||||
driver_buffers[index].pwm_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3736_update_led_control_registers(uint8_t addr, uint8_t index) {
|
||||
if (g_led_control_registers_update_required[index]) {
|
||||
// Firstly we need to unlock the command register and select PG0
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND_WRITE_LOCK, IS31FL3736_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3736_write_register(addr, IS31FL3736_REG_COMMAND, IS31FL3736_COMMAND_LED_CONTROL);
|
||||
for (int i = 0; i < IS31FL3736_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3736_write_register(addr, i, g_led_control_registers[index][i]);
|
||||
void is31fl3736_update_led_control_registers(uint8_t index) {
|
||||
if (driver_buffers[index].led_control_buffer_dirty) {
|
||||
is31fl3736_select_page(index, IS31FL3736_COMMAND_LED_CONTROL);
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3736_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3736_write_register(index, i, driver_buffers[index].led_control_buffer[i]);
|
||||
}
|
||||
g_led_control_registers_update_required[index] = false;
|
||||
|
||||
driver_buffers[index].led_control_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3736_flush(void) {
|
||||
is31fl3736_update_pwm_buffers(IS31FL3736_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3736_I2C_ADDRESS_2)
|
||||
is31fl3736_update_pwm_buffers(IS31FL3736_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3736_I2C_ADDRESS_3)
|
||||
is31fl3736_update_pwm_buffers(IS31FL3736_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3736_I2C_ADDRESS_4)
|
||||
is31fl3736_update_pwm_buffers(IS31FL3736_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
for (uint8_t i = 0; i < IS31FL3736_DRIVER_COUNT; i++) {
|
||||
is31fl3736_update_pwm_buffers(i);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,9 +124,9 @@ typedef struct is31fl3736_led_t {
|
|||
extern const is31fl3736_led_t PROGMEM g_is31fl3736_leds[IS31FL3736_LED_COUNT];
|
||||
|
||||
void is31fl3736_init_drivers(void);
|
||||
void is31fl3736_init(uint8_t addr);
|
||||
void is31fl3736_write_register(uint8_t addr, uint8_t reg, uint8_t data);
|
||||
void is31fl3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
|
||||
void is31fl3736_init(uint8_t index);
|
||||
void is31fl3736_write_register(uint8_t index, uint8_t reg, uint8_t data);
|
||||
void is31fl3736_select_page(uint8_t index, uint8_t page);
|
||||
|
||||
void is31fl3736_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
|
||||
void is31fl3736_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
@ -137,8 +137,8 @@ void is31fl3736_set_led_control_register(uint8_t index, bool red, bool green, bo
|
|||
// (eg. from a timer interrupt).
|
||||
// Call this while idle (in between matrix scans).
|
||||
// If the buffer is dirty, it will update the driver with the buffer.
|
||||
void is31fl3736_update_pwm_buffers(uint8_t addr, uint8_t index);
|
||||
void is31fl3736_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
void is31fl3736_update_pwm_buffers(uint8_t index);
|
||||
void is31fl3736_update_led_control_registers(uint8_t index);
|
||||
|
||||
void is31fl3736_flush(void);
|
||||
|
||||
|
@ -166,110 +166,110 @@ void is31fl3736_flush(void);
|
|||
#define IS31FL3736_PWM_FREQUENCY_2K1_HZ 0b011
|
||||
#define IS31FL3736_PWM_FREQUENCY_1K05_HZ 0b100
|
||||
|
||||
#define A_1 0x00
|
||||
#define A_2 0x02
|
||||
#define A_3 0x04
|
||||
#define A_4 0x06
|
||||
#define A_5 0x08
|
||||
#define A_6 0x0A
|
||||
#define A_7 0x0C
|
||||
#define A_8 0x0E
|
||||
#define SW1_CS1 0x00
|
||||
#define SW1_CS2 0x02
|
||||
#define SW1_CS3 0x04
|
||||
#define SW1_CS4 0x06
|
||||
#define SW1_CS5 0x08
|
||||
#define SW1_CS6 0x0A
|
||||
#define SW1_CS7 0x0C
|
||||
#define SW1_CS8 0x0E
|
||||
|
||||
#define B_1 0x10
|
||||
#define B_2 0x12
|
||||
#define B_3 0x14
|
||||
#define B_4 0x16
|
||||
#define B_5 0x18
|
||||
#define B_6 0x1A
|
||||
#define B_7 0x1C
|
||||
#define B_8 0x1E
|
||||
#define SW2_CS1 0x10
|
||||
#define SW2_CS2 0x12
|
||||
#define SW2_CS3 0x14
|
||||
#define SW2_CS4 0x16
|
||||
#define SW2_CS5 0x18
|
||||
#define SW2_CS6 0x1A
|
||||
#define SW2_CS7 0x1C
|
||||
#define SW2_CS8 0x1E
|
||||
|
||||
#define C_1 0x20
|
||||
#define C_2 0x22
|
||||
#define C_3 0x24
|
||||
#define C_4 0x26
|
||||
#define C_5 0x28
|
||||
#define C_6 0x2A
|
||||
#define C_7 0x2C
|
||||
#define C_8 0x2E
|
||||
#define SW3_CS1 0x20
|
||||
#define SW3_CS2 0x22
|
||||
#define SW3_CS3 0x24
|
||||
#define SW3_CS4 0x26
|
||||
#define SW3_CS5 0x28
|
||||
#define SW3_CS6 0x2A
|
||||
#define SW3_CS7 0x2C
|
||||
#define SW3_CS8 0x2E
|
||||
|
||||
#define D_1 0x30
|
||||
#define D_2 0x32
|
||||
#define D_3 0x34
|
||||
#define D_4 0x36
|
||||
#define D_5 0x38
|
||||
#define D_6 0x3A
|
||||
#define D_7 0x3C
|
||||
#define D_8 0x3E
|
||||
#define SW4_CS1 0x30
|
||||
#define SW4_CS2 0x32
|
||||
#define SW4_CS3 0x34
|
||||
#define SW4_CS4 0x36
|
||||
#define SW4_CS5 0x38
|
||||
#define SW4_CS6 0x3A
|
||||
#define SW4_CS7 0x3C
|
||||
#define SW4_CS8 0x3E
|
||||
|
||||
#define E_1 0x40
|
||||
#define E_2 0x42
|
||||
#define E_3 0x44
|
||||
#define E_4 0x46
|
||||
#define E_5 0x48
|
||||
#define E_6 0x4A
|
||||
#define E_7 0x4C
|
||||
#define E_8 0x4E
|
||||
#define SW5_CS1 0x40
|
||||
#define SW5_CS2 0x42
|
||||
#define SW5_CS3 0x44
|
||||
#define SW5_CS4 0x46
|
||||
#define SW5_CS5 0x48
|
||||
#define SW5_CS6 0x4A
|
||||
#define SW5_CS7 0x4C
|
||||
#define SW5_CS8 0x4E
|
||||
|
||||
#define F_1 0x50
|
||||
#define F_2 0x52
|
||||
#define F_3 0x54
|
||||
#define F_4 0x56
|
||||
#define F_5 0x58
|
||||
#define F_6 0x5A
|
||||
#define F_7 0x5C
|
||||
#define F_8 0x5E
|
||||
#define SW6_CS1 0x50
|
||||
#define SW6_CS2 0x52
|
||||
#define SW6_CS3 0x54
|
||||
#define SW6_CS4 0x56
|
||||
#define SW6_CS5 0x58
|
||||
#define SW6_CS6 0x5A
|
||||
#define SW6_CS7 0x5C
|
||||
#define SW6_CS8 0x5E
|
||||
|
||||
#define G_1 0x60
|
||||
#define G_2 0x62
|
||||
#define G_3 0x64
|
||||
#define G_4 0x66
|
||||
#define G_5 0x68
|
||||
#define G_6 0x6A
|
||||
#define G_7 0x6C
|
||||
#define G_8 0x6E
|
||||
#define SW7_CS1 0x60
|
||||
#define SW7_CS2 0x62
|
||||
#define SW7_CS3 0x64
|
||||
#define SW7_CS4 0x66
|
||||
#define SW7_CS5 0x68
|
||||
#define SW7_CS6 0x6A
|
||||
#define SW7_CS7 0x6C
|
||||
#define SW7_CS8 0x6E
|
||||
|
||||
#define H_1 0x70
|
||||
#define H_2 0x72
|
||||
#define H_3 0x74
|
||||
#define H_4 0x76
|
||||
#define H_5 0x78
|
||||
#define H_6 0x7A
|
||||
#define H_7 0x7C
|
||||
#define H_8 0x7E
|
||||
#define SW8_CS1 0x70
|
||||
#define SW8_CS2 0x72
|
||||
#define SW8_CS3 0x74
|
||||
#define SW8_CS4 0x76
|
||||
#define SW8_CS5 0x78
|
||||
#define SW8_CS6 0x7A
|
||||
#define SW8_CS7 0x7C
|
||||
#define SW8_CS8 0x7E
|
||||
|
||||
#define I_1 0x80
|
||||
#define I_2 0x82
|
||||
#define I_3 0x84
|
||||
#define I_4 0x86
|
||||
#define I_5 0x88
|
||||
#define I_6 0x8A
|
||||
#define I_7 0x8C
|
||||
#define I_8 0x8E
|
||||
#define SW9_CS1 0x80
|
||||
#define SW9_CS2 0x82
|
||||
#define SW9_CS3 0x84
|
||||
#define SW9_CS4 0x86
|
||||
#define SW9_CS5 0x88
|
||||
#define SW9_CS6 0x8A
|
||||
#define SW9_CS7 0x8C
|
||||
#define SW9_CS8 0x8E
|
||||
|
||||
#define J_1 0x90
|
||||
#define J_2 0x92
|
||||
#define J_3 0x94
|
||||
#define J_4 0x96
|
||||
#define J_5 0x98
|
||||
#define J_6 0x9A
|
||||
#define J_7 0x9C
|
||||
#define J_8 0x9E
|
||||
#define SW10_CS1 0x90
|
||||
#define SW10_CS2 0x92
|
||||
#define SW10_CS3 0x94
|
||||
#define SW10_CS4 0x96
|
||||
#define SW10_CS5 0x98
|
||||
#define SW10_CS6 0x9A
|
||||
#define SW10_CS7 0x9C
|
||||
#define SW10_CS8 0x9E
|
||||
|
||||
#define K_1 0xA0
|
||||
#define K_2 0xA2
|
||||
#define K_3 0xA4
|
||||
#define K_4 0xA6
|
||||
#define K_5 0xA8
|
||||
#define K_6 0xAA
|
||||
#define K_7 0xAC
|
||||
#define K_8 0xAE
|
||||
#define SW11_CS1 0xA0
|
||||
#define SW11_CS2 0xA2
|
||||
#define SW11_CS3 0xA4
|
||||
#define SW11_CS4 0xA6
|
||||
#define SW11_CS5 0xA8
|
||||
#define SW11_CS6 0xAA
|
||||
#define SW11_CS7 0xAC
|
||||
#define SW11_CS8 0xAE
|
||||
|
||||
#define L_1 0xB0
|
||||
#define L_2 0xB2
|
||||
#define L_3 0xB4
|
||||
#define L_4 0xB6
|
||||
#define L_5 0xB8
|
||||
#define L_6 0xBA
|
||||
#define L_7 0xBC
|
||||
#define L_8 0xBE
|
||||
#define SW12_CS1 0xB0
|
||||
#define SW12_CS2 0xB2
|
||||
#define SW12_CS3 0xB4
|
||||
#define SW12_CS4 0xB6
|
||||
#define SW12_CS5 0xB8
|
||||
#define SW12_CS6 0xBA
|
||||
#define SW12_CS7 0xBC
|
||||
#define SW12_CS8 0xBE
|
||||
|
|
236
drivers/led/issi/is31fl3737-mono.c
Normal file
236
drivers/led/issi/is31fl3737-mono.c
Normal file
|
@ -0,0 +1,236 @@
|
|||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2021 Doni Crosby
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "is31fl3737-mono.h"
|
||||
#include "i2c_master.h"
|
||||
#include "gpio.h"
|
||||
#include "wait.h"
|
||||
|
||||
#define IS31FL3737_PWM_REGISTER_COUNT 192 // actually 144
|
||||
#define IS31FL3737_LED_CONTROL_REGISTER_COUNT 24
|
||||
|
||||
#ifndef IS31FL3737_I2C_TIMEOUT
|
||||
# define IS31FL3737_I2C_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3737_I2C_PERSISTENCE
|
||||
# define IS31FL3737_I2C_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3737_PWM_FREQUENCY
|
||||
# define IS31FL3737_PWM_FREQUENCY IS31FL3737_PWM_FREQUENCY_8K4_HZ // PFS - IS31FL3737B only
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3737_SW_PULLUP
|
||||
# define IS31FL3737_SW_PULLUP IS31FL3737_PUR_0_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3737_CS_PULLDOWN
|
||||
# define IS31FL3737_CS_PULLDOWN IS31FL3737_PDR_0_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3737_GLOBAL_CURRENT
|
||||
# define IS31FL3737_GLOBAL_CURRENT 0xFF
|
||||
#endif
|
||||
|
||||
const uint8_t i2c_addresses[IS31FL3737_DRIVER_COUNT] = {
|
||||
IS31FL3737_I2C_ADDRESS_1,
|
||||
#ifdef IS31FL3737_I2C_ADDRESS_2
|
||||
IS31FL3737_I2C_ADDRESS_2,
|
||||
# ifdef IS31FL3737_I2C_ADDRESS_3
|
||||
IS31FL3737_I2C_ADDRESS_3,
|
||||
# ifdef IS31FL3737_I2C_ADDRESS_4
|
||||
IS31FL3737_I2C_ADDRESS_4,
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
// These buffers match the IS31FL3737 PWM registers.
|
||||
// The control buffers match the page 0 LED On/Off registers.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
// We could optimize this and take out the unused registers from these
|
||||
// buffers and the transfers in is31fl3737_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
typedef struct is31fl3737_driver_t {
|
||||
uint8_t pwm_buffer[IS31FL3737_PWM_REGISTER_COUNT];
|
||||
bool pwm_buffer_dirty;
|
||||
uint8_t led_control_buffer[IS31FL3737_LED_CONTROL_REGISTER_COUNT];
|
||||
bool led_control_buffer_dirty;
|
||||
} PACKED is31fl3737_driver_t;
|
||||
|
||||
is31fl3737_driver_t driver_buffers[IS31FL3737_DRIVER_COUNT] = {{
|
||||
.pwm_buffer = {0},
|
||||
.pwm_buffer_dirty = false,
|
||||
.led_control_buffer = {0},
|
||||
.led_control_buffer_dirty = false,
|
||||
}};
|
||||
|
||||
void is31fl3737_write_register(uint8_t index, uint8_t reg, uint8_t data) {
|
||||
#if IS31FL3737_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3737_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3737_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3737_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3737_select_page(uint8_t index, uint8_t page) {
|
||||
is31fl3737_write_register(index, IS31FL3737_REG_COMMAND_WRITE_LOCK, IS31FL3737_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3737_write_register(index, IS31FL3737_REG_COMMAND, page);
|
||||
}
|
||||
|
||||
void is31fl3737_write_pwm_buffer(uint8_t index) {
|
||||
// Assumes page 1 is already selected.
|
||||
// Transmit PWM registers in 12 transfers of 16 bytes.
|
||||
|
||||
// Iterate over the pwm_buffer contents at 16 byte intervals.
|
||||
for (uint8_t i = 0; i < IS31FL3737_PWM_REGISTER_COUNT; i += 16) {
|
||||
#if IS31FL3737_I2C_PERSISTENCE > 0
|
||||
for (uint8_t j = 0; j < IS31FL3737_I2C_PERSISTENCE; j++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer + i, 16, IS31FL3737_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer + i, 16, IS31FL3737_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3737_init_drivers(void) {
|
||||
i2c_init();
|
||||
|
||||
#if defined(IS31FL3737_SDB_PIN)
|
||||
gpio_set_pin_output(IS31FL3737_SDB_PIN);
|
||||
gpio_write_pin_high(IS31FL3737_SDB_PIN);
|
||||
#endif
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3737_DRIVER_COUNT; i++) {
|
||||
is31fl3737_init(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < IS31FL3737_LED_COUNT; i++) {
|
||||
is31fl3737_set_led_control_register(i, true);
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3737_DRIVER_COUNT; i++) {
|
||||
is31fl3737_update_led_control_registers(i);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3737_init(uint8_t index) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
|
||||
is31fl3737_select_page(index, IS31FL3737_COMMAND_LED_CONTROL);
|
||||
|
||||
// Turn off all LEDs.
|
||||
for (uint8_t i = 0; i < IS31FL3737_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3737_write_register(index, i, 0x00);
|
||||
}
|
||||
|
||||
is31fl3737_select_page(index, IS31FL3737_COMMAND_PWM);
|
||||
|
||||
// Set PWM on all LEDs to 0
|
||||
// No need to setup Breath registers to PWM as that is the default.
|
||||
for (uint8_t i = 0; i < IS31FL3737_PWM_REGISTER_COUNT; i++) {
|
||||
is31fl3737_write_register(index, i, 0x00);
|
||||
}
|
||||
|
||||
is31fl3737_select_page(index, IS31FL3737_COMMAND_FUNCTION);
|
||||
|
||||
// Set de-ghost pull-up resistors (SWx)
|
||||
is31fl3737_write_register(index, IS31FL3737_FUNCTION_REG_SW_PULLUP, IS31FL3737_SW_PULLUP);
|
||||
// Set de-ghost pull-down resistors (CSx)
|
||||
is31fl3737_write_register(index, IS31FL3737_FUNCTION_REG_CS_PULLDOWN, IS31FL3737_CS_PULLDOWN);
|
||||
// Set global current to maximum.
|
||||
is31fl3737_write_register(index, IS31FL3737_FUNCTION_REG_GLOBAL_CURRENT, IS31FL3737_GLOBAL_CURRENT);
|
||||
// Disable software shutdown.
|
||||
is31fl3737_write_register(index, IS31FL3737_FUNCTION_REG_CONFIGURATION, ((IS31FL3737_PWM_FREQUENCY & 0b111) << 3) | 0x01);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
wait_ms(10);
|
||||
}
|
||||
|
||||
void is31fl3737_set_value(int index, uint8_t value) {
|
||||
is31fl3737_led_t led;
|
||||
|
||||
if (index >= 0 && index < IS31FL3737_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3737_leds[index]), sizeof(led));
|
||||
|
||||
if (driver_buffers[led.driver].pwm_buffer[led.v] == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
driver_buffers[led.driver].pwm_buffer[led.v] = value;
|
||||
driver_buffers[led.driver].pwm_buffer_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3737_set_value_all(uint8_t value) {
|
||||
for (int i = 0; i < IS31FL3737_LED_COUNT; i++) {
|
||||
is31fl3737_set_value(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3737_set_led_control_register(uint8_t index, bool value) {
|
||||
is31fl3737_led_t led;
|
||||
memcpy_P(&led, (&g_is31fl3737_leds[index]), sizeof(led));
|
||||
|
||||
uint8_t control_register = led.v / 8;
|
||||
uint8_t bit_value = led.v % 8;
|
||||
|
||||
if (value) {
|
||||
driver_buffers[led.driver].led_control_buffer[control_register] |= (1 << bit_value);
|
||||
} else {
|
||||
driver_buffers[led.driver].led_control_buffer[control_register] &= ~(1 << bit_value);
|
||||
}
|
||||
|
||||
driver_buffers[led.driver].led_control_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3737_update_pwm_buffers(uint8_t index) {
|
||||
if (driver_buffers[index].pwm_buffer_dirty) {
|
||||
is31fl3737_select_page(index, IS31FL3737_COMMAND_PWM);
|
||||
|
||||
is31fl3737_write_pwm_buffer(index);
|
||||
|
||||
driver_buffers[index].pwm_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3737_update_led_control_registers(uint8_t index) {
|
||||
if (driver_buffers[index].led_control_buffer_dirty) {
|
||||
is31fl3737_select_page(index, IS31FL3737_COMMAND_LED_CONTROL);
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3737_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3737_write_register(index, i, driver_buffers[index].led_control_buffer[i]);
|
||||
}
|
||||
|
||||
driver_buffers[index].led_control_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3737_flush(void) {
|
||||
for (uint8_t i = 0; i < IS31FL3737_DRIVER_COUNT; i++) {
|
||||
is31fl3737_update_pwm_buffers(i);
|
||||
}
|
||||
}
|
|
@ -100,9 +100,9 @@ typedef struct is31fl3737_led_t {
|
|||
extern const is31fl3737_led_t PROGMEM g_is31fl3737_leds[IS31FL3737_LED_COUNT];
|
||||
|
||||
void is31fl3737_init_drivers(void);
|
||||
void is31fl3737_init(uint8_t addr);
|
||||
void is31fl3737_write_register(uint8_t addr, uint8_t reg, uint8_t data);
|
||||
void is31fl3737_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
|
||||
void is31fl3737_init(uint8_t index);
|
||||
void is31fl3737_write_register(uint8_t index, uint8_t reg, uint8_t data);
|
||||
void is31fl3737_select_page(uint8_t index, uint8_t page);
|
||||
|
||||
void is31fl3737_set_value(int index, uint8_t value);
|
||||
void is31fl3737_set_value_all(uint8_t value);
|
||||
|
@ -113,8 +113,8 @@ void is31fl3737_set_led_control_register(uint8_t index, bool value);
|
|||
// (eg. from a timer interrupt).
|
||||
// Call this while idle (in between matrix scans).
|
||||
// If the buffer is dirty, it will update the driver with the buffer.
|
||||
void is31fl3737_update_pwm_buffers(uint8_t addr, uint8_t index);
|
||||
void is31fl3737_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
void is31fl3737_update_pwm_buffers(uint8_t index);
|
||||
void is31fl3737_update_led_control_registers(uint8_t index);
|
||||
|
||||
void is31fl3737_flush(void);
|
||||
|
||||
|
@ -142,158 +142,158 @@ void is31fl3737_flush(void);
|
|||
#define IS31FL3737_PWM_FREQUENCY_2K1_HZ 0b011
|
||||
#define IS31FL3737_PWM_FREQUENCY_1K05_HZ 0b100
|
||||
|
||||
#define A_1 0x00
|
||||
#define A_2 0x01
|
||||
#define A_3 0x02
|
||||
#define A_4 0x03
|
||||
#define A_5 0x04
|
||||
#define A_6 0x05
|
||||
#define A_7 0x08
|
||||
#define A_8 0x09
|
||||
#define A_9 0x0A
|
||||
#define A_10 0x0B
|
||||
#define A_11 0x0C
|
||||
#define A_12 0x0D
|
||||
#define SW1_CS1 0x00
|
||||
#define SW1_CS2 0x01
|
||||
#define SW1_CS3 0x02
|
||||
#define SW1_CS4 0x03
|
||||
#define SW1_CS5 0x04
|
||||
#define SW1_CS6 0x05
|
||||
#define SW1_CS7 0x08
|
||||
#define SW1_CS8 0x09
|
||||
#define SW1_CS9 0x0A
|
||||
#define SW1_CS10 0x0B
|
||||
#define SW1_CS11 0x0C
|
||||
#define SW1_CS12 0x0D
|
||||
|
||||
#define B_1 0x10
|
||||
#define B_2 0x11
|
||||
#define B_3 0x12
|
||||
#define B_4 0x13
|
||||
#define B_5 0x14
|
||||
#define B_6 0x15
|
||||
#define B_7 0x18
|
||||
#define B_8 0x19
|
||||
#define B_9 0x1A
|
||||
#define B_10 0x1B
|
||||
#define B_11 0x1C
|
||||
#define B_12 0x1D
|
||||
#define SW2_CS1 0x10
|
||||
#define SW2_CS2 0x11
|
||||
#define SW2_CS3 0x12
|
||||
#define SW2_CS4 0x13
|
||||
#define SW2_CS5 0x14
|
||||
#define SW2_CS6 0x15
|
||||
#define SW2_CS7 0x18
|
||||
#define SW2_CS8 0x19
|
||||
#define SW2_CS9 0x1A
|
||||
#define SW2_CS10 0x1B
|
||||
#define SW2_CS11 0x1C
|
||||
#define SW2_CS12 0x1D
|
||||
|
||||
#define C_1 0x20
|
||||
#define C_2 0x21
|
||||
#define C_3 0x22
|
||||
#define C_4 0x23
|
||||
#define C_5 0x24
|
||||
#define C_6 0x25
|
||||
#define C_7 0x28
|
||||
#define C_8 0x29
|
||||
#define C_9 0x2A
|
||||
#define C_10 0x2B
|
||||
#define C_11 0x2C
|
||||
#define C_12 0x2D
|
||||
#define SW3_CS1 0x20
|
||||
#define SW3_CS2 0x21
|
||||
#define SW3_CS3 0x22
|
||||
#define SW3_CS4 0x23
|
||||
#define SW3_CS5 0x24
|
||||
#define SW3_CS6 0x25
|
||||
#define SW3_CS7 0x28
|
||||
#define SW3_CS8 0x29
|
||||
#define SW3_CS9 0x2A
|
||||
#define SW3_CS10 0x2B
|
||||
#define SW3_CS11 0x2C
|
||||
#define SW3_CS12 0x2D
|
||||
|
||||
#define D_1 0x30
|
||||
#define D_2 0x31
|
||||
#define D_3 0x32
|
||||
#define D_4 0x33
|
||||
#define D_5 0x34
|
||||
#define D_6 0x35
|
||||
#define D_7 0x38
|
||||
#define D_8 0x39
|
||||
#define D_9 0x3A
|
||||
#define D_10 0x3B
|
||||
#define D_11 0x3C
|
||||
#define D_12 0x3D
|
||||
#define SW4_CS1 0x30
|
||||
#define SW4_CS2 0x31
|
||||
#define SW4_CS3 0x32
|
||||
#define SW4_CS4 0x33
|
||||
#define SW4_CS5 0x34
|
||||
#define SW4_CS6 0x35
|
||||
#define SW4_CS7 0x38
|
||||
#define SW4_CS8 0x39
|
||||
#define SW4_CS9 0x3A
|
||||
#define SW4_CS10 0x3B
|
||||
#define SW4_CS11 0x3C
|
||||
#define SW4_CS12 0x3D
|
||||
|
||||
#define E_1 0x40
|
||||
#define E_2 0x41
|
||||
#define E_3 0x42
|
||||
#define E_4 0x43
|
||||
#define E_5 0x44
|
||||
#define E_6 0x45
|
||||
#define E_7 0x48
|
||||
#define E_8 0x49
|
||||
#define E_9 0x4A
|
||||
#define E_10 0x4B
|
||||
#define E_11 0x4C
|
||||
#define E_12 0x4D
|
||||
#define SW5_CS1 0x40
|
||||
#define SW5_CS2 0x41
|
||||
#define SW5_CS3 0x42
|
||||
#define SW5_CS4 0x43
|
||||
#define SW5_CS5 0x44
|
||||
#define SW5_CS6 0x45
|
||||
#define SW5_CS7 0x48
|
||||
#define SW5_CS8 0x49
|
||||
#define SW5_CS9 0x4A
|
||||
#define SW5_CS10 0x4B
|
||||
#define SW5_CS11 0x4C
|
||||
#define SW5_CS12 0x4D
|
||||
|
||||
#define F_1 0x50
|
||||
#define F_2 0x51
|
||||
#define F_3 0x52
|
||||
#define F_4 0x53
|
||||
#define F_5 0x54
|
||||
#define F_6 0x55
|
||||
#define F_7 0x58
|
||||
#define F_8 0x59
|
||||
#define F_9 0x5A
|
||||
#define F_10 0x5B
|
||||
#define F_11 0x5C
|
||||
#define F_12 0x5D
|
||||
#define SW6_CS1 0x50
|
||||
#define SW6_CS2 0x51
|
||||
#define SW6_CS3 0x52
|
||||
#define SW6_CS4 0x53
|
||||
#define SW6_CS5 0x54
|
||||
#define SW6_CS6 0x55
|
||||
#define SW6_CS7 0x58
|
||||
#define SW6_CS8 0x59
|
||||
#define SW6_CS9 0x5A
|
||||
#define SW6_CS10 0x5B
|
||||
#define SW6_CS11 0x5C
|
||||
#define SW6_CS12 0x5D
|
||||
|
||||
#define G_1 0x60
|
||||
#define G_2 0x61
|
||||
#define G_3 0x62
|
||||
#define G_4 0x63
|
||||
#define G_5 0x64
|
||||
#define G_6 0x65
|
||||
#define G_7 0x68
|
||||
#define G_8 0x69
|
||||
#define G_9 0x6A
|
||||
#define G_10 0x6B
|
||||
#define G_11 0x6C
|
||||
#define G_12 0x6D
|
||||
#define SW7_CS1 0x60
|
||||
#define SW7_CS2 0x61
|
||||
#define SW7_CS3 0x62
|
||||
#define SW7_CS4 0x63
|
||||
#define SW7_CS5 0x64
|
||||
#define SW7_CS6 0x65
|
||||
#define SW7_CS7 0x68
|
||||
#define SW7_CS8 0x69
|
||||
#define SW7_CS9 0x6A
|
||||
#define SW7_CS10 0x6B
|
||||
#define SW7_CS11 0x6C
|
||||
#define SW7_CS12 0x6D
|
||||
|
||||
#define H_1 0x70
|
||||
#define H_2 0x71
|
||||
#define H_3 0x72
|
||||
#define H_4 0x73
|
||||
#define H_5 0x74
|
||||
#define H_6 0x75
|
||||
#define H_7 0x78
|
||||
#define H_8 0x79
|
||||
#define H_9 0x7A
|
||||
#define H_10 0x7B
|
||||
#define H_11 0x7C
|
||||
#define H_12 0x7D
|
||||
#define SW8_CS1 0x70
|
||||
#define SW8_CS2 0x71
|
||||
#define SW8_CS3 0x72
|
||||
#define SW8_CS4 0x73
|
||||
#define SW8_CS5 0x74
|
||||
#define SW8_CS6 0x75
|
||||
#define SW8_CS7 0x78
|
||||
#define SW8_CS8 0x79
|
||||
#define SW8_CS9 0x7A
|
||||
#define SW8_CS10 0x7B
|
||||
#define SW8_CS11 0x7C
|
||||
#define SW8_CS12 0x7D
|
||||
|
||||
#define I_1 0x80
|
||||
#define I_2 0x81
|
||||
#define I_3 0x82
|
||||
#define I_4 0x83
|
||||
#define I_5 0x84
|
||||
#define I_6 0x85
|
||||
#define I_7 0x88
|
||||
#define I_8 0x89
|
||||
#define I_9 0x8A
|
||||
#define I_10 0x8B
|
||||
#define I_11 0x8C
|
||||
#define I_12 0x8D
|
||||
#define SW9_CS1 0x80
|
||||
#define SW9_CS2 0x81
|
||||
#define SW9_CS3 0x82
|
||||
#define SW9_CS4 0x83
|
||||
#define SW9_CS5 0x84
|
||||
#define SW9_CS6 0x85
|
||||
#define SW9_CS7 0x88
|
||||
#define SW9_CS8 0x89
|
||||
#define SW9_CS9 0x8A
|
||||
#define SW9_CS10 0x8B
|
||||
#define SW9_CS11 0x8C
|
||||
#define SW9_CS12 0x8D
|
||||
|
||||
#define J_1 0x90
|
||||
#define J_2 0x91
|
||||
#define J_3 0x92
|
||||
#define J_4 0x93
|
||||
#define J_5 0x94
|
||||
#define J_6 0x95
|
||||
#define J_7 0x98
|
||||
#define J_8 0x99
|
||||
#define J_9 0x9A
|
||||
#define J_10 0x9B
|
||||
#define J_11 0x9C
|
||||
#define J_12 0x9D
|
||||
#define SW10_CS1 0x90
|
||||
#define SW10_CS2 0x91
|
||||
#define SW10_CS3 0x92
|
||||
#define SW10_CS4 0x93
|
||||
#define SW10_CS5 0x94
|
||||
#define SW10_CS6 0x95
|
||||
#define SW10_CS7 0x98
|
||||
#define SW10_CS8 0x99
|
||||
#define SW10_CS9 0x9A
|
||||
#define SW10_CS10 0x9B
|
||||
#define SW10_CS11 0x9C
|
||||
#define SW10_CS12 0x9D
|
||||
|
||||
#define K_1 0xA0
|
||||
#define K_2 0xA1
|
||||
#define K_3 0xA2
|
||||
#define K_4 0xA3
|
||||
#define K_5 0xA4
|
||||
#define K_6 0xA5
|
||||
#define K_7 0xA8
|
||||
#define K_8 0xA9
|
||||
#define K_9 0xAA
|
||||
#define K_10 0xAB
|
||||
#define K_11 0xAC
|
||||
#define K_12 0xAD
|
||||
#define SW11_CS1 0xA0
|
||||
#define SW11_CS2 0xA1
|
||||
#define SW11_CS3 0xA2
|
||||
#define SW11_CS4 0xA3
|
||||
#define SW11_CS5 0xA4
|
||||
#define SW11_CS6 0xA5
|
||||
#define SW11_CS7 0xA8
|
||||
#define SW11_CS8 0xA9
|
||||
#define SW11_CS9 0xAA
|
||||
#define SW11_CS10 0xAB
|
||||
#define SW11_CS11 0xAC
|
||||
#define SW11_CS12 0xAD
|
||||
|
||||
#define L_1 0xB0
|
||||
#define L_2 0xB1
|
||||
#define L_3 0xB2
|
||||
#define L_4 0xB3
|
||||
#define L_5 0xB4
|
||||
#define L_6 0xB5
|
||||
#define L_7 0xB8
|
||||
#define L_8 0xB9
|
||||
#define L_9 0xBA
|
||||
#define L_10 0xBB
|
||||
#define L_11 0xBC
|
||||
#define L_12 0xBD
|
||||
#define SW12_CS1 0xB0
|
||||
#define SW12_CS2 0xB1
|
||||
#define SW12_CS3 0xB2
|
||||
#define SW12_CS4 0xB3
|
||||
#define SW12_CS5 0xB4
|
||||
#define SW12_CS6 0xB5
|
||||
#define SW12_CS7 0xB8
|
||||
#define SW12_CS8 0xB9
|
||||
#define SW12_CS9 0xBA
|
||||
#define SW12_CS10 0xBB
|
||||
#define SW12_CS11 0xBC
|
||||
#define SW12_CS12 0xBD
|
|
@ -1,249 +0,0 @@
|
|||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2021 Doni Crosby
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "is31fl3737-simple.h"
|
||||
#include <string.h>
|
||||
#include "i2c_master.h"
|
||||
#include "wait.h"
|
||||
|
||||
#define IS31FL3737_PWM_REGISTER_COUNT 192 // actually 144
|
||||
#define IS31FL3737_LED_CONTROL_REGISTER_COUNT 24
|
||||
|
||||
#ifndef IS31FL3737_I2C_TIMEOUT
|
||||
# define IS31FL3737_I2C_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3737_I2C_PERSISTENCE
|
||||
# define IS31FL3737_I2C_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3737_PWM_FREQUENCY
|
||||
# define IS31FL3737_PWM_FREQUENCY IS31FL3737_PWM_FREQUENCY_8K4_HZ // PFS - IS31FL3737B only
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3737_SW_PULLUP
|
||||
# define IS31FL3737_SW_PULLUP IS31FL3737_PUR_0_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3737_CS_PULLDOWN
|
||||
# define IS31FL3737_CS_PULLDOWN IS31FL3737_PDR_0_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3737_GLOBAL_CURRENT
|
||||
# define IS31FL3737_GLOBAL_CURRENT 0xFF
|
||||
#endif
|
||||
|
||||
// Transfer buffer for TWITransmitData()
|
||||
uint8_t g_twi_transfer_buffer[20];
|
||||
|
||||
// These buffers match the IS31FL3737 PWM registers.
|
||||
// The control buffers match the PG0 LED On/Off registers.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
// We could optimize this and take out the unused registers from these
|
||||
// buffers and the transfers in is31fl3737_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
|
||||
uint8_t g_pwm_buffer[IS31FL3737_DRIVER_COUNT][IS31FL3737_PWM_REGISTER_COUNT];
|
||||
bool g_pwm_buffer_update_required[IS31FL3737_DRIVER_COUNT] = {false};
|
||||
|
||||
uint8_t g_led_control_registers[IS31FL3737_DRIVER_COUNT][IS31FL3737_LED_CONTROL_REGISTER_COUNT] = {0};
|
||||
bool g_led_control_registers_update_required[IS31FL3737_DRIVER_COUNT] = {false};
|
||||
|
||||
void is31fl3737_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
|
||||
#if IS31FL3737_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3737_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3737_I2C_TIMEOUT) == 0) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3737_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3737_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
||||
// assumes PG1 is already selected
|
||||
|
||||
// transmit PWM registers in 12 transfers of 16 bytes
|
||||
// g_twi_transfer_buffer[] is 20 bytes
|
||||
|
||||
// iterate over the pwm_buffer contents at 16 byte intervals
|
||||
for (int i = 0; i < IS31FL3737_PWM_REGISTER_COUNT; i += 16) {
|
||||
g_twi_transfer_buffer[0] = i;
|
||||
// copy the data from i to i+15
|
||||
// device will auto-increment register for data after the first byte
|
||||
// thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer
|
||||
memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 16);
|
||||
|
||||
#if IS31FL3737_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3737_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3737_I2C_TIMEOUT) == 0) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3737_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3737_init_drivers(void) {
|
||||
i2c_init();
|
||||
|
||||
is31fl3737_init(IS31FL3737_I2C_ADDRESS_1);
|
||||
#if defined(IS31FL3737_I2C_ADDRESS_2)
|
||||
is31fl3737_init(IS31FL3737_I2C_ADDRESS_2);
|
||||
# if defined(IS31FL3737_I2C_ADDRESS_3)
|
||||
is31fl3737_init(IS31FL3737_I2C_ADDRESS_3);
|
||||
# if defined(IS31FL3737_I2C_ADDRESS_4)
|
||||
is31fl3737_init(IS31FL3737_I2C_ADDRESS_4);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < IS31FL3737_LED_COUNT; i++) {
|
||||
is31fl3737_set_led_control_register(i, true);
|
||||
}
|
||||
|
||||
is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3737_I2C_ADDRESS_2)
|
||||
is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3737_I2C_ADDRESS_3)
|
||||
is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3737_I2C_ADDRESS_4)
|
||||
is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3737_init(uint8_t addr) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND_WRITE_LOCK, IS31FL3737_COMMAND_WRITE_LOCK_MAGIC);
|
||||
|
||||
// Select PG0
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND, IS31FL3737_COMMAND_LED_CONTROL);
|
||||
// Turn off all LEDs.
|
||||
for (int i = 0; i < IS31FL3737_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3737_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND_WRITE_LOCK, IS31FL3737_COMMAND_WRITE_LOCK_MAGIC);
|
||||
|
||||
// Select PG1
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND, IS31FL3737_COMMAND_PWM);
|
||||
// Set PWM on all LEDs to 0
|
||||
// No need to setup Breath registers to PWM as that is the default.
|
||||
for (int i = 0; i < IS31FL3737_PWM_REGISTER_COUNT; i++) {
|
||||
is31fl3737_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND_WRITE_LOCK, IS31FL3737_COMMAND_WRITE_LOCK_MAGIC);
|
||||
|
||||
// Select PG3
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND, IS31FL3737_COMMAND_FUNCTION);
|
||||
// Set de-ghost pull-up resistors (SWx)
|
||||
is31fl3737_write_register(addr, IS31FL3737_FUNCTION_REG_SW_PULLUP, IS31FL3737_SW_PULLUP);
|
||||
// Set de-ghost pull-down resistors (CSx)
|
||||
is31fl3737_write_register(addr, IS31FL3737_FUNCTION_REG_CS_PULLDOWN, IS31FL3737_CS_PULLDOWN);
|
||||
// Set global current to maximum.
|
||||
is31fl3737_write_register(addr, IS31FL3737_FUNCTION_REG_GLOBAL_CURRENT, IS31FL3737_GLOBAL_CURRENT);
|
||||
// Disable software shutdown.
|
||||
is31fl3737_write_register(addr, IS31FL3737_FUNCTION_REG_CONFIGURATION, ((IS31FL3737_PWM_FREQUENCY & 0b111) << 3) | 0x01);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
wait_ms(10);
|
||||
}
|
||||
|
||||
void is31fl3737_set_value(int index, uint8_t value) {
|
||||
is31fl3737_led_t led;
|
||||
if (index >= 0 && index < IS31FL3737_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3737_leds[index]), sizeof(led));
|
||||
|
||||
if (g_pwm_buffer[led.driver][led.v] == value) {
|
||||
return;
|
||||
}
|
||||
g_pwm_buffer[led.driver][led.v] = value;
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3737_set_value_all(uint8_t value) {
|
||||
for (int i = 0; i < IS31FL3737_LED_COUNT; i++) {
|
||||
is31fl3737_set_value(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3737_set_led_control_register(uint8_t index, bool value) {
|
||||
is31fl3737_led_t led;
|
||||
memcpy_P(&led, (&g_is31fl3737_leds[index]), sizeof(led));
|
||||
|
||||
uint8_t control_register = led.v / 8;
|
||||
uint8_t bit_value = led.v % 8;
|
||||
|
||||
if (value) {
|
||||
g_led_control_registers[led.driver][control_register] |= (1 << bit_value);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register] &= ~(1 << bit_value);
|
||||
}
|
||||
|
||||
g_led_control_registers_update_required[led.driver] = true;
|
||||
}
|
||||
|
||||
void is31fl3737_update_pwm_buffers(uint8_t addr, uint8_t index) {
|
||||
if (g_pwm_buffer_update_required[index]) {
|
||||
// Firstly we need to unlock the command register and select PG1
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND_WRITE_LOCK, IS31FL3737_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND, IS31FL3737_COMMAND_PWM);
|
||||
|
||||
is31fl3737_write_pwm_buffer(addr, g_pwm_buffer[index]);
|
||||
g_pwm_buffer_update_required[index] = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3737_update_led_control_registers(uint8_t addr, uint8_t index) {
|
||||
if (g_led_control_registers_update_required[index]) {
|
||||
// Firstly we need to unlock the command register and select PG0
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND_WRITE_LOCK, IS31FL3737_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND, IS31FL3737_COMMAND_LED_CONTROL);
|
||||
for (int i = 0; i < IS31FL3737_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3737_write_register(addr, i, g_led_control_registers[index][i]);
|
||||
}
|
||||
g_led_control_registers_update_required[index] = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3737_flush(void) {
|
||||
is31fl3737_update_pwm_buffers(IS31FL3737_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3737_I2C_ADDRESS_2)
|
||||
is31fl3737_update_pwm_buffers(IS31FL3737_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3737_I2C_ADDRESS_3)
|
||||
is31fl3737_update_pwm_buffers(IS31FL3737_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3737_I2C_ADDRESS_4)
|
||||
is31fl3737_update_pwm_buffers(IS31FL3737_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
}
|
|
@ -18,8 +18,8 @@
|
|||
*/
|
||||
|
||||
#include "is31fl3737.h"
|
||||
#include <string.h>
|
||||
#include "i2c_master.h"
|
||||
#include "gpio.h"
|
||||
#include "wait.h"
|
||||
|
||||
#define IS31FL3737_PWM_REGISTER_COUNT 192 // actually 144
|
||||
|
@ -41,7 +41,7 @@
|
|||
# define IS31FL3737_SW_PULLUP IS31FL3737_PUR_0_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3737_CS_PULLDONW
|
||||
#ifndef IS31FL3737_CS_PULLDOWN
|
||||
# define IS31FL3737_CS_PULLDOWN IS31FL3737_PDR_0_OHM
|
||||
#endif
|
||||
|
||||
|
@ -49,55 +49,66 @@
|
|||
# define IS31FL3737_GLOBAL_CURRENT 0xFF
|
||||
#endif
|
||||
|
||||
// Transfer buffer for TWITransmitData()
|
||||
uint8_t g_twi_transfer_buffer[20];
|
||||
const uint8_t i2c_addresses[IS31FL3737_DRIVER_COUNT] = {
|
||||
IS31FL3737_I2C_ADDRESS_1,
|
||||
#ifdef IS31FL3737_I2C_ADDRESS_2
|
||||
IS31FL3737_I2C_ADDRESS_2,
|
||||
# ifdef IS31FL3737_I2C_ADDRESS_3
|
||||
IS31FL3737_I2C_ADDRESS_3,
|
||||
# ifdef IS31FL3737_I2C_ADDRESS_4
|
||||
IS31FL3737_I2C_ADDRESS_4,
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
// These buffers match the IS31FL3737 PWM registers.
|
||||
// The control buffers match the PG0 LED On/Off registers.
|
||||
// The control buffers match the page 0 LED On/Off registers.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
// We could optimize this and take out the unused registers from these
|
||||
// buffers and the transfers in is31fl3737_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
typedef struct is31fl3737_driver_t {
|
||||
uint8_t pwm_buffer[IS31FL3737_PWM_REGISTER_COUNT];
|
||||
bool pwm_buffer_dirty;
|
||||
uint8_t led_control_buffer[IS31FL3737_LED_CONTROL_REGISTER_COUNT];
|
||||
bool led_control_buffer_dirty;
|
||||
} PACKED is31fl3737_driver_t;
|
||||
|
||||
uint8_t g_pwm_buffer[IS31FL3737_DRIVER_COUNT][IS31FL3737_PWM_REGISTER_COUNT];
|
||||
bool g_pwm_buffer_update_required[IS31FL3737_DRIVER_COUNT] = {false};
|
||||
|
||||
uint8_t g_led_control_registers[IS31FL3737_DRIVER_COUNT][IS31FL3737_LED_CONTROL_REGISTER_COUNT] = {0};
|
||||
bool g_led_control_registers_update_required[IS31FL3737_DRIVER_COUNT] = {false};
|
||||
|
||||
void is31fl3737_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
is31fl3737_driver_t driver_buffers[IS31FL3737_DRIVER_COUNT] = {{
|
||||
.pwm_buffer = {0},
|
||||
.pwm_buffer_dirty = false,
|
||||
.led_control_buffer = {0},
|
||||
.led_control_buffer_dirty = false,
|
||||
}};
|
||||
|
||||
void is31fl3737_write_register(uint8_t index, uint8_t reg, uint8_t data) {
|
||||
#if IS31FL3737_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3737_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3737_I2C_TIMEOUT) == 0) break;
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3737_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3737_I2C_TIMEOUT);
|
||||
i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3737_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3737_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
||||
// assumes PG1 is already selected
|
||||
void is31fl3737_select_page(uint8_t index, uint8_t page) {
|
||||
is31fl3737_write_register(index, IS31FL3737_REG_COMMAND_WRITE_LOCK, IS31FL3737_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3737_write_register(index, IS31FL3737_REG_COMMAND, page);
|
||||
}
|
||||
|
||||
// transmit PWM registers in 12 transfers of 16 bytes
|
||||
// g_twi_transfer_buffer[] is 20 bytes
|
||||
|
||||
// iterate over the pwm_buffer contents at 16 byte intervals
|
||||
for (int i = 0; i < IS31FL3737_PWM_REGISTER_COUNT; i += 16) {
|
||||
g_twi_transfer_buffer[0] = i;
|
||||
// copy the data from i to i+15
|
||||
// device will auto-increment register for data after the first byte
|
||||
// thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer
|
||||
memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 16);
|
||||
void is31fl3737_write_pwm_buffer(uint8_t index) {
|
||||
// Assumes page 1 is already selected.
|
||||
// Transmit PWM registers in 12 transfers of 16 bytes.
|
||||
|
||||
// Iterate over the pwm_buffer contents at 16 byte intervals.
|
||||
for (uint8_t i = 0; i < IS31FL3737_PWM_REGISTER_COUNT; i += 16) {
|
||||
#if IS31FL3737_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3737_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3737_I2C_TIMEOUT) == 0) break;
|
||||
for (uint8_t j = 0; j < IS31FL3737_I2C_PERSISTENCE; j++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer + i, 16, IS31FL3737_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3737_I2C_TIMEOUT);
|
||||
i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer + i, 16, IS31FL3737_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -105,73 +116,55 @@ void is31fl3737_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
|||
void is31fl3737_init_drivers(void) {
|
||||
i2c_init();
|
||||
|
||||
is31fl3737_init(IS31FL3737_I2C_ADDRESS_1);
|
||||
#if defined(IS31FL3737_I2C_ADDRESS_2)
|
||||
is31fl3737_init(IS31FL3737_I2C_ADDRESS_2);
|
||||
# if defined(IS31FL3737_I2C_ADDRESS_3)
|
||||
is31fl3737_init(IS31FL3737_I2C_ADDRESS_3);
|
||||
# if defined(IS31FL3737_I2C_ADDRESS_4)
|
||||
is31fl3737_init(IS31FL3737_I2C_ADDRESS_4);
|
||||
# endif
|
||||
# endif
|
||||
#if defined(IS31FL3737_SDB_PIN)
|
||||
gpio_set_pin_output(IS31FL3737_SDB_PIN);
|
||||
gpio_write_pin_high(IS31FL3737_SDB_PIN);
|
||||
#endif
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3737_DRIVER_COUNT; i++) {
|
||||
is31fl3737_init(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < IS31FL3737_LED_COUNT; i++) {
|
||||
is31fl3737_set_led_control_register(i, true, true, true);
|
||||
}
|
||||
|
||||
is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3737_I2C_ADDRESS_2)
|
||||
is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3737_I2C_ADDRESS_3)
|
||||
is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3737_I2C_ADDRESS_4)
|
||||
is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
for (uint8_t i = 0; i < IS31FL3737_DRIVER_COUNT; i++) {
|
||||
is31fl3737_update_led_control_registers(i);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3737_init(uint8_t addr) {
|
||||
void is31fl3737_init(uint8_t index) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND_WRITE_LOCK, IS31FL3737_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3737_select_page(index, IS31FL3737_COMMAND_LED_CONTROL);
|
||||
|
||||
// Select PG0
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND, IS31FL3737_COMMAND_LED_CONTROL);
|
||||
// Turn off all LEDs.
|
||||
for (int i = 0; i < IS31FL3737_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3737_write_register(addr, i, 0x00);
|
||||
for (uint8_t i = 0; i < IS31FL3737_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3737_write_register(index, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND_WRITE_LOCK, IS31FL3737_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3737_select_page(index, IS31FL3737_COMMAND_PWM);
|
||||
|
||||
// Select PG1
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND, IS31FL3737_COMMAND_PWM);
|
||||
// Set PWM on all LEDs to 0
|
||||
// No need to setup Breath registers to PWM as that is the default.
|
||||
for (int i = 0; i < IS31FL3737_PWM_REGISTER_COUNT; i++) {
|
||||
is31fl3737_write_register(addr, i, 0x00);
|
||||
for (uint8_t i = 0; i < IS31FL3737_PWM_REGISTER_COUNT; i++) {
|
||||
is31fl3737_write_register(index, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND_WRITE_LOCK, IS31FL3737_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3737_select_page(index, IS31FL3737_COMMAND_FUNCTION);
|
||||
|
||||
// Select PG3
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND, IS31FL3737_COMMAND_FUNCTION);
|
||||
// Set de-ghost pull-up resistors (SWx)
|
||||
is31fl3737_write_register(addr, IS31FL3737_FUNCTION_REG_SW_PULLUP, IS31FL3737_SW_PULLUP);
|
||||
is31fl3737_write_register(index, IS31FL3737_FUNCTION_REG_SW_PULLUP, IS31FL3737_SW_PULLUP);
|
||||
// Set de-ghost pull-down resistors (CSx)
|
||||
is31fl3737_write_register(addr, IS31FL3737_FUNCTION_REG_CS_PULLDOWN, IS31FL3737_CS_PULLDOWN);
|
||||
is31fl3737_write_register(index, IS31FL3737_FUNCTION_REG_CS_PULLDOWN, IS31FL3737_CS_PULLDOWN);
|
||||
// Set global current to maximum.
|
||||
is31fl3737_write_register(addr, IS31FL3737_FUNCTION_REG_GLOBAL_CURRENT, IS31FL3737_GLOBAL_CURRENT);
|
||||
is31fl3737_write_register(index, IS31FL3737_FUNCTION_REG_GLOBAL_CURRENT, IS31FL3737_GLOBAL_CURRENT);
|
||||
// Disable software shutdown.
|
||||
is31fl3737_write_register(addr, IS31FL3737_FUNCTION_REG_CONFIGURATION, ((IS31FL3737_PWM_FREQUENCY & 0b111) << 3) | 0x01);
|
||||
is31fl3737_write_register(index, IS31FL3737_FUNCTION_REG_CONFIGURATION, ((IS31FL3737_PWM_FREQUENCY & 0b111) << 3) | 0x01);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
wait_ms(10);
|
||||
|
@ -179,16 +172,18 @@ void is31fl3737_init(uint8_t addr) {
|
|||
|
||||
void is31fl3737_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
is31fl3737_led_t led;
|
||||
|
||||
if (index >= 0 && index < IS31FL3737_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3737_leds[index]), sizeof(led));
|
||||
|
||||
if (g_pwm_buffer[led.driver][led.r] == red && g_pwm_buffer[led.driver][led.g] == green && g_pwm_buffer[led.driver][led.b] == blue) {
|
||||
if (driver_buffers[led.driver].pwm_buffer[led.r] == red && driver_buffers[led.driver].pwm_buffer[led.g] == green && driver_buffers[led.driver].pwm_buffer[led.b] == blue) {
|
||||
return;
|
||||
}
|
||||
g_pwm_buffer[led.driver][led.r] = red;
|
||||
g_pwm_buffer[led.driver][led.g] = green;
|
||||
g_pwm_buffer[led.driver][led.b] = blue;
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
|
||||
driver_buffers[led.driver].pwm_buffer[led.r] = red;
|
||||
driver_buffers[led.driver].pwm_buffer[led.g] = green;
|
||||
driver_buffers[led.driver].pwm_buffer[led.b] = blue;
|
||||
driver_buffers[led.driver].pwm_buffer_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,56 +205,48 @@ void is31fl3737_set_led_control_register(uint8_t index, bool red, bool green, bo
|
|||
uint8_t bit_b = led.b % 8;
|
||||
|
||||
if (red) {
|
||||
g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_r] |= (1 << bit_r);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_r] &= ~(1 << bit_r);
|
||||
}
|
||||
if (green) {
|
||||
g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_g] |= (1 << bit_g);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_g] &= ~(1 << bit_g);
|
||||
}
|
||||
if (blue) {
|
||||
g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_b] |= (1 << bit_b);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b);
|
||||
driver_buffers[led.driver].led_control_buffer[control_register_b] &= ~(1 << bit_b);
|
||||
}
|
||||
|
||||
g_led_control_registers_update_required[led.driver] = true;
|
||||
driver_buffers[led.driver].led_control_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3737_update_pwm_buffers(uint8_t addr, uint8_t index) {
|
||||
if (g_pwm_buffer_update_required[index]) {
|
||||
// Firstly we need to unlock the command register and select PG1
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND_WRITE_LOCK, IS31FL3737_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND, IS31FL3737_COMMAND_PWM);
|
||||
void is31fl3737_update_pwm_buffers(uint8_t index) {
|
||||
if (driver_buffers[index].pwm_buffer_dirty) {
|
||||
is31fl3737_select_page(index, IS31FL3737_COMMAND_PWM);
|
||||
|
||||
is31fl3737_write_pwm_buffer(addr, g_pwm_buffer[index]);
|
||||
g_pwm_buffer_update_required[index] = false;
|
||||
is31fl3737_write_pwm_buffer(index);
|
||||
|
||||
driver_buffers[index].pwm_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3737_update_led_control_registers(uint8_t addr, uint8_t index) {
|
||||
if (g_led_control_registers_update_required[index]) {
|
||||
// Firstly we need to unlock the command register and select PG0
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND_WRITE_LOCK, IS31FL3737_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3737_write_register(addr, IS31FL3737_REG_COMMAND, IS31FL3737_COMMAND_LED_CONTROL);
|
||||
for (int i = 0; i < IS31FL3737_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3737_write_register(addr, i, g_led_control_registers[index][i]);
|
||||
void is31fl3737_update_led_control_registers(uint8_t index) {
|
||||
if (driver_buffers[index].led_control_buffer_dirty) {
|
||||
is31fl3737_select_page(index, IS31FL3737_COMMAND_LED_CONTROL);
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3737_LED_CONTROL_REGISTER_COUNT; i++) {
|
||||
is31fl3737_write_register(index, i, driver_buffers[index].led_control_buffer[i]);
|
||||
}
|
||||
g_led_control_registers_update_required[index] = false;
|
||||
|
||||
driver_buffers[index].led_control_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3737_flush(void) {
|
||||
is31fl3737_update_pwm_buffers(IS31FL3737_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3737_I2C_ADDRESS_2)
|
||||
is31fl3737_update_pwm_buffers(IS31FL3737_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3737_I2C_ADDRESS_3)
|
||||
is31fl3737_update_pwm_buffers(IS31FL3737_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3737_I2C_ADDRESS_4)
|
||||
is31fl3737_update_pwm_buffers(IS31FL3737_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
for (uint8_t i = 0; i < IS31FL3737_DRIVER_COUNT; i++) {
|
||||
is31fl3737_update_pwm_buffers(i);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,9 +117,9 @@ typedef struct is31fl3737_led_t {
|
|||
extern const is31fl3737_led_t PROGMEM g_is31fl3737_leds[IS31FL3737_LED_COUNT];
|
||||
|
||||
void is31fl3737_init_drivers(void);
|
||||
void is31fl3737_init(uint8_t addr);
|
||||
void is31fl3737_write_register(uint8_t addr, uint8_t reg, uint8_t data);
|
||||
void is31fl3737_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
|
||||
void is31fl3737_init(uint8_t index);
|
||||
void is31fl3737_write_register(uint8_t index, uint8_t reg, uint8_t data);
|
||||
void is31fl3737_select_page(uint8_t index, uint8_t page);
|
||||
|
||||
void is31fl3737_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
|
||||
void is31fl3737_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
@ -130,8 +130,8 @@ void is31fl3737_set_led_control_register(uint8_t index, bool red, bool green, bo
|
|||
// (eg. from a timer interrupt).
|
||||
// Call this while idle (in between matrix scans).
|
||||
// If the buffer is dirty, it will update the driver with the buffer.
|
||||
void is31fl3737_update_pwm_buffers(uint8_t addr, uint8_t index);
|
||||
void is31fl3737_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
void is31fl3737_update_pwm_buffers(uint8_t index);
|
||||
void is31fl3737_update_led_control_registers(uint8_t index);
|
||||
|
||||
void is31fl3737_flush(void);
|
||||
|
||||
|
@ -159,158 +159,316 @@ void is31fl3737_flush(void);
|
|||
#define IS31FL3737_PWM_FREQUENCY_2K1_HZ 0b011
|
||||
#define IS31FL3737_PWM_FREQUENCY_1K05_HZ 0b100
|
||||
|
||||
#define A_1 0x00
|
||||
#define A_2 0x01
|
||||
#define A_3 0x02
|
||||
#define A_4 0x03
|
||||
#define A_5 0x04
|
||||
#define A_6 0x05
|
||||
#define A_7 0x08
|
||||
#define A_8 0x09
|
||||
#define A_9 0x0A
|
||||
#define A_10 0x0B
|
||||
#define A_11 0x0C
|
||||
#define A_12 0x0D
|
||||
#define SW1_CS1 0x00
|
||||
#define SW1_CS2 0x01
|
||||
#define SW1_CS3 0x02
|
||||
#define SW1_CS4 0x03
|
||||
#define SW1_CS5 0x04
|
||||
#define SW1_CS6 0x05
|
||||
#define SW1_CS7 0x08
|
||||
#define SW1_CS8 0x09
|
||||
#define SW1_CS9 0x0A
|
||||
#define SW1_CS10 0x0B
|
||||
#define SW1_CS11 0x0C
|
||||
#define SW1_CS12 0x0D
|
||||
|
||||
#define B_1 0x10
|
||||
#define B_2 0x11
|
||||
#define B_3 0x12
|
||||
#define B_4 0x13
|
||||
#define B_5 0x14
|
||||
#define B_6 0x15
|
||||
#define B_7 0x18
|
||||
#define B_8 0x19
|
||||
#define B_9 0x1A
|
||||
#define B_10 0x1B
|
||||
#define B_11 0x1C
|
||||
#define B_12 0x1D
|
||||
#define SW2_CS1 0x10
|
||||
#define SW2_CS2 0x11
|
||||
#define SW2_CS3 0x12
|
||||
#define SW2_CS4 0x13
|
||||
#define SW2_CS5 0x14
|
||||
#define SW2_CS6 0x15
|
||||
#define SW2_CS7 0x18
|
||||
#define SW2_CS8 0x19
|
||||
#define SW2_CS9 0x1A
|
||||
#define SW2_CS10 0x1B
|
||||
#define SW2_CS11 0x1C
|
||||
#define SW2_CS12 0x1D
|
||||
|
||||
#define C_1 0x20
|
||||
#define C_2 0x21
|
||||
#define C_3 0x22
|
||||
#define C_4 0x23
|
||||
#define C_5 0x24
|
||||
#define C_6 0x25
|
||||
#define C_7 0x28
|
||||
#define C_8 0x29
|
||||
#define C_9 0x2A
|
||||
#define C_10 0x2B
|
||||
#define C_11 0x2C
|
||||
#define C_12 0x2D
|
||||
#define SW3_CS1 0x20
|
||||
#define SW3_CS2 0x21
|
||||
#define SW3_CS3 0x22
|
||||
#define SW3_CS4 0x23
|
||||
#define SW3_CS5 0x24
|
||||
#define SW3_CS6 0x25
|
||||
#define SW3_CS7 0x28
|
||||
#define SW3_CS8 0x29
|
||||
#define SW3_CS9 0x2A
|
||||
#define SW3_CS10 0x2B
|
||||
#define SW3_CS11 0x2C
|
||||
#define SW3_CS12 0x2D
|
||||
|
||||
#define D_1 0x30
|
||||
#define D_2 0x31
|
||||
#define D_3 0x32
|
||||
#define D_4 0x33
|
||||
#define D_5 0x34
|
||||
#define D_6 0x35
|
||||
#define D_7 0x38
|
||||
#define D_8 0x39
|
||||
#define D_9 0x3A
|
||||
#define D_10 0x3B
|
||||
#define D_11 0x3C
|
||||
#define D_12 0x3D
|
||||
#define SW4_CS1 0x30
|
||||
#define SW4_CS2 0x31
|
||||
#define SW4_CS3 0x32
|
||||
#define SW4_CS4 0x33
|
||||
#define SW4_CS5 0x34
|
||||
#define SW4_CS6 0x35
|
||||
#define SW4_CS7 0x38
|
||||
#define SW4_CS8 0x39
|
||||
#define SW4_CS9 0x3A
|
||||
#define SW4_CS10 0x3B
|
||||
#define SW4_CS11 0x3C
|
||||
#define SW4_CS12 0x3D
|
||||
|
||||
#define E_1 0x40
|
||||
#define E_2 0x41
|
||||
#define E_3 0x42
|
||||
#define E_4 0x43
|
||||
#define E_5 0x44
|
||||
#define E_6 0x45
|
||||
#define E_7 0x48
|
||||
#define E_8 0x49
|
||||
#define E_9 0x4A
|
||||
#define E_10 0x4B
|
||||
#define E_11 0x4C
|
||||
#define E_12 0x4D
|
||||
#define SW5_CS1 0x40
|
||||
#define SW5_CS2 0x41
|
||||
#define SW5_CS3 0x42
|
||||
#define SW5_CS4 0x43
|
||||
#define SW5_CS5 0x44
|
||||
#define SW5_CS6 0x45
|
||||
#define SW5_CS7 0x48
|
||||
#define SW5_CS8 0x49
|
||||
#define SW5_CS9 0x4A
|
||||
#define SW5_CS10 0x4B
|
||||
#define SW5_CS11 0x4C
|
||||
#define SW5_CS12 0x4D
|
||||
|
||||
#define F_1 0x50
|
||||
#define F_2 0x51
|
||||
#define F_3 0x52
|
||||
#define F_4 0x53
|
||||
#define F_5 0x54
|
||||
#define F_6 0x55
|
||||
#define F_7 0x58
|
||||
#define F_8 0x59
|
||||
#define F_9 0x5A
|
||||
#define F_10 0x5B
|
||||
#define F_11 0x5C
|
||||
#define F_12 0x5D
|
||||
#define SW6_CS1 0x50
|
||||
#define SW6_CS2 0x51
|
||||
#define SW6_CS3 0x52
|
||||
#define SW6_CS4 0x53
|
||||
#define SW6_CS5 0x54
|
||||
#define SW6_CS6 0x55
|
||||
#define SW6_CS7 0x58
|
||||
#define SW6_CS8 0x59
|
||||
#define SW6_CS9 0x5A
|
||||
#define SW6_CS10 0x5B
|
||||
#define SW6_CS11 0x5C
|
||||
#define SW6_CS12 0x5D
|
||||
|
||||
#define G_1 0x60
|
||||
#define G_2 0x61
|
||||
#define G_3 0x62
|
||||
#define G_4 0x63
|
||||
#define G_5 0x64
|
||||
#define G_6 0x65
|
||||
#define G_7 0x68
|
||||
#define G_8 0x69
|
||||
#define G_9 0x6A
|
||||
#define G_10 0x6B
|
||||
#define G_11 0x6C
|
||||
#define G_12 0x6D
|
||||
#define SW7_CS1 0x60
|
||||
#define SW7_CS2 0x61
|
||||
#define SW7_CS3 0x62
|
||||
#define SW7_CS4 0x63
|
||||
#define SW7_CS5 0x64
|
||||
#define SW7_CS6 0x65
|
||||
#define SW7_CS7 0x68
|
||||
#define SW7_CS8 0x69
|
||||
#define SW7_CS9 0x6A
|
||||
#define SW7_CS10 0x6B
|
||||
#define SW7_CS11 0x6C
|
||||
#define SW7_CS12 0x6D
|
||||
|
||||
#define H_1 0x70
|
||||
#define H_2 0x71
|
||||
#define H_3 0x72
|
||||
#define H_4 0x73
|
||||
#define H_5 0x74
|
||||
#define H_6 0x75
|
||||
#define H_7 0x78
|
||||
#define H_8 0x79
|
||||
#define H_9 0x7A
|
||||
#define H_10 0x7B
|
||||
#define H_11 0x7C
|
||||
#define H_12 0x7D
|
||||
#define SW8_CS1 0x70
|
||||
#define SW8_CS2 0x71
|
||||
#define SW8_CS3 0x72
|
||||
#define SW8_CS4 0x73
|
||||
#define SW8_CS5 0x74
|
||||
#define SW8_CS6 0x75
|
||||
#define SW8_CS7 0x78
|
||||
#define SW8_CS8 0x79
|
||||
#define SW8_CS9 0x7A
|
||||
#define SW8_CS10 0x7B
|
||||
#define SW8_CS11 0x7C
|
||||
#define SW8_CS12 0x7D
|
||||
|
||||
#define I_1 0x80
|
||||
#define I_2 0x81
|
||||
#define I_3 0x82
|
||||
#define I_4 0x83
|
||||
#define I_5 0x84
|
||||
#define I_6 0x85
|
||||
#define I_7 0x88
|
||||
#define I_8 0x89
|
||||
#define I_9 0x8A
|
||||
#define I_10 0x8B
|
||||
#define I_11 0x8C
|
||||
#define I_12 0x8D
|
||||
#define SW9_CS1 0x80
|
||||
#define SW9_CS2 0x81
|
||||
#define SW9_CS3 0x82
|
||||
#define SW9_CS4 0x83
|
||||
#define SW9_CS5 0x84
|
||||
#define SW9_CS6 0x85
|
||||
#define SW9_CS7 0x88
|
||||
#define SW9_CS8 0x89
|
||||
#define SW9_CS9 0x8A
|
||||
#define SW9_CS10 0x8B
|
||||
#define SW9_CS11 0x8C
|
||||
#define SW9_CS12 0x8D
|
||||
|
||||
#define J_1 0x90
|
||||
#define J_2 0x91
|
||||
#define J_3 0x92
|
||||
#define J_4 0x93
|
||||
#define J_5 0x94
|
||||
#define J_6 0x95
|
||||
#define J_7 0x98
|
||||
#define J_8 0x99
|
||||
#define J_9 0x9A
|
||||
#define J_10 0x9B
|
||||
#define J_11 0x9C
|
||||
#define J_12 0x9D
|
||||
#define SW10_CS1 0x90
|
||||
#define SW10_CS2 0x91
|
||||
#define SW10_CS3 0x92
|
||||
#define SW10_CS4 0x93
|
||||
#define SW10_CS5 0x94
|
||||
#define SW10_CS6 0x95
|
||||
#define SW10_CS7 0x98
|
||||
#define SW10_CS8 0x99
|
||||
#define SW10_CS9 0x9A
|
||||
#define SW10_CS10 0x9B
|
||||
#define SW10_CS11 0x9C
|
||||
#define SW10_CS12 0x9D
|
||||
|
||||
#define K_1 0xA0
|
||||
#define K_2 0xA1
|
||||
#define K_3 0xA2
|
||||
#define K_4 0xA3
|
||||
#define K_5 0xA4
|
||||
#define K_6 0xA5
|
||||
#define K_7 0xA8
|
||||
#define K_8 0xA9
|
||||
#define K_9 0xAA
|
||||
#define K_10 0xAB
|
||||
#define K_11 0xAC
|
||||
#define K_12 0xAD
|
||||
#define SW11_CS1 0xA0
|
||||
#define SW11_CS2 0xA1
|
||||
#define SW11_CS3 0xA2
|
||||
#define SW11_CS4 0xA3
|
||||
#define SW11_CS5 0xA4
|
||||
#define SW11_CS6 0xA5
|
||||
#define SW11_CS7 0xA8
|
||||
#define SW11_CS8 0xA9
|
||||
#define SW11_CS9 0xAA
|
||||
#define SW11_CS10 0xAB
|
||||
#define SW11_CS11 0xAC
|
||||
#define SW11_CS12 0xAD
|
||||
|
||||
#define L_1 0xB0
|
||||
#define L_2 0xB1
|
||||
#define L_3 0xB2
|
||||
#define L_4 0xB3
|
||||
#define L_5 0xB4
|
||||
#define L_6 0xB5
|
||||
#define L_7 0xB8
|
||||
#define L_8 0xB9
|
||||
#define L_9 0xBA
|
||||
#define L_10 0xBB
|
||||
#define L_11 0xBC
|
||||
#define L_12 0xBD
|
||||
#define SW12_CS1 0xB0
|
||||
#define SW12_CS2 0xB1
|
||||
#define SW12_CS3 0xB2
|
||||
#define SW12_CS4 0xB3
|
||||
#define SW12_CS5 0xB4
|
||||
#define SW12_CS6 0xB5
|
||||
#define SW12_CS7 0xB8
|
||||
#define SW12_CS8 0xB9
|
||||
#define SW12_CS9 0xBA
|
||||
#define SW12_CS10 0xBB
|
||||
#define SW12_CS11 0xBC
|
||||
#define SW12_CS12 0xBD
|
||||
|
||||
// DEPRECATED - DO NOT USE
|
||||
|
||||
#define A_1 SW1_CS1
|
||||
#define A_2 SW1_CS2
|
||||
#define A_3 SW1_CS3
|
||||
#define A_4 SW1_CS4
|
||||
#define A_5 SW1_CS5
|
||||
#define A_6 SW1_CS6
|
||||
#define A_7 SW1_CS7
|
||||
#define A_8 SW1_CS8
|
||||
#define A_9 SW1_CS9
|
||||
#define A_10 SW1_CS10
|
||||
#define A_11 SW1_CS11
|
||||
#define A_12 SW1_CS12
|
||||
|
||||
#define B_1 SW2_CS1
|
||||
#define B_2 SW2_CS2
|
||||
#define B_3 SW2_CS3
|
||||
#define B_4 SW2_CS4
|
||||
#define B_5 SW2_CS5
|
||||
#define B_6 SW2_CS6
|
||||
#define B_7 SW2_CS7
|
||||
#define B_8 SW2_CS8
|
||||
#define B_9 SW2_CS9
|
||||
#define B_10 SW2_CS10
|
||||
#define B_11 SW2_CS11
|
||||
#define B_12 SW2_CS12
|
||||
|
||||
#define C_1 SW3_CS1
|
||||
#define C_2 SW3_CS2
|
||||
#define C_3 SW3_CS3
|
||||
#define C_4 SW3_CS4
|
||||
#define C_5 SW3_CS5
|
||||
#define C_6 SW3_CS6
|
||||
#define C_7 SW3_CS7
|
||||
#define C_8 SW3_CS8
|
||||
#define C_9 SW3_CS9
|
||||
#define C_10 SW3_CS10
|
||||
#define C_11 SW3_CS11
|
||||
#define C_12 SW3_CS12
|
||||
|
||||
#define D_1 SW4_CS1
|
||||
#define D_2 SW4_CS2
|
||||
#define D_3 SW4_CS3
|
||||
#define D_4 SW4_CS4
|
||||
#define D_5 SW4_CS5
|
||||
#define D_6 SW4_CS6
|
||||
#define D_7 SW4_CS7
|
||||
#define D_8 SW4_CS8
|
||||
#define D_9 SW4_CS9
|
||||
#define D_10 SW4_CS10
|
||||
#define D_11 SW4_CS11
|
||||
#define D_12 SW4_CS12
|
||||
|
||||
#define E_1 SW5_CS1
|
||||
#define E_2 SW5_CS2
|
||||
#define E_3 SW5_CS3
|
||||
#define E_4 SW5_CS4
|
||||
#define E_5 SW5_CS5
|
||||
#define E_6 SW5_CS6
|
||||
#define E_7 SW5_CS7
|
||||
#define E_8 SW5_CS8
|
||||
#define E_9 SW5_CS9
|
||||
#define E_10 SW5_CS10
|
||||
#define E_11 SW5_CS11
|
||||
#define E_12 SW5_CS12
|
||||
|
||||
#define F_1 SW6_CS1
|
||||
#define F_2 SW6_CS2
|
||||
#define F_3 SW6_CS3
|
||||
#define F_4 SW6_CS4
|
||||
#define F_5 SW6_CS5
|
||||
#define F_6 SW6_CS6
|
||||
#define F_7 SW6_CS7
|
||||
#define F_8 SW6_CS8
|
||||
#define F_9 SW6_CS9
|
||||
#define F_10 SW6_CS10
|
||||
#define F_11 SW6_CS11
|
||||
#define F_12 SW6_CS12
|
||||
|
||||
#define G_1 SW7_CS1
|
||||
#define G_2 SW7_CS2
|
||||
#define G_3 SW7_CS3
|
||||
#define G_4 SW7_CS4
|
||||
#define G_5 SW7_CS5
|
||||
#define G_6 SW7_CS6
|
||||
#define G_7 SW7_CS7
|
||||
#define G_8 SW7_CS8
|
||||
#define G_9 SW7_CS9
|
||||
#define G_10 SW7_CS10
|
||||
#define G_11 SW7_CS11
|
||||
#define G_12 SW7_CS12
|
||||
|
||||
#define H_1 SW8_CS1
|
||||
#define H_2 SW8_CS2
|
||||
#define H_3 SW8_CS3
|
||||
#define H_4 SW8_CS4
|
||||
#define H_5 SW8_CS5
|
||||
#define H_6 SW8_CS6
|
||||
#define H_7 SW8_CS7
|
||||
#define H_8 SW8_CS8
|
||||
#define H_9 SW8_CS9
|
||||
#define H_10 SW8_CS10
|
||||
#define H_11 SW8_CS11
|
||||
#define H_12 SW8_CS12
|
||||
|
||||
#define I_1 SW9_CS1
|
||||
#define I_2 SW9_CS2
|
||||
#define I_3 SW9_CS3
|
||||
#define I_4 SW9_CS4
|
||||
#define I_5 SW9_CS5
|
||||
#define I_6 SW9_CS6
|
||||
#define I_7 SW9_CS7
|
||||
#define I_8 SW9_CS8
|
||||
#define I_9 SW9_CS9
|
||||
#define I_10 SW9_CS10
|
||||
#define I_11 SW9_CS11
|
||||
#define I_12 SW9_CS12
|
||||
|
||||
#define J_1 SW10_CS1
|
||||
#define J_2 SW10_CS2
|
||||
#define J_3 SW10_CS3
|
||||
#define J_4 SW10_CS4
|
||||
#define J_5 SW10_CS5
|
||||
#define J_6 SW10_CS6
|
||||
#define J_7 SW10_CS7
|
||||
#define J_8 SW10_CS8
|
||||
#define J_9 SW10_CS9
|
||||
#define J_10 SW10_CS10
|
||||
#define J_11 SW10_CS11
|
||||
#define J_12 SW10_CS12
|
||||
|
||||
#define K_1 SW11_CS1
|
||||
#define K_2 SW11_CS2
|
||||
#define K_3 SW11_CS3
|
||||
#define K_4 SW11_CS4
|
||||
#define K_5 SW11_CS5
|
||||
#define K_6 SW11_CS6
|
||||
#define K_7 SW11_CS7
|
||||
#define K_8 SW11_CS8
|
||||
#define K_9 SW11_CS9
|
||||
#define K_10 SW11_CS10
|
||||
#define K_11 SW11_CS11
|
||||
#define K_12 SW11_CS12
|
||||
|
||||
#define L_1 SW12_CS1
|
||||
#define L_2 SW12_CS2
|
||||
#define L_3 SW12_CS3
|
||||
#define L_4 SW12_CS4
|
||||
#define L_5 SW12_CS5
|
||||
#define L_6 SW12_CS6
|
||||
#define L_7 SW12_CS7
|
||||
#define L_8 SW12_CS8
|
||||
#define L_9 SW12_CS9
|
||||
#define L_10 SW12_CS10
|
||||
#define L_11 SW12_CS11
|
||||
#define L_12 SW12_CS12
|
||||
|
|
282
drivers/led/issi/is31fl3741-mono.c
Normal file
282
drivers/led/issi/is31fl3741-mono.c
Normal file
|
@ -0,0 +1,282 @@
|
|||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2020 MelGeek
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "is31fl3741-mono.h"
|
||||
#include "i2c_master.h"
|
||||
#include "gpio.h"
|
||||
#include "wait.h"
|
||||
|
||||
#define IS31FL3741_PWM_0_REGISTER_COUNT 180
|
||||
#define IS31FL3741_PWM_1_REGISTER_COUNT 171
|
||||
#define IS31FL3741_SCALING_0_REGISTER_COUNT 180
|
||||
#define IS31FL3741_SCALING_1_REGISTER_COUNT 171
|
||||
|
||||
#ifndef IS31FL3741_I2C_TIMEOUT
|
||||
# define IS31FL3741_I2C_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3741_I2C_PERSISTENCE
|
||||
# define IS31FL3741_I2C_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3741_CONFIGURATION
|
||||
# define IS31FL3741_CONFIGURATION 0x01
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3741_PWM_FREQUENCY
|
||||
# define IS31FL3741_PWM_FREQUENCY IS31FL3741_PWM_FREQUENCY_29K_HZ
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3741_SW_PULLUP
|
||||
# define IS31FL3741_SW_PULLUP IS31FL3741_PUR_32K_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3741_CS_PULLDOWN
|
||||
# define IS31FL3741_CS_PULLDOWN IS31FL3741_PDR_32K_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3741_GLOBAL_CURRENT
|
||||
# define IS31FL3741_GLOBAL_CURRENT 0xFF
|
||||
#endif
|
||||
|
||||
const uint8_t i2c_addresses[IS31FL3741_DRIVER_COUNT] = {
|
||||
IS31FL3741_I2C_ADDRESS_1,
|
||||
#ifdef IS31FL3741_I2C_ADDRESS_2
|
||||
IS31FL3741_I2C_ADDRESS_2,
|
||||
# ifdef IS31FL3741_I2C_ADDRESS_3
|
||||
IS31FL3741_I2C_ADDRESS_3,
|
||||
# ifdef IS31FL3741_I2C_ADDRESS_4
|
||||
IS31FL3741_I2C_ADDRESS_4,
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
// These buffers match the IS31FL3741 and IS31FL3741A PWM registers.
|
||||
// The scaling buffers match the page 2 and 3 LED On/Off registers.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
// We could optimize this and take out the unused registers from these
|
||||
// buffers and the transfers in is31fl3741_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
typedef struct is31fl3741_driver_t {
|
||||
uint8_t pwm_buffer_0[IS31FL3741_PWM_0_REGISTER_COUNT];
|
||||
uint8_t pwm_buffer_1[IS31FL3741_PWM_1_REGISTER_COUNT];
|
||||
bool pwm_buffer_dirty;
|
||||
uint8_t scaling_buffer_0[IS31FL3741_SCALING_0_REGISTER_COUNT];
|
||||
uint8_t scaling_buffer_1[IS31FL3741_SCALING_1_REGISTER_COUNT];
|
||||
bool scaling_buffer_dirty;
|
||||
} PACKED is31fl3741_driver_t;
|
||||
|
||||
is31fl3741_driver_t driver_buffers[IS31FL3741_DRIVER_COUNT] = {{
|
||||
.pwm_buffer_0 = {0},
|
||||
.pwm_buffer_1 = {0},
|
||||
.pwm_buffer_dirty = false,
|
||||
.scaling_buffer_0 = {0},
|
||||
.scaling_buffer_1 = {0},
|
||||
.scaling_buffer_dirty = false,
|
||||
}};
|
||||
|
||||
void is31fl3741_write_register(uint8_t index, uint8_t reg, uint8_t data) {
|
||||
#if IS31FL3741_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3741_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3741_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3741_select_page(uint8_t index, uint8_t page) {
|
||||
is31fl3741_write_register(index, IS31FL3741_REG_COMMAND_WRITE_LOCK, IS31FL3741_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3741_write_register(index, IS31FL3741_REG_COMMAND, page);
|
||||
}
|
||||
|
||||
void is31fl3741_write_pwm_buffer(uint8_t index) {
|
||||
is31fl3741_select_page(index, IS31FL3741_COMMAND_PWM_0);
|
||||
|
||||
// Transmit PWM0 registers in 6 transfers of 30 bytes.
|
||||
|
||||
// Iterate over the pwm_buffer_0 contents at 30 byte intervals.
|
||||
for (uint8_t i = 0; i < IS31FL3741_PWM_0_REGISTER_COUNT; i += 30) {
|
||||
#if IS31FL3741_I2C_PERSISTENCE > 0
|
||||
for (uint8_t j = 0; j < IS31FL3741_I2C_PERSISTENCE; j++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer_0 + i, 30, IS31FL3741_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer_0 + i, 30, IS31FL3741_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
is31fl3741_select_page(index, IS31FL3741_COMMAND_PWM_1);
|
||||
|
||||
// Transmit PWM1 registers in 9 transfers of 19 bytes.
|
||||
|
||||
// Iterate over the pwm_buffer_1 contents at 19 byte intervals.
|
||||
for (uint8_t i = 0; i < IS31FL3741_PWM_1_REGISTER_COUNT; i += 19) {
|
||||
#if IS31FL3741_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer_1 + i, 19, IS31FL3741_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer_1 + i, 19, IS31FL3741_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3741_init_drivers(void) {
|
||||
i2c_init();
|
||||
|
||||
#if defined(IS31FL3741_SDB_PIN)
|
||||
gpio_set_pin_output(IS31FL3741_SDB_PIN);
|
||||
gpio_write_pin_high(IS31FL3741_SDB_PIN);
|
||||
#endif
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3741_DRIVER_COUNT; i++) {
|
||||
is31fl3741_init(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < IS31FL3741_LED_COUNT; i++) {
|
||||
is31fl3741_set_led_control_register(i, true);
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3741_DRIVER_COUNT; i++) {
|
||||
is31fl3741_update_led_control_registers(i);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3741_init(uint8_t index) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
// Unlock the command register.
|
||||
|
||||
is31fl3741_select_page(index, IS31FL3741_COMMAND_FUNCTION);
|
||||
|
||||
// Set to Normal operation
|
||||
is31fl3741_write_register(index, IS31FL3741_FUNCTION_REG_CONFIGURATION, IS31FL3741_CONFIGURATION);
|
||||
|
||||
// Set Golbal Current Control Register
|
||||
is31fl3741_write_register(index, IS31FL3741_FUNCTION_REG_GLOBAL_CURRENT, IS31FL3741_GLOBAL_CURRENT);
|
||||
// Set Pull up & Down for SWx CSy
|
||||
is31fl3741_write_register(index, IS31FL3741_FUNCTION_REG_PULLDOWNUP, ((IS31FL3741_CS_PULLDOWN << 4) | IS31FL3741_SW_PULLUP));
|
||||
// Set PWM frequency
|
||||
is31fl3741_write_register(index, IS31FL3741_FUNCTION_REG_PWM_FREQUENCY, (IS31FL3741_PWM_FREQUENCY & 0b1111));
|
||||
|
||||
// is31fl3741_update_led_scaling_registers(index, 0xFF, 0xFF, 0xFF);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
wait_ms(10);
|
||||
}
|
||||
|
||||
uint8_t get_pwm_value(uint8_t driver, uint16_t reg) {
|
||||
if (reg & 0x100) {
|
||||
return driver_buffers[driver].pwm_buffer_1[reg & 0xFF];
|
||||
} else {
|
||||
return driver_buffers[driver].pwm_buffer_0[reg];
|
||||
}
|
||||
}
|
||||
|
||||
void set_pwm_value(uint8_t driver, uint16_t reg, uint8_t value) {
|
||||
if (reg & 0x100) {
|
||||
driver_buffers[driver].pwm_buffer_1[reg & 0xFF] = value;
|
||||
} else {
|
||||
driver_buffers[driver].pwm_buffer_0[reg] = value;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3741_set_value(int index, uint8_t value) {
|
||||
is31fl3741_led_t led;
|
||||
|
||||
if (index >= 0 && index < IS31FL3741_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3741_leds[index]), sizeof(led));
|
||||
|
||||
if (get_pwm_value(led.driver, led.v) == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
set_pwm_value(led.driver, led.v, value);
|
||||
driver_buffers[led.driver].pwm_buffer_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3741_set_value_all(uint8_t value) {
|
||||
for (int i = 0; i < IS31FL3741_LED_COUNT; i++) {
|
||||
is31fl3741_set_value(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
void set_scaling_value(uint8_t driver, uint16_t reg, uint8_t value) {
|
||||
if (reg & 0x100) {
|
||||
driver_buffers[driver].scaling_buffer_1[reg & 0xFF] = value;
|
||||
} else {
|
||||
driver_buffers[driver].scaling_buffer_0[reg] = value;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3741_set_led_control_register(uint8_t index, bool value) {
|
||||
is31fl3741_led_t led;
|
||||
memcpy_P(&led, (&g_is31fl3741_leds[index]), sizeof(led));
|
||||
|
||||
set_scaling_value(led.driver, led.v, value ? 0xFF : 0x00);
|
||||
|
||||
driver_buffers[led.driver].scaling_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3741_update_pwm_buffers(uint8_t index) {
|
||||
if (driver_buffers[index].pwm_buffer_dirty) {
|
||||
is31fl3741_write_pwm_buffer(index);
|
||||
|
||||
driver_buffers[index].pwm_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3741_set_pwm_buffer(const is31fl3741_led_t *pled, uint8_t value) {
|
||||
set_pwm_value(pled->driver, pled->v, value);
|
||||
driver_buffers[pled->driver].pwm_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3741_update_led_control_registers(uint8_t index) {
|
||||
if (driver_buffers[index].scaling_buffer_dirty) {
|
||||
is31fl3741_select_page(index, IS31FL3741_COMMAND_SCALING_0);
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3741_SCALING_0_REGISTER_COUNT; i++) {
|
||||
is31fl3741_write_register(index, i, driver_buffers[index].scaling_buffer_0[i]);
|
||||
}
|
||||
|
||||
is31fl3741_select_page(index, IS31FL3741_COMMAND_SCALING_1);
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3741_SCALING_1_REGISTER_COUNT; i++) {
|
||||
is31fl3741_write_register(index, i, driver_buffers[index].scaling_buffer_1[i]);
|
||||
}
|
||||
|
||||
driver_buffers[index].scaling_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3741_set_scaling_registers(const is31fl3741_led_t *pled, uint8_t value) {
|
||||
set_scaling_value(pled->driver, pled->v, value);
|
||||
driver_buffers[pled->driver].scaling_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3741_flush(void) {
|
||||
for (uint8_t i = 0; i < IS31FL3741_DRIVER_COUNT; i++) {
|
||||
is31fl3741_update_pwm_buffers(i);
|
||||
}
|
||||
}
|
887
drivers/led/issi/is31fl3741-mono.h
Normal file
887
drivers/led/issi/is31fl3741-mono.h
Normal file
|
@ -0,0 +1,887 @@
|
|||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2020 MelGeek
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "progmem.h"
|
||||
#include "util.h"
|
||||
|
||||
// ======== DEPRECATED DEFINES - DO NOT USE ========
|
||||
#ifdef ISSI_TIMEOUT
|
||||
# define IS31FL3741_I2C_TIMEOUT ISSI_TIMEOUT
|
||||
#endif
|
||||
#ifdef ISSI_PERSISTENCE
|
||||
# define IS31FL3741_I2C_PERSISTENCE ISSI_PERSISTENCE
|
||||
#endif
|
||||
#ifdef ISSI_CONFIGURATION
|
||||
# define IS31FL3741_CONFIGURATION ISSI_CONFIGURATION
|
||||
#endif
|
||||
#ifdef ISSI_SWPULLUP
|
||||
# define IS31FL3741_SW_PULLUP ISSI_SWPULLUP
|
||||
#endif
|
||||
#ifdef ISSI_CSPULLUP
|
||||
# define IS31FL3741_CS_PULLDOWN ISSI_CSPULLUP
|
||||
#endif
|
||||
#ifdef ISSI_GLOBALCURRENT
|
||||
# define IS31FL3741_GLOBAL_CURRENT ISSI_GLOBALCURRENT
|
||||
#endif
|
||||
|
||||
#define PUR_0R IS31FL3741_PUR_0_OHM
|
||||
#define PUR_05KR IS31FL3741_PUR_0K5_OHM
|
||||
#define PUR_1KR IS31FL3741_PUR_1K_OHM
|
||||
#define PUR_2KR IS31FL3741_PUR_2K_OHM
|
||||
#define PUR_4KR IS31FL3741_PUR_4K_OHM
|
||||
#define PUR_8KR IS31FL3741_PUR_8K_OHM
|
||||
#define PUR_16KR IS31FL3741_PUR_16K_OHM
|
||||
#define PUR_32KR IS31FL3741_PUR_32K_OHM
|
||||
// ========
|
||||
|
||||
#define IS31FL3741_REG_INTERRUPT_MASK 0xF0
|
||||
#define IS31FL3741_REG_INTERRUPT_STATUS 0xF1
|
||||
#define IS31FL3741_REG_ID 0xFC
|
||||
|
||||
#define IS31FL3741_REG_COMMAND 0xFD
|
||||
|
||||
#define IS31FL3741_COMMAND_PWM_0 0x00
|
||||
#define IS31FL3741_COMMAND_PWM_1 0x01
|
||||
#define IS31FL3741_COMMAND_SCALING_0 0x02
|
||||
#define IS31FL3741_COMMAND_SCALING_1 0x03
|
||||
#define IS31FL3741_COMMAND_FUNCTION 0x04
|
||||
|
||||
#define IS31FL3741_FUNCTION_REG_CONFIGURATION 0x00
|
||||
#define IS31FL3741_FUNCTION_REG_GLOBAL_CURRENT 0x01
|
||||
#define IS31FL3741_FUNCTION_REG_PULLDOWNUP 0x02
|
||||
#define IS31FL3741_FUNCTION_REG_PWM_FREQUENCY 0x36
|
||||
#define IS31FL3741_FUNCTION_REG_RESET 0x3F
|
||||
|
||||
#define IS31FL3741_REG_COMMAND_WRITE_LOCK 0xFE
|
||||
#define IS31FL3741_COMMAND_WRITE_LOCK_MAGIC 0xC5
|
||||
|
||||
#define IS31FL3741_I2C_ADDRESS_GND 0x30
|
||||
#define IS31FL3741_I2C_ADDRESS_SCL 0x31
|
||||
#define IS31FL3741_I2C_ADDRESS_SDA 0x32
|
||||
#define IS31FL3741_I2C_ADDRESS_VCC 0x33
|
||||
|
||||
#if defined(LED_MATRIX_IS31FL3741)
|
||||
# define IS31FL3741_LED_COUNT LED_MATRIX_LED_COUNT
|
||||
#endif
|
||||
|
||||
#if defined(IS31FL3741_I2C_ADDRESS_4)
|
||||
# define IS31FL3741_DRIVER_COUNT 4
|
||||
#elif defined(IS31FL3741_I2C_ADDRESS_3)
|
||||
# define IS31FL3741_DRIVER_COUNT 3
|
||||
#elif defined(IS31FL3741_I2C_ADDRESS_2)
|
||||
# define IS31FL3741_DRIVER_COUNT 2
|
||||
#elif defined(IS31FL3741_I2C_ADDRESS_1)
|
||||
# define IS31FL3741_DRIVER_COUNT 1
|
||||
#endif
|
||||
|
||||
typedef struct is31fl3741_led_t {
|
||||
uint8_t driver : 2;
|
||||
uint16_t v : 9;
|
||||
} PACKED is31fl3741_led_t;
|
||||
|
||||
extern const is31fl3741_led_t PROGMEM g_is31fl3741_leds[IS31FL3741_LED_COUNT];
|
||||
|
||||
void is31fl3741_init_drivers(void);
|
||||
void is31fl3741_init(uint8_t index);
|
||||
void is31fl3741_write_register(uint8_t index, uint8_t reg, uint8_t data);
|
||||
void is31fl3741_select_page(uint8_t index, uint8_t page);
|
||||
|
||||
void is31fl3741_set_value(int index, uint8_t value);
|
||||
void is31fl3741_set_value_all(uint8_t value);
|
||||
|
||||
void is31fl3741_set_led_control_register(uint8_t index, bool value);
|
||||
|
||||
// This should not be called from an interrupt
|
||||
// (eg. from a timer interrupt).
|
||||
// Call this while idle (in between matrix scans).
|
||||
// If the buffer is dirty, it will update the driver with the buffer.
|
||||
void is31fl3741_update_pwm_buffers(uint8_t index);
|
||||
void is31fl3741_update_led_control_registers(uint8_t index);
|
||||
void is31fl3741_set_scaling_registers(const is31fl3741_led_t *pled, uint8_t value);
|
||||
|
||||
void is31fl3741_set_pwm_buffer(const is31fl3741_led_t *pled, uint8_t value);
|
||||
|
||||
void is31fl3741_flush(void);
|
||||
|
||||
#define IS31FL3741_PDR_0_OHM 0b000 // No pull-down resistor
|
||||
#define IS31FL3741_PDR_0K5_OHM 0b001 // 0.5 kOhm resistor
|
||||
#define IS31FL3741_PDR_1K_OHM 0b010 // 1 kOhm resistor
|
||||
#define IS31FL3741_PDR_2K_OHM 0b011 // 2 kOhm resistor
|
||||
#define IS31FL3741_PDR_4K_OHM 0b100 // 4 kOhm resistor
|
||||
#define IS31FL3741_PDR_8K_OHM 0b101 // 8 kOhm resistor
|
||||
#define IS31FL3741_PDR_16K_OHM 0b110 // 16 kOhm resistor
|
||||
#define IS31FL3741_PDR_32K_OHM 0b111 // 32 kOhm resistor
|
||||
|
||||
#define IS31FL3741_PUR_0_OHM 0b000 // No pull-up resistor
|
||||
#define IS31FL3741_PUR_0K5_OHM 0b001 // 0.5 kOhm resistor
|
||||
#define IS31FL3741_PUR_1K_OHM 0b010 // 1 kOhm resistor
|
||||
#define IS31FL3741_PUR_2K_OHM 0b011 // 2 kOhm resistor
|
||||
#define IS31FL3741_PUR_4K_OHM 0b100 // 4 kOhm resistor
|
||||
#define IS31FL3741_PUR_8K_OHM 0b101 // 8 kOhm resistor
|
||||
#define IS31FL3741_PUR_16K_OHM 0b110 // 16 kOhm resistor
|
||||
#define IS31FL3741_PUR_32K_OHM 0b111 // 32 kOhm resistor
|
||||
|
||||
#define IS31FL3741_PWM_FREQUENCY_29K_HZ 0b0000
|
||||
#define IS31FL3741_PWM_FREQUENCY_3K6_HZ 0b0011
|
||||
#define IS31FL3741_PWM_FREQUENCY_1K8_HZ 0b0111
|
||||
#define IS31FL3741_PWM_FREQUENCY_900_HZ 0b1011
|
||||
|
||||
#define SW1_CS1 0x00
|
||||
#define SW1_CS2 0x01
|
||||
#define SW1_CS3 0x02
|
||||
#define SW1_CS4 0x03
|
||||
#define SW1_CS5 0x04
|
||||
#define SW1_CS6 0x05
|
||||
#define SW1_CS7 0x06
|
||||
#define SW1_CS8 0x07
|
||||
#define SW1_CS9 0x08
|
||||
#define SW1_CS10 0x09
|
||||
#define SW1_CS11 0x0A
|
||||
#define SW1_CS12 0x0B
|
||||
#define SW1_CS13 0x0C
|
||||
#define SW1_CS14 0x0D
|
||||
#define SW1_CS15 0x0E
|
||||
#define SW1_CS16 0x0F
|
||||
#define SW1_CS17 0x10
|
||||
#define SW1_CS18 0x11
|
||||
#define SW1_CS19 0x12
|
||||
#define SW1_CS20 0x13
|
||||
#define SW1_CS21 0x14
|
||||
#define SW1_CS22 0x15
|
||||
#define SW1_CS23 0x16
|
||||
#define SW1_CS24 0x17
|
||||
#define SW1_CS25 0x18
|
||||
#define SW1_CS26 0x19
|
||||
#define SW1_CS27 0x1A
|
||||
#define SW1_CS28 0x1B
|
||||
#define SW1_CS29 0x1C
|
||||
#define SW1_CS30 0x1D
|
||||
|
||||
#define SW2_CS1 0x1E
|
||||
#define SW2_CS2 0x1F
|
||||
#define SW2_CS3 0x20
|
||||
#define SW2_CS4 0x21
|
||||
#define SW2_CS5 0x22
|
||||
#define SW2_CS6 0x23
|
||||
#define SW2_CS7 0x24
|
||||
#define SW2_CS8 0x25
|
||||
#define SW2_CS9 0x26
|
||||
#define SW2_CS10 0x27
|
||||
#define SW2_CS11 0x28
|
||||
#define SW2_CS12 0x29
|
||||
#define SW2_CS13 0x2A
|
||||
#define SW2_CS14 0x2B
|
||||
#define SW2_CS15 0x2C
|
||||
#define SW2_CS16 0x2D
|
||||
#define SW2_CS17 0x2E
|
||||
#define SW2_CS18 0x2F
|
||||
#define SW2_CS19 0x30
|
||||
#define SW2_CS20 0x31
|
||||
#define SW2_CS21 0x32
|
||||
#define SW2_CS22 0x33
|
||||
#define SW2_CS23 0x34
|
||||
#define SW2_CS24 0x35
|
||||
#define SW2_CS25 0x36
|
||||
#define SW2_CS26 0x37
|
||||
#define SW2_CS27 0x38
|
||||
#define SW2_CS28 0x39
|
||||
#define SW2_CS29 0x3A
|
||||
#define SW2_CS30 0x3B
|
||||
|
||||
#define SW3_CS1 0x3C
|
||||
#define SW3_CS2 0x3D
|
||||
#define SW3_CS3 0x3E
|
||||
#define SW3_CS4 0x3F
|
||||
#define SW3_CS5 0x40
|
||||
#define SW3_CS6 0x41
|
||||
#define SW3_CS7 0x42
|
||||
#define SW3_CS8 0x43
|
||||
#define SW3_CS9 0x44
|
||||
#define SW3_CS10 0x45
|
||||
#define SW3_CS11 0x46
|
||||
#define SW3_CS12 0x47
|
||||
#define SW3_CS13 0x48
|
||||
#define SW3_CS14 0x49
|
||||
#define SW3_CS15 0x4A
|
||||
#define SW3_CS16 0x4B
|
||||
#define SW3_CS17 0x4C
|
||||
#define SW3_CS18 0x4D
|
||||
#define SW3_CS19 0x4E
|
||||
#define SW3_CS20 0x4F
|
||||
#define SW3_CS21 0x50
|
||||
#define SW3_CS22 0x51
|
||||
#define SW3_CS23 0x52
|
||||
#define SW3_CS24 0x53
|
||||
#define SW3_CS25 0x54
|
||||
#define SW3_CS26 0x55
|
||||
#define SW3_CS27 0x56
|
||||
#define SW3_CS28 0x57
|
||||
#define SW3_CS29 0x58
|
||||
#define SW3_CS30 0x59
|
||||
|
||||
#define SW4_CS1 0x5A
|
||||
#define SW4_CS2 0x5B
|
||||
#define SW4_CS3 0x5C
|
||||
#define SW4_CS4 0x5D
|
||||
#define SW4_CS5 0x5E
|
||||
#define SW4_CS6 0x5F
|
||||
#define SW4_CS7 0x60
|
||||
#define SW4_CS8 0x61
|
||||
#define SW4_CS9 0x62
|
||||
#define SW4_CS10 0x63
|
||||
#define SW4_CS11 0x64
|
||||
#define SW4_CS12 0x65
|
||||
#define SW4_CS13 0x66
|
||||
#define SW4_CS14 0x67
|
||||
#define SW4_CS15 0x68
|
||||
#define SW4_CS16 0x69
|
||||
#define SW4_CS17 0x6A
|
||||
#define SW4_CS18 0x6B
|
||||
#define SW4_CS19 0x6C
|
||||
#define SW4_CS20 0x6D
|
||||
#define SW4_CS21 0x6E
|
||||
#define SW4_CS22 0x6F
|
||||
#define SW4_CS23 0x70
|
||||
#define SW4_CS24 0x71
|
||||
#define SW4_CS25 0x72
|
||||
#define SW4_CS26 0x73
|
||||
#define SW4_CS27 0x74
|
||||
#define SW4_CS28 0x75
|
||||
#define SW4_CS29 0x76
|
||||
#define SW4_CS30 0x77
|
||||
|
||||
#define SW5_CS1 0x78
|
||||
#define SW5_CS2 0x79
|
||||
#define SW5_CS3 0x7A
|
||||
#define SW5_CS4 0x7B
|
||||
#define SW5_CS5 0x7C
|
||||
#define SW5_CS6 0x7D
|
||||
#define SW5_CS7 0x7E
|
||||
#define SW5_CS8 0x7F
|
||||
#define SW5_CS9 0x80
|
||||
#define SW5_CS10 0x81
|
||||
#define SW5_CS11 0x82
|
||||
#define SW5_CS12 0x83
|
||||
#define SW5_CS13 0x84
|
||||
#define SW5_CS14 0x85
|
||||
#define SW5_CS15 0x86
|
||||
#define SW5_CS16 0x87
|
||||
#define SW5_CS17 0x88
|
||||
#define SW5_CS18 0x89
|
||||
#define SW5_CS19 0x8A
|
||||
#define SW5_CS20 0x8B
|
||||
#define SW5_CS21 0x8C
|
||||
#define SW5_CS22 0x8D
|
||||
#define SW5_CS23 0x8E
|
||||
#define SW5_CS24 0x8F
|
||||
#define SW5_CS25 0x90
|
||||
#define SW5_CS26 0x91
|
||||
#define SW5_CS27 0x92
|
||||
#define SW5_CS28 0x93
|
||||
#define SW5_CS29 0x94
|
||||
#define SW5_CS30 0x95
|
||||
|
||||
#define SW6_CS1 0x96
|
||||
#define SW6_CS2 0x97
|
||||
#define SW6_CS3 0x98
|
||||
#define SW6_CS4 0x99
|
||||
#define SW6_CS5 0x9A
|
||||
#define SW6_CS6 0x9B
|
||||
#define SW6_CS7 0x9C
|
||||
#define SW6_CS8 0x9D
|
||||
#define SW6_CS9 0x9E
|
||||
#define SW6_CS10 0x9F
|
||||
#define SW6_CS11 0xA0
|
||||
#define SW6_CS12 0xA1
|
||||
#define SW6_CS13 0xA2
|
||||
#define SW6_CS14 0xA3
|
||||
#define SW6_CS15 0xA4
|
||||
#define SW6_CS16 0xA5
|
||||
#define SW6_CS17 0xA6
|
||||
#define SW6_CS18 0xA7
|
||||
#define SW6_CS19 0xA8
|
||||
#define SW6_CS20 0xA9
|
||||
#define SW6_CS21 0xAA
|
||||
#define SW6_CS22 0xAB
|
||||
#define SW6_CS23 0xAC
|
||||
#define SW6_CS24 0xAD
|
||||
#define SW6_CS25 0xAE
|
||||
#define SW6_CS26 0xAF
|
||||
#define SW6_CS27 0xB0
|
||||
#define SW6_CS28 0xB1
|
||||
#define SW6_CS29 0xB2
|
||||
#define SW6_CS30 0xB3
|
||||
|
||||
#define SW7_CS1 0x100
|
||||
#define SW7_CS2 0x101
|
||||
#define SW7_CS3 0x102
|
||||
#define SW7_CS4 0x103
|
||||
#define SW7_CS5 0x104
|
||||
#define SW7_CS6 0x105
|
||||
#define SW7_CS7 0x106
|
||||
#define SW7_CS8 0x107
|
||||
#define SW7_CS9 0x108
|
||||
#define SW7_CS10 0x109
|
||||
#define SW7_CS11 0x10A
|
||||
#define SW7_CS12 0x10B
|
||||
#define SW7_CS13 0x10C
|
||||
#define SW7_CS14 0x10D
|
||||
#define SW7_CS15 0x10E
|
||||
#define SW7_CS16 0x10F
|
||||
#define SW7_CS17 0x110
|
||||
#define SW7_CS18 0x111
|
||||
#define SW7_CS19 0x112
|
||||
#define SW7_CS20 0x113
|
||||
#define SW7_CS21 0x114
|
||||
#define SW7_CS22 0x115
|
||||
#define SW7_CS23 0x116
|
||||
#define SW7_CS24 0x117
|
||||
#define SW7_CS25 0x118
|
||||
#define SW7_CS26 0x119
|
||||
#define SW7_CS27 0x11A
|
||||
#define SW7_CS28 0x11B
|
||||
#define SW7_CS29 0x11C
|
||||
#define SW7_CS30 0x11D
|
||||
|
||||
#define SW8_CS1 0x11E
|
||||
#define SW8_CS2 0x11F
|
||||
#define SW8_CS3 0x120
|
||||
#define SW8_CS4 0x121
|
||||
#define SW8_CS5 0x122
|
||||
#define SW8_CS6 0x123
|
||||
#define SW8_CS7 0x124
|
||||
#define SW8_CS8 0x125
|
||||
#define SW8_CS9 0x126
|
||||
#define SW8_CS10 0x127
|
||||
#define SW8_CS11 0x128
|
||||
#define SW8_CS12 0x129
|
||||
#define SW8_CS13 0x12A
|
||||
#define SW8_CS14 0x12B
|
||||
#define SW8_CS15 0x12C
|
||||
#define SW8_CS16 0x12D
|
||||
#define SW8_CS17 0x12E
|
||||
#define SW8_CS18 0x12F
|
||||
#define SW8_CS19 0x130
|
||||
#define SW8_CS20 0x131
|
||||
#define SW8_CS21 0x132
|
||||
#define SW8_CS22 0x133
|
||||
#define SW8_CS23 0x134
|
||||
#define SW8_CS24 0x135
|
||||
#define SW8_CS25 0x136
|
||||
#define SW8_CS26 0x137
|
||||
#define SW8_CS27 0x138
|
||||
#define SW8_CS28 0x139
|
||||
#define SW8_CS29 0x13A
|
||||
#define SW8_CS30 0x13B
|
||||
|
||||
#define SW9_CS1 0x13C
|
||||
#define SW9_CS2 0x13D
|
||||
#define SW9_CS3 0x13E
|
||||
#define SW9_CS4 0x13F
|
||||
#define SW9_CS5 0x140
|
||||
#define SW9_CS6 0x141
|
||||
#define SW9_CS7 0x142
|
||||
#define SW9_CS8 0x143
|
||||
#define SW9_CS9 0x144
|
||||
#define SW9_CS10 0x145
|
||||
#define SW9_CS11 0x146
|
||||
#define SW9_CS12 0x147
|
||||
#define SW9_CS13 0x148
|
||||
#define SW9_CS14 0x149
|
||||
#define SW9_CS15 0x14A
|
||||
#define SW9_CS16 0x14B
|
||||
#define SW9_CS17 0x14C
|
||||
#define SW9_CS18 0x14D
|
||||
#define SW9_CS19 0x14E
|
||||
#define SW9_CS20 0x14F
|
||||
#define SW9_CS21 0x150
|
||||
#define SW9_CS22 0x151
|
||||
#define SW9_CS23 0x152
|
||||
#define SW9_CS24 0x153
|
||||
#define SW9_CS25 0x154
|
||||
#define SW9_CS26 0x155
|
||||
#define SW9_CS27 0x156
|
||||
#define SW9_CS28 0x157
|
||||
#define SW9_CS29 0x158
|
||||
#define SW9_CS30 0x159
|
||||
|
||||
#define SW1_CS31 0x15A
|
||||
#define SW1_CS32 0x15B
|
||||
#define SW1_CS33 0x15C
|
||||
#define SW1_CS34 0x15D
|
||||
#define SW1_CS35 0x15E
|
||||
#define SW1_CS36 0x15F
|
||||
#define SW1_CS37 0x160
|
||||
#define SW1_CS38 0x161
|
||||
#define SW1_CS39 0x162
|
||||
|
||||
#define SW2_CS31 0x163
|
||||
#define SW2_CS32 0x164
|
||||
#define SW2_CS33 0x165
|
||||
#define SW2_CS34 0x166
|
||||
#define SW2_CS35 0x167
|
||||
#define SW2_CS36 0x168
|
||||
#define SW2_CS37 0x169
|
||||
#define SW2_CS38 0x16A
|
||||
#define SW2_CS39 0x16B
|
||||
|
||||
#define SW3_CS31 0x16C
|
||||
#define SW3_CS32 0x16D
|
||||
#define SW3_CS33 0x16E
|
||||
#define SW3_CS34 0x16F
|
||||
#define SW3_CS35 0x170
|
||||
#define SW3_CS36 0x171
|
||||
#define SW3_CS37 0x172
|
||||
#define SW3_CS38 0x173
|
||||
#define SW3_CS39 0x174
|
||||
|
||||
#define SW4_CS31 0x175
|
||||
#define SW4_CS32 0x176
|
||||
#define SW4_CS33 0x177
|
||||
#define SW4_CS34 0x178
|
||||
#define SW4_CS35 0x179
|
||||
#define SW4_CS36 0x17A
|
||||
#define SW4_CS37 0x17B
|
||||
#define SW4_CS38 0x17C
|
||||
#define SW4_CS39 0x17D
|
||||
|
||||
#define SW5_CS31 0x17E
|
||||
#define SW5_CS32 0x17F
|
||||
#define SW5_CS33 0x180
|
||||
#define SW5_CS34 0x181
|
||||
#define SW5_CS35 0x182
|
||||
#define SW5_CS36 0x183
|
||||
#define SW5_CS37 0x184
|
||||
#define SW5_CS38 0x185
|
||||
#define SW5_CS39 0x186
|
||||
|
||||
#define SW6_CS31 0x187
|
||||
#define SW6_CS32 0x188
|
||||
#define SW6_CS33 0x189
|
||||
#define SW6_CS34 0x18A
|
||||
#define SW6_CS35 0x18B
|
||||
#define SW6_CS36 0x18C
|
||||
#define SW6_CS37 0x18D
|
||||
#define SW6_CS38 0x18E
|
||||
#define SW6_CS39 0x18F
|
||||
|
||||
#define SW7_CS31 0x190
|
||||
#define SW7_CS32 0x191
|
||||
#define SW7_CS33 0x192
|
||||
#define SW7_CS34 0x193
|
||||
#define SW7_CS35 0x194
|
||||
#define SW7_CS36 0x195
|
||||
#define SW7_CS37 0x196
|
||||
#define SW7_CS38 0x197
|
||||
#define SW7_CS39 0x198
|
||||
|
||||
#define SW8_CS31 0x199
|
||||
#define SW8_CS32 0x19A
|
||||
#define SW8_CS33 0x19B
|
||||
#define SW8_CS34 0x19C
|
||||
#define SW8_CS35 0x19D
|
||||
#define SW8_CS36 0x19E
|
||||
#define SW8_CS37 0x19F
|
||||
#define SW8_CS38 0x1A0
|
||||
#define SW8_CS39 0x1A1
|
||||
|
||||
#define SW9_CS31 0x1A2
|
||||
#define SW9_CS32 0x1A3
|
||||
#define SW9_CS33 0x1A4
|
||||
#define SW9_CS34 0x1A5
|
||||
#define SW9_CS35 0x1A6
|
||||
#define SW9_CS36 0x1A7
|
||||
#define SW9_CS37 0x1A8
|
||||
#define SW9_CS38 0x1A9
|
||||
#define SW9_CS39 0x1AA
|
||||
|
||||
// DEPRECATED - DO NOT USE
|
||||
|
||||
#define CS1_SW1 SW1_CS1
|
||||
#define CS2_SW1 SW1_CS2
|
||||
#define CS3_SW1 SW1_CS3
|
||||
#define CS4_SW1 SW1_CS4
|
||||
#define CS5_SW1 SW1_CS5
|
||||
#define CS6_SW1 SW1_CS6
|
||||
#define CS7_SW1 SW1_CS7
|
||||
#define CS8_SW1 SW1_CS8
|
||||
#define CS9_SW1 SW1_CS9
|
||||
#define CS10_SW1 SW1_CS10
|
||||
#define CS11_SW1 SW1_CS11
|
||||
#define CS12_SW1 SW1_CS12
|
||||
#define CS13_SW1 SW1_CS13
|
||||
#define CS14_SW1 SW1_CS14
|
||||
#define CS15_SW1 SW1_CS15
|
||||
#define CS16_SW1 SW1_CS16
|
||||
#define CS17_SW1 SW1_CS17
|
||||
#define CS18_SW1 SW1_CS18
|
||||
#define CS19_SW1 SW1_CS19
|
||||
#define CS20_SW1 SW1_CS20
|
||||
#define CS21_SW1 SW1_CS21
|
||||
#define CS22_SW1 SW1_CS22
|
||||
#define CS23_SW1 SW1_CS23
|
||||
#define CS24_SW1 SW1_CS24
|
||||
#define CS25_SW1 SW1_CS25
|
||||
#define CS26_SW1 SW1_CS26
|
||||
#define CS27_SW1 SW1_CS27
|
||||
#define CS28_SW1 SW1_CS28
|
||||
#define CS29_SW1 SW1_CS29
|
||||
#define CS30_SW1 SW1_CS30
|
||||
|
||||
#define CS1_SW2 SW2_CS1
|
||||
#define CS2_SW2 SW2_CS2
|
||||
#define CS3_SW2 SW2_CS3
|
||||
#define CS4_SW2 SW2_CS4
|
||||
#define CS5_SW2 SW2_CS5
|
||||
#define CS6_SW2 SW2_CS6
|
||||
#define CS7_SW2 SW2_CS7
|
||||
#define CS8_SW2 SW2_CS8
|
||||
#define CS9_SW2 SW2_CS9
|
||||
#define CS10_SW2 SW2_CS10
|
||||
#define CS11_SW2 SW2_CS11
|
||||
#define CS12_SW2 SW2_CS12
|
||||
#define CS13_SW2 SW2_CS13
|
||||
#define CS14_SW2 SW2_CS14
|
||||
#define CS15_SW2 SW2_CS15
|
||||
#define CS16_SW2 SW2_CS16
|
||||
#define CS17_SW2 SW2_CS17
|
||||
#define CS18_SW2 SW2_CS18
|
||||
#define CS19_SW2 SW2_CS19
|
||||
#define CS20_SW2 SW2_CS20
|
||||
#define CS21_SW2 SW2_CS21
|
||||
#define CS22_SW2 SW2_CS22
|
||||
#define CS23_SW2 SW2_CS23
|
||||
#define CS24_SW2 SW2_CS24
|
||||
#define CS25_SW2 SW2_CS25
|
||||
#define CS26_SW2 SW2_CS26
|
||||
#define CS27_SW2 SW2_CS27
|
||||
#define CS28_SW2 SW2_CS28
|
||||
#define CS29_SW2 SW2_CS29
|
||||
#define CS30_SW2 SW2_CS30
|
||||
|
||||
#define CS1_SW3 SW3_CS1
|
||||
#define CS2_SW3 SW3_CS2
|
||||
#define CS3_SW3 SW3_CS3
|
||||
#define CS4_SW3 SW3_CS4
|
||||
#define CS5_SW3 SW3_CS5
|
||||
#define CS6_SW3 SW3_CS6
|
||||
#define CS7_SW3 SW3_CS7
|
||||
#define CS8_SW3 SW3_CS8
|
||||
#define CS9_SW3 SW3_CS9
|
||||
#define CS10_SW3 SW3_CS10
|
||||
#define CS11_SW3 SW3_CS11
|
||||
#define CS12_SW3 SW3_CS12
|
||||
#define CS13_SW3 SW3_CS13
|
||||
#define CS14_SW3 SW3_CS14
|
||||
#define CS15_SW3 SW3_CS15
|
||||
#define CS16_SW3 SW3_CS16
|
||||
#define CS17_SW3 SW3_CS17
|
||||
#define CS18_SW3 SW3_CS18
|
||||
#define CS19_SW3 SW3_CS19
|
||||
#define CS20_SW3 SW3_CS20
|
||||
#define CS21_SW3 SW3_CS21
|
||||
#define CS22_SW3 SW3_CS22
|
||||
#define CS23_SW3 SW3_CS23
|
||||
#define CS24_SW3 SW3_CS24
|
||||
#define CS25_SW3 SW3_CS25
|
||||
#define CS26_SW3 SW3_CS26
|
||||
#define CS27_SW3 SW3_CS27
|
||||
#define CS28_SW3 SW3_CS28
|
||||
#define CS29_SW3 SW3_CS29
|
||||
#define CS30_SW3 SW3_CS30
|
||||
|
||||
#define CS1_SW4 SW4_CS1
|
||||
#define CS2_SW4 SW4_CS2
|
||||
#define CS3_SW4 SW4_CS3
|
||||
#define CS4_SW4 SW4_CS4
|
||||
#define CS5_SW4 SW4_CS5
|
||||
#define CS6_SW4 SW4_CS6
|
||||
#define CS7_SW4 SW4_CS7
|
||||
#define CS8_SW4 SW4_CS8
|
||||
#define CS9_SW4 SW4_CS9
|
||||
#define CS10_SW4 SW4_CS10
|
||||
#define CS11_SW4 SW4_CS11
|
||||
#define CS12_SW4 SW4_CS12
|
||||
#define CS13_SW4 SW4_CS13
|
||||
#define CS14_SW4 SW4_CS14
|
||||
#define CS15_SW4 SW4_CS15
|
||||
#define CS16_SW4 SW4_CS16
|
||||
#define CS17_SW4 SW4_CS17
|
||||
#define CS18_SW4 SW4_CS18
|
||||
#define CS19_SW4 SW4_CS19
|
||||
#define CS20_SW4 SW4_CS20
|
||||
#define CS21_SW4 SW4_CS21
|
||||
#define CS22_SW4 SW4_CS22
|
||||
#define CS23_SW4 SW4_CS23
|
||||
#define CS24_SW4 SW4_CS24
|
||||
#define CS25_SW4 SW4_CS25
|
||||
#define CS26_SW4 SW4_CS26
|
||||
#define CS27_SW4 SW4_CS27
|
||||
#define CS28_SW4 SW4_CS28
|
||||
#define CS29_SW4 SW4_CS29
|
||||
#define CS30_SW4 SW4_CS30
|
||||
|
||||
#define CS1_SW5 SW5_CS1
|
||||
#define CS2_SW5 SW5_CS2
|
||||
#define CS3_SW5 SW5_CS3
|
||||
#define CS4_SW5 SW5_CS4
|
||||
#define CS5_SW5 SW5_CS5
|
||||
#define CS6_SW5 SW5_CS6
|
||||
#define CS7_SW5 SW5_CS7
|
||||
#define CS8_SW5 SW5_CS8
|
||||
#define CS9_SW5 SW5_CS9
|
||||
#define CS10_SW5 SW5_CS10
|
||||
#define CS11_SW5 SW5_CS11
|
||||
#define CS12_SW5 SW5_CS12
|
||||
#define CS13_SW5 SW5_CS13
|
||||
#define CS14_SW5 SW5_CS14
|
||||
#define CS15_SW5 SW5_CS15
|
||||
#define CS16_SW5 SW5_CS16
|
||||
#define CS17_SW5 SW5_CS17
|
||||
#define CS18_SW5 SW5_CS18
|
||||
#define CS19_SW5 SW5_CS19
|
||||
#define CS20_SW5 SW5_CS20
|
||||
#define CS21_SW5 SW5_CS21
|
||||
#define CS22_SW5 SW5_CS22
|
||||
#define CS23_SW5 SW5_CS23
|
||||
#define CS24_SW5 SW5_CS24
|
||||
#define CS25_SW5 SW5_CS25
|
||||
#define CS26_SW5 SW5_CS26
|
||||
#define CS27_SW5 SW5_CS27
|
||||
#define CS28_SW5 SW5_CS28
|
||||
#define CS29_SW5 SW5_CS29
|
||||
#define CS30_SW5 SW5_CS30
|
||||
|
||||
#define CS1_SW6 SW6_CS1
|
||||
#define CS2_SW6 SW6_CS2
|
||||
#define CS3_SW6 SW6_CS3
|
||||
#define CS4_SW6 SW6_CS4
|
||||
#define CS5_SW6 SW6_CS5
|
||||
#define CS6_SW6 SW6_CS6
|
||||
#define CS7_SW6 SW6_CS7
|
||||
#define CS8_SW6 SW6_CS8
|
||||
#define CS9_SW6 SW6_CS9
|
||||
#define CS10_SW6 SW6_CS10
|
||||
#define CS11_SW6 SW6_CS11
|
||||
#define CS12_SW6 SW6_CS12
|
||||
#define CS13_SW6 SW6_CS13
|
||||
#define CS14_SW6 SW6_CS14
|
||||
#define CS15_SW6 SW6_CS15
|
||||
#define CS16_SW6 SW6_CS16
|
||||
#define CS17_SW6 SW6_CS17
|
||||
#define CS18_SW6 SW6_CS18
|
||||
#define CS19_SW6 SW6_CS19
|
||||
#define CS20_SW6 SW6_CS20
|
||||
#define CS21_SW6 SW6_CS21
|
||||
#define CS22_SW6 SW6_CS22
|
||||
#define CS23_SW6 SW6_CS23
|
||||
#define CS24_SW6 SW6_CS24
|
||||
#define CS25_SW6 SW6_CS25
|
||||
#define CS26_SW6 SW6_CS26
|
||||
#define CS27_SW6 SW6_CS27
|
||||
#define CS28_SW6 SW6_CS28
|
||||
#define CS29_SW6 SW6_CS29
|
||||
#define CS30_SW6 SW6_CS30
|
||||
|
||||
#define CS1_SW7 SW7_CS1
|
||||
#define CS2_SW7 SW7_CS2
|
||||
#define CS3_SW7 SW7_CS3
|
||||
#define CS4_SW7 SW7_CS4
|
||||
#define CS5_SW7 SW7_CS5
|
||||
#define CS6_SW7 SW7_CS6
|
||||
#define CS7_SW7 SW7_CS7
|
||||
#define CS8_SW7 SW7_CS8
|
||||
#define CS9_SW7 SW7_CS9
|
||||
#define CS10_SW7 SW7_CS10
|
||||
#define CS11_SW7 SW7_CS11
|
||||
#define CS12_SW7 SW7_CS12
|
||||
#define CS13_SW7 SW7_CS13
|
||||
#define CS14_SW7 SW7_CS14
|
||||
#define CS15_SW7 SW7_CS15
|
||||
#define CS16_SW7 SW7_CS16
|
||||
#define CS17_SW7 SW7_CS17
|
||||
#define CS18_SW7 SW7_CS18
|
||||
#define CS19_SW7 SW7_CS19
|
||||
#define CS20_SW7 SW7_CS20
|
||||
#define CS21_SW7 SW7_CS21
|
||||
#define CS22_SW7 SW7_CS22
|
||||
#define CS23_SW7 SW7_CS23
|
||||
#define CS24_SW7 SW7_CS24
|
||||
#define CS25_SW7 SW7_CS25
|
||||
#define CS26_SW7 SW7_CS26
|
||||
#define CS27_SW7 SW7_CS27
|
||||
#define CS28_SW7 SW7_CS28
|
||||
#define CS29_SW7 SW7_CS29
|
||||
#define CS30_SW7 SW7_CS30
|
||||
|
||||
#define CS1_SW8 SW8_CS1
|
||||
#define CS2_SW8 SW8_CS2
|
||||
#define CS3_SW8 SW8_CS3
|
||||
#define CS4_SW8 SW8_CS4
|
||||
#define CS5_SW8 SW8_CS5
|
||||
#define CS6_SW8 SW8_CS6
|
||||
#define CS7_SW8 SW8_CS7
|
||||
#define CS8_SW8 SW8_CS8
|
||||
#define CS9_SW8 SW8_CS9
|
||||
#define CS10_SW8 SW8_CS10
|
||||
#define CS11_SW8 SW8_CS11
|
||||
#define CS12_SW8 SW8_CS12
|
||||
#define CS13_SW8 SW8_CS13
|
||||
#define CS14_SW8 SW8_CS14
|
||||
#define CS15_SW8 SW8_CS15
|
||||
#define CS16_SW8 SW8_CS16
|
||||
#define CS17_SW8 SW8_CS17
|
||||
#define CS18_SW8 SW8_CS18
|
||||
#define CS19_SW8 SW8_CS19
|
||||
#define CS20_SW8 SW8_CS20
|
||||
#define CS21_SW8 SW8_CS21
|
||||
#define CS22_SW8 SW8_CS22
|
||||
#define CS23_SW8 SW8_CS23
|
||||
#define CS24_SW8 SW8_CS24
|
||||
#define CS25_SW8 SW8_CS25
|
||||
#define CS26_SW8 SW8_CS26
|
||||
#define CS27_SW8 SW8_CS27
|
||||
#define CS28_SW8 SW8_CS28
|
||||
#define CS29_SW8 SW8_CS29
|
||||
#define CS30_SW8 SW8_CS30
|
||||
|
||||
#define CS1_SW9 SW9_CS1
|
||||
#define CS2_SW9 SW9_CS2
|
||||
#define CS3_SW9 SW9_CS3
|
||||
#define CS4_SW9 SW9_CS4
|
||||
#define CS5_SW9 SW9_CS5
|
||||
#define CS6_SW9 SW9_CS6
|
||||
#define CS7_SW9 SW9_CS7
|
||||
#define CS8_SW9 SW9_CS8
|
||||
#define CS9_SW9 SW9_CS9
|
||||
#define CS10_SW9 SW9_CS10
|
||||
#define CS11_SW9 SW9_CS11
|
||||
#define CS12_SW9 SW9_CS12
|
||||
#define CS13_SW9 SW9_CS13
|
||||
#define CS14_SW9 SW9_CS14
|
||||
#define CS15_SW9 SW9_CS15
|
||||
#define CS16_SW9 SW9_CS16
|
||||
#define CS17_SW9 SW9_CS17
|
||||
#define CS18_SW9 SW9_CS18
|
||||
#define CS19_SW9 SW9_CS19
|
||||
#define CS20_SW9 SW9_CS20
|
||||
#define CS21_SW9 SW9_CS21
|
||||
#define CS22_SW9 SW9_CS22
|
||||
#define CS23_SW9 SW9_CS23
|
||||
#define CS24_SW9 SW9_CS24
|
||||
#define CS25_SW9 SW9_CS25
|
||||
#define CS26_SW9 SW9_CS26
|
||||
#define CS27_SW9 SW9_CS27
|
||||
#define CS28_SW9 SW9_CS28
|
||||
#define CS29_SW9 SW9_CS29
|
||||
#define CS30_SW9 SW9_CS30
|
||||
|
||||
#define CS31_SW1 SW1_CS31
|
||||
#define CS32_SW1 SW1_CS32
|
||||
#define CS33_SW1 SW1_CS33
|
||||
#define CS34_SW1 SW1_CS34
|
||||
#define CS35_SW1 SW1_CS35
|
||||
#define CS36_SW1 SW1_CS36
|
||||
#define CS37_SW1 SW1_CS37
|
||||
#define CS38_SW1 SW1_CS38
|
||||
#define CS39_SW1 SW1_CS39
|
||||
|
||||
#define CS31_SW2 SW2_CS31
|
||||
#define CS32_SW2 SW2_CS32
|
||||
#define CS33_SW2 SW2_CS33
|
||||
#define CS34_SW2 SW2_CS34
|
||||
#define CS35_SW2 SW2_CS35
|
||||
#define CS36_SW2 SW2_CS36
|
||||
#define CS37_SW2 SW2_CS37
|
||||
#define CS38_SW2 SW2_CS38
|
||||
#define CS39_SW2 SW2_CS39
|
||||
|
||||
#define CS31_SW3 SW3_CS31
|
||||
#define CS32_SW3 SW3_CS32
|
||||
#define CS33_SW3 SW3_CS33
|
||||
#define CS34_SW3 SW3_CS34
|
||||
#define CS35_SW3 SW3_CS35
|
||||
#define CS36_SW3 SW3_CS36
|
||||
#define CS37_SW3 SW3_CS37
|
||||
#define CS38_SW3 SW3_CS38
|
||||
#define CS39_SW3 SW3_CS39
|
||||
|
||||
#define CS31_SW4 SW4_CS31
|
||||
#define CS32_SW4 SW4_CS32
|
||||
#define CS33_SW4 SW4_CS33
|
||||
#define CS34_SW4 SW4_CS34
|
||||
#define CS35_SW4 SW4_CS35
|
||||
#define CS36_SW4 SW4_CS36
|
||||
#define CS37_SW4 SW4_CS37
|
||||
#define CS38_SW4 SW4_CS38
|
||||
#define CS39_SW4 SW4_CS39
|
||||
|
||||
#define CS31_SW5 SW5_CS31
|
||||
#define CS32_SW5 SW5_CS32
|
||||
#define CS33_SW5 SW5_CS33
|
||||
#define CS34_SW5 SW5_CS34
|
||||
#define CS35_SW5 SW5_CS35
|
||||
#define CS36_SW5 SW5_CS36
|
||||
#define CS37_SW5 SW5_CS37
|
||||
#define CS38_SW5 SW5_CS38
|
||||
#define CS39_SW5 SW5_CS39
|
||||
|
||||
#define CS31_SW6 SW6_CS31
|
||||
#define CS32_SW6 SW6_CS32
|
||||
#define CS33_SW6 SW6_CS33
|
||||
#define CS34_SW6 SW6_CS34
|
||||
#define CS35_SW6 SW6_CS35
|
||||
#define CS36_SW6 SW6_CS36
|
||||
#define CS37_SW6 SW6_CS37
|
||||
#define CS38_SW6 SW6_CS38
|
||||
#define CS39_SW6 SW6_CS39
|
||||
|
||||
#define CS31_SW7 SW7_CS31
|
||||
#define CS32_SW7 SW7_CS32
|
||||
#define CS33_SW7 SW7_CS33
|
||||
#define CS34_SW7 SW7_CS34
|
||||
#define CS35_SW7 SW7_CS35
|
||||
#define CS36_SW7 SW7_CS36
|
||||
#define CS37_SW7 SW7_CS37
|
||||
#define CS38_SW7 SW7_CS38
|
||||
#define CS39_SW7 SW7_CS39
|
||||
|
||||
#define CS31_SW8 SW8_CS31
|
||||
#define CS32_SW8 SW8_CS32
|
||||
#define CS33_SW8 SW8_CS33
|
||||
#define CS34_SW8 SW8_CS34
|
||||
#define CS35_SW8 SW8_CS35
|
||||
#define CS36_SW8 SW8_CS36
|
||||
#define CS37_SW8 SW8_CS37
|
||||
#define CS38_SW8 SW8_CS38
|
||||
#define CS39_SW8 SW8_CS39
|
||||
|
||||
#define CS31_SW9 SW9_CS31
|
||||
#define CS32_SW9 SW9_CS32
|
||||
#define CS33_SW9 SW9_CS33
|
||||
#define CS34_SW9 SW9_CS34
|
||||
#define CS35_SW9 SW9_CS35
|
||||
#define CS36_SW9 SW9_CS36
|
||||
#define CS37_SW9 SW9_CS37
|
||||
#define CS38_SW9 SW9_CS38
|
||||
#define CS39_SW9 SW9_CS39
|
|
@ -1,278 +0,0 @@
|
|||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2020 MelGeek
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "is31fl3741-simple.h"
|
||||
#include <string.h>
|
||||
#include "i2c_master.h"
|
||||
#include "wait.h"
|
||||
|
||||
#define IS31FL3741_PWM_REGISTER_COUNT 351
|
||||
|
||||
#ifndef IS31FL3741_I2C_TIMEOUT
|
||||
# define IS31FL3741_I2C_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3741_I2C_PERSISTENCE
|
||||
# define IS31FL3741_I2C_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3741_CONFIGURATION
|
||||
# define IS31FL3741_CONFIGURATION 0x01
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3741_PWM_FREQUENCY
|
||||
# define IS31FL3741_PWM_FREQUENCY IS31FL3741_PWM_FREQUENCY_29K_HZ
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3741_SW_PULLUP
|
||||
# define IS31FL3741_SW_PULLUP IS31FL3741_PUR_32K_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3741_CS_PULLDOWN
|
||||
# define IS31FL3741_CS_PULLDOWN IS31FL3741_PDR_32K_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3741_GLOBAL_CURRENT
|
||||
# define IS31FL3741_GLOBAL_CURRENT 0xFF
|
||||
#endif
|
||||
|
||||
// Transfer buffer for TWITransmitData()
|
||||
uint8_t g_twi_transfer_buffer[20] = {0xFF};
|
||||
|
||||
// These buffers match the IS31FL3741 and IS31FL3741A PWM registers.
|
||||
// The scaling buffers match the PG2 and PG3 LED On/Off registers.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
// We could optimize this and take out the unused registers from these
|
||||
// buffers and the transfers in is31fl3741_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
uint8_t g_pwm_buffer[IS31FL3741_DRIVER_COUNT][IS31FL3741_PWM_REGISTER_COUNT];
|
||||
bool g_pwm_buffer_update_required[IS31FL3741_DRIVER_COUNT] = {false};
|
||||
bool g_scaling_registers_update_required[IS31FL3741_DRIVER_COUNT] = {false};
|
||||
|
||||
uint8_t g_scaling_registers[IS31FL3741_DRIVER_COUNT][IS31FL3741_PWM_REGISTER_COUNT];
|
||||
|
||||
void is31fl3741_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
|
||||
#if IS31FL3741_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3741_I2C_TIMEOUT) == 0) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3741_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
||||
// Assume PG0 is already selected
|
||||
|
||||
for (int i = 0; i < 342; i += 18) {
|
||||
if (i == 180) {
|
||||
// unlock the command register and select PG1
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND_WRITE_LOCK, IS31FL3741_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND, IS31FL3741_COMMAND_PWM_1);
|
||||
}
|
||||
|
||||
g_twi_transfer_buffer[0] = i % 180;
|
||||
memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 18);
|
||||
|
||||
#if IS31FL3741_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// transfer the left cause the total number is 351
|
||||
g_twi_transfer_buffer[0] = 162;
|
||||
memcpy(g_twi_transfer_buffer + 1, pwm_buffer + 342, 9);
|
||||
|
||||
#if IS31FL3741_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void is31fl3741_init_drivers(void) {
|
||||
i2c_init();
|
||||
|
||||
is31fl3741_init(IS31FL3741_I2C_ADDRESS_1);
|
||||
#if defined(IS31FL3741_I2C_ADDRESS_2)
|
||||
is31fl3741_init(IS31FL3741_I2C_ADDRESS_2);
|
||||
# if defined(IS31FL3741_I2C_ADDRESS_3)
|
||||
is31fl3741_init(IS31FL3741_I2C_ADDRESS_3);
|
||||
# if defined(IS31FL3741_I2C_ADDRESS_4)
|
||||
is31fl3741_init(IS31FL3741_I2C_ADDRESS_4);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < IS31FL3741_LED_COUNT; i++) {
|
||||
is31fl3741_set_led_control_register(i, true);
|
||||
}
|
||||
|
||||
is31fl3741_update_led_control_registers(IS31FL3741_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3741_I2C_ADDRESS_2)
|
||||
is31fl3741_update_led_control_registers(IS31FL3741_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3741_I2C_ADDRESS_3)
|
||||
is31fl3741_update_led_control_registers(IS31FL3741_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3741_I2C_ADDRESS_4)
|
||||
is31fl3741_update_led_control_registers(IS31FL3741_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3741_init(uint8_t addr) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
// Unlock the command register.
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND_WRITE_LOCK, IS31FL3741_COMMAND_WRITE_LOCK_MAGIC);
|
||||
|
||||
// Select PG4
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND, IS31FL3741_COMMAND_FUNCTION);
|
||||
|
||||
// Set to Normal operation
|
||||
is31fl3741_write_register(addr, IS31FL3741_FUNCTION_REG_CONFIGURATION, IS31FL3741_CONFIGURATION);
|
||||
|
||||
// Set Golbal Current Control Register
|
||||
is31fl3741_write_register(addr, IS31FL3741_FUNCTION_REG_GLOBAL_CURRENT, IS31FL3741_GLOBAL_CURRENT);
|
||||
// Set Pull up & Down for SWx CSy
|
||||
is31fl3741_write_register(addr, IS31FL3741_FUNCTION_REG_PULLDOWNUP, ((IS31FL3741_CS_PULLDOWN << 4) | IS31FL3741_SW_PULLUP));
|
||||
// Set PWM frequency
|
||||
is31fl3741_write_register(addr, IS31FL3741_FUNCTION_REG_PWM_FREQUENCY, (IS31FL3741_PWM_FREQUENCY & 0b1111));
|
||||
|
||||
// is31fl3741_update_led_scaling_registers(addr, 0xFF, 0xFF, 0xFF);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
wait_ms(10);
|
||||
}
|
||||
|
||||
void is31fl3741_set_value(int index, uint8_t value) {
|
||||
is31fl3741_led_t led;
|
||||
if (index >= 0 && index < IS31FL3741_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3741_leds[index]), sizeof(led));
|
||||
|
||||
if (g_pwm_buffer[led.driver][led.v] == value) {
|
||||
return;
|
||||
}
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
g_pwm_buffer[led.driver][led.v] = value;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3741_set_value_all(uint8_t value) {
|
||||
for (int i = 0; i < IS31FL3741_LED_COUNT; i++) {
|
||||
is31fl3741_set_value(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3741_set_led_control_register(uint8_t index, bool value) {
|
||||
is31fl3741_led_t led;
|
||||
memcpy_P(&led, (&g_is31fl3741_leds[index]), sizeof(led));
|
||||
|
||||
if (value) {
|
||||
g_scaling_registers[led.driver][led.v] = 0xFF;
|
||||
} else {
|
||||
g_scaling_registers[led.driver][led.v] = 0x00;
|
||||
}
|
||||
|
||||
g_scaling_registers_update_required[led.driver] = true;
|
||||
}
|
||||
|
||||
void is31fl3741_update_pwm_buffers(uint8_t addr, uint8_t index) {
|
||||
if (g_pwm_buffer_update_required[index]) {
|
||||
// unlock the command register and select PG2
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND_WRITE_LOCK, IS31FL3741_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND, IS31FL3741_COMMAND_PWM_0);
|
||||
|
||||
is31fl3741_write_pwm_buffer(addr, g_pwm_buffer[index]);
|
||||
}
|
||||
|
||||
g_pwm_buffer_update_required[index] = false;
|
||||
}
|
||||
|
||||
void is31fl3741_set_pwm_buffer(const is31fl3741_led_t *pled, uint8_t value) {
|
||||
g_pwm_buffer[pled->driver][pled->v] = value;
|
||||
|
||||
g_pwm_buffer_update_required[pled->driver] = true;
|
||||
}
|
||||
|
||||
void is31fl3741_update_led_control_registers(uint8_t addr, uint8_t index) {
|
||||
if (g_scaling_registers_update_required[index]) {
|
||||
// unlock the command register and select PG2
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND_WRITE_LOCK, IS31FL3741_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND, IS31FL3741_COMMAND_SCALING_0);
|
||||
|
||||
// CS1_SW1 to CS30_SW6 are on PG2
|
||||
for (int i = CS1_SW1; i <= CS30_SW6; ++i) {
|
||||
is31fl3741_write_register(addr, i, g_scaling_registers[index][i]);
|
||||
}
|
||||
|
||||
// unlock the command register and select PG3
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND_WRITE_LOCK, IS31FL3741_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND, IS31FL3741_COMMAND_SCALING_1);
|
||||
|
||||
// CS1_SW7 to CS39_SW9 are on PG3
|
||||
for (int i = CS1_SW7; i <= CS39_SW9; ++i) {
|
||||
is31fl3741_write_register(addr, i - CS1_SW7, g_scaling_registers[index][i]);
|
||||
}
|
||||
|
||||
g_scaling_registers_update_required[index] = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3741_set_scaling_registers(const is31fl3741_led_t *pled, uint8_t value) {
|
||||
g_scaling_registers[pled->driver][pled->v] = value;
|
||||
|
||||
g_scaling_registers_update_required[pled->driver] = true;
|
||||
}
|
||||
|
||||
void is31fl3741_flush(void) {
|
||||
is31fl3741_update_pwm_buffers(IS31FL3741_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3741_I2C_ADDRESS_2)
|
||||
is31fl3741_update_pwm_buffers(IS31FL3741_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3741_I2C_ADDRESS_3)
|
||||
is31fl3741_update_pwm_buffers(IS31FL3741_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3741_I2C_ADDRESS_4)
|
||||
is31fl3741_update_pwm_buffers(IS31FL3741_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
}
|
|
@ -1,516 +0,0 @@
|
|||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2020 MelGeek
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "progmem.h"
|
||||
#include "util.h"
|
||||
|
||||
// ======== DEPRECATED DEFINES - DO NOT USE ========
|
||||
#ifdef ISSI_TIMEOUT
|
||||
# define IS31FL3741_I2C_TIMEOUT ISSI_TIMEOUT
|
||||
#endif
|
||||
#ifdef ISSI_PERSISTENCE
|
||||
# define IS31FL3741_I2C_PERSISTENCE ISSI_PERSISTENCE
|
||||
#endif
|
||||
#ifdef ISSI_CONFIGURATION
|
||||
# define IS31FL3741_CONFIGURATION ISSI_CONFIGURATION
|
||||
#endif
|
||||
#ifdef ISSI_SWPULLUP
|
||||
# define IS31FL3741_SW_PULLUP ISSI_SWPULLUP
|
||||
#endif
|
||||
#ifdef ISSI_CSPULLUP
|
||||
# define IS31FL3741_CS_PULLDOWN ISSI_CSPULLUP
|
||||
#endif
|
||||
#ifdef ISSI_GLOBALCURRENT
|
||||
# define IS31FL3741_GLOBAL_CURRENT ISSI_GLOBALCURRENT
|
||||
#endif
|
||||
|
||||
#define PUR_0R IS31FL3741_PUR_0_OHM
|
||||
#define PUR_05KR IS31FL3741_PUR_0K5_OHM
|
||||
#define PUR_1KR IS31FL3741_PUR_1K_OHM
|
||||
#define PUR_2KR IS31FL3741_PUR_2K_OHM
|
||||
#define PUR_4KR IS31FL3741_PUR_4K_OHM
|
||||
#define PUR_8KR IS31FL3741_PUR_8K_OHM
|
||||
#define PUR_16KR IS31FL3741_PUR_16K_OHM
|
||||
#define PUR_32KR IS31FL3741_PUR_32K_OHM
|
||||
// ========
|
||||
|
||||
#define IS31FL3741_REG_INTERRUPT_MASK 0xF0
|
||||
#define IS31FL3741_REG_INTERRUPT_STATUS 0xF1
|
||||
#define IS31FL3741_REG_ID 0xFC
|
||||
|
||||
#define IS31FL3741_REG_COMMAND 0xFD
|
||||
|
||||
#define IS31FL3741_COMMAND_PWM_0 0x00
|
||||
#define IS31FL3741_COMMAND_PWM_1 0x01
|
||||
#define IS31FL3741_COMMAND_SCALING_0 0x02
|
||||
#define IS31FL3741_COMMAND_SCALING_1 0x03
|
||||
#define IS31FL3741_COMMAND_FUNCTION 0x04
|
||||
|
||||
#define IS31FL3741_FUNCTION_REG_CONFIGURATION 0x00
|
||||
#define IS31FL3741_FUNCTION_REG_GLOBAL_CURRENT 0x01
|
||||
#define IS31FL3741_FUNCTION_REG_PULLDOWNUP 0x02
|
||||
#define IS31FL3741_FUNCTION_REG_PWM_FREQUENCY 0x36
|
||||
#define IS31FL3741_FUNCTION_REG_RESET 0x3F
|
||||
|
||||
#define IS31FL3741_REG_COMMAND_WRITE_LOCK 0xFE
|
||||
#define IS31FL3741_COMMAND_WRITE_LOCK_MAGIC 0xC5
|
||||
|
||||
#define IS31FL3741_I2C_ADDRESS_GND 0x30
|
||||
#define IS31FL3741_I2C_ADDRESS_SCL 0x31
|
||||
#define IS31FL3741_I2C_ADDRESS_SDA 0x32
|
||||
#define IS31FL3741_I2C_ADDRESS_VCC 0x33
|
||||
|
||||
#if defined(LED_MATRIX_IS31FL3741)
|
||||
# define IS31FL3741_LED_COUNT LED_MATRIX_LED_COUNT
|
||||
#endif
|
||||
|
||||
#if defined(IS31FL3741_I2C_ADDRESS_4)
|
||||
# define IS31FL3741_DRIVER_COUNT 4
|
||||
#elif defined(IS31FL3741_I2C_ADDRESS_3)
|
||||
# define IS31FL3741_DRIVER_COUNT 3
|
||||
#elif defined(IS31FL3741_I2C_ADDRESS_2)
|
||||
# define IS31FL3741_DRIVER_COUNT 2
|
||||
#elif defined(IS31FL3741_I2C_ADDRESS_1)
|
||||
# define IS31FL3741_DRIVER_COUNT 1
|
||||
#endif
|
||||
|
||||
typedef struct is31fl3741_led_t {
|
||||
uint8_t driver : 2;
|
||||
uint16_t v : 9;
|
||||
} PACKED is31fl3741_led_t;
|
||||
|
||||
extern const is31fl3741_led_t PROGMEM g_is31fl3741_leds[IS31FL3741_LED_COUNT];
|
||||
|
||||
void is31fl3741_init_drivers(void);
|
||||
void is31fl3741_init(uint8_t addr);
|
||||
void is31fl3741_write_register(uint8_t addr, uint8_t reg, uint8_t data);
|
||||
bool is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
|
||||
|
||||
void is31fl3741_set_value(int index, uint8_t value);
|
||||
void is31fl3741_set_value_all(uint8_t value);
|
||||
|
||||
void is31fl3741_set_led_control_register(uint8_t index, bool value);
|
||||
|
||||
// This should not be called from an interrupt
|
||||
// (eg. from a timer interrupt).
|
||||
// Call this while idle (in between matrix scans).
|
||||
// If the buffer is dirty, it will update the driver with the buffer.
|
||||
void is31fl3741_update_pwm_buffers(uint8_t addr, uint8_t index);
|
||||
void is31fl3741_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
void is31fl3741_set_scaling_registers(const is31fl3741_led_t *pled, uint8_t value);
|
||||
|
||||
void is31fl3741_set_pwm_buffer(const is31fl3741_led *pled, uint8_t value);
|
||||
|
||||
void is31fl3741_flush(void);
|
||||
|
||||
#define IS31FL3741_PDR_0_OHM 0b000 // No pull-down resistor
|
||||
#define IS31FL3741_PDR_0K5_OHM 0b001 // 0.5 kOhm resistor
|
||||
#define IS31FL3741_PDR_1K_OHM 0b010 // 1 kOhm resistor
|
||||
#define IS31FL3741_PDR_2K_OHM 0b011 // 2 kOhm resistor
|
||||
#define IS31FL3741_PDR_4K_OHM 0b100 // 4 kOhm resistor
|
||||
#define IS31FL3741_PDR_8K_OHM 0b101 // 8 kOhm resistor
|
||||
#define IS31FL3741_PDR_16K_OHM 0b110 // 16 kOhm resistor
|
||||
#define IS31FL3741_PDR_32K_OHM 0b111 // 32 kOhm resistor
|
||||
|
||||
#define IS31FL3741_PUR_0_OHM 0b000 // No pull-up resistor
|
||||
#define IS31FL3741_PUR_0K5_OHM 0b001 // 0.5 kOhm resistor
|
||||
#define IS31FL3741_PUR_1K_OHM 0b010 // 1 kOhm resistor
|
||||
#define IS31FL3741_PUR_2K_OHM 0b011 // 2 kOhm resistor
|
||||
#define IS31FL3741_PUR_4K_OHM 0b100 // 4 kOhm resistor
|
||||
#define IS31FL3741_PUR_8K_OHM 0b101 // 8 kOhm resistor
|
||||
#define IS31FL3741_PUR_16K_OHM 0b110 // 16 kOhm resistor
|
||||
#define IS31FL3741_PUR_32K_OHM 0b111 // 32 kOhm resistor
|
||||
|
||||
#define IS31FL3741_PWM_FREQUENCY_29K_HZ 0b0000
|
||||
#define IS31FL3741_PWM_FREQUENCY_3K6_HZ 0b0011
|
||||
#define IS31FL3741_PWM_FREQUENCY_1K8_HZ 0b0111
|
||||
#define IS31FL3741_PWM_FREQUENCY_900_HZ 0b1011
|
||||
|
||||
#define CS1_SW1 0x00
|
||||
#define CS2_SW1 0x01
|
||||
#define CS3_SW1 0x02
|
||||
#define CS4_SW1 0x03
|
||||
#define CS5_SW1 0x04
|
||||
#define CS6_SW1 0x05
|
||||
#define CS7_SW1 0x06
|
||||
#define CS8_SW1 0x07
|
||||
#define CS9_SW1 0x08
|
||||
#define CS10_SW1 0x09
|
||||
#define CS11_SW1 0x0A
|
||||
#define CS12_SW1 0x0B
|
||||
#define CS13_SW1 0x0C
|
||||
#define CS14_SW1 0x0D
|
||||
#define CS15_SW1 0x0E
|
||||
#define CS16_SW1 0x0F
|
||||
#define CS17_SW1 0x10
|
||||
#define CS18_SW1 0x11
|
||||
#define CS19_SW1 0x12
|
||||
#define CS20_SW1 0x13
|
||||
#define CS21_SW1 0x14
|
||||
#define CS22_SW1 0x15
|
||||
#define CS23_SW1 0x16
|
||||
#define CS24_SW1 0x17
|
||||
#define CS25_SW1 0x18
|
||||
#define CS26_SW1 0x19
|
||||
#define CS27_SW1 0x1A
|
||||
#define CS28_SW1 0x1B
|
||||
#define CS29_SW1 0x1C
|
||||
#define CS30_SW1 0x1D
|
||||
|
||||
#define CS1_SW2 0x1E
|
||||
#define CS2_SW2 0x1F
|
||||
#define CS3_SW2 0x20
|
||||
#define CS4_SW2 0x21
|
||||
#define CS5_SW2 0x22
|
||||
#define CS6_SW2 0x23
|
||||
#define CS7_SW2 0x24
|
||||
#define CS8_SW2 0x25
|
||||
#define CS9_SW2 0x26
|
||||
#define CS10_SW2 0x27
|
||||
#define CS11_SW2 0x28
|
||||
#define CS12_SW2 0x29
|
||||
#define CS13_SW2 0x2A
|
||||
#define CS14_SW2 0x2B
|
||||
#define CS15_SW2 0x2C
|
||||
#define CS16_SW2 0x2D
|
||||
#define CS17_SW2 0x2E
|
||||
#define CS18_SW2 0x2F
|
||||
#define CS19_SW2 0x30
|
||||
#define CS20_SW2 0x31
|
||||
#define CS21_SW2 0x32
|
||||
#define CS22_SW2 0x33
|
||||
#define CS23_SW2 0x34
|
||||
#define CS24_SW2 0x35
|
||||
#define CS25_SW2 0x36
|
||||
#define CS26_SW2 0x37
|
||||
#define CS27_SW2 0x38
|
||||
#define CS28_SW2 0x39
|
||||
#define CS29_SW2 0x3A
|
||||
#define CS30_SW2 0x3B
|
||||
|
||||
#define CS1_SW3 0x3C
|
||||
#define CS2_SW3 0x3D
|
||||
#define CS3_SW3 0x3E
|
||||
#define CS4_SW3 0x3F
|
||||
#define CS5_SW3 0x40
|
||||
#define CS6_SW3 0x41
|
||||
#define CS7_SW3 0x42
|
||||
#define CS8_SW3 0x43
|
||||
#define CS9_SW3 0x44
|
||||
#define CS10_SW3 0x45
|
||||
#define CS11_SW3 0x46
|
||||
#define CS12_SW3 0x47
|
||||
#define CS13_SW3 0x48
|
||||
#define CS14_SW3 0x49
|
||||
#define CS15_SW3 0x4A
|
||||
#define CS16_SW3 0x4B
|
||||
#define CS17_SW3 0x4C
|
||||
#define CS18_SW3 0x4D
|
||||
#define CS19_SW3 0x4E
|
||||
#define CS20_SW3 0x4F
|
||||
#define CS21_SW3 0x50
|
||||
#define CS22_SW3 0x51
|
||||
#define CS23_SW3 0x52
|
||||
#define CS24_SW3 0x53
|
||||
#define CS25_SW3 0x54
|
||||
#define CS26_SW3 0x55
|
||||
#define CS27_SW3 0x56
|
||||
#define CS28_SW3 0x57
|
||||
#define CS29_SW3 0x58
|
||||
#define CS30_SW3 0x59
|
||||
|
||||
#define CS1_SW4 0x5A
|
||||
#define CS2_SW4 0x5B
|
||||
#define CS3_SW4 0x5C
|
||||
#define CS4_SW4 0x5D
|
||||
#define CS5_SW4 0x5E
|
||||
#define CS6_SW4 0x5F
|
||||
#define CS7_SW4 0x60
|
||||
#define CS8_SW4 0x61
|
||||
#define CS9_SW4 0x62
|
||||
#define CS10_SW4 0x63
|
||||
#define CS11_SW4 0x64
|
||||
#define CS12_SW4 0x65
|
||||
#define CS13_SW4 0x66
|
||||
#define CS14_SW4 0x67
|
||||
#define CS15_SW4 0x68
|
||||
#define CS16_SW4 0x69
|
||||
#define CS17_SW4 0x6A
|
||||
#define CS18_SW4 0x6B
|
||||
#define CS19_SW4 0x6C
|
||||
#define CS20_SW4 0x6D
|
||||
#define CS21_SW4 0x6E
|
||||
#define CS22_SW4 0x6F
|
||||
#define CS23_SW4 0x70
|
||||
#define CS24_SW4 0x71
|
||||
#define CS25_SW4 0x72
|
||||
#define CS26_SW4 0x73
|
||||
#define CS27_SW4 0x74
|
||||
#define CS28_SW4 0x75
|
||||
#define CS29_SW4 0x76
|
||||
#define CS30_SW4 0x77
|
||||
|
||||
#define CS1_SW5 0x78
|
||||
#define CS2_SW5 0x79
|
||||
#define CS3_SW5 0x7A
|
||||
#define CS4_SW5 0x7B
|
||||
#define CS5_SW5 0x7C
|
||||
#define CS6_SW5 0x7D
|
||||
#define CS7_SW5 0x7E
|
||||
#define CS8_SW5 0x7F
|
||||
#define CS9_SW5 0x80
|
||||
#define CS10_SW5 0x81
|
||||
#define CS11_SW5 0x82
|
||||
#define CS12_SW5 0x83
|
||||
#define CS13_SW5 0x84
|
||||
#define CS14_SW5 0x85
|
||||
#define CS15_SW5 0x86
|
||||
#define CS16_SW5 0x87
|
||||
#define CS17_SW5 0x88
|
||||
#define CS18_SW5 0x89
|
||||
#define CS19_SW5 0x8A
|
||||
#define CS20_SW5 0x8B
|
||||
#define CS21_SW5 0x8C
|
||||
#define CS22_SW5 0x8D
|
||||
#define CS23_SW5 0x8E
|
||||
#define CS24_SW5 0x8F
|
||||
#define CS25_SW5 0x90
|
||||
#define CS26_SW5 0x91
|
||||
#define CS27_SW5 0x92
|
||||
#define CS28_SW5 0x93
|
||||
#define CS29_SW5 0x94
|
||||
#define CS30_SW5 0x95
|
||||
|
||||
#define CS1_SW6 0x96
|
||||
#define CS2_SW6 0x97
|
||||
#define CS3_SW6 0x98
|
||||
#define CS4_SW6 0x99
|
||||
#define CS5_SW6 0x9A
|
||||
#define CS6_SW6 0x9B
|
||||
#define CS7_SW6 0x9C
|
||||
#define CS8_SW6 0x9D
|
||||
#define CS9_SW6 0x9E
|
||||
#define CS10_SW6 0x9F
|
||||
#define CS11_SW6 0xA0
|
||||
#define CS12_SW6 0xA1
|
||||
#define CS13_SW6 0xA2
|
||||
#define CS14_SW6 0xA3
|
||||
#define CS15_SW6 0xA4
|
||||
#define CS16_SW6 0xA5
|
||||
#define CS17_SW6 0xA6
|
||||
#define CS18_SW6 0xA7
|
||||
#define CS19_SW6 0xA8
|
||||
#define CS20_SW6 0xA9
|
||||
#define CS21_SW6 0xAA
|
||||
#define CS22_SW6 0xAB
|
||||
#define CS23_SW6 0xAC
|
||||
#define CS24_SW6 0xAD
|
||||
#define CS25_SW6 0xAE
|
||||
#define CS26_SW6 0xAF
|
||||
#define CS27_SW6 0xB0
|
||||
#define CS28_SW6 0xB1
|
||||
#define CS29_SW6 0xB2
|
||||
#define CS30_SW6 0xB3
|
||||
|
||||
#define CS1_SW7 0xB4
|
||||
#define CS2_SW7 0xB5
|
||||
#define CS3_SW7 0xB6
|
||||
#define CS4_SW7 0xB7
|
||||
#define CS5_SW7 0xB8
|
||||
#define CS6_SW7 0xB9
|
||||
#define CS7_SW7 0xBA
|
||||
#define CS8_SW7 0xBB
|
||||
#define CS9_SW7 0xBC
|
||||
#define CS10_SW7 0xBD
|
||||
#define CS11_SW7 0xBE
|
||||
#define CS12_SW7 0xBF
|
||||
#define CS13_SW7 0xC0
|
||||
#define CS14_SW7 0xC1
|
||||
#define CS15_SW7 0xC2
|
||||
#define CS16_SW7 0xC3
|
||||
#define CS17_SW7 0xC4
|
||||
#define CS18_SW7 0xC5
|
||||
#define CS19_SW7 0xC6
|
||||
#define CS20_SW7 0xC7
|
||||
#define CS21_SW7 0xC8
|
||||
#define CS22_SW7 0xC9
|
||||
#define CS23_SW7 0xCA
|
||||
#define CS24_SW7 0xCB
|
||||
#define CS25_SW7 0xCC
|
||||
#define CS26_SW7 0xCD
|
||||
#define CS27_SW7 0xCE
|
||||
#define CS28_SW7 0xCF
|
||||
#define CS29_SW7 0xD0
|
||||
#define CS30_SW7 0xD1
|
||||
|
||||
#define CS1_SW8 0xD2
|
||||
#define CS2_SW8 0xD3
|
||||
#define CS3_SW8 0xD4
|
||||
#define CS4_SW8 0xD5
|
||||
#define CS5_SW8 0xD6
|
||||
#define CS6_SW8 0xD7
|
||||
#define CS7_SW8 0xD8
|
||||
#define CS8_SW8 0xD9
|
||||
#define CS9_SW8 0xDA
|
||||
#define CS10_SW8 0xDB
|
||||
#define CS11_SW8 0xDC
|
||||
#define CS12_SW8 0xDD
|
||||
#define CS13_SW8 0xDE
|
||||
#define CS14_SW8 0xDF
|
||||
#define CS15_SW8 0xE0
|
||||
#define CS16_SW8 0xE1
|
||||
#define CS17_SW8 0xE2
|
||||
#define CS18_SW8 0xE3
|
||||
#define CS19_SW8 0xE4
|
||||
#define CS20_SW8 0xE5
|
||||
#define CS21_SW8 0xE6
|
||||
#define CS22_SW8 0xE7
|
||||
#define CS23_SW8 0xE8
|
||||
#define CS24_SW8 0xE9
|
||||
#define CS25_SW8 0xEA
|
||||
#define CS26_SW8 0xEB
|
||||
#define CS27_SW8 0xEC
|
||||
#define CS28_SW8 0xED
|
||||
#define CS29_SW8 0xEE
|
||||
#define CS30_SW8 0xEF
|
||||
|
||||
#define CS1_SW9 0xF0
|
||||
#define CS2_SW9 0xF1
|
||||
#define CS3_SW9 0xF2
|
||||
#define CS4_SW9 0xF3
|
||||
#define CS5_SW9 0xF4
|
||||
#define CS6_SW9 0xF5
|
||||
#define CS7_SW9 0xF6
|
||||
#define CS8_SW9 0xF7
|
||||
#define CS9_SW9 0xF8
|
||||
#define CS10_SW9 0xF9
|
||||
#define CS11_SW9 0xFA
|
||||
#define CS12_SW9 0xFB
|
||||
#define CS13_SW9 0xFC
|
||||
#define CS14_SW9 0xFD
|
||||
#define CS15_SW9 0xFE
|
||||
#define CS16_SW9 0xFF
|
||||
#define CS17_SW9 0x100
|
||||
#define CS18_SW9 0x101
|
||||
#define CS19_SW9 0x102
|
||||
#define CS20_SW9 0x103
|
||||
#define CS21_SW9 0x104
|
||||
#define CS22_SW9 0x105
|
||||
#define CS23_SW9 0x106
|
||||
#define CS24_SW9 0x107
|
||||
#define CS25_SW9 0x108
|
||||
#define CS26_SW9 0x109
|
||||
#define CS27_SW9 0x10A
|
||||
#define CS28_SW9 0x10B
|
||||
#define CS29_SW9 0x10C
|
||||
#define CS30_SW9 0x10D
|
||||
|
||||
#define CS31_SW1 0x10E
|
||||
#define CS32_SW1 0x10F
|
||||
#define CS33_SW1 0x110
|
||||
#define CS34_SW1 0x111
|
||||
#define CS35_SW1 0x112
|
||||
#define CS36_SW1 0x113
|
||||
#define CS37_SW1 0x114
|
||||
#define CS38_SW1 0x115
|
||||
#define CS39_SW1 0x116
|
||||
|
||||
#define CS31_SW2 0x117
|
||||
#define CS32_SW2 0x118
|
||||
#define CS33_SW2 0x119
|
||||
#define CS34_SW2 0x11A
|
||||
#define CS35_SW2 0x11B
|
||||
#define CS36_SW2 0x11C
|
||||
#define CS37_SW2 0x11D
|
||||
#define CS38_SW2 0x11E
|
||||
#define CS39_SW2 0x11F
|
||||
|
||||
#define CS31_SW3 0x120
|
||||
#define CS32_SW3 0x121
|
||||
#define CS33_SW3 0x122
|
||||
#define CS34_SW3 0x123
|
||||
#define CS35_SW3 0x124
|
||||
#define CS36_SW3 0x125
|
||||
#define CS37_SW3 0x126
|
||||
#define CS38_SW3 0x127
|
||||
#define CS39_SW3 0x128
|
||||
|
||||
#define CS31_SW4 0x129
|
||||
#define CS32_SW4 0x12A
|
||||
#define CS33_SW4 0x12B
|
||||
#define CS34_SW4 0x12C
|
||||
#define CS35_SW4 0x12D
|
||||
#define CS36_SW4 0x12E
|
||||
#define CS37_SW4 0x12F
|
||||
#define CS38_SW4 0x130
|
||||
#define CS39_SW4 0x131
|
||||
|
||||
#define CS31_SW5 0x132
|
||||
#define CS32_SW5 0x133
|
||||
#define CS33_SW5 0x134
|
||||
#define CS34_SW5 0x135
|
||||
#define CS35_SW5 0x136
|
||||
#define CS36_SW5 0x137
|
||||
#define CS37_SW5 0x138
|
||||
#define CS38_SW5 0x139
|
||||
#define CS39_SW5 0x13A
|
||||
|
||||
#define CS31_SW6 0x13B
|
||||
#define CS32_SW6 0x13C
|
||||
#define CS33_SW6 0x13D
|
||||
#define CS34_SW6 0x13E
|
||||
#define CS35_SW6 0x13F
|
||||
#define CS36_SW6 0x140
|
||||
#define CS37_SW6 0x141
|
||||
#define CS38_SW6 0x142
|
||||
#define CS39_SW6 0x143
|
||||
|
||||
#define CS31_SW7 0x144
|
||||
#define CS32_SW7 0x145
|
||||
#define CS33_SW7 0x146
|
||||
#define CS34_SW7 0x147
|
||||
#define CS35_SW7 0x148
|
||||
#define CS36_SW7 0x149
|
||||
#define CS37_SW7 0x14A
|
||||
#define CS38_SW7 0x14B
|
||||
#define CS39_SW7 0x14C
|
||||
|
||||
#define CS31_SW8 0x14D
|
||||
#define CS32_SW8 0x14E
|
||||
#define CS33_SW8 0x14F
|
||||
#define CS34_SW8 0x150
|
||||
#define CS35_SW8 0x151
|
||||
#define CS36_SW8 0x152
|
||||
#define CS37_SW8 0x153
|
||||
#define CS38_SW8 0x154
|
||||
#define CS39_SW8 0x155
|
||||
|
||||
#define CS31_SW9 0x156
|
||||
#define CS32_SW9 0x157
|
||||
#define CS33_SW9 0x158
|
||||
#define CS34_SW9 0x159
|
||||
#define CS35_SW9 0x15A
|
||||
#define CS36_SW9 0x15B
|
||||
#define CS37_SW9 0x15C
|
||||
#define CS38_SW9 0x15D
|
||||
#define CS39_SW9 0x15E
|
|
@ -18,11 +18,14 @@
|
|||
*/
|
||||
|
||||
#include "is31fl3741.h"
|
||||
#include <string.h>
|
||||
#include "i2c_master.h"
|
||||
#include "gpio.h"
|
||||
#include "wait.h"
|
||||
|
||||
#define IS31FL3741_PWM_REGISTER_COUNT 351
|
||||
#define IS31FL3741_PWM_0_REGISTER_COUNT 180
|
||||
#define IS31FL3741_PWM_1_REGISTER_COUNT 171
|
||||
#define IS31FL3741_SCALING_0_REGISTER_COUNT 180
|
||||
#define IS31FL3741_SCALING_1_REGISTER_COUNT 171
|
||||
|
||||
#ifndef IS31FL3741_I2C_TIMEOUT
|
||||
# define IS31FL3741_I2C_TIMEOUT 100
|
||||
|
@ -52,150 +55,166 @@
|
|||
# define IS31FL3741_GLOBAL_CURRENT 0xFF
|
||||
#endif
|
||||
|
||||
// Transfer buffer for TWITransmitData()
|
||||
uint8_t g_twi_transfer_buffer[20] = {0xFF};
|
||||
const uint8_t i2c_addresses[IS31FL3741_DRIVER_COUNT] = {
|
||||
IS31FL3741_I2C_ADDRESS_1,
|
||||
#ifdef IS31FL3741_I2C_ADDRESS_2
|
||||
IS31FL3741_I2C_ADDRESS_2,
|
||||
# ifdef IS31FL3741_I2C_ADDRESS_3
|
||||
IS31FL3741_I2C_ADDRESS_3,
|
||||
# ifdef IS31FL3741_I2C_ADDRESS_4
|
||||
IS31FL3741_I2C_ADDRESS_4,
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
// These buffers match the IS31FL3741 and IS31FL3741A PWM registers.
|
||||
// The scaling buffers match the PG2 and PG3 LED On/Off registers.
|
||||
// The scaling buffers match the page 2 and 3 LED On/Off registers.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
// We could optimize this and take out the unused registers from these
|
||||
// buffers and the transfers in is31fl3741_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
uint8_t g_pwm_buffer[IS31FL3741_DRIVER_COUNT][IS31FL3741_PWM_REGISTER_COUNT];
|
||||
bool g_pwm_buffer_update_required[IS31FL3741_DRIVER_COUNT] = {false};
|
||||
bool g_scaling_registers_update_required[IS31FL3741_DRIVER_COUNT] = {false};
|
||||
typedef struct is31fl3741_driver_t {
|
||||
uint8_t pwm_buffer_0[IS31FL3741_PWM_0_REGISTER_COUNT];
|
||||
uint8_t pwm_buffer_1[IS31FL3741_PWM_1_REGISTER_COUNT];
|
||||
bool pwm_buffer_dirty;
|
||||
uint8_t scaling_buffer_0[IS31FL3741_SCALING_0_REGISTER_COUNT];
|
||||
uint8_t scaling_buffer_1[IS31FL3741_SCALING_1_REGISTER_COUNT];
|
||||
bool scaling_buffer_dirty;
|
||||
} PACKED is31fl3741_driver_t;
|
||||
|
||||
uint8_t g_scaling_registers[IS31FL3741_DRIVER_COUNT][IS31FL3741_PWM_REGISTER_COUNT];
|
||||
|
||||
void is31fl3741_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
is31fl3741_driver_t driver_buffers[IS31FL3741_DRIVER_COUNT] = {{
|
||||
.pwm_buffer_0 = {0},
|
||||
.pwm_buffer_1 = {0},
|
||||
.pwm_buffer_dirty = false,
|
||||
.scaling_buffer_0 = {0},
|
||||
.scaling_buffer_1 = {0},
|
||||
.scaling_buffer_dirty = false,
|
||||
}};
|
||||
|
||||
void is31fl3741_write_register(uint8_t index, uint8_t reg, uint8_t data) {
|
||||
#if IS31FL3741_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3741_I2C_TIMEOUT) == 0) break;
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3741_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3741_I2C_TIMEOUT);
|
||||
i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3741_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
||||
// Assume PG0 is already selected
|
||||
void is31fl3741_select_page(uint8_t index, uint8_t page) {
|
||||
is31fl3741_write_register(index, IS31FL3741_REG_COMMAND_WRITE_LOCK, IS31FL3741_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3741_write_register(index, IS31FL3741_REG_COMMAND, page);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 342; i += 18) {
|
||||
if (i == 180) {
|
||||
// unlock the command register and select PG1
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND_WRITE_LOCK, IS31FL3741_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND, IS31FL3741_COMMAND_PWM_1);
|
||||
void is31fl3741_write_pwm_buffer(uint8_t index) {
|
||||
is31fl3741_select_page(index, IS31FL3741_COMMAND_PWM_0);
|
||||
|
||||
// Transmit PWM0 registers in 6 transfers of 30 bytes.
|
||||
|
||||
// Iterate over the pwm_buffer_0 contents at 30 byte intervals.
|
||||
for (uint8_t i = 0; i < IS31FL3741_PWM_0_REGISTER_COUNT; i += 30) {
|
||||
#if IS31FL3741_I2C_PERSISTENCE > 0
|
||||
for (uint8_t j = 0; j < IS31FL3741_I2C_PERSISTENCE; j++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer_0 + i, 30, IS31FL3741_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer_0 + i, 30, IS31FL3741_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
g_twi_transfer_buffer[0] = i % 180;
|
||||
memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 18);
|
||||
is31fl3741_select_page(index, IS31FL3741_COMMAND_PWM_1);
|
||||
|
||||
// Transmit PWM1 registers in 9 transfers of 19 bytes.
|
||||
|
||||
// Iterate over the pwm_buffer_1 contents at 19 byte intervals.
|
||||
for (uint8_t i = 0; i < IS31FL3741_PWM_1_REGISTER_COUNT; i += 19) {
|
||||
#if IS31FL3741_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer_1 + i, 19, IS31FL3741_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer_1 + i, 19, IS31FL3741_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
// transfer the left cause the total number is 351
|
||||
g_twi_transfer_buffer[0] = 162;
|
||||
memcpy(g_twi_transfer_buffer + 1, pwm_buffer + 342, 9);
|
||||
|
||||
#if IS31FL3741_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void is31fl3741_init_drivers(void) {
|
||||
i2c_init();
|
||||
|
||||
is31fl3741_init(IS31FL3741_I2C_ADDRESS_1);
|
||||
#if defined(IS31FL3741_I2C_ADDRESS_2)
|
||||
is31fl3741_init(IS31FL3741_I2C_ADDRESS_2);
|
||||
# if defined(IS31FL3741_I2C_ADDRESS_3)
|
||||
is31fl3741_init(IS31FL3741_I2C_ADDRESS_3);
|
||||
# if defined(IS31FL3741_I2C_ADDRESS_4)
|
||||
is31fl3741_init(IS31FL3741_I2C_ADDRESS_4);
|
||||
# endif
|
||||
# endif
|
||||
#if defined(IS31FL3741_SDB_PIN)
|
||||
gpio_set_pin_output(IS31FL3741_SDB_PIN);
|
||||
gpio_write_pin_high(IS31FL3741_SDB_PIN);
|
||||
#endif
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3741_DRIVER_COUNT; i++) {
|
||||
is31fl3741_init(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < IS31FL3741_LED_COUNT; i++) {
|
||||
is31fl3741_set_led_control_register(i, true, true, true);
|
||||
}
|
||||
|
||||
is31fl3741_update_led_control_registers(IS31FL3741_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3741_I2C_ADDRESS_2)
|
||||
is31fl3741_update_led_control_registers(IS31FL3741_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3741_I2C_ADDRESS_3)
|
||||
is31fl3741_update_led_control_registers(IS31FL3741_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3741_I2C_ADDRESS_4)
|
||||
is31fl3741_update_led_control_registers(IS31FL3741_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
for (uint8_t i = 0; i < IS31FL3741_DRIVER_COUNT; i++) {
|
||||
is31fl3741_update_led_control_registers(i);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3741_init(uint8_t addr) {
|
||||
void is31fl3741_init(uint8_t index) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
// Unlock the command register.
|
||||
|
||||
// Unlock the command register.
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND_WRITE_LOCK, IS31FL3741_COMMAND_WRITE_LOCK_MAGIC);
|
||||
|
||||
// Select PG4
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND, IS31FL3741_COMMAND_FUNCTION);
|
||||
is31fl3741_select_page(index, IS31FL3741_COMMAND_FUNCTION);
|
||||
|
||||
// Set to Normal operation
|
||||
is31fl3741_write_register(addr, IS31FL3741_FUNCTION_REG_CONFIGURATION, IS31FL3741_CONFIGURATION);
|
||||
is31fl3741_write_register(index, IS31FL3741_FUNCTION_REG_CONFIGURATION, IS31FL3741_CONFIGURATION);
|
||||
|
||||
// Set Golbal Current Control Register
|
||||
is31fl3741_write_register(addr, IS31FL3741_FUNCTION_REG_GLOBAL_CURRENT, IS31FL3741_GLOBAL_CURRENT);
|
||||
is31fl3741_write_register(index, IS31FL3741_FUNCTION_REG_GLOBAL_CURRENT, IS31FL3741_GLOBAL_CURRENT);
|
||||
// Set Pull up & Down for SWx CSy
|
||||
is31fl3741_write_register(addr, IS31FL3741_FUNCTION_REG_PULLDOWNUP, ((IS31FL3741_CS_PULLDOWN << 4) | IS31FL3741_SW_PULLUP));
|
||||
is31fl3741_write_register(index, IS31FL3741_FUNCTION_REG_PULLDOWNUP, ((IS31FL3741_CS_PULLDOWN << 4) | IS31FL3741_SW_PULLUP));
|
||||
// Set PWM frequency
|
||||
is31fl3741_write_register(addr, IS31FL3741_FUNCTION_REG_PWM_FREQUENCY, (IS31FL3741_PWM_FREQUENCY & 0b1111));
|
||||
is31fl3741_write_register(index, IS31FL3741_FUNCTION_REG_PWM_FREQUENCY, (IS31FL3741_PWM_FREQUENCY & 0b1111));
|
||||
|
||||
// is31fl3741_update_led_scaling_registers(addr, 0xFF, 0xFF, 0xFF);
|
||||
// is31fl3741_update_led_scaling_registers(index, 0xFF, 0xFF, 0xFF);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
wait_ms(10);
|
||||
}
|
||||
|
||||
uint8_t get_pwm_value(uint8_t driver, uint16_t reg) {
|
||||
if (reg & 0x100) {
|
||||
return driver_buffers[driver].pwm_buffer_1[reg & 0xFF];
|
||||
} else {
|
||||
return driver_buffers[driver].pwm_buffer_0[reg];
|
||||
}
|
||||
}
|
||||
|
||||
void set_pwm_value(uint8_t driver, uint16_t reg, uint8_t value) {
|
||||
if (reg & 0x100) {
|
||||
driver_buffers[driver].pwm_buffer_1[reg & 0xFF] = value;
|
||||
} else {
|
||||
driver_buffers[driver].pwm_buffer_0[reg] = value;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3741_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
is31fl3741_led_t led;
|
||||
|
||||
if (index >= 0 && index < IS31FL3741_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3741_leds[index]), sizeof(led));
|
||||
|
||||
if (g_pwm_buffer[led.driver][led.r] == red && g_pwm_buffer[led.driver][led.g] == green && g_pwm_buffer[led.driver][led.b] == blue) {
|
||||
if (get_pwm_value(led.driver, led.r) == red && get_pwm_value(led.driver, led.g) == green && get_pwm_value(led.driver, led.b) == blue) {
|
||||
return;
|
||||
}
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
g_pwm_buffer[led.driver][led.r] = red;
|
||||
g_pwm_buffer[led.driver][led.g] = green;
|
||||
g_pwm_buffer[led.driver][led.b] = blue;
|
||||
|
||||
set_pwm_value(led.driver, led.r, red);
|
||||
set_pwm_value(led.driver, led.g, green);
|
||||
set_pwm_value(led.driver, led.b, blue);
|
||||
driver_buffers[led.driver].pwm_buffer_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,92 +224,67 @@ void is31fl3741_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
|
|||
}
|
||||
}
|
||||
|
||||
void set_scaling_value(uint8_t driver, uint16_t reg, uint8_t value) {
|
||||
if (reg & 0x100) {
|
||||
driver_buffers[driver].scaling_buffer_1[reg & 0xFF] = value;
|
||||
} else {
|
||||
driver_buffers[driver].scaling_buffer_0[reg] = value;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3741_set_led_control_register(uint8_t index, bool red, bool green, bool blue) {
|
||||
is31fl3741_led_t led;
|
||||
memcpy_P(&led, (&g_is31fl3741_leds[index]), sizeof(led));
|
||||
|
||||
if (red) {
|
||||
g_scaling_registers[led.driver][led.r] = 0xFF;
|
||||
} else {
|
||||
g_scaling_registers[led.driver][led.r] = 0x00;
|
||||
}
|
||||
set_scaling_value(led.driver, led.r, red ? 0xFF : 0x00);
|
||||
set_scaling_value(led.driver, led.g, green ? 0xFF : 0x00);
|
||||
set_scaling_value(led.driver, led.b, blue ? 0xFF : 0x00);
|
||||
|
||||
if (green) {
|
||||
g_scaling_registers[led.driver][led.g] = 0xFF;
|
||||
} else {
|
||||
g_scaling_registers[led.driver][led.g] = 0x00;
|
||||
}
|
||||
|
||||
if (blue) {
|
||||
g_scaling_registers[led.driver][led.b] = 0xFF;
|
||||
} else {
|
||||
g_scaling_registers[led.driver][led.b] = 0x00;
|
||||
}
|
||||
|
||||
g_scaling_registers_update_required[led.driver] = true;
|
||||
driver_buffers[led.driver].scaling_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3741_update_pwm_buffers(uint8_t addr, uint8_t index) {
|
||||
if (g_pwm_buffer_update_required[index]) {
|
||||
// unlock the command register and select PG2
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND_WRITE_LOCK, IS31FL3741_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND, IS31FL3741_COMMAND_PWM_0);
|
||||
void is31fl3741_update_pwm_buffers(uint8_t index) {
|
||||
if (driver_buffers[index].pwm_buffer_dirty) {
|
||||
is31fl3741_write_pwm_buffer(index);
|
||||
|
||||
is31fl3741_write_pwm_buffer(addr, g_pwm_buffer[index]);
|
||||
driver_buffers[index].pwm_buffer_dirty = false;
|
||||
}
|
||||
|
||||
g_pwm_buffer_update_required[index] = false;
|
||||
}
|
||||
|
||||
void is31fl3741_set_pwm_buffer(const is31fl3741_led_t *pled, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
g_pwm_buffer[pled->driver][pled->r] = red;
|
||||
g_pwm_buffer[pled->driver][pled->g] = green;
|
||||
g_pwm_buffer[pled->driver][pled->b] = blue;
|
||||
|
||||
g_pwm_buffer_update_required[pled->driver] = true;
|
||||
set_pwm_value(pled->driver, pled->r, red);
|
||||
set_pwm_value(pled->driver, pled->g, green);
|
||||
set_pwm_value(pled->driver, pled->b, blue);
|
||||
driver_buffers[pled->driver].pwm_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3741_update_led_control_registers(uint8_t addr, uint8_t index) {
|
||||
if (g_scaling_registers_update_required[index]) {
|
||||
// unlock the command register and select PG2
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND_WRITE_LOCK, IS31FL3741_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND, IS31FL3741_COMMAND_SCALING_0);
|
||||
void is31fl3741_update_led_control_registers(uint8_t index) {
|
||||
if (driver_buffers[index].scaling_buffer_dirty) {
|
||||
is31fl3741_select_page(index, IS31FL3741_COMMAND_SCALING_0);
|
||||
|
||||
// CS1_SW1 to CS30_SW6 are on PG2
|
||||
for (int i = CS1_SW1; i <= CS30_SW6; ++i) {
|
||||
is31fl3741_write_register(addr, i, g_scaling_registers[index][i]);
|
||||
for (uint8_t i = 0; i < IS31FL3741_SCALING_0_REGISTER_COUNT; i++) {
|
||||
is31fl3741_write_register(index, i, driver_buffers[index].scaling_buffer_0[i]);
|
||||
}
|
||||
|
||||
// unlock the command register and select PG3
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND_WRITE_LOCK, IS31FL3741_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND, IS31FL3741_COMMAND_SCALING_1);
|
||||
is31fl3741_select_page(index, IS31FL3741_COMMAND_SCALING_1);
|
||||
|
||||
// CS1_SW7 to CS39_SW9 are on PG3
|
||||
for (int i = CS1_SW7; i <= CS39_SW9; ++i) {
|
||||
is31fl3741_write_register(addr, i - CS1_SW7, g_scaling_registers[index][i]);
|
||||
for (uint8_t i = 0; i < IS31FL3741_SCALING_1_REGISTER_COUNT; i++) {
|
||||
is31fl3741_write_register(index, i, driver_buffers[index].scaling_buffer_1[i]);
|
||||
}
|
||||
|
||||
g_scaling_registers_update_required[index] = false;
|
||||
driver_buffers[index].scaling_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3741_set_scaling_registers(const is31fl3741_led_t *pled, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
g_scaling_registers[pled->driver][pled->r] = red;
|
||||
g_scaling_registers[pled->driver][pled->g] = green;
|
||||
g_scaling_registers[pled->driver][pled->b] = blue;
|
||||
|
||||
g_scaling_registers_update_required[pled->driver] = true;
|
||||
set_scaling_value(pled->driver, pled->r, red);
|
||||
set_scaling_value(pled->driver, pled->g, green);
|
||||
set_scaling_value(pled->driver, pled->b, blue);
|
||||
driver_buffers[pled->driver].scaling_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3741_flush(void) {
|
||||
is31fl3741_update_pwm_buffers(IS31FL3741_I2C_ADDRESS_1, 0);
|
||||
#if defined(IS31FL3741_I2C_ADDRESS_2)
|
||||
is31fl3741_update_pwm_buffers(IS31FL3741_I2C_ADDRESS_2, 1);
|
||||
# if defined(IS31FL3741_I2C_ADDRESS_3)
|
||||
is31fl3741_update_pwm_buffers(IS31FL3741_I2C_ADDRESS_3, 2);
|
||||
# if defined(IS31FL3741_I2C_ADDRESS_4)
|
||||
is31fl3741_update_pwm_buffers(IS31FL3741_I2C_ADDRESS_4, 3);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
for (uint8_t i = 0; i < IS31FL3741_DRIVER_COUNT; i++) {
|
||||
is31fl3741_update_pwm_buffers(i);
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,299 +0,0 @@
|
|||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2020 MelGeek
|
||||
* Copyright 2021 MasterSpoon
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// This is a 7-bit address, that gets left-shifted and bit 0
|
||||
// set to 0 for write, 1 for read (as per I2C protocol)
|
||||
// The address will vary depending on your wiring:
|
||||
// 00 <-> GND
|
||||
// 01 <-> SCL
|
||||
// 10 <-> SDA
|
||||
// 11 <-> VCC
|
||||
// ADDR represents A1:A0 of the 7-bit address.
|
||||
// The result is: 0b01100(ADDR)
|
||||
#ifndef DRIVER_ADDR_1
|
||||
# define DRIVER_ADDR_1 0b0110000
|
||||
#endif
|
||||
|
||||
// Command Registers
|
||||
#define ISSI_COMMANDREGISTER_WRITELOCK 0xFE
|
||||
#define ISSI_COMMANDREGISTER 0xFD
|
||||
#define ISSI_IDREGISTER 0xFC
|
||||
#define ISSI_REGISTER_UNLOCK 0xC5
|
||||
|
||||
// Response Registers
|
||||
#define ISSI_PAGE_PWM 0x00
|
||||
#define ISSI_PAGE_SCALING 0x02
|
||||
#define ISSI_PAGE_FUNCTION 0x04
|
||||
|
||||
// Registers under Function Register
|
||||
#define ISSI_REG_CONFIGURATION 0x00
|
||||
#define ISSI_REG_GLOBALCURRENT 0x01
|
||||
#define ISSI_REG_PULLDOWNUP 0x02
|
||||
#define ISSI_REG_SSR 0x41
|
||||
#define ISSI_REG_RESET 0x3F
|
||||
#define ISSI_REG_PWM_SET 0x36
|
||||
|
||||
// Set defaults for Function Registers
|
||||
#ifndef ISSI_CONFIGURATION
|
||||
# define ISSI_CONFIGURATION 0x31
|
||||
#endif
|
||||
#ifndef ISSI_GLOBALCURRENT
|
||||
# define ISSI_GLOBALCURRENT 0xFF
|
||||
#endif
|
||||
#ifndef ISSI_PULLDOWNUP
|
||||
# define ISSI_PULLDOWNUP 0x55
|
||||
#endif
|
||||
#ifndef ISSI_PWM_SET
|
||||
# define ISSI_PWM_SET 0x00
|
||||
#endif
|
||||
|
||||
// Set defaults for Spread Spectrum Register
|
||||
#ifndef ISSI_SSR_1
|
||||
# define ISSI_SSR_1 0x00
|
||||
#endif
|
||||
#ifndef ISSI_SSR_2
|
||||
# define ISSI_SSR_2 0x00
|
||||
#endif
|
||||
#ifndef ISSI_SSR_3
|
||||
# define ISSI_SSR_3 0x00
|
||||
#endif
|
||||
#ifndef ISSI_SSR_4
|
||||
# define ISSI_SSR_4 0x00
|
||||
#endif
|
||||
|
||||
// Set defaults for Scaling registers
|
||||
#ifndef ISSI_SCAL_RED
|
||||
# define ISSI_SCAL_RED 0xFF
|
||||
#endif
|
||||
#ifndef ISSI_SCAL_BLUE
|
||||
# define ISSI_SCAL_BLUE 0xFF
|
||||
#endif
|
||||
#ifndef ISSI_SCAL_GREEN
|
||||
# define ISSI_SCAL_GREEN 0xFF
|
||||
#endif
|
||||
#define ISSI_SCAL_RED_OFF 0x00
|
||||
#define ISSI_SCAL_GREEN_OFF 0x00
|
||||
#define ISSI_SCAL_BLUE_OFF 0x00
|
||||
|
||||
#ifndef ISSI_SCAL_LED
|
||||
# define ISSI_SCAL_LED 0xFF
|
||||
#endif
|
||||
#define ISSI_SCAL_LED_OFF 0x00
|
||||
|
||||
// Set buffer sizes
|
||||
#define ISSI_MAX_LEDS 180
|
||||
#define ISSI_SCALING_SIZE 180
|
||||
#define ISSI_PWM_TRF_SIZE 18
|
||||
#define ISSI_SCALING_TRF_SIZE 18
|
||||
|
||||
// Location of 1st bit for PWM and Scaling registers
|
||||
#define ISSI_PWM_REG_1ST 0x00
|
||||
#define ISSI_SCL_REG_1ST 0x00
|
||||
|
||||
// Map CS SW locations to order in PWM / Scaling buffers
|
||||
// This matches the ORDER in the Datasheet Register not the POSITION
|
||||
// It will always count from 0x00 to (ISSI_MAX_LEDS - 1)
|
||||
#define CS1_SW1 0x00
|
||||
#define CS2_SW1 0x01
|
||||
#define CS3_SW1 0x02
|
||||
#define CS4_SW1 0x03
|
||||
#define CS5_SW1 0x04
|
||||
#define CS6_SW1 0x05
|
||||
#define CS7_SW1 0x06
|
||||
#define CS8_SW1 0x07
|
||||
#define CS9_SW1 0x08
|
||||
#define CS10_SW1 0x09
|
||||
#define CS11_SW1 0x0A
|
||||
#define CS12_SW1 0x0B
|
||||
#define CS13_SW1 0x0C
|
||||
#define CS14_SW1 0x0D
|
||||
#define CS15_SW1 0x0E
|
||||
#define CS16_SW1 0x0F
|
||||
#define CS17_SW1 0x10
|
||||
#define CS18_SW1 0x11
|
||||
#define CS19_SW1 0x12
|
||||
#define CS20_SW1 0x13
|
||||
#define CS21_SW1 0x14
|
||||
#define CS22_SW1 0x15
|
||||
#define CS23_SW1 0x16
|
||||
#define CS24_SW1 0x17
|
||||
#define CS25_SW1 0x18
|
||||
#define CS26_SW1 0x19
|
||||
#define CS27_SW1 0x1A
|
||||
#define CS28_SW1 0x1B
|
||||
#define CS29_SW1 0x1C
|
||||
#define CS30_SW1 0x1D
|
||||
|
||||
#define CS1_SW2 0x1E
|
||||
#define CS2_SW2 0x1F
|
||||
#define CS3_SW2 0x20
|
||||
#define CS4_SW2 0x21
|
||||
#define CS5_SW2 0x22
|
||||
#define CS6_SW2 0x23
|
||||
#define CS7_SW2 0x24
|
||||
#define CS8_SW2 0x25
|
||||
#define CS9_SW2 0x26
|
||||
#define CS10_SW2 0x27
|
||||
#define CS11_SW2 0x28
|
||||
#define CS12_SW2 0x29
|
||||
#define CS13_SW2 0x2A
|
||||
#define CS14_SW2 0x2B
|
||||
#define CS15_SW2 0x2C
|
||||
#define CS16_SW2 0x2D
|
||||
#define CS17_SW2 0x2E
|
||||
#define CS18_SW2 0x2F
|
||||
#define CS19_SW2 0x30
|
||||
#define CS20_SW2 0x31
|
||||
#define CS21_SW2 0x32
|
||||
#define CS22_SW2 0x33
|
||||
#define CS23_SW2 0x34
|
||||
#define CS24_SW2 0x35
|
||||
#define CS25_SW2 0x36
|
||||
#define CS26_SW2 0x37
|
||||
#define CS27_SW2 0x38
|
||||
#define CS28_SW2 0x39
|
||||
#define CS29_SW2 0x3A
|
||||
#define CS30_SW2 0x3B
|
||||
|
||||
#define CS1_SW3 0x3C
|
||||
#define CS2_SW3 0x3D
|
||||
#define CS3_SW3 0x3E
|
||||
#define CS4_SW3 0x3F
|
||||
#define CS5_SW3 0x40
|
||||
#define CS6_SW3 0x41
|
||||
#define CS7_SW3 0x42
|
||||
#define CS8_SW3 0x43
|
||||
#define CS9_SW3 0x44
|
||||
#define CS10_SW3 0x45
|
||||
#define CS11_SW3 0x46
|
||||
#define CS12_SW3 0x47
|
||||
#define CS13_SW3 0x48
|
||||
#define CS14_SW3 0x49
|
||||
#define CS15_SW3 0x4A
|
||||
#define CS16_SW3 0x4B
|
||||
#define CS17_SW3 0x4C
|
||||
#define CS18_SW3 0x4D
|
||||
#define CS19_SW3 0x4E
|
||||
#define CS20_SW3 0x4F
|
||||
#define CS21_SW3 0x50
|
||||
#define CS22_SW3 0x51
|
||||
#define CS23_SW3 0x52
|
||||
#define CS24_SW3 0x53
|
||||
#define CS25_SW3 0x54
|
||||
#define CS26_SW3 0x55
|
||||
#define CS27_SW3 0x56
|
||||
#define CS28_SW3 0x57
|
||||
#define CS29_SW3 0x58
|
||||
#define CS30_SW3 0x59
|
||||
|
||||
#define CS1_SW4 0x5A
|
||||
#define CS2_SW4 0x5B
|
||||
#define CS3_SW4 0x5C
|
||||
#define CS4_SW4 0x5D
|
||||
#define CS5_SW4 0x5E
|
||||
#define CS6_SW4 0x5F
|
||||
#define CS7_SW4 0x60
|
||||
#define CS8_SW4 0x61
|
||||
#define CS9_SW4 0x62
|
||||
#define CS10_SW4 0x63
|
||||
#define CS11_SW4 0x64
|
||||
#define CS12_SW4 0x65
|
||||
#define CS13_SW4 0x66
|
||||
#define CS14_SW4 0x67
|
||||
#define CS15_SW4 0x68
|
||||
#define CS16_SW4 0x69
|
||||
#define CS17_SW4 0x6A
|
||||
#define CS18_SW4 0x6B
|
||||
#define CS19_SW4 0x6C
|
||||
#define CS20_SW4 0x6D
|
||||
#define CS21_SW4 0x6E
|
||||
#define CS22_SW4 0x6F
|
||||
#define CS23_SW4 0x70
|
||||
#define CS24_SW4 0x71
|
||||
#define CS25_SW4 0x72
|
||||
#define CS26_SW4 0x73
|
||||
#define CS27_SW4 0x74
|
||||
#define CS28_SW4 0x75
|
||||
#define CS29_SW4 0x76
|
||||
#define CS30_SW4 0x77
|
||||
|
||||
#define CS1_SW5 0x78
|
||||
#define CS2_SW5 0x79
|
||||
#define CS3_SW5 0x7A
|
||||
#define CS4_SW5 0x7B
|
||||
#define CS5_SW5 0x7C
|
||||
#define CS6_SW5 0x7D
|
||||
#define CS7_SW5 0x7E
|
||||
#define CS8_SW5 0x7F
|
||||
#define CS9_SW5 0x80
|
||||
#define CS10_SW5 0x81
|
||||
#define CS11_SW5 0x82
|
||||
#define CS12_SW5 0x83
|
||||
#define CS13_SW5 0x84
|
||||
#define CS14_SW5 0x85
|
||||
#define CS15_SW5 0x86
|
||||
#define CS16_SW5 0x87
|
||||
#define CS17_SW5 0x88
|
||||
#define CS18_SW5 0x89
|
||||
#define CS19_SW5 0x8A
|
||||
#define CS20_SW5 0x8B
|
||||
#define CS21_SW5 0x8C
|
||||
#define CS22_SW5 0x8D
|
||||
#define CS23_SW5 0x8E
|
||||
#define CS24_SW5 0x8F
|
||||
#define CS25_SW5 0x90
|
||||
#define CS26_SW5 0x91
|
||||
#define CS27_SW5 0x92
|
||||
#define CS28_SW5 0x93
|
||||
#define CS29_SW5 0x94
|
||||
#define CS30_SW5 0x95
|
||||
|
||||
#define CS1_SW6 0x96
|
||||
#define CS2_SW6 0x97
|
||||
#define CS3_SW6 0x98
|
||||
#define CS4_SW6 0x99
|
||||
#define CS5_SW6 0x9A
|
||||
#define CS6_SW6 0x9B
|
||||
#define CS7_SW6 0x9C
|
||||
#define CS8_SW6 0x9D
|
||||
#define CS9_SW6 0x9E
|
||||
#define CS10_SW6 0x9F
|
||||
#define CS11_SW6 0xA0
|
||||
#define CS12_SW6 0xA1
|
||||
#define CS13_SW6 0xA2
|
||||
#define CS14_SW6 0xA3
|
||||
#define CS15_SW6 0xA4
|
||||
#define CS16_SW6 0xA5
|
||||
#define CS17_SW6 0xA6
|
||||
#define CS18_SW6 0xA7
|
||||
#define CS19_SW6 0xA8
|
||||
#define CS20_SW6 0xA9
|
||||
#define CS21_SW6 0xAA
|
||||
#define CS22_SW6 0xAB
|
||||
#define CS23_SW6 0xAC
|
||||
#define CS24_SW6 0xAD
|
||||
#define CS25_SW6 0xAE
|
||||
#define CS26_SW6 0xAF
|
||||
#define CS27_SW6 0xB0
|
||||
#define CS28_SW6 0xB1
|
||||
#define CS29_SW6 0xB2
|
||||
#define CS30_SW6 0xB3
|
221
drivers/led/issi/is31fl3742a-mono.c
Normal file
221
drivers/led/issi/is31fl3742a-mono.c
Normal file
|
@ -0,0 +1,221 @@
|
|||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2020 MelGeek
|
||||
* Copyright 2021 MasterSpoon
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "is31fl3742a-mono.h"
|
||||
#include "i2c_master.h"
|
||||
#include "gpio.h"
|
||||
#include "wait.h"
|
||||
|
||||
#define IS31FL3742A_PWM_REGISTER_COUNT 180
|
||||
#define IS31FL3742A_SCALING_REGISTER_COUNT 180
|
||||
|
||||
#ifndef IS31FL3742A_I2C_TIMEOUT
|
||||
# define IS31FL3742A_I2C_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3742A_I2C_PERSISTENCE
|
||||
# define IS31FL3742A_I2C_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3742A_CONFIGURATION
|
||||
# define IS31FL3742A_CONFIGURATION 0x31
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3742A_PWM_FREQUENCY
|
||||
# define IS31FL3742A_PWM_FREQUENCY IS31FL3742A_PWM_FREQUENCY_29K_HZ
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3742A_SW_PULLDOWN
|
||||
# define IS31FL3742A_SW_PULLDOWN IS31FL3742A_PDR_8K_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3742A_CS_PULLUP
|
||||
# define IS31FL3742A_CS_PULLUP IS31FL3742A_PUR_8K_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3742A_GLOBAL_CURRENT
|
||||
# define IS31FL3742A_GLOBAL_CURRENT 0xFF
|
||||
#endif
|
||||
|
||||
const uint8_t i2c_addresses[IS31FL3742A_DRIVER_COUNT] = {
|
||||
IS31FL3742A_I2C_ADDRESS_1,
|
||||
#ifdef IS31FL3742A_I2C_ADDRESS_2
|
||||
IS31FL3742A_I2C_ADDRESS_2,
|
||||
# ifdef IS31FL3742A_I2C_ADDRESS_3
|
||||
IS31FL3742A_I2C_ADDRESS_3,
|
||||
# ifdef IS31FL3742A_I2C_ADDRESS_4
|
||||
IS31FL3742A_I2C_ADDRESS_4,
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct is31fl3742a_driver_t {
|
||||
uint8_t pwm_buffer[IS31FL3742A_PWM_REGISTER_COUNT];
|
||||
bool pwm_buffer_dirty;
|
||||
uint8_t scaling_buffer[IS31FL3742A_SCALING_REGISTER_COUNT];
|
||||
bool scaling_buffer_dirty;
|
||||
} PACKED is31fl3742a_driver_t;
|
||||
|
||||
is31fl3742a_driver_t driver_buffers[IS31FL3742A_DRIVER_COUNT] = {{
|
||||
.pwm_buffer = {0},
|
||||
.pwm_buffer_dirty = false,
|
||||
.scaling_buffer = {0},
|
||||
.scaling_buffer_dirty = false,
|
||||
}};
|
||||
|
||||
void is31fl3742a_write_register(uint8_t index, uint8_t reg, uint8_t data) {
|
||||
#if IS31FL3742A_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3742A_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3742A_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3742A_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3742a_select_page(uint8_t index, uint8_t page) {
|
||||
is31fl3742a_write_register(index, IS31FL3742A_REG_COMMAND_WRITE_LOCK, IS31FL3742A_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3742a_write_register(index, IS31FL3742A_REG_COMMAND, page);
|
||||
}
|
||||
|
||||
void is31fl3742a_write_pwm_buffer(uint8_t index) {
|
||||
// Assumes page 0 is already selected.
|
||||
// Transmit PWM registers in 6 transfers of 30 bytes.
|
||||
|
||||
// Iterate over the pwm_buffer contents at 30 byte intervals.
|
||||
for (uint8_t i = 0; i < IS31FL3742A_PWM_REGISTER_COUNT; i += 30) {
|
||||
#if IS31FL3742A_I2C_PERSISTENCE > 0
|
||||
for (uint8_t j = 0; j < IS31FL3742A_I2C_PERSISTENCE; j++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer + i, 30, IS31FL3742A_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer + i, 30, IS31FL3742A_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3742a_init_drivers(void) {
|
||||
i2c_init();
|
||||
|
||||
#if defined(IS31FL3742A_SDB_PIN)
|
||||
gpio_set_pin_output(IS31FL3742A_SDB_PIN);
|
||||
gpio_write_pin_high(IS31FL3742A_SDB_PIN);
|
||||
#endif
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3742A_DRIVER_COUNT; i++) {
|
||||
is31fl3742a_init(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < IS31FL3742A_LED_COUNT; i++) {
|
||||
is31fl3742a_set_scaling_register(i, 0xFF);
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3742A_DRIVER_COUNT; i++) {
|
||||
is31fl3742a_update_scaling_registers(i);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3742a_init(uint8_t index) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
|
||||
is31fl3742a_select_page(index, IS31FL3742A_COMMAND_SCALING);
|
||||
|
||||
// Turn off all LEDs.
|
||||
for (uint8_t i = 0; i < IS31FL3742A_SCALING_REGISTER_COUNT; i++) {
|
||||
is31fl3742a_write_register(index, i, 0x00);
|
||||
}
|
||||
|
||||
is31fl3742a_select_page(index, IS31FL3742A_COMMAND_PWM);
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3742A_PWM_REGISTER_COUNT; i++) {
|
||||
is31fl3742a_write_register(index, i, 0x00);
|
||||
}
|
||||
|
||||
is31fl3742a_select_page(index, IS31FL3742A_COMMAND_FUNCTION);
|
||||
|
||||
is31fl3742a_write_register(index, IS31FL3742A_FUNCTION_REG_PULLDOWNUP, (IS31FL3742A_SW_PULLDOWN << 4) | IS31FL3742A_CS_PULLUP);
|
||||
is31fl3742a_write_register(index, IS31FL3742A_FUNCTION_REG_GLOBAL_CURRENT, IS31FL3742A_GLOBAL_CURRENT);
|
||||
is31fl3742a_write_register(index, IS31FL3742A_FUNCTION_REG_PWM_FREQUENCY, (IS31FL3742A_PWM_FREQUENCY & 0b0111));
|
||||
is31fl3742a_write_register(index, IS31FL3742A_FUNCTION_REG_CONFIGURATION, IS31FL3742A_CONFIGURATION);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
wait_ms(10);
|
||||
}
|
||||
|
||||
void is31fl3742a_set_value(int index, uint8_t value) {
|
||||
is31fl3742a_led_t led;
|
||||
|
||||
if (index >= 0 && index < IS31FL3742A_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3742a_leds[index]), sizeof(led));
|
||||
|
||||
if (driver_buffers[led.driver].pwm_buffer[led.v] == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
driver_buffers[led.driver].pwm_buffer[led.v] = value;
|
||||
driver_buffers[led.driver].pwm_buffer_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3742a_set_value_all(uint8_t value) {
|
||||
for (int i = 0; i < IS31FL3742A_LED_COUNT; i++) {
|
||||
is31fl3742a_set_value(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3742a_set_scaling_register(uint8_t index, uint8_t value) {
|
||||
is31fl3742a_led_t led;
|
||||
memcpy_P(&led, (&g_is31fl3742a_leds[index]), sizeof(led));
|
||||
|
||||
driver_buffers[led.driver].scaling_buffer[led.v] = value;
|
||||
driver_buffers[led.driver].scaling_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3742a_update_pwm_buffers(uint8_t index) {
|
||||
if (driver_buffers[index].pwm_buffer_dirty) {
|
||||
is31fl3742a_select_page(index, IS31FL3742A_COMMAND_PWM);
|
||||
|
||||
is31fl3742a_write_pwm_buffer(index);
|
||||
|
||||
driver_buffers[index].pwm_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3742a_update_scaling_registers(uint8_t index) {
|
||||
if (driver_buffers[index].scaling_buffer_dirty) {
|
||||
is31fl3742a_select_page(index, IS31FL3742A_COMMAND_SCALING);
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3742A_SCALING_REGISTER_COUNT; i++) {
|
||||
is31fl3742a_write_register(index, i, driver_buffers[index].scaling_buffer[i]);
|
||||
}
|
||||
|
||||
driver_buffers[index].scaling_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3742a_flush(void) {
|
||||
for (uint8_t i = 0; i < IS31FL3742A_DRIVER_COUNT; i++) {
|
||||
is31fl3742a_update_pwm_buffers(i);
|
||||
}
|
||||
}
|
296
drivers/led/issi/is31fl3742a-mono.h
Normal file
296
drivers/led/issi/is31fl3742a-mono.h
Normal file
|
@ -0,0 +1,296 @@
|
|||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2020 MelGeek
|
||||
* Copyright 2021 MasterSpoon
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "progmem.h"
|
||||
#include "util.h"
|
||||
|
||||
#define IS31FL3742A_REG_INTERRUPT_MASK 0xF0
|
||||
#define IS31FL3742A_REG_INTERRUPT_STATUS 0xF1
|
||||
#define IS31FL3742A_REG_ID 0xFC
|
||||
|
||||
#define IS31FL3742A_REG_COMMAND 0xFD
|
||||
|
||||
#define IS31FL3742A_COMMAND_PWM 0x00
|
||||
#define IS31FL3742A_COMMAND_SCALING 0x02
|
||||
#define IS31FL3742A_COMMAND_FUNCTION 0x04
|
||||
|
||||
#define IS31FL3742A_FUNCTION_REG_CONFIGURATION 0x00
|
||||
#define IS31FL3742A_FUNCTION_REG_GLOBAL_CURRENT 0x01
|
||||
#define IS31FL3742A_FUNCTION_REG_PULLDOWNUP 0x02
|
||||
#define IS31FL3742A_FUNCTION_REG_PWM_FREQUENCY 0x36
|
||||
#define IS31FL3742A_FUNCTION_REG_RESET 0x3F
|
||||
#define IS31FL3742A_FUNCTION_REG_SPREAD_SPECTRUM 0x41
|
||||
|
||||
#define IS31FL3742A_REG_COMMAND_WRITE_LOCK 0xFE
|
||||
#define IS31FL3742A_COMMAND_WRITE_LOCK_MAGIC 0xC5
|
||||
|
||||
#define IS31FL3742A_I2C_ADDRESS_GND 0x30
|
||||
#define IS31FL3742A_I2C_ADDRESS_SCL 0x31
|
||||
#define IS31FL3742A_I2C_ADDRESS_SDA 0x32
|
||||
#define IS31FL3742A_I2C_ADDRESS_VCC 0x33
|
||||
|
||||
#if defined(LED_MATRIX_IS31FL3742A)
|
||||
# define IS31FL3742A_LED_COUNT LED_MATRIX_LED_COUNT
|
||||
#endif
|
||||
|
||||
#if defined(IS31FL3742A_I2C_ADDRESS_4)
|
||||
# define IS31FL3742A_DRIVER_COUNT 4
|
||||
#elif defined(IS31FL3742A_I2C_ADDRESS_3)
|
||||
# define IS31FL3742A_DRIVER_COUNT 3
|
||||
#elif defined(IS31FL3742A_I2C_ADDRESS_2)
|
||||
# define IS31FL3742A_DRIVER_COUNT 2
|
||||
#elif defined(IS31FL3742A_I2C_ADDRESS_1)
|
||||
# define IS31FL3742A_DRIVER_COUNT 1
|
||||
#endif
|
||||
|
||||
typedef struct is31fl3742a_led_t {
|
||||
uint8_t driver : 2;
|
||||
uint8_t v;
|
||||
} PACKED is31fl3742a_led_t;
|
||||
|
||||
extern const is31fl3742a_led_t PROGMEM g_is31fl3742a_leds[IS31FL3742A_LED_COUNT];
|
||||
|
||||
void is31fl3742a_init_drivers(void);
|
||||
void is31fl3742a_init(uint8_t index);
|
||||
void is31fl3742a_write_register(uint8_t index, uint8_t reg, uint8_t data);
|
||||
void is31fl3742a_select_page(uint8_t index, uint8_t page);
|
||||
|
||||
void is31fl3742a_set_value(int index, uint8_t value);
|
||||
void is31fl3742a_set_value_all(uint8_t value);
|
||||
|
||||
void is31fl3742a_set_scaling_register(uint8_t index, uint8_t value);
|
||||
|
||||
void is31fl3742a_update_pwm_buffers(uint8_t index);
|
||||
void is31fl3742a_update_scaling_registers(uint8_t index);
|
||||
|
||||
void is31fl3742a_flush(void);
|
||||
|
||||
#define IS31FL3742A_PDR_0_OHM 0b000 // No pull-down resistor
|
||||
#define IS31FL3742A_PDR_0K5_OHM 0b001 // 0.5 kOhm resistor
|
||||
#define IS31FL3742A_PDR_1K_OHM 0b010 // 1 kOhm resistor
|
||||
#define IS31FL3742A_PDR_2K_OHM 0b011 // 2 kOhm resistor
|
||||
#define IS31FL3742A_PDR_4K_OHM 0b100 // 4 kOhm resistor
|
||||
#define IS31FL3742A_PDR_8K_OHM 0b101 // 8 kOhm resistor
|
||||
#define IS31FL3742A_PDR_16K_OHM 0b110 // 16 kOhm resistor
|
||||
#define IS31FL3742A_PDR_32K_OHM 0b111 // 32 kOhm resistor
|
||||
|
||||
#define IS31FL3742A_PUR_0_OHM 0b000 // No pull-up resistor
|
||||
#define IS31FL3742A_PUR_0K5_OHM 0b001 // 0.5 kOhm resistor
|
||||
#define IS31FL3742A_PUR_1K_OHM 0b010 // 1 kOhm resistor
|
||||
#define IS31FL3742A_PUR_2K_OHM 0b011 // 2 kOhm resistor
|
||||
#define IS31FL3742A_PUR_4K_OHM 0b100 // 4 kOhm resistor
|
||||
#define IS31FL3742A_PUR_8K_OHM 0b101 // 8 kOhm resistor
|
||||
#define IS31FL3742A_PUR_16K_OHM 0b110 // 16 kOhm resistor
|
||||
#define IS31FL3742A_PUR_32K_OHM 0b111 // 32 kOhm resistor
|
||||
|
||||
#define IS31FL3742A_PWM_FREQUENCY_29K_HZ 0b0000
|
||||
#define IS31FL3742A_PWM_FREQUENCY_3K6_HZ 0b0011
|
||||
#define IS31FL3742A_PWM_FREQUENCY_1K8_HZ 0b0111
|
||||
#define IS31FL3742A_PWM_FREQUENCY_900_HZ 0b1011
|
||||
|
||||
#define SW1_CS1 0x00
|
||||
#define SW1_CS2 0x01
|
||||
#define SW1_CS3 0x02
|
||||
#define SW1_CS4 0x03
|
||||
#define SW1_CS5 0x04
|
||||
#define SW1_CS6 0x05
|
||||
#define SW1_CS7 0x06
|
||||
#define SW1_CS8 0x07
|
||||
#define SW1_CS9 0x08
|
||||
#define SW1_CS10 0x09
|
||||
#define SW1_CS11 0x0A
|
||||
#define SW1_CS12 0x0B
|
||||
#define SW1_CS13 0x0C
|
||||
#define SW1_CS14 0x0D
|
||||
#define SW1_CS15 0x0E
|
||||
#define SW1_CS16 0x0F
|
||||
#define SW1_CS17 0x10
|
||||
#define SW1_CS18 0x11
|
||||
#define SW1_CS19 0x12
|
||||
#define SW1_CS20 0x13
|
||||
#define SW1_CS21 0x14
|
||||
#define SW1_CS22 0x15
|
||||
#define SW1_CS23 0x16
|
||||
#define SW1_CS24 0x17
|
||||
#define SW1_CS25 0x18
|
||||
#define SW1_CS26 0x19
|
||||
#define SW1_CS27 0x1A
|
||||
#define SW1_CS28 0x1B
|
||||
#define SW1_CS29 0x1C
|
||||
#define SW1_CS30 0x1D
|
||||
|
||||
#define SW2_CS1 0x1E
|
||||
#define SW2_CS2 0x1F
|
||||
#define SW2_CS3 0x20
|
||||
#define SW2_CS4 0x21
|
||||
#define SW2_CS5 0x22
|
||||
#define SW2_CS6 0x23
|
||||
#define SW2_CS7 0x24
|
||||
#define SW2_CS8 0x25
|
||||
#define SW2_CS9 0x26
|
||||
#define SW2_CS10 0x27
|
||||
#define SW2_CS11 0x28
|
||||
#define SW2_CS12 0x29
|
||||
#define SW2_CS13 0x2A
|
||||
#define SW2_CS14 0x2B
|
||||
#define SW2_CS15 0x2C
|
||||
#define SW2_CS16 0x2D
|
||||
#define SW2_CS17 0x2E
|
||||
#define SW2_CS18 0x2F
|
||||
#define SW2_CS19 0x30
|
||||
#define SW2_CS20 0x31
|
||||
#define SW2_CS21 0x32
|
||||
#define SW2_CS22 0x33
|
||||
#define SW2_CS23 0x34
|
||||
#define SW2_CS24 0x35
|
||||
#define SW2_CS25 0x36
|
||||
#define SW2_CS26 0x37
|
||||
#define SW2_CS27 0x38
|
||||
#define SW2_CS28 0x39
|
||||
#define SW2_CS29 0x3A
|
||||
#define SW2_CS30 0x3B
|
||||
|
||||
#define SW3_CS1 0x3C
|
||||
#define SW3_CS2 0x3D
|
||||
#define SW3_CS3 0x3E
|
||||
#define SW3_CS4 0x3F
|
||||
#define SW3_CS5 0x40
|
||||
#define SW3_CS6 0x41
|
||||
#define SW3_CS7 0x42
|
||||
#define SW3_CS8 0x43
|
||||
#define SW3_CS9 0x44
|
||||
#define SW3_CS10 0x45
|
||||
#define SW3_CS11 0x46
|
||||
#define SW3_CS12 0x47
|
||||
#define SW3_CS13 0x48
|
||||
#define SW3_CS14 0x49
|
||||
#define SW3_CS15 0x4A
|
||||
#define SW3_CS16 0x4B
|
||||
#define SW3_CS17 0x4C
|
||||
#define SW3_CS18 0x4D
|
||||
#define SW3_CS19 0x4E
|
||||
#define SW3_CS20 0x4F
|
||||
#define SW3_CS21 0x50
|
||||
#define SW3_CS22 0x51
|
||||
#define SW3_CS23 0x52
|
||||
#define SW3_CS24 0x53
|
||||
#define SW3_CS25 0x54
|
||||
#define SW3_CS26 0x55
|
||||
#define SW3_CS27 0x56
|
||||
#define SW3_CS28 0x57
|
||||
#define SW3_CS29 0x58
|
||||
#define SW3_CS30 0x59
|
||||
|
||||
#define SW4_CS1 0x5A
|
||||
#define SW4_CS2 0x5B
|
||||
#define SW4_CS3 0x5C
|
||||
#define SW4_CS4 0x5D
|
||||
#define SW4_CS5 0x5E
|
||||
#define SW4_CS6 0x5F
|
||||
#define SW4_CS7 0x60
|
||||
#define SW4_CS8 0x61
|
||||
#define SW4_CS9 0x62
|
||||
#define SW4_CS10 0x63
|
||||
#define SW4_CS11 0x64
|
||||
#define SW4_CS12 0x65
|
||||
#define SW4_CS13 0x66
|
||||
#define SW4_CS14 0x67
|
||||
#define SW4_CS15 0x68
|
||||
#define SW4_CS16 0x69
|
||||
#define SW4_CS17 0x6A
|
||||
#define SW4_CS18 0x6B
|
||||
#define SW4_CS19 0x6C
|
||||
#define SW4_CS20 0x6D
|
||||
#define SW4_CS21 0x6E
|
||||
#define SW4_CS22 0x6F
|
||||
#define SW4_CS23 0x70
|
||||
#define SW4_CS24 0x71
|
||||
#define SW4_CS25 0x72
|
||||
#define SW4_CS26 0x73
|
||||
#define SW4_CS27 0x74
|
||||
#define SW4_CS28 0x75
|
||||
#define SW4_CS29 0x76
|
||||
#define SW4_CS30 0x77
|
||||
|
||||
#define SW5_CS1 0x78
|
||||
#define SW5_CS2 0x79
|
||||
#define SW5_CS3 0x7A
|
||||
#define SW5_CS4 0x7B
|
||||
#define SW5_CS5 0x7C
|
||||
#define SW5_CS6 0x7D
|
||||
#define SW5_CS7 0x7E
|
||||
#define SW5_CS8 0x7F
|
||||
#define SW5_CS9 0x80
|
||||
#define SW5_CS10 0x81
|
||||
#define SW5_CS11 0x82
|
||||
#define SW5_CS12 0x83
|
||||
#define SW5_CS13 0x84
|
||||
#define SW5_CS14 0x85
|
||||
#define SW5_CS15 0x86
|
||||
#define SW5_CS16 0x87
|
||||
#define SW5_CS17 0x88
|
||||
#define SW5_CS18 0x89
|
||||
#define SW5_CS19 0x8A
|
||||
#define SW5_CS20 0x8B
|
||||
#define SW5_CS21 0x8C
|
||||
#define SW5_CS22 0x8D
|
||||
#define SW5_CS23 0x8E
|
||||
#define SW5_CS24 0x8F
|
||||
#define SW5_CS25 0x90
|
||||
#define SW5_CS26 0x91
|
||||
#define SW5_CS27 0x92
|
||||
#define SW5_CS28 0x93
|
||||
#define SW5_CS29 0x94
|
||||
#define SW5_CS30 0x95
|
||||
|
||||
#define SW6_CS1 0x96
|
||||
#define SW6_CS2 0x97
|
||||
#define SW6_CS3 0x98
|
||||
#define SW6_CS4 0x99
|
||||
#define SW6_CS5 0x9A
|
||||
#define SW6_CS6 0x9B
|
||||
#define SW6_CS7 0x9C
|
||||
#define SW6_CS8 0x9D
|
||||
#define SW6_CS9 0x9E
|
||||
#define SW6_CS10 0x9F
|
||||
#define SW6_CS11 0xA0
|
||||
#define SW6_CS12 0xA1
|
||||
#define SW6_CS13 0xA2
|
||||
#define SW6_CS14 0xA3
|
||||
#define SW6_CS15 0xA4
|
||||
#define SW6_CS16 0xA5
|
||||
#define SW6_CS17 0xA6
|
||||
#define SW6_CS18 0xA7
|
||||
#define SW6_CS19 0xA8
|
||||
#define SW6_CS20 0xA9
|
||||
#define SW6_CS21 0xAA
|
||||
#define SW6_CS22 0xAB
|
||||
#define SW6_CS23 0xAC
|
||||
#define SW6_CS24 0xAD
|
||||
#define SW6_CS25 0xAE
|
||||
#define SW6_CS26 0xAF
|
||||
#define SW6_CS27 0xB0
|
||||
#define SW6_CS28 0xB1
|
||||
#define SW6_CS29 0xB2
|
||||
#define SW6_CS30 0xB3
|
225
drivers/led/issi/is31fl3742a.c
Normal file
225
drivers/led/issi/is31fl3742a.c
Normal file
|
@ -0,0 +1,225 @@
|
|||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2020 MelGeek
|
||||
* Copyright 2021 MasterSpoon
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "is31fl3742a.h"
|
||||
#include "i2c_master.h"
|
||||
#include "gpio.h"
|
||||
#include "wait.h"
|
||||
|
||||
#define IS31FL3742A_PWM_REGISTER_COUNT 180
|
||||
#define IS31FL3742A_SCALING_REGISTER_COUNT 180
|
||||
|
||||
#ifndef IS31FL3742A_I2C_TIMEOUT
|
||||
# define IS31FL3742A_I2C_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3742A_I2C_PERSISTENCE
|
||||
# define IS31FL3742A_I2C_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3742A_CONFIGURATION
|
||||
# define IS31FL3742A_CONFIGURATION 0x31
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3742A_PWM_FREQUENCY
|
||||
# define IS31FL3742A_PWM_FREQUENCY IS31FL3742A_PWM_FREQUENCY_29K_HZ
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3742A_SW_PULLDOWN
|
||||
# define IS31FL3742A_SW_PULLDOWN IS31FL3742A_PDR_8K_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3742A_CS_PULLUP
|
||||
# define IS31FL3742A_CS_PULLUP IS31FL3742A_PUR_8K_OHM
|
||||
#endif
|
||||
|
||||
#ifndef IS31FL3742A_GLOBAL_CURRENT
|
||||
# define IS31FL3742A_GLOBAL_CURRENT 0xFF
|
||||
#endif
|
||||
|
||||
const uint8_t i2c_addresses[IS31FL3742A_DRIVER_COUNT] = {
|
||||
IS31FL3742A_I2C_ADDRESS_1,
|
||||
#ifdef IS31FL3742A_I2C_ADDRESS_2
|
||||
IS31FL3742A_I2C_ADDRESS_2,
|
||||
# ifdef IS31FL3742A_I2C_ADDRESS_3
|
||||
IS31FL3742A_I2C_ADDRESS_3,
|
||||
# ifdef IS31FL3742A_I2C_ADDRESS_4
|
||||
IS31FL3742A_I2C_ADDRESS_4,
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct is31fl3742a_driver_t {
|
||||
uint8_t pwm_buffer[IS31FL3742A_PWM_REGISTER_COUNT];
|
||||
bool pwm_buffer_dirty;
|
||||
uint8_t scaling_buffer[IS31FL3742A_SCALING_REGISTER_COUNT];
|
||||
bool scaling_buffer_dirty;
|
||||
} PACKED is31fl3742a_driver_t;
|
||||
|
||||
is31fl3742a_driver_t driver_buffers[IS31FL3742A_DRIVER_COUNT] = {{
|
||||
.pwm_buffer = {0},
|
||||
.pwm_buffer_dirty = false,
|
||||
.scaling_buffer = {0},
|
||||
.scaling_buffer_dirty = false,
|
||||
}};
|
||||
|
||||
void is31fl3742a_write_register(uint8_t index, uint8_t reg, uint8_t data) {
|
||||
#if IS31FL3742A_I2C_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < IS31FL3742A_I2C_PERSISTENCE; i++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3742A_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, reg, &data, 1, IS31FL3742A_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void is31fl3742a_select_page(uint8_t index, uint8_t page) {
|
||||
is31fl3742a_write_register(index, IS31FL3742A_REG_COMMAND_WRITE_LOCK, IS31FL3742A_COMMAND_WRITE_LOCK_MAGIC);
|
||||
is31fl3742a_write_register(index, IS31FL3742A_REG_COMMAND, page);
|
||||
}
|
||||
|
||||
void is31fl3742a_write_pwm_buffer(uint8_t index) {
|
||||
// Assumes page 0 is already selected.
|
||||
// Transmit PWM registers in 6 transfers of 30 bytes.
|
||||
|
||||
// Iterate over the pwm_buffer contents at 30 byte intervals.
|
||||
for (uint8_t i = 0; i < IS31FL3742A_PWM_REGISTER_COUNT; i += 30) {
|
||||
#if IS31FL3742A_I2C_PERSISTENCE > 0
|
||||
for (uint8_t j = 0; j < IS31FL3742A_I2C_PERSISTENCE; j++) {
|
||||
if (i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer + i, 30, IS31FL3742A_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
|
||||
}
|
||||
#else
|
||||
i2c_write_register(i2c_addresses[index] << 1, i, driver_buffers[index].pwm_buffer + i, 30, IS31FL3742A_I2C_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3742a_init_drivers(void) {
|
||||
i2c_init();
|
||||
|
||||
#if defined(IS31FL3742A_SDB_PIN)
|
||||
gpio_set_pin_output(IS31FL3742A_SDB_PIN);
|
||||
gpio_write_pin_high(IS31FL3742A_SDB_PIN);
|
||||
#endif
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3742A_DRIVER_COUNT; i++) {
|
||||
is31fl3742a_init(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < IS31FL3742A_LED_COUNT; i++) {
|
||||
is31fl3742a_set_scaling_register(i, 0xFF, 0xFF, 0xFF);
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3742A_DRIVER_COUNT; i++) {
|
||||
is31fl3742a_update_scaling_registers(i);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3742a_init(uint8_t index) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
|
||||
is31fl3742a_select_page(index, IS31FL3742A_COMMAND_SCALING);
|
||||
|
||||
// Turn off all LEDs.
|
||||
for (uint8_t i = 0; i < IS31FL3742A_SCALING_REGISTER_COUNT; i++) {
|
||||
is31fl3742a_write_register(index, i, 0x00);
|
||||
}
|
||||
|
||||
is31fl3742a_select_page(index, IS31FL3742A_COMMAND_PWM);
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3742A_PWM_REGISTER_COUNT; i++) {
|
||||
is31fl3742a_write_register(index, i, 0x00);
|
||||
}
|
||||
|
||||
is31fl3742a_select_page(index, IS31FL3742A_COMMAND_FUNCTION);
|
||||
|
||||
is31fl3742a_write_register(index, IS31FL3742A_FUNCTION_REG_PULLDOWNUP, (IS31FL3742A_SW_PULLDOWN << 4) | IS31FL3742A_CS_PULLUP);
|
||||
is31fl3742a_write_register(index, IS31FL3742A_FUNCTION_REG_GLOBAL_CURRENT, IS31FL3742A_GLOBAL_CURRENT);
|
||||
is31fl3742a_write_register(index, IS31FL3742A_FUNCTION_REG_PWM_FREQUENCY, (IS31FL3742A_PWM_FREQUENCY & 0b0111));
|
||||
is31fl3742a_write_register(index, IS31FL3742A_FUNCTION_REG_CONFIGURATION, IS31FL3742A_CONFIGURATION);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
wait_ms(10);
|
||||
}
|
||||
|
||||
void is31fl3742a_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
is31fl3742a_led_t led;
|
||||
|
||||
if (index >= 0 && index < IS31FL3742A_LED_COUNT) {
|
||||
memcpy_P(&led, (&g_is31fl3742a_leds[index]), sizeof(led));
|
||||
|
||||
if (driver_buffers[led.driver].pwm_buffer[led.r] == red && driver_buffers[led.driver].pwm_buffer[led.g] == green && driver_buffers[led.driver].pwm_buffer[led.b] == blue) {
|
||||
return;
|
||||
}
|
||||
|
||||
driver_buffers[led.driver].pwm_buffer[led.r] = red;
|
||||
driver_buffers[led.driver].pwm_buffer[led.g] = green;
|
||||
driver_buffers[led.driver].pwm_buffer[led.b] = blue;
|
||||
driver_buffers[led.driver].pwm_buffer_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3742a_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
for (int i = 0; i < IS31FL3742A_LED_COUNT; i++) {
|
||||
is31fl3742a_set_color(i, red, green, blue);
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3742a_set_scaling_register(uint8_t index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
is31fl3742a_led_t led;
|
||||
memcpy_P(&led, (&g_is31fl3742a_leds[index]), sizeof(led));
|
||||
|
||||
driver_buffers[led.driver].scaling_buffer[led.r] = red;
|
||||
driver_buffers[led.driver].scaling_buffer[led.g] = green;
|
||||
driver_buffers[led.driver].scaling_buffer[led.b] = blue;
|
||||
driver_buffers[led.driver].scaling_buffer_dirty = true;
|
||||
}
|
||||
|
||||
void is31fl3742a_update_pwm_buffers(uint8_t index) {
|
||||
if (driver_buffers[index].pwm_buffer_dirty) {
|
||||
is31fl3742a_select_page(index, IS31FL3742A_COMMAND_PWM);
|
||||
|
||||
is31fl3742a_write_pwm_buffer(index);
|
||||
|
||||
driver_buffers[index].pwm_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3742a_update_scaling_registers(uint8_t index) {
|
||||
if (driver_buffers[index].scaling_buffer_dirty) {
|
||||
is31fl3742a_select_page(index, IS31FL3742A_COMMAND_SCALING);
|
||||
|
||||
for (uint8_t i = 0; i < IS31FL3742A_SCALING_REGISTER_COUNT; i++) {
|
||||
is31fl3742a_write_register(index, i, driver_buffers[index].scaling_buffer[i]);
|
||||
}
|
||||
|
||||
driver_buffers[index].scaling_buffer_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void is31fl3742a_flush(void) {
|
||||
for (uint8_t i = 0; i < IS31FL3742A_DRIVER_COUNT; i++) {
|
||||
is31fl3742a_update_pwm_buffers(i);
|
||||
}
|
||||
}
|
298
drivers/led/issi/is31fl3742a.h
Normal file
298
drivers/led/issi/is31fl3742a.h
Normal file
|
@ -0,0 +1,298 @@
|
|||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2020 MelGeek
|
||||
* Copyright 2021 MasterSpoon
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "progmem.h"
|
||||
#include "util.h"
|
||||
|
||||
#define IS31FL3742A_REG_INTERRUPT_MASK 0xF0
|
||||
#define IS31FL3742A_REG_INTERRUPT_STATUS 0xF1
|
||||
#define IS31FL3742A_REG_ID 0xFC
|
||||
|
||||
#define IS31FL3742A_REG_COMMAND 0xFD
|
||||
|
||||
#define IS31FL3742A_COMMAND_PWM 0x00
|
||||
#define IS31FL3742A_COMMAND_SCALING 0x02
|
||||
#define IS31FL3742A_COMMAND_FUNCTION 0x04
|
||||
|
||||
#define IS31FL3742A_FUNCTION_REG_CONFIGURATION 0x00
|
||||
#define IS31FL3742A_FUNCTION_REG_GLOBAL_CURRENT 0x01
|
||||
#define IS31FL3742A_FUNCTION_REG_PULLDOWNUP 0x02
|
||||
#define IS31FL3742A_FUNCTION_REG_PWM_FREQUENCY 0x36
|
||||
#define IS31FL3742A_FUNCTION_REG_RESET 0x3F
|
||||
#define IS31FL3742A_FUNCTION_REG_SPREAD_SPECTRUM 0x41
|
||||
|
||||
#define IS31FL3742A_REG_COMMAND_WRITE_LOCK 0xFE
|
||||
#define IS31FL3742A_COMMAND_WRITE_LOCK_MAGIC 0xC5
|
||||
|
||||
#define IS31FL3742A_I2C_ADDRESS_GND 0x30
|
||||
#define IS31FL3742A_I2C_ADDRESS_SCL 0x31
|
||||
#define IS31FL3742A_I2C_ADDRESS_SDA 0x32
|
||||
#define IS31FL3742A_I2C_ADDRESS_VCC 0x33
|
||||
|
||||
#if defined(RGB_MATRIX_IS31FL3742A)
|
||||
# define IS31FL3742A_LED_COUNT RGB_MATRIX_LED_COUNT
|
||||
#endif
|
||||
|
||||
#if defined(IS31FL3742A_I2C_ADDRESS_4)
|
||||
# define IS31FL3742A_DRIVER_COUNT 4
|
||||
#elif defined(IS31FL3742A_I2C_ADDRESS_3)
|
||||
# define IS31FL3742A_DRIVER_COUNT 3
|
||||
#elif defined(IS31FL3742A_I2C_ADDRESS_2)
|
||||
# define IS31FL3742A_DRIVER_COUNT 2
|
||||
#elif defined(IS31FL3742A_I2C_ADDRESS_1)
|
||||
# define IS31FL3742A_DRIVER_COUNT 1
|
||||
#endif
|
||||
|
||||
typedef struct is31fl3742a_led_t {
|
||||
uint8_t driver : 2;
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
} PACKED is31fl3742a_led_t;
|
||||
|
||||
extern const is31fl3742a_led_t PROGMEM g_is31fl3742a_leds[IS31FL3742A_LED_COUNT];
|
||||
|
||||
void is31fl3742a_init_drivers(void);
|
||||
void is31fl3742a_init(uint8_t index);
|
||||
void is31fl3742a_write_register(uint8_t index, uint8_t reg, uint8_t data);
|
||||
void is31fl3742a_select_page(uint8_t index, uint8_t page);
|
||||
|
||||
void is31fl3742a_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
|
||||
void is31fl3742a_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
||||
void is31fl3742a_set_scaling_register(uint8_t index, uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
||||
void is31fl3742a_update_pwm_buffers(uint8_t index);
|
||||
void is31fl3742a_update_scaling_registers(uint8_t index);
|
||||
|
||||
void is31fl3742a_flush(void);
|
||||
|
||||
#define IS31FL3742A_PDR_0_OHM 0b000 // No pull-down resistor
|
||||
#define IS31FL3742A_PDR_0K5_OHM 0b001 // 0.5 kOhm resistor
|
||||
#define IS31FL3742A_PDR_1K_OHM 0b010 // 1 kOhm resistor
|
||||
#define IS31FL3742A_PDR_2K_OHM 0b011 // 2 kOhm resistor
|
||||
#define IS31FL3742A_PDR_4K_OHM 0b100 // 4 kOhm resistor
|
||||
#define IS31FL3742A_PDR_8K_OHM 0b101 // 8 kOhm resistor
|
||||
#define IS31FL3742A_PDR_16K_OHM 0b110 // 16 kOhm resistor
|
||||
#define IS31FL3742A_PDR_32K_OHM 0b111 // 32 kOhm resistor
|
||||
|
||||
#define IS31FL3742A_PUR_0_OHM 0b000 // No pull-up resistor
|
||||
#define IS31FL3742A_PUR_0K5_OHM 0b001 // 0.5 kOhm resistor
|
||||
#define IS31FL3742A_PUR_1K_OHM 0b010 // 1 kOhm resistor
|
||||
#define IS31FL3742A_PUR_2K_OHM 0b011 // 2 kOhm resistor
|
||||
#define IS31FL3742A_PUR_4K_OHM 0b100 // 4 kOhm resistor
|
||||
#define IS31FL3742A_PUR_8K_OHM 0b101 // 8 kOhm resistor
|
||||
#define IS31FL3742A_PUR_16K_OHM 0b110 // 16 kOhm resistor
|
||||
#define IS31FL3742A_PUR_32K_OHM 0b111 // 32 kOhm resistor
|
||||
|
||||
#define IS31FL3742A_PWM_FREQUENCY_29K_HZ 0b0000
|
||||
#define IS31FL3742A_PWM_FREQUENCY_3K6_HZ 0b0011
|
||||
#define IS31FL3742A_PWM_FREQUENCY_1K8_HZ 0b0111
|
||||
#define IS31FL3742A_PWM_FREQUENCY_900_HZ 0b1011
|
||||
|
||||
#define SW1_CS1 0x00
|
||||
#define SW1_CS2 0x01
|
||||
#define SW1_CS3 0x02
|
||||
#define SW1_CS4 0x03
|
||||
#define SW1_CS5 0x04
|
||||
#define SW1_CS6 0x05
|
||||
#define SW1_CS7 0x06
|
||||
#define SW1_CS8 0x07
|
||||
#define SW1_CS9 0x08
|
||||
#define SW1_CS10 0x09
|
||||
#define SW1_CS11 0x0A
|
||||
#define SW1_CS12 0x0B
|
||||
#define SW1_CS13 0x0C
|
||||
#define SW1_CS14 0x0D
|
||||
#define SW1_CS15 0x0E
|
||||
#define SW1_CS16 0x0F
|
||||
#define SW1_CS17 0x10
|
||||
#define SW1_CS18 0x11
|
||||
#define SW1_CS19 0x12
|
||||
#define SW1_CS20 0x13
|
||||
#define SW1_CS21 0x14
|
||||
#define SW1_CS22 0x15
|
||||
#define SW1_CS23 0x16
|
||||
#define SW1_CS24 0x17
|
||||
#define SW1_CS25 0x18
|
||||
#define SW1_CS26 0x19
|
||||
#define SW1_CS27 0x1A
|
||||
#define SW1_CS28 0x1B
|
||||
#define SW1_CS29 0x1C
|
||||
#define SW1_CS30 0x1D
|
||||
|
||||
#define SW2_CS1 0x1E
|
||||
#define SW2_CS2 0x1F
|
||||
#define SW2_CS3 0x20
|
||||
#define SW2_CS4 0x21
|
||||
#define SW2_CS5 0x22
|
||||
#define SW2_CS6 0x23
|
||||
#define SW2_CS7 0x24
|
||||
#define SW2_CS8 0x25
|
||||
#define SW2_CS9 0x26
|
||||
#define SW2_CS10 0x27
|
||||
#define SW2_CS11 0x28
|
||||
#define SW2_CS12 0x29
|
||||
#define SW2_CS13 0x2A
|
||||
#define SW2_CS14 0x2B
|
||||
#define SW2_CS15 0x2C
|
||||
#define SW2_CS16 0x2D
|
||||
#define SW2_CS17 0x2E
|
||||
#define SW2_CS18 0x2F
|
||||
#define SW2_CS19 0x30
|
||||
#define SW2_CS20 0x31
|
||||
#define SW2_CS21 0x32
|
||||
#define SW2_CS22 0x33
|
||||
#define SW2_CS23 0x34
|
||||
#define SW2_CS24 0x35
|
||||
#define SW2_CS25 0x36
|
||||
#define SW2_CS26 0x37
|
||||
#define SW2_CS27 0x38
|
||||
#define SW2_CS28 0x39
|
||||
#define SW2_CS29 0x3A
|
||||
#define SW2_CS30 0x3B
|
||||
|
||||
#define SW3_CS1 0x3C
|
||||
#define SW3_CS2 0x3D
|
||||
#define SW3_CS3 0x3E
|
||||
#define SW3_CS4 0x3F
|
||||
#define SW3_CS5 0x40
|
||||
#define SW3_CS6 0x41
|
||||
#define SW3_CS7 0x42
|
||||
#define SW3_CS8 0x43
|
||||
#define SW3_CS9 0x44
|
||||
#define SW3_CS10 0x45
|
||||
#define SW3_CS11 0x46
|
||||
#define SW3_CS12 0x47
|
||||
#define SW3_CS13 0x48
|
||||
#define SW3_CS14 0x49
|
||||
#define SW3_CS15 0x4A
|
||||
#define SW3_CS16 0x4B
|
||||
#define SW3_CS17 0x4C
|
||||
#define SW3_CS18 0x4D
|
||||
#define SW3_CS19 0x4E
|
||||
#define SW3_CS20 0x4F
|
||||
#define SW3_CS21 0x50
|
||||
#define SW3_CS22 0x51
|
||||
#define SW3_CS23 0x52
|
||||
#define SW3_CS24 0x53
|
||||
#define SW3_CS25 0x54
|
||||
#define SW3_CS26 0x55
|
||||
#define SW3_CS27 0x56
|
||||
#define SW3_CS28 0x57
|
||||
#define SW3_CS29 0x58
|
||||
#define SW3_CS30 0x59
|
||||
|
||||
#define SW4_CS1 0x5A
|
||||
#define SW4_CS2 0x5B
|
||||
#define SW4_CS3 0x5C
|
||||
#define SW4_CS4 0x5D
|
||||
#define SW4_CS5 0x5E
|
||||
#define SW4_CS6 0x5F
|
||||
#define SW4_CS7 0x60
|
||||
#define SW4_CS8 0x61
|
||||
#define SW4_CS9 0x62
|
||||
#define SW4_CS10 0x63
|
||||
#define SW4_CS11 0x64
|
||||
#define SW4_CS12 0x65
|
||||
#define SW4_CS13 0x66
|
||||
#define SW4_CS14 0x67
|
||||
#define SW4_CS15 0x68
|
||||
#define SW4_CS16 0x69
|
||||
#define SW4_CS17 0x6A
|
||||
#define SW4_CS18 0x6B
|
||||
#define SW4_CS19 0x6C
|
||||
#define SW4_CS20 0x6D
|
||||
#define SW4_CS21 0x6E
|
||||
#define SW4_CS22 0x6F
|
||||
#define SW4_CS23 0x70
|
||||
#define SW4_CS24 0x71
|
||||
#define SW4_CS25 0x72
|
||||
#define SW4_CS26 0x73
|
||||
#define SW4_CS27 0x74
|
||||
#define SW4_CS28 0x75
|
||||
#define SW4_CS29 0x76
|
||||
#define SW4_CS30 0x77
|
||||
|
||||
#define SW5_CS1 0x78
|
||||
#define SW5_CS2 0x79
|
||||
#define SW5_CS3 0x7A
|
||||
#define SW5_CS4 0x7B
|
||||
#define SW5_CS5 0x7C
|
||||
#define SW5_CS6 0x7D
|
||||
#define SW5_CS7 0x7E
|
||||
#define SW5_CS8 0x7F
|
||||
#define SW5_CS9 0x80
|
||||
#define SW5_CS10 0x81
|
||||
#define SW5_CS11 0x82
|
||||
#define SW5_CS12 0x83
|
||||
#define SW5_CS13 0x84
|
||||
#define SW5_CS14 0x85
|
||||
#define SW5_CS15 0x86
|
||||
#define SW5_CS16 0x87
|
||||
#define SW5_CS17 0x88
|
||||
#define SW5_CS18 0x89
|
||||
#define SW5_CS19 0x8A
|
||||
#define SW5_CS20 0x8B
|
||||
#define SW5_CS21 0x8C
|
||||
#define SW5_CS22 0x8D
|
||||
#define SW5_CS23 0x8E
|
||||
#define SW5_CS24 0x8F
|
||||
#define SW5_CS25 0x90
|
||||
#define SW5_CS26 0x91
|
||||
#define SW5_CS27 0x92
|
||||
#define SW5_CS28 0x93
|
||||
#define SW5_CS29 0x94
|
||||
#define SW5_CS30 0x95
|
||||
|
||||
#define SW6_CS1 0x96
|
||||
#define SW6_CS2 0x97
|
||||
#define SW6_CS3 0x98
|
||||
#define SW6_CS4 0x99
|
||||
#define SW6_CS5 0x9A
|
||||
#define SW6_CS6 0x9B
|
||||
#define SW6_CS7 0x9C
|
||||
#define SW6_CS8 0x9D
|
||||
#define SW6_CS9 0x9E
|
||||
#define SW6_CS10 0x9F
|
||||
#define SW6_CS11 0xA0
|
||||
#define SW6_CS12 0xA1
|
||||
#define SW6_CS13 0xA2
|
||||
#define SW6_CS14 0xA3
|
||||
#define SW6_CS15 0xA4
|
||||
#define SW6_CS16 0xA5
|
||||
#define SW6_CS17 0xA6
|
||||
#define SW6_CS18 0xA7
|
||||
#define SW6_CS19 0xA8
|
||||
#define SW6_CS20 0xA9
|
||||
#define SW6_CS21 0xAA
|
||||
#define SW6_CS22 0xAB
|
||||
#define SW6_CS23 0xAC
|
||||
#define SW6_CS24 0xAD
|
||||
#define SW6_CS25 0xAE
|
||||
#define SW6_CS26 0xAF
|
||||
#define SW6_CS27 0xB0
|
||||
#define SW6_CS28 0xB1
|
||||
#define SW6_CS29 0xB2
|
||||
#define SW6_CS30 0xB3
|
|
@ -1,327 +0,0 @@
|
|||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2020 MelGeek
|
||||
* Copyright 2021 MasterSpoon
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// This is a 7-bit address, that gets left-shifted and bit 0
|
||||
// set to 0 for write, 1 for read (as per I2C protocol)
|
||||
// The address will vary depending on your wiring:
|
||||
// 00 <-> GND
|
||||
// 01 <-> SCL
|
||||
// 10 <-> SDA
|
||||
// 11 <-> VCC
|
||||
// ADDR1 represents A1:A0 of the 7-bit address.
|
||||
// ADDR2 represents A3:A2 of the 7-bit address.
|
||||
// The result is: 0b010(ADDR2)(ADDR1)
|
||||
#ifndef DRIVER_ADDR_1
|
||||
# define DRIVER_ADDR_1 0b0100000
|
||||
#endif
|
||||
|
||||
// Set defaults for Spread Spectrum Register
|
||||
#ifndef ISSI_SSR_1
|
||||
# ifndef DRIVER_ADDR_2
|
||||
# define ISSI_SSR_1 0x00
|
||||
# else
|
||||
# define ISSI_SSR_1 0xC0
|
||||
# endif
|
||||
#endif
|
||||
#ifndef ISSI_SSR_2
|
||||
# define ISSI_SSR_2 0x80
|
||||
#endif
|
||||
#ifndef ISSI_SSR_3
|
||||
# define ISSI_SSR_3 0x80
|
||||
#endif
|
||||
#ifndef ISSI_SSR_4
|
||||
# define ISSI_SSR_4 0x80
|
||||
#endif
|
||||
|
||||
// Command Registers
|
||||
#define ISSI_COMMANDREGISTER_WRITELOCK 0xFE
|
||||
#define ISSI_COMMANDREGISTER 0xFD
|
||||
#define ISSI_IDREGISTER 0xFC
|
||||
#define ISSI_REGISTER_UNLOCK 0xC5
|
||||
|
||||
// Response Registers
|
||||
#define ISSI_PAGE_PWM 0x00
|
||||
#define ISSI_PAGE_SCALING 0x01
|
||||
#define ISSI_PAGE_FUNCTION 0x02
|
||||
|
||||
// Registers under Function Register
|
||||
#define ISSI_REG_CONFIGURATION 0x00
|
||||
#define ISSI_REG_GLOBALCURRENT 0x01
|
||||
#define ISSI_REG_PULLDOWNUP 0x02
|
||||
#define ISSI_REG_TEMP 0x24
|
||||
#define ISSI_REG_SSR 0x25
|
||||
#define ISSI_REG_RESET 0x2F
|
||||
|
||||
// Set defaults for Function Registers
|
||||
#ifndef ISSI_CONFIGURATION
|
||||
# define ISSI_CONFIGURATION 0x01
|
||||
#endif
|
||||
#ifndef ISSI_GLOBALCURRENT
|
||||
# define ISSI_GLOBALCURRENT 0xFF
|
||||
#endif
|
||||
#ifndef ISSI_PULLDOWNUP
|
||||
# define ISSI_PULLDOWNUP 0x33
|
||||
#endif
|
||||
#ifndef ISSI_TEMP
|
||||
# define ISSI_TEMP 0x00
|
||||
#endif
|
||||
|
||||
// Set defaults for Scaling registers
|
||||
#ifndef ISSI_SCAL_RED
|
||||
# define ISSI_SCAL_RED 0xFF
|
||||
#endif
|
||||
#ifndef ISSI_SCAL_BLUE
|
||||
# define ISSI_SCAL_BLUE 0xFF
|
||||
#endif
|
||||
#ifndef ISSI_SCAL_GREEN
|
||||
# define ISSI_SCAL_GREEN 0xFF
|
||||
#endif
|
||||
#define ISSI_SCAL_RED_OFF 0x00
|
||||
#define ISSI_SCAL_GREEN_OFF 0x00
|
||||
#define ISSI_SCAL_BLUE_OFF 0x00
|
||||
|
||||
#ifndef ISSI_SCAL_LED
|
||||
# define ISSI_SCAL_LED 0xFF
|
||||
#endif
|
||||
#define ISSI_SCAL_LED_OFF 0x00
|
||||
|
||||
// Set buffer sizes
|
||||
#define ISSI_MAX_LEDS 198
|
||||
#define ISSI_SCALING_SIZE 198
|
||||
#define ISSI_PWM_TRF_SIZE 18
|
||||
#define ISSI_SCALING_TRF_SIZE 18
|
||||
|
||||
// Location of 1st bit for PWM and Scaling registers
|
||||
#define ISSI_PWM_REG_1ST 0x01
|
||||
#define ISSI_SCL_REG_1ST 0x01
|
||||
|
||||
// Map CS SW locations to order in PWM / Scaling buffers
|
||||
// This matches the ORDER in the Datasheet Register not the POSITION
|
||||
// It will always count from 0x00 to (ISSI_MAX_LEDS - 1)
|
||||
#define CS1_SW1 0x00
|
||||
#define CS2_SW1 0x01
|
||||
#define CS3_SW1 0x02
|
||||
#define CS4_SW1 0x03
|
||||
#define CS5_SW1 0x04
|
||||
#define CS6_SW1 0x05
|
||||
#define CS7_SW1 0x06
|
||||
#define CS8_SW1 0x07
|
||||
#define CS9_SW1 0x08
|
||||
#define CS10_SW1 0x09
|
||||
#define CS11_SW1 0x0A
|
||||
#define CS12_SW1 0x0B
|
||||
#define CS13_SW1 0x0C
|
||||
#define CS14_SW1 0x0D
|
||||
#define CS15_SW1 0x0E
|
||||
#define CS16_SW1 0x0F
|
||||
#define CS17_SW1 0x10
|
||||
#define CS18_SW1 0x11
|
||||
|
||||
#define CS1_SW2 0x12
|
||||
#define CS2_SW2 0x13
|
||||
#define CS3_SW2 0x14
|
||||
#define CS4_SW2 0x15
|
||||
#define CS5_SW2 0x16
|
||||
#define CS6_SW2 0x17
|
||||
#define CS7_SW2 0x18
|
||||
#define CS8_SW2 0x19
|
||||
#define CS9_SW2 0x1A
|
||||
#define CS10_SW2 0x1B
|
||||
#define CS11_SW2 0x1C
|
||||
#define CS12_SW2 0x1D
|
||||
#define CS13_SW2 0x1E
|
||||
#define CS14_SW2 0x1F
|
||||
#define CS15_SW2 0x20
|
||||
#define CS16_SW2 0x21
|
||||
#define CS17_SW2 0x22
|
||||
#define CS18_SW2 0x23
|
||||
|
||||
#define CS1_SW3 0x24
|
||||
#define CS2_SW3 0x25
|
||||
#define CS3_SW3 0x26
|
||||
#define CS4_SW3 0x27
|
||||
#define CS5_SW3 0x28
|
||||
#define CS6_SW3 0x29
|
||||
#define CS7_SW3 0x2A
|
||||
#define CS8_SW3 0x2B
|
||||
#define CS9_SW3 0x2C
|
||||
#define CS10_SW3 0x2D
|
||||
#define CS11_SW3 0x2E
|
||||
#define CS12_SW3 0x2F
|
||||
#define CS13_SW3 0x30
|
||||
#define CS14_SW3 0x31
|
||||
#define CS15_SW3 0x32
|
||||
#define CS16_SW3 0x33
|
||||
#define CS17_SW3 0x34
|
||||
#define CS18_SW3 0x35
|
||||
|
||||
#define CS1_SW4 0x36
|
||||
#define CS2_SW4 0x37
|
||||
#define CS3_SW4 0x38
|
||||
#define CS4_SW4 0x39
|
||||
#define CS5_SW4 0x3A
|
||||
#define CS6_SW4 0x3B
|
||||
#define CS7_SW4 0x3C
|
||||
#define CS8_SW4 0x3D
|
||||
#define CS9_SW4 0x3E
|
||||
#define CS10_SW4 0x3F
|
||||
#define CS11_SW4 0x40
|
||||
#define CS12_SW4 0x41
|
||||
#define CS13_SW4 0x42
|
||||
#define CS14_SW4 0x43
|
||||
#define CS15_SW4 0x44
|
||||
#define CS16_SW4 0x45
|
||||
#define CS17_SW4 0x46
|
||||
#define CS18_SW4 0x47
|
||||
|
||||
#define CS1_SW5 0x48
|
||||
#define CS2_SW5 0x49
|
||||
#define CS3_SW5 0x4A
|
||||
#define CS4_SW5 0x4B
|
||||
#define CS5_SW5 0x4C
|
||||
#define CS6_SW5 0x4D
|
||||
#define CS7_SW5 0x4E
|
||||
#define CS8_SW5 0x4F
|
||||
#define CS9_SW5 0x50
|
||||
#define CS10_SW5 0x51
|
||||
#define CS11_SW5 0x52
|
||||
#define CS12_SW5 0x53
|
||||
#define CS13_SW5 0x54
|
||||
#define CS14_SW5 0x55
|
||||
#define CS15_SW5 0x56
|
||||
#define CS16_SW5 0x57
|
||||
#define CS17_SW5 0x58
|
||||
#define CS18_SW5 0x59
|
||||
|
||||
#define CS1_SW6 0x5A
|
||||
#define CS2_SW6 0x5B
|
||||
#define CS3_SW6 0x5C
|
||||
#define CS4_SW6 0x5D
|
||||
#define CS5_SW6 0x5E
|
||||
#define CS6_SW6 0x5F
|
||||
#define CS7_SW6 0x60
|
||||
#define CS8_SW6 0x61
|
||||
#define CS9_SW6 0x62
|
||||
#define CS10_SW6 0x63
|
||||
#define CS11_SW6 0x64
|
||||
#define CS12_SW6 0x65
|
||||
#define CS13_SW6 0x66
|
||||
#define CS14_SW6 0x67
|
||||
#define CS15_SW6 0x68
|
||||
#define CS16_SW6 0x69
|
||||
#define CS17_SW6 0x6A
|
||||
#define CS18_SW6 0x6B
|
||||
|
||||
#define CS1_SW7 0x6C
|
||||
#define CS2_SW7 0x6D
|
||||
#define CS3_SW7 0x6E
|
||||
#define CS4_SW7 0x6F
|
||||
#define CS5_SW7 0x70
|
||||
#define CS6_SW7 0x71
|
||||
#define CS7_SW7 0x72
|
||||
#define CS8_SW7 0x73
|
||||
#define CS9_SW7 0x74
|
||||
#define CS10_SW7 0x75
|
||||
#define CS11_SW7 0x76
|
||||
#define CS12_SW7 0x77
|
||||
#define CS13_SW7 0x78
|
||||
#define CS14_SW7 0x79
|
||||
#define CS15_SW7 0x7A
|
||||
#define CS16_SW7 0x7B
|
||||
#define CS17_SW7 0x7C
|
||||
#define CS18_SW7 0x7D
|
||||
|
||||
#define CS1_SW8 0x7E
|
||||
#define CS2_SW8 0x7F
|
||||
#define CS3_SW8 0x80
|
||||
#define CS4_SW8 0x81
|
||||
#define CS5_SW8 0x82
|
||||
#define CS6_SW8 0x83
|
||||
#define CS7_SW8 0x84
|
||||
#define CS8_SW8 0x85
|
||||
#define CS9_SW8 0x86
|
||||
#define CS10_SW8 0x87
|
||||
#define CS11_SW8 0x88
|
||||
#define CS12_SW8 0x89
|
||||
#define CS13_SW8 0x8A
|
||||
#define CS14_SW8 0x8B
|
||||
#define CS15_SW8 0x8C
|
||||
#define CS16_SW8 0x8D
|
||||
#define CS17_SW8 0x8E
|
||||
#define CS18_SW8 0x8F
|
||||
|
||||
#define CS1_SW9 0x90
|
||||
#define CS2_SW9 0x91
|
||||
#define CS3_SW9 0x92
|
||||
#define CS4_SW9 0x93
|
||||
#define CS5_SW9 0x94
|
||||
#define CS6_SW9 0x95
|
||||
#define CS7_SW9 0x96
|
||||
#define CS8_SW9 0x97
|
||||
#define CS9_SW9 0x98
|
||||
#define CS10_SW9 0x99
|
||||
#define CS11_SW9 0x9A
|
||||
#define CS12_SW9 0x9B
|
||||
#define CS13_SW9 0x9C
|
||||
#define CS14_SW9 0x9D
|
||||
#define CS15_SW9 0x9E
|
||||
#define CS16_SW9 0x9F
|
||||
#define CS17_SW9 0xA0
|
||||
#define CS18_SW9 0xA1
|
||||
|
||||
#define CS1_SW10 0xA2
|
||||
#define CS2_SW10 0xA3
|
||||
#define CS3_SW10 0xA4
|
||||
#define CS4_SW10 0xA5
|
||||
#define CS5_SW10 0xA6
|
||||
#define CS6_SW10 0xA7
|
||||
#define CS7_SW10 0xA8
|
||||
#define CS8_SW10 0xA9
|
||||
#define CS9_SW10 0xAA
|
||||
#define CS10_SW10 0xAB
|
||||
#define CS11_SW10 0xAC
|
||||
#define CS12_SW10 0xAD
|
||||
#define CS13_SW10 0xAE
|
||||
#define CS14_SW10 0xAF
|
||||
#define CS15_SW10 0xB0
|
||||
#define CS16_SW10 0xB1
|
||||
#define CS17_SW10 0xB2
|
||||
#define CS18_SW10 0xB3
|
||||
|
||||
#define CS1_SW11 0xB4
|
||||
#define CS2_SW11 0xB5
|
||||
#define CS3_SW11 0xB6
|
||||
#define CS4_SW11 0xB7
|
||||
#define CS5_SW11 0xB8
|
||||
#define CS6_SW11 0xB9
|
||||
#define CS7_SW11 0xBA
|
||||
#define CS8_SW11 0xBB
|
||||
#define CS9_SW11 0xBC
|
||||
#define CS10_SW11 0xBD
|
||||
#define CS11_SW11 0xBE
|
||||
#define CS12_SW11 0xBF
|
||||
#define CS13_SW11 0xC0
|
||||
#define CS14_SW11 0xC1
|
||||
#define CS15_SW11 0xC2
|
||||
#define CS16_SW11 0xC3
|
||||
#define CS17_SW11 0xC4
|
||||
#define CS18_SW11 0xC5
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue