Skip to content

Commit

Permalink
Reapply "Add encoder abstraction. (qmk#21548)"
Browse files Browse the repository at this point in the history
This reverts commit e3cb6bb.

# Conflicts:
#	keyboards/mechwild/sugarglider/matrix.c
#	keyboards/pica40/rev2/rev2.c
#	keyboards/ploopyco/mouse/config.h
#	keyboards/ploopyco/mouse/keyboard.json
#	keyboards/ploopyco/mouse/rules.mk
#	keyboards/ploopyco/ploopyco.c
#	keyboards/ploopyco/ploopyco.h
#	keyboards/ploopyco/trackball/config.h
#	keyboards/ploopyco/trackball/info.json
#	keyboards/ploopyco/trackball/rules.mk
#	keyboards/ploopyco/trackball_mini/config.h
#	keyboards/ploopyco/trackball_mini/info.json
#	keyboards/ploopyco/trackball_mini/rules.mk
#	keyboards/ploopyco/trackball_thumb/config.h
#	keyboards/ploopyco/trackball_thumb/info.json
  • Loading branch information
ykeisuke committed Jun 4, 2024
1 parent 777b7ff commit 4c9a8a9
Show file tree
Hide file tree
Showing 45 changed files with 1,785 additions and 541 deletions.
15 changes: 15 additions & 0 deletions builddefs/common_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -898,9 +898,24 @@ 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
Expand Down
1 change: 1 addition & 0 deletions data/mappings/info_rules.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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"},
"HAPTIC_DRIVER": {"info_key": "haptic.driver"},
"KEYBOARD_SHARED_EP": {"info_key": "usb.shared_endpoint.keyboard", "value_type": "bool"},
Expand Down
123 changes: 88 additions & 35 deletions data/schemas/keyboard.jsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"encoder_config": {
"type": "object",
"properties": {
"driver": {
"type": "string",
"enum": ["custom", "quadrature"]
},
"rotary": {
"type": "array",
"items": {
Expand All @@ -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"},
Expand Down Expand Up @@ -131,8 +133,20 @@
"clicky": {"type": "boolean"}
}
},
"driver": {
"type": "string",
"enum": ["dac_additive", "dac_basic", "pwm_software", "pwm_hardware"]
},
"macro_beep": {"type": "boolean"},
"pins": {"$ref": "qmk.definitions.v1#/mcu_pin_array"},
"power_control": {
"type": "object",
"additionalProperties": false,
"properties": {
"on_state": {"$ref": "qmk.definitions.v1#/bit"},
"pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}
}
},
"voices": {"type": "boolean"}
}
},
Expand All @@ -142,7 +156,7 @@
"properties": {
"driver": {
"type": "string",
"enum": ["pwm", "software", "timer", "custom"]
"enum": ["custom", "pwm", "software", "timer"]
},
"default": {
"type": "object",
Expand Down Expand Up @@ -314,8 +328,8 @@
},
"features": {
"$ref": "qmk.definitions.v1#/boolean_array",
"propertyNames": { "$ref": "qmk.definitions.v1#/snake_case" },
"not": { "required": [ "lto" ] }
"propertyNames": {"$ref": "qmk.definitions.v1#/snake_case"},
"not": {"required": ["lto"]}
},
"indicators": {
"type": "object",
Expand All @@ -340,15 +354,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": {
Expand Down Expand Up @@ -383,6 +391,15 @@
}
}
},
"haptic": {
"type": "object",
"properties": {
"driver": {
"type": "string",
"enum": ["drv2605l", "solenoid"]
}
}
},
"leader_key": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -431,10 +448,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",
Expand All @@ -446,7 +461,25 @@
"speed": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}
}
},
"driver": {"type": "string"},
"driver": {
"type": "string",
"enum": [
"custom",
"is31fl3218",
"is31fl3236",
"is31fl3729",
"is31fl3731",
"is31fl3733",
"is31fl3736",
"is31fl3737",
"is31fl3741",
"is31fl3742a",
"is31fl3743a",
"is31fl3745",
"is31fl3746a",
"snled27351"
]
},
"center_point": {
"type": "array",
"minItems": 2,
Expand Down Expand Up @@ -495,10 +528,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",
Expand All @@ -512,7 +543,27 @@
"speed": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}
}
},
"driver": {"type": "string"},
"driver": {
"type": "string",
"enum": [
"aw20216s",
"custom",
"is31fl3218",
"is31fl3236",
"is31fl3729",
"is31fl3731",
"is31fl3733",
"is31fl3736",
"is31fl3737",
"is31fl3741",
"is31fl3742a",
"is31fl3743a",
"is31fl3745",
"is31fl3746a",
"snled27351",
"ws2812"
]
},
"center_point": {
"type": "array",
"minItems": 2,
Expand Down Expand Up @@ -564,10 +615,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": {
Expand Down Expand Up @@ -612,7 +661,10 @@
"$ref": "qmk.definitions.v1#/mcu_pin",
"$comment": "Deprecated: use ws2812.pin instead"
},
"rgbw": {"type": "boolean"},
"rgbw": {
"type": "boolean",
"$comment": "Deprecated: use ws2812.rgbw instead"
},
"saturation_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"sleep": {"type": "boolean"},
"split": {"type": "boolean"},
Expand Down Expand Up @@ -753,7 +805,7 @@
"properties": {
"protocol": {
"type": "string",
"enum": ["custom", "i2c", "serial", "serial_usart"]
"enum": ["custom", "i2c", "serial"]
},
"sync": {
"type": "object",
Expand All @@ -770,7 +822,7 @@
"st7565": {"type": "boolean"},
"wpm": {"type": "boolean"}
}
}
},
"watchdog": {"type": "boolean"},
"watchdog_timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"sync_matrix_state": {
Expand Down Expand Up @@ -849,7 +901,7 @@
}
},
"suspend_wakeup_delay": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"wait_for": {"type": "boolean"}
"wait_for_enumeration": {"type": "boolean"}
}
},
"qmk": {
Expand Down Expand Up @@ -888,6 +940,7 @@
"enum": ["bitbang", "custom", "i2c", "pwm", "spi", "vendor"]
},
"pin": {"$ref": "qmk.definitions.v1#/mcu_pin"},
"rgbw": {"type": "boolean"},
"i2c_address": {"$ref": "qmk.definitions.v1#/hex_number_2d"},
"i2c_timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"}
}
Expand Down
Loading

0 comments on commit 4c9a8a9

Please sign in to comment.