Merge branch 'develop' of github.com:qmk/qmk_firmware into develop

This commit is contained in:
Thomas Haukland 2022-09-25 10:07:07 +02:00
commit b292324586
835 changed files with 9632 additions and 3007 deletions

View File

@ -12,7 +12,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v5
- uses: actions/stale@v6
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -241,21 +241,20 @@ endif
#
# https://docs.qmk.fm/#/feature_layouts?id=tips-for-making-layouts-keyboard-agnostic
#
QMK_KEYBOARD_H = $(KEYBOARD_OUTPUT)/src/default_keyboard.h
ifneq ("$(wildcard $(KEYBOARD_PATH_1)/$(KEYBOARD_FOLDER_1).h)","")
QMK_KEYBOARD_H = $(KEYBOARD_FOLDER_1).h
FOUND_KEYBOARD_H = $(KEYBOARD_FOLDER_1).h
endif
ifneq ("$(wildcard $(KEYBOARD_PATH_2)/$(KEYBOARD_FOLDER_2).h)","")
QMK_KEYBOARD_H = $(KEYBOARD_FOLDER_2).h
FOUND_KEYBOARD_H = $(KEYBOARD_FOLDER_2).h
endif
ifneq ("$(wildcard $(KEYBOARD_PATH_3)/$(KEYBOARD_FOLDER_3).h)","")
QMK_KEYBOARD_H = $(KEYBOARD_FOLDER_3).h
FOUND_KEYBOARD_H = $(KEYBOARD_FOLDER_3).h
endif
ifneq ("$(wildcard $(KEYBOARD_PATH_4)/$(KEYBOARD_FOLDER_4).h)","")
QMK_KEYBOARD_H = $(KEYBOARD_FOLDER_4).h
FOUND_KEYBOARD_H = $(KEYBOARD_FOLDER_4).h
endif
ifneq ("$(wildcard $(KEYBOARD_PATH_5)/$(KEYBOARD_FOLDER_5).h)","")
QMK_KEYBOARD_H = $(KEYBOARD_FOLDER_5).h
FOUND_KEYBOARD_H = $(KEYBOARD_FOLDER_5).h
endif
# Determine and set parameters based on the keyboard's processor family.
@ -329,7 +328,7 @@ ifneq ("$(wildcard $(KEYBOARD_PATH_5)/info.json)","")
INFO_JSON_FILES += $(KEYBOARD_PATH_5)/info.json
endif
CONFIG_H += $(KEYBOARD_OUTPUT)/src/info_config.h $(KEYBOARD_OUTPUT)/src/layouts.h
CONFIG_H += $(KEYBOARD_OUTPUT)/src/info_config.h
KEYBOARD_SRC += $(KEYBOARD_OUTPUT)/src/default_keyboard.c
$(KEYBOARD_OUTPUT)/src/info_config.h: $(INFO_JSON_FILES)
@ -344,15 +343,10 @@ $(KEYBOARD_OUTPUT)/src/default_keyboard.c: $(INFO_JSON_FILES)
$(KEYBOARD_OUTPUT)/src/default_keyboard.h: $(INFO_JSON_FILES)
@$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD)
$(eval CMD=$(QMK_BIN) generate-keyboard-h --quiet --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/default_keyboard.h)
$(eval CMD=$(QMK_BIN) generate-keyboard-h --quiet --keyboard $(KEYBOARD) --include $(FOUND_KEYBOARD_H) --output $(KEYBOARD_OUTPUT)/src/default_keyboard.h)
@$(BUILD_CMD)
$(KEYBOARD_OUTPUT)/src/layouts.h: $(INFO_JSON_FILES)
@$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD)
$(eval CMD=$(QMK_BIN) generate-layouts --quiet --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/layouts.h)
@$(BUILD_CMD)
generated-files: $(KEYBOARD_OUTPUT)/src/info_config.h $(KEYBOARD_OUTPUT)/src/default_keyboard.c $(KEYBOARD_OUTPUT)/src/default_keyboard.h $(KEYBOARD_OUTPUT)/src/layouts.h
generated-files: $(KEYBOARD_OUTPUT)/src/info_config.h $(KEYBOARD_OUTPUT)/src/default_keyboard.c $(KEYBOARD_OUTPUT)/src/default_keyboard.h
.INTERMEDIATE : generated-files
@ -471,7 +465,7 @@ ALL_CONFIGS := $(PROJECT_CONFIG) $(CONFIG_H)
OUTPUTS := $(KEYMAP_OUTPUT) $(KEYBOARD_OUTPUT)
$(KEYMAP_OUTPUT)_SRC := $(SRC)
$(KEYMAP_OUTPUT)_DEFS := $(OPT_DEFS) \
-DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYBOARD_H=\"$(QMK_KEYBOARD_H)\" \
-DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYBOARD_H=\"$(KEYBOARD_OUTPUT)/src/default_keyboard.h\" \
-DQMK_KEYMAP=\"$(KEYMAP)\" -DQMK_KEYMAP_H=\"$(KEYMAP).h\" -DQMK_KEYMAP_CONFIG_H=\"$(KEYMAP_PATH)/config.h\"
$(KEYMAP_OUTPUT)_INC := $(VPATH) $(EXTRAINCDIRS)
$(KEYMAP_OUTPUT)_CONFIG := $(CONFIG_H)

View File

@ -136,6 +136,7 @@ ifeq ($(strip $(POINTING_DEVICE_ENABLE)), yes)
VPATH += $(QUANTUM_DIR)/pointing_device
SRC += $(QUANTUM_DIR)/pointing_device/pointing_device.c
SRC += $(QUANTUM_DIR)/pointing_device/pointing_device_drivers.c
SRC += $(QUANTUM_DIR)/pointing_device/pointing_device_auto_mouse.c
ifneq ($(strip $(POINTING_DEVICE_DRIVER)), custom)
SRC += drivers/sensors/$(strip $(POINTING_DEVICE_DRIVER)).c
OPT_DEFS += -DPOINTING_DEVICE_DRIVER_$(strip $(shell echo $(POINTING_DEVICE_DRIVER) | tr '[:lower:]' '[:upper:]'))

View File

@ -38,6 +38,13 @@
"LED_COMPOSE_PIN": {"info_key": "indicators.compose"},
"LED_KANA_PIN": {"info_key": "indicators.kana"},
"LED_PIN_ON_STATE": {"info_key": "indicators.on_state", "value_type": "int"},
"LED_MATRIX_CENTER": {"info_key": "led_matrix.center_point", "value_type": "array.int"},
"LED_MATRIX_MAXIMUM_BRIGHTNESS": {"info_key": "led_matrix.max_brightness", "value_type": "int"},
"LED_MATRIX_SPLIT": {"info_key": "led_matrix.split_count", "value_type": "array.int"},
"LED_MATRIX_HUE_STEP": {"info_key": "led_matrix.hue_steps", "value_type": "int"},
"LED_MATRIX_SAT_STEP": {"info_key": "led_matrix.sat_steps", "value_type": "int"},
"LED_MATRIX_VAL_STEP": {"info_key": "led_matrix.val_steps", "value_type": "int"},
"LED_MATRIX_SPD_STEP": {"info_key": "led_matrix.speed_steps", "value_type": "int"},
"MANUFACTURER": {"info_key": "manufacturer", "value_type": "str"},
"MATRIX_HAS_GHOST": {"info_key": "matrix_pins.ghost", "value_type": "bool"},
"MATRIX_IO_DELAY": {"info_key": "matrix_pins.io_delay", "value_type": "int"},
@ -77,6 +84,13 @@
"RGBLIGHT_VAL_STEP": {"info_key": "rgblight.brightness_steps", "value_type": "int"},
"RGBLIGHT_SLEEP": {"info_key": "rgblight.sleep", "value_type": "bool"},
"RGBLIGHT_SPLIT": {"info_key": "rgblight.split", "value_type": "bool"},
"RGB_MATRIX_CENTER": {"info_key": "rgb_matrix.center_point", "value_type": "array.int"},
"RGB_MATRIX_MAXIMUM_BRIGHTNESS": {"info_key": "rgb_matrix.max_brightness", "value_type": "int"},
"RGB_MATRIX_SPLIT": {"info_key": "rgb_matrix.split_count", "value_type": "array.int"},
"RGB_MATRIX_HUE_STEP": {"info_key": "rgb_matrix.hue_steps", "value_type": "int"},
"RGB_MATRIX_SAT_STEP": {"info_key": "rgb_matrix.sat_steps", "value_type": "int"},
"RGB_MATRIX_VAL_STEP": {"info_key": "rgb_matrix.val_steps", "value_type": "int"},
"RGB_MATRIX_SPD_STEP": {"info_key": "rgb_matrix.speed_steps", "value_type": "int"},
"RGBW": {"info_key": "rgblight.rgbw", "value_type": "bool"},
"PRODUCT": {"info_key": "keyboard_name", "warn_duplicate": false, "value_type": "str"},
"PRODUCT_ID": {"info_key": "usb.pid", "value_type": "hex"},

View File

