@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,145 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Display adapter generator: produces zero-cost display-specific C++ code
|
|
3
|
+
// based on the display profile's driver type. The transpiler emits the
|
|
4
|
+
// adapter (includes + declaration + inline functions) before the runtime
|
|
5
|
+
// header, so the runtime never names a specific display class.
|
|
6
|
+
//
|
|
7
|
+
// To add a new display driver:
|
|
8
|
+
// 1. Write a generator function matching the DisplayAdapterGenerator signature
|
|
9
|
+
// 2. Register it: registerDisplayAdapter("driver-name", generator)
|
|
10
|
+
// 3. Reference it from cuttlefish.config.ts: display: { profile: "driver-name-spi" }
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// ── Adapter registry ────────────────────────────────────────────────────────
|
|
13
|
+
const adapters = new Map();
|
|
14
|
+
export function registerDisplayAdapter(driver, gen) {
|
|
15
|
+
adapters.set(driver, gen);
|
|
16
|
+
}
|
|
17
|
+
export function generateDisplayAdapter(display) {
|
|
18
|
+
const driver = display.driver;
|
|
19
|
+
const gen = adapters.get(driver);
|
|
20
|
+
if (!gen) {
|
|
21
|
+
throw new Error(`No display adapter registered for driver "${driver}". ` +
|
|
22
|
+
`Registered: ${[...adapters.keys()].join(", ")}.`);
|
|
23
|
+
}
|
|
24
|
+
return gen(display);
|
|
25
|
+
}
|
|
26
|
+
// ── ST7796S adapter (RGB565 + RGB666 modes) ─────────────────────────────────
|
|
27
|
+
import { st7796Adapter } from "./display-adapters/st7796.js";
|
|
28
|
+
registerDisplayAdapter("st7796", st7796Adapter);
|
|
29
|
+
// ── eink-mono adapter (SSD1680-class, 1-bit, deferred partial refresh) ───────
|
|
30
|
+
import { einkMonoAdapter } from "./display-adapters/eink-mono.js";
|
|
31
|
+
registerDisplayAdapter("ssd1680", einkMonoAdapter);
|
|
32
|
+
// ── SSD1309 OLED adapter (1-bit mono, I2C, page-buffered) ───────────────────
|
|
33
|
+
import { ssd1309Adapter } from "./display-adapters/ssd1309.js";
|
|
34
|
+
registerDisplayAdapter("ssd1309", ssd1309Adapter);
|
|
35
|
+
// ── SDL2 adapter (native desktop window, RGB888) ────────────────────────────
|
|
36
|
+
import { sdlAdapter } from "./display-adapters/sdl.js";
|
|
37
|
+
registerDisplayAdapter("sdl", sdlAdapter);
|
|
38
|
+
// ── ILI9341 adapter ─────────────────────────────────────────────────────────
|
|
39
|
+
// The first built-in adapter. Mirrors the code previously hardcoded in
|
|
40
|
+
// ui-emitter.ts and runtime-header.ts.
|
|
41
|
+
registerDisplayAdapter("ili9341", (display) => {
|
|
42
|
+
const cs = display._mountCs;
|
|
43
|
+
const dc = display._mountDc;
|
|
44
|
+
const rst = display._mountRst;
|
|
45
|
+
const rotation = display.rotation ?? 1;
|
|
46
|
+
const spiFreq = display.spiFrequency;
|
|
47
|
+
return {
|
|
48
|
+
includes: [
|
|
49
|
+
`#define CuttlefishDisplayTarget Adafruit_GFX`,
|
|
50
|
+
`#define CuttlefishCanvas16 GFXcanvas16`,
|
|
51
|
+
`#include <Adafruit_GFX.h>`,
|
|
52
|
+
`#include <Adafruit_ILI9341.h>`,
|
|
53
|
+
].join("\n"),
|
|
54
|
+
declaration: `Adafruit_ILI9341 __tc_display = Adafruit_ILI9341(${cs}, ${dc}, ${rst});`,
|
|
55
|
+
functions: [
|
|
56
|
+
`// --- Display adapter: ILI9341 ---`,
|
|
57
|
+
``,
|
|
58
|
+
`static inline void display_init() {`,
|
|
59
|
+
spiFreq
|
|
60
|
+
? ` __tc_display.begin(${spiFreq});`
|
|
61
|
+
: ` __tc_display.begin();`,
|
|
62
|
+
` __tc_display.setRotation(${rotation});`,
|
|
63
|
+
` __tc_display.fillScreen(0x0000);`,
|
|
64
|
+
`}`,
|
|
65
|
+
``,
|
|
66
|
+
`static inline void display_fillScreen(uint16_t color) {`,
|
|
67
|
+
` __tc_display.fillScreen(color);`,
|
|
68
|
+
`}`,
|
|
69
|
+
``,
|
|
70
|
+
`static inline CuttlefishDisplayTarget* display_defaultTarget() { return &__tc_display; }`,
|
|
71
|
+
`static inline int16_t display_width() { return __tc_display.width(); }`,
|
|
72
|
+
`static inline int16_t display_height() { return __tc_display.height(); }`,
|
|
73
|
+
``,
|
|
74
|
+
`static inline void display_startWrite() { __tc_display.startWrite(); }`,
|
|
75
|
+
`static inline void display_endWrite() { __tc_display.endWrite(); }`,
|
|
76
|
+
`static inline void display_setAddrWindow(int16_t x, int16_t y, int16_t w, int16_t h) {`,
|
|
77
|
+
` __tc_display.setAddrWindow(x, y, w, h);`,
|
|
78
|
+
`}`,
|
|
79
|
+
`static inline void display_writePixels(uint16_t* pixels, uint32_t count) {`,
|
|
80
|
+
` __tc_display.writePixels(pixels, count);`,
|
|
81
|
+
`}`,
|
|
82
|
+
``,
|
|
83
|
+
`static inline CuttlefishCanvas16* display_createCanvas(int16_t w, int16_t h) {`,
|
|
84
|
+
` return new GFXcanvas16(w, h);`,
|
|
85
|
+
`}`,
|
|
86
|
+
`static inline CuttlefishCanvas16* display_createCanvasPsram(int16_t w, int16_t h) {`,
|
|
87
|
+
`#if defined(ESP32) && defined(BOARD_HAS_PSRAM)`,
|
|
88
|
+
` return new (ps_malloc(sizeof(GFXcanvas16))) GFXcanvas16(w, h);`,
|
|
89
|
+
`#else`,
|
|
90
|
+
` (void)w; (void)h;`,
|
|
91
|
+
` return nullptr;`,
|
|
92
|
+
`#endif`,
|
|
93
|
+
`}`,
|
|
94
|
+
`static inline void display_deleteCanvas(CuttlefishCanvas16* canvas) { delete canvas; }`,
|
|
95
|
+
`static inline int16_t display_canvasWidth(CuttlefishCanvas16* canvas) { return canvas->width(); }`,
|
|
96
|
+
`static inline int16_t display_canvasHeight(CuttlefishCanvas16* canvas) { return canvas->height(); }`,
|
|
97
|
+
`static inline uint16_t* display_canvasBuffer(CuttlefishCanvas16* canvas) { return canvas->getBuffer(); }`,
|
|
98
|
+
`static inline uint16_t display_canvasGetPixel(CuttlefishCanvas16* canvas, int16_t x, int16_t y) { return canvas->getPixel(x, y); }`,
|
|
99
|
+
`static inline void display_canvasFillScreen(CuttlefishCanvas16* canvas, UI_COLOR_T color) { canvas->fillScreen((uint16_t)color); }`,
|
|
100
|
+
`static inline void display_canvasFillRect(CuttlefishCanvas16* canvas, int16_t x, int16_t y, int16_t w, int16_t h, UI_COLOR_T color) {`,
|
|
101
|
+
` canvas->fillRect(x, y, w, h, (uint16_t)color);`,
|
|
102
|
+
`}`,
|
|
103
|
+
``,
|
|
104
|
+
`static inline void display_targetDrawPixel(CuttlefishDisplayTarget* target, int16_t x, int16_t y, UI_COLOR_T color) { target->drawPixel(x, y, (uint16_t)color); }`,
|
|
105
|
+
`static inline int16_t display_targetWidth(CuttlefishDisplayTarget* target) { return target->width(); }`,
|
|
106
|
+
`static inline int16_t display_targetHeight(CuttlefishDisplayTarget* target) { return target->height(); }`,
|
|
107
|
+
`static inline void display_targetDrawRGBBitmap(CuttlefishDisplayTarget* target, int16_t x, int16_t y, const uint16_t* bitmap, int16_t w, int16_t h) {`,
|
|
108
|
+
` target->drawRGBBitmap(x, y, bitmap, w, h);`,
|
|
109
|
+
`}`,
|
|
110
|
+
`static inline void display_targetFillRect(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t w, int16_t h, UI_COLOR_T color) {`,
|
|
111
|
+
` target->fillRect(x, y, w, h, (uint16_t)color);`,
|
|
112
|
+
`}`,
|
|
113
|
+
`static inline void display_targetDrawFastHLine(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t w, UI_COLOR_T color) {`,
|
|
114
|
+
` target->drawFastHLine(x, y, w, (uint16_t)color);`,
|
|
115
|
+
`}`,
|
|
116
|
+
`static inline void display_targetDrawFastVLine(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t h, UI_COLOR_T color) {`,
|
|
117
|
+
` target->drawFastVLine(x, y, h, (uint16_t)color);`,
|
|
118
|
+
`}`,
|
|
119
|
+
`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) {`,
|
|
120
|
+
` target->fillRoundRect(x, y, w, h, r, (uint16_t)color);`,
|
|
121
|
+
`}`,
|
|
122
|
+
`static inline void display_targetDrawRect(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t w, int16_t h, UI_COLOR_T color) {`,
|
|
123
|
+
` target->drawRect(x, y, w, h, (uint16_t)color);`,
|
|
124
|
+
`}`,
|
|
125
|
+
`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) {`,
|
|
126
|
+
` target->drawRoundRect(x, y, w, h, r, (uint16_t)color);`,
|
|
127
|
+
`}`,
|
|
128
|
+
`static inline void display_targetDrawLine(CuttlefishDisplayTarget* target, int16_t x0, int16_t y0, int16_t x1, int16_t y1, UI_COLOR_T color) {`,
|
|
129
|
+
` target->drawLine(x0, y0, x1, y1, (uint16_t)color);`,
|
|
130
|
+
`}`,
|
|
131
|
+
`static inline void display_targetFillCircle(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t r, UI_COLOR_T color) {`,
|
|
132
|
+
` target->fillCircle(x, y, r, (uint16_t)color);`,
|
|
133
|
+
`}`,
|
|
134
|
+
`static inline void display_targetDrawCircle(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t r, UI_COLOR_T color) {`,
|
|
135
|
+
` target->drawCircle(x, y, r, (uint16_t)color);`,
|
|
136
|
+
`}`,
|
|
137
|
+
`static inline void display_targetSetCursor(CuttlefishDisplayTarget* target, int16_t x, int16_t y) { target->setCursor(x, y); }`,
|
|
138
|
+
`static inline void display_targetSetTextColor(CuttlefishDisplayTarget* target, UI_COLOR_T fg) { target->setTextColor((uint16_t)fg); }`,
|
|
139
|
+
`static inline void display_targetSetTextColorBg(CuttlefishDisplayTarget* target, UI_COLOR_T fg, UI_COLOR_T bg) { target->setTextColor((uint16_t)fg, (uint16_t)bg); }`,
|
|
140
|
+
`static inline void display_targetSetTextSize(CuttlefishDisplayTarget* target, uint8_t size) { target->setTextSize(size); }`,
|
|
141
|
+
`static inline void display_targetSetTextWrap(CuttlefishDisplayTarget* target, bool wrap) { target->setTextWrap(wrap); }`,
|
|
142
|
+
`static inline void display_targetPrint(CuttlefishDisplayTarget* target, const char* text) { target->print(text); }`,
|
|
143
|
+
].join("\n"),
|
|
144
|
+
};
|
|
145
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// eink-mono display adapter — 1-bit B&W e-ink panels (SSD1680-class, e.g. the
|
|
3
|
+
// common 296×128 / 250×122 breakouts). Deferred refresh: no fillScreen on init
|
|
4
|
+
// (a full clear flashes), and a partial-refresh entry point the runtime's dirty-
|
|
5
|
+
// rect union calls once per frame.
|
|
6
|
+
//
|
|
7
|
+
// Library note: targets Adafruit_EPD (Adafruit_SSD168x). The exact partial-
|
|
8
|
+
// refresh method name varies by library (Adafruit_EPD: refreshPartial / GxEPD:
|
|
9
|
+
// updateWindow). Verify against the target library before flashing — the shim
|
|
10
|
+
// shape is correct; the method call is library-specific. TODO Phase 5.
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
export const einkMonoAdapter = (display) => {
|
|
13
|
+
const cs = display._mountCs;
|
|
14
|
+
const dc = display._mountDc;
|
|
15
|
+
const rst = display._mountRst;
|
|
16
|
+
const rotation = display.rotation ?? 0;
|
|
17
|
+
const w = display.width;
|
|
18
|
+
const h = display.height;
|
|
19
|
+
return {
|
|
20
|
+
includes: [
|
|
21
|
+
"#include <Adafruit_GFX.h>",
|
|
22
|
+
"#include <Adafruit_EPD.h>",
|
|
23
|
+
].join("\n"),
|
|
24
|
+
// busy pin = -1 (unused); SRCS+D/C+RST+CS wiring. Adafruit_SSD168x(width, height, dc, rst, cs, busy).
|
|
25
|
+
declaration: `Adafruit_SSD168x __tc_display(${w}, ${h}, ${dc}, ${rst}, ${cs}, -1);`,
|
|
26
|
+
functions: [
|
|
27
|
+
"// --- Display adapter: eink-mono (SSD1680-class, 1-bit, deferred refresh) ---",
|
|
28
|
+
"static inline void display_init() {",
|
|
29
|
+
" __tc_display.begin();",
|
|
30
|
+
` __tc_display.setRotation(${rotation});`,
|
|
31
|
+
" // No full-screen clear here — e-ink flashes on a full clear. The runtime",
|
|
32
|
+
" // marks all nodes dirty (UI_REFRESH_DEFERRED) and the first flush repaints",
|
|
33
|
+
" // via partial refresh instead.",
|
|
34
|
+
"}",
|
|
35
|
+
"",
|
|
36
|
+
"static inline CuttlefishDisplayTarget* display_defaultTarget() { return &__tc_display; }",
|
|
37
|
+
"static inline int16_t display_width() { return __tc_display.width(); }",
|
|
38
|
+
"static inline int16_t display_height() { return __tc_display.height(); }",
|
|
39
|
+
"static inline void display_startWrite() {}",
|
|
40
|
+
"static inline void display_endWrite() {}",
|
|
41
|
+
"static inline void display_setAddrWindow(int16_t x, int16_t y, int16_t w, int16_t h) { (void)x; (void)y; (void)w; (void)h; }",
|
|
42
|
+
// Partial refresh: push just the dirty region. The runtime draws into the
|
|
43
|
+
// EPD's built-in GFX buffer (the display IS the backing store for 1-bit),
|
|
44
|
+
// then calls this with the unioned dirty rect. TODO Phase 5: verify the
|
|
45
|
+
// exact partial-refresh API for the target EPD library.
|
|
46
|
+
"static inline void display_partial_refresh(int16_t x, int16_t y, int16_t w, int16_t h) {",
|
|
47
|
+
" __tc_display.refreshPartial(x, y, (uint16_t)w, (uint16_t)h);",
|
|
48
|
+
"}",
|
|
49
|
+
// drawPixel goes through GFX into the EPD buffer; partial_refresh publishes it.
|
|
50
|
+
"static inline void display_fillScreen(uint32_t color) { __tc_display.fillScreen(color ? EPD_WHITE : EPD_BLACK); }",
|
|
51
|
+
].join("\n"),
|
|
52
|
+
};
|
|
53
|
+
};
|