@typecad/cuttlefish 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +79 -0
- package/dist/api/board-types.d.ts +1 -0
- package/dist/api/board-types.js +4 -0
- package/dist/api/capabilities.d.ts +12 -0
- package/dist/api/capabilities.js +1 -0
- package/dist/api/config.d.ts +120 -0
- package/dist/api/config.js +7 -0
- package/dist/api/index.d.ts +5 -0
- package/dist/api/index.js +2 -0
- package/dist/api/schema/builder.d.ts +14 -0
- package/dist/api/schema/builder.js +15 -0
- package/dist/api/schema/index.d.ts +2 -0
- package/dist/api/schema/index.js +1 -0
- package/dist/api/schema/types.d.ts +257 -0
- package/dist/api/schema/types.js +4 -0
- package/dist/api/shared/async-runtime-static.d.ts +8 -0
- package/dist/api/shared/async-runtime-static.js +201 -0
- package/dist/api/shared/async-types.d.ts +42 -0
- package/dist/api/shared/async-types.js +8 -0
- package/dist/api/shared/board-resolver.d.ts +12 -0
- package/dist/api/shared/board-resolver.js +7 -0
- package/dist/api/shared/cpp-type-ir.d.ts +229 -0
- package/dist/api/shared/cpp-type-ir.js +672 -0
- package/dist/api/shared/display-adapter.d.ts +12 -0
- package/dist/api/shared/display-adapter.js +145 -0
- package/dist/api/shared/display-adapters/eink-mono.d.ts +2 -0
- package/dist/api/shared/display-adapters/eink-mono.js +53 -0
- package/dist/api/shared/display-adapters/sdl.d.ts +2 -0
- package/dist/api/shared/display-adapters/sdl.js +452 -0
- package/dist/api/shared/display-adapters/ssd1309.d.ts +2 -0
- package/dist/api/shared/display-adapters/ssd1309.js +136 -0
- package/dist/api/shared/display-adapters/st7796.d.ts +2 -0
- package/dist/api/shared/display-adapters/st7796.js +132 -0
- package/dist/api/shared/display-capabilities.d.ts +45 -0
- package/dist/api/shared/display-capabilities.js +54 -0
- package/dist/api/shared/display-op-ir.d.ts +62 -0
- package/dist/api/shared/display-op-ir.js +19 -0
- package/dist/api/shared/display-profile.d.ts +265 -0
- package/dist/api/shared/display-profile.js +338 -0
- package/dist/api/shared/graphics-strategy.d.ts +29 -0
- package/dist/api/shared/graphics-strategy.js +11 -0
- package/dist/api/shared/hal-op-ir.d.ts +393 -0
- package/dist/api/shared/hal-op-ir.js +18 -0
- package/dist/api/shared/index.d.ts +26 -0
- package/dist/api/shared/index.js +21 -0
- package/dist/api/shared/ir-core.d.ts +363 -0
- package/dist/api/shared/ir-core.js +8 -0
- package/dist/api/shared/ir-declarations.d.ts +201 -0
- package/dist/api/shared/ir-declarations.js +26 -0
- package/dist/api/shared/ir.d.ts +85 -0
- package/dist/api/shared/ir.js +13 -0
- package/dist/api/shared/platform-strategy.d.ts +402 -0
- package/dist/api/shared/platform-strategy.js +14 -0
- package/dist/api/shared/polyfill-helper-registry.d.ts +11 -0
- package/dist/api/shared/polyfill-helper-registry.js +86 -0
- package/dist/api/shared/polyfill-types.d.ts +33 -0
- package/dist/api/shared/polyfill-types.js +76 -0
- package/dist/api/shared/promise-runtime.d.ts +10 -0
- package/dist/api/shared/promise-runtime.js +244 -0
- package/dist/api/shared/snprintf-types.d.ts +29 -0
- package/dist/api/shared/snprintf-types.js +8 -0
- package/dist/api/shared/string-method-registry.d.ts +53 -0
- package/dist/api/shared/string-method-registry.js +168 -0
- package/dist/api/shared/toolchain-types.d.ts +63 -0
- package/dist/api/shared/toolchain-types.js +71 -0
- package/dist/api/shared/types.d.ts +50 -0
- package/dist/api/shared/types.js +6 -0
- package/dist/ast/parse.d.ts +2 -0
- package/dist/ast/parse.js +4 -0
- package/dist/cache.d.ts +26 -0
- package/dist/cache.js +95 -0
- package/dist/cli-utils.d.ts +37 -0
- package/dist/cli-utils.js +250 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +635 -0
- package/dist/config-loader.d.ts +78 -0
- package/dist/config-loader.js +508 -0
- package/dist/config-schema.d.ts +233 -0
- package/dist/config-schema.js +83 -0
- package/dist/create/board-checklist.d.ts +2 -0
- package/dist/create/board-checklist.js +52 -0
- package/dist/create/board-codegen.d.ts +9 -0
- package/dist/create/board-codegen.js +238 -0
- package/dist/create/board-generators.d.ts +12 -0
- package/dist/create/board-generators.js +652 -0
- package/dist/create/board-spec.d.ts +640 -0
- package/dist/create/board-spec.js +215 -0
- package/dist/create/eslint-rules-template.d.ts +2 -0
- package/dist/create/eslint-rules-template.js +672 -0
- package/dist/create/index.d.ts +11 -0
- package/dist/create/index.js +8 -0
- package/dist/create/init-scaffold.d.ts +27 -0
- package/dist/create/init-scaffold.js +150 -0
- package/dist/create/init-templates.d.ts +24 -0
- package/dist/create/init-templates.js +379 -0
- package/dist/create/init-wizard.d.ts +8 -0
- package/dist/create/init-wizard.js +168 -0
- package/dist/debug/breakpoint-loader.d.ts +24 -0
- package/dist/debug/breakpoint-loader.js +137 -0
- package/dist/debug/index.d.ts +3 -0
- package/dist/debug/index.js +7 -0
- package/dist/debug/preprocessor.d.ts +9 -0
- package/dist/debug/preprocessor.js +214 -0
- package/dist/debug/types.d.ts +32 -0
- package/dist/debug/types.js +6 -0
- package/dist/diagnostics/diagnostics-report.d.ts +51 -0
- package/dist/diagnostics/diagnostics-report.js +333 -0
- package/dist/diagnostics/json-schema.d.ts +138 -0
- package/dist/diagnostics/json-schema.js +27 -0
- package/dist/diagnostics/md-writer.d.ts +10 -0
- package/dist/diagnostics/md-writer.js +336 -0
- package/dist/diagnostics/mermaid-builder.d.ts +65 -0
- package/dist/diagnostics/mermaid-builder.js +681 -0
- package/dist/emit/cpp-emitter.d.ts +6 -0
- package/dist/emit/cpp-emitter.js +48 -0
- package/dist/emit/emitters/class-emitter.d.ts +2 -0
- package/dist/emit/emitters/class-emitter.js +523 -0
- package/dist/emit/emitters/emitter-context.d.ts +174 -0
- package/dist/emit/emitters/emitter-context.js +1 -0
- package/dist/emit/emitters/entrypoint-synthesizer.d.ts +2 -0
- package/dist/emit/emitters/entrypoint-synthesizer.js +175 -0
- package/dist/emit/emitters/function-emitter-impl.d.ts +19 -0
- package/dist/emit/emitters/function-emitter-impl.js +428 -0
- package/dist/emit/emitters/line-appender.d.ts +15 -0
- package/dist/emit/emitters/line-appender.js +344 -0
- package/dist/emit/emitters/namespace-emitter.d.ts +2 -0
- package/dist/emit/emitters/namespace-emitter.js +324 -0
- package/dist/emit/emitters/output-finalizer.d.ts +4 -0
- package/dist/emit/emitters/output-finalizer.js +267 -0
- package/dist/emit/emitters/setup.d.ts +3 -0
- package/dist/emit/emitters/setup.js +851 -0
- package/dist/emit/emitters/top-level-prep.d.ts +2 -0
- package/dist/emit/emitters/top-level-prep.js +706 -0
- package/dist/emit/emitters/type-decl-emitter.d.ts +2 -0
- package/dist/emit/emitters/type-decl-emitter.js +251 -0
- package/dist/emit/emitters/ui-emitter.d.ts +21 -0
- package/dist/emit/emitters/ui-emitter.js +564 -0
- package/dist/emit/enum-emitter.d.ts +1 -0
- package/dist/emit/enum-emitter.js +1 -0
- package/dist/emit/expression-renderer.d.ts +283 -0
- package/dist/emit/expression-renderer.js +1477 -0
- package/dist/emit/native-helpers-emitter.d.ts +11 -0
- package/dist/emit/native-helpers-emitter.js +34 -0
- package/dist/emit/route-hal-op.d.ts +5 -0
- package/dist/emit/route-hal-op.js +13 -0
- package/dist/emit/snprintf-helpers.d.ts +17 -0
- package/dist/emit/snprintf-helpers.js +462 -0
- package/dist/emit/statement-renderer.d.ts +189 -0
- package/dist/emit/statement-renderer.js +948 -0
- package/dist/emit/utils/async-state-machine.d.ts +42 -0
- package/dist/emit/utils/async-state-machine.js +343 -0
- package/dist/emit/utils/comment-helpers.d.ts +20 -0
- package/dist/emit/utils/comment-helpers.js +31 -0
- package/dist/emit/utils/cpp-helpers.d.ts +47 -0
- package/dist/emit/utils/cpp-helpers.js +85 -0
- package/dist/emit/utils/include-resolver.d.ts +58 -0
- package/dist/emit/utils/include-resolver.js +155 -0
- package/dist/emit/utils/index.d.ts +8 -0
- package/dist/emit/utils/index.js +12 -0
- package/dist/emit/utils/type-inference.d.ts +159 -0
- package/dist/emit/utils/type-inference.js +559 -0
- package/dist/eslint-check.d.ts +10 -0
- package/dist/eslint-check.js +102 -0
- package/dist/framework-package.d.ts +10 -0
- package/dist/framework-package.js +58 -0
- package/dist/framework-registry.d.ts +39 -0
- package/dist/framework-registry.js +30 -0
- package/dist/incremental-cache.d.ts +116 -0
- package/dist/incremental-cache.js +335 -0
- package/dist/ir/adc-range-validation.d.ts +11 -0
- package/dist/ir/adc-range-validation.js +250 -0
- package/dist/ir/ast-node-utils.d.ts +8 -0
- package/dist/ir/ast-node-utils.js +32 -0
- package/dist/ir/board-pin-utils.d.ts +13 -0
- package/dist/ir/board-pin-utils.js +65 -0
- package/dist/ir/board-resolver.d.ts +36 -0
- package/dist/ir/board-resolver.js +437 -0
- package/dist/ir/build-ir-state.d.ts +167 -0
- package/dist/ir/build-ir-state.js +306 -0
- package/dist/ir/build-ir.d.ts +2 -0
- package/dist/ir/build-ir.js +808 -0
- package/dist/ir/call-graph.d.ts +35 -0
- package/dist/ir/call-graph.js +194 -0
- package/dist/ir/compile-time-only.d.ts +2 -0
- package/dist/ir/compile-time-only.js +16 -0
- package/dist/ir/declaration-builders.d.ts +9 -0
- package/dist/ir/declaration-builders.js +608 -0
- package/dist/ir/entry-points.d.ts +30 -0
- package/dist/ir/entry-points.js +191 -0
- package/dist/ir/expression-to-ir.d.ts +5 -0
- package/dist/ir/expression-to-ir.js +2249 -0
- package/dist/ir/extract-property-chain.d.ts +10 -0
- package/dist/ir/extract-property-chain.js +30 -0
- package/dist/ir/feature-prescan.d.ts +3 -0
- package/dist/ir/feature-prescan.js +43 -0
- package/dist/ir/feature-registry.d.ts +30 -0
- package/dist/ir/feature-registry.js +816 -0
- package/dist/ir/filter.d.ts +7 -0
- package/dist/ir/filter.js +85 -0
- package/dist/ir/function-builder.d.ts +19 -0
- package/dist/ir/function-builder.js +670 -0
- package/dist/ir/hal/hal-emitter.d.ts +62 -0
- package/dist/ir/hal/hal-emitter.js +735 -0
- package/dist/ir/hal/hal-parser.d.ts +61 -0
- package/dist/ir/hal/hal-parser.js +473 -0
- package/dist/ir/hal/hal-plugins.d.ts +34 -0
- package/dist/ir/hal/hal-plugins.js +706 -0
- package/dist/ir/hal-resolver.d.ts +5 -0
- package/dist/ir/hal-resolver.js +5 -0
- package/dist/ir/heap-analysis.d.ts +8 -0
- package/dist/ir/heap-analysis.js +350 -0
- package/dist/ir/heap-array-validation.d.ts +24 -0
- package/dist/ir/heap-array-validation.js +29 -0
- package/dist/ir/identifier-collector.d.ts +18 -0
- package/dist/ir/identifier-collector.js +439 -0
- package/dist/ir/interrupt-analysis.d.ts +39 -0
- package/dist/ir/interrupt-analysis.js +467 -0
- package/dist/ir/memory-budget-validation.d.ts +10 -0
- package/dist/ir/memory-budget-validation.js +86 -0
- package/dist/ir/namespace-builder.d.ts +7 -0
- package/dist/ir/namespace-builder.js +152 -0
- package/dist/ir/ownership-analysis.d.ts +9 -0
- package/dist/ir/ownership-analysis.js +1207 -0
- package/dist/ir/peripheral-ownership.d.ts +3 -0
- package/dist/ir/peripheral-ownership.js +152 -0
- package/dist/ir/peripheral-symbols.d.ts +7 -0
- package/dist/ir/peripheral-symbols.js +57 -0
- package/dist/ir/peripheral-usage.d.ts +54 -0
- package/dist/ir/peripheral-usage.js +691 -0
- package/dist/ir/peripheral-validation.d.ts +8 -0
- package/dist/ir/peripheral-validation.js +77 -0
- package/dist/ir/pin-alias-conflict.d.ts +4 -0
- package/dist/ir/pin-alias-conflict.js +34 -0
- package/dist/ir/pin-capability-validation.d.ts +6 -0
- package/dist/ir/pin-capability-validation.js +413 -0
- package/dist/ir/pin-mode-validation.d.ts +10 -0
- package/dist/ir/pin-mode-validation.js +301 -0
- package/dist/ir/pin-safety.d.ts +11 -0
- package/dist/ir/pin-safety.js +58 -0
- package/dist/ir/program-analysis.d.ts +44 -0
- package/dist/ir/program-analysis.js +589 -0
- package/dist/ir/pulldown-validation.d.ts +7 -0
- package/dist/ir/pulldown-validation.js +49 -0
- package/dist/ir/pwm-timer-sharing.d.ts +4 -0
- package/dist/ir/pwm-timer-sharing.js +93 -0
- package/dist/ir/reachability.d.ts +68 -0
- package/dist/ir/reachability.js +224 -0
- package/dist/ir/register-decorators.d.ts +6 -0
- package/dist/ir/register-decorators.js +49 -0
- package/dist/ir/render-expr.d.ts +4 -0
- package/dist/ir/render-expr.js +127 -0
- package/dist/ir/resource-analysis.d.ts +19 -0
- package/dist/ir/resource-analysis.js +153 -0
- package/dist/ir/statement-to-ir.d.ts +23 -0
- package/dist/ir/statement-to-ir.js +349 -0
- package/dist/ir/symbol-table.d.ts +68 -0
- package/dist/ir/symbol-table.js +179 -0
- package/dist/ir/symbol-types.d.ts +56 -0
- package/dist/ir/symbol-types.js +107 -0
- package/dist/ir/timer0-pwm-timing-conflict.d.ts +4 -0
- package/dist/ir/timer0-pwm-timing-conflict.js +71 -0
- package/dist/ir/timing-validation.d.ts +7 -0
- package/dist/ir/timing-validation.js +95 -0
- package/dist/ir/transformers/array-methods.d.ts +8 -0
- package/dist/ir/transformers/array-methods.js +493 -0
- package/dist/ir/transformers/call-statement.d.ts +5 -0
- package/dist/ir/transformers/call-statement.js +758 -0
- package/dist/ir/transformers/callback-context-registry.d.ts +20 -0
- package/dist/ir/transformers/callback-context-registry.js +55 -0
- package/dist/ir/transformers/canvas-lowering.d.ts +42 -0
- package/dist/ir/transformers/canvas-lowering.js +249 -0
- package/dist/ir/transformers/control-flow.d.ts +8 -0
- package/dist/ir/transformers/control-flow.js +508 -0
- package/dist/ir/transformers/expressions.d.ts +7 -0
- package/dist/ir/transformers/expressions.js +406 -0
- package/dist/ir/transformers/hal-call-resolver.d.ts +29 -0
- package/dist/ir/transformers/hal-call-resolver.js +274 -0
- package/dist/ir/transformers/hal-emit-helpers.d.ts +14 -0
- package/dist/ir/transformers/hal-emit-helpers.js +63 -0
- package/dist/ir/transformers/namespace-methods.d.ts +20 -0
- package/dist/ir/transformers/namespace-methods.js +110 -0
- package/dist/ir/transformers/register-assignment.d.ts +5 -0
- package/dist/ir/transformers/register-assignment.js +56 -0
- package/dist/ir/transformers/ui-call-resolver.d.ts +149 -0
- package/dist/ir/transformers/ui-call-resolver.js +1136 -0
- package/dist/ir/transformers/ui-callback-lowering.d.ts +62 -0
- package/dist/ir/transformers/ui-callback-lowering.js +623 -0
- package/dist/ir/transformers/ui-mount.d.ts +20 -0
- package/dist/ir/transformers/ui-mount.js +35 -0
- package/dist/ir/transformers/ui-reactive.d.ts +68 -0
- package/dist/ir/transformers/ui-reactive.js +129 -0
- package/dist/ir/transformers/variables.d.ts +14 -0
- package/dist/ir/transformers/variables.js +1045 -0
- package/dist/ir/try-catch-validation.d.ts +26 -0
- package/dist/ir/try-catch-validation.js +128 -0
- package/dist/ir/type-resolution.d.ts +31 -0
- package/dist/ir/type-resolution.js +977 -0
- package/dist/ir/ui-element-auto-wire.d.ts +50 -0
- package/dist/ir/ui-element-auto-wire.js +218 -0
- package/dist/ir/unit-suspicion-validation.d.ts +12 -0
- package/dist/ir/unit-suspicion-validation.js +296 -0
- package/dist/ir/utils/walk-ir.d.ts +6 -0
- package/dist/ir/utils/walk-ir.js +162 -0
- package/dist/ir/validation-orchestrator.d.ts +4 -0
- package/dist/ir/validation-orchestrator.js +45 -0
- package/dist/libdef/base-class-resolver.d.ts +23 -0
- package/dist/libdef/base-class-resolver.js +50 -0
- package/dist/libdef/cpp-to-decl.d.ts +34 -0
- package/dist/libdef/cpp-to-decl.js +584 -0
- package/dist/libdef/header-parser.d.ts +53 -0
- package/dist/libdef/header-parser.js +269 -0
- package/dist/libdef/registry.d.ts +10 -0
- package/dist/libdef/registry.js +142 -0
- package/dist/mapping/peripheral-names.d.ts +23 -0
- package/dist/mapping/peripheral-names.js +63 -0
- package/dist/mapping/source-map.d.ts +46 -0
- package/dist/mapping/source-map.js +207 -0
- package/dist/orchestrator/dts-generator.d.ts +17 -0
- package/dist/orchestrator/dts-generator.js +83 -0
- package/dist/orchestrator/graph-builder.d.ts +18 -0
- package/dist/orchestrator/graph-builder.js +218 -0
- package/dist/orchestrator/semantic-facts-verifier.d.ts +38 -0
- package/dist/orchestrator/semantic-facts-verifier.js +121 -0
- package/dist/orchestrator/semantic-facts.d.ts +141 -0
- package/dist/orchestrator/semantic-facts.js +652 -0
- package/dist/orchestrator/type-checker.d.ts +39 -0
- package/dist/orchestrator/type-checker.js +760 -0
- package/dist/platform/async-runtime.d.ts +8 -0
- package/dist/platform/async-runtime.js +26 -0
- package/dist/platform/generic-strategy.d.ts +101 -0
- package/dist/platform/generic-strategy.js +289 -0
- package/dist/platform/index.d.ts +4 -0
- package/dist/platform/index.js +9 -0
- package/dist/platform/registry.d.ts +21 -0
- package/dist/platform/registry.js +42 -0
- package/dist/platform/toolchain.d.ts +4 -0
- package/dist/platform/toolchain.js +43 -0
- package/dist/preview/client.d.ts +1 -0
- package/dist/preview/client.js +137 -0
- package/dist/preview/server.d.ts +5 -0
- package/dist/preview/server.js +199 -0
- package/dist/profiler/index.d.ts +28 -0
- package/dist/profiler/index.js +28 -0
- package/dist/profiler/profiler.d.ts +95 -0
- package/dist/profiler/profiler.js +338 -0
- package/dist/profiler/types.d.ts +87 -0
- package/dist/profiler/types.js +12 -0
- package/dist/stores/display-profile-store.d.ts +16 -0
- package/dist/stores/display-profile-store.js +48 -0
- package/dist/stores/theme-store.d.ts +13 -0
- package/dist/stores/theme-store.js +30 -0
- package/dist/testing.d.ts +45 -0
- package/dist/testing.js +47 -0
- package/dist/transpile/resolution.d.ts +29 -0
- package/dist/transpile/resolution.js +282 -0
- package/dist/transpile.d.ts +3 -0
- package/dist/transpile.js +722 -0
- package/dist/types.d.ts +217 -0
- package/dist/types.js +1 -0
- package/dist/ui/ui-bridge.d.ts +4 -0
- package/dist/ui/ui-bridge.js +34 -0
- package/dist/ui-hook.d.ts +84 -0
- package/dist/ui-hook.js +45 -0
- package/dist/utils/cli.d.ts +3 -0
- package/dist/utils/cli.js +463 -0
- package/dist/utils/fs.d.ts +4 -0
- package/dist/utils/fs.js +23 -0
- package/dist/utils/logger.d.ts +2 -0
- package/dist/utils/logger.js +8 -0
- package/dist/utils/strings.d.ts +35 -0
- package/dist/utils/strings.js +142 -0
- package/dist/utils/ui.d.ts +66 -0
- package/dist/utils/ui.js +149 -0
- package/dist/watch.d.ts +35 -0
- package/dist/watch.js +111 -0
- package/package.json +127 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// ST7796S display adapter — targets the Adafruit_ST7735_and_ST7789_Library
|
|
3
|
+
// fork that exposes the Adafruit_ST7796S class (320×480 SPI TFT).
|
|
4
|
+
//
|
|
5
|
+
// Color mode: RGB565 only. The Adafruit_ST7796S init sequence hardcodes
|
|
6
|
+
// ST77XX_COLMOD = 0x55 (16-bit/pixel). RGB666/18-bit would require patching
|
|
7
|
+
// the library's init array (0x55 → 0x66) AND overriding Adafruit_SPITFT's
|
|
8
|
+
// 565-native writePixels — out of scope for v1. Requesting rgb666 throws.
|
|
9
|
+
//
|
|
10
|
+
// Init API: Adafruit_ST7796S requires init(w,h,rowOff,colOff,colorOrder) to
|
|
11
|
+
// send the panel init sequence. begin(freq) alone would skip it (blank panel).
|
|
12
|
+
// SPI frequency handling: init() runs the panel command sequence and initializes
|
|
13
|
+
// Adafruit_SPITFT. If the profile requests a frequency, update the transaction
|
|
14
|
+
// settings with setSPISpeed() after init; do not call initSPI() a second time.
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
export const st7796Adapter = (display) => {
|
|
17
|
+
const cs = display._mountCs;
|
|
18
|
+
const dc = display._mountDc;
|
|
19
|
+
const rst = display._mountRst;
|
|
20
|
+
const rotation = display.rotation ?? 1;
|
|
21
|
+
const spiFreq = display.spiFrequency;
|
|
22
|
+
const invertDisplay = display.invertDisplay;
|
|
23
|
+
const colorOrder = display.colorOrder === "bgr" ? "ST7796S_BGR" : "ST7796S_RGB";
|
|
24
|
+
if (display.colorFormat === "rgb666" || display.colorFormat === "rgb888") {
|
|
25
|
+
throw new Error(`RGB666/RGB888 is not supported by the Adafruit_ST7796S library: ` +
|
|
26
|
+
`its init sequence hardcodes COLMOD=0x55 (RGB565). Use colorFormat: "rgb565". ` +
|
|
27
|
+
`True 18-bit support requires patching the library init array and overriding ` +
|
|
28
|
+
`Adafruit_SPITFT's 565-native writePixels — tracked as a follow-up.`);
|
|
29
|
+
}
|
|
30
|
+
const includes = [
|
|
31
|
+
"#define CuttlefishDisplayTarget Adafruit_GFX",
|
|
32
|
+
"#define CuttlefishCanvas16 GFXcanvas16",
|
|
33
|
+
"#include <Adafruit_GFX.h>",
|
|
34
|
+
"#include <Adafruit_ST7796S.h>",
|
|
35
|
+
].join("\n");
|
|
36
|
+
const inversionLines = invertDisplay === undefined
|
|
37
|
+
? []
|
|
38
|
+
: [
|
|
39
|
+
` __tc_display.startWrite();`,
|
|
40
|
+
` __tc_display.writeCommand(${invertDisplay ? "ST77XX_INVON" : "ST77XX_INVOFF"});`,
|
|
41
|
+
` __tc_display.endWrite();`,
|
|
42
|
+
];
|
|
43
|
+
return {
|
|
44
|
+
includes,
|
|
45
|
+
declaration: `Adafruit_ST7796S __tc_display = Adafruit_ST7796S(${cs}, ${dc}, ${rst});`,
|
|
46
|
+
functions: [
|
|
47
|
+
`// --- Display adapter: ST7796S (RGB565) ---`,
|
|
48
|
+
`static inline void display_init() {`,
|
|
49
|
+
` __tc_display.init(320, 480, 0, 0, ${colorOrder});`,
|
|
50
|
+
spiFreq ? ` __tc_display.setSPISpeed(${spiFreq});` : ``,
|
|
51
|
+
...inversionLines,
|
|
52
|
+
` __tc_display.setRotation(${rotation});`,
|
|
53
|
+
` __tc_display.fillScreen(0x0000);`,
|
|
54
|
+
`}`,
|
|
55
|
+
``,
|
|
56
|
+
`static inline void display_fillScreen(UI_COLOR_T color) { __tc_display.fillScreen((uint16_t)color); }`,
|
|
57
|
+
`static inline CuttlefishDisplayTarget* display_defaultTarget() { return &__tc_display; }`,
|
|
58
|
+
`static inline int16_t display_width() { return __tc_display.width(); }`,
|
|
59
|
+
`static inline int16_t display_height() { return __tc_display.height(); }`,
|
|
60
|
+
``,
|
|
61
|
+
`static inline void display_startWrite() { __tc_display.startWrite(); }`,
|
|
62
|
+
`static inline void display_endWrite() { __tc_display.endWrite(); }`,
|
|
63
|
+
`static inline void display_setAddrWindow(int16_t x, int16_t y, int16_t w, int16_t h) {`,
|
|
64
|
+
` __tc_display.setAddrWindow(x, y, w, h);`,
|
|
65
|
+
`}`,
|
|
66
|
+
`static inline void display_writePixels(uint16_t* pixels, uint32_t count) {`,
|
|
67
|
+
` __tc_display.writePixels(pixels, count);`,
|
|
68
|
+
`}`,
|
|
69
|
+
``,
|
|
70
|
+
`static inline CuttlefishCanvas16* display_createCanvas(int16_t w, int16_t h) {`,
|
|
71
|
+
` return new GFXcanvas16(w, h);`,
|
|
72
|
+
`}`,
|
|
73
|
+
`static inline CuttlefishCanvas16* display_createCanvasPsram(int16_t w, int16_t h) {`,
|
|
74
|
+
`#if defined(ESP32) && defined(BOARD_HAS_PSRAM)`,
|
|
75
|
+
` return new (ps_malloc(sizeof(GFXcanvas16))) GFXcanvas16(w, h);`,
|
|
76
|
+
`#else`,
|
|
77
|
+
` (void)w; (void)h;`,
|
|
78
|
+
` return nullptr;`,
|
|
79
|
+
`#endif`,
|
|
80
|
+
`}`,
|
|
81
|
+
`static inline void display_deleteCanvas(CuttlefishCanvas16* canvas) { delete canvas; }`,
|
|
82
|
+
`static inline int16_t display_canvasWidth(CuttlefishCanvas16* canvas) { return canvas->width(); }`,
|
|
83
|
+
`static inline int16_t display_canvasHeight(CuttlefishCanvas16* canvas) { return canvas->height(); }`,
|
|
84
|
+
`static inline uint16_t* display_canvasBuffer(CuttlefishCanvas16* canvas) { return canvas->getBuffer(); }`,
|
|
85
|
+
`static inline uint16_t display_canvasGetPixel(CuttlefishCanvas16* canvas, int16_t x, int16_t y) { return canvas->getPixel(x, y); }`,
|
|
86
|
+
`static inline void display_canvasFillScreen(CuttlefishCanvas16* canvas, UI_COLOR_T color) { canvas->fillScreen((uint16_t)color); }`,
|
|
87
|
+
`static inline void display_canvasFillRect(CuttlefishCanvas16* canvas, int16_t x, int16_t y, int16_t w, int16_t h, UI_COLOR_T color) {`,
|
|
88
|
+
` canvas->fillRect(x, y, w, h, (uint16_t)color);`,
|
|
89
|
+
`}`,
|
|
90
|
+
``,
|
|
91
|
+
`static inline void display_targetDrawPixel(CuttlefishDisplayTarget* target, int16_t x, int16_t y, UI_COLOR_T color) { target->drawPixel(x, y, (uint16_t)color); }`,
|
|
92
|
+
`static inline int16_t display_targetWidth(CuttlefishDisplayTarget* target) { return target->width(); }`,
|
|
93
|
+
`static inline int16_t display_targetHeight(CuttlefishDisplayTarget* target) { return target->height(); }`,
|
|
94
|
+
`static inline void display_targetDrawRGBBitmap(CuttlefishDisplayTarget* target, int16_t x, int16_t y, const uint16_t* bitmap, int16_t w, int16_t h) {`,
|
|
95
|
+
` target->drawRGBBitmap(x, y, bitmap, w, h);`,
|
|
96
|
+
`}`,
|
|
97
|
+
`static inline void display_targetFillRect(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t w, int16_t h, UI_COLOR_T color) {`,
|
|
98
|
+
` target->fillRect(x, y, w, h, (uint16_t)color);`,
|
|
99
|
+
`}`,
|
|
100
|
+
`static inline void display_targetDrawFastHLine(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t w, UI_COLOR_T color) {`,
|
|
101
|
+
` target->drawFastHLine(x, y, w, (uint16_t)color);`,
|
|
102
|
+
`}`,
|
|
103
|
+
`static inline void display_targetDrawFastVLine(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t h, UI_COLOR_T color) {`,
|
|
104
|
+
` target->drawFastVLine(x, y, h, (uint16_t)color);`,
|
|
105
|
+
`}`,
|
|
106
|
+
`static inline void display_targetFillRoundRect(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, UI_COLOR_T color) {`,
|
|
107
|
+
` target->fillRoundRect(x, y, w, h, r, (uint16_t)color);`,
|
|
108
|
+
`}`,
|
|
109
|
+
`static inline void display_targetDrawRect(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t w, int16_t h, UI_COLOR_T color) {`,
|
|
110
|
+
` target->drawRect(x, y, w, h, (uint16_t)color);`,
|
|
111
|
+
`}`,
|
|
112
|
+
`static inline void display_targetDrawRoundRect(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, UI_COLOR_T color) {`,
|
|
113
|
+
` target->drawRoundRect(x, y, w, h, r, (uint16_t)color);`,
|
|
114
|
+
`}`,
|
|
115
|
+
`static inline void display_targetDrawLine(CuttlefishDisplayTarget* target, int16_t x0, int16_t y0, int16_t x1, int16_t y1, UI_COLOR_T color) {`,
|
|
116
|
+
` target->drawLine(x0, y0, x1, y1, (uint16_t)color);`,
|
|
117
|
+
`}`,
|
|
118
|
+
`static inline void display_targetFillCircle(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t r, UI_COLOR_T color) {`,
|
|
119
|
+
` target->fillCircle(x, y, r, (uint16_t)color);`,
|
|
120
|
+
`}`,
|
|
121
|
+
`static inline void display_targetDrawCircle(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t r, UI_COLOR_T color) {`,
|
|
122
|
+
` target->drawCircle(x, y, r, (uint16_t)color);`,
|
|
123
|
+
`}`,
|
|
124
|
+
`static inline void display_targetSetCursor(CuttlefishDisplayTarget* target, int16_t x, int16_t y) { target->setCursor(x, y); }`,
|
|
125
|
+
`static inline void display_targetSetTextColor(CuttlefishDisplayTarget* target, UI_COLOR_T fg) { target->setTextColor((uint16_t)fg); }`,
|
|
126
|
+
`static inline void display_targetSetTextColorBg(CuttlefishDisplayTarget* target, UI_COLOR_T fg, UI_COLOR_T bg) { target->setTextColor((uint16_t)fg, (uint16_t)bg); }`,
|
|
127
|
+
`static inline void display_targetSetTextSize(CuttlefishDisplayTarget* target, uint8_t size) { target->setTextSize(size); }`,
|
|
128
|
+
`static inline void display_targetSetTextWrap(CuttlefishDisplayTarget* target, bool wrap) { target->setTextWrap(wrap); }`,
|
|
129
|
+
`static inline void display_targetPrint(CuttlefishDisplayTarget* target, const char* text) { target->print(text); }`,
|
|
130
|
+
].join("\n"),
|
|
131
|
+
};
|
|
132
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Native pixel format the panel stores / the shim quantizes to at push. */
|
|
2
|
+
export type NativeFormat = "rgb888" | "rgb666" | "rgb565" | "mono" | "palette";
|
|
3
|
+
/** How the panel accepts refreshed pixels. */
|
|
4
|
+
export type RefreshModel = "immediate" | "deferred-partial" | "deferred-full";
|
|
5
|
+
/** Scope of partial-refresh support (e-ink panels vary). */
|
|
6
|
+
export type PartialRefreshScope = "none" | "mono-only" | "full";
|
|
7
|
+
/** Feature flags the shim can honor. False ⇒ the core snaps/disables. */
|
|
8
|
+
export interface DisplayFeatureFlags {
|
|
9
|
+
antialias: boolean;
|
|
10
|
+
gradients: boolean;
|
|
11
|
+
opacityBlend: boolean;
|
|
12
|
+
smoothScroll: boolean;
|
|
13
|
+
animation: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface DisplayCapabilities {
|
|
16
|
+
nativeFormat: NativeFormat;
|
|
17
|
+
/** For palette displays (e-ink multi-color): the ink set as CSS strings. */
|
|
18
|
+
palette?: string[];
|
|
19
|
+
refreshModel: RefreshModel;
|
|
20
|
+
partialRefresh: PartialRefreshScope;
|
|
21
|
+
/** Latency (ms) of a full refresh; used by the refresh scheduler (Phase 4). */
|
|
22
|
+
fullRefreshMs?: number;
|
|
23
|
+
/** Max sustained partial refreshes/sec. */
|
|
24
|
+
maxPartialFps?: number;
|
|
25
|
+
/** Shim requires a backing store (e-ink, any dithered target). */
|
|
26
|
+
requiresBackingStore: boolean;
|
|
27
|
+
features: DisplayFeatureFlags;
|
|
28
|
+
}
|
|
29
|
+
/** The capabilities a fast RGB565 TFT has today — the Phase 2 default so
|
|
30
|
+
* output stays byte-identical with pre-descriptor behavior. */
|
|
31
|
+
export declare function defaultTftCapabilities(): DisplayCapabilities;
|
|
32
|
+
/** A minimal profile shape deriveCapabilities reads. Keeps it decoupled from
|
|
33
|
+
* the full DisplayProfile (which references this module). */
|
|
34
|
+
interface ProfileLike {
|
|
35
|
+
width: number;
|
|
36
|
+
height: number;
|
|
37
|
+
colorFormat: "rgb565" | "rgb666" | "rgb888" | "mono";
|
|
38
|
+
displayClass?: "tft" | "eink" | "oled";
|
|
39
|
+
capabilities?: DisplayCapabilities;
|
|
40
|
+
}
|
|
41
|
+
/** Derive capabilities from a profile. Explicit `capabilities` on the profile
|
|
42
|
+
* win; otherwise derive from `displayClass` + `colorFormat`. A bare TFT profile
|
|
43
|
+
* (no displayClass) defaults to defaultTftCapabilities() — byte-identical. */
|
|
44
|
+
export declare function deriveCapabilities(profile: ProfileLike): DisplayCapabilities;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// DisplayCapabilities — declarative description of a display's rendering
|
|
3
|
+
// capabilities. The single source of truth that @media evaluation, feature-flag
|
|
4
|
+
// consultation, and (in later phases) the display shim all read.
|
|
5
|
+
//
|
|
6
|
+
// Phase 2 introduces the type + derivation. Default = today's TFT behavior, so
|
|
7
|
+
// output is byte-identical. Phase 3+ consumes it for shim routing.
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
/** The capabilities a fast RGB565 TFT has today — the Phase 2 default so
|
|
10
|
+
* output stays byte-identical with pre-descriptor behavior. */
|
|
11
|
+
export function defaultTftCapabilities() {
|
|
12
|
+
return {
|
|
13
|
+
nativeFormat: "rgb565",
|
|
14
|
+
refreshModel: "immediate",
|
|
15
|
+
partialRefresh: "full",
|
|
16
|
+
requiresBackingStore: false,
|
|
17
|
+
features: {
|
|
18
|
+
antialias: true,
|
|
19
|
+
gradients: true,
|
|
20
|
+
opacityBlend: true,
|
|
21
|
+
smoothScroll: true,
|
|
22
|
+
animation: true,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** Derive capabilities from a profile. Explicit `capabilities` on the profile
|
|
27
|
+
* win; otherwise derive from `displayClass` + `colorFormat`. A bare TFT profile
|
|
28
|
+
* (no displayClass) defaults to defaultTftCapabilities() — byte-identical. */
|
|
29
|
+
export function deriveCapabilities(profile) {
|
|
30
|
+
if (profile.capabilities)
|
|
31
|
+
return profile.capabilities;
|
|
32
|
+
if (profile.displayClass === "eink" || profile.displayClass === "oled") {
|
|
33
|
+
return {
|
|
34
|
+
nativeFormat: profile.colorFormat === "mono" ? "mono" : "palette",
|
|
35
|
+
refreshModel: "deferred-partial",
|
|
36
|
+
partialRefresh: profile.colorFormat === "mono" ? "mono-only" : "none",
|
|
37
|
+
requiresBackingStore: true,
|
|
38
|
+
features: {
|
|
39
|
+
antialias: false,
|
|
40
|
+
gradients: false,
|
|
41
|
+
opacityBlend: false,
|
|
42
|
+
smoothScroll: false,
|
|
43
|
+
animation: false,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const base = defaultTftCapabilities();
|
|
48
|
+
// rgb888 TFT (e.g. the SDL native target) carries true 888 to the surface;
|
|
49
|
+
// all other TFT color formats are 565 by default (byte-identical history).
|
|
50
|
+
if (profile.colorFormat === "rgb888") {
|
|
51
|
+
base.nativeFormat = "rgb888";
|
|
52
|
+
}
|
|
53
|
+
return base;
|
|
54
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export interface DisplayInitOp {
|
|
2
|
+
operation: "display.init";
|
|
3
|
+
/** Bus identifier, e.g. "SPI" or "Wire" */
|
|
4
|
+
bus: string;
|
|
5
|
+
/** Chip-select pin number */
|
|
6
|
+
cs: number;
|
|
7
|
+
/** Data/Command pin number */
|
|
8
|
+
dc: number;
|
|
9
|
+
/** Reset pin number */
|
|
10
|
+
rst: number;
|
|
11
|
+
/** Panel width in pixels */
|
|
12
|
+
width: number;
|
|
13
|
+
/** Panel height in pixels */
|
|
14
|
+
height: number;
|
|
15
|
+
/** Driver id, e.g. "ili9341" — must be in supportedDisplayDrivers() */
|
|
16
|
+
driver: string;
|
|
17
|
+
/** Optional SPI clock frequency in Hz for SPI-backed displays. */
|
|
18
|
+
spiFrequency?: number;
|
|
19
|
+
/** I2C address (hex) for I2C-backed displays like SSD1309. */
|
|
20
|
+
address?: number;
|
|
21
|
+
/** Reset pin for I2C displays (separate from SPI rst). */
|
|
22
|
+
reset?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface DisplayFillRectOp {
|
|
25
|
+
operation: "display.fill_rect";
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
w: number;
|
|
29
|
+
h: number;
|
|
30
|
+
/** Pre-resolved color value (rgb565 uint16 on color targets, 0/1 on mono) */
|
|
31
|
+
color: number;
|
|
32
|
+
}
|
|
33
|
+
export interface DisplayDrawTextOp {
|
|
34
|
+
operation: "display.draw_text";
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
text: string;
|
|
38
|
+
/** Font id, e.g. "8x16" — resolved by the driver to a font table */
|
|
39
|
+
fontId: string;
|
|
40
|
+
/** Pre-resolved color value */
|
|
41
|
+
color: number;
|
|
42
|
+
}
|
|
43
|
+
export interface DisplayDrawRectOp {
|
|
44
|
+
operation: "display.draw_rect";
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
w: number;
|
|
48
|
+
h: number;
|
|
49
|
+
color: number;
|
|
50
|
+
}
|
|
51
|
+
export interface DisplayFlushOp {
|
|
52
|
+
operation: "display.flush";
|
|
53
|
+
/** Dirty rectangles to push to the panel this frame */
|
|
54
|
+
rects: Array<{
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
w: number;
|
|
58
|
+
h: number;
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
61
|
+
export type DisplayHALOp = DisplayInitOp | DisplayFillRectOp | DisplayDrawTextOp | DisplayDrawRectOp | DisplayFlushOp;
|
|
62
|
+
export declare const DISPLAY_OPERATION_KINDS: readonly ["display.init", "display.fill_rect", "display.draw_text", "display.draw_rect", "display.flush"];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Display HAL Operations — semantic graphics draw calls
|
|
3
|
+
//
|
|
4
|
+
// Each DisplayHALOp node represents a single display operation. Framework
|
|
5
|
+
// strategies (PlatformGraphicsStrategy.resolveDisplayOp) translate these into
|
|
6
|
+
// driver-specific C++ (ILI9341 SPI commands, SSD1306 I2C bitpacks, native
|
|
7
|
+
// terminal cells). Colors are pre-resolved at transpile time to the target's
|
|
8
|
+
// color format, so no runtime color conversion occurs.
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Runtime registry of every display operation discriminator. Lets tests verify
|
|
11
|
+
// union membership at runtime (type-only `import type` assertions are erased
|
|
12
|
+
// and pass vacuously). Keep in sync with DisplayHALOp above.
|
|
13
|
+
export const DISPLAY_OPERATION_KINDS = [
|
|
14
|
+
"display.init",
|
|
15
|
+
"display.fill_rect",
|
|
16
|
+
"display.draw_text",
|
|
17
|
+
"display.draw_rect",
|
|
18
|
+
"display.flush",
|
|
19
|
+
];
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import type { DisplayCapabilities } from "./display-capabilities.js";
|
|
2
|
+
export type TouchLibrary = "XPT2046_Touchscreen" | "Adafruit_TouchScreen" | "Adafruit_STMPE610" | "FT6336U" | "sdl";
|
|
3
|
+
export interface TouchProfile {
|
|
4
|
+
/**
|
|
5
|
+
* Either a built-in library name OR a path to a custom TypeScript adapter
|
|
6
|
+
* file (relative to the project root). The adapter must export:
|
|
7
|
+
* - isTouched(): boolean
|
|
8
|
+
* - read(): { x: number, y: number, z: number }
|
|
9
|
+
*
|
|
10
|
+
* Built-in: { library: 'XPT2046_Touchscreen', cs: 14, irq: 2 }
|
|
11
|
+
* Custom: { adapter: './my-touch-adapter' }
|
|
12
|
+
*/
|
|
13
|
+
library?: TouchLibrary;
|
|
14
|
+
adapter?: string;
|
|
15
|
+
/** CS pin for SPI touch controllers (separate from display CS). */
|
|
16
|
+
cs?: number;
|
|
17
|
+
/** IRQ pin (optional). */
|
|
18
|
+
irq?: number;
|
|
19
|
+
/** Resistive 4-wire analog pins (Adafruit_TouchScreen only). */
|
|
20
|
+
analogPins?: {
|
|
21
|
+
xp: number;
|
|
22
|
+
yp: number;
|
|
23
|
+
xm: number;
|
|
24
|
+
ym: number;
|
|
25
|
+
rx: number;
|
|
26
|
+
};
|
|
27
|
+
/** Software SPI pins (optional). */
|
|
28
|
+
swSpiPins?: {
|
|
29
|
+
mosi: number;
|
|
30
|
+
miso: number;
|
|
31
|
+
sck: number;
|
|
32
|
+
};
|
|
33
|
+
/** I2C address for I2C touch controllers (FT6336U default 0x38). */
|
|
34
|
+
i2cAddress?: number;
|
|
35
|
+
/** I2C bus speed in Hz for I2C touch controllers. */
|
|
36
|
+
i2cFrequency?: number;
|
|
37
|
+
/** Reset pin for touch controllers requiring a hardware-reset sequence
|
|
38
|
+
* before begin() (FT6336U on boards with a reset GPIO tied to the chip). */
|
|
39
|
+
resetPin?: number;
|
|
40
|
+
/** Raw ADC calibration — maps touch controller raw values to display pixels. */
|
|
41
|
+
calibration: {
|
|
42
|
+
xMin: number;
|
|
43
|
+
xMax: number;
|
|
44
|
+
yMin: number;
|
|
45
|
+
yMax: number;
|
|
46
|
+
};
|
|
47
|
+
/** Minimum pressure/z to register a touch (default 10). */
|
|
48
|
+
minPressure?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface DisplayProfile {
|
|
51
|
+
driver: string;
|
|
52
|
+
/** Visible screen-space dimensions used by UI layout and preview. */
|
|
53
|
+
width: number;
|
|
54
|
+
height: number;
|
|
55
|
+
/** Native panel dimensions before rotation, when they differ from layout size. */
|
|
56
|
+
nativeWidth?: number;
|
|
57
|
+
nativeHeight?: number;
|
|
58
|
+
colorFormat: "rgb565" | "rgb666" | "rgb888" | "mono";
|
|
59
|
+
/** Display class: "tft" (default) for fast-refresh panels, "eink" for
|
|
60
|
+
* bistable/slow-refresh panels. Drives capability derivation + @media. */
|
|
61
|
+
displayClass?: "tft" | "eink" | "oled";
|
|
62
|
+
/** Explicit capabilities override. If absent, capabilities are derived from
|
|
63
|
+
* displayClass + colorFormat. Phase 2 default (bare TFT) = today's behavior. */
|
|
64
|
+
capabilities?: DisplayCapabilities;
|
|
65
|
+
rotation: number;
|
|
66
|
+
backlight?: number;
|
|
67
|
+
spiFrequency?: number;
|
|
68
|
+
spiPins?: {
|
|
69
|
+
mosi: number;
|
|
70
|
+
sck: number;
|
|
71
|
+
miso: number;
|
|
72
|
+
};
|
|
73
|
+
/** Pixel color channel order expected by the panel module. Default: rgb. */
|
|
74
|
+
colorOrder?: "rgb" | "bgr";
|
|
75
|
+
/** Optional explicit display inversion override. Some controller libraries
|
|
76
|
+
* use panel-specific defaults that do not match every module. */
|
|
77
|
+
invertDisplay?: boolean;
|
|
78
|
+
touch?: TouchProfile;
|
|
79
|
+
/** Enable antialiased rendering for circles, lines, rounded corners, and text
|
|
80
|
+
* unless a node opts out with font-smoothing:none.
|
|
81
|
+
* Renders AA work to offscreen GFXcanvas16 buffers, blends edges, then draws. */
|
|
82
|
+
antialias?: boolean;
|
|
83
|
+
/** SDL desktop target only: render the window borderless at the current
|
|
84
|
+
* desktop resolution, scaling the fixed framebuffer to fill the monitor.
|
|
85
|
+
* true (or "desktop") = `SDL_WINDOW_FULLSCREEN_DESKTOP`. Ignored by hardware
|
|
86
|
+
* targets. Default: off (a normal titled window at width × height). */
|
|
87
|
+
fullscreen?: boolean | "desktop";
|
|
88
|
+
/** SDL desktop target only: the OS window title. Default "cuttlefish".
|
|
89
|
+
* Overridable at runtime via ui.window.setTitle(). Ignored by hardware. */
|
|
90
|
+
title?: string;
|
|
91
|
+
/** SDL desktop target only: window/taskbar icon image file path (BMP via
|
|
92
|
+
* core SDL2; .png/.ico require SDL_image). Ignored by hardware. */
|
|
93
|
+
icon?: string;
|
|
94
|
+
/** Scroll engine capability + physics tunables. Defaults are derived from the
|
|
95
|
+
* declared touch hardware when omitted (see resolveScrollConfig). */
|
|
96
|
+
scroll?: ScrollConfig;
|
|
97
|
+
}
|
|
98
|
+
/** Extended profile with mount wiring (cs/dc/rst/address/reset from ui.mount).
|
|
99
|
+
* Lives here (not in the store) so api/shared has zero upward dependencies
|
|
100
|
+
* on ui/. The store populates it; display-adapter.ts types against it. */
|
|
101
|
+
export interface ResolvedDisplay extends DisplayProfile {
|
|
102
|
+
_mountCs: number;
|
|
103
|
+
_mountDc: number;
|
|
104
|
+
_mountRst: number;
|
|
105
|
+
_mountBus: string;
|
|
106
|
+
_mountAddress: number;
|
|
107
|
+
_mountReset: number;
|
|
108
|
+
/** Arduino FQBN (e.g. "esp32:esp32:esp32s3:PSRAM=opi"), used to derive PSRAM
|
|
109
|
+
* availability for the scroll-canvas-memory budget. Optional. */
|
|
110
|
+
_buildTarget?: string;
|
|
111
|
+
}
|
|
112
|
+
export interface DisplayConfig {
|
|
113
|
+
profile?: string;
|
|
114
|
+
driver?: string;
|
|
115
|
+
/** Visible screen-space dimensions used by UI layout and preview. */
|
|
116
|
+
width?: number;
|
|
117
|
+
height?: number;
|
|
118
|
+
/** Native panel dimensions before rotation, when they differ from layout size. */
|
|
119
|
+
nativeWidth?: number;
|
|
120
|
+
nativeHeight?: number;
|
|
121
|
+
colorFormat?: "rgb565" | "rgb888" | "mono";
|
|
122
|
+
displayClass?: "tft" | "eink" | "oled";
|
|
123
|
+
capabilities?: DisplayCapabilities;
|
|
124
|
+
rotation?: number;
|
|
125
|
+
backlight?: number;
|
|
126
|
+
spiFrequency?: number;
|
|
127
|
+
spiPins?: {
|
|
128
|
+
mosi: number;
|
|
129
|
+
sck: number;
|
|
130
|
+
miso: number;
|
|
131
|
+
};
|
|
132
|
+
/** Pixel color channel order expected by the panel module. Default: rgb. */
|
|
133
|
+
colorOrder?: "rgb" | "bgr";
|
|
134
|
+
/** Optional explicit display inversion override. */
|
|
135
|
+
invertDisplay?: boolean;
|
|
136
|
+
touch?: TouchProfile | false;
|
|
137
|
+
cs?: number;
|
|
138
|
+
dc?: number;
|
|
139
|
+
rst?: number;
|
|
140
|
+
bus?: string;
|
|
141
|
+
/** I2C address (hex, e.g. 0x3C). Used by I2C display drivers like SSD1309. */
|
|
142
|
+
address?: number;
|
|
143
|
+
/** Reset pin for I2C displays (separate from SPI `rst`). */
|
|
144
|
+
reset?: number;
|
|
145
|
+
antialias?: boolean;
|
|
146
|
+
/** SDL desktop target only: render the window borderless at the current
|
|
147
|
+
* desktop resolution, scaling the fixed framebuffer to fill the monitor.
|
|
148
|
+
* Ignored by hardware targets. Default: off. */
|
|
149
|
+
fullscreen?: boolean | "desktop";
|
|
150
|
+
/** SDL desktop target only: the OS window title. Default "cuttlefish". */
|
|
151
|
+
title?: string;
|
|
152
|
+
/** SDL desktop target only: window/taskbar icon image file path (BMP). */
|
|
153
|
+
icon?: string;
|
|
154
|
+
/** Override the CSS theme file. Relative paths resolve from the .ui.html
|
|
155
|
+
* directory; absolute paths are used as-is. Default: sibling .ui.css. */
|
|
156
|
+
themeCss?: string;
|
|
157
|
+
/** Activate a class-scoped theme for CSS variables (e.g. "dark"). When set,
|
|
158
|
+
* var() substitution prefers variables defined under `.dark { ... }` over
|
|
159
|
+
* :root. One theme per build (transpile-time selection). */
|
|
160
|
+
themeClass?: string;
|
|
161
|
+
/** Scroll engine capability + physics tunables. Defaults are derived from the
|
|
162
|
+
* declared touch hardware when omitted (see resolveScrollConfig). */
|
|
163
|
+
scroll?: ScrollConfig;
|
|
164
|
+
}
|
|
165
|
+
export interface DisplaySize {
|
|
166
|
+
width: number;
|
|
167
|
+
height: number;
|
|
168
|
+
}
|
|
169
|
+
export declare function normalizeDisplayRotation(rotation?: number): 0 | 1 | 2 | 3;
|
|
170
|
+
/** Return the screen-space dimensions after the display rotation is applied. */
|
|
171
|
+
export declare function effectiveDisplaySize(display: {
|
|
172
|
+
width: number;
|
|
173
|
+
height: number;
|
|
174
|
+
nativeWidth?: number;
|
|
175
|
+
nativeHeight?: number;
|
|
176
|
+
rotation?: number;
|
|
177
|
+
}): DisplaySize;
|
|
178
|
+
/** Input-quality axis: how raw touch becomes a smoothed scroll delta. */
|
|
179
|
+
export type ScrollInputTier = "capacitive" | "resistive" | "none";
|
|
180
|
+
/** Frame/refresh-budget axis: whether per-frame canvas repaint (incl. the
|
|
181
|
+
* rubber-band animation) is affordable. Constrained tiers get a cheaper path. */
|
|
182
|
+
export type ScrollRenderTier = "full" | "constrained";
|
|
183
|
+
/** Author-facing scroll config (all optional; defaults derived from hardware). */
|
|
184
|
+
export interface ScrollConfig {
|
|
185
|
+
inputTier?: ScrollInputTier;
|
|
186
|
+
renderTier?: ScrollRenderTier;
|
|
187
|
+
/** Multiplier applied to drag deltas before scroll physics. Default 1.0. */
|
|
188
|
+
dragScale?: number;
|
|
189
|
+
/** Ceiling on rubber-band excursion past a boundary, in px. Default 40. */
|
|
190
|
+
maxOverscroll?: number;
|
|
191
|
+
/** Rubber-band resistance curve (higher = stiffer, less stretch). Default 0.5. */
|
|
192
|
+
stiffness?: number;
|
|
193
|
+
/** Radius within which release snaps to a boundary for free, in px. Default 12. */
|
|
194
|
+
edgeSnapPx?: number;
|
|
195
|
+
/** Low-pass coefficient for the resistive input filter (0 = passthrough).
|
|
196
|
+
* Capacitive/preview always passthrough regardless. Default 0.3. */
|
|
197
|
+
inputSmoothing?: number;
|
|
198
|
+
/** default true: trust the declared tiers (deterministic). When false, runtime
|
|
199
|
+
* probes may refine the input smoothing level from observed sample quality. */
|
|
200
|
+
overrideProbes?: boolean;
|
|
201
|
+
/** Emit per-frame scroll/canvas telemetry over Serial (UI_SCROLL_DEBUG). Off by
|
|
202
|
+
* default — enable temporarily to diagnose scroll/canvas draw skips on-device. */
|
|
203
|
+
debug?: boolean;
|
|
204
|
+
/** Max RGB565 scroll viewport canvas size (w×h×2 bytes) assumed to fit in heap
|
|
205
|
+
* for Mode B smooth scrolling on the target. Default ~88 KB (ESP32 no PSRAM). */
|
|
206
|
+
scrollCanvasBudgetBytes?: number;
|
|
207
|
+
}
|
|
208
|
+
/** Fully-resolved scroll config — every field populated, ready for emit. */
|
|
209
|
+
export interface ResolvedScrollConfig {
|
|
210
|
+
inputTier: ScrollInputTier;
|
|
211
|
+
renderTier: ScrollRenderTier;
|
|
212
|
+
dragScale: number;
|
|
213
|
+
maxOverscroll: number;
|
|
214
|
+
stiffness: number;
|
|
215
|
+
edgeSnapPx: number;
|
|
216
|
+
inputSmoothing: number;
|
|
217
|
+
overrideProbes: boolean;
|
|
218
|
+
debug: boolean;
|
|
219
|
+
scrollCanvasBudgetBytes: number;
|
|
220
|
+
}
|
|
221
|
+
/** Default RGB565 scroll viewport canvas budget (~88 KB, ESP32-class SRAM). */
|
|
222
|
+
export declare const DEFAULT_SCROLL_CANVAS_BUDGET_BYTES = 88000;
|
|
223
|
+
/** PSRAM scroll canvas budget (~2 MB). ESP32-S3 with OPI/QSPI PSRAM exposes
|
|
224
|
+
* ~8 MB external RAM; a full-width scroll viewport canvas (e.g. 460×266×2 ≈
|
|
225
|
+
* 239 KB) is trivial there, so the transpile-time scroll-canvas-memory
|
|
226
|
+
* diagnostic should use a PSRAM-appropriate budget rather than the no-PSRAM
|
|
227
|
+
* SRAM default — otherwise every PSRAM target emits stale "exceeds budget"
|
|
228
|
+
* warnings for canvases the runtime allocates without issue. */
|
|
229
|
+
export declare const PSRAM_SCROLL_CANVAS_BUDGET_BYTES = 2000000;
|
|
230
|
+
/** Detect PSRAM from an Arduino FQBN buildTarget (e.g. "esp32:esp32:esp32s3:PSRAM=opi").
|
|
231
|
+
* Returns true for any PSRAM=<value> option whose value indicates PSRAM is
|
|
232
|
+
* enabled (opi, io, qspi, enabled, true). Returns false when absent or set
|
|
233
|
+
* to a disabled-looking value (disabled, false, none). */
|
|
234
|
+
export declare function buildTargetHasPsram(buildTarget: string | undefined): boolean;
|
|
235
|
+
/**
|
|
236
|
+
* Resolve scroll config from a display profile. Declared overrides win;
|
|
237
|
+
* otherwise derive the input tier from the touch library (resistive chips →
|
|
238
|
+
* "resistive", any other touch → "capacitive", no touch → "none") and assume a
|
|
239
|
+
* full render tier (ESP32-class SRAM can fit a viewport canvas).
|
|
240
|
+
*/
|
|
241
|
+
export declare function resolveScrollConfig(display: {
|
|
242
|
+
touch?: TouchProfile | false;
|
|
243
|
+
scroll?: ScrollConfig;
|
|
244
|
+
}, ctx?: {
|
|
245
|
+
buildTarget?: string;
|
|
246
|
+
}): ResolvedScrollConfig;
|
|
247
|
+
export declare function resolveDisplayProfile(config: DisplayConfig, registry: Map<string, DisplayProfile>): {
|
|
248
|
+
profile: DisplayProfile;
|
|
249
|
+
cs: number;
|
|
250
|
+
dc: number;
|
|
251
|
+
rst: number;
|
|
252
|
+
bus: string;
|
|
253
|
+
address: number;
|
|
254
|
+
reset: number;
|
|
255
|
+
};
|
|
256
|
+
export interface TouchAdapterCodegen {
|
|
257
|
+
/** C++ #include lines for the touch library. */
|
|
258
|
+
includes: string[];
|
|
259
|
+
/** C++ declaration(s) for the touch object (file scope). */
|
|
260
|
+
declaration: string;
|
|
261
|
+
/** C++ static inline shim functions: touch_init, touch_isTouched, touch_readRaw. */
|
|
262
|
+
functions: string;
|
|
263
|
+
}
|
|
264
|
+
/** Generate C++ code for a built-in touch library adapter. */
|
|
265
|
+
export declare function generateTouchAdapter(touch: TouchProfile): TouchAdapterCodegen;
|