@ -38,7 +38,7 @@
},
"pin_compatible": {
"type": "string",
"enum": ["promicro"]
"enum": ["promicro", "elite_c"]
},
"processor": {
"type": "string",
@ -265,6 +265,23 @@
"type": "object",
"properties": {
"driver": {"type": "string"},
"center_point": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}
},
"max_brightness": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
"hue_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"sat_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"val_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"speed_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"split_count": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {"$ref": "qmk.definitions.v1#/unsigned_int"}
},
"layout": {
"type": "array",
"items": {
@ -292,6 +309,23 @@
"type": "object",
"properties": {
"driver": {"type": "string"},
"center_point": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}
},
"max_brightness": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
"hue_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"sat_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"val_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"speed_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"split_count": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {"$ref": "qmk.definitions.v1#/unsigned_int"}
},
"layout": {
"type": "array",
"items": {

View File

@ -80,6 +80,7 @@
* [Caps Word](feature_caps_word.md)
* [Combos](feature_combo.md)
* [Debounce API](feature_debounce_type.md)
* [EEPROM](feature_eeprom.md)
* [Key Lock](feature_key_lock.md)
* [Key Overrides](feature_key_overrides.md)
* [Layers](feature_layers.md)

View File

@ -102,11 +102,11 @@ These are the three main initialization functions, listed in the order that they
## Keyboard Pre Initialization code
This runs very early during startup, even before the USB has been started.
This runs very early during startup, even before the USB has been started.
Shortly after this, the matrix is initialized.
For most users, this shouldn't be used, as it's primarily for hardware oriented initialization.
For most users, this shouldn't be used, as it's primarily for hardware oriented initialization.
However, if you have hardware stuff that you need initialized, this is the best place for it (such as initializing LED pins).
@ -134,9 +134,9 @@ void keyboard_pre_init_user(void) {
## Matrix Initialization Code
This is called when the matrix is initialized, and after some of the hardware has been set up, but before many of the features have been initialized.
This is called when the matrix is initialized, and after some of the hardware has been set up, but before many of the features have been initialized.
This is useful for setting up stuff that you may need elsewhere, but isn't hardware related nor is dependant on where it's started.
This is useful for setting up stuff that you may need elsewhere, but isn't hardware related nor is dependant on where it's started.
### `matrix_init_*` Function Documentation
@ -227,185 +227,6 @@ void suspend_wakeup_init_user(void) {
* Keyboard/Revision: `void suspend_power_down_kb(void)` and `void suspend_wakeup_init_user(void)`
* Keymap: `void suspend_power_down_kb(void)` and `void suspend_wakeup_init_user(void)`
# Layer Change Code :id=layer-change-code
This runs code every time that the layers get changed. This can be useful for layer indication, or custom layer handling.
### Example `layer_state_set_*` Implementation
This example shows how to set the [RGB Underglow](feature_rgblight.md) lights based on the layer, using the Planck as an example.
```c
layer_state_t layer_state_set_user(layer_state_t state) {
switch (get_highest_layer(state)) {
case _RAISE:
rgblight_setrgb (0x00, 0x00, 0xFF);
break;
case _LOWER:
rgblight_setrgb (0xFF, 0x00, 0x00);
break;
case _PLOVER:
rgblight_setrgb (0x00, 0xFF, 0x00);
break;
case _ADJUST:
rgblight_setrgb (0x7A, 0x00, 0xFF);
break;
default: // for any other layers, or the default layer
rgblight_setrgb (0x00, 0xFF, 0xFF);
break;
}
return state;
}
```
Use the `IS_LAYER_ON_STATE(state, layer)` and `IS_LAYER_OFF_STATE(state, layer)` macros to check the status of a particular layer.
Outside of `layer_state_set_*` functions, you can use the `IS_LAYER_ON(layer)` and `IS_LAYER_OFF(layer)` macros to check global layer state.
### `layer_state_set_*` Function Documentation
* Keyboard/Revision: `layer_state_t layer_state_set_kb(layer_state_t state)`
* Keymap: `layer_state_t layer_state_set_user(layer_state_t state)`
The `state` is the bitmask of the active layers, as explained in the [Keymap Overview](keymap.md#keymap-layer-status)
# Persistent Configuration (EEPROM)
This allows you to configure persistent settings for your keyboard. These settings are stored in the EEPROM of your controller, and are retained even after power loss. The settings can be read with `eeconfig_read_kb` and `eeconfig_read_user`, and can be written to using `eeconfig_update_kb` and `eeconfig_update_user`. This is useful for features that you want to be able to toggle (like toggling rgb layer indication). Additionally, you can use `eeconfig_init_kb` and `eeconfig_init_user` to set the default values for the EEPROM.
The complicated part here, is that there are a bunch of ways that you can store and access data via EEPROM, and there is no "correct" way to do this. However, you only have a DWORD (4 bytes) for each function.
Keep in mind that EEPROM has a limited number of writes. While this is very high, it's not the only thing writing to the EEPROM, and if you write too often, you can potentially drastically shorten the life of your MCU.
* If you don't understand the example, then you may want to avoid using this feature, as it is rather complicated.
### Example Implementation
This is an example of how to add settings, and read and write it. We're using the user keymap for the example here. This is a complex function, and has a lot going on. In fact, it uses a lot of the above functions to work!
In your keymap.c file, add this to the top:
```c
typedef union {
uint32_t raw;
struct {
bool rgb_layer_change :1;
};
} user_config_t;
user_config_t user_config;
```
This sets up a 32 bit structure that we can store settings with in memory, and write to the EEPROM. Using this removes the need to define variables, since they're defined in this structure. Remember that `bool` (boolean) values use 1 bit, `uint8_t` uses 8 bits, `uint16_t` uses up 16 bits. You can mix and match, but changing the order can cause issues, as it will change the values that are read and written.
We're using `rgb_layer_change`, for the `layer_state_set_*` function, and use `keyboard_post_init_user` and `process_record_user` to configure everything.
Now, using the `keyboard_post_init_user` code above, you want to add `eeconfig_read_user()` to it, to populate the structure you've just created. And you can then immediately use this structure to control functionality in your keymap. And It should look like:
```c
void keyboard_post_init_user(void) {
// Call the keymap level matrix init.
// Read the user config from EEPROM
user_config.raw = eeconfig_read_user();
// Set default layer, if enabled
if (user_config.rgb_layer_change) {
rgblight_enable_noeeprom();
rgblight_sethsv_noeeprom_cyan();
rgblight_mode_noeeprom(1);
}
}
```
The above function will use the EEPROM config immediately after reading it, to set the default layer's RGB color. The "raw" value of it is converted in a usable structure based on the "union" that you created above.
```c
layer_state_t layer_state_set_user(layer_state_t state) {
switch (get_highest_layer(state)) {
case _RAISE:
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_magenta(); rgblight_mode_noeeprom(1); }
break;
case _LOWER:
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_red(); rgblight_mode_noeeprom(1); }
break;
case _PLOVER:
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_green(); rgblight_mode_noeeprom(1); }
break;
case _ADJUST:
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_white(); rgblight_mode_noeeprom(1); }
break;
default: // for any other layers, or the default layer
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_cyan(); rgblight_mode_noeeprom(1); }
break;
}
return state;
}
```
This will cause the RGB underglow to be changed ONLY if the value was enabled. Now to configure this value, create a new keycode for `process_record_user` called `RGB_LYR`. Additionally, we want to make sure that if you use the normal RGB codes, that it turns off Using the example above, make it look this:
```c
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case FOO:
if (record->event.pressed) {
// Do something when pressed
} else {
// Do something else when release
}
return false; // Skip all further processing of this key
case KC_ENTER:
// Play a tone when enter is pressed
if (record->event.pressed) {
PLAY_SONG(tone_qwerty);
}
return true; // Let QMK send the enter press/release events
case RGB_LYR: // This allows me to use underglow as layer indication, or as normal
if (record->event.pressed) {
user_config.rgb_layer_change ^= 1; // Toggles the status
eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM
if (user_config.rgb_layer_change) { // if layer state indication is enabled,
layer_state_set(layer_state); // then immediately update the layer color
}
}
return false;
case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // For any of the RGB codes (see quantum_keycodes.h, L400 for reference)
if (record->event.pressed) { //This disables layer indication, as it's assumed that if you're changing this ... you want that disabled
if (user_config.rgb_layer_change) { // only if this is enabled
user_config.rgb_layer_change = false; // disable it, and
eeconfig_update_user(user_config.raw); // write the setings to EEPROM
}
}
return true; break;
default:
return true; // Process all other keycodes normally
}
}
```
And lastly, you want to add the `eeconfig_init_user` function, so that when the EEPROM is reset, you can specify default values, and even custom actions. To force an EEPROM reset, use the `EEP_RST` keycode or [Bootmagic Lite](feature_bootmagic.md) functionallity. For example, if you want to set rgb layer indication by default, and save the default valued.
```c
void eeconfig_init_user(void) { // EEPROM is getting reset!
user_config.raw = 0;
user_config.rgb_layer_change = true; // We want this enabled by default
eeconfig_update_user(user_config.raw); // Write default value to EEPROM now
// use the non noeeprom versions, to write these values to EEPROM too
rgblight_enable(); // Enable RGB by default
rgblight_sethsv_cyan(); // Set it to CYAN by default
rgblight_mode(1); // set to solid by default
}
```
And you're done. The RGB layer indication will only work if you want it to. And it will be saved, even after unplugging the board. And if you use any of the RGB codes, it will disable the layer indication, so that it stays on the mode and color that you set it to.
### 'EECONFIG' Function Documentation
* Keyboard/Revision: `void eeconfig_init_kb(void)`, `uint32_t eeconfig_read_kb(void)` and `void eeconfig_update_kb(uint32_t val)`
* Keymap: `void eeconfig_init_user(void)`, `uint32_t eeconfig_read_user(void)` and `void eeconfig_update_user(uint32_t val)`
The `val` is the value of the data that you want to write to EEPROM. And the `eeconfig_read_*` function return a 32 bit (DWORD) value from the EEPROM.
# Deferred Execution :id=deferred-execution
QMK has the ability to execute a callback after a specified period of time, rather than having to manually manage timers. To enable this functionality, set `DEFERRED_EXEC_ENABLE = yes` in rules.mk.
@ -471,3 +292,15 @@ If registrations fail, then you can increase this value in your keyboard or keym
```c
#define MAX_DEFERRED_EXECUTORS 16
```
# Advanced topics :id=advanced-topics
This page used to encompass a large set of features. We have moved many sections that used to be part of this page to their own pages. Everything below this point is simply a redirect so that people following old links on the web find what they're looking for.
## Layer Change Code :id=layer-change-code
[Layer change code](feature_layers.md#layer-change-code)
## Persistent Configuration (EEPROM) :id=persistent-configuration-eeprom
[Persistent Configuration (EEPROM)](feature_eeprom.md)

View File

@ -161,7 +161,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
};
```
# Legacy Content :id=legacy-content
# Advanced topics :id=advanced-topics
This page used to encompass a large set of features. We have moved many sections that used to be part of this page to their own pages. Everything below this point is simply a redirect so that people following old links on the web find what they're looking for.

View File

@ -18,6 +18,8 @@ Currently the following converters are available:
| `promicro` | `stemcell` |
| `promicro` | `bonsai_c4` |
| `promicro` | `elite_pi` |
| `elite_c` | `stemcell` |
| `elite_c` | `elite_pi` |
See below for more in depth information on each converter.
@ -48,6 +50,23 @@ Once a converter is enabled, it exposes the `CONVERT_TO_<target_uppercase>` flag
#endif
```
### Pin Compatibility
To ensure compatibility, provide validation, and power future workflows, a keyboard should declare its `pin compatibility`. For legacy reasons, this is currently assumed to be `promicro`.
Currently the following pin compatibility interfaces are defined:
| Pinout | Notes |
|------------|-----------------------------------|
| `promicro` | Includes RX/TX LEDs |
| `elite_c` | Includes bottom row pins, no LEDs |
To declare the base for conversions, add this line to your keyboard's `rules.mk`:
```makefile
PIN_COMPATIBLE = elite_c
```
## Pro Micro
If a board currently supported in QMK uses a [Pro Micro](https://www.sparkfun.com/products/12640) (or compatible board), the supported alternative controllers are:
@ -107,7 +126,7 @@ The following defaults are based on what has been implemented for [RP2040](platf
### SparkFun Pro Micro - RP2040, Blok, Bit-C PRO, and Elite-Pi :id=promicro_rp2040
Currently identical to [Adafruit KB2040](#kb2040).
Currently identical to [Adafruit KB2040](#kb2040).
### STeMCell :id=stemcell
@ -138,4 +157,28 @@ The Bonsai C4 only has one on-board LED (B2), and by default, both the Pro Micro
#define B0 PAL_LINE(GPIOA, 9)
```
No peripherals are enabled by default at this time, but example code to enable SPI, I2C, PWM, and Serial communications can be found [here](/keyboards/custommk/bonsai_c4_template)
No peripherals are enabled by default at this time, but example code to enable SPI, I2C, PWM, and Serial communications can be found [here](/keyboards/custommk/bonsai_c4_template).
## Elite-C
If a board currently supported in QMK uses an [Elite-C](https://keeb.io/products/elite-c-low-profile-version-usb-c-pro-micro-replacement-atmega32u4), the supported alternative controllers are:
| Device | Target |
|----------------------------------------------------------------------------------|-------------------|
| [STeMCell](https://github.com/megamind4089/STeMCell) | `stemcell` |
| [Elite-Pi](https://keeb.io/products/elite-pi-usb-c-pro-micro-replacement-rp2040) | `elite_pi` |
Converter summary:
| Target | Argument | `rules.mk` | Condition |
|-------------------|---------------------------------|------------------------------|-------------------------------------|
| `stemcell` | `-e CONVERT_TO=stemcell` | `CONVERT_TO=stemcell` | `#ifdef CONVERT_TO_STEMCELL` |
| `elite_pi` | `-e CONVERT_TO=elite_pi` | `CONVERT_TO=elite_pi` | `#ifdef CONVERT_TO_ELITE_PI` |
### STeMCell :id=stemcell_elite
Currently identical to [STeMCell](#stemcell) with support for the additional bottom row of pins.
### Elite-Pi :id=elite_pi
Currently identical to [Adafruit KB2040](#kb2040), with support for the additional bottom row of pins.

134
docs/feature_eeprom.md Normal file
View File

@ -0,0 +1,134 @@
# Persistent Configuration (EEPROM)
This allows you to configure persistent settings for your keyboard. These settings are stored in the EEPROM of your controller, and are retained even after power loss. The settings can be read with `eeconfig_read_kb` and `eeconfig_read_user`, and can be written to using `eeconfig_update_kb` and `eeconfig_update_user`. This is useful for features that you want to be able to toggle (like toggling rgb layer indication). Additionally, you can use `eeconfig_init_kb` and `eeconfig_init_user` to set the default values for the EEPROM.
The complicated part here, is that there are a bunch of ways that you can store and access data via EEPROM, and there is no "correct" way to do this. However, you only have a DWORD (4 bytes) for each function.
Keep in mind that EEPROM has a limited number of writes. While this is very high, it's not the only thing writing to the EEPROM, and if you write too often, you can potentially drastically shorten the life of your MCU.
* If you don't understand the example, then you may want to avoid using this feature, as it is rather complicated.
## Example Implementation
This is an example of how to add settings, and read and write it. We're using the user keymap for the example here. This is a complex function, and has a lot going on. In fact, it uses a lot of the above functions to work!
In your keymap.c file, add this to the top:
```c
typedef union {
uint32_t raw;
struct {
bool rgb_layer_change :1;
};
} user_config_t;
user_config_t user_config;
```
This sets up a 32 bit structure that we can store settings with in memory, and write to the EEPROM. Using this removes the need to define variables, since they're defined in this structure. Remember that `bool` (boolean) values use 1 bit, `uint8_t` uses 8 bits, `uint16_t` uses up 16 bits. You can mix and match, but changing the order can cause issues, as it will change the values that are read and written.
We're using `rgb_layer_change`, for the `layer_state_set_*` function, and use `keyboard_post_init_user` and `process_record_user` to configure everything.
Now, using the `keyboard_post_init_user` code above, you want to add `eeconfig_read_user()` to it, to populate the structure you've just created. And you can then immediately use this structure to control functionality in your keymap. And It should look like:
```c
void keyboard_post_init_user(void) {
// Call the keymap level matrix init.
// Read the user config from EEPROM
user_config.raw = eeconfig_read_user();
// Set default layer, if enabled
if (user_config.rgb_layer_change) {
rgblight_enable_noeeprom();
rgblight_sethsv_noeeprom_cyan();
rgblight_mode_noeeprom(1);
}
}
```
The above function will use the EEPROM config immediately after reading it, to set the default layer's RGB color. The "raw" value of it is converted in a usable structure based on the "union" that you created above.
```c
layer_state_t layer_state_set_user(layer_state_t state) {
switch (get_highest_layer(state)) {
case _RAISE:
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_magenta(); rgblight_mode_noeeprom(1); }
break;
case _LOWER:
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_red(); rgblight_mode_noeeprom(1); }
break;
case _PLOVER:
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_green(); rgblight_mode_noeeprom(1); }
break;
case _ADJUST:
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_white(); rgblight_mode_noeeprom(1); }
break;
default: // for any other layers, or the default layer
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_cyan(); rgblight_mode_noeeprom(1); }
break;
}
return state;
}
```
This will cause the RGB underglow to be changed ONLY if the value was enabled. Now to configure this value, create a new keycode for `process_record_user` called `RGB_LYR`. Additionally, we want to make sure that if you use the normal RGB codes, that it turns off Using the example above, make it look this:
```c
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case FOO:
if (record->event.pressed) {
// Do something when pressed
} else {
// Do something else when release
}
return false; // Skip all further processing of this key
case KC_ENTER:
// Play a tone when enter is pressed
if (record->event.pressed) {
PLAY_SONG(tone_qwerty);
}
return true; // Let QMK send the enter press/release events
case RGB_LYR: // This allows me to use underglow as layer indication, or as normal
if (record->event.pressed) {
user_config.rgb_layer_change ^= 1; // Toggles the status
eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM
if (user_config.rgb_layer_change) { // if layer state indication is enabled,
layer_state_set(layer_state); // then immediately update the layer color
}
}
return false;
case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // For any of the RGB codes (see quantum_keycodes.h, L400 for reference)
if (record->event.pressed) { //This disables layer indication, as it's assumed that if you're changing this ... you want that disabled
if (user_config.rgb_layer_change) { // only if this is enabled
user_config.rgb_layer_change = false; // disable it, and
eeconfig_update_user(user_config.raw); // write the setings to EEPROM
}
}
return true; break;
default:
return true; // Process all other keycodes normally
}
}
```
And lastly, you want to add the `eeconfig_init_user` function, so that when the EEPROM is reset, you can specify default values, and even custom actions. To force an EEPROM reset, use the `EEP_RST` keycode or [Bootmagic Lite](feature_bootmagic.md) functionallity. For example, if you want to set rgb layer indication by default, and save the default valued.
```c
void eeconfig_init_user(void) { // EEPROM is getting reset!
user_config.raw = 0;
user_config.rgb_layer_change = true; // We want this enabled by default
eeconfig_update_user(user_config.raw); // Write default value to EEPROM now
// use the non noeeprom versions, to write these values to EEPROM too
rgblight_enable(); // Enable RGB by default
rgblight_sethsv_cyan(); // Set it to CYAN by default
rgblight_mode(1); // set to solid by default
}
```
And you're done. The RGB layer indication will only work if you want it to. And it will be saved, even after unplugging the board. And if you use any of the RGB codes, it will disable the layer indication, so that it stays on the mode and color that you set it to.
## 'EECONFIG' Function Documentation
* Keyboard/Revision: `void eeconfig_init_kb(void)`, `uint32_t eeconfig_read_kb(void)` and `void eeconfig_update_kb(uint32_t val)`
* Keymap: `void eeconfig_init_user(void)`, `uint32_t eeconfig_read_user(void)` and `void eeconfig_update_user(uint32_t val)`
The `val` is the value of the data that you want to write to EEPROM. And the `eeconfig_read_*` function return a 32 bit (DWORD) value from the EEPROM.

View File

@ -1,6 +1,6 @@
# Layers :id=layers
One of the most powerful and well used features of QMK Firmware is the ability to use layers. For most people, this amounts to a function key that allows for different keys, much like what you would see on a laptop or tablet keyboard.
One of the most powerful and well used features of QMK Firmware is the ability to use layers. For most people, this amounts to a function key that allows for different keys, much like what you would see on a laptop or tablet keyboard.
For a detailed explanation of how the layer stack works, checkout [Keymap Overview](keymap.md#keymap-and-layers).
@ -9,7 +9,7 @@ For a detailed explanation of how the layer stack works, checkout [Keymap Overvi
These functions allow you to activate layers in various ways. Note that layers are not generally independent layouts -- multiple layers can be activated at once, and it's typical for layers to use `KC_TRNS` to allow keypresses to pass through to lower layers. When using momentary layer switching with MO(), LM(), TT(), or LT(), make sure to leave the key on the above layers transparent or it may not work as intended.
* `DF(layer)` - switches the default layer. The default layer is the always-active base layer that other layers stack on top of. See below for more about the default layer. This might be used to switch from QWERTY to Dvorak layout. (Note that this is a temporary switch that only persists until the keyboard loses power. To modify the default layer in a persistent way requires deeper customization, such as calling the `set_single_persistent_default_layer` function inside of [process_record_user](custom_quantum_functions.md#programming-the-behavior-of-any-keycode).)
* `MO(layer)` - momentarily activates *layer*. As soon as you let go of the key, the layer is deactivated.
* `MO(layer)` - momentarily activates *layer*. As soon as you let go of the key, the layer is deactivated.
* `LM(layer, mod)` - Momentarily activates *layer* (like `MO`), but with modifier(s) *mod* active. Only supports layers 0-15 and the left modifiers: `MOD_LCTL`, `MOD_LSFT`, `MOD_LALT`, `MOD_LGUI` (note the use of `MOD_` constants instead of `KC_`). These modifiers can be combined using bitwise OR, e.g. `LM(_RAISE, MOD_LCTL | MOD_LALT)`.
* `LT(layer, kc)` - momentarily activates *layer* when held, and sends *kc* when tapped. Only supports layers 0-15.
* `OSL(layer)` - momentarily activates *layer* until the next key is pressed. See [One Shot Keys](one_shot_keys.md) for details and additional functionality.
@ -31,7 +31,7 @@ Care must be taken when switching layers, it's possible to lock yourself into a
If you are just getting started with QMK you will want to keep everything simple. Follow these guidelines when setting up your layers:
* Setup layer 0 as your default, "base" layer. This is your normal typing layer, and could be whatever layout you want (qwerty, dvorak, colemak, etc.). It's important to set this as the lowest layer since it will typically have most or all of the keyboard's keys defined, so would block other layers from having any effect if it were above them (i.e., had a higher layer number).
* Setup layer 0 as your default, "base" layer. This is your normal typing layer, and could be whatever layout you want (qwerty, dvorak, colemak, etc.). It's important to set this as the lowest layer since it will typically have most or all of the keyboard's keys defined, so would block other layers from having any effect if it were above them (i.e., had a higher layer number).
* Arrange your layers in a "tree" layout, with layer 0 as the root. Do not try to enter the same layer from more than one other layer.
* In a layer's keymap, only reference higher-numbered layers. Because layers are processed from the highest-numbered (topmost) active layer down, modifying the state of lower layers can be tricky and error-prone.
@ -89,3 +89,46 @@ It is also possible to check the state of a particular layer using the following
|---------------------------------|-------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| `layer_state_is(layer)` | Checks if the specified `layer` is enabled globally. | `IS_LAYER_ON(layer)`, `IS_LAYER_OFF(layer)` |
| `layer_state_cmp(state, layer)` | Checks `state` to see if the specified `layer` is enabled. Intended for use in layer callbacks. | `IS_LAYER_ON_STATE(state, layer)`, `IS_LAYER_OFF_STATE(state, layer)` |
## Layer Change Code :id=layer-change-code
This runs code every time that the layers get changed. This can be useful for layer indication, or custom layer handling.
### Example `layer_state_set_*` Implementation
This example shows how to set the [RGB Underglow](feature_rgblight.md) lights based on the layer, using the Planck as an example.
```c
layer_state_t layer_state_set_user(layer_state_t state) {
switch (get_highest_layer(state)) {
case _RAISE:
rgblight_setrgb (0x00, 0x00, 0xFF);
break;
case _LOWER:
rgblight_setrgb (0xFF, 0x00, 0x00);
break;
case _PLOVER:
rgblight_setrgb (0x00, 0xFF, 0x00);
break;
case _ADJUST:
rgblight_setrgb (0x7A, 0x00, 0xFF);
break;
default: // for any other layers, or the default layer
rgblight_setrgb (0x00, 0xFF, 0xFF);
break;
}
return state;
}
```
Use the `IS_LAYER_ON_STATE(state, layer)` and `IS_LAYER_OFF_STATE(state, layer)` macros to check the status of a particular layer.
Outside of `layer_state_set_*` functions, you can use the `IS_LAYER_ON(layer)` and `IS_LAYER_OFF(layer)` macros to check global layer state.
### `layer_state_set_*` Function Documentation
* Keyboard/Revision: `layer_state_t layer_state_set_kb(layer_state_t state)`
* Keymap: `layer_state_t layer_state_set_user(layer_state_t state)`
The `state` is the bitmask of the active layers, as explained in the [Keymap Overview](keymap.md#keymap-layer-status)

View File

@ -22,7 +22,7 @@ You can use between 1 and 4 IS31FL3731 IC's. Do not specify `LED_DRIVER_ADDR_<N>
| `ISSI_TIMEOUT` | (Optional) How long to wait for i2c messages, in milliseconds | 100 |
| `ISSI_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 |
| `LED_DRIVER_COUNT` | (Required) How many LED driver IC's are present | |
| `DRIVER_LED_TOTAL` | (Required) How many LED lights are present across all drivers | |
| `LED_MATRIX_LED_COUNT` | (Required) How many LED lights are present across all drivers | |
| `LED_DRIVER_ADDR_1` | (Required) Address for the first LED driver | |
| `LED_DRIVER_ADDR_2` | (Optional) Address for the second LED driver | |
| `LED_DRIVER_ADDR_3` | (Optional) Address for the third LED driver | |
@ -44,17 +44,17 @@ Here is an example using 2 drivers.
#define LED_DRIVER_COUNT 2
#define LED_DRIVER_1_LED_TOTAL 25
#define LED_DRIVER_2_LED_TOTAL 24
#define DRIVER_LED_TOTAL (LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL)
#define LED_MATRIX_LED_COUNT (LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL)
```
!> Note the parentheses, this is so when `LED_DRIVER_LED_TOTAL` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL)` will give very different results than `rand() % LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL`.
!> Note the parentheses, this is so when `LED_MATRIX_LED_COUNT` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL)` will give very different results than `rand() % LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL`.
For split keyboards using `LED_MATRIX_SPLIT` with an LED driver, you can either have the same driver address or different driver addresses. If using different addresses, use `DRIVER_ADDR_1` for one and `DRIVER_ADDR_2` for the other one. Then, in `g_is31_leds`, fill out the correct driver index (0 or 1). If using one address, use `DRIVER_ADDR_1` for both, and use index 0 for `g_is31_leds`.
Define these arrays listing all the LEDs in your `<keyboard>.c`:
```c
const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {
const is31_led PROGMEM g_is31_leds[LED_MATRIX_LED_COUNT] = {
/* Refer to IS31 manual for these locations
* driver
* | LED address
@ -95,7 +95,7 @@ Configure the hardware via your `config.h`:
| `ISSI_TIMEOUT` | (Optional) How long to wait for i2c messages, in milliseconds | 100 |
| `ISSI_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 |
| `DRIVER_COUNT` | (Required) How many LED driver IC's are present | |
| `DRIVER_LED_TOTAL` | (Required) How many LED lights are present across all drivers | |
| `LED_MATRIX_LED_COUNT` | (Required) How many LED lights are present across all drivers | |
| `DRIVER_ADDR_1` | (Optional) Address for the first LED driver | |
| `DRIVER_ADDR_<N>` | (Required) Address for the additional LED drivers | |
| `ISSI_SSR_<N>` | (Optional) Configuration for the Spread Spectrum Register | |
@ -130,16 +130,16 @@ Here is an example using 2 drivers.
#define DRIVER_COUNT 2
#define DRIVER_1_LED_TOTAL 66
#define DRIVER_2_LED_TOTAL 42
#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
#define LED_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
```
!> Note the parentheses, this is so when `DRIVER_LED_TOTAL` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
!> Note the parentheses, this is so when `LED_MATRIX_LED_COUNT` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
Currently only 4 drivers are supported, but it would be trivial to support for more. Note that using a combination of different drivers is not supported. All drivers must be of the same model.
Define these arrays listing all the LEDs in your `<keyboard>.c`:
```c
const is31_led __flash g_is31_leds[DRIVER_LED_TOTAL] = {
const is31_led __flash g_is31_leds[LED_MATRIX_LED_COUNT] = {
/* Refer to IS31 manual for these locations
* driver
* | LED address
@ -367,7 +367,7 @@ For inspiration and examples, check out the built-in effects under `quantum/led_
#define LED_DISABLE_TIMEOUT 0 // number of milliseconds to wait until led automatically turns off
#define LED_DISABLE_AFTER_TIMEOUT 0 // OBSOLETE: number of ticks to wait until disabling effects
#define LED_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
#define LED_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5 // limits the number of LEDs to process in an animation per task run (increases keyboard responsiveness)
#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
#define LED_MATRIX_STARTUP_MODE LED_MATRIX_SOLID // Sets the default mode, if none has been set
@ -391,7 +391,7 @@ Where `28` is an unused index from `eeconfig.h`.
|Function |Description |
|--------------------------------------------|-------------|
|`led_matrix_set_value_all(v)` |Set all of the LEDs to the given value, where `v` is between 0 and 255 (not written to EEPROM) |
|`led_matrix_set_value(index, v)` |Set a single LED to the given value, where `v` is between 0 and 255, and `index` is between 0 and `DRIVER_LED_TOTAL` (not written to EEPROM) |
|`led_matrix_set_value(index, v)` |Set a single LED to the given value, where `v` is between 0 and 255, and `index` is between 0 and `LED_MATRIX_LED_COUNT` (not written to EEPROM) |
### Disable/Enable Effects :id=disable-enable-effects
|Function |Description |

View File

@ -289,6 +289,7 @@ void pointing_device_driver_set_cpi(uint16_t cpi) {}
| `POINTING_DEVICE_INVERT_X` | (Optional) Inverts the X axis report. | _not defined_ |
| `POINTING_DEVICE_INVERT_Y` | (Optional) Inverts the Y axis report. | _not defined_ |
| `POINTING_DEVICE_MOTION_PIN` | (Optional) If supported, will only read from sensor if pin is active. | _not defined_ |
| `POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW` | (Optional) If defined then the motion pin is active-low. | _varies_ |
| `POINTING_DEVICE_TASK_THROTTLE_MS` | (Optional) Limits the frequency that the sensor is polled for motion. | _not defined_ |
| `POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE` | (Optional) Enable inertial cursor. Cursor continues moving after a flick gesture and slows down by kinetic friction. | _not defined_ |
| `POINTING_DEVICE_GESTURES_SCROLL_ENABLE` | (Optional) Enable scroll gesture. The gesture that activates the scroll is device dependent. | _not defined_ |
@ -345,7 +346,7 @@ The combined functions below are only available when using `SPLIT_POINTING_ENABL
| Function | Description |
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `pointing_device_set_shared_report(mouse_report)` | Sets the shared mouse report to the assigned `mouse_report_t` data structured passed to the function. |
| `pointing_device_set_cpi_on_side(bool, uint16_t)` | Sets the CPI/DPI of one side, if supported. Passing `true` will set the left and `false` the right` |
| `pointing_device_set_cpi_on_side(bool, uint16_t)` | Sets the CPI/DPI of one side, if supported. Passing `true` will set the left and `false` the right |
| `pointing_device_combine_reports(left_report, right_report)` | Returns a combined mouse_report of left_report and right_report (as a `mouse_report_t` data structure) |
| `pointing_device_task_combined_kb(left_report, right_report)` | Callback, so keyboard code can intercept and modify the data. Returns a combined mouse report. |
| `pointing_device_task_combined_user(left_report, right_report)` | Callback, so user code can intercept and modify. Returns a combined mouse report using `pointing_device_combine_reports` |
@ -497,3 +498,233 @@ If you are having issues with pointing device drivers debug messages can be enab
```
?> The messages will be printed out to the `CONSOLE` output. For additional information, refer to [Debugging/Troubleshooting QMK](faq_debug.md).
---
# Automatic Mouse Layer :id=pointing-device-auto-mouse
When using a pointing device combined with a keyboard the mouse buttons are often kept on a separate layer from the default keyboard layer, which requires pressing or holding a key to change layers before using the mouse. To make this easier and more efficient an additional pointing device feature may be enabled that will automatically activate a target layer as soon as the pointing device is active _(in motion, mouse button pressed etc.)_ and deactivate the target layer after a set time.
Additionally if any key that is defined as a mouse key is pressed then the layer will be held as long as the key is pressed and the timer will be reset on key release. When a non-mouse key is pressed then the layer is deactivated early _(with some exceptions see below)_. Mod, mod tap, and one shot mod keys are ignored _(i.e. don't hold or activate layer but do not deactivate the layer either)_ when sending a modifier keycode _(e.g. hold for mod tap)_ allowing for mod keys to be used with the mouse without activating the target layer when typing.
All of the standard layer keys (tap toggling, toggle, toggle on, one_shot, layer tap, layer mod) that activate the current target layer are uniquely handled to ensure they behave as expected _(see layer key table below)_. The target layer that can be changed at any point during by calling the `set_auto_mouse_layer(<new_target_layer>);` function.
### Behaviour of Layer keys that activate the target layer
| Layer key as in `keymap.c` | Auto Mouse specific behaviour |
| -------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `MO(<target_layer>)` | Treated as a mouse key holding the layer while pressed |
| `LT(<target_layer>)` | When tapped will be treated as non mouse key and mouse key when held |
| `LM(<target_layer>)` | Treated as a mouse key |
| `TG(<target_layer>)` | Will set flag preventing target layer deactivation or removal until pressed again |
| `TO(<target_layer>)` | Same as `TG(<target_layer>)` |
| `TT(<target_layer>)` | Treated as a mouse key when `tap.count < TAPPING_TOGGLE` and as `TG` when `tap.count == TAPPING_TOGGLE` |
| `DF(<target_layer>)` | Skips auto mouse key processing similar to mod keys |
| `OSL(<target_layer>)` | Skips, but if current one shot layer is the target layer then it will prevent target layer deactivation or removal |
## How to enable:
```c
// in config.h:
#define POINTING_DEVICE_AUTO_MOUSE_ENABLE
// only required if not setting mouse layer elsewhere
#define AUTO_MOUSE_DEFAULT_LAYER <index of your mouse layer>
// in keymap.c:
void pointing_device_init_user(void) {
set_auto_mouse_layer(<mouse_layer>); // only required if AUTO_MOUSE_DEFAULT_LAYER is not set to index of <mouse_layer>
set_auto_mouse_enable(true); // always required before the auto mouse feature will work
}
```
Because the auto mouse feature can be disabled/enabled during runtime and starts as disabled by default it must be enabled by calling `set_auto_mouse_enable(true);` somewhere in firmware before the feature will work.
_Note: for setting the target layer during initialization either setting `AUTO_MOUSE_DEFAULT_LAYER` in `config.h` or calling `set_auto_mouse_layer(<mouse_layer>)` can be used._
## How to Customize:
There are a few ways to control the auto mouse feature with both `config.h` options and functions for controlling it during runtime.
### `config.h` Options:
| Define | Description | Range | Units | Default |
| ----------------------------------- | --------------------------------------------------------------------- | :------------------: | :---------: | -------------------------: |
| `POINTING_DEVICE_AUTO_MOUSE_ENABLE` | (Required) Enables auto mouse layer feature | | _None_ | _Not defined_ |
| `AUTO_MOUSE_DEFAULT_LAYER` | (Optional) Index of layer to use as default target layer | 0 - `LAYER_MAX` | _`uint8_t`_ | `1` |
| `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` |
### Adding mouse keys
While all default mouse keys and layer keys(for current mouse layer) are treated as mouse keys, additional Keyrecords can be added to mouse keys by adding them to the is_mouse_record_* stack.
#### Callbacks for setting up additional key codes as mouse keys:
| Callback | Description |
| -------------------------------------------------------------------- | -------------------------------------------------- |
| `bool is_mouse_record_kb(uint16_t keycode, keyrecord_t* record)` | keyboard level callback for adding mouse keys |
| `bool is_mouse_record_user(uint16_t keycode, keyrecord_t* record)` | user/keymap level callback for adding mouse keys |
##### To use the callback function to add mouse keys:
The following code will cause the enter key and all of the arrow keys to be treated as mouse keys (hold target layer while they are pressed and reset active layer timer).
```c
// in <keyboard>.c:
bool is_mouse_record_kb(uint16_t keycode, keyrecord_t* record) {
switch(keycode) {
case KC_ENT:
return true;
case KC_RIGHT ... KC_UP:
return true;
default:
return false;
}
return is_mouse_record_user(keycode, record);
}
```
## Advanced control
There are several functions that allow for more advanced interaction with the auto mouse feature allowing for greater control.
### Functions to control auto mouse enable and target layer:
| Function | Description | Aliases | Return type |
| :--------------------------------------------------------- | ------------------------------------------------------------------------------------ | ------------------------- | --------------: |
| `set_auto_mouse_enable(bool enable)` | Enable or disable auto mouse (true:enable, false:disable) | | `void`(None) |
| `get_auto_mouse_enable(void)` | Return auto mouse enable state (true:enabled, false:disabled) | `AUTO_MOUSE_ENABLED` | `bool` |
| `set_auto_mouse_layer(uint8_t LAYER)` | Change/set the target layer for auto mouse | | `void`(None) |
| `get_auto_mouse_layer(void)` | Return auto mouse target layer index | `AUTO_MOUSE_TARGET_LAYER` | `uint8_t` |
| `remove_auto_mouse_layer(layer_state_t state, bool force)` | Return `state` with target layer removed if appropriate (ignore criteria if `force`) | | `layer_state_t` |
| `auto_mouse_layer_off(void)` | Disable target layer if appropriate will call (makes call to `layer_state_set`) | | `void`(None) |
| `auto_mouse_toggle(void)` | Toggle on/off target toggle state (disables layer deactivation when true) | | `void`(None) |
| `get_auto_mouse_toggle(void)` | Return value of toggling state variable | | `bool` |
_NOTES:_
- _Due to the nature of how some functions work, the `auto_mouse_trigger_reset`, and `auto_mouse_layer_off` functions should never be called in the `layer_state_set_*` stack as this can cause indefinite loops._
- _It is recommended that `remove_auto_mouse_layer` is used in the `layer_state_set_*` stack of functions and `auto_mouse_layer_off` is used everywhere else_
- _`remove_auto_mouse_layer(state, false)` or `auto_mouse_layer_off()` should be called before any instance of `set_auto_mouse_enabled(false)` or `set_auto_mouse_layer(layer)` to ensure that the target layer will be removed appropriately before disabling auto mouse or changing target to avoid a stuck layer_
### Functions for handling custom key events:
| Function | Description | Return type |
| :--------------------------------------------------------- | -------------------------------------------------------------------------------- | --------------: |
| `auto_mouse_keyevent(bool pressed)` | Auto mouse mouse key event (true: key down, false: key up) | `void`(None) |
| `auto_mouse_trigger_reset(bool pressed)` | Reset auto mouse status on key down and start delay timer (non-mouse key event) | `void`(None) |
| `auto_mouse_toggle(void)` | Toggle on/off target toggle state (disables layer deactivation when true) | `void`(None) |
| `get_auto_mouse_toggle(void)` | Return value of toggling state variable | `bool` |
_NOTE: Generally it would be preferable to use the `is_mouse_record_*` functions to add any additional keys that should act as mouse keys rather than adding `auto_mouse_keyevent(record.event->pressed)` to `process_records_*`_
### Advanced control examples
#### Disable auto mouse on certain layers:
The auto mouse feature can be disabled any time and this can be helpful if you want to disable the auto mouse feature under certain circumstances such as when particular layers are active. One issue however is the handling of the target layer, it needs to be removed appropriately **before** disabling auto mouse _(see notes under control functions above)_. The following function would disable the auto_mouse feature whenever the layers `_LAYER5` through `_LAYER7` are active as the top most layer _(ignoring target layer)_.
```c
// in keymap.c:
layer_state_t layer_state_set_user(layer_state_t state) {
// checks highest layer other than target layer
switch(get_highest_layer(remove_auto_mouse_layer(state, true))) {
case _LAYER5 ... _LAYER7:
// remove_auto_mouse_target must be called to adjust state *before* setting enable
state = remove_auto_mouse_layer(state, false);
set_auto_mouse_enable(false);
break;
default:
set_auto_mouse_enable(true);
break;
}
// recommend that any code that makes adjustment based on auto mouse layer state would go here
return state;
}
```
#### Set different target layer when a particular layer is active:
The below code will change the auto mouse layer target to `_MOUSE_LAYER_2` when `_DEFAULT_LAYER_2` is highest default layer state.
*NOTE: that `auto_mouse_layer_off` is used here instead of `remove_auto_mouse_layer` as `default_layer_state_set_*` stack is separate from the `layer_state_set_*` stack* if something similar was to be done in `layer_state_set_user `state = remove_auto_mouse_layer(state, false)` should be used instead
*ADDITIONAL NOTE: `AUTO_MOUSE_TARGET_LAYER` is checked if already set to avoid deactivating the target layer unless needed*
```c
// in keymap.c
layer_state_t default_layer_state_set_user(layer_state_t state) {
// switch on change in default layer need to check if target layer already set to avoid turning off layer needlessly
switch(get_highest_layer(state)) {
case _DEFAULT_LAYER_2:
if ((AUTO_MOUSE_TARGET_LAYER) == _MOUSE_LAYER_2) break;
auto_mouse_layer_off();
set_auto_mouse_layer(_MOUSE_LAYER_2);
break;
default:
if((AUTO_MOUSE_TARGET_LAYER) == _MOUSE_LAYER_1) break;
auto_mouse_layer_off();
set_auto_mouse_layer(_MOUSE_LAYER_1);
}
return state;
}
```
### Use custom keys to control auto mouse:
Custom key records could also be created that control the auto mouse feature.
The code example below would create a custom key that would toggle the auto mouse feature on and off when pressed while also setting a bool that could be used to disable other code that may turn it on such as the layer code above.
```c
// in config.h:
enum user_custom_keycodes {
AM_Toggle = SAFE_RANGE
};
// in keymap.c:
// set up global bool to adjust other user code
bool auto_mouse_tg_off = !AUTO_MOUSE_ENABLED;
bool process_record_user(uint16_t keycode, keyrecord_t* record) {
switch (keycode) {
// toggle auto mouse enable key
case AM_Toggle:
if(record->event.pressed) { // key down
auto_mouse_layer_off(); // disable target layer if needed
set_auto_mouse_enabled((AUTO_MOUSE_ENABLED) ^ 1);
auto_mouse_tg_off = !get_auto_mouse_enabled();
} // do nothing on key up
return false; // prevent further processing of keycode
}
}
```
## Customize Target Layer Activation
Layer activation can be customized by overwriting the `auto_mouse_activation` function. This function is checked every time `pointing_device_task` is called when inactive and every `AUTO_MOUSE_DEBOUNCE` ms when active, and will evaluate pointing device level conditions that trigger target layer activation. When it returns true, the target layer will be activated barring the usual exceptions _(e.g. delay time has not expired)_.
By default it will return true if any of the `mouse_report` axes `x`,`y`,`h`,`v` are non zero, or if there is any mouse buttons active in `mouse_report`.
_Note: The Cirque pinnacle track pad already implements a custom activation function that will activate on touchdown as well as movement all of the default conditions, currently this only works for the master side of split keyboards._
| Function | Description | Return type |
| :--------------------------------------------------------- | -------------------------------------------------------------------------------- | --------------: |
| `auto_mouse_activation(report_mouse_t mouse_report)` | Overwritable function that controls target layer activation (when true) | `bool` |
## Auto Mouse for Custom Pointing Device Task
When using a custom pointing device (overwriting `pointing_device_task`) the following code should be somewhere in the `pointing_device_task_*` stack:
```c
void pointing_device_task(void) {
//...Custom pointing device task code
// handle automatic mouse layer (needs report_mouse_t as input)
pointing_device_task_auto_mouse(local_mouse_report);
//...More custom pointing device task code
pointing_device_send();
}
```
In general the following two functions must be implemented in appropriate locations for auto mouse to function:
| Function | Description | Suggested location |
| -------------------------------------------------------------- | ------------------------------------------------------------ | ---------------------------: |
| `pointing_device_task_auto_mouse(report_mouse_t mouse_report)` | handles target layer activation and is_active status updates | `pointing_device_task` stack |
| `process_auto_mouse(uint16_t keycode, keyrecord_t* record)` | Keycode processing for auto mouse | `process_record` stack |

View File

@ -23,7 +23,7 @@ You can use between 1 and 4 IS31FL3731 IC's. Do not specify `DRIVER_ADDR_<N>` de
| `ISSI_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 |
| `ISSI_3731_DEGHOST` | (Optional) Set this define to enable de-ghosting by halving Vcc during blanking time | |
| `DRIVER_COUNT` | (Required) How many RGB driver IC's are present | |
| `DRIVER_LED_TOTAL` | (Required) How many RGB lights are present across all drivers | |
| `RGB_MATRIX_LED_COUNT` | (Required) How many RGB lights are present across all drivers | |
| `DRIVER_ADDR_1` | (Required) Address for the first RGB driver | |
| `DRIVER_ADDR_2` | (Optional) Address for the second RGB driver | |
| `DRIVER_ADDR_3` | (Optional) Address for the third RGB driver | |
@ -45,17 +45,17 @@ Here is an example using 2 drivers.
#define DRIVER_COUNT 2
#define DRIVER_1_LED_TOTAL 25
#define DRIVER_2_LED_TOTAL 24
#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
#define RGB_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
```
!> Note the parentheses, this is so when `DRIVER_LED_TOTAL` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
!> Note the parentheses, this is so when `RGB_MATRIX_LED_COUNT` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
For split keyboards using `RGB_MATRIX_SPLIT` with an LED driver, you can either have the same driver address or different driver addresses. If using different addresses, use `DRIVER_ADDR_1` for one and `DRIVER_ADDR_2` for the other one. Then, in `g_is31_leds`, fill out the correct driver index (0 or 1). If using one address, use `DRIVER_ADDR_1` for both, and use index 0 for `g_is31_leds`.
Define these arrays listing all the LEDs in your `<keyboard>.c`:
```c
const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {
const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT] = {
/* Refer to IS31 manual for these locations
* driver
* | R location
@ -90,7 +90,7 @@ You can use between 1 and 4 IS31FL3733 IC's. Do not specify `DRIVER_ADDR_<N>` de
| `ISSI_SWPULLUP` | (Optional) Set the value of the SWx lines on-chip de-ghosting resistors | PUR_0R (Disabled) |
| `ISSI_CSPULLUP` | (Optional) Set the value of the CSx lines on-chip de-ghosting resistors | PUR_0R (Disabled) |
| `DRIVER_COUNT` | (Required) How many RGB driver IC's are present | |
| `DRIVER_LED_TOTAL` | (Required) How many RGB lights are present across all drivers | |
| `RGB_MATRIX_LED_COUNT` | (Required) How many RGB lights are present across all drivers | |
| `DRIVER_ADDR_1` | (Required) Address for the first RGB driver | |
| `DRIVER_ADDR_2` | (Optional) Address for the second RGB driver | |
| `DRIVER_ADDR_3` | (Optional) Address for the third RGB driver | |
@ -131,17 +131,17 @@ Here is an example using 2 drivers.
#define DRIVER_COUNT 2
#define DRIVER_1_LED_TOTAL 58
#define DRIVER_2_LED_TOTAL 10
#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
#define RGB_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
```
!> Note the parentheses, this is so when `DRIVER_LED_TOTAL` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
!> Note the parentheses, this is so when `RGB_MATRIX_LED_COUNT` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
Currently only 4 drivers are supported, but it would be trivial to support all 8 combinations.
Define these arrays listing all the LEDs in your `<keyboard>.c`:
```c
const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {
const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT] = {
/* Refer to IS31 manual for these locations
* driver
* | R location
@ -177,7 +177,7 @@ Configure the hardware via your `config.h`:
| `ISSI_SWPULLUP` | (Optional) Set the value of the SWx lines on-chip de-ghosting resistors | PUR_0R (Disabled) |
| `ISSI_CSPULLUP` | (Optional) Set the value of the CSx lines on-chip de-ghosting resistors | PUR_0R (Disabled) |
| `DRIVER_COUNT` | (Required) How many RGB driver IC's are present | |
| `DRIVER_LED_TOTAL` | (Required) How many RGB lights are present across all drivers | |
| `RGB_MATRIX_LED_COUNT` | (Required) How many RGB lights are present across all drivers | |
| `DRIVER_ADDR_1` | (Required) Address for the first RGB driver | |
| `DRIVER_ADDR_2` | (Optional) Address for the second RGB driver | |
@ -212,16 +212,16 @@ Here is an example using 2 drivers.
#define DRIVER_COUNT 2
#define DRIVER_1_LED_TOTAL 30
#define DRIVER_2_LED_TOTAL 36
#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
#define RGB_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
```
!> Note the parentheses, this is so when `DRIVER_LED_TOTAL` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
!> Note the parentheses, this is so when `RGB_MATRIX_LED_COUNT` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
Currently only 2 drivers are supported, but it would be trivial to support all 4 combinations.
Define these arrays listing all the LEDs in your `<keyboard>.c`:
```c
const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {
const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT] = {
/* Refer to IS31 manual for these locations
* driver
* | R location
@ -263,7 +263,7 @@ Configure the hardware via your `config.h`:
| `ISSI_TIMEOUT` | (Optional) How long to wait for i2c messages, in milliseconds | 100 |
| `ISSI_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 |
| `DRIVER_COUNT` | (Required) How many RGB driver IC's are present | |
| `DRIVER_LED_TOTAL` | (Required) How many RGB lights are present across all drivers | |
| `RGB_MATRIX_LED_COUNT` | (Required) How many RGB lights are present across all drivers | |
| `DRIVER_ADDR_1` | (Optional) Address for the first RGB driver | |
| `DRIVER_ADDR_<N>` | (Required) Address for the additional RGB drivers | |
| `ISSI_SSR_<N>` | (Optional) Configuration for the Spread Spectrum Register | |
@ -300,17 +300,17 @@ Here is an example using 2 drivers.
#define DRIVER_COUNT 2
#define DRIVER_1_LED_TOTAL 66
#define DRIVER_2_LED_TOTAL 42
#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
#define RGB_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
```
!> Note the parentheses, this is so when `DRIVER_LED_TOTAL` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
!> Note the parentheses, this is so when `RGB_MATRIX_LED_COUNT` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
Currently only 4 drivers are supported, but it would be trivial to support for more. Note that using a combination of different drivers is not supported. All drivers must be of the same model.
Define these arrays listing all the LEDs in your `<keyboard>.c`:
```c
const is31_led __flash g_is31_leds[DRIVER_LED_TOTAL] = {
const is31_led __flash g_is31_leds[RGB_MATRIX_LED_COUNT] = {
/* Refer to IS31 manual for these locations
* driver
* | R location
@ -361,7 +361,7 @@ Configure the hardware via your `config.h`:
// The pin connected to the data pin of the LEDs
#define RGB_DI_PIN D7
// The number of LEDs connected
#define DRIVER_LED_TOTAL 70
#define RGB_MATRIX_LED_COUNT 70
```
?> There are additional configuration options for ARM controllers that offer increased performance over the default bitbang driver. Please see [WS2812 Driver](ws2812_driver.md) for more information.
@ -385,7 +385,7 @@ Configure the hardware via your `config.h`:
// The pin connected to the clock pin of the LEDs
#define RGB_CI_PIN D6
// The number of LEDs connected
#define DRIVER_LED_TOTAL 70
#define RGB_MATRIX_LED_COUNT 70
```
---
@ -408,7 +408,7 @@ You can use up to 2 AW20216 IC's. Do not specify `DRIVER_<N>_xxx` defines for IC
| `DRIVER_1_LED_TOTAL` | (Required) How many RGB lights are connected to first RGB driver | |
| `DRIVER_2_LED_TOTAL` | (Optional) How many RGB lights are connected to second RGB driver | |
| `DRIVER_COUNT` | (Required) How many RGB driver IC's are present | |
| `DRIVER_LED_TOTAL` | (Required) How many RGB lights are present across all drivers | |
| `RGB_MATRIX_LED_COUNT` | (Required) How many RGB lights are present across all drivers | |
| `AW_SCALING_MAX` | (Optional) LED current scaling value (0-255, higher values mean LED is brighter at full PWM) | 150 |
| `AW_GLOBAL_CURRENT_MAX` | (Optional) Driver global current limit (0-255, higher values means the driver may consume more power) | 150 |
| `AW_SPI_MODE` | (Optional) Mode for SPI communication (0-3, defines polarity and phase of the clock) | 3 |
@ -426,15 +426,15 @@ Here is an example using 2 drivers.
#define DRIVER_COUNT 2
#define DRIVER_1_LED_TOTAL 66
#define DRIVER_2_LED_TOTAL 32
#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
#define RGB_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
```
!> Note the parentheses, this is so when `DRIVER_LED_TOTAL` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
!> Note the parentheses, this is so when `RGB_MATRIX_LED_COUNT` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
Define these arrays listing all the LEDs in your `<keyboard>.c`:
```c
const aw_led PROGMEM g_aw_leds[DRIVER_LED_TOTAL] = {
const aw_led PROGMEM g_aw_leds[RGB_MATRIX_LED_COUNT] = {
/* Each AW20216 channel is controlled by a register at some offset between 0x00
* and 0xD7 inclusive.
* See drivers/awinic/aw20216.h for the mapping between register offsets and
@ -794,7 +794,7 @@ These are defined in [`color.h`](https://github.com/qmk/qmk_firmware/blob/master
#define RGB_DISABLE_TIMEOUT 0 // number of milliseconds to wait until rgb automatically turns off
#define RGB_DISABLE_AFTER_TIMEOUT 0 // OBSOLETE: number of ticks to wait until disabling effects
#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
#define RGB_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5 // limits the number of LEDs to process in an animation per task run (increases keyboard responsiveness)
#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_STARTUP_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT // Sets the default mode, if none has been set
@ -824,7 +824,7 @@ Where `28` is an unused index from `eeconfig.h`.
|Function |Description |
|--------------------------------------------|-------------|
|`rgb_matrix_set_color_all(r, g, b)` |Set all of the LEDs to the given RGB value, where `r`/`g`/`b` are between 0 and 255 (not written to EEPROM) |
|`rgb_matrix_set_color(index, r, g, b)` |Set a single LED to the given RGB value, where `r`/`g`/`b` are between 0 and 255, and `index` is between 0 and `DRIVER_LED_TOTAL` (not written to EEPROM) |
|`rgb_matrix_set_color(index, r, g, b)` |Set a single LED to the given RGB value, where `r`/`g`/`b` are between 0 and 255, and `index` is between 0 and `RGB_MATRIX_LED_COUNT` (not written to EEPROM) |
### Disable/Enable Effects :id=disable-enable-effects
|Function |Description |

View File

@ -92,11 +92,10 @@ These keycodes allow the processing to fall through to lower layers in search of
For this example we will walk through an [older version of the default Clueboard 66% keymap](https://github.com/qmk/qmk_firmware/blob/ca01d94005f67ec4fa9528353481faa622d949ae/keyboards/clueboard/keymaps/default/keymap.c). You'll find it helpful to open that file in another browser window so you can look at everything in context.
There are 3 main sections of a `keymap.c` file you'll want to concern yourself with:
There are 2 main sections of a `keymap.c` file you'll want to concern yourself with:
* [The Definitions](#definitions)
* [The Layer/Keymap Datastructure](#layers-and-keymaps)
* [Custom Functions](#custom-functions), if any
### Definitions

View File

@ -52,6 +52,9 @@ https://github.com/qmk/qmk_firmware/pulls?q=is%3Apr+is%3Aclosed+label%3Akeyboard
- valid maintainer
- valid USB VID/PID and device version
- displays correctly in Configurator (press Ctrl+Shift+I to preview local file, turn on fast input to verify ordering)
- `layout` definitions should include matrix positions, so that `LAYOUT` macros can be generated at build time
- should use standard definitions if applicable
- use the Community Layout macro names where they apply (preferred above `LAYOUT`/`LAYOUT_all`)
- `readme.md`
- standard template should be present -- [link to template](https://github.com/qmk/qmk_firmware/blob/master/data/templates/keyboard/readme.md)
- flash command is present, and has `:flash` at end
@ -82,17 +85,15 @@ https://github.com/qmk/qmk_firmware/pulls?q=is%3Apr+is%3Aclosed+label%3Akeyboard
- Vial-related files or changes will not be accepted, as they are not used by QMK firmware (no Vial-specific core code has been submitted or merged)
- `<keyboard>.c`
- empty `xxxx_xxxx_kb()` or other weak-defined default implemented functions removed
- empty `xxxx_xxxx_user()` or other user-level functions are disallowed at the keyboard level and must be moved to keymaps
- commented-out functions removed too
- `matrix_init_board()` etc. migrated to `keyboard_pre_init_kb()`, see: [keyboard_pre_init*](custom_quantum_functions.md?id=keyboard_pre_init_-function-documentation)
- prefer `CUSTOM_MATRIX = lite` if custom matrix used, allows for standard debounce, see [custom matrix 'lite'](custom_matrix.md?id=lite)
- prefer LED indicator [Configuration Options](feature_led_indicators.md?id=configuration-options) to custom `led_update_*()` implementations where possible
- Encoder support should not be hacked into the keymap here -- no `tap_code(dynamic_keymap_get_keycode())` or `action_exec()` hacks. The [Encoder Map](feature_encoders.md?id=encoder-map) feature already supports the dynamic keymap feature (what power's VIA's "live keymap updates" capability).
- If support is absolutely necessary, it should be implemented exclusively at the keymap level, with none of the implementation bleeding into the keyboard level (no empty rows/columns, no encoder specific layouts, etc.), as those configurations can be redefined at the keymap level. Keymaps can then choose to use the `action_exec` hack. <!-- because people will complain, give them a way to implement it, in the meanwhile. To be removed. -->
- [Request for official proper VIA support](https://github.com/the-via/app/issues/26)
- Encoder support should not require any keyboard-level code, and associated keymaps should now leverage the [Encoder Map](feature_encoders.md?id=encoder-map) feature instead.
- `<keyboard>.h`
- `#include "quantum.h"` appears at the top
- `LAYOUT` macros should use standard definitions if applicable
- use the Community Layout macro names where they apply (preferred above `LAYOUT`/`LAYOUT_all`)
- `LAYOUT` macros should be moved to `info.json`
- keymap `config.h`
- no duplication of `rules.mk` or `config.h` from keyboard
- `keymaps/default/keymap.c`
@ -111,7 +112,7 @@ https://github.com/qmk/qmk_firmware/pulls?q=is%3Apr+is%3Aclosed+label%3Akeyboard
- submitters can have a personal (or bells-and-whistles) keymap showcasing capabilities in the same PR but it shouldn't be embedded in the 'default' keymap
- submitters can also have a "manufacturer-matching" keymap that mirrors existing functionality of the commercial product, if porting an existing board
- Do not include VIA json files in the PR. These do not belong in the QMK repository as they are not used by QMK firmware -- they belong in the [VIA Keyboard Repo](https://github.com/the-via/keyboards)
- Do not include source files from another keyboard or vendors keyboard folder. Including core files is fine.
- Do not include source files from another keyboard or vendors keyboard folder. Including core files is fine.
- For instance, only `wilba_tech` boards using be including `keyboards/wilba_tech/wt_main.c` and `keyboards/wilba_tech/wt_rgb_backlight.c`. But including `drivers/sensors/pmw3360.c` is absolutely fine.
- Code that needs to be used by multiple boards is a candidate for core code changes, and should be separated out.
@ -134,6 +135,7 @@ Also, specific to ChibiOS:
- for new MCUs, a new "child" keyboard should be added that targets your newly-added MCU, so that builds can be verified
- for new hardware support such as display panels, core-side matrix implementations, or other peripherals, an associated keymap should be provided
- if an existing keymap exists that can leverage this functionality this may not be required (e.g. a new RGB driver chip, supported by the `rgb` keymap) -- consult with the QMK Collaborators on Discord to determine if there is sufficient overlap already
- any features adding `_kb`/`_user` callbacks must return a `bool`, to allow for user override of keyboard-level callbacks.
- other requirements are at the discretion of QMK collaborators
- core is a lot more subjective given the breadth of posted changes

View File

@ -8,7 +8,7 @@ To enable overall Quantum Painter to be built into your firmware, add the follow
```make
QUANTUM_PAINTER_ENABLE = yes
QUANTUM_PAINTER_DRIVERS = ......
QUANTUM_PAINTER_DRIVERS += ......
```
You will also likely need to select an appropriate driver in `rules.mk`, which is listed below.
@ -17,17 +17,18 @@ You will also likely need to select an appropriate driver in `rules.mk`, which i
The QMK CLI can be used to convert from normal images such as PNG files or animated GIFs, as well as fonts from TTF files.
Hardware supported:
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` |
| ST7789 | RGB LCD | 240x320, 240x240 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS = st7789_spi` |
| ST7735 | RGB LCD | 132x162, 80x160 | SPI + D/C + RST | `QUANTUM_PAINTER_DRIVERS = st7735_spi` |
| 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` |
| RGB565 Surface | Virtual | User-defined | None | `QUANTUM_PAINTER_DRIVERS += rgb565_surface` |
## Quantum Painter Configuration :id=quantum-painter-config
@ -45,7 +46,9 @@ Drivers have their own set of configurable options, and are described in their r
## Quantum Painter CLI Commands :id=quantum-painter-cli
### `qmk painter-convert-graphics`
<!-- tabs:start -->
### ** `qmk painter-convert-graphics` **
This command converts images to a format usable by QMK, i.e. the QGF File Format.
@ -93,7 +96,7 @@ Writing /home/qmk/qmk_firmware/keyboards/my_keeb/generated/my_image.qgf.h...
Writing /home/qmk/qmk_firmware/keyboards/my_keeb/generated/my_image.qgf.c...
```
### `qmk painter-make-font-image`
### ** `qmk painter-make-font-image` **
This command converts a TTF font to an intermediate format for editing, before converting to the QFF File Format.
@ -126,7 +129,7 @@ The `UNICODE_GLYPHS` argument allows for specifying extra unicode glyphs to gene
$ qmk painter-make-font-image --font NotoSans-ExtraCondensedBold.ttf --size 11 -o noto11.png --unicode-glyphs "ĄȽɂɻɣɈʣ"
```
### `qmk painter-convert-font-image`
### ** `qmk painter-convert-font-image` **
This command converts an intermediate font image to the QFF File Format.
@ -170,6 +173,255 @@ Writing /home/qmk/qmk_firmware/keyboards/my_keeb/generated/noto11.qff.h...
Writing /home/qmk/qmk_firmware/keyboards/my_keeb/generated/noto11.qff.c...
```
<!-- tabs:end -->
## Quantum Painter Display Drivers :id=quantum-painter-drivers
<!-- tabs:start -->
### ** Common: Standard TFT (SPI + D/C + RST) **
Most TFT display panels use a 5-pin interface -- SPI SCK, SPI MOSI, SPI CS, D/C, and RST pins.
For these displays, QMK's `spi_master` must already be correctly configured for the platform you're building for.
The pin assignments for SPI CS, D/C, and RST are specified during device construction.
<!-- tabs:start -->
#### ** GC9A01 **
Enabling support for the GC9A01 in Quantum Painter is done by adding the following to `rules.mk`:
```make
QUANTUM_PAINTER_ENABLE = yes
QUANTUM_PAINTER_DRIVERS += gc9a01_spi
```
Creating a GC9A01 device in firmware can then be done with the following API:
```c
painter_device_t qp_gc9a01_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);
```
The device handle returned from the `qp_gc9a01_make_spi_device` function 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 GC9A01_NUM_DEVICES 3
```
#### ** ILI9163 **
Enabling support for the ILI9163 in Quantum Painter is done by adding the following to `rules.mk`:
```make
QUANTUM_PAINTER_ENABLE = yes
QUANTUM_PAINTER_DRIVERS += ili9163_spi
```
Creating a ILI9163 device in firmware can then be done with the following API:
```c
painter_device_t qp_ili9163_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);
```
The device handle returned from the `qp_ili9163_make_spi_device` function 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 ILI9163_NUM_DEVICES 3
```
#### ** ILI9341 **
Enabling support for the ILI9341 in Quantum Painter is done by adding the following to `rules.mk`:
```make
QUANTUM_PAINTER_ENABLE = yes
QUANTUM_PAINTER_DRIVERS += ili9341_spi
```
Creating a ILI9341 device in firmware can then be done with the following API:
```c
painter_device_t qp_ili9341_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);
```
The device handle returned from the `qp_ili9341_make_spi_device` function 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 ILI9341_NUM_DEVICES 3
```
#### ** ILI9488 **
Enabling support for the ILI9488 in Quantum Painter is done by adding the following to `rules.mk`:
```make
QUANTUM_PAINTER_ENABLE = yes
QUANTUM_PAINTER_DRIVERS += ili9488_spi
```
Creating a ILI9488 device in firmware can then be done with the following API:
```c
painter_device_t qp_ili9488_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);
```
The device handle returned from the `qp_ili9488_make_spi_device` function 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 ILI9488_NUM_DEVICES 3
```
#### ** SSD1351 **
Enabling support for the SSD1351 in Quantum Painter is done by adding the following to `rules.mk`:
```make
QUANTUM_PAINTER_ENABLE = yes
QUANTUM_PAINTER_DRIVERS += ssd1351_spi
```
Creating a SSD1351 device in firmware can then be done with the following API:
```c
painter_device_t qp_ssd1351_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);
```
The device handle returned from the `qp_ssd1351_make_spi_device` function 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 SSD1351_NUM_DEVICES 3
```
#### ** ST7735 **
Enabling support for the ST7735 in Quantum Painter is done by adding the following to `rules.mk`:
```make
QUANTUM_PAINTER_ENABLE = yes
QUANTUM_PAINTER_DRIVERS += st7735_spi
```
Creating a ST7735 device in firmware can then be done with the following API:
```c
painter_device_t qp_st7735_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);
```
The device handle returned from the `qp_st7735_make_spi_device` function 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 ST7735_NUM_DEVICES 3
```
!> Some ST7735 devices are known to have different drawing offsets -- despite being a 132x162 pixel display controller internally, some display panels are only 80x160, or smaller. These may require an offset to be applied; see `qp_set_viewport_offsets` above for information on how to override the offsets if they aren't correctly rendered.
#### ** ST7789 **
Enabling support for the ST7789 in Quantum Painter is done by adding the following to `rules.mk`:
```make
QUANTUM_PAINTER_ENABLE = yes
QUANTUM_PAINTER_DRIVERS += st7789_spi
```
Creating a ST7789 device in firmware can then be done with the following API:
```c
painter_device_t qp_st7789_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);
```
The device handle returned from the `qp_st7789_make_spi_device` function 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 ST7789_NUM_DEVICES 3
```
!> Some ST7789 devices are known to have different drawing offsets -- despite being a 240x320 pixel display controller internally, some display panels are only 240x240, or smaller. These may require an offset to be applied; see `qp_set_viewport_offsets` above for information on how to override the offsets if they aren't correctly rendered.
<!-- tabs:end -->
### ** Common: Surfaces **
Quantum Painter has surface drivers which are able to target a buffer in RAM. In general, surfaces keep track of the "dirty" region -- the area that has been drawn to since the last flush -- so that when transferring to the display they can transfer the minimal amount of data to achieve the end result.
!> These generally require significant amounts of RAM, so at large sizes and/or higher bit depths, they may not be usable on all MCUs.
<!-- tabs:start -->
#### ** RGB565 Surface **
Enabling support for RGB565 surfaces in Quantum Painter is done by adding the following to `rules.mk`:
```make
QUANTUM_PAINTER_ENABLE = yes
QUANTUM_PAINTER_DRIVERS += rgb565_surface
```
Creating a RGB565 surface in firmware can then be done with the following API:
```c
painter_device_t qp_rgb565_make_surface(uint16_t panel_width, uint16_t panel_height, void *buffer);
```
The `buffer` is a user-supplied area of memory, and is assumed to be of the size `sizeof(uint16_t) * panel_width * panel_height`.
The device handle returned from the `qp_rgb565_make_surface` function can be used to perform all other drawing operations.
Example:
```c
static painter_device_t my_surface;
static uint16_t my_framebuffer[320 * 240]; // Allocate a buffer for a 320x240 RGB565 display
void keyboard_post_init_kb(void) {
my_surface = qp_rgb565_make_surface(320, 240, my_framebuffer);
qp_init(my_surface, QP_ROTATION_0);
}
```
The maximum number of RGB565 surfaces can be configured by changing the following in your `config.h` (default is 1):
```c
// 3 surfaces:
#define RGB565_SURFACE_NUM_DEVICES 3
```
To transfer the contents of the RGB565 surface to another display, the following API can be invoked:
```c
bool qp_rgb565_surface_draw(painter_device_t surface, painter_device_t display, uint16_t x, uint16_t y);
```
The `surface` is the surface to copy out from. The `display` is the target display to draw into. `x` and `y` are the target location to draw the surface pixel data. Under normal circumstances, the location should be consistent, as the dirty region is calculated with respect to the `x` and `y` coordinates -- changing those will result in partial, overlapping draws.
?> Calling `qp_flush()` on the surface resets its dirty region. Copying the surface contents to the display also automatically resets the dirty region.
<!-- tabs:end -->
<!-- tabs:end -->
## Quantum Painter Drawing API :id=quantum-painter-api
All APIs require a `painter_device_t` object as their first parameter -- this object comes from the specific device initialisation, and instructions on creating it can be found in each driver's respective section.
@ -179,7 +431,9 @@ To use any of the APIs, you need to include `qp.h`:
#include <qp.h>
```
### General Notes :id=quantum-painter-api-general
<!-- tabs:start -->
### ** General Notes **
The coordinate system used in Quantum Painter generally accepts `left`, `top`, `right`, and `bottom` instead of x/y/width/height, and each coordinate is inclusive of where pixels should be drawn. This is required as some datatypes used by display panels have a maximum value of `255` -- for any value or geometry extent that matches `256`, this would be represented as a `0`, instead.
@ -193,9 +447,11 @@ All color data matches the standard QMK HSV triplet definitions:
?> Colors used in Quantum Painter are not subject to the RGB lighting CIE curve, if it is enabled.
### Device Control :id=quantum-painter-api-device-control
### ** Device Control **
#### Display Initialisation :id=quantum-painter-api-init
<!-- tabs:start -->
#### ** Display Initialisation **
```c
bool qp_init(painter_device_t device, painter_rotation_t rotation);
@ -211,7 +467,7 @@ void keyboard_post_init_kb(void) {
}
```
#### Display Power :id=quantum-painter-api-power
#### ** Display Power **
```c
bool qp_power(painter_device_t device, bool power_on);
@ -242,7 +498,7 @@ void suspend_wakeup_init_user(void) {
}
```
#### Display Clear :id=quantum-painter-api-clear
#### ** Display Clear **
```c
bool qp_clear(painter_device_t device);
@ -250,7 +506,7 @@ bool qp_clear(painter_device_t device);
The `qp_clear` function clears the display's screen.
#### Display Flush :id=quantum-painter-api-flush
#### ** Display Flush **
```c
bool qp_flush(painter_device_t device);
@ -272,9 +528,13 @@ void housekeeping_task_user(void) {
}
```
### Drawing Primitives :id=quantum-painter-api-primitives
<!-- tabs:end -->
#### Set Pixel :id=quantum-painter-api-setpixel
### ** Drawing Primitives **
<!-- tabs:start -->
#### ** Set Pixel **
```c
bool qp_setpixel(painter_device_t device, uint16_t x, uint16_t y, uint8_t hue, uint8_t sat, uint8_t val);
@ -298,7 +558,7 @@ void housekeeping_task_user(void) {
}
```
#### Draw Line :id=quantum-painter-api-line
#### ** Draw Line **
```c
bool qp_line(painter_device_t device, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t hue, uint8_t sat, uint8_t val);
@ -320,7 +580,7 @@ void housekeeping_task_user(void) {
}
```
#### Draw Rect :id=quantum-painter-api-rect
#### ** Draw Rect **
```c
bool qp_rect(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom, uint8_t hue, uint8_t sat, uint8_t val, bool filled);
@ -342,7 +602,7 @@ void housekeeping_task_user(void) {
}
```
#### Draw Circle :id=quantum-painter-api-circle
#### ** Draw Circle **
```c
bool qp_circle(painter_device_t device, uint16_t x, uint16_t y, uint16_t radius, uint8_t hue, uint8_t sat, uint8_t val, bool filled);
@ -364,7 +624,7 @@ void housekeeping_task_user(void) {
}
```
#### Draw Ellipse :id=quantum-painter-api-ellipse
#### ** Draw Ellipse **
```c
bool qp_ellipse(painter_device_t device, uint16_t x, uint16_t y, uint16_t sizex, uint16_t sizey, uint8_t hue, uint8_t sat, uint8_t val, bool filled);
@ -386,9 +646,24 @@ void housekeeping_task_user(void) {
}
```
### Image Functions :id=quantum-painter-api-images
<!-- tabs:end -->
#### Load Image :id=quantum-painter-api-load-image
### ** Image Functions **
Making an image available for use requires compiling it into your firmware. To do so, assuming you've created `my_image.qgf.c` and `my_image.qgf.h` as per the CLI examples above, you'd add the following to your `rules.mk`:
```make
SRC += my_image.qgf.c
```
...and in your `keymap.c`, you'd add to the top of the file:
```c
#include "my_image.qgf.h"
```
<!-- tabs:start -->
#### ** Load Image **
```c
painter_image_handle_t qp_load_image_mem(const void *buffer);
@ -396,7 +671,7 @@ painter_image_handle_t qp_load_image_mem(const void *buffer);
The `qp_load_image_mem` function loads a QGF image from memory or flash.
`qp_load_image_mem` returns a handle to the loaded image, which can then be used to draw to the screen using `qp_drawimage`, `qp_drawimage_recolor`, `qp_animate`, or `qp_animate_recolor`. If an image is no longer required, it can be unloaded by calling `qp_close_image` below.
`qp_load_image_mem` returns a handle to the loaded image, which can then be used to draw to the screen using `qp_drawimage`, `qp_drawimage_recolor`, `qp_animate`, or `qp_animate_recolor`. If an image is no longer required, it can be unloaded by calling `qp_close_image` below.
See the [CLI Commands](quantum_painter.md?id=quantum-painter-cli) for instructions on how to convert images to [QGF](quantum_painter_qgf.md).
@ -410,7 +685,7 @@ Image information is available through accessing the handle:
| Height | `image->height` |
| Frame Count | `image->frame_count` |
#### Unload Image :id=quantum-painter-api-close-image
#### ** Unload Image **
```c
bool qp_close_image(painter_image_handle_t image);
@ -418,7 +693,7 @@ bool qp_close_image(painter_image_handle_t image);
The `qp_close_image` function releases resources related to the loading of the supplied image.
#### Draw image :id=quantum-painter-api-draw-image
#### ** Draw image **
```c
bool qp_drawimage(painter_device_t device, uint16_t x, uint16_t y, painter_image_handle_t image);
@ -438,7 +713,7 @@ void keyboard_post_init_kb(void) {
}
```
#### Animate Image :id=quantum-painter-api-animate-image
#### ** Animate Image **
```c
deferred_token qp_animate(painter_device_t device, uint16_t x, uint16_t y, painter_image_handle_t image);
@ -463,7 +738,7 @@ void keyboard_post_init_kb(void) {
}
```
#### Stop Animation :id=quantum-painter-api-stop-animation
#### ** Stop Animation **
```c
void qp_stop_animation(deferred_token anim_token);
@ -478,9 +753,24 @@ void housekeeping_task_user(void) {
}
```
### Font Functions :id=quantum-painter-api-fonts
<!-- tabs:end -->
#### Load Font :id=quantum-painter-api-load-font
### ** Font Functions **
Making a font available for use requires compiling it into your firmware. To do so, assuming you've created `my_font.qff.c` and `my_font.qff.h` as per the CLI examples above, you'd add the following to your `rules.mk`:
```make
SRC += noto11.qff.c
```
...and in your `keymap.c`, you'd add to the top of the file:
```c
#include "noto11.qff.h"
```
<!-- tabs: start -->
#### ** Load Font **
```c
painter_font_handle_t qp_load_font_mem(const void *buffer);
@ -488,7 +778,7 @@ painter_font_handle_t qp_load_font_mem(const void *buffer);
The `qp_load_font_mem` function loads a QFF font from memory or flash.
`qp_load_font_mem` returns a handle to the loaded font, which can then be measured using `qp_textwidth`, or drawn to the screen using `qp_drawtext`, or `qp_drawtext_recolor`. If a font is no longer required, it can be unloaded by calling `qp_close_font` below.
`qp_load_font_mem` returns a handle to the loaded font, which can then be measured using `qp_textwidth`, or drawn to the screen using `qp_drawtext`, or `qp_drawtext_recolor`. If a font is no longer required, it can be unloaded by calling `qp_close_font` below.
See the [CLI Commands](quantum_painter.md?id=quantum-painter-cli) for instructions on how to convert TTF fonts to [QFF](quantum_painter_qff.md).
@ -500,7 +790,7 @@ Font information is available through accessing the handle:
|-------------|----------------------|
| Line Height | `image->line_height` |
#### Unload Font :id=quantum-painter-api-close-font
#### ** Unload Font **
```c
bool qp_close_font(painter_font_handle_t font);
@ -508,7 +798,7 @@ bool qp_close_font(painter_font_handle_t font);
The `qp_close_font` function releases resources related to the loading of the supplied font.
#### Measure Text :id=quantum-painter-api-textwidth
#### ** Measure Text **
```c
int16_t qp_textwidth(painter_font_handle_t font, const char *str);
@ -516,7 +806,7 @@ int16_t qp_textwidth(painter_font_handle_t font, const char *str);
The `qp_textwidth` function allows measurement of how many pixels wide the supplied string would result in, for the given font.
#### Draw Text :id=quantum-painter-api-drawtext
#### ** Draw Text **
```c
int16_t qp_drawtext(painter_device_t device, uint16_t x, uint16_t y, painter_font_handle_t font, const char *str);
@ -529,7 +819,7 @@ The `qp_drawtext` and `qp_drawtext_recolor` functions draw the supplied string t
// Draw a text message on the bottom-right of the 240x320 display on initialisation
static painter_font_handle_t my_font;
void keyboard_post_init_kb(void) {
my_font = qp_load_font_mem(font_opensans);
my_font = qp_load_font_mem(font_noto11);
if (my_font != NULL) {
static const char *text = "Hello from QMK!";
int16_t width = qp_textwidth(my_font, text);
@ -538,9 +828,13 @@ void keyboard_post_init_kb(void) {
}
```
### Advanced Functions :id=quantum-painter-api-advanced
<!-- tabs:end -->
#### Get Geometry :id=quantum-painter-api-get-geometry
### ** Advanced Functions **
<!-- tabs:start -->
#### ** Get Geometry **
```c
void qp_get_geometry(painter_device_t device, uint16_t *width, uint16_t *height, painter_rotation_t *rotation, uint16_t *offset_x, uint16_t *offset_y);
@ -548,7 +842,7 @@ void qp_get_geometry(painter_device_t device, uint16_t *width, uint16_t *height,
The `qp_get_geometry` function allows external code to retrieve the current width, height, rotation, and drawing offsets.
#### Set Viewport Offsets :id=quantum-painter-api-set-viewport
#### ** Set Viewport Offsets **
```c
void qp_set_viewport_offsets(painter_device_t device, uint16_t offset_x, uint16_t offset_y);
@ -556,7 +850,7 @@ void qp_set_viewport_offsets(painter_device_t device, uint16_t offset_x, uint16_
The `qp_set_viewport_offsets` function can be used to offset all subsequent drawing operations. For example, if a display controller is internally 240x320, but the display panel is 240x240 and has a Y offset of 80 pixels, you could invoke `qp_set_viewport_offsets(display, 0, 80);` and the drawing positioning would be corrected.
#### Set Viewport :id=quantum-painter-api-viewport
#### ** Set Viewport **
```c
bool qp_viewport(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom);
@ -564,7 +858,7 @@ bool qp_viewport(painter_device_t device, uint16_t left, uint16_t top, uint16_t
The `qp_viewport` function controls where raw pixel data is written to.
#### Stream Pixel Data :id=quantum-painter-api-pixdata
#### ** Stream Pixel Data **
```c
bool qp_pixdata(painter_device_t device, const void *pixel_data, uint32_t native_pixel_count);
@ -574,184 +868,6 @@ The `qp_pixdata` function allows raw pixel data to be streamed to the display. I
!> Under normal circumstances, users will not need to manually call either `qp_viewport` or `qp_pixdata`. These allow for writing of raw pixel information, in the display panel's native format, to the area defined by the viewport.
## Quantum Painter Display Drivers :id=quantum-painter-drivers
<!-- tabs:end -->
### Common: Standard TFT (SPI + D/C + RST)
Most TFT display panels use a 5-pin interface -- SPI SCK, SPI MOSI, SPI CS, D/C, and RST pins.
For these displays, QMK's `spi_master` must already be correctly configured for the platform you're building for.
The pin assignments for SPI CS, D/C, and RST are specified during device construction.
### GC9A01 :id=qp-driver-gc9a01
Enabling support for the GC9A01 in Quantum Painter is done by adding the following to `rules.mk`:
```make
QUANTUM_PAINTER_ENABLE = yes
QUANTUM_PAINTER_DRIVERS = gc9a01_spi
```
Creating a GC9A01 device in firmware can then be done with the following API:
```c
painter_device_t qp_gc9a01_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);
```
The device handle returned from the `qp_gc9a01_make_spi_device` function 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 GC9A01_NUM_DEVICES 3
```
### ILI9163 :id=qp-driver-ili9163
Enabling support for the ILI9163 in Quantum Painter is done by adding the following to `rules.mk`:
```make
QUANTUM_PAINTER_ENABLE = yes
QUANTUM_PAINTER_DRIVERS = ili9163_spi
```
Creating a ILI9163 device in firmware can then be done with the following API:
```c
painter_device_t qp_ili9163_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);
```
The device handle returned from the `qp_ili9163_make_spi_device` function 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 ILI9163_NUM_DEVICES 3
```
### ILI9341 :id=qp-driver-ili9341
Enabling support for the ILI9341 in Quantum Painter is done by adding the following to `rules.mk`:
```make
QUANTUM_PAINTER_ENABLE = yes
QUANTUM_PAINTER_DRIVERS = ili9341_spi
```
Creating a ILI9341 device in firmware can then be done with the following API:
```c
painter_device_t qp_ili9341_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);
```
The device handle returned from the `qp_ili9341_make_spi_device` function 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 ILI9341_NUM_DEVICES 3
```
### ILI9488 :id=qp-driver-ili9488
Enabling support for the ILI9488 in Quantum Painter is done by adding the following to `rules.mk`:
```make
QUANTUM_PAINTER_ENABLE = yes
QUANTUM_PAINTER_DRIVERS = ili9488_spi
```
Creating a ILI9488 device in firmware can then be done with the following API:
```c
painter_device_t qp_ili9488_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);
```
The device handle returned from the `qp_ili9488_make_spi_device` function 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 ILI9488_NUM_DEVICES 3
```
### SSD1351 :id=qp-driver-ssd1351
Enabling support for the SSD1351 in Quantum Painter is done by adding the following to `rules.mk`:
```make
QUANTUM_PAINTER_ENABLE = yes
QUANTUM_PAINTER_DRIVERS = ssd1351_spi
```
Creating a SSD1351 device in firmware can then be done with the following API:
```c
painter_device_t qp_ssd1351_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);
```
The device handle returned from the `qp_ssd1351_make_spi_device` function 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 SSD1351_NUM_DEVICES 3
```
### ST7789 :id=qp-driver-st7789
Enabling support for the ST7789 in Quantum Painter is done by adding the following to `rules.mk`:
```make
QUANTUM_PAINTER_ENABLE = yes
QUANTUM_PAINTER_DRIVERS = st7789_spi
```
Creating a ST7789 device in firmware can then be done with the following API:
```c
painter_device_t qp_st7789_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);
```
The device handle returned from the `qp_st7789_make_spi_device` function 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 ST7789_NUM_DEVICES 3
```
!> Some ST7789 devices are known to have different drawing offsets -- despite being a 240x320 pixel display controller internally, some display panels are only 240x240, or smaller. These may require an offset to be applied; see `qp_set_viewport_offsets` above for information on how to override the offsets if they aren't correctly rendered.
### ST7735 :id=qp-driver-st7735
Enabling support for the ST7735 in Quantum Painter is done by adding the following to `rules.mk`:
```make
QUANTUM_PAINTER_ENABLE = yes
QUANTUM_PAINTER_DRIVERS = st7735_spi
```
Creating a ST7735 device in firmware can then be done with the following API:
```c
painter_device_t qp_st7735_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);
```
The device handle returned from the `qp_st7735_make_spi_device` function 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 ST7735_NUM_DEVICES 3
```
!> Some ST7735 devices are known to have different drawing offsets -- despite being a 132x162 pixel display controller internally, some display panels are only 80x160, or smaller. These may require an offset to be applied; see `qp_set_viewport_offsets` above for information on how to override the offsets if they aren't correctly rendered.
<!-- tabs:end -->

View File

@ -133,7 +133,7 @@ void AW20216_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
}
void AW20216_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
for (uint8_t i = 0; i < RGB_MATRIX_LED_COUNT; i++) {
AW20216_set_color(i, red, green, blue);
}
}

View File

@ -28,7 +28,7 @@ typedef struct aw_led {
uint8_t b;
} aw_led;
extern const aw_led PROGMEM g_aw_leds[DRIVER_LED_TOTAL];
extern const aw_led PROGMEM g_aw_leds[RGB_MATRIX_LED_COUNT];
void AW20216_init(pin_t cs_pin, pin_t en_pin);
void AW20216_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);

View File

@ -148,7 +148,7 @@ void CKLED2001_init(uint8_t addr) {
void CKLED2001_set_value(int index, uint8_t value) {
ckled2001_led led;
if (index >= 0 && index < DRIVER_LED_TOTAL) {
if (index >= 0 && index < LED_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_ckled2001_leds[index]), sizeof(led));
g_pwm_buffer[led.driver][led.v] = value;
@ -157,7 +157,7 @@ void CKLED2001_set_value(int index, uint8_t value) {
}
void CKLED2001_set_value_all(uint8_t value) {
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
for (int i = 0; i < LED_MATRIX_LED_COUNT; i++) {
CKLED2001_set_value(i, value);
}
}

View File

@ -25,7 +25,7 @@ typedef struct ckled2001_led {
uint8_t v;
} __attribute__((packed)) ckled2001_led;
extern const ckled2001_led PROGMEM g_ckled2001_leds[DRIVER_LED_TOTAL];
extern const ckled2001_led PROGMEM g_ckled2001_leds[LED_MATRIX_LED_COUNT];
void CKLED2001_init(uint8_t addr);
bool CKLED2001_write_register(uint8_t addr, uint8_t reg, uint8_t data);

View File

@ -148,7 +148,7 @@ void CKLED2001_init(uint8_t addr) {
void CKLED2001_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
ckled2001_led led;
if (index >= 0 && index < DRIVER_LED_TOTAL) {
if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_ckled2001_leds[index]), sizeof(led));
g_pwm_buffer[led.driver][led.r] = red;
@ -159,7 +159,7 @@ void CKLED2001_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
}
void CKLED2001_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) {
CKLED2001_set_color(i, red, green, blue);
}
}

View File

@ -27,7 +27,7 @@ typedef struct ckled2001_led {
uint8_t b;
} __attribute__((packed)) ckled2001_led;
extern const ckled2001_led PROGMEM g_ckled2001_leds[DRIVER_LED_TOTAL];
extern const ckled2001_led PROGMEM g_ckled2001_leds[RGB_MATRIX_LED_COUNT];
void CKLED2001_init(uint8_t addr);
bool CKLED2001_write_register(uint8_t addr, uint8_t reg, uint8_t data);

View File

@ -194,7 +194,7 @@ void IS31FL3731_init(uint8_t addr) {
void IS31FL3731_set_value(int index, uint8_t value) {
is31_led led;
if (index >= 0 && index < DRIVER_LED_TOTAL) {
if (index >= 0 && index < LED_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
// Subtract 0x24 to get the second index of g_pwm_buffer
@ -204,7 +204,7 @@ void IS31FL3731_set_value(int index, uint8_t value) {
}
void IS31FL3731_set_value_all(uint8_t value) {
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
for (int i = 0; i < LED_MATRIX_LED_COUNT; i++) {
IS31FL3731_set_value(i, value);
}
}

View File

@ -27,7 +27,7 @@ typedef struct is31_led {
uint8_t v;
} __attribute__((packed)) is31_led;
extern const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL];
extern const is31_led PROGMEM g_is31_leds[LED_MATRIX_LED_COUNT];
void IS31FL3731_init(uint8_t addr);
void IS31FL3731_write_register(uint8_t addr, uint8_t reg, uint8_t data);

View File

@ -182,7 +182,7 @@ void IS31FL3731_init(uint8_t addr) {
void IS31FL3731_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
is31_led led;
if (index >= 0 && index < DRIVER_LED_TOTAL) {
if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
// Subtract 0x24 to get the second index of g_pwm_buffer
@ -194,7 +194,7 @@ 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) {
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) {
IS31FL3731_set_color(i, red, green, blue);
}
}

View File

@ -28,7 +28,7 @@ typedef struct is31_led {
uint8_t b;
} __attribute__((packed)) is31_led;
extern const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL];
extern const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT];
void IS31FL3731_init(uint8_t addr);
void IS31FL3731_write_register(uint8_t addr, uint8_t reg, uint8_t data);

View File

@ -195,7 +195,7 @@ void IS31FL3733_init(uint8_t addr, uint8_t sync) {
}
void IS31FL3733_set_value(int index, uint8_t value) {
if (index >= 0 && index < DRIVER_LED_TOTAL) {
if (index >= 0 && index < LED_MATRIX_LED_COUNT) {
is31_led led = g_is31_leds[index];
g_pwm_buffer[led.driver][led.v] = value;
@ -204,7 +204,7 @@ void IS31FL3733_set_value(int index, uint8_t value) {
}
void IS31FL3733_set_value_all(uint8_t value) {
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
for (int i = 0; i < LED_MATRIX_LED_COUNT; i++) {
IS31FL3733_set_value(i, value);
}
}

View File

@ -29,7 +29,7 @@ typedef struct is31_led {
uint8_t v;
} __attribute__((packed)) is31_led;
extern const is31_led __flash g_is31_leds[DRIVER_LED_TOTAL];
extern const is31_led __flash g_is31_leds[LED_MATRIX_LED_COUNT];
void IS31FL3733_init(uint8_t addr, uint8_t sync);
bool IS31FL3733_write_register(uint8_t addr, uint8_t reg, uint8_t data);

View File

@ -186,7 +186,7 @@ void IS31FL3733_init(uint8_t addr, uint8_t sync) {
void IS31FL3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
is31_led led;
if (index >= 0 && index < DRIVER_LED_TOTAL) {
if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
g_pwm_buffer[led.driver][led.r] = red;
@ -197,7 +197,7 @@ 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) {
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) {
IS31FL3733_set_color(i, red, green, blue);
}
}

View File

@ -30,7 +30,7 @@ typedef struct is31_led {
uint8_t b;
} __attribute__((packed)) is31_led;
extern const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL];
extern const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT];
void IS31FL3733_init(uint8_t addr, uint8_t sync);
bool IS31FL3733_write_register(uint8_t addr, uint8_t reg, uint8_t data);

View File

@ -168,7 +168,7 @@ void IS31FL3736_init(uint8_t addr) {
void IS31FL3736_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
is31_led led;
if (index >= 0 && index < DRIVER_LED_TOTAL) {
if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
g_pwm_buffer[led.driver][led.r] = red;
@ -179,7 +179,7 @@ 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) {
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) {
IS31FL3736_set_color(i, red, green, blue);
}
}

View File

@ -28,8 +28,8 @@
# define DRIVER_COUNT 2
#endif
#ifndef DRIVER_LED_TOTAL
# define DRIVER_LED_TOTAL 96
#ifndef RGB_MATRIX_LED_COUNT
# define RGB_MATRIX_LED_COUNT 96
#endif
typedef struct is31_led {
@ -39,7 +39,7 @@ typedef struct is31_led {
uint8_t b;
} __attribute__((packed)) is31_led;
extern const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL];
extern const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT];
void IS31FL3736_init(uint8_t addr);
void IS31FL3736_write_register(uint8_t addr, uint8_t reg, uint8_t data);

View File

@ -175,7 +175,7 @@ void IS31FL3737_init(uint8_t addr) {
void IS31FL3737_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
is31_led led;
if (index >= 0 && index < DRIVER_LED_TOTAL) {
if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
g_pwm_buffer[led.driver][led.r] = red;
@ -186,7 +186,7 @@ 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) {
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) {
IS31FL3737_set_color(i, red, green, blue);
}
}

View File

@ -30,7 +30,7 @@ typedef struct is31_led {
uint8_t b;
} __attribute__((packed)) is31_led;
extern const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL];
extern const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT];
void IS31FL3737_init(uint8_t addr);
void IS31FL3737_write_register(uint8_t addr, uint8_t reg, uint8_t data);

View File

@ -179,7 +179,7 @@ void IS31FL3741_init(uint8_t addr) {
void IS31FL3741_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
is31_led led;
if (index >= 0 && index < DRIVER_LED_TOTAL) {
if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
g_pwm_buffer[led.driver][led.r] = red;
@ -190,7 +190,7 @@ void IS31FL3741_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
}
void IS31FL3741_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) {
IS31FL3741_set_color(i, red, green, blue);
}
}

View File

@ -30,7 +30,7 @@ typedef struct is31_led {
uint32_t b : 10;
} __attribute__((packed)) is31_led;
extern const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL];
extern const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT];
void IS31FL3741_init(uint8_t addr);
void IS31FL3741_write_register(uint8_t addr, uint8_t reg, uint8_t data);

View File

@ -135,14 +135,17 @@ void IS31FL_common_update_pwm_register(uint8_t addr, uint8_t index) {
void IS31FL_set_manual_scaling_buffer(void) {
for (int i = 0; i < ISSI_MANUAL_SCALING; i++) {
is31_led scale = g_is31_scaling[i];
if (scale.driver >= 0 && scale.driver < DRIVER_LED_TOTAL) {
# ifdef RGB_MATRIX_ENABLE
if (scale.driver >= 0 && scale.driver < RGB_MATRIX_LED_COUNT) {
is31_led led = g_is31_leds[scale.driver];
# ifdef RGB_MATRIX_ENABLE
g_scaling_buffer[led.driver][led.r] = scale.r;
g_scaling_buffer[led.driver][led.g] = scale.g;
g_scaling_buffer[led.driver][led.b] = scale.b;
# elif defined(LED_MATRIX_ENABLE)
if (scale.driver >= 0 && scale.driver < LED_MATRIX_LED_COUNT) {
is31_led led = g_is31_leds[scale.driver];
g_scaling_buffer[led.driver][led.v] = scale.v;
# endif
g_scaling_buffer_update_required[led.driver] = true;
@ -165,7 +168,7 @@ void IS31FL_common_update_scaling_register(uint8_t addr, uint8_t index) {
#ifdef RGB_MATRIX_ENABLE
// Colour is set by adjusting PWM register
void IS31FL_RGB_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
if (index >= 0 && index < DRIVER_LED_TOTAL) {
if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
is31_led led = g_is31_leds[index];
g_pwm_buffer[led.driver][led.r] = red;
@ -176,7 +179,7 @@ void IS31FL_RGB_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
}
void IS31FL_RGB_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) {
IS31FL_RGB_set_color(i, red, green, blue);
}
}
@ -215,7 +218,7 @@ void IS31FL_simple_set_scaling_buffer(uint8_t index, bool value) {
}
void IS31FL_simple_set_brightness(int index, uint8_t value) {
if (index >= 0 && index < DRIVER_LED_TOTAL) {
if (index >= 0 && index < LED_MATRIX_LED_COUNT) {
is31_led led = g_is31_leds[index];
g_pwm_buffer[led.driver][led.v] = value;
g_pwm_buffer_update_required[led.driver] = true;
@ -223,7 +226,7 @@ void IS31FL_simple_set_brightness(int index, uint8_t value) {
}
void IS31FL_simple_set_brigntness_all(uint8_t value) {
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
for (int i = 0; i < LED_MATRIX_LED_COUNT; i++) {
IS31FL_simple_set_brightness(i, value);
}
}

View File

@ -43,11 +43,15 @@ typedef struct is31_led {
uint8_t b;
} __attribute__((packed)) is31_led;
extern const is31_led __flash g_is31_leds[RGB_MATRIX_LED_COUNT];
#elif defined(LED_MATRIX_ENABLE)
typedef struct is31_led {
uint8_t driver;
uint8_t v;
} __attribute__((packed)) is31_led;
extern const is31_led __flash g_is31_leds[LED_MATRIX_LED_COUNT];
#endif
#ifdef ISSI_MANUAL_SCALING
@ -55,8 +59,6 @@ extern const is31_led __flash g_is31_scaling[];
void IS31FL_set_manual_scaling_buffer(void);
#endif
extern const is31_led __flash g_is31_leds[DRIVER_LED_TOTAL];
void IS31FL_write_single_register(uint8_t addr, uint8_t reg, uint8_t data);
bool IS31FL_write_multi_registers(uint8_t addr, uint8_t *source_buffer, uint8_t buffer_size, uint8_t transfer_size, uint8_t start_reg_addr);
void IS31FL_unlock_register(uint8_t addr, uint8_t page);

View File

@ -0,0 +1,277 @@
// Copyright 2022 Nick Brassel (@tzarc)
// SPDX-License-Identifier: GPL-2.0-or-later
#include "color.h"
#include "qp_rgb565_surface.h"
#include "qp_draw.h"
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Common
// Device definition
typedef struct rgb565_surface_painter_device_t {
struct painter_driver_t base; // must be first, so it can be cast to/from the painter_device_t* type
// The target buffer
uint16_t *buffer;
// Manually manage the viewport for streaming pixel data to the display
uint16_t viewport_l;
uint16_t viewport_t;
uint16_t viewport_r;
uint16_t viewport_b;
// Current write location to the display when streaming pixel data
uint16_t pixdata_x;
uint16_t pixdata_y;
// Maintain a dirty region so we can stream only what we need
bool is_dirty;
uint16_t dirty_l;
uint16_t dirty_t;
uint16_t dirty_r;
uint16_t dirty_b;
} rgb565_surface_painter_device_t;
// Driver storage
rgb565_surface_painter_device_t surface_drivers[RGB565_SURFACE_NUM_DEVICES] = {0};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Helpers
static inline void increment_pixdata_location(rgb565_surface_painter_device_t *surface) {
// Increment the X-position
surface->pixdata_x++;
// If the x-coord has gone past the right-side edge, loop it back around and increment the y-coord
if (surface->pixdata_x > surface->viewport_r) {
surface->pixdata_x = surface->viewport_l;
surface->pixdata_y++;
}
// If the y-coord has gone past the bottom, loop it back to the top
if (surface->pixdata_y > surface->viewport_b) {
surface->pixdata_y = surface->viewport_t;
}
}
static inline void setpixel(rgb565_surface_painter_device_t *surface, uint16_t x, uint16_t y, uint16_t rgb565) {
// Skip messing with the dirty info if the original value already matches
if (surface->buffer[y * surface->base.panel_width + x] != rgb565) {
// Maintain dirty region
if (surface->dirty_l > x) {
surface->dirty_l = x;
}
if (surface->dirty_r < x) {
surface->dirty_r = x;
}
if (surface->dirty_t > y) {
surface->dirty_t = y;
}
if (surface->dirty_b < y) {
surface->dirty_b = y;
}
// Always dirty after a setpixel
surface->is_dirty = true;
// Update the pixel data in the buffer
surface->buffer[y * surface->base.panel_width + x] = rgb565;
}
}
static inline void append_pixel(rgb565_surface_painter_device_t *surface, uint16_t rgb565) {
setpixel(surface, surface->pixdata_x, surface->pixdata_y, rgb565);
increment_pixdata_location(surface);
}
static inline void stream_pixdata(rgb565_surface_painter_device_t *surface, const uint16_t *data, uint32_t native_pixel_count) {
for (uint32_t pixel_counter = 0; pixel_counter < native_pixel_count; ++pixel_counter) {
append_pixel(surface, data[pixel_counter]);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Driver vtable
static bool qp_rgb565_surface_init(painter_device_t device, painter_rotation_t rotation) {
struct painter_driver_t * driver = (struct painter_driver_t *)device;
rgb565_surface_painter_device_t *surface = (rgb565_surface_painter_device_t *)driver;
memset(surface->buffer, 0, driver->panel_width * driver->panel_height * driver->native_bits_per_pixel / 8);
return true;
}
static bool qp_rgb565_surface_power(painter_device_t device, bool power_on) {
// No-op.
return true;
}
static bool qp_rgb565_surface_clear(painter_device_t device) {
struct painter_driver_t *driver = (struct painter_driver_t *)device;
driver->driver_vtable->init(device, driver->rotation); // Re-init the surface
return true;
}
static bool qp_rgb565_surface_flush(painter_device_t device) {
struct painter_driver_t * driver = (struct painter_driver_t *)device;
rgb565_surface_painter_device_t *surface = (rgb565_surface_painter_device_t *)driver;
surface->dirty_l = surface->dirty_t = UINT16_MAX;
surface->dirty_r = surface->dirty_b = 0;
surface->is_dirty = false;
return true;
}
static bool qp_rgb565_surface_viewport(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) {
struct painter_driver_t * driver = (struct painter_driver_t *)device;
rgb565_surface_painter_device_t *surface = (rgb565_surface_painter_device_t *)driver;
// Set the viewport locations
surface->viewport_l = left;
surface->viewport_t = top;
surface->viewport_r = right;
surface->viewport_b = bottom;
// Reset the write location to the top left
surface->pixdata_x = left;
surface->pixdata_y = top;
return true;
}
// Stream pixel data to the current write position in GRAM
static bool qp_rgb565_surface_pixdata(painter_device_t device, const void *pixel_data, uint32_t native_pixel_count) {
struct painter_driver_t * driver = (struct painter_driver_t *)device;
rgb565_surface_painter_device_t *surface = (rgb565_surface_painter_device_t *)driver;
stream_pixdata(surface, (const uint16_t *)pixel_data, native_pixel_count);
return true;
}
// Pixel colour conversion
static bool qp_rgb565_surface_palette_convert_rgb565_swapped(painter_device_t device, int16_t palette_size, qp_pixel_t *palette) {
for (int16_t i = 0; i < palette_size; ++i) {
RGB rgb = hsv_to_rgb_nocie((HSV){palette[i].hsv888.h, palette[i].hsv888.s, palette[i].hsv888.v});
uint16_t rgb565 = (((uint16_t)rgb.r) >> 3) << 11 | (((uint16_t)rgb.g) >> 2) << 5 | (((uint16_t)rgb.b) >> 3);
palette[i].rgb565 = __builtin_bswap16(rgb565);
}
return true;
}
// Append pixels to the target location, keyed by the pixel index
static bool qp_rgb565_surface_append_pixels_rgb565(painter_device_t device, uint8_t *target_buffer, qp_pixel_t *palette, uint32_t pixel_offset, uint32_t pixel_count, uint8_t *palette_indices) {
uint16_t *buf = (uint16_t *)target_buffer;
for (uint32_t i = 0; i < pixel_count; ++i) {
buf[pixel_offset + i] = palette[palette_indices[i]].rgb565;
}
return true;
}
const struct painter_driver_vtable_t rgb565_surface_driver_vtable = {
.init = qp_rgb565_surface_init,
.power = qp_rgb565_surface_power,
.clear = qp_rgb565_surface_clear,
.flush = qp_rgb565_surface_flush,
.pixdata = qp_rgb565_surface_pixdata,
.viewport = qp_rgb565_surface_viewport,
.palette_convert = qp_rgb565_surface_palette_convert_rgb565_swapped,
.append_pixels = qp_rgb565_surface_append_pixels_rgb565,
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Comms vtable
static bool qp_rgb565_surface_comms_init(painter_device_t device) {
// No-op.
return true;
}
static bool qp_rgb565_surface_comms_start(painter_device_t device) {
// No-op.
return true;
}
static void qp_rgb565_surface_comms_stop(painter_device_t device) {
// No-op.
}
uint32_t qp_rgb565_surface_comms_send(painter_device_t device, const void *data, uint32_t byte_count) {
// No-op.
return byte_count;
}
struct painter_comms_vtable_t rgb565_surface_driver_comms_vtable = {
// These are all effective no-op's because they're not actually needed.
.comms_init = qp_rgb565_surface_comms_init,
.comms_start = qp_rgb565_surface_comms_start,
.comms_stop = qp_rgb565_surface_comms_stop,
.comms_send = qp_rgb565_surface_comms_send};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory function for creating a handle to an rgb565 surface
painter_device_t qp_rgb565_make_surface(uint16_t panel_width, uint16_t panel_height, void *buffer) {
for (uint32_t i = 0; i < RGB565_SURFACE_NUM_DEVICES; ++i) {
rgb565_surface_painter_device_t *driver = &surface_drivers[i];
if (!driver->base.driver_vtable) {
driver->base.driver_vtable = &rgb565_surface_driver_vtable;
driver->base.comms_vtable = &rgb565_surface_driver_comms_vtable;
driver->base.native_bits_per_pixel = 16; // RGB565
driver->base.panel_width = panel_width;
driver->base.panel_height = panel_height;
driver->base.rotation = QP_ROTATION_0;
driver->base.offset_x = 0;
driver->base.offset_y = 0;
driver->buffer = (uint16_t *)buffer;
return (painter_device_t)driver;
}
}
return NULL;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Drawing routine to copy out the dirty region and send it to another device
bool qp_rgb565_surface_draw(painter_device_t surface, painter_device_t display, uint16_t x, uint16_t y) {
struct painter_driver_t * surface_driver = (struct painter_driver_t *)surface;
rgb565_surface_painter_device_t *surface_handle = (rgb565_surface_painter_device_t *)surface_driver;
// If we're not dirty... we're done.
if (!surface_handle->is_dirty) {
return true;
}
// Set the target drawing area
bool ok = qp_viewport(display, x + surface_handle->dirty_l, y + surface_handle->dirty_t, x + surface_handle->dirty_r, y + surface_handle->dirty_b);
if (!ok) {
return false;
}
// Housekeeping of the amount of pixels to transfer
uint32_t total_pixel_count = QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE / sizeof(uint16_t);
uint32_t pixel_counter = 0;
uint16_t *target_buffer = (uint16_t *)qp_internal_global_pixdata_buffer;
// Fill the global pixdata area so that we can start transferring to the panel
for (uint16_t y = surface_handle->dirty_t; y <= surface_handle->dirty_b; ++y) {
for (uint16_t x = surface_handle->dirty_l; x <= surface_handle->dirty_r; ++x) {
// Update the target buffer
target_buffer[pixel_counter++] = surface_handle->buffer[y * surface_handle->base.panel_width + x];
// If we've accumulated enough data, send it
if (pixel_counter == total_pixel_count) {
ok = qp_pixdata(display, qp_internal_global_pixdata_buffer, pixel_counter);
if (!ok) {
return false;
}
// Reset the counter
pixel_counter = 0;
}
}
}
// If there's any leftover data, send it
if (pixel_counter > 0) {
ok = qp_pixdata(display, qp_internal_global_pixdata_buffer, pixel_counter);
if (!ok) {
return false;
}
}
// Clear the dirty info for the surface
return qp_flush(surface);
}

View File

@ -0,0 +1,42 @@
// Copyright 2022 Nick Brassel (@tzarc)
// SPDX-License-Identifier: GPL-2.0-or-later
#include "qp_internal.h"
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Quantum Painter RGB565 surface configurables (add to your keyboard's config.h)
#ifndef RGB565_SURFACE_NUM_DEVICES
/**
* @def This controls the maximum number of surface devices that Quantum Painter can use at any one time.
* Increasing this number allows for multiple framebuffers to be used. Each requires its own RAM allocation.
*/
# define RGB565_SURFACE_NUM_DEVICES 1
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Forward declarations
#ifdef QUANTUM_PAINTER_RGB565_SURFACE_ENABLE
/**
* Factory method for an RGB565 surface (aka framebuffer).
*
* @param panel_width[in] the width of the display panel
* @param panel_height[in] the height of the display panel
* @param buffer[in] pointer to a preallocated buffer of size `(sizeof(uint16_t) * panel_width * panel_height)`
* @return the device handle used with all drawing routines in Quantum Painter
*/
painter_device_t qp_rgb565_make_surface(uint16_t panel_width, uint16_t panel_height, void *buffer);
/**
* Helper method to draw the dirty contents of the framebuffer to the target device.
*
* After successful completion, the dirty area is reset.
*
* @param surface[in] the surface to copy from
* @param display[in] the display to copy into
* @param x[in] the x-location of the original position of the framebuffer
* @param y[in] the y-location of the original position of the framebuffer
* @return whether the draw operation completed successfully
*/
bool qp_rgb565_surface_draw(painter_device_t surface, painter_device_t display, uint16_t x, uint16_t y);
#endif // QUANTUM_PAINTER_RGB565_SURFACE_ENABLE

View File

@ -7,8 +7,6 @@
#include "qp_draw.h"
#include "qp_tft_panel.h"
#define BYTE_SWAP(x) (((((uint16_t)(x)) >> 8) & 0x00FF) | ((((uint16_t)(x)) << 8) & 0xFF00))
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Quantum Painter API implementations
@ -94,7 +92,7 @@ bool qp_tft_panel_palette_convert_rgb565_swapped(painter_device_t device, int16_
for (int16_t i = 0; i < palette_size; ++i) {
RGB rgb = hsv_to_rgb_nocie((HSV){palette[i].hsv888.h, palette[i].hsv888.s, palette[i].hsv888.v});
uint16_t rgb565 = (((uint16_t)rgb.r) >> 3) << 11 | (((uint16_t)rgb.g) >> 2) << 5 | (((uint16_t)rgb.b) >> 3);
palette[i].rgb565 = BYTE_SWAP(rgb565);
palette[i].rgb565 = __builtin_bswap16(rgb565);
}
return true;
}

View File

@ -29,7 +29,7 @@
#define ENCODERS_PAD_B { GP13 }
#define RGB_DI_PIN GP0
#define DRIVER_LED_TOTAL 47
#define RGB_MATRIX_LED_COUNT 47
#define RGBLED_NUM 47
# define RGB_MATRIX_KEYPRESSES // reacts to keypresses
# define RGB_MATRIX_FRAMEBUFFER_EFFECTS

View File

@ -53,7 +53,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define RGB_DI_PIN D3
#ifdef RGB_DI_PIN
# define RGBLED_NUM 16 // Add 12 if attaching the RGB LED ring
# define DRIVER_LED_TOTAL RGBLED_NUM
# define RGB_MATRIX_LED_COUNT RGBLED_NUM
# ifdef RGBLIGHT_ENABLE
# define RGBLIGHT_HUE_STEP 8
# define RGBLIGHT_SAT_STEP 8

View File

@ -62,7 +62,7 @@
//#define BACKLIGHT_BREATHING
#define RGB_DI_PIN B5
#define DRIVER_LED_TOTAL 20
#define RGB_MATRIX_LED_COUNT 20
#ifdef RGB_DI_PIN
# define RGB_MATRIX_KEYPRESSES // reacts to keypresses
# define RGBLIGHT_LIMIT_VAL 255

View File

@ -34,7 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* RGB matrix key backlighting */
#define RGB_DI_PIN B2
#define DRIVER_LED_TOTAL 2
#define RGB_MATRIX_LED_COUNT 2
#define RGB_MATRIX_KEYPRESSES
#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_SOLID_REACTIVE
#define RGB_MATRIX_STARTUP_HUE 90

View File

@ -33,7 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DRIVER_ADDR_1 0b1010000
#define DRIVER_COUNT 1
#define DRIVER_LED_TOTAL 62
#define RGB_MATRIX_LED_COUNT 62
#define ISSI_PWM_FREQUENCY 0b010
#define RGB_MATRIX_STARTUP_VAL 80

View File

@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "rev_a.h"
#ifdef RGB_MATRIX_ENABLE
const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {
const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT] = {
{ 0, K_2, J_2, L_2 }, //D402
{ 0, K_3, J_3, L_3 }, //D403
{ 0, K_4, J_4, L_4 }, //D404

View File

@ -21,6 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* RGB Matrix setup */
#define RGB_DI_PIN GP19
#define DRIVER_LED_TOTAL 2
#define RGB_MATRIX_LED_COUNT 2
#define RGBLED_NUM 2
#define WS2812_PIO_USE_PIO1 // Force the usage of PIO1 peripheral, by default the WS2812 implementation uses the PIO0 peripheral

View File

@ -38,14 +38,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE
#define EEPROM_I2C_24LC256
//#define I2C1_CLOCK_SPEED 400000
//#define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2
#define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
#define RGB_DI_PIN B15
#define DRIVER_LED_TOTAL 87
#define RGB_MATRIX_LED_COUNT 87
#define WS2812_PWM_COMPLEMENTARY_OUTPUT
#define WS2812_PWM_DRIVER PWMD1

View File

@ -1,4 +1,4 @@
/* Copyright 2022 QMK
/* Copyright 2022 Gondolindrim <gondolindrim@acheronproject.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
@ -16,8 +16,6 @@
#pragma once
#define HAL_USE_I2C TRUE
#define HAL_USE_PWM TRUE
#define HAL_USE_PAL TRUE

View File

@ -18,9 +18,6 @@
#include_next <mcuconf.h>
#undef STM32_I2C_USE_I2C1
#define STM32_I2C_USE_I2C1 TRUE
#undef STM32_PWM_USE_ADVANCED
#define STM32_PWM_USE_ADVANCED TRUE

View File

@ -19,7 +19,8 @@ RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
AUDIO_ENABLE = no # Audio output
RGB_MATRIX_ENABLE = yes
RGB_MATRIX_DRIVER = WS2812
EEPROM_DRIVER = i2c
EEPROM_DRIVER = wear_leveling
WEAR_LEVELING_DRIVER = legacy
# Enter lower-power sleep mode when on the ChibiOS idle thread
OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE -DDEBUG_EEPROM_OUTPUT=TRUE

View File

@ -38,10 +38,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE
#define EEPROM_I2C_24LC256
//#define I2C1_CLOCK_SPEED 400000
//#define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2
#define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
// RGB Matrix defines
@ -49,8 +45,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DRIVER_COUNT 1
#define DRIVER_1_LED_TOTAL 87
#define DRIVER_LED_TOTAL DRIVER_1_LED_TOTAL
#define ISSI_DRIVER_TOTAL DRIVER_LED_TOTAL
#define RGB_MATRIX_LED_COUNT DRIVER_1_LED_TOTAL
#define ISSI_DRIVER_TOTAL RGB_MATRIX_LED_COUNT
#define RGB_MATRIX_STARTUP_VAL 80
#define RGB_MATRIX_FRAMEBUFFER_EFFECTS

View File

@ -17,13 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "gamma.h"
void board_init(void) {
setPinInput(B9);
setPinInput(B10);
}
#ifdef RGB_MATRIX_ENABLE
const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {
const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT] = {
/* Refer to IS31 manual for these locations
* driver
* | R location
@ -126,7 +121,6 @@ const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {
};
led_config_t g_led_config = { {
{ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 },
{ 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 },

View File

@ -18,7 +18,4 @@
#define HAL_USE_I2C TRUE
// #define HAL_USE_PWM TRUE
// #define HAL_USE_PAL TRUE
#include_next <halconf.h>

View File

@ -20,9 +20,3 @@
#undef STM32_I2C_USE_I2C1
#define STM32_I2C_USE_I2C1 TRUE
// #undef STM32_PWM_USE_ADVANCED
// #define STM32_PWM_USE_ADVANCED TRUE
// #undef STM32_PWM_USE_TIM1
// #define STM32_PWM_USE_TIM1 TRUE

View File

@ -20,7 +20,8 @@ AUDIO_ENABLE = no # Audio output
RGB_MATRIX_ENABLE = yes
RGB_MATRIX_DRIVER = IS31FL3741
KEYBOARD_SHARED_EP = yes
EEPROM_DRIVER = i2c
EEPROM_DRIVER = wear_leveling
WEAR_LEVELING_DRIVER = legacy
# Enter lower-power sleep mode when on the ChibiOS idle thread
OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE -DDEBUG_EEPROM_OUTPUT=TRUE

View File

@ -41,7 +41,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
#define RGB_DI_PIN B15
#define DRIVER_LED_TOTAL 86
#define RGB_MATRIX_LED_COUNT 86
#define WS2812_PWM_COMPLEMENTARY_OUTPUT
#define WS2812_PWM_DRIVER PWMD1

View File

@ -16,8 +16,6 @@
#pragma once
#define HAL_USE_I2C TRUE
#define HAL_USE_PWM TRUE
#define HAL_USE_PAL TRUE

View File

@ -18,9 +18,6 @@
#include_next <mcuconf.h>
#undef STM32_I2C_USE_I2C1
#define STM32_I2C_USE_I2C1 TRUE
#undef STM32_PWM_USE_ADVANCED
#define STM32_PWM_USE_ADVANCED TRUE

View File

@ -19,5 +19,8 @@ RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
AUDIO_ENABLE = no # Audio output
RGB_MATRIX_ENABLE = yes
RGB_MATRIX_DRIVER = WS2812
EEPROM_DRIVER = wear_leveling
WEAR_LEVELING_DRIVER = legacy
# Enter lower-power sleep mode when on the ChibiOS idle thread
OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE -DDEBUG_EEPROM_OUTPUT=TRUE

View File

@ -17,11 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "88htsc.h"
void board_init(void) {
setPinInput(B9);
setPinInput(B10);
}
led_config_t g_led_config = { {
{ 16 , 15 , 14 , 13 , 12 , 11 , 10 , 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 },
{ 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , 33 },

View File

@ -41,7 +41,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
#define RGB_DI_PIN B15
#define DRIVER_LED_TOTAL 87
#define RGB_MATRIX_LED_COUNT 87
#define WS2812_PWM_COMPLEMENTARY_OUTPUT
#define WS2812_PWM_DRIVER PWMD1

View File

@ -16,8 +16,6 @@
#pragma once
#define HAL_USE_I2C TRUE
#define HAL_USE_PWM TRUE
#define HAL_USE_PAL TRUE

View File

@ -18,9 +18,6 @@
#include_next <mcuconf.h>
#undef STM32_I2C_USE_I2C1
#define STM32_I2C_USE_I2C1 TRUE
#undef STM32_PWM_USE_ADVANCED
#define STM32_PWM_USE_ADVANCED TRUE

View File

@ -19,7 +19,9 @@ RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
AUDIO_ENABLE = no # Audio output
RGB_MATRIX_ENABLE = yes
RGB_MATRIX_DRIVER = WS2812
EEPROM_DRIVER = i2c
EEPROM_DRIVER = wear_leveling
WEAR_LEVELING_DRIVER = legacy
# Enter lower-power sleep mode when on the ChibiOS idle thread
OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE -DDEBUG_EEPROM_OUTPUT=TRUE

View File

@ -78,7 +78,7 @@
/* RGB Defines */
# define RGB_DI_PIN GP19
# define DRIVER_LED_TOTAL 12
# define RGB_MATRIX_LED_COUNT 12
# define RGBLED_NUM 12
/* Enable Framebuffer and keypress effects */

View File

@ -21,9 +21,8 @@
#define RGB_DI_PIN B7
#define DRIVER_LED_TOTAL 42
#define RGB_MATRIX_LED_COUNT 42
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 170
#define RGB_MATRIX_CENTER { 112, 32 }
#define RGB_DISABLE_WHEN_USB_SUSPENDED
#define RGB_MATRIX_LED_PROCESS_LIMIT 21
#define RGB_MATRIX_LED_FLUSH_LIMIT 16

View File

@ -53,7 +53,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#endif
#ifdef RGB_MATRIX_ENABLE
#define DRIVER_LED_TOTAL 68
#define RGB_MATRIX_LED_COUNT 68
#define RGB_MATRIX_SPLIT { 34, 34 }
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash.
#define RGB_MATRIX_KEYPRESSES

View File

@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET
#define DRIVER_LED_TOTAL 70
#define RGB_MATRIX_LED_COUNT 70
/* disable debug print */
//#define NO_DEBUG

View File

@ -18,7 +18,7 @@
#ifdef RGB_MATRIX_ENABLE
#define DRIVER_LED_TOTAL 61
#define RGB_MATRIX_LED_COUNT 61
/* Limit animations to 62.5 FPS to avoid tearing. (1/.016 = 62.5 FPS). */
#define RGB_MATRIX_LED_FLUSH_LIMIT 16

View File

@ -19,7 +19,7 @@
#include "rgb_matrix.h"
#include "ap2_led.h"
uint8_t led_pos[DRIVER_LED_TOTAL];
uint8_t led_pos[RGB_MATRIX_LED_COUNT];
void init(void) {
unsigned int i = 0;
@ -52,7 +52,7 @@ void set_color(int index, uint8_t r, uint8_t g, uint8_t b) {
}
void set_color_all(uint8_t r, uint8_t g, uint8_t b) {
for (int i=0; i<DRIVER_LED_TOTAL; i++)
for (int i=0; i<RGB_MATRIX_LED_COUNT; i++)
set_color(i, r, g, b);
}

View File

@ -57,7 +57,7 @@
#define RGB_MATRIX_KEYPRESSES
#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
#define RGB_DISABLE_WHEN_USB_SUSPENDED true
#define DRIVER_LED_TOTAL 96
#define RGB_MATRIX_LED_COUNT 96
#define RGB_MATRIX_STARTUP_HUE 170
#define RGB_MATRIX_STARTUP_SAT 255
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 130

View File

@ -78,7 +78,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
# define DRIVER_ADDR_1 0b1010000
# define DRIVER_COUNT 1
# define DRIVER_LED_TOTAL 64
# define RGB_MATRIX_LED_COUNT 64
#endif
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */

View File

@ -17,7 +17,7 @@
#include "hotswap.h"
#ifdef RGB_MATRIX_ENABLE
const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
const is31_led g_is31_leds[RGB_MATRIX_LED_COUNT] = {
{ 0, B_1, A_1, C_1 },
{ 0, B_2, A_2, C_2 },
{ 0, B_3, A_3, C_3 },

View File

@ -91,7 +91,7 @@
#ifdef RGB_MATRIX_ENABLE
/* ws2812 RGB MATRIX */
# define DRIVER_LED_TOTAL 76
# define RGB_MATRIX_LED_COUNT 76
// reacts to keypresses
# define RGB_MATRIX_KEYPRESSES

View File

@ -36,7 +36,7 @@
#define RGB_DI_PIN E6
#define DRIVER_LED_TOTAL 80
#define RGB_MATRIX_LED_COUNT 80
/* RGB LED */
#ifdef RGBLIGHT_ENABLE
@ -75,7 +75,7 @@
// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
//# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
# define RGB_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5 // limits the number of LEDs to process in an animation per task run (increases keyboard responsiveness)
# 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 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash.
# define RGB_MATRIX_HUE_STEP 8

View File

@ -38,7 +38,7 @@
/* RGB matrix support. */
#ifdef RGB_MATRIX_ENABLE
# define SPLIT_TRANSPORT_MIRROR
# define DRIVER_LED_TOTAL RGBLED_NUM
# define RGB_MATRIX_LED_COUNT RGBLED_NUM
# define RGB_MATRIX_SPLIT RGBLED_SPLIT
# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 50
# define RGB_MATRIX_STARTUP_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS

View File

@ -40,7 +40,7 @@
/* RGB matrix support. */
#ifdef RGB_MATRIX_ENABLE
# define SPLIT_TRANSPORT_MIRROR
# define DRIVER_LED_TOTAL RGBLED_NUM
# define RGB_MATRIX_LED_COUNT RGBLED_NUM
# define RGB_MATRIX_SPLIT RGBLED_SPLIT
# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 50
# define RGB_MATRIX_STARTUP_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS

View File

@ -38,7 +38,7 @@
/* RGB matrix support. */
#ifdef RGB_MATRIX_ENABLE
# define SPLIT_TRANSPORT_MIRROR
# define DRIVER_LED_TOTAL RGBLED_NUM
# define RGB_MATRIX_LED_COUNT RGBLED_NUM
# define RGB_MATRIX_SPLIT RGBLED_SPLIT
# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 50
# define RGB_MATRIX_STARTUP_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS

View File

@ -37,7 +37,7 @@
/* RGB matrix support. */
#ifdef RGB_MATRIX_ENABLE
# define SPLIT_TRANSPORT_MIRROR
# define DRIVER_LED_TOTAL RGBLED_NUM
# define RGB_MATRIX_LED_COUNT RGBLED_NUM
# define RGB_MATRIX_SPLIT RGBLED_SPLIT
# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 50
# define RGB_MATRIX_STARTUP_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS

View File

@ -37,7 +37,7 @@
/* RGB matrix support. */
#ifdef RGB_MATRIX_ENABLE
# define SPLIT_TRANSPORT_MIRROR
# define DRIVER_LED_TOTAL RGBLED_NUM
# define RGB_MATRIX_LED_COUNT RGBLED_NUM
# define RGB_MATRIX_SPLIT RGBLED_SPLIT
# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 50
# define RGB_MATRIX_STARTUP_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS

View File

@ -37,7 +37,7 @@
/* RGB matrix support. */
#ifdef RGB_MATRIX_ENABLE
# define SPLIT_TRANSPORT_MIRROR
# define DRIVER_LED_TOTAL RGBLED_NUM
# define RGB_MATRIX_LED_COUNT RGBLED_NUM
# define RGB_MATRIX_SPLIT RGBLED_SPLIT
# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 50
# define RGB_MATRIX_STARTUP_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS

View File

@ -7,7 +7,7 @@
// RGB configuration
#define RGB_DI_PIN B7
// The number of LEDs connected
#define DRIVER_LED_TOTAL 81
#define RGB_MATRIX_LED_COUNT 81
//#ifdef RGB_DI_PIN
# define RGBLED_NUM 81
@ -17,7 +17,7 @@
// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
//# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
// # define RGB_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5 // limits the number of LEDs to process in an animation per task run (increases keyboard responsiveness)
// # 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 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash.
# define RGB_MATRIX_HUE_STEP 8

View File

@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#define RGB_DI_PIN C6
#define DRIVER_LED_TOTAL 18
#define RGB_MATRIX_LED_COUNT 18
#define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN
#define ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT
#define ENABLE_RGB_MATRIX_BREATHING

View File

@ -3,7 +3,7 @@
#pragma once
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150
#define DRIVER_LED_TOTAL 70
#define RGB_MATRIX_LED_COUNT 70
#define RGB_MATRIX_SPLIT { 35, 35 }
#define ENABLE_RGB_MATRIX_ALPHAS_MODS
#define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN

View File

@ -36,70 +36,70 @@
{ "flags": 2, "x": 17, "y": 10 },
{ "flags": 2, "x": 51, "y": 10 },
{ "flags": 2, "x": 86, "y": 10 },
{ "flags": 2, "x": 137, "y": 55 },
{ "flags": 2, "x": 172, "y": 55 },
{ "flags": 2, "x": 206, "y": 40 },
{ "flags": 2, "x": 206, "y": 10 },
{ "flags": 2, "x": 172, "y": 10 },
{ "flags": 2, "x": 137, "y": 10 },
{ "flags": 1, "matrix": [0, 0], "x": 0, "y": 0 },
{ "flags": 4, "matrix": [0, 1], "x": 17, "y": 0 },
{ "flags": 4, "matrix": [0, 2], "x": 34, "y": 0 },
{ "flags": 4, "matrix": [0, 3], "x": 51, "y": 0 },
{ "flags": 4, "matrix": [0, 4], "x": 68, "y": 0 },
{ "flags": 4, "matrix": [0, 5], "x": 86, "y": 0 },
{ "flags": 4, "matrix": [5, 5], "x": 137, "y": 0 },
{ "flags": 4, "matrix": [5, 4], "x": 155, "y": 0 },
{ "flags": 4, "matrix": [5, 3], "x": 172, "y": 0 },
{ "flags": 4, "matrix": [5, 2], "x": 189, "y": 0 },
{ "flags": 4, "matrix": [5, 1], "x": 206, "y": 0 },
{ "flags": 1, "matrix": [5, 0], "x": 224, "y": 0 },
{ "flags": 4, "matrix": [0, 4], "x": 68, "y": 0 },
{ "flags": 4, "matrix": [0, 3], "x": 51, "y": 0 },
{ "flags": 4, "matrix": [0, 2], "x": 34, "y": 0 },
{ "flags": 4, "matrix": [0, 1], "x": 17, "y": 0 },
{ "flags": 1, "matrix": [0, 0], "x": 0, "y": 0 },
{ "flags": 1, "matrix": [1, 0], "x": 0, "y": 16 },
{ "flags": 4, "matrix": [1, 1], "x": 17, "y": 16 },
{ "flags": 4, "matrix": [1, 2], "x": 34, "y": 16 },
{ "flags": 4, "matrix": [1, 3], "x": 51, "y": 16 },
{ "flags": 4, "matrix": [1, 4], "x": 68, "y": 16 },
{ "flags": 4, "matrix": [1, 5], "x": 86, "y": 16 },
{ "flags": 4, "matrix": [6, 5], "x": 137, "y": 16 },
{ "flags": 4, "matrix": [6, 4], "x": 155, "y": 16 },
{ "flags": 4, "matrix": [6, 3], "x": 172, "y": 16 },
{ "flags": 4, "matrix": [6, 2], "x": 189, "y": 16 },
{ "flags": 4, "matrix": [6, 1], "x": 206, "y": 16 },
{ "flags": 1, "matrix": [6, 4], "x": 224, "y": 16 },
{ "flags": 1, "matrix": [2, 0], "x": 0, "y": 32 },
{ "flags": 4, "matrix": [2, 1], "x": 17, "y": 32 },
{ "flags": 4, "matrix": [2, 2], "x": 34, "y": 32 },
{ "flags": 4, "matrix": [2, 3], "x": 51, "y": 32 },
{ "flags": 4, "matrix": [2, 4], "x": 68, "y": 32 },
{ "flags": 4, "matrix": [2, 5], "x": 86, "y": 32 },
{ "flags": 4, "matrix": [7, 5], "x": 137, "y": 32 },
{ "flags": 4, "matrix": [7, 4], "x": 155, "y": 32 },
{ "flags": 4, "matrix": [7, 3], "x": 172, "y": 32 },
{ "flags": 4, "matrix": [7, 2], "x": 189, "y": 32 },
{ "flags": 4, "matrix": [7, 1], "x": 206, "y": 32 },
{ "flags": 1, "matrix": [7, 4], "x": 224, "y": 32 },
{ "flags": 4, "matrix": [2, 4], "x": 68, "y": 32 },
{ "flags": 4, "matrix": [2, 3], "x": 51, "y": 32 },
{ "flags": 4, "matrix": [2, 2], "x": 34, "y": 32 },
{ "flags": 4, "matrix": [2, 1], "x": 17, "y": 32 },
{ "flags": 1, "matrix": [2, 0], "x": 0, "y": 32 },
{ "flags": 1, "matrix": [3, 0], "x": 0, "y": 48 },
{ "flags": 4, "matrix": [3, 1], "x": 17, "y": 48 },
{ "flags": 4, "matrix": [3, 2], "x": 34, "y": 48 },
{ "flags": 4, "matrix": [3, 3], "x": 51, "y": 48 },
{ "flags": 4, "matrix": [3, 4], "x": 68, "y": 48 },
{ "flags": 4, "matrix": [3, 5], "x": 86, "y": 48 },
{ "flags": 4, "matrix": [4, 5], "x": 103, "y": 48 },
{ "flags": 4, "matrix": [9, 5], "x": 120, "y": 48 },
{ "flags": 4, "matrix": [8, 5], "x": 137, "y": 48 },
{ "flags": 4, "matrix": [8, 4], "x": 155, "y": 48 },
{ "flags": 4, "matrix": [8, 3], "x": 172, "y": 48 },
{ "flags": 4, "matrix": [8, 2], "x": 189, "y": 48 },
{ "flags": 4, "matrix": [4, 5], "x": 103, "y": 40 },
{ "flags": 1, "matrix": [4, 4], "x": 96, "y": 64 },
{ "flags": 1, "matrix": [4, 3], "x": 77, "y": 64 },
{ "flags": 1, "matrix": [4, 2], "x": 60, "y": 64 },
{ "flags": 1, "matrix": [4, 1], "x": 43, "y": 64 },
{ "flags": 2, "x": 137, "y": 55 },
{ "flags": 2, "x": 172, "y": 55 },
{ "flags": 2, "x": 206, "y": 40 },
{ "flags": 2, "x": 206, "y": 10 },
{ "flags": 2, "x": 172, "y": 10 },
{ "flags": 2, "x": 137, "y": 10 },
{ "flags": 4, "matrix": [5, 5], "x": 137, "y": 0 },
{ "flags": 4, "matrix": [5, 4], "x": 155, "y": 0 },
{ "flags": 4, "matrix": [5, 3], "x": 172, "y": 0 },
{ "flags": 4, "matrix": [5, 2], "x": 189, "y": 0 },
{ "flags": 4, "matrix": [5, 1], "x": 206, "y": 0 },
{ "flags": 1, "matrix": [5, 0], "x": 224, "y": 0 },
{ "flags": 1, "matrix": [6, 0], "x": 224, "y": 16 },
{ "flags": 4, "matrix": [6, 1], "x": 206, "y": 16 },
{ "flags": 4, "matrix": [6, 2], "x": 189, "y": 16 },
{ "flags": 4, "matrix": [6, 3], "x": 172, "y": 16 },
{ "flags": 4, "matrix": [6, 4], "x": 155, "y": 16 },
{ "flags": 4, "matrix": [6, 5], "x": 137, "y": 16 },
{ "flags": 4, "matrix": [7, 5], "x": 137, "y": 32 },
{ "flags": 4, "matrix": [7, 4], "x": 155, "y": 32 },
{ "flags": 4, "matrix": [7, 3], "x": 172, "y": 32 },
{ "flags": 4, "matrix": [7, 2], "x": 189, "y": 32 },
{ "flags": 4, "matrix": [7, 1], "x": 206, "y": 32 },
{ "flags": 1, "matrix": [7, 0], "x": 224, "y": 32 },
{ "flags": 1, "matrix": [8, 0], "x": 224, "y": 48 },
{ "flags": 4, "matrix": [8, 1], "x": 206, "y": 48 },
{ "flags": 1, "matrix": [8, 4], "x": 224, "y": 48 },
{ "flags": 1, "matrix": [4, 1], "x": 34, "y": 64 },
{ "flags": 1, "matrix": [4, 2], "x": 51, "y": 64 },
{ "flags": 1, "matrix": [4, 3], "x": 68, "y": 64 },
{ "flags": 1, "matrix": [4, 4], "x": 86, "y": 64 },
{ "flags": 1, "matrix": [9, 4], "x": 137, "y": 64 },
{ "flags": 1, "matrix": [9, 3], "x": 155, "y": 64 },
{ "flags": 1, "matrix": [9, 2], "x": 172, "y": 64 },
{ "flags": 1, "matrix": [9, 1], "x": 189, "y": 64 }
{ "flags": 4, "matrix": [8, 2], "x": 189, "y": 48 },
{ "flags": 4, "matrix": [8, 3], "x": 172, "y": 48 },
{ "flags": 4, "matrix": [8, 4], "x": 155, "y": 48 },
{ "flags": 4, "matrix": [8, 5], "x": 137, "y": 48 },
{ "flags": 4, "matrix": [9, 5], "x": 120, "y": 40 },
{ "flags": 1, "matrix": [9, 4], "x": 127, "y": 64 },
{ "flags": 1, "matrix": [9, 3], "x": 146, "y": 64 },
{ "flags": 1, "matrix": [9, 2], "x": 163, "y": 64 },
{ "flags": 1, "matrix": [9, 1], "x": 180, "y": 64 }
]
},
"layouts": {

View File

@ -4,7 +4,7 @@
#define RGB_DI_PIN B5
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150
#define DRIVER_LED_TOTAL 44
#define RGB_MATRIX_LED_COUNT 44
#define RGB_MATRIX_SPLIT { 22, 22 }
#define RGB_DISABLE_WHEN_USB_SUSPENDED
#define ENABLE_RGB_MATRIX_ALPHAS_MODS

View File

@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#define RGB_DI_PIN C6
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 120
#define DRIVER_LED_TOTAL 58
#define RGB_MATRIX_LED_COUNT 58
#define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN
#define ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT
#define ENABLE_RGB_MATRIX_BREATHING

View File

@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#define RGB_DI_PIN C6
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 120
#define DRIVER_LED_TOTAL 55
#define RGB_MATRIX_LED_COUNT 55
#define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN
#define ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT
#define ENABLE_RGB_MATRIX_BREATHING

View File

@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#ifdef RGB_MATRIX_ENABLE
# define DRIVER_LED_TOTAL 24
# define RGB_MATRIX_LED_COUNT 24
# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200
# define RGB_DISABLE_WHEN_USB_SUSPENDED
# define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN

View File

@ -155,7 +155,7 @@
#define RGBLED_NUM 10
#define RGB_DI_PIN B5
#define DRIVER_LED_TOTAL RGBLED_NUM
#define RGB_MATRIX_LED_COUNT RGBLED_NUM
#define RGB_MATRIX_KEYPRESSES

View File

@ -16,7 +16,7 @@
#include "canary60rgb.h"
#ifdef RGB_MATRIX_ENABLE
const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {
const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT] = {
{ 0, J_14, K_14, L_14 },
{ 0, J_13, K_13, L_13 },
{ 0, J_12, K_12, L_12 },

View File

@ -78,5 +78,5 @@
# define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
# define DRIVER_ADDR_1 0b1010000
# define DRIVER_COUNT 1
# define DRIVER_LED_TOTAL 63
# define RGB_MATRIX_LED_COUNT 63
#endif

View File

@ -0,0 +1,98 @@
{
"manufacturer": "CannonKeys",
"keyboard_name": "Moment HS",
"maintainer": "awkannan",
"bootloader": "stm32-dfu",
"diode_direction": "COL2ROW",
"features": {
"bootmagic": true,
"command": false,
"console": false,
"extrakey": true,
"mousekey": true,
"nkro": true
},
"matrix_pins": {
"cols": ["B11", "B10", "B2", "A9", "A15", "B3", "B4", "B5", "B6", "B7", "B8", "B9", "C13", "C14", "C15"],
"rows": ["B1", "B0", "A7", "A5", "A4"]
},
"indicators": {
"caps_lock": "A3",
"on_state": 0
},
"processor": "STM32F072",
"url": "https://cannonkeys.com/",
"usb": {
"device_version": "1.0.0",
"vid": "0xCA04",
"pid": "0x0013"
},
"layouts": {
"LAYOUT_all": {
"layout": [
{ "label": "Esc", "matrix": [0, 0], "x": 0.0, "y": 0.0 },
{ "label": "!", "matrix": [0, 1], "x": 1.0, "y": 0.0 },
{ "label": "@", "matrix": [0, 2], "x": 2.0, "y": 0.0 },
{ "label": "#", "matrix": [0, 3], "x": 3.0, "y": 0.0 },
{ "label": "$", "matrix": [0, 4], "x": 4.0, "y": 0.0 },
{ "label": "%", "matrix": [0, 5], "x": 5.0, "y": 0.0 },
{ "label": "^", "matrix": [0, 6], "x": 6.0, "y": 0.0 },
{ "label": "&", "matrix": [0, 7], "x": 7.0, "y": 0.0 },
{ "label": "*", "matrix": [0, 8], "x": 8.0, "y": 0.0 },
{ "label": "(", "matrix": [0, 9], "x": 9.0, "y": 0.0 },
{ "label": ")", "matrix": [0, 10], "x": 10.0, "y": 0.0 },
{ "label": "_", "matrix": [0, 11], "x": 11.0, "y": 0.0 },
{ "label": "+", "matrix": [0, 12], "x": 12.0, "y": 0.0 },
{ "label": "Bksp", "matrix": [0, 14], "x": 13.0, "y": 0.0 },
{ "label": "Del", "matrix": [0, 13], "x": 14.0, "y": 0.0 },
{ "label": "Tab", "matrix": [1, 0], "w": 1.5, "x": 0.0, "y": 1.0 },
{ "label": "Q", "matrix": [1, 1], "x": 1.5, "y": 1.0 },
{ "label": "W", "matrix": [1, 2], "x": 2.5, "y": 1.0 },
{ "label": "E", "matrix": [1, 3], "x": 3.5, "y": 1.0 },
{ "label": "R", "matrix": [1, 4], "x": 4.5, "y": 1.0 },
{ "label": "T", "matrix": [1, 5], "x": 5.5, "y": 1.0 },
{ "label": "Y", "matrix": [1, 6], "x": 6.5, "y": 1.0 },
{ "label": "U", "matrix": [1, 7], "x": 7.5, "y": 1.0 },
{ "label": "I", "matrix": [1, 8], "x": 8.5, "y": 1.0 },
{ "label": "O", "matrix": [1, 9], "x": 9.5, "y": 1.0 },
{ "label": "P", "matrix": [1, 10], "x": 10.5, "y": 1.0 },
{ "label": "{", "matrix": [1, 11], "x": 11.5, "y": 1.0 },
{ "label": "}", "matrix": [1, 12], "x": 12.5, "y": 1.0 },
{ "label": "|", "matrix": [1, 14], "w": 1.5, "x": 13.5, "y": 1.0 },
{ "label": "Caps Lock", "matrix": [2, 0], "w": 1.75, "x": 0.0, "y": 2.0 },
{ "label": "A", "matrix": [2, 1], "x": 1.75, "y": 2.0 },
{ "label": "S", "matrix": [2, 2], "x": 2.75, "y": 2.0 },
{ "label": "D", "matrix": [2, 3], "x": 3.75, "y": 2.0 },
{ "label": "F", "matrix": [2, 4], "x": 4.75, "y": 2.0 },
{ "label": "G", "matrix": [2, 5], "x": 5.75, "y": 2.0 },
{ "label": "H", "matrix": [2, 6], "x": 6.75, "y": 2.0 },
{ "label": "J", "matrix": [2, 7], "x": 7.75, "y": 2.0 },
{ "label": "K", "matrix": [2, 8], "x": 8.75, "y": 2.0 },
{ "label": "L", "matrix": [2, 9], "x": 9.75, "y": 2.0 },
{ "label": ":", "matrix": [2, 10], "x": 10.75, "y": 2.0 },
{ "label": "\"", "matrix": [2, 11], "x": 11.75, "y": 2.0 },
{ "label": "Enter", "matrix": [2, 14], "w": 2.25, "x": 12.75, "y": 2.0 },
{ "label": "Shift", "matrix": [3, 0], "w": 2.25, "x": 0.0, "y": 3.0 },
{ "label": "Z", "matrix": [3, 2], "x": 2.25, "y": 3.0 },
{ "label": "X", "matrix": [3, 3], "x": 3.25, "y": 3.0 },
{ "label": "C", "matrix": [3, 4], "x": 4.25, "y": 3.0 },
{ "label": "V", "matrix": [3, 5], "x": 5.25, "y": 3.0 },
{ "label": "B", "matrix": [3, 6], "x": 6.25, "y": 3.0 },
{ "label": "N", "matrix": [3, 7], "x": 7.25, "y": 3.0 },
{ "label": "M", "matrix": [3, 8], "x": 8.25, "y": 3.0 },
{ "label": "<", "matrix": [3, 9], "x": 9.25, "y": 3.0 },
{ "label": ">", "matrix": [3, 10], "x": 10.25, "y": 3.0 },
{ "label": "?", "matrix": [3, 11], "x": 11.25, "y": 3.0 },
{ "label": "Shift", "matrix": [3, 12], "w": 1.75, "x": 12.25, "y": 3.0 },
{ "label": "Fn", "matrix": [3, 14], "x": 14.0, "y": 3.0 },
{ "label": "Ctrl", "matrix": [4, 0], "w": 1.5, "x": 0.0, "y": 4.0 },
{ "label": "Win", "matrix": [4, 1], "x": 1.5, "y": 4.0 },
{ "label": "Alt", "matrix": [4, 2], "w": 1.5, "x": 2.5, "y": 4.0 },
{ "matrix": [4, 6], "w": 7.0, "x": 4.0, "y": 4.0 },
{ "label": "Alt", "matrix": [4, 11], "w": 1.5, "x": 11.0, "y": 4.0 },
{ "label": "Win", "matrix": [4, 12], "x": 12.5, "y": 4.0 },
{ "label": "Menu", "matrix": [4, 14], "w": 1.5, "x": 13.5, "y": 4.0 }
]
}
}
}

View File

@ -0,0 +1,45 @@
// Copyright 2022 Andrew Kannan (@awkannan)
// SPDX-License-Identifier: GPL-2.0-or-later
#include QMK_KEYBOARD_H
enum layer_names {
_BASE,
_FN1,
_FN2,
_FN3
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_BASE] = LAYOUT_all(
KC_GESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_DEL,
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS,
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, MO(_FN1),
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, KC_RCTL
),
[_FN1] = LAYOUT_all(
KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_DEL,
RGB_TOG, RGB_MOD, KC_UP, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
BL_BRTG, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, _______, _______, _______,
BL_INC, BL_TOGG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, RESET
),
[_FN2] = LAYOUT_all(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______
),
[_FN3] = LAYOUT_all(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______
)
};

View File

@ -0,0 +1,45 @@
// Copyright 2022 Andrew Kannan (@awkannan)
// SPDX-License-Identifier: GPL-2.0-or-later
#include QMK_KEYBOARD_H
enum layer_names {
_BASE,
_FN1,
_FN2,
_FN3
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_BASE] = LAYOUT_all(
KC_GESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_DEL,
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS,
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, MO(_FN1),
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, KC_RCTL
),
[_FN1] = LAYOUT_all(
KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_DEL,
_______, _______, KC_UP, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, RESET
),
[_FN2] = LAYOUT_all(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______
),
[_FN3] = LAYOUT_all(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______
)
};

View File

@ -0,0 +1 @@
VIA_ENABLE = yes

View File

@ -0,0 +1,25 @@
# Moment Hotswap
*A 60% keyboard from jjw_kb*
* Keyboard Maintainer: [Andrew Kannan](https://github.com/awkannan)
* Hardware Supported: STM32F072CBT6
* Hardware Availability: [CannonKeys](https://cannonkeys.com)
Make example for this keyboard (after setting up your build environment):
make cannonkeys/moment_hs:default
Flashing example for this keyboard:
make cannonkeys/moment_hs:default:flash
See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
## Bootloader
Enter the bootloader in 3 ways:
* **Bootmagic reset**: Hold down the key at (0,0) in the matrix (usually the top left key or Escape) and plug in the keyboard
* **Physical reset button**: Swap the boot switch on the back of the PCB to "1" and hit the reset button
* **Keycode in layout**: Press the key mapped to `RESET` if it is available

Some files were not shown because too many files have changed in this diff Show More