@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,338 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// DisplayProfile — declarative description of a display's capabilities.
|
|
3
|
+
//
|
|
4
|
+
// Lives in the project config (cuttlefish.config.ts) or in built-in framework
|
|
5
|
+
// profiles. Describes everything the transpiler needs to know about the
|
|
6
|
+
// display hardware: dimensions, color depth, rotation, pins, touch.
|
|
7
|
+
//
|
|
8
|
+
// Adding a new display = adding a profile. No framework code changes.
|
|
9
|
+
export function normalizeDisplayRotation(rotation) {
|
|
10
|
+
const r = ((rotation ?? 0) % 4 + 4) % 4;
|
|
11
|
+
return r;
|
|
12
|
+
}
|
|
13
|
+
/** Return the screen-space dimensions after the display rotation is applied. */
|
|
14
|
+
export function effectiveDisplaySize(display) {
|
|
15
|
+
if (display.nativeWidth === undefined || display.nativeHeight === undefined) {
|
|
16
|
+
return { width: display.width, height: display.height };
|
|
17
|
+
}
|
|
18
|
+
const rotation = normalizeDisplayRotation(display.rotation);
|
|
19
|
+
return rotation === 1 || rotation === 3
|
|
20
|
+
? { width: display.nativeHeight, height: display.nativeWidth }
|
|
21
|
+
: { width: display.nativeWidth, height: display.nativeHeight };
|
|
22
|
+
}
|
|
23
|
+
/** Touch libraries treated as resistive (noisy, low-sample-rate) panels. */
|
|
24
|
+
const RESISTIVE_TOUCH_LIBS = new Set([
|
|
25
|
+
"XPT2046_Touchscreen",
|
|
26
|
+
"Adafruit_TouchScreen",
|
|
27
|
+
]);
|
|
28
|
+
/** Default RGB565 scroll viewport canvas budget (~88 KB, ESP32-class SRAM). */
|
|
29
|
+
export const DEFAULT_SCROLL_CANVAS_BUDGET_BYTES = 88000;
|
|
30
|
+
/** PSRAM scroll canvas budget (~2 MB). ESP32-S3 with OPI/QSPI PSRAM exposes
|
|
31
|
+
* ~8 MB external RAM; a full-width scroll viewport canvas (e.g. 460×266×2 ≈
|
|
32
|
+
* 239 KB) is trivial there, so the transpile-time scroll-canvas-memory
|
|
33
|
+
* diagnostic should use a PSRAM-appropriate budget rather than the no-PSRAM
|
|
34
|
+
* SRAM default — otherwise every PSRAM target emits stale "exceeds budget"
|
|
35
|
+
* warnings for canvases the runtime allocates without issue. */
|
|
36
|
+
export const PSRAM_SCROLL_CANVAS_BUDGET_BYTES = 2_000_000;
|
|
37
|
+
/** Detect PSRAM from an Arduino FQBN buildTarget (e.g. "esp32:esp32:esp32s3:PSRAM=opi").
|
|
38
|
+
* Returns true for any PSRAM=<value> option whose value indicates PSRAM is
|
|
39
|
+
* enabled (opi, io, qspi, enabled, true). Returns false when absent or set
|
|
40
|
+
* to a disabled-looking value (disabled, false, none). */
|
|
41
|
+
export function buildTargetHasPsram(buildTarget) {
|
|
42
|
+
if (!buildTarget)
|
|
43
|
+
return false;
|
|
44
|
+
const opts = buildTarget.split(":");
|
|
45
|
+
for (const opt of opts) {
|
|
46
|
+
const eq = opt.indexOf("=");
|
|
47
|
+
if (eq < 0)
|
|
48
|
+
continue;
|
|
49
|
+
const key = opt.slice(0, eq).trim().toLowerCase();
|
|
50
|
+
const val = opt.slice(eq + 1).trim().toLowerCase();
|
|
51
|
+
if (key !== "psram")
|
|
52
|
+
continue;
|
|
53
|
+
// Any explicit PSRAM option except an explicit disabled value means PSRAM.
|
|
54
|
+
return !["disabled", "false", "none", "no", "0"].includes(val);
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Resolve scroll config from a display profile. Declared overrides win;
|
|
60
|
+
* otherwise derive the input tier from the touch library (resistive chips →
|
|
61
|
+
* "resistive", any other touch → "capacitive", no touch → "none") and assume a
|
|
62
|
+
* full render tier (ESP32-class SRAM can fit a viewport canvas).
|
|
63
|
+
*/
|
|
64
|
+
export function resolveScrollConfig(display, ctx) {
|
|
65
|
+
const s = display.scroll ?? {};
|
|
66
|
+
const lib = display.touch && typeof display.touch === "object"
|
|
67
|
+
? display.touch.library
|
|
68
|
+
: undefined;
|
|
69
|
+
const derivedInput = lib && RESISTIVE_TOUCH_LIBS.has(lib)
|
|
70
|
+
? "resistive"
|
|
71
|
+
: display.touch
|
|
72
|
+
? "capacitive"
|
|
73
|
+
: "none";
|
|
74
|
+
// PSRAM-aware canvas budget: an explicit override always wins; otherwise use
|
|
75
|
+
// the PSRAM budget when the build target opts into PSRAM (so the scroll-canvas-
|
|
76
|
+
// memory diagnostic doesn't emit stale warnings for canvases the runtime
|
|
77
|
+
// allocates in external RAM without issue), else the no-PSRAM SRAM default.
|
|
78
|
+
const psramBudget = buildTargetHasPsram(ctx?.buildTarget);
|
|
79
|
+
const budgetDefault = psramBudget
|
|
80
|
+
? PSRAM_SCROLL_CANVAS_BUDGET_BYTES
|
|
81
|
+
: DEFAULT_SCROLL_CANVAS_BUDGET_BYTES;
|
|
82
|
+
return {
|
|
83
|
+
inputTier: s.inputTier ?? derivedInput,
|
|
84
|
+
renderTier: s.renderTier ?? "full",
|
|
85
|
+
dragScale: s.dragScale ?? 1,
|
|
86
|
+
maxOverscroll: s.maxOverscroll ?? 40,
|
|
87
|
+
stiffness: s.stiffness ?? 0.5,
|
|
88
|
+
edgeSnapPx: s.edgeSnapPx ?? 12,
|
|
89
|
+
inputSmoothing: s.inputSmoothing ?? 0.3,
|
|
90
|
+
overrideProbes: s.overrideProbes ?? true,
|
|
91
|
+
debug: s.debug ?? false,
|
|
92
|
+
scrollCanvasBudgetBytes: s.scrollCanvasBudgetBytes ?? budgetDefault,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export function resolveDisplayProfile(config, registry) {
|
|
96
|
+
let base;
|
|
97
|
+
if (config.profile) {
|
|
98
|
+
const found = registry.get(config.profile);
|
|
99
|
+
if (!found) {
|
|
100
|
+
throw new Error(`Unknown display profile "${config.profile}". Available: ${[...registry.keys()].join(", ") || "(none)"}`);
|
|
101
|
+
}
|
|
102
|
+
base = { ...found };
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
base = {
|
|
106
|
+
driver: config.driver ?? "ili9341",
|
|
107
|
+
width: config.width ?? 320,
|
|
108
|
+
height: config.height ?? 240,
|
|
109
|
+
nativeWidth: config.nativeWidth,
|
|
110
|
+
nativeHeight: config.nativeHeight,
|
|
111
|
+
// The SDL adapter renders to a 32-bit desktop framebuffer and is
|
|
112
|
+
// RGB888-only (uint32_t throughout). The generic default is rgb565
|
|
113
|
+
// (byte-identical to bare TFT hardware), but a desktop window has no
|
|
114
|
+
// 565 surface — default SDL to rgb888 so UI_COLOR_T matches the adapter
|
|
115
|
+
// and colors reach the window at full 24-bit precision.
|
|
116
|
+
colorFormat: config.colorFormat ?? (config.driver === "sdl" ? "rgb888" : "rgb565"),
|
|
117
|
+
rotation: config.rotation ?? 1,
|
|
118
|
+
backlight: config.backlight,
|
|
119
|
+
spiFrequency: config.spiFrequency,
|
|
120
|
+
spiPins: config.spiPins,
|
|
121
|
+
colorOrder: config.colorOrder,
|
|
122
|
+
invertDisplay: config.invertDisplay,
|
|
123
|
+
touch: config.touch === false ? undefined : config.touch,
|
|
124
|
+
displayClass: config.displayClass,
|
|
125
|
+
capabilities: config.capabilities,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (config.width !== undefined)
|
|
129
|
+
base.width = config.width;
|
|
130
|
+
if (config.height !== undefined)
|
|
131
|
+
base.height = config.height;
|
|
132
|
+
if (config.nativeWidth !== undefined)
|
|
133
|
+
base.nativeWidth = config.nativeWidth;
|
|
134
|
+
if (config.nativeHeight !== undefined)
|
|
135
|
+
base.nativeHeight = config.nativeHeight;
|
|
136
|
+
if (config.colorFormat !== undefined)
|
|
137
|
+
base.colorFormat = config.colorFormat;
|
|
138
|
+
if (config.displayClass !== undefined)
|
|
139
|
+
base.displayClass = config.displayClass;
|
|
140
|
+
if (config.capabilities !== undefined)
|
|
141
|
+
base.capabilities = config.capabilities;
|
|
142
|
+
if (config.rotation !== undefined)
|
|
143
|
+
base.rotation = config.rotation;
|
|
144
|
+
if (config.backlight !== undefined)
|
|
145
|
+
base.backlight = config.backlight;
|
|
146
|
+
if (config.spiFrequency !== undefined)
|
|
147
|
+
base.spiFrequency = config.spiFrequency;
|
|
148
|
+
if (config.spiPins !== undefined)
|
|
149
|
+
base.spiPins = config.spiPins;
|
|
150
|
+
if (config.colorOrder !== undefined)
|
|
151
|
+
base.colorOrder = config.colorOrder;
|
|
152
|
+
if (config.invertDisplay !== undefined)
|
|
153
|
+
base.invertDisplay = config.invertDisplay;
|
|
154
|
+
if (config.touch === false)
|
|
155
|
+
base.touch = undefined;
|
|
156
|
+
else if (config.touch !== undefined)
|
|
157
|
+
base.touch = config.touch;
|
|
158
|
+
if (config.antialias !== undefined)
|
|
159
|
+
base.antialias = config.antialias;
|
|
160
|
+
if (config.fullscreen !== undefined)
|
|
161
|
+
base.fullscreen = config.fullscreen;
|
|
162
|
+
if (config.title !== undefined)
|
|
163
|
+
base.title = config.title;
|
|
164
|
+
if (config.icon !== undefined)
|
|
165
|
+
base.icon = config.icon;
|
|
166
|
+
// Carry scroll config through resolution so it reaches getDisplayProfile().
|
|
167
|
+
if (config.scroll !== undefined)
|
|
168
|
+
base.scroll = config.scroll;
|
|
169
|
+
return {
|
|
170
|
+
profile: base,
|
|
171
|
+
cs: config.cs ?? 5,
|
|
172
|
+
dc: config.dc ?? 21,
|
|
173
|
+
rst: config.rst ?? 22,
|
|
174
|
+
bus: config.bus ?? "SPI",
|
|
175
|
+
address: config.address ?? 0x3C,
|
|
176
|
+
reset: config.reset ?? -1,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/** Generate C++ code for a built-in touch library adapter. */
|
|
180
|
+
export function generateTouchAdapter(touch) {
|
|
181
|
+
const cs = touch.cs ?? 0;
|
|
182
|
+
const irq = touch.irq;
|
|
183
|
+
if (touch.library === "XPT2046_Touchscreen") {
|
|
184
|
+
return {
|
|
185
|
+
includes: ["#include <XPT2046_Touchscreen.h>"],
|
|
186
|
+
declaration: `XPT2046_Touchscreen __tc_touch(${cs}${irq ? `, ${irq}` : ""});`,
|
|
187
|
+
functions: [
|
|
188
|
+
`static inline void touch_init() { __tc_touch.begin(); }`,
|
|
189
|
+
`static inline bool touch_isTouched() { return __tc_touch.touched(); }`,
|
|
190
|
+
`static inline void touch_readRaw(int16_t* x, int16_t* y, int16_t* z) {`,
|
|
191
|
+
` TS_Point __tp = __tc_touch.getPoint();`,
|
|
192
|
+
` if (x) *x = (int16_t)__tp.x;`,
|
|
193
|
+
` if (y) *y = (int16_t)__tp.y;`,
|
|
194
|
+
` if (z) *z = (int16_t)__tp.z;`,
|
|
195
|
+
`}`,
|
|
196
|
+
].join("\n"),
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
if (touch.library === "Adafruit_TouchScreen" && touch.analogPins) {
|
|
200
|
+
const a = touch.analogPins;
|
|
201
|
+
return {
|
|
202
|
+
includes: ["#include <TouchScreen.h>"],
|
|
203
|
+
declaration: `TouchScreen __tc_touch = TouchScreen(${a.xp}, ${a.yp}, ${a.xm}, ${a.ym}, ${a.rx});`,
|
|
204
|
+
functions: [
|
|
205
|
+
`static inline void touch_init() {}`,
|
|
206
|
+
`static inline bool touch_isTouched() { return __tc_touch.isTouching(); }`,
|
|
207
|
+
`static inline void touch_readRaw(int16_t* x, int16_t* y, int16_t* z) {`,
|
|
208
|
+
` TS_Point __tp = __tc_touch.getPoint();`,
|
|
209
|
+
` if (x) *x = (int16_t)__tp.x;`,
|
|
210
|
+
` if (y) *y = (int16_t)__tp.y;`,
|
|
211
|
+
` if (z) *z = (int16_t)__tp.z;`,
|
|
212
|
+
`}`,
|
|
213
|
+
].join("\n"),
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
if (touch.library === "Adafruit_STMPE610") {
|
|
217
|
+
return {
|
|
218
|
+
includes: ["#include <Adafruit_STMPE610.h>"],
|
|
219
|
+
declaration: `Adafruit_STMPE610 __tc_touch(${cs});`,
|
|
220
|
+
functions: [
|
|
221
|
+
`static inline void touch_init() { __tc_touch.begin(); }`,
|
|
222
|
+
`static inline bool touch_isTouched() { return __tc_touch.touched() && !__tc_touch.bufferEmpty(); }`,
|
|
223
|
+
`static inline void touch_readRaw(int16_t* x, int16_t* y, int16_t* z) {`,
|
|
224
|
+
` TS_Point __tp = __tc_touch.getPoint();`,
|
|
225
|
+
` if (x) *x = (int16_t)__tp.x;`,
|
|
226
|
+
` if (y) *y = (int16_t)__tp.y;`,
|
|
227
|
+
` if (z) *z = (int16_t)__tp.z;`,
|
|
228
|
+
`}`,
|
|
229
|
+
].join("\n"),
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
if (touch.library === "FT6336U") {
|
|
233
|
+
const addr = touch.i2cAddress ?? 0x38;
|
|
234
|
+
// I2C addresses are conventional in hex in Arduino code.
|
|
235
|
+
const addrHex = "0x" + addr.toString(16).toUpperCase();
|
|
236
|
+
const i2cFrequency = touch.i2cFrequency ?? 400000;
|
|
237
|
+
const reset = touch.resetPin;
|
|
238
|
+
const resetLines = reset
|
|
239
|
+
? [
|
|
240
|
+
` pinMode(${reset}, OUTPUT);`,
|
|
241
|
+
` digitalWrite(${reset}, LOW);`,
|
|
242
|
+
` delay(10);`,
|
|
243
|
+
` digitalWrite(${reset}, HIGH);`,
|
|
244
|
+
` delay(500);`,
|
|
245
|
+
].join("\n")
|
|
246
|
+
: ``;
|
|
247
|
+
return {
|
|
248
|
+
includes: ["#include <Wire.h>", "#include <RAK14014_FT6336U.h>"],
|
|
249
|
+
declaration: [
|
|
250
|
+
`FT6336U __tc_touch(${addrHex});`,
|
|
251
|
+
`static int16_t __tc_touch_cached_x = 0;`,
|
|
252
|
+
`static int16_t __tc_touch_cached_y = 0;`,
|
|
253
|
+
`static int16_t __tc_touch_cached_z = 0;`,
|
|
254
|
+
`static uint8_t __tc_touch_cached_valid = 0;`,
|
|
255
|
+
].join("\n"),
|
|
256
|
+
functions: [
|
|
257
|
+
`static inline uint8_t __tc_ft6336u_read_block(uint8_t reg, uint8_t* buf, uint8_t len) {`,
|
|
258
|
+
` Wire.beginTransmission(${addrHex});`,
|
|
259
|
+
` Wire.write(reg);`,
|
|
260
|
+
` if (Wire.endTransmission(false) != 0) return 0;`,
|
|
261
|
+
` uint8_t got = Wire.requestFrom((uint8_t)${addrHex}, len);`,
|
|
262
|
+
` if (got < len) return 0;`,
|
|
263
|
+
` for (uint8_t i = 0; i < len; i++) {`,
|
|
264
|
+
` if (!Wire.available()) return 0;`,
|
|
265
|
+
` buf[i] = Wire.read();`,
|
|
266
|
+
` }`,
|
|
267
|
+
` return 1;`,
|
|
268
|
+
`}`,
|
|
269
|
+
`static inline void touch_init() {`,
|
|
270
|
+
resetLines,
|
|
271
|
+
` __tc_touch.begin(Wire, ${addrHex});`,
|
|
272
|
+
` Wire.setClock(${i2cFrequency});`,
|
|
273
|
+
`}`,
|
|
274
|
+
`static inline bool touch_isTouched() {`,
|
|
275
|
+
` uint8_t buf[5] = {0, 0, 0, 0, 0};`,
|
|
276
|
+
` __tc_touch_cached_valid = 0;`,
|
|
277
|
+
` __tc_touch_cached_z = 0;`,
|
|
278
|
+
` if (!__tc_ft6336u_read_block(0x02, buf, 5)) return false;`,
|
|
279
|
+
` uint8_t count = buf[0] & 0x0F;`,
|
|
280
|
+
` if (count == 0) return false;`,
|
|
281
|
+
` __tc_touch_cached_x = (int16_t)(((uint16_t)(buf[1] & 0x0F) << 8) | buf[2]);`,
|
|
282
|
+
` __tc_touch_cached_y = (int16_t)(((uint16_t)(buf[3] & 0x0F) << 8) | buf[4]);`,
|
|
283
|
+
` __tc_touch_cached_z = 255;`,
|
|
284
|
+
` __tc_touch_cached_valid = 1;`,
|
|
285
|
+
` return true;`,
|
|
286
|
+
`}`,
|
|
287
|
+
`static inline void touch_readRaw(int16_t* x, int16_t* y, int16_t* z) {`,
|
|
288
|
+
` if (!__tc_touch_cached_valid) {`,
|
|
289
|
+
` (void)touch_isTouched();`,
|
|
290
|
+
` }`,
|
|
291
|
+
` if (x) *x = __tc_touch_cached_x;`,
|
|
292
|
+
` if (y) *y = __tc_touch_cached_y;`,
|
|
293
|
+
` if (z) *z = __tc_touch_cached_z;`,
|
|
294
|
+
` __tc_touch_cached_valid = 0;`,
|
|
295
|
+
`}`,
|
|
296
|
+
].join("\n"),
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
if (touch.library === "sdl") {
|
|
300
|
+
return {
|
|
301
|
+
includes: ["#include <SDL2/SDL.h>"],
|
|
302
|
+
declaration: `// SDL touch: no controller object — the event-driven mouse state`,
|
|
303
|
+
// __sdl_mouse_* is declared in the SDL display adapter (sdl.ts) and written
|
|
304
|
+
// by the host event loop from SDL_MOUSEBUTTONDOWN/MOTION/BUTTONUP. Reading
|
|
305
|
+
// it here (instead of polling SDL_GetMouseState each frame) makes input
|
|
306
|
+
// event-driven, removes a per-frame SDL query, and lets the same state feed
|
|
307
|
+
// hit-testing in the wheel handler. Forward-declared here in case the touch
|
|
308
|
+
// adapter is ever emitted without the display adapter (defensive).
|
|
309
|
+
functions: [
|
|
310
|
+
`extern uint8_t __sdl_mouse_down;`,
|
|
311
|
+
`extern int16_t __sdl_mouse_x;`,
|
|
312
|
+
`extern int16_t __sdl_mouse_y;`,
|
|
313
|
+
`static inline void touch_init() {}`,
|
|
314
|
+
`static inline bool touch_isTouched() {`,
|
|
315
|
+
` return __sdl_mouse_down != 0;`,
|
|
316
|
+
`}`,
|
|
317
|
+
// Scale window/logical mouse coords to framebuffer coords. In a normal
|
|
318
|
+
// window the two are the same size (1:1), but in fullscreen (or any
|
|
319
|
+
// HiDPI case where the window is larger than the fixed framebuffer) the
|
|
320
|
+
// raw coords cover the whole window (e.g. 0..1920) while the framebuffer
|
|
321
|
+
// is w_×h_ (e.g. 320×240). Without scaling, clicks past the framebuffer
|
|
322
|
+
// size clamp to the corner. SDL_RenderCopy stretches the texture to fill
|
|
323
|
+
// the renderer, so the inverse scale maps window→framebuffer.
|
|
324
|
+
`static inline void touch_readRaw(int16_t* x, int16_t* y, int16_t* z) {`,
|
|
325
|
+
` int __ww = 0, __wh = 0; SDL_GetWindowSize(__tc_display.win, &__ww, &__wh);`,
|
|
326
|
+
` if (__ww <= 0) __ww = display_width();`,
|
|
327
|
+
` if (__wh <= 0) __wh = display_height();`,
|
|
328
|
+
` if (x) *x = (int16_t)((int32_t)__sdl_mouse_x * display_width() / __ww);`,
|
|
329
|
+
` if (y) *y = (int16_t)((int32_t)__sdl_mouse_y * display_height() / __wh);`,
|
|
330
|
+
` if (z) *z = 200; // constant > default minPressure (10)`,
|
|
331
|
+
`}`,
|
|
332
|
+
].join("\n"),
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
throw new Error(`Unknown touch library "${touch.library}". ` +
|
|
336
|
+
`Use { adapter: './path' } for custom touch adapters, or one of: ` +
|
|
337
|
+
`XPT2046_Touchscreen, Adafruit_TouchScreen, Adafruit_STMPE610, FT6336U, sdl.`);
|
|
338
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DisplayHALOp } from "./display-op-ir.js";
|
|
2
|
+
export interface GraphicsCapacity {
|
|
3
|
+
/** Max nodes the retained tree may hold on this target. */
|
|
4
|
+
maxNodes: number;
|
|
5
|
+
/** Max ui.bind() entries. */
|
|
6
|
+
maxBindings: number;
|
|
7
|
+
/** Max simultaneously-armed transitions. */
|
|
8
|
+
maxActiveTransitions: number;
|
|
9
|
+
/** Where the static node table lives. */
|
|
10
|
+
nodeStorage: "progmem" | "flash";
|
|
11
|
+
}
|
|
12
|
+
export interface PlatformGraphicsStrategy {
|
|
13
|
+
/** Resolve a display HAL op to target-specific C++. Return undefined to fall back. */
|
|
14
|
+
resolveDisplayOp(op: DisplayHALOp): {
|
|
15
|
+
code?: string;
|
|
16
|
+
expression?: string;
|
|
17
|
+
} | undefined;
|
|
18
|
+
/** Display driver ids this framework provides (e.g. new Set(["ili9341"])). */
|
|
19
|
+
supportedDisplayDrivers(): ReadonlySet<string>;
|
|
20
|
+
/** Target color format — drives transpile-time color resolution.
|
|
21
|
+
* Phase 1: 565/mono active. Phase 2+ will widen the plumbing (ColorFormat
|
|
22
|
+
* aliases in model.ts/ui-lowering.ts, resolveColor signature) to admit
|
|
23
|
+
* rgb666/rgb888/palette, at which point resolveColor888 is the resolution
|
|
24
|
+
* entry point. Widening only the return type now would break assignment to
|
|
25
|
+
* the "rgb565" | "mono" field types downstream. */
|
|
26
|
+
colorFormat(): "rgb565" | "rgb666" | "rgb888" | "mono";
|
|
27
|
+
/** Per-target capacity caps (node/binding/transition limits, storage). */
|
|
28
|
+
graphicsCapacity(): GraphicsCapacity;
|
|
29
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// PlatformGraphicsStrategy — per-target graphics capacity and driver resolution
|
|
3
|
+
//
|
|
4
|
+
// Frameworks implement this sub-interface to (a) declare which display drivers
|
|
5
|
+
// they support (used by ui.mount() for fail-fast validation), (b) declare the
|
|
6
|
+
// target's color format (drives transpile-time color resolution), and (c)
|
|
7
|
+
// translate display HAL ops to driver-specific C++.
|
|
8
|
+
//
|
|
9
|
+
// Mirrors the existing resolveHALOperation() seam.
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
export {};
|