diff --git a/docs/feature_backlight.md b/docs/feature_backlight.md index 89916aa8134..69391fcefe9 100644 --- a/docs/feature_backlight.md +++ b/docs/feature_backlight.md @@ -40,7 +40,6 @@ Add the following to your `config.h`: |`BACKLIGHT_DEFAULT_ON` |`true` |Enable backlight upon clearing the EEPROM | |`BACKLIGHT_DEFAULT_BREATHING`|`false` |Whether to enable backlight breathing upon clearing the EEPROM | |`BACKLIGHT_DEFAULT_LEVEL` |`BACKLIGHT_LEVELS`|The default backlight level to use upon clearing the EEPROM | -|`BACKLIGHT_PWM_PERIOD` |2048Hz |Defaults to `BACKLIGHT_PWM_COUNTER_FREQUENCY / 2048`, which results in a PWM frequency of 2048Hz. | Unless you are designing your own keyboard, you generally should not need to change the `BACKLIGHT_PIN` or `BACKLIGHT_ON_STATE`. @@ -174,11 +173,13 @@ Depending on the ChibiOS board configuration, you may need to enable PWM at the The following `#define`s apply only to the `pwm` driver: -|Define |Default |Description | -|-----------------------|--------|-----------------------------------| -|`BACKLIGHT_PWM_DRIVER` |`PWMD4` |The PWM driver to use | -|`BACKLIGHT_PWM_CHANNEL`|`3` |The PWM channel to use | -|`BACKLIGHT_PAL_MODE` |`2` |The pin alternative function to use| +|Define |Default |Description | +|-----------------------|-------------|---------------------------------------------------------------| +|`BACKLIGHT_PWM_DRIVER` |`PWMD4` |The PWM driver to use | +|`BACKLIGHT_PWM_CHANNEL`|`3` |The PWM channel to use | +|`BACKLIGHT_PAL_MODE` |`2` |The pin alternative function to use | +|`BACKLIGHT_PWM_PERIOD` |*Not defined*|The PWM period in counter ticks - Default is platform dependent| + Refer to the ST datasheet for your particular MCU to determine these values. For example, these defaults are set up for pin `B8` on a Proton-C (STM32F303) using `TIM4_CH3` on AF2. Unless you are designing your own keyboard, you generally should not need to change them. diff --git a/lib/python/qmk/build_targets.py b/lib/python/qmk/build_targets.py index fc720220499..16a7ef87a22 100644 --- a/lib/python/qmk/build_targets.py +++ b/lib/python/qmk/build_targets.py @@ -31,6 +31,17 @@ class BuildTarget: def __repr__(self): return f'BuildTarget(keyboard={self.keyboard}, keymap={self.keymap})' + def __eq__(self, __value: object) -> bool: + if not isinstance(__value, BuildTarget): + return False + return self.__repr__() == __value.__repr__() + + def __ne__(self, __value: object) -> bool: + return not self.__eq__(__value) + + def __hash__(self) -> int: + return self.__repr__().__hash__() + def configure(self, parallel: int = None, clean: bool = None, compiledb: bool = None) -> None: if parallel is not None: self._parallel = parallel diff --git a/lib/python/qmk/cli/ci/validate_aliases.py b/lib/python/qmk/cli/ci/validate_aliases.py index a205d03cff9..7f781d43970 100644 --- a/lib/python/qmk/cli/ci/validate_aliases.py +++ b/lib/python/qmk/cli/ci/validate_aliases.py @@ -1,11 +1,8 @@ """Validates the list of keyboard aliases. """ -from pathlib import Path - from milc import cli -from qmk.json_schema import json_load -from qmk.keyboard import resolve_keyboard, keyboard_folder +from qmk.keyboard import resolve_keyboard, keyboard_folder, keyboard_alias_definitions def _safe_keyboard_folder(target): @@ -34,7 +31,7 @@ def _target_keyboard_exists(target): @cli.subcommand('Validates the list of keyboard aliases.', hidden=True) def ci_validate_aliases(cli): - aliases = json_load(Path('data/mappings/keyboard_aliases.hjson')) + aliases = keyboard_alias_definitions() success = True for alias in aliases.keys(): diff --git a/lib/python/qmk/cli/generate/api.py b/lib/python/qmk/cli/generate/api.py index 6c19b21ef58..53da16bea02 100755 --- a/lib/python/qmk/cli/generate/api.py +++ b/lib/python/qmk/cli/generate/api.py @@ -11,7 +11,7 @@ from qmk.datetime import current_datetime from qmk.info import info_json from qmk.json_schema import json_load from qmk.keymap import list_keymaps -from qmk.keyboard import find_readme, list_keyboards +from qmk.keyboard import find_readme, list_keyboards, keyboard_alias_definitions from qmk.keycodes import load_spec, list_versions, list_languages from qmk.xap.common import get_xap_definition_files, update_xap_definitions @@ -184,7 +184,7 @@ def generate_api(cli): # Generate data for the global files keyboard_list = sorted(kb_all) - keyboard_aliases = json_load(Path('data/mappings/keyboard_aliases.hjson')) + keyboard_aliases = keyboard_alias_definitions() keyboard_metadata = { 'last_updated': current_datetime(), 'keyboards': keyboard_list, diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py index 09418222222..f826050cd24 100644 --- a/lib/python/qmk/commands.py +++ b/lib/python/qmk/commands.py @@ -4,12 +4,12 @@ import os import sys import shutil from itertools import islice -from pathlib import Path from milc import cli import jsonschema from qmk.json_schema import json_load, validate +from qmk.keyboard import keyboard_alias_definitions def find_make(): @@ -54,7 +54,7 @@ def parse_configurator_json(configurator_file): exit(1) keyboard = user_keymap['keyboard'] - aliases = json_load(Path('data/mappings/keyboard_aliases.hjson')) + aliases = keyboard_alias_definitions() while keyboard in aliases: last_keyboard = keyboard diff --git a/lib/python/qmk/keyboard.py b/lib/python/qmk/keyboard.py index fdb509ac62a..01b016bfd6a 100644 --- a/lib/python/qmk/keyboard.py +++ b/lib/python/qmk/keyboard.py @@ -72,6 +72,11 @@ class AllKeyboards: base_path = os.path.join(os.getcwd(), "keyboards") + os.path.sep +@lru_cache(maxsize=1) +def keyboard_alias_definitions(): + return json_load(Path('data/mappings/keyboard_aliases.hjson')) + + def is_all_keyboards(keyboard): """Returns True if the keyboard is an AllKeyboards object. """ @@ -114,7 +119,7 @@ def keyboard_folder(keyboard): This checks aliases and DEFAULT_FOLDER to resolve the actual path for a keyboard. """ - aliases = json_load(Path('data/mappings/keyboard_aliases.hjson')) + aliases = keyboard_alias_definitions() while keyboard in aliases: last_keyboard = keyboard diff --git a/lib/python/qmk/search.py b/lib/python/qmk/search.py index 1140abe69df..84cf6cbe326 100644 --- a/lib/python/qmk/search.py +++ b/lib/python/qmk/search.py @@ -6,7 +6,7 @@ import fnmatch import logging import re from typing import List, Tuple -from dotty_dict import dotty +from dotty_dict import dotty, Dotty from milc import cli from qmk.util import parallel_map @@ -107,13 +107,22 @@ def expand_keymap_targets(targets: List[Tuple[str, str]]) -> List[Tuple[str, str return list(sorted(set(overall_targets))) +def _construct_build_target_kb_km(e): + return KeyboardKeymapBuildTarget(keyboard=e[0], keymap=e[1]) + + +def _construct_build_target_kb_km_json(e): + return KeyboardKeymapBuildTarget(keyboard=e[0], keymap=e[1], json=e[2]) + + def _filter_keymap_targets(target_list: List[Tuple[str, str]], filters: List[str] = []) -> List[BuildTarget]: """Filter a list of (keyboard, keymap) tuples based on the supplied filters. Optionally includes the values of the queried info.json keys. """ if len(filters) == 0: - targets = [KeyboardKeymapBuildTarget(keyboard=kb, keymap=km) for kb, km in target_list] + cli.log.info('Preparing target list...') + targets = list(set(parallel_map(_construct_build_target_kb_km, target_list))) else: cli.log.info('Parsing data for all matching keyboard/keymap combinations...') valid_keymaps = [(e[0], e[1], dotty(e[2])) for e in parallel_map(_load_keymap_info, target_list)] @@ -172,7 +181,9 @@ def _filter_keymap_targets(target_list: List[Tuple[str, str]], filters: List[str cli.log.warning(f'Unrecognized filter expression: {filter_expr}') continue - targets = [KeyboardKeymapBuildTarget(keyboard=e[0], keymap=e[1], json=e[2]) for e in valid_keymaps] + cli.log.info('Preparing target list...') + valid_keymaps = [(e[0], e[1], e[2].to_dict() if isinstance(e[2], Dotty) else e[2]) for e in valid_keymaps] # need to convert dotty_dict back to dict because it doesn't survive parallelisation + targets = list(set(parallel_map(_construct_build_target_kb_km_json, list(valid_keymaps)))) return targets diff --git a/platforms/arm_atsam/_util.h b/platforms/arm_atsam/_util.h new file mode 100644 index 00000000000..38aa9f44728 --- /dev/null +++ b/platforms/arm_atsam/_util.h @@ -0,0 +1,9 @@ +// Copyright 2023 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#define RESIDENT_IN_RAM(funcname) __attribute__((section(".ramfunc." #funcname), noinline)) funcname + +#if __has_include_next("_util.h") +# include_next "_util.h" +#endif diff --git a/platforms/avr/_util.h b/platforms/avr/_util.h new file mode 100644 index 00000000000..81b94896ba1 --- /dev/null +++ b/platforms/avr/_util.h @@ -0,0 +1,10 @@ +// Copyright 2023 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +// AVR can't actually run anything from RAM, so just no-op the define. +#define RESIDENT_IN_RAM(funcname) funcname + +#if __has_include_next("_util.h") +# include_next "_util.h" +#endif diff --git a/platforms/chibios/_util.h b/platforms/chibios/_util.h new file mode 100644 index 00000000000..64eb62fa151 --- /dev/null +++ b/platforms/chibios/_util.h @@ -0,0 +1,9 @@ +// Copyright 2023 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#define RESIDENT_IN_RAM(funcname) __attribute__((section(".ram0_init." #funcname), noinline)) funcname + +#if __has_include_next("_util.h") +# include_next "_util.h" +#endif diff --git a/quantum/util.h b/quantum/util.h index 21e3487b282..94d9f223179 100644 --- a/quantum/util.h +++ b/quantum/util.h @@ -50,3 +50,7 @@ #if !defined(PACKED) # define PACKED __attribute__((__packed__)) #endif + +#if __has_include("_util.h") +# include "_util.h" /* Include the platform's _util.h */ +#endif