diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 77b38ff..0a994da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,7 +70,7 @@ jobs: run: compote component pack --name waveshare_boards build: - name: ${{ matrix.board }} / ${{ matrix.idf }} / BMGR ${{ matrix.bmgr }} / ${{ matrix.integration }} + name: ${{ matrix.board }} / ${{ matrix.idf }} / BMGR ${{ matrix.bmgr }} needs: validate if: needs.validate.outputs.has_builds == 'true' runs-on: ubuntu-latest @@ -92,7 +92,6 @@ jobs: set -eu python -m pip install '${{ matrix.component_manager }}' '${{ matrix.bmgr_assist }}' python ../scripts/board_pack.py pin '${{ matrix.bmgr }}' - python ../scripts/board_pack.py integration '${{ matrix.integration }}' idf.py bmgr -l idf.py bmgr -b '${{ matrix.board }}' idf.py build diff --git a/README.md b/README.md index 838c61c..7b21b77 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,8 @@ CI validates generation and compilation; physical operation requires board testi ## 🚀 Quick start -Activate ESP-IDF first. Until a registry version is published, clone this pack -into an **existing ESP-IDF application's** component directory: +Activate ESP-IDF first. For a local checkout, clone this pack into an +**existing ESP-IDF application's** component directory: ```bash mkdir -p components @@ -69,8 +69,7 @@ the component name. The pack declares `espressif/esp_board_manager` as a public dependency. Applications can include `esp_board_manager.h` and initialize the selected board using `esp_board_manager_init()`. -After maintainers publish the component, install it from the registry instead -of keeping the local clone: +Published versions can be installed from the registry: ```bash idf.py add-dependency "waveshare/waveshare_boards" @@ -78,15 +77,14 @@ idf.py reconfigure idf.py bmgr -l ``` -The intended registry identity is `waveshare/waveshare_boards`; a repository version -or a passing packaging check does not by itself mean that version is published. +Find available versions in the +[Component Registry](https://components.espressif.com/components/waveshare/waveshare_boards). ## 🗂️ Repository layout ```text boards// Board metadata, peripherals, devices, and setup code include/ Framework-independent AMOLED brightness helper -integrations/ Optional framework adapters, shared across boards idf_component.yml Component metadata and managed dependencies CMakeLists.txt Board-pack component registration ci/test_app/ Board Manager integration compile test @@ -116,7 +114,7 @@ unique `board` value. The catalog is regenerated from the definitions. ## 📚 Documentation - [Board organization, hardware revisions, and migration](docs/BOARDS.md) -- [AMOLED brightness and optional Brookesia integration](docs/INTEGRATIONS.md) +- [AMOLED brightness control](docs/INTEGRATIONS.md) - [CI coverage and local validation](docs/CI.md) - [Registry credentials and publication](docs/PUBLISHING.md) - [Contributing](CONTRIBUTING.md) diff --git a/README_ZH.md b/README_ZH.md index ee98892..7eff548 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -42,7 +42,7 @@ ## 🚀 快速开始 -先激活 ESP-IDF 环境。在组件库版本发布之前,将本仓库克隆到**已有 ESP-IDF 应用**的组件目录: +先激活 ESP-IDF 环境。使用本地源码时,将本仓库克隆到**已有 ESP-IDF 应用**的组件目录: ```bash mkdir -p components @@ -63,7 +63,7 @@ idf.py build 组件包已经公开依赖 `espressif/esp_board_manager`;应用可以包含 `esp_board_manager.h`,并通过 `esp_board_manager_init()` 初始化所选板卡。 -维护者正式发布组件后,可以通过组件库安装,替代本地克隆: +也可以通过组件库安装已发布版本: ```bash idf.py add-dependency "waveshare/waveshare_boards" @@ -71,15 +71,13 @@ idf.py reconfigure idf.py bmgr -l ``` -计划使用的组件库名称为 `waveshare/waveshare_boards`。仓库里的版本号或打包检查通过, -不代表该版本已经在组件库发布。 +可用版本见[在线组件库](https://components.espressif.com/components/waveshare/waveshare_boards)。 ## 🗂️ 仓库结构 ```text boards/<完整型号>/ 板卡信息、外设、设备与初始化代码 include/ 不依赖应用框架的 AMOLED 调光函数 -integrations/ 跨板卡共用的可选框架适配 idf_component.yml 组件元数据与托管依赖 CMakeLists.txt 板卡包组件注册 ci/test_app/ Board Manager 集成编译测试 @@ -107,7 +105,7 @@ python -m unittest discover -s ci/scripts -p 'test_*.py' -v ## 📚 文档 - [板卡组织、硬件版本与迁移说明](docs/BOARDS_ZH.md) -- [AMOLED 调光与可选 Brookesia 集成](docs/INTEGRATIONS_ZH.md) +- [AMOLED 亮度控制](docs/INTEGRATIONS_ZH.md) - [CI 覆盖范围与本地验证](docs/CI_ZH.md) - [组件库凭据与发布](docs/PUBLISHING_ZH.md) - [贡献指南](CONTRIBUTING_ZH.md) diff --git a/ci/markdown-audit.json b/ci/markdown-audit.json index 2f84179..1c0067b 100644 --- a/ci/markdown-audit.json +++ b/ci/markdown-audit.json @@ -29,13 +29,5 @@ "license" ] } - ], - "classification_rules": [ - { - "category": "embedded_upstream", - "patterns": [ - "integrations/brookesia_hal_custom/CHANGELOG.md" - ] - } ] } diff --git a/ci/scripts/board_pack.py b/ci/scripts/board_pack.py index 28fe910..849ae72 100644 --- a/ci/scripts/board_pack.py +++ b/ci/scripts/board_pack.py @@ -15,7 +15,7 @@ ROOT = Path(__file__).resolve().parents[2] EXCLUDED = {"ci", "scripts", "docs", "firmware", "examples", "build", - "managed_components", "components", "third_party", "libraries", "dist", "integrations"} + "managed_components", "components", "third_party", "libraries", "dist"} STABLE = re.compile(r"\d+\.\d+\.\d+(?:~\d+)?") @@ -94,7 +94,7 @@ def route(boards, paths): selected.update(direct) else: selected.update(b["board"] for b in boards) - if not (value.startswith(("ci/", "scripts/", ".github/workflows/", "integrations/", "include/")) + if not (value.startswith(("ci/", "scripts/", ".github/workflows/", "include/")) or value in {"CMakeLists.txt", "idf_component.yml"}): unknown.append(value) return {"boards": [b for b in boards if b["board"] in selected], @@ -113,42 +113,17 @@ def registry_versions(root): def matrix(root, boards, versions): config = json.loads((root / "ci/versions.json").read_text(encoding="utf-8")) - if not set(config.get("brookesia_idf", [])).issubset(config["idf"]): - raise ValueError("Brookesia test versions must be in the main IDF matrix") cells = [] - profiles = root / "integrations/brookesia_hal_custom/profiles" for board in boards: - modes = ["none"] - if (profiles / board["board"] / "sdkconfig.defaults").is_file(): - modes.append("brookesia") for idf in config["idf"]: for version in versions: - for mode in modes: - if mode == "brookesia" and idf not in config.get("brookesia_idf", []): - continue - cells.append(dict(board=board["board"], target=board["target"], - idf=idf, bmgr=version, integration=mode, - component_manager=config["component_manager"][idf], - bmgr_assist=config["bmgr_assist"])) + cells.append(dict(board=board["board"], target=board["target"], + idf=idf, bmgr=version, + component_manager=config["component_manager"][idf], + bmgr_assist=config["bmgr_assist"])) return {"include": cells} -def configure_integration(root, name): - path = root / "ci/test_app/main/idf_component.yml" - data = load_yaml(path) - if name == "brookesia": - component = root / "integrations/brookesia_hal_custom" - if not (component / "CMakeLists.txt").is_file(): - raise ValueError("Brookesia integration component is missing") - data["dependencies"]["brookesia_hal_custom"] = { - "override_path": "../../../integrations/brookesia_hal_custom"} - elif name == "none": - data["dependencies"].pop("brookesia_hal_custom", None) - else: - raise ValueError("unknown integration") - path.write_text(yaml.safe_dump(data, sort_keys=False), encoding="utf-8") - - def pin(root, version): if not STABLE.fullmatch(version): raise ValueError("an exact stable Board Manager version is required") @@ -165,8 +140,6 @@ def main(): sub.add_parser("check") pin_parser = sub.add_parser("pin") pin_parser.add_argument("version") - integration = sub.add_parser("integration") - integration.add_argument("name", choices=("none", "brookesia")) plan = sub.add_parser("matrix") scope = plan.add_mutually_exclusive_group(required=True) scope.add_argument("--all", action="store_true") @@ -178,9 +151,6 @@ def main(): if args.command == "pin": pin(args.root, args.version) return 0 - if args.command == "integration": - configure_integration(args.root, args.name) - return 0 boards = discover(args.root) if args.command == "check": print(json.dumps(boards, indent=2)) diff --git a/ci/scripts/test_board_pack.py b/ci/scripts/test_board_pack.py index d44593e..0be0329 100644 --- a/ci/scripts/test_board_pack.py +++ b/ci/scripts/test_board_pack.py @@ -56,7 +56,7 @@ def cli(self, *args): return result, values def test_discovery_excludes_generated_and_upstream(self): - for root in ('ci', 'managed_components', 'components', 'firmware', 'libraries', 'integrations', '.hidden'): + for root in ('ci', 'managed_components', 'components', 'firmware', 'libraries', '.hidden'): self.add_board(f'{root}/ignored') self.assertEqual(['alpha', 'beta'], [b['board'] for b in bp.discover(self.root)]) @@ -182,35 +182,8 @@ def test_full_matrix_cli_records_exact_tooling(self): self.assertEqual({'idf-component-manager==2.5.0', 'idf-component-manager==3.0.3'}, {c['component_manager'] for c in cells}) self.assertEqual('true', values['has_builds']) - - def test_matrix_only_adds_integration_for_declared_profiles(self): - self.write('integrations/brookesia_hal_custom/profiles/alpha/sdkconfig.defaults', '# profile\n') - result, values = self.cli('matrix', '--all', '--bmgr', '0.7.2') - self.assertEqual(0, result.returncode, result.stderr) - cells = json.loads(values['matrix'])['include'] - self.assertEqual(5, len(cells)) - opt_in = [cell for cell in cells if cell['integration'] == 'brookesia'] - self.assertEqual(1, len(opt_in)) - self.assertEqual({'v6.1'}, {cell['idf'] for cell in opt_in}) - self.assertEqual({'alpha'}, {cell['board'] for cell in opt_in}) - self.assertTrue(bp.route(self.boards, ['integrations/brookesia_hal_custom/README.md'])['docs_only']) - self.assertEqual(self.boards, bp.route(self.boards, ['integrations/brookesia_hal_custom/src/plugin.cpp'])['boards']) - - def test_integration_cli_preserves_pack_and_requires_component(self): - self.write('ci/test_app/main/idf_component.yml', - 'dependencies:\n waveshare_boards:\n override_path: ../../../\n') - result, _ = self.cli('integration', 'brookesia') - self.assertEqual(2, result.returncode) - self.write('integrations/brookesia_hal_custom/CMakeLists.txt', 'idf_component_register()\n') - result, _ = self.cli('integration', 'brookesia') - self.assertEqual(0, result.returncode, result.stderr) - path = self.root / 'ci/test_app/main/idf_component.yml' - deps = bp.load_yaml(path)['dependencies'] - self.assertEqual('../../../', deps['waveshare_boards']['override_path']) - self.assertEqual('../../../integrations/brookesia_hal_custom', deps['brookesia_hal_custom']['override_path']) - result, _ = self.cli('integration', 'none') - self.assertEqual(0, result.returncode, result.stderr) - self.assertEqual({'waveshare_boards'}, set(bp.load_yaml(path)['dependencies'])) + for cell in cells: + self.assertEqual({'board', 'target', 'idf', 'bmgr', 'component_manager', 'bmgr_assist'}, set(cell)) def test_pin_is_exact_and_preserves_pack(self): self.write('ci/test_app/main/idf_component.yml', diff --git a/ci/versions.json b/ci/versions.json index 5cb9f0d..48940fa 100644 --- a/ci/versions.json +++ b/ci/versions.json @@ -7,8 +7,5 @@ "v5.5.5": "idf-component-manager==2.5.0", "v6.1": "idf-component-manager==3.0.3" }, - "bmgr_assist": "esp-bmgr-assist==0.8.3", - "brookesia_idf": [ - "v6.1" - ] + "bmgr_assist": "esp-bmgr-assist==0.8.3" } diff --git a/docs/BOARDS.md b/docs/BOARDS.md index 8fb4d09..fd04ddc 100644 --- a/docs/BOARDS.md +++ b/docs/BOARDS.md @@ -42,22 +42,18 @@ The migration makes these changes to the imported profiles: - Include `dev_custom.h` explicitly for custom-device registration on Board Manager 0.7.2. - Extract the unchanged QSPI brightness command into the public - `waveshare_amoled_set_brightness()` helper. Both ordinary applications and the - optional framework adapter can use it without duplicating the hardware command. + `waveshare_amoled_set_brightness()` helper for applications to control panel brightness. + See [brightness control](INTEGRATIONS.md). - Keep only hardware defaults in `sdkconfig.defaults.board`. Applications choose their own feature settings and partition layout. -- Consolidate the three Brookesia brightness plugins into one optional component - under `integrations/brookesia_hal_custom/`, with the original three application - profiles under its `profiles/` directory. Board YAML no longer selects a - framework plugin automatically. See [explicit integration](INTEGRATIONS.md). - Disable automatic SD formatting after mount failure on the 1.8 and 2.16 boards. Mount failure is reported without erasing an existing card. - Remove duplicate YAML keys with identical values and correct stale pin comments. The imported PMU rail and charging initialization remains unchanged. Display, touch, audio, SD, peripheral configuration, and panel initialization are retained -in each board directory. The shared integration keeps the brightness methods, -plugin/interface names, display group, mutex, command format, and default values. +in each board directory. Runtime AMOLED brightness control remains available +through the public helper, with the original command format and percentage scaling. The AXP2101 implementation remains board-local because the 1.8 setup also uses its GPIO expander; merging those paths is a separate hardware change. @@ -115,7 +111,7 @@ physical display/touch test after implementation. Brookesia's board package carries Apache-2.0; individual imported files retain SPDX notices, including CC0-1.0 on setup code. Preserve the original copyright -headers. The imported integration changelog remains upstream-owned and unchanged. +headers. Managed drivers retain their respective licenses; this pack does not relicense them. See [the upstream package license](https://github.com/espressif/esp-brookesia/blob/6a087b6d76e989802b72fdb835928b273af76af8/hal/brookesia_hal_boards/license.txt) and [CC0-1.0 terms](https://creativecommons.org/publicdomain/zero/1.0/legalcode.en). diff --git a/docs/BOARDS_ZH.md b/docs/BOARDS_ZH.md index 3967034..eecbbd5 100644 --- a/docs/BOARDS_ZH.md +++ b/docs/BOARDS_ZH.md @@ -38,17 +38,14 @@ boards/ - 显式包含 `dev_custom.h`,适配 Board Manager 0.7.2 的自定义设备注册接口。 - 将原有 QSPI 亮度命令提取为公共函数 `waveshare_amoled_set_brightness()`, - 普通应用与可选框架适配均可调用,硬件命令无需重复实现。 + 应用可以直接调用它控制面板亮度,详见[亮度控制](INTEGRATIONS_ZH.md)。 - `sdkconfig.defaults.board` 仅保留硬件默认配置,由应用自行选择功能配置和分区表。 -- 将三份 Brookesia 调光插件合并到一份可选组件 `integrations/brookesia_hal_custom/`, - 三块板卡的原应用配置分别保存在其 `profiles/` 目录。板卡 YAML 不再自动选择框架插件, - 应用可[显式接入](INTEGRATIONS_ZH.md)。 - 将 1.8、2.16 的 SD 挂载失败自动格式化关闭,挂载失败会报错,不会清空已有卡片。 - 删除值相同的重复 YAML 键,修正过时的引脚注释。 导入的 PMU 电源轨及充电初始化保持不变。显示、触摸、音频、SD、外设配置和面板初始化 -继续保存在各板卡目录。共用集成保留原调光方法、插件与接口名称、显示分组、线程互斥、 -命令格式及默认值。AXP2101 实现继续随板卡维护,因为 1.8 的初始化还涉及 GPIO 扩展器, +继续保存在各板卡目录。公共函数继续提供运行时 AMOLED 调光,保留原命令格式和百分比换算。 +AXP2101 实现继续随板卡维护,因为 1.8 的初始化还涉及 GPIO 扩展器, 合并这些路径属于另一项硬件行为修改。 ## 硬件资料核对 @@ -97,6 +94,6 @@ CST816S 是兼容驱动的 API 名称,V2 实际安装的是 CST820。 ## 来源许可证 Brookesia 板卡包采用 Apache-2.0,导入文件保留原 SPDX 声明,包括初始化代码中的 CC0-1.0。 -请保留原版权头。导入的集成更新日志保持上游原文。托管驱动遵循各自的许可证,本组件包不改变其授权。 +请保留原版权头。托管驱动遵循各自的许可证,本组件包不改变其授权。 详见[上游板卡包许可证](https://github.com/espressif/esp-brookesia/blob/6a087b6d76e989802b72fdb835928b273af76af8/hal/brookesia_hal_boards/license.txt)及 [CC0-1.0 条款](https://creativecommons.org/publicdomain/zero/1.0/legalcode.en)。 diff --git a/docs/CI.md b/docs/CI.md index e7bba14..3a30bef 100644 --- a/docs/CI.md +++ b/docs/CI.md @@ -16,9 +16,8 @@ Registry lookup failures fail the job. Each matrix entry records an exact versio The initial Board Manager floor is **0.7.2**, matching the reference board-pack template. The current floor and latest resolve to the same version, giving eight -plain board builds across the two IDF lines plus three optional Brookesia adapter -builds on IDF 6.1, eleven builds in total. Keep the floor until a deliberate compatibility change -is tested. Unsupported catalog profiles or generation failures fail CI; they are +board builds across the two IDF lines. Keep the floor until a deliberate +compatibility change is tested. Unsupported catalog profiles or generation failures fail CI; they are not counted as successful builds. For IDF 5.5, Component Manager **2.5.0** is selected because the reference template documents @@ -35,13 +34,6 @@ Use `boards//` inside the pack: local scanning begins at the application's `components/` root, so adding another chip directory exceeds its three-level search limit. See [layout and source evidence](BOARDS.md). -The optional adapter uses HAL interface/lib_utils 0.8.2. Upstream lib_utils 0.8 -requires IDF 6.0–6.2, so `ci/versions.json` declares its native IDF test line in -`brookesia_idf`. The ordinary board builds still cover both lines. The three -preserved application profiles identify the boards with this additional test; -full application profiles are not applied by the standalone adapter compile test. -See [integration coverage and upstream constraints](INTEGRATIONS.md). - ## Change routing The lightweight metadata, unit-test, navigation, and packaging checks run on every @@ -52,7 +44,7 @@ PR. `Board pack checks` is the stable aggregate status suitable for branch prote | Root or nested Markdown, documentation images | None | | Issue forms, license, ignore rules | None | | Files inside one board directory | That board | -| CI scripts, tests, workflows, integrations, root manifest or CMake | All boards | +| CI scripts, tests, workflows, public headers, root manifest or CMake | All boards | | Deleted or renamed board paths | Both sides are considered; removed paths can select all remaining boards | | Firmware documentation, source, binary, archive | Reported separately; no board build | | Unrecognized non-documentation input | All boards; path reported for review | @@ -82,7 +74,6 @@ python scripts/update_supported_boards_table.py --check python ci/scripts/check_docs.py python ci/scripts/board_pack.py matrix --all python ci/scripts/board_pack.py pin 0.7.2 -python ci/scripts/board_pack.py integration none idf.py -C ci/test_app bmgr -l idf.py -C ci/test_app bmgr -b esp32_s3_touch_lcd_7 idf.py -C ci/test_app build diff --git a/docs/CI_ZH.md b/docs/CI_ZH.md index 5bb6150..d4bfd13 100644 --- a/docs/CI_ZH.md +++ b/docs/CI_ZH.md @@ -13,8 +13,7 @@ 相同版本合并。组件库查询失败会使任务失败,每个矩阵项均记录明确版本。 Board Manager 初始最低版本为 **0.7.2**,与参考板卡包模板一致。 -当前最低版与最新版相同,普通板卡模式在两个 IDF 版本线上共八项编译, -另加三个 AMOLED 型号在 IDF 6.1 下的可选 Brookesia 适配测试,总计十一项。 +当前最低版与最新版相同,四块板卡在两个 IDF 版本线上共八项编译。 调整最低版本前需要明确兼容性变更并测试。 不支持的芯片能力配置或生成失败会使 CI 失败,不会被计为编译成功。 @@ -28,11 +27,6 @@ Board Manager 0.7.2 可在托管安装、`components/` 本地克隆和清单 `ov 组件包内采用 `boards/<完整型号>/`:本地扫描从应用的 `components/` 根目录开始, 再增加一层芯片目录会超过其三层搜索限制。详见[目录与源码依据](BOARDS_ZH.md)。 -可选适配使用 HAL interface / lib_utils 0.8.2。上游 lib_utils 0.8 要求 IDF 6.0–6.2, -因此 `ci/versions.json` 通过 `brookesia_idf` 声明其原生支持的测试版本线。 -普通板卡模式仍覆盖两个版本线,三个保留的应用配置标识需要额外适配测试的板卡。 -独立适配编译不会套用完整应用配置。详见[集成覆盖与上游约束](INTEGRATIONS_ZH.md)。 - ## 变更路由 每个 PR 都运行轻量的元数据、单元测试、导航和打包检查。 @@ -43,7 +37,7 @@ Board Manager 0.7.2 可在托管安装、`components/` 本地克隆和清单 `ov | 根目录或嵌套 Markdown、文档图片 | 不编译 | | Issue 表单、许可证、忽略规则 | 不编译 | | 单个板卡目录内的文件 | 对应板卡 | -| CI 脚本、测试、工作流、集成组件、根清单或 CMake | 全部板卡 | +| CI 脚本、测试、工作流、公共头文件、根清单或 CMake | 全部板卡 | | 删除或重命名板卡路径 | 同时考虑新旧路径;已移除路径可能选择全部剩余板卡 | | 固件文档、源码、二进制、归档 | 单独报告,不触发板卡编译 | | 未识别的非文档输入 | 全部板卡,并报告路径供检查 | @@ -70,7 +64,6 @@ python scripts/update_supported_boards_table.py --check python ci/scripts/check_docs.py python ci/scripts/board_pack.py matrix --all python ci/scripts/board_pack.py pin 0.7.2 -python ci/scripts/board_pack.py integration none idf.py -C ci/test_app bmgr -l idf.py -C ci/test_app bmgr -b esp32_s3_touch_lcd_7 idf.py -C ci/test_app build diff --git a/docs/INTEGRATIONS.md b/docs/INTEGRATIONS.md index 4480a5b..193cb9d 100644 --- a/docs/INTEGRATIONS.md +++ b/docs/INTEGRATIONS.md @@ -1,13 +1,13 @@ -# AMOLED brightness and optional integrations +# AMOLED brightness control [简体中文](INTEGRATIONS_ZH.md) · [Home](../README.md) · [Board layout](BOARDS.md) -## Brightness without Brookesia +## Set brightness -The public `waveshare_amoled_set_brightness(io, percent)` helper is available in -`include/waveshare_amoled.h`. It sends the original QSPI brightness command for -the supported CO5300/SH8601 panels without a Brookesia dependency. After board -initialization, an ordinary application can use the selected display's IO handle: +The public `waveshare_amoled_set_brightness(io, percent)` helper in +`include/waveshare_amoled.h` controls the supported CO5300/SH8601 QSPI AMOLED +panels. It is available directly from the board pack. After board initialization, +an application can use the selected display's IO handle: ```c #include "esp_board_manager.h" @@ -20,106 +20,25 @@ ESP_ERROR_CHECK(esp_board_manager_get_device_handle("display_lcd", (void **)&dis ESP_ERROR_CHECK(waveshare_amoled_set_brightness(display->io_handle, 75)); ``` -The function clamps percentages above 100 and returns the LCD IO error on failure. -It has no cached state; the optional framework adapter below retains the original -cached getter, mutex, and interface lifecycle. RGB LCD boards do not use this -QSPI AMOLED command. - -## Brookesia AMOLED brightness - -`integrations/brookesia_hal_custom/` provides one shared adapter for the 1.75C, -1.8 V1, and 2.16 AMOLED profiles. It replaces their three identical brightness -implementations. Board discovery and hardware initialization use `boards/` and -do not select this component. Applications opt in when they need Brookesia HAL -brightness control. - -The shared adapter preserves: - -- Device name `CustomDisplay`, interface implementation `CustomDisplay:Backlight`, - and display group `display_lcd`. -- `set_brightness()` and `get_brightness()`, clamping to 0–100 percent and converting - to the panel's 0–255 brightness command (`0x51` over QSPI) through the public helper. -- The mutex, unchanged-command suppression, error propagation, and initialization - behavior. The plugin starts at 0 percent; the application then chooses brightness. - `get_brightness()` returns the last successfully set value, not a hardware readback. -- The original unsupported result for separate light on/off methods. - -The ordinary panel setup retains its existing initial-brightness command. The -plugin is a framework interface adapter, not a replacement panel or PMU driver. - -## Explicit application setup - -Use **ESP-IDF 6.1** for the optional adapter. Brookesia HAL interface **0.8.2** -and its lib_utils **0.8.2** dependency are tested. Upstream lib_utils 0.8 requires -IDF **6.0 through 6.2**; it cannot resolve on IDF 5.5. This upstream framework -requirement does not apply to the ordinary board pack, which continues to build -on IDF 5.5.5 and 6.1. See the -[upstream dependency contract](https://github.com/espressif/esp-brookesia/blob/6a087b6d76e989802b72fdb835928b273af76af8/utils/brookesia_lib_utils/idf_component.yml). - -For the local clone layout in the [quick start](../README.md#quick-start), add -this dependency to the application's `main/idf_component.yml`: - -```yaml -dependencies: - brookesia_hal_custom: - override_path: ../components/waveshare_boards/integrations/brookesia_hal_custom -``` +The helper accepts 0–100 percent, clamps values above 100, and sends the original +QSPI brightness command (`0x51`). It returns `ESP_ERR_INVALID_ARG` for a null IO +handle and propagates LCD IO errors. Zero sets brightness to zero. -Merge it with existing dependencies. Resolve dependencies, select the matching -AMOLED board, and build the application. Do not add this adapter dependency to -`board_devices.yaml`. Explicit component selection registers the plugin under -its original name; applications use their normal HAL interface lookup. - -The adapter directly uses `brookesia_hal_interface` and Board Manager. It no -longer includes the full `brookesia_hal_adaptor` solely for the `display_lcd` -group constant. This keeps the standalone plugin independent of the adaptor's -Board Manager version constraint. - -A complete Brookesia application still needs its own dependency review: -[HAL adaptor 0.8.4](https://github.com/espressif/esp-brookesia/blob/6a087b6d76e989802b72fdb835928b273af76af8/hal/brookesia_hal_adaptor/idf_component.yml) -requires Board Manager `0.5.*` when display is enabled, while this board pack -requires `>=0.7.2`. That upstream constraint is not changed here. Passing the -standalone interface-adapter test does not claim that an unmodified full -Brookesia application resolves with this pack. - -## Preserved application profiles - -The original Brookesia application defaults are retained separately: - -```text -integrations/brookesia_hal_custom/profiles/ - esp32_s3_touch_amoled_1_75c/sdkconfig.defaults - esp32_s3_touch_amoled_1_8/sdkconfig.defaults - esp32_s3_touch_amoled_2_16/sdkconfig.defaults -``` - -They are opt-in reference configuration, not automatically appended board -settings. They enable application features and refer to `partitions_16m.csv`, -which the consuming application must provide. Choose the matching board profile -and review it against that application's Brookesia version and partition layout. -The ordinary hardware defaults remain beside each board. - -## Validation - -CI builds the plain board pack for all four boards on both IDF lines (eight -builds), then separately enables this adapter for the three AMOLED boards on -IDF 6.1 (three builds). This proves compilation and plugin linkage against the -HAL interfaces. Host tests cover the public command encoding, percentage scaling, -clamping, invalid handles, and IO-error propagation. CI also compiles the public -header with both IDF lines. It does not exercise physical brightness changes or a full -Brookesia application. +The helper has no cached state or mutex. Applications that need a remembered +brightness value or coordinate concurrent brightness changes manage that state +and synchronization themselves. The panel's existing initial-brightness command +and board power initialization are unchanged. RGB LCD boards do not use this +QSPI AMOLED command. -To compile the adapter with the repository's test app in a fresh checkout: +## Supported profiles and validation -```bash -python ci/scripts/board_pack.py pin 0.7.2 -python ci/scripts/board_pack.py integration brookesia -idf.py -C ci/test_app bmgr -b esp32_s3_touch_amoled_1_8 -idf.py -C ci/test_app build -``` +This helper applies to the 1.75C, 1.8 V1, and 2.16 AMOLED profiles. See +[board revisions](BOARDS.md) before selecting a hardware revision. -Use `integration none` for the ordinary test mode. Both commands only modify -the test application's manifest; do not commit generated test inputs. +Host tests check the command encoding, percentage scaling, clamping, invalid +handles, and IO-error propagation. CI compiles all four board profiles on +ESP-IDF 5.5.5 and 6.1, including the public header, for eight builds in total. +Physical brightness changes still require testing on the selected board. -The implementation and profiles retain their upstream copyright and license -notices. See [source attribution](BOARDS.md#source-licenses). +The implementation retains its original copyright and license notice. See +[source attribution](BOARDS.md#source-licenses). diff --git a/docs/INTEGRATIONS_ZH.md b/docs/INTEGRATIONS_ZH.md index 850f844..dbb86f2 100644 --- a/docs/INTEGRATIONS_ZH.md +++ b/docs/INTEGRATIONS_ZH.md @@ -1,12 +1,12 @@ -# AMOLED 调光与可选集成 +# AMOLED 亮度控制 [English](INTEGRATIONS.md) · [首页](../README_ZH.md) · [板卡结构](BOARDS_ZH.md) -## 不依赖 Brookesia 的调光 +## 设置亮度 公共函数 `waveshare_amoled_set_brightness(io, percent)` 位于 -`include/waveshare_amoled.h`,不依赖 Brookesia,使用原有 QSPI 亮度命令控制所支持的 -CO5300 / SH8601 面板。普通应用初始化板卡后,可以使用显示设备的 IO 句柄调光: +`include/waveshare_amoled.h`,控制所支持的 CO5300 / SH8601 QSPI AMOLED 面板, +由板卡包直接提供。应用初始化板卡后,可以使用显示设备的 IO 句柄调光: ```c #include "esp_board_manager.h" @@ -19,90 +19,20 @@ ESP_ERROR_CHECK(esp_board_manager_get_device_handle("display_lcd", (void **)&dis ESP_ERROR_CHECK(waveshare_amoled_set_brightness(display->io_handle, 75)); ``` -函数将超过 100 的百分比限制为 100,发送失败时返回 LCD IO 错误。 -它不缓存状态;下面的可选框架适配继续保留原有缓存读取、线程互斥与接口生命周期。 -RGB LCD 板卡不使用这条 QSPI AMOLED 命令。 - -## Brookesia AMOLED 调光 - -`integrations/brookesia_hal_custom/` 为 1.75C、1.8 V1 和 2.16 三个 AMOLED 型号 -提供一份共用适配,替代原来重复的三份亮度实现。板卡发现和硬件初始化使用 `boards/`, -不会自动选择该组件。需要 Brookesia HAL 调光接口的应用可以显式接入。 - -共用适配保留以下行为: - -- 设备名 `CustomDisplay`、接口实现名 `CustomDisplay:Backlight` 和显示分组 `display_lcd`。 -- `set_brightness()`、`get_brightness()`,百分比限制在 0–100,转换成面板的 - 0–255 亮度值,通过公共函数发送原有 QSPI `0x51` 命令。 -- 线程互斥、相同值不重复发送、错误返回与初始化行为。插件初始化亮度仍为 0%, - 后续由应用设置亮度。`get_brightness()` 返回最近成功设置的值,不是从硬件读回。 -- 独立灯光开关接口仍返回不支持,与原实现一致。 - -普通屏幕初始化保留原有的初始亮度命令。该插件负责框架接口适配,不替代面板或 PMU 驱动。 - -## 应用显式接入 - -可选适配使用 **ESP-IDF 6.1**。测试的 Brookesia HAL interface 和 lib_utils 均为 **0.8.2**。 -上游 lib_utils 0.8 要求 IDF **6.0 至 6.2**,无法在 IDF 5.5 下解析依赖。 -这一上游框架限制不影响普通板卡包,普通模式继续覆盖 IDF 5.5.5 和 6.1。 -依据见[上游依赖约定](https://github.com/espressif/esp-brookesia/blob/6a087b6d76e989802b72fdb835928b273af76af8/utils/brookesia_lib_utils/idf_component.yml)。 - -采用[快速开始](../README_ZH.md#quick-start)中的本地克隆结构时,在应用的 -`main/idf_component.yml` 中增加: - -```yaml -dependencies: - brookesia_hal_custom: - override_path: ../components/waveshare_boards/integrations/brookesia_hal_custom -``` +函数接受 0–100 的亮度百分比,将超过 100 的值限制为 100,发送原有 QSPI 亮度命令 `0x51`。 +IO 句柄为空时返回 `ESP_ERR_INVALID_ARG`,发送失败时返回 LCD IO 错误。 +设置为 0 时将亮度降至零。 -与已有依赖合并,解析依赖后选择对应 AMOLED 板卡,再编译应用。 -不要把这条依赖加回 `board_devices.yaml`。显式选择组件后,插件以原有名称注册, -应用仍通过正常的 HAL 接口查询方式使用它。 - -适配组件直接依赖 `brookesia_hal_interface` 和 Board Manager,不再仅为引用 -`display_lcd` 分组常量而包含完整的 `brookesia_hal_adaptor`,因此独立插件不受 -adaptor 的 Board Manager 版本约束牵连。 - -完整 Brookesia 应用仍需单独核对依赖: -[HAL adaptor 0.8.4](https://github.com/espressif/esp-brookesia/blob/6a087b6d76e989802b72fdb835928b273af76af8/hal/brookesia_hal_adaptor/idf_component.yml) -启用显示时要求 Board Manager `0.5.*`,而本板卡包要求 `>=0.7.2`。 -本次没有修改该上游约束。独立接口适配编译通过,不代表未修改的完整 Brookesia 应用 -能与本组件包一起解析依赖。 - -## 保留的应用配置 - -原 Brookesia 应用默认配置按型号分别保留: - -```text -integrations/brookesia_hal_custom/profiles/ - esp32_s3_touch_amoled_1_75c/sdkconfig.defaults - esp32_s3_touch_amoled_1_8/sdkconfig.defaults - esp32_s3_touch_amoled_2_16/sdkconfig.defaults -``` - -这些是按需采用的参考配置,不会自动追加到板卡配置中。 -它们会启用应用功能,并引用由应用提供的 `partitions_16m.csv`。 -选择对应板卡配置后,需要结合应用的 Brookesia 版本与分区表核对。 -普通硬件默认配置仍保存在各板卡目录。 - -## 验证范围 - -CI 对四块板卡在两个 IDF 版本线上运行普通模式编译,共八项; -另外在 IDF 6.1 上为三个 AMOLED 型号启用独立适配,共三项。 -它验证 HAL 接口的编译与插件链接。主机测试覆盖公共函数的命令编码、百分比换算、 -范围限制、无效句柄和 IO 错误返回;CI 也会在两个 IDF 版本线上编译公共头文件。 -这些检查不替代实机调光或完整 Brookesia 应用测试。 +函数不缓存状态,也不持有互斥锁。需要记忆亮度值或协调多个任务调光的应用, +应自行管理状态和同步。面板原有的初始亮度命令和板卡电源初始化保持不变。 +RGB LCD 板卡不使用这条 QSPI AMOLED 命令。 -在干净副本中,通过仓库测试应用编译该适配: +## 支持配置与验证 -```bash -python ci/scripts/board_pack.py pin 0.7.2 -python ci/scripts/board_pack.py integration brookesia -idf.py -C ci/test_app bmgr -b esp32_s3_touch_amoled_1_8 -idf.py -C ci/test_app build -``` +函数适用于 1.75C、1.8 V1 和 2.16 AMOLED 配置。选择板卡前请核对[硬件版本](BOARDS_ZH.md)。 -普通测试模式使用 `integration none`。命令只修改测试应用的清单,生成的测试输入不应提交。 +主机测试覆盖命令编码、百分比换算、范围限制、无效句柄和 IO 错误返回。 +CI 对四块板卡在 ESP-IDF 5.5.5 和 6.1 上进行编译,并包含公共头文件,共八项编译。 +实际亮度变化仍需在对应板卡上测试。 -实现和配置保留原有版权及许可证声明,详见[来源说明](BOARDS_ZH.md#来源许可证)。 +实现保留原有版权及许可证声明,详见[来源说明](BOARDS_ZH.md#来源许可证)。 diff --git a/idf_component.yml b/idf_component.yml index 5c9b04c..51ab5a6 100644 --- a/idf_component.yml +++ b/idf_component.yml @@ -1,4 +1,4 @@ -version: "0.1.0" +version: "0.1.1" description: Waveshare board definitions for ESP Board Manager license: Apache-2.0 url: https://github.com/waveshareteam/waveshare_boards diff --git a/integrations/brookesia_hal_custom/CHANGELOG.md b/integrations/brookesia_hal_custom/CHANGELOG.md deleted file mode 100644 index bb384c7..0000000 --- a/integrations/brookesia_hal_custom/CHANGELOG.md +++ /dev/null @@ -1,9 +0,0 @@ -# ChangeLog - -## v0.1.0 - 2026-04-30 - -### Initial Release - -- feat(repo): add custom HAL component for the Waveshare ESP32-S3 Touch AMOLED 1.75C board -- feat(display): add board-specific AMOLED display and backlight implementations -- feat(power): add setup callbacks for board power and battery hardware diff --git a/integrations/brookesia_hal_custom/CMakeLists.txt b/integrations/brookesia_hal_custom/CMakeLists.txt deleted file mode 100644 index bceba5c..0000000 --- a/integrations/brookesia_hal_custom/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# This component is selected explicitly by the consuming application. -idf_component_register( - SRCS "src/display/device.cpp" "src/display/backlight_impl.cpp" - INCLUDE_DIRS "include" - PRIV_INCLUDE_DIRS "src" - REQUIRES waveshare_boards -) - -target_compile_features(${COMPONENT_LIB} PUBLIC cxx_std_17) -target_compile_definitions(${COMPONENT_LIB} PRIVATE - BROOKESIA_HAL_CUSTOM_DISPLAY_DEVICE_PLUGIN_SYMBOL=custom_display_device_plugin_symbol -) -target_link_libraries(${COMPONENT_LIB} PRIVATE "-u custom_display_device_plugin_symbol") diff --git a/integrations/brookesia_hal_custom/Kconfig b/integrations/brookesia_hal_custom/Kconfig deleted file mode 100644 index 080ba23..0000000 --- a/integrations/brookesia_hal_custom/Kconfig +++ /dev/null @@ -1,5 +0,0 @@ -menu "ESP-Brookesia: Hal Custom Configurations" - menuconfig BROOKESIA_HAL_CUSTOM_ENABLE_DEBUG_LOG - bool "Enable debug or lower level logs" - default n -endmenu diff --git a/integrations/brookesia_hal_custom/idf_component.yml b/integrations/brookesia_hal_custom/idf_component.yml deleted file mode 100644 index 94fa444..0000000 --- a/integrations/brookesia_hal_custom/idf_component.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: "0.1.1" -description: Optional AMOLED brightness integration for Brookesia HAL interfaces -license: Apache-2.0 -dependencies: - # Brookesia 0.8 lib_utils requires ESP-IDF 6.0 through 6.2. - idf: ">=6.0,<=6.2" - # Keep the interface ABI aligned with the imported Brookesia source. - espressif/brookesia_hal_interface: - version: "0.8.*" - require: public - espressif/esp_board_manager: - version: ">=0.7.2" - require: public diff --git a/integrations/brookesia_hal_custom/include/brookesia/hal_custom.hpp b/integrations/brookesia_hal_custom/include/brookesia/hal_custom.hpp deleted file mode 100644 index 201d3a1..0000000 --- a/integrations/brookesia_hal_custom/include/brookesia/hal_custom.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -#include "hal_custom/macro_configs.h" -#include "hal_custom/display/device.hpp" diff --git a/integrations/brookesia_hal_custom/include/brookesia/hal_custom/display/device.hpp b/integrations/brookesia_hal_custom/include/brookesia/hal_custom/display/device.hpp deleted file mode 100644 index 17f4585..0000000 --- a/integrations/brookesia_hal_custom/include/brookesia/hal_custom/display/device.hpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * @file device.hpp - * @brief Singleton HAL device providing brightness control for board-managed AMOLED displays. - */ -#pragma once - -#include -#include -#include -#include -#include "brookesia/hal_interface/device.hpp" -#include "brookesia/hal_interface/interfaces/display/backlight.hpp" - -namespace esp_brookesia::hal { - -/** - * @brief Board-backed custom display device - * - * Obtained via get_instance(). Not copyable or movable. - */ -class CustomDisplayDevice : public Device { -public: - /** @brief Logical device name passed to the base @ref Device constructor. */ - static constexpr const char *DEVICE_NAME = "CustomDisplay"; - /** @brief Registry key for the display backlight HAL implementation (`"CustomDisplay:Backlight"`). */ - static constexpr const char *DISPLAY_BACKLIGHT_IMPL_NAME = "CustomDisplay:Backlight"; - - CustomDisplayDevice(const CustomDisplayDevice &) = delete; - CustomDisplayDevice &operator=(const CustomDisplayDevice &) = delete; - CustomDisplayDevice(CustomDisplayDevice &&) = delete; - CustomDisplayDevice &operator=(CustomDisplayDevice &&) = delete; - - /** - * @brief Returns the process-wide singleton custom display device. - * - * @return Reference to the unique @ref CustomDisplayDevice instance. - */ - static CustomDisplayDevice &get_instance() - { - static CustomDisplayDevice instance; - return instance; - } - -private: - CustomDisplayDevice() - : Device(std::string(DEVICE_NAME)) - { - } - ~CustomDisplayDevice() = default; - - bool probe() override; - std::vector get_interface_specs() const override; - bool on_init() override; - void on_deinit() override; - - bool init_backlight(); - void deinit_backlight(); -}; - -} // namespace esp_brookesia::hal diff --git a/integrations/brookesia_hal_custom/include/brookesia/hal_custom/macro_configs.h b/integrations/brookesia_hal_custom/include/brookesia/hal_custom/macro_configs.h deleted file mode 100644 index cc69b71..0000000 --- a/integrations/brookesia_hal_custom/include/brookesia/hal_custom/macro_configs.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#pragma once - -#include "sdkconfig.h" - -/** - * @brief Default log tag used by the component. - */ -#define BROOKESIA_HAL_CUSTOM_LOG_TAG "HalCustom" - -#if !defined(BROOKESIA_HAL_CUSTOM_ENABLE_DEBUG_LOG) -# if defined(CONFIG_BROOKESIA_HAL_CUSTOM_ENABLE_DEBUG_LOG) -# define BROOKESIA_HAL_CUSTOM_ENABLE_DEBUG_LOG CONFIG_BROOKESIA_HAL_CUSTOM_ENABLE_DEBUG_LOG -# else -# define BROOKESIA_HAL_CUSTOM_ENABLE_DEBUG_LOG (0) -# endif -#endif - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////// Display ////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -/* Backlight */ -#if !defined(BROOKESIA_HAL_CUSTOM_DISPLAY_BACKLIGHT_BRIGHTNESS_DEFAULT) -# if defined(CONFIG_BROOKESIA_HAL_CUSTOM_DISPLAY_BACKLIGHT_BRIGHTNESS_DEFAULT) -# define BROOKESIA_HAL_CUSTOM_DISPLAY_BACKLIGHT_BRIGHTNESS_DEFAULT CONFIG_BROOKESIA_HAL_CUSTOM_DISPLAY_BACKLIGHT_BRIGHTNESS_DEFAULT -# else -# define BROOKESIA_HAL_CUSTOM_DISPLAY_BACKLIGHT_BRIGHTNESS_DEFAULT (90) -# endif -#endif - -#if !defined(BROOKESIA_HAL_CUSTOM_DISPLAY_BACKLIGHT_BRIGHTNESS_MIN) -# if defined(CONFIG_BROOKESIA_HAL_CUSTOM_DISPLAY_BACKLIGHT_BRIGHTNESS_MIN) -# define BROOKESIA_HAL_CUSTOM_DISPLAY_BACKLIGHT_BRIGHTNESS_MIN CONFIG_BROOKESIA_HAL_CUSTOM_DISPLAY_BACKLIGHT_BRIGHTNESS_MIN -# else -# define BROOKESIA_HAL_CUSTOM_DISPLAY_BACKLIGHT_BRIGHTNESS_MIN (20) -# endif -#endif - -#if !defined(BROOKESIA_HAL_CUSTOM_DISPLAY_BACKLIGHT_BRIGHTNESS_MAX) -# if defined(CONFIG_BROOKESIA_HAL_CUSTOM_DISPLAY_BACKLIGHT_BRIGHTNESS_MAX) -# define BROOKESIA_HAL_CUSTOM_DISPLAY_BACKLIGHT_BRIGHTNESS_MAX CONFIG_BROOKESIA_HAL_CUSTOM_DISPLAY_BACKLIGHT_BRIGHTNESS_MAX -# else -# define BROOKESIA_HAL_CUSTOM_DISPLAY_BACKLIGHT_BRIGHTNESS_MAX (100) -# endif -#endif diff --git a/integrations/brookesia_hal_custom/profiles/esp32_s3_touch_amoled_1_75c/sdkconfig.defaults b/integrations/brookesia_hal_custom/profiles/esp32_s3_touch_amoled_1_75c/sdkconfig.defaults deleted file mode 100644 index ed9d32e..0000000 --- a/integrations/brookesia_hal_custom/profiles/esp32_s3_touch_amoled_1_75c/sdkconfig.defaults +++ /dev/null @@ -1,84 +0,0 @@ -CONFIG_ESPTOOLPY_FLASHMODE_QIO=y -CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y -CONFIG_ESPTOOLPY_FLASHFREQ_80M=y -CONFIG_PARTITION_TABLE_CUSTOM=y -CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_16m.csv" -CONFIG_PARTITION_TABLE_FILENAME="partitions_16m.csv" -CONFIG_SPIRAM=y -CONFIG_SPIRAM_MODE_OCT=y -CONFIG_SPIRAM_SPEED_80M=y -CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y -CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0 -CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y -CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y -CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY=y -CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y -CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y -CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y -CONFIG_IDF_EXPERIMENTAL_FEATURES=y - -# Brookesia:Hal:Adaptor -# System -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_SYSTEM_DEVICE=y -# System:BoardInfo -CONFIG_BROOKESIA_HAL_ADAPTOR_SYSTEM_ENABLE_BOARD_INFO_IMPL=y -# Network -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_NETWORK_DEVICE=y -# Network:SntpClient -CONFIG_BROOKESIA_HAL_ADAPTOR_NETWORK_ENABLE_SNTP_CLIENT_IMPL=y -# Network:HttpClient -CONFIG_BROOKESIA_HAL_ADAPTOR_NETWORK_ENABLE_HTTP_CLIENT_IMPL=y -CONFIG_LWIP_SNTP_MAX_SERVERS=4 -CONFIG_LWIP_SNTP_STARTUP_DELAY=n -CONFIG_LWIP_DHCP_GET_NTP_SRV=y -CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=4 -# Audio -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_AUDIO_DEVICE=y -# Audio:CodecPlayer -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_ENABLE_CODEC_PLAYER_IMPL=y -# Audio:CodecRecorder -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_ENABLE_CODEC_RECORDER_IMPL=y -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_CODEC_RECORDER_BITS=32 -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_CODEC_RECORDER_CHANNELS=2 -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_CODEC_RECORDER_SAMPLE_RATE=16000 -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_CODEC_RECORDER_MIC_LAYOUT="RMNN" -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_CODEC_RECORDER_GENERAL_GAIN="36.0" -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_CODEC_RECORDER_CHANNEL_GAINS="{}" -# Audio:Processor -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_ENABLE_PROCESSOR_IMPL=y -CONFIG_AUDIO_SIMPLE_PLAYER_RESAMPLE_DEST_RATE=16000 -CONFIG_ESP_AUDIO_SIMPLE_PLAYER_CH_CVT_EN=y -CONFIG_ESP_AUDIO_SIMPLE_PLAYER_BIT_CVT_EN=y -CONFIG_AUDIO_SIMPLE_PLAYER_BIT_CVT_DEST_32BIT=y -# Display -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_DISPLAY_DEVICE=y -# Display:LedcBacklight -# Since custom backlight device is used, the default is disabled here -CONFIG_BROOKESIA_HAL_ADAPTOR_DISPLAY_ENABLE_LEDC_BACKLIGHT_IMPL=n -# Display:LcdPanel -CONFIG_BROOKESIA_HAL_ADAPTOR_DISPLAY_ENABLE_LCD_PANEL_IMPL=y -CONFIG_BROOKESIA_HAL_ADAPTOR_DISPLAY_LCD_PANEL_H_RES=466 -CONFIG_BROOKESIA_HAL_ADAPTOR_DISPLAY_LCD_PANEL_V_RES=466 -CONFIG_BROOKESIA_HAL_ADAPTOR_DISPLAY_LCD_PANEL_DRAW_X_ALIGN_BYTES=2 -CONFIG_BROOKESIA_HAL_ADAPTOR_DISPLAY_LCD_PANEL_DRAW_Y_ALIGN_BYTES=2 -# Display:LcdTouch -CONFIG_BROOKESIA_HAL_ADAPTOR_DISPLAY_ENABLE_LCD_TOUCH_IMPL=y -# Storage -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_STORAGE_DEVICE=y -# Storage:KV -CONFIG_BROOKESIA_HAL_ADAPTOR_STORAGE_ENABLE_KEY_VALUE_IMPL=y -CONFIG_NVS_ALLOCATE_CACHE_IN_SPIRAM=y -# Storage:GeneralFs -CONFIG_BROOKESIA_HAL_ADAPTOR_STORAGE_ENABLE_FILE_SYSTEM_IMPL=y -CONFIG_BROOKESIA_HAL_ADAPTOR_STORAGE_FILE_SYSTEM_ENABLE_LITTLEFS=y -CONFIG_BROOKESIA_HAL_ADAPTOR_STORAGE_FILE_SYSTEM_ENABLE_SDCARD=n -CONFIG_FATFS_LFN_HEAP=y -CONFIG_SPIFFS_OBJ_NAME_LEN=64 -# Power -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_POWER_DEVICE=y -# Power:Battery -CONFIG_BROOKESIA_HAL_ADAPTOR_POWER_ENABLE_BATTERY=y -CONFIG_BROOKESIA_HAL_ADAPTOR_POWER_BATTERY_IMPL_AXP2101=y -# WiFi -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_WIFI_DEVICE=y -CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=3072 diff --git a/integrations/brookesia_hal_custom/profiles/esp32_s3_touch_amoled_1_8/sdkconfig.defaults b/integrations/brookesia_hal_custom/profiles/esp32_s3_touch_amoled_1_8/sdkconfig.defaults deleted file mode 100644 index d33d6f6..0000000 --- a/integrations/brookesia_hal_custom/profiles/esp32_s3_touch_amoled_1_8/sdkconfig.defaults +++ /dev/null @@ -1,81 +0,0 @@ -CONFIG_ESPTOOLPY_FLASHMODE_QIO=y -CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y -CONFIG_ESPTOOLPY_FLASHFREQ_80M=y -CONFIG_PARTITION_TABLE_CUSTOM=y -CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_16m.csv" -CONFIG_PARTITION_TABLE_FILENAME="partitions_16m.csv" -CONFIG_SPIRAM=y -CONFIG_SPIRAM_MODE_OCT=y -CONFIG_SPIRAM_SPEED_80M=y -CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0 -CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y -CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y -CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY=y -CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y -CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y -CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y -CONFIG_IDF_EXPERIMENTAL_FEATURES=y - -# Brookesia:Hal:Adaptor -# System -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_SYSTEM_DEVICE=y -# System:BoardInfo -CONFIG_BROOKESIA_HAL_ADAPTOR_SYSTEM_ENABLE_BOARD_INFO_IMPL=y -# Network -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_NETWORK_DEVICE=y -# Network:SntpClient -CONFIG_BROOKESIA_HAL_ADAPTOR_NETWORK_ENABLE_SNTP_CLIENT_IMPL=y -# Network:HttpClient -CONFIG_BROOKESIA_HAL_ADAPTOR_NETWORK_ENABLE_HTTP_CLIENT_IMPL=y -CONFIG_LWIP_SNTP_MAX_SERVERS=4 -CONFIG_LWIP_SNTP_STARTUP_DELAY=n -CONFIG_LWIP_DHCP_GET_NTP_SRV=y -CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=4 -# Audio -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_AUDIO_DEVICE=y -# Audio:CodecPlayer -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_ENABLE_CODEC_PLAYER_IMPL=y -# Audio:CodecRecorder -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_ENABLE_CODEC_RECORDER_IMPL=y -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_CODEC_RECORDER_BITS=16 -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_CODEC_RECORDER_CHANNELS=2 -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_CODEC_RECORDER_SAMPLE_RATE=16000 -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_CODEC_RECORDER_MIC_LAYOUT="MR" -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_CODEC_RECORDER_GENERAL_GAIN="30.0" -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_CODEC_RECORDER_CHANNEL_GAINS="{}" -# Audio:Processor -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_ENABLE_PROCESSOR_IMPL=y -CONFIG_AUDIO_SIMPLE_PLAYER_RESAMPLE_DEST_RATE=16000 -CONFIG_ESP_AUDIO_SIMPLE_PLAYER_CH_CVT_EN=y -CONFIG_ESP_AUDIO_SIMPLE_PLAYER_BIT_CVT_EN=y -CONFIG_AUDIO_SIMPLE_PLAYER_BIT_CVT_DEST_16BIT=y -# Display -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_DISPLAY_DEVICE=y -# Display:LedcBacklight -# Since custom backlight device is used, the default is disabled here -CONFIG_BROOKESIA_HAL_ADAPTOR_DISPLAY_ENABLE_LEDC_BACKLIGHT_IMPL=n -# Display:LcdPanel -CONFIG_BROOKESIA_HAL_ADAPTOR_DISPLAY_ENABLE_LCD_PANEL_IMPL=y -CONFIG_BROOKESIA_HAL_ADAPTOR_DISPLAY_LCD_PANEL_H_RES=368 -CONFIG_BROOKESIA_HAL_ADAPTOR_DISPLAY_LCD_PANEL_V_RES=448 -# Display:LcdTouch -CONFIG_BROOKESIA_HAL_ADAPTOR_DISPLAY_ENABLE_LCD_TOUCH_IMPL=y -# Storage -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_STORAGE_DEVICE=y -# Storage:KV -CONFIG_BROOKESIA_HAL_ADAPTOR_STORAGE_ENABLE_KEY_VALUE_IMPL=y -CONFIG_NVS_ALLOCATE_CACHE_IN_SPIRAM=y -# Storage:GeneralFs -CONFIG_BROOKESIA_HAL_ADAPTOR_STORAGE_ENABLE_FILE_SYSTEM_IMPL=y -CONFIG_BROOKESIA_HAL_ADAPTOR_STORAGE_FILE_SYSTEM_ENABLE_LITTLEFS=y -CONFIG_BROOKESIA_HAL_ADAPTOR_STORAGE_FILE_SYSTEM_ENABLE_SDCARD=y -CONFIG_FATFS_LFN_HEAP=y -CONFIG_SPIFFS_OBJ_NAME_LEN=64 -# Power -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_POWER_DEVICE=y -# Power:Battery -CONFIG_BROOKESIA_HAL_ADAPTOR_POWER_ENABLE_BATTERY=y -CONFIG_BROOKESIA_HAL_ADAPTOR_POWER_BATTERY_IMPL_AXP2101=y -# WiFi -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_WIFI_DEVICE=y -CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=3072 diff --git a/integrations/brookesia_hal_custom/profiles/esp32_s3_touch_amoled_2_16/sdkconfig.defaults b/integrations/brookesia_hal_custom/profiles/esp32_s3_touch_amoled_2_16/sdkconfig.defaults deleted file mode 100644 index 9f7c968..0000000 --- a/integrations/brookesia_hal_custom/profiles/esp32_s3_touch_amoled_2_16/sdkconfig.defaults +++ /dev/null @@ -1,84 +0,0 @@ -CONFIG_ESPTOOLPY_FLASHMODE_QIO=y -CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y -CONFIG_ESPTOOLPY_FLASHFREQ_80M=y -CONFIG_PARTITION_TABLE_CUSTOM=y -CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_16m.csv" -CONFIG_PARTITION_TABLE_FILENAME="partitions_16m.csv" -CONFIG_SPIRAM=y -CONFIG_SPIRAM_MODE_OCT=y -CONFIG_SPIRAM_SPEED_80M=y -CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y -CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0 -CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y -CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y -CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY=y -CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y -CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y -CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y -CONFIG_IDF_EXPERIMENTAL_FEATURES=y - -# Brookesia:Hal:Adaptor -# System -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_SYSTEM_DEVICE=y -# System:BoardInfo -CONFIG_BROOKESIA_HAL_ADAPTOR_SYSTEM_ENABLE_BOARD_INFO_IMPL=y -# Network -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_NETWORK_DEVICE=y -# Network:SntpClient -CONFIG_BROOKESIA_HAL_ADAPTOR_NETWORK_ENABLE_SNTP_CLIENT_IMPL=y -# Network:HttpClient -CONFIG_BROOKESIA_HAL_ADAPTOR_NETWORK_ENABLE_HTTP_CLIENT_IMPL=y -CONFIG_LWIP_SNTP_MAX_SERVERS=4 -CONFIG_LWIP_SNTP_STARTUP_DELAY=n -CONFIG_LWIP_DHCP_GET_NTP_SRV=y -CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=4 -# Audio -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_AUDIO_DEVICE=y -# Audio:CodecPlayer -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_ENABLE_CODEC_PLAYER_IMPL=y -# Audio:CodecRecorder -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_ENABLE_CODEC_RECORDER_IMPL=y -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_CODEC_RECORDER_BITS=32 -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_CODEC_RECORDER_CHANNELS=2 -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_CODEC_RECORDER_SAMPLE_RATE=16000 -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_CODEC_RECORDER_MIC_LAYOUT="RMNN" -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_CODEC_RECORDER_GENERAL_GAIN="36.0" -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_CODEC_RECORDER_CHANNEL_GAINS="{}" -# Audio:Processor -CONFIG_BROOKESIA_HAL_ADAPTOR_AUDIO_ENABLE_PROCESSOR_IMPL=y -CONFIG_AUDIO_SIMPLE_PLAYER_RESAMPLE_DEST_RATE=16000 -CONFIG_ESP_AUDIO_SIMPLE_PLAYER_CH_CVT_EN=y -CONFIG_ESP_AUDIO_SIMPLE_PLAYER_BIT_CVT_EN=y -CONFIG_AUDIO_SIMPLE_PLAYER_BIT_CVT_DEST_32BIT=y -# Display -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_DISPLAY_DEVICE=y -# Display:LedcBacklight -# Since custom backlight device is used, the default is disabled here -CONFIG_BROOKESIA_HAL_ADAPTOR_DISPLAY_ENABLE_LEDC_BACKLIGHT_IMPL=n -# Display:LcdPanel -CONFIG_BROOKESIA_HAL_ADAPTOR_DISPLAY_ENABLE_LCD_PANEL_IMPL=y -CONFIG_BROOKESIA_HAL_ADAPTOR_DISPLAY_LCD_PANEL_H_RES=480 -CONFIG_BROOKESIA_HAL_ADAPTOR_DISPLAY_LCD_PANEL_V_RES=480 -CONFIG_BROOKESIA_HAL_ADAPTOR_DISPLAY_LCD_PANEL_DRAW_X_ALIGN_BYTES=2 -CONFIG_BROOKESIA_HAL_ADAPTOR_DISPLAY_LCD_PANEL_DRAW_Y_ALIGN_BYTES=2 -# Display:LcdTouch -CONFIG_BROOKESIA_HAL_ADAPTOR_DISPLAY_ENABLE_LCD_TOUCH_IMPL=y -# Storage -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_STORAGE_DEVICE=y -# Storage:KV -CONFIG_BROOKESIA_HAL_ADAPTOR_STORAGE_ENABLE_KEY_VALUE_IMPL=y -CONFIG_NVS_ALLOCATE_CACHE_IN_SPIRAM=y -# Storage:GeneralFs -CONFIG_BROOKESIA_HAL_ADAPTOR_STORAGE_ENABLE_FILE_SYSTEM_IMPL=y -CONFIG_BROOKESIA_HAL_ADAPTOR_STORAGE_FILE_SYSTEM_ENABLE_LITTLEFS=y -CONFIG_BROOKESIA_HAL_ADAPTOR_STORAGE_FILE_SYSTEM_ENABLE_SDCARD=y -CONFIG_FATFS_LFN_HEAP=y -CONFIG_SPIFFS_OBJ_NAME_LEN=64 -# Power -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_POWER_DEVICE=y -# Power:Battery -CONFIG_BROOKESIA_HAL_ADAPTOR_POWER_ENABLE_BATTERY=y -CONFIG_BROOKESIA_HAL_ADAPTOR_POWER_BATTERY_IMPL_AXP2101=y -# WiFi -CONFIG_BROOKESIA_HAL_ADAPTOR_ENABLE_WIFI_DEVICE=y -CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=3072 diff --git a/integrations/brookesia_hal_custom/src/display/backlight_impl.cpp b/integrations/brookesia_hal_custom/src/display/backlight_impl.cpp deleted file mode 100644 index a7e0c0d..0000000 --- a/integrations/brookesia_hal_custom/src/display/backlight_impl.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#include -#include "brookesia/hal_custom/macro_configs.h" -#if !BROOKESIA_HAL_CUSTOM_ENABLE_DEBUG_LOG -# define BROOKESIA_LOG_DISABLE_DEBUG_TRACE 1 -#endif -#include "private/utils.hpp" -#include "esp_lcd_panel_ops.h" -#include "esp_board_device.h" -#include "esp_board_manager_includes.h" -#include "waveshare_amoled.h" -#include "backlight_impl.hpp" - -namespace esp_brookesia::hal { - -constexpr uint8_t BRIGHTNESS_DEFAULT = 0; -constexpr uint8_t BRIGHTNESS_MIN = 0; -constexpr uint8_t BRIGHTNESS_MAX = 100; - -namespace { -esp_lcd_panel_io_handle_t get_io_handle(void *handles) -{ - return reinterpret_cast(handles)->io_handle; -} -} // namespace - -CustomDisplayBacklightImpl::CustomDisplayBacklightImpl() - : display::BacklightIface(display::BacklightIface::Info{ - .group_id = ESP_BOARD_DEVICE_NAME_DISPLAY_LCD, -}) -{ - BROOKESIA_LOG_TRACE_GUARD_WITH_THIS(); - - boost::lock_guard lock(mutex_); - - auto ret = esp_board_manager_init_device_by_name(ESP_BOARD_DEVICE_NAME_DISPLAY_LCD); - BROOKESIA_CHECK_ESP_ERR_EXIT(ret, "Failed to init display LCD"); - - ret = esp_board_manager_get_device_handle(ESP_BOARD_DEVICE_NAME_DISPLAY_LCD, &handles_); - BROOKESIA_CHECK_ESP_ERR_EXIT(ret, "Failed to get handles"); - BROOKESIA_CHECK_NULL_EXIT(handles_, "Failed to get handles"); - - BROOKESIA_CHECK_FALSE_EXIT(set_brightness_internal(BRIGHTNESS_DEFAULT, true), "Failed to set default brightness"); -} - -CustomDisplayBacklightImpl::~CustomDisplayBacklightImpl() -{ - BROOKESIA_LOG_TRACE_GUARD_WITH_THIS(); -} - -bool CustomDisplayBacklightImpl::set_brightness(uint8_t percent) -{ - BROOKESIA_LOG_TRACE_GUARD_WITH_THIS(); - - BROOKESIA_LOGD("Params: percent(%1%)", percent); - - boost::lock_guard lock(mutex_); - - return set_brightness_internal(percent, false); -} - -bool CustomDisplayBacklightImpl::get_brightness(uint8_t &percent) -{ - BROOKESIA_LOG_TRACE_GUARD_WITH_THIS(); - - boost::lock_guard lock(mutex_); - - BROOKESIA_CHECK_FALSE_RETURN(is_valid_internal(), false, "LCD brightness is not initialized"); - - percent = brightness_; - - return true; -} - -bool CustomDisplayBacklightImpl::set_brightness_internal(uint8_t percent, bool force) -{ - BROOKESIA_LOG_TRACE_GUARD_WITH_THIS(); - - BROOKESIA_LOGD("Params: percent(%1%), force(%2%)", percent, force); - - BROOKESIA_CHECK_FALSE_RETURN(is_valid_internal(), false, "LCD brightness is not initialized"); - - auto percent_clamped = std::clamp(percent, BRIGHTNESS_MIN, BRIGHTNESS_MAX); - if (percent_clamped != percent) { - BROOKESIA_LOGW( - "Target brightness(%1%) is out of range [%2%, %3%], clamp to %4%", percent, BRIGHTNESS_MIN, BRIGHTNESS_MAX, - percent_clamped - ); - } - - if (!force && (percent_clamped == brightness_)) { - BROOKESIA_LOGD("Brightness is already %1%, skip", percent_clamped); - return true; - } - - auto ret = waveshare_amoled_set_brightness(get_io_handle(handles_), percent_clamped); - BROOKESIA_CHECK_ESP_ERR_RETURN(ret, false, "Failed to transmit brightness command"); - - brightness_ = percent_clamped; - - BROOKESIA_LOGI("Set brightness: %1%", brightness_); - - return true; -} - -} // namespace esp_brookesia::hal diff --git a/integrations/brookesia_hal_custom/src/display/backlight_impl.hpp b/integrations/brookesia_hal_custom/src/display/backlight_impl.hpp deleted file mode 100644 index ca0a64a..0000000 --- a/integrations/brookesia_hal_custom/src/display/backlight_impl.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#pragma once - -#include -#include "boost/thread/lock_guard.hpp" -#include "boost/thread/mutex.hpp" -#include "brookesia/hal_interface/interfaces/display/backlight.hpp" - -namespace esp_brookesia::hal { - -/** - * @brief Board-backed AMOLED brightness HAL interface using the display panel IO handle. - */ -class CustomDisplayBacklightImpl : public display::BacklightIface { -public: - CustomDisplayBacklightImpl(); - ~CustomDisplayBacklightImpl() override; - - bool set_brightness(uint8_t percent) override; - bool get_brightness(uint8_t &percent) override; - - bool is_light_on_off_supported() override - { - return false; - } - bool set_light_on_off(bool on) override - { - return false; - } - bool is_light_on() const override - { - return false; - } - - bool is_valid() const - { - boost::lock_guard lock(mutex_); - return is_valid_internal(); - } - -private: - bool is_valid_internal() const - { - return handles_ != nullptr; - } - - bool set_brightness_internal(uint8_t percent, bool force = false); - - mutable boost::mutex mutex_; - void *handles_ = nullptr; - uint8_t brightness_ = 0; -}; - -} // namespace esp_brookesia::hal diff --git a/integrations/brookesia_hal_custom/src/display/device.cpp b/integrations/brookesia_hal_custom/src/display/device.cpp deleted file mode 100644 index 5cceead..0000000 --- a/integrations/brookesia_hal_custom/src/display/device.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#include "brookesia/hal_custom/macro_configs.h" -#if !BROOKESIA_HAL_CUSTOM_ENABLE_DEBUG_LOG -# define BROOKESIA_LOG_DISABLE_DEBUG_TRACE 1 -#endif -#include "private/utils.hpp" -#include "brookesia/lib_utils/function_guard.hpp" -#include "brookesia/hal_custom/display/device.hpp" -#include "display/backlight_impl.hpp" - -using namespace esp_brookesia; - -namespace esp_brookesia::hal { - -bool CustomDisplayDevice::probe() -{ - BROOKESIA_LOG_TRACE_GUARD_WITH_THIS(); - - return true; -} - -std::vector CustomDisplayDevice::get_interface_specs() const -{ - return { - {display::BacklightIface::NAME, DISPLAY_BACKLIGHT_IMPL_NAME}, - }; -} - -bool CustomDisplayDevice::on_init() -{ - BROOKESIA_LOG_TRACE_GUARD_WITH_THIS(); - - BROOKESIA_CHECK_FALSE_EXECUTE(init_backlight(), {}, { BROOKESIA_LOGE("Failed to init display backlight"); }); - - BROOKESIA_CHECK_FALSE_RETURN(!interfaces_.empty(), false, "No valid display interfaces found"); - - return true; -} - -void CustomDisplayDevice::on_deinit() -{ - BROOKESIA_LOG_TRACE_GUARD_WITH_THIS(); - - deinit_backlight(); -} - -bool CustomDisplayDevice::init_backlight() -{ - BROOKESIA_LOG_TRACE_GUARD_WITH_THIS(); - - if (is_iface_initialized(DISPLAY_BACKLIGHT_IMPL_NAME)) { - BROOKESIA_LOGD("Backlight is already initialized, skip"); - return true; - } - - std::shared_ptr iface = nullptr; - BROOKESIA_CHECK_EXCEPTION_RETURN( - iface = std::make_shared(), false, - "Failed to create backlight interface" - ); - lib_utils::FunctionGuard iface_delete_guard([this, &iface]() { - BROOKESIA_LOG_TRACE_GUARD_WITH_THIS(); - iface.reset(); - }); - - BROOKESIA_CHECK_FALSE_RETURN(iface->is_valid(), false, "Failed to create backlight interface"); - - interfaces_.emplace(DISPLAY_BACKLIGHT_IMPL_NAME, iface); - - iface_delete_guard.release(); - - return true; -} - -void CustomDisplayDevice::deinit_backlight() -{ - BROOKESIA_LOG_TRACE_GUARD_WITH_THIS(); - - if (!is_iface_initialized(DISPLAY_BACKLIGHT_IMPL_NAME)) { - BROOKESIA_LOGD("Backlight is not initialized, skip"); - return; - } - - interfaces_.erase(DISPLAY_BACKLIGHT_IMPL_NAME); -} - -BROOKESIA_PLUGIN_REGISTER_SINGLETON_WITH_SYMBOL( - Device, CustomDisplayDevice, CustomDisplayDevice::DEVICE_NAME, CustomDisplayDevice::get_instance(), - BROOKESIA_HAL_CUSTOM_DISPLAY_DEVICE_PLUGIN_SYMBOL -); - -} // namespace esp_brookesia::hal diff --git a/integrations/brookesia_hal_custom/src/private/utils.hpp b/integrations/brookesia_hal_custom/src/private/utils.hpp deleted file mode 100644 index 89e5260..0000000 --- a/integrations/brookesia_hal_custom/src/private/utils.hpp +++ /dev/null @@ -1,11 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#pragma once - -#undef BROOKESIA_LOG_TAG -#define BROOKESIA_LOG_TAG "HalAdptExtra" -#include "brookesia/lib_utils/log.hpp" -#include "brookesia/lib_utils/check.hpp"