@typecad/cuttlefish 1.0.0-alpha.3 → 1.0.0-alpha.7

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.
Files changed (123) hide show
  1. package/README.md +4 -4
  2. package/dist/api/shared/display-adapter.d.ts +2 -1
  3. package/dist/api/shared/display-adapter.js +8 -1
  4. package/dist/api/shared/display-adapters/sdl.js +9 -2
  5. package/dist/api/shared/display-profile.d.ts +20 -3
  6. package/dist/api/shared/display-profile.js +21 -6
  7. package/dist/api/shared/framework-manifest-registry.d.ts +9 -0
  8. package/dist/api/shared/framework-manifest-registry.js +25 -0
  9. package/dist/api/shared/framework-manifest.d.ts +462 -0
  10. package/dist/api/shared/framework-manifest.js +149 -0
  11. package/dist/api/shared/glcdfont.d.ts +12 -0
  12. package/dist/api/shared/glcdfont.js +124 -0
  13. package/dist/api/shared/graphics-strategy.d.ts +28 -0
  14. package/dist/api/shared/hal-op-ir.d.ts +427 -1
  15. package/dist/api/shared/hal-op-ir.js +95 -1
  16. package/dist/api/shared/index.d.ts +11 -1
  17. package/dist/api/shared/index.js +14 -0
  18. package/dist/api/shared/native-display-op-resolver.d.ts +10 -0
  19. package/dist/api/shared/native-display-op-resolver.js +64 -0
  20. package/dist/api/shared/platform-strategy.d.ts +9 -0
  21. package/dist/api/shared/promise-runtime.js +78 -0
  22. package/dist/api/shared/types.d.ts +8 -0
  23. package/dist/api/shared/validate-framework-manifest.d.ts +28 -0
  24. package/dist/api/shared/validate-framework-manifest.js +417 -0
  25. package/dist/cli-utils.d.ts +1 -0
  26. package/dist/cli-utils.js +3 -1
  27. package/dist/cli.js +175 -4
  28. package/dist/config-loader.js +20 -1
  29. package/dist/config-schema.d.ts +36 -36
  30. package/dist/create/board-spec.d.ts +4 -4
  31. package/dist/create/index.d.ts +1 -1
  32. package/dist/create/index.js +1 -1
  33. package/dist/create/init-scaffold.d.ts +3 -0
  34. package/dist/create/init-scaffold.js +74 -2
  35. package/dist/create/init-templates.d.ts +4 -0
  36. package/dist/create/init-templates.js +217 -17
  37. package/dist/create/init-wizard.js +20 -1
  38. package/dist/emit/cpp-emitter.js +4 -3
  39. package/dist/emit/emitters/emitter-context.d.ts +5 -0
  40. package/dist/emit/emitters/function-emitter-impl.js +69 -59
  41. package/dist/emit/emitters/output-finalizer.d.ts +6 -0
  42. package/dist/emit/emitters/output-finalizer.js +21 -11
  43. package/dist/emit/emitters/setup.js +155 -0
  44. package/dist/emit/emitters/top-level-prep.js +2 -0
  45. package/dist/emit/emitters/ui-emitter.js +23 -8
  46. package/dist/emit/expression-renderer.js +10 -1
  47. package/dist/emit/snprintf-helpers.js +8 -0
  48. package/dist/emit/statement-renderer.js +13 -0
  49. package/dist/emit/utils/async-state-machine.js +185 -116
  50. package/dist/emit/utils/hal-op-cpp-type.d.ts +6 -0
  51. package/dist/emit/utils/hal-op-cpp-type.js +40 -0
  52. package/dist/ir/adc-range-validation.js +26 -25
  53. package/dist/ir/build-ir.js +5 -1
  54. package/dist/ir/expression-to-ir.js +57 -6
  55. package/dist/ir/feature-registry.js +7 -25
  56. package/dist/ir/hal/hal-emitter.d.ts +5 -2
  57. package/dist/ir/hal/hal-emitter.js +40 -12
  58. package/dist/ir/hal/hal-parser.d.ts +6 -0
  59. package/dist/ir/hal/hal-parser.js +74 -0
  60. package/dist/ir/hal/hal-plugins.js +571 -0
  61. package/dist/ir/identifier-collector.js +18 -0
  62. package/dist/ir/interrupt-analysis.js +8 -3
  63. package/dist/ir/memory-budget-validation.js +1 -0
  64. package/dist/ir/network-validation.d.ts +4 -0
  65. package/dist/ir/network-validation.js +184 -0
  66. package/dist/ir/ownership-analysis.js +33 -1
  67. package/dist/ir/peripheral-ownership.js +5 -0
  68. package/dist/ir/peripheral-validation.d.ts +1 -1
  69. package/dist/ir/peripheral-validation.js +6 -3
  70. package/dist/ir/pin-alias-conflict.d.ts +1 -1
  71. package/dist/ir/pin-alias-conflict.js +2 -1
  72. package/dist/ir/pin-capability-validation.js +34 -32
  73. package/dist/ir/pin-mode-validation.js +5 -0
  74. package/dist/ir/pin-safety.d.ts +1 -1
  75. package/dist/ir/pin-safety.js +2 -1
  76. package/dist/ir/program-analysis.d.ts +39 -0
  77. package/dist/ir/program-analysis.js +192 -0
  78. package/dist/ir/pulldown-validation.d.ts +1 -1
  79. package/dist/ir/pulldown-validation.js +2 -1
  80. package/dist/ir/pwm-timer-sharing.d.ts +1 -1
  81. package/dist/ir/pwm-timer-sharing.js +2 -1
  82. package/dist/ir/resource-analysis.js +2 -0
  83. package/dist/ir/timer0-pwm-timing-conflict.d.ts +1 -1
  84. package/dist/ir/timer0-pwm-timing-conflict.js +2 -1
  85. package/dist/ir/timing-validation.d.ts +6 -1
  86. package/dist/ir/timing-validation.js +51 -12
  87. package/dist/ir/transformers/expressions.js +58 -0
  88. package/dist/ir/transformers/hal-emit-helpers.js +1 -1
  89. package/dist/ir/transformers/variables.js +86 -19
  90. package/dist/ir/try-catch-validation.js +2 -0
  91. package/dist/ir/type-resolution.js +2 -2
  92. package/dist/ir/unit-suspicion-validation.js +9 -7
  93. package/dist/ir/validation-orchestrator.js +9 -7
  94. package/dist/libdef/c-to-decl.d.ts +27 -0
  95. package/dist/libdef/c-to-decl.js +397 -0
  96. package/dist/libdef/component-decls.d.ts +2 -0
  97. package/dist/libdef/component-decls.js +6 -0
  98. package/dist/libdef/component-discovery.d.ts +43 -0
  99. package/dist/libdef/component-discovery.js +83 -0
  100. package/dist/libdef/cpp-to-decl.d.ts +9 -0
  101. package/dist/libdef/cpp-to-decl.js +72 -0
  102. package/dist/libdef/idf-discovery.d.ts +7 -0
  103. package/dist/libdef/idf-discovery.js +59 -0
  104. package/dist/libdef/registry.js +5 -2
  105. package/dist/licenses.d.ts +185 -0
  106. package/dist/licenses.js +963 -0
  107. package/dist/lint-cache.d.ts +59 -0
  108. package/dist/lint-cache.js +257 -0
  109. package/dist/orchestrator/graph-builder.js +6 -2
  110. package/dist/stores/display-profile-store.d.ts +1 -0
  111. package/dist/stores/display-profile-store.js +1 -0
  112. package/dist/testing.d.ts +4 -2
  113. package/dist/testing.js +4 -2
  114. package/dist/transpile.d.ts +3 -0
  115. package/dist/transpile.js +78 -32
  116. package/dist/types.d.ts +5 -1
  117. package/dist/ui-hook.d.ts +17 -1
  118. package/dist/utils/cli.js +71 -1
  119. package/dist/utils/fs.d.ts +13 -0
  120. package/dist/utils/fs.js +50 -0
  121. package/package.json +9 -4
  122. package/dist/ir/heap-array-validation.d.ts +0 -24
  123. package/dist/ir/heap-array-validation.js +0 -29
@@ -0,0 +1,149 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Framework manifest schema
3
+ //
4
+ // Single source of truth for "what a framework is." A zod schema defines the
5
+ // contract; the FrameworkManifest type is inferred from it so there is no
6
+ // drift between runtime validation and static types. Each field maps to a real
7
+ // code artifact (PlatformStrategy method, LoadedFramework export, file path).
8
+ //
9
+ // Per-package `framework.manifest.ts` files call defineFrameworkManifest() to
10
+ // declare their coverage. The validator in validate-framework-manifest.ts
11
+ // cross-checks each claim against the loaded strategy/toolchain.
12
+ // ---------------------------------------------------------------------------
13
+ import { z } from 'zod';
14
+ const HAL_CATEGORIES = [
15
+ 'gpio', 'pwm', 'adc', 'dac', 'interrupts', 'tone', 'timing', 'power',
16
+ 'i2c', 'spi', 'uart', 'pulse', 'shift', 'board', 'wdt', 'wifi', 'http',
17
+ 'display',
18
+ ];
19
+ const OpStatus = z.enum(['supported', 'stub', 'unsupported', 'probe-inconclusive', 'polyfill']);
20
+ const HalCategorySchema = z.object({
21
+ supported: z.boolean(),
22
+ unsupportedReason: z.string().optional(),
23
+ ops: z.record(z.string(), OpStatus),
24
+ partialCoverage: z.boolean().default(false),
25
+ });
26
+ const DisplayCategorySchema = HalCategorySchema.extend({
27
+ drivers: z.array(z.string()),
28
+ colorFormat: z.enum(['rgb565', 'mono']).nullable(),
29
+ });
30
+ const HalCoverageSchema = z.object(Object.fromEntries(HAL_CATEGORIES.map((c) => [
31
+ c,
32
+ c === 'display' ? DisplayCategorySchema : HalCategorySchema,
33
+ ]))).extend({
34
+ raw: z.object({ supported: z.boolean() }).default({ supported: true }),
35
+ });
36
+ const EntrypointSchema = z.object({
37
+ entrypointFunctionName: z.string(),
38
+ requiresLoopFunction: z.boolean(),
39
+ sourceExtension: z.enum(['ino', 'cc', 'cpp', 'h']),
40
+ overrideBaseName: z.string().optional(),
41
+ outputSubdirectory: z.string().optional(),
42
+ generateHeaderFile: z.boolean(),
43
+ customBridgeShim: z.string().optional(),
44
+ });
45
+ const ProfileSchema = z.object({
46
+ targets: z.array(z.string()),
47
+ forcedIncludes: z.array(z.string()),
48
+ symbolAliases: z.record(z.string(), z.string()),
49
+ });
50
+ const PolyfillCoverageSchema = z.object({
51
+ emitted: z.array(z.object({
52
+ id: z.string(),
53
+ domain: z.string(),
54
+ notes: z.string().optional(),
55
+ })),
56
+ suppressed: z.array(z.object({
57
+ id: z.string(),
58
+ reason: z.string(),
59
+ })),
60
+ });
61
+ const ToolchainCoverageSchema = z.object({
62
+ backend: z.string(),
63
+ operations: z.object({
64
+ prepare: z.boolean(),
65
+ compile: z.boolean(),
66
+ upload: z.boolean(),
67
+ monitor: z.boolean(),
68
+ }),
69
+ reexportedFrom: z.string().optional(),
70
+ });
71
+ const LibraryResolutionSchema = z.object({
72
+ isFrameworkLibraryImport: z.boolean(),
73
+ getFrameworkLibraryHeaderName: z.boolean(),
74
+ buildClassNameMap: z.boolean(),
75
+ tryGenerateLibDecl: z.boolean(),
76
+ reexportedFrom: z.string().optional(),
77
+ });
78
+ const StdLibSupportSchema = z.object({
79
+ hasVector: z.boolean(),
80
+ hasString: z.boolean(),
81
+ hasIostream: z.boolean(),
82
+ hasExceptions: z.boolean(),
83
+ hasRTTI: z.boolean(),
84
+ recommendedArrayImpl: z.enum(['std_vector', 'static_array']),
85
+ recommendedStringImpl: z.enum(['std_string', 'static_string']),
86
+ });
87
+ const TypeEmissionSchema = z.object({
88
+ normalizeCppType: z.boolean(),
89
+ mathHeader: z.enum(['none', '<math.h>', '<Arduino.h>']),
90
+ needsStdString: z.boolean(),
91
+ needsStdVector: z.boolean(),
92
+ needsIostream: z.boolean(),
93
+ needsStdFunction: z.boolean(),
94
+ stdlibSupport: StdLibSupportSchema,
95
+ });
96
+ const ConformanceSchema = z.object({
97
+ hardwareTestGroups: z.array(z.string()),
98
+ halResolutionTests: z.array(z.string()),
99
+ });
100
+ export const FrameworkManifestSchema = z.object({
101
+ schemaVersion: z.literal(1),
102
+ frameworkId: z.string(),
103
+ packageName: z.string(),
104
+ canonical: z.boolean().default(false),
105
+ displayName: z.string(),
106
+ description: z.string(),
107
+ basedOn: z.string().optional(),
108
+ implementationMode: z.enum(['from-scratch', 'extends-canonical', 'extends-other']),
109
+ inheritsStrategyId: z.string().optional(),
110
+ entrypoint: EntrypointSchema,
111
+ profile: ProfileSchema,
112
+ hal: HalCoverageSchema,
113
+ polyfills: PolyfillCoverageSchema,
114
+ toolchain: ToolchainCoverageSchema,
115
+ libraryResolution: LibraryResolutionSchema.optional(),
116
+ typeEmission: TypeEmissionSchema,
117
+ ambientTypes: z.array(z.string()),
118
+ conformance: ConformanceSchema,
119
+ });
120
+ /**
121
+ * Authoritative map of HAL op kinds that are lowered via the polyfill system
122
+ * rather than via `resolveHALOperation`. Keyed by op kind; value is the
123
+ * polyfill id that backs it.
124
+ *
125
+ * The manifest validator uses this to verify `polyfill`-declared ops: if a
126
+ * manifest declares `timing.set_interval: 'polyfill'`, the framework's
127
+ * `polyfills.emitted` list must include the polyfill id named here.
128
+ *
129
+ * Keep in sync with the transpiler's lowering routes — when a new op kind
130
+ * starts being routed via a polyfill instead of the HAL resolver, add it
131
+ * here. The set is intentionally small and stable: polyfill-routed ops are
132
+ * the exception, not the rule.
133
+ */
134
+ export const POLYFILL_BACKED_OPS = {
135
+ 'timing.set_interval': 'timer_methods',
136
+ 'timing.set_timeout': 'timer_methods',
137
+ 'timing.clear_interval': 'timer_methods',
138
+ 'timing.clear_timeout': 'timer_methods',
139
+ };
140
+ /**
141
+ * Validates and returns a FrameworkManifest. Frameworks call this from their
142
+ * `framework.manifest.ts` to get both static type-checking (the parameter type
143
+ * is the inferred FrameworkManifest) and runtime validation (zod parse).
144
+ * Bad manifests throw at module-load time.
145
+ */
146
+ export function defineFrameworkManifest(input) {
147
+ return FrameworkManifestSchema.parse(input);
148
+ }
149
+ export { HAL_CATEGORIES };
@@ -0,0 +1,12 @@
1
+ export declare const GLCDFONT_BYTES: readonly number[];
2
+ /**
3
+ * Render the font as a C++ byte-array literal (16 bytes per line). Used by
4
+ * adapters that need the table emitted into the synthesized translation unit.
5
+ *
6
+ * Example output:
7
+ * static const uint8_t glcdfont[] = {
8
+ * 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x5b, 0x4f, 0x5b, 0x3e, ...
9
+ * ...
10
+ * };
11
+ */
12
+ export declare function renderGlcdfontArray(name: string, type?: string): string;
@@ -0,0 +1,124 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Adafruit GFX 5x7 glcdfont — the 'classic' fixed-space bitmap font shipped
3
+ // with Adafruit_GFX since 1.0.
4
+ //
5
+ // Source: Adafruit_GFX library glcdfont.c
6
+ // Copyright (c) 2013 Adafruit Industries. All rights reserved.
7
+ // Licensed under BSD-3-Clause (as part of the Adafruit_GFX library).
8
+ // Upstream: https://github.com/adafruit/Adafruit-GFX-Library/blob/master/glcdfont.c
9
+ //
10
+ // NOTE: an earlier revision of this file described the bytes as "public
11
+ // domain." That claim could not be verified — glcdfont.c carries no
12
+ // per-file license statement and is distributed as part of the BSD-3-Clause
13
+ // Adafruit_GFX library, so the conservative treatment is BSD-3-Clause.
14
+ //
15
+ // Shared between:
16
+ // - packages/cuttlefish/src/api/shared/display-adapters/sdl.ts
17
+ // (emits __sdl_glcdfont[] for the SDL preview host adapter)
18
+ // - packages/ui/src/ui-engine/runtime-header/cuttlefish-gfx.ts
19
+ // (emits glcdfont[] for native display adapters — AVR, ESP32)
20
+ //
21
+ // 256 glyphs × 5 bytes = 1280 bytes. Indexed as glcdfont[ch * 5 + column].
22
+ // ---------------------------------------------------------------------------
23
+ export const GLCDFONT_BYTES = [
24
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x5b, 0x4f, 0x5b, 0x3e, 0x3e, 0x6b, 0x4f, 0x6b, 0x3e, 0x1c,
25
+ 0x3e, 0x7c, 0x3e, 0x1c, 0x18, 0x3c, 0x7e, 0x3c, 0x18, 0x1c, 0x57, 0x7d, 0x57, 0x1c, 0x1c, 0x5e,
26
+ 0x7f, 0x5e, 0x1c, 0x00, 0x18, 0x3c, 0x18, 0x00, 0xff, 0xe7, 0xc3, 0xe7, 0xff, 0x00, 0x18, 0x24,
27
+ 0x18, 0x00, 0xff, 0xe7, 0xdb, 0xe7, 0xff, 0x30, 0x48, 0x3a, 0x06, 0x0e, 0x26, 0x29, 0x79, 0x29,
28
+ 0x26, 0x40, 0x7f, 0x05, 0x05, 0x07, 0x40, 0x7f, 0x05, 0x25, 0x3f, 0x5a, 0x3c, 0xe7, 0x3c, 0x5a,
29
+ 0x7f, 0x3e, 0x1c, 0x1c, 0x08, 0x08, 0x1c, 0x1c, 0x3e, 0x7f, 0x14, 0x22, 0x7f, 0x22, 0x14, 0x5f,
30
+ 0x5f, 0x00, 0x5f, 0x5f, 0x06, 0x09, 0x7f, 0x01, 0x7f, 0x00, 0x66, 0x89, 0x95, 0x6a, 0x60, 0x60,
31
+ 0x60, 0x60, 0x60, 0x94, 0xa2, 0xff, 0xa2, 0x94, 0x08, 0x04, 0x7e, 0x04, 0x08, 0x10, 0x20, 0x7e,
32
+ 0x20, 0x10, 0x08, 0x08, 0x2a, 0x1c, 0x08, 0x08, 0x1c, 0x2a, 0x08, 0x08, 0x1e, 0x10, 0x10, 0x10,
33
+ 0x10, 0x0c, 0x1e, 0x0c, 0x1e, 0x0c, 0x30, 0x38, 0x3e, 0x38, 0x30, 0x06, 0x0e, 0x3e, 0x0e, 0x06,
34
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x14,
35
+ 0x7f, 0x14, 0x7f, 0x14, 0x24, 0x2a, 0x7f, 0x2a, 0x12, 0x23, 0x13, 0x08, 0x64, 0x62, 0x36, 0x49,
36
+ 0x56, 0x20, 0x50, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00, 0x00, 0x41, 0x22,
37
+ 0x1c, 0x00, 0x2a, 0x1c, 0x7f, 0x1c, 0x2a, 0x08, 0x08, 0x3e, 0x08, 0x08, 0x00, 0x80, 0x70, 0x30,
38
+ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x60, 0x60, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02,
39
+ 0x3e, 0x51, 0x49, 0x45, 0x3e, 0x00, 0x42, 0x7f, 0x40, 0x00, 0x72, 0x49, 0x49, 0x49, 0x46, 0x21,
40
+ 0x41, 0x49, 0x4d, 0x33, 0x18, 0x14, 0x12, 0x7f, 0x10, 0x27, 0x45, 0x45, 0x45, 0x39, 0x3c, 0x4a,
41
+ 0x49, 0x49, 0x31, 0x41, 0x21, 0x11, 0x09, 0x07, 0x36, 0x49, 0x49, 0x49, 0x36, 0x46, 0x49, 0x49,
42
+ 0x29, 0x1e, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, 0x08, 0x14, 0x22,
43
+ 0x41, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x41, 0x22, 0x14, 0x08, 0x02, 0x01, 0x59, 0x09, 0x06,
44
+ 0x3e, 0x41, 0x5d, 0x59, 0x4e, 0x7c, 0x12, 0x11, 0x12, 0x7c, 0x7f, 0x49, 0x49, 0x49, 0x36, 0x3e,
45
+ 0x41, 0x41, 0x41, 0x22, 0x7f, 0x41, 0x41, 0x41, 0x3e, 0x7f, 0x49, 0x49, 0x49, 0x41, 0x7f, 0x09,
46
+ 0x09, 0x09, 0x01, 0x3e, 0x41, 0x41, 0x51, 0x73, 0x7f, 0x08, 0x08, 0x08, 0x7f, 0x00, 0x41, 0x7f,
47
+ 0x41, 0x00, 0x20, 0x40, 0x41, 0x3f, 0x01, 0x7f, 0x08, 0x14, 0x22, 0x41, 0x7f, 0x40, 0x40, 0x40,
48
+ 0x40, 0x7f, 0x02, 0x1c, 0x02, 0x7f, 0x7f, 0x04, 0x08, 0x10, 0x7f, 0x3e, 0x41, 0x41, 0x41, 0x3e,
49
+ 0x7f, 0x09, 0x09, 0x09, 0x06, 0x3e, 0x41, 0x51, 0x21, 0x5e, 0x7f, 0x09, 0x19, 0x29, 0x46, 0x26,
50
+ 0x49, 0x49, 0x49, 0x32, 0x03, 0x01, 0x7f, 0x01, 0x03, 0x3f, 0x40, 0x40, 0x40, 0x3f, 0x1f, 0x20,
51
+ 0x40, 0x20, 0x1f, 0x3f, 0x40, 0x38, 0x40, 0x3f, 0x63, 0x14, 0x08, 0x14, 0x63, 0x03, 0x04, 0x78,
52
+ 0x04, 0x03, 0x61, 0x59, 0x49, 0x4d, 0x43, 0x00, 0x7f, 0x41, 0x41, 0x41, 0x02, 0x04, 0x08, 0x10,
53
+ 0x20, 0x00, 0x41, 0x41, 0x41, 0x7f, 0x04, 0x02, 0x01, 0x02, 0x04, 0x40, 0x40, 0x40, 0x40, 0x40,
54
+ 0x00, 0x03, 0x07, 0x08, 0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x7f, 0x28, 0x44, 0x44, 0x38, 0x38,
55
+ 0x44, 0x44, 0x44, 0x28, 0x38, 0x44, 0x44, 0x28, 0x7f, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x08,
56
+ 0x7e, 0x09, 0x02, 0x18, 0xa4, 0xa4, 0x9c, 0x78, 0x7f, 0x08, 0x04, 0x04, 0x78, 0x00, 0x44, 0x7d,
57
+ 0x40, 0x00, 0x20, 0x40, 0x40, 0x3d, 0x00, 0x7f, 0x10, 0x28, 0x44, 0x00, 0x00, 0x41, 0x7f, 0x40,
58
+ 0x00, 0x7c, 0x04, 0x78, 0x04, 0x78, 0x7c, 0x08, 0x04, 0x04, 0x78, 0x38, 0x44, 0x44, 0x44, 0x38,
59
+ 0xfc, 0x18, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x18, 0xfc, 0x7c, 0x08, 0x04, 0x04, 0x08, 0x48,
60
+ 0x54, 0x54, 0x54, 0x24, 0x04, 0x04, 0x3f, 0x44, 0x24, 0x3c, 0x40, 0x40, 0x20, 0x7c, 0x1c, 0x20,
61
+ 0x40, 0x20, 0x1c, 0x3c, 0x40, 0x30, 0x40, 0x3c, 0x44, 0x28, 0x10, 0x28, 0x44, 0x4c, 0x90, 0x90,
62
+ 0x90, 0x7c, 0x44, 0x64, 0x54, 0x4c, 0x44, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x77, 0x00,
63
+ 0x00, 0x00, 0x41, 0x36, 0x08, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x3c, 0x26, 0x23, 0x26, 0x3c,
64
+ 0x1e, 0xa1, 0xa1, 0x61, 0x12, 0x3a, 0x40, 0x40, 0x20, 0x7a, 0x38, 0x54, 0x54, 0x55, 0x59, 0x21,
65
+ 0x55, 0x55, 0x79, 0x41, 0x22, 0x54, 0x54, 0x78, 0x42, 0x21, 0x55, 0x54, 0x78, 0x40, 0x20, 0x54,
66
+ 0x55, 0x79, 0x40, 0x0c, 0x1e, 0x52, 0x72, 0x12, 0x39, 0x55, 0x55, 0x55, 0x59, 0x39, 0x54, 0x54,
67
+ 0x54, 0x59, 0x39, 0x55, 0x54, 0x54, 0x58, 0x00, 0x00, 0x45, 0x7c, 0x41, 0x00, 0x02, 0x45, 0x7d,
68
+ 0x42, 0x00, 0x01, 0x45, 0x7c, 0x40, 0x7d, 0x12, 0x11, 0x12, 0x7d, 0xf0, 0x28, 0x25, 0x28, 0xf0,
69
+ 0x7c, 0x54, 0x55, 0x45, 0x00, 0x20, 0x54, 0x54, 0x7c, 0x54, 0x7c, 0x0a, 0x09, 0x7f, 0x49, 0x32,
70
+ 0x49, 0x49, 0x49, 0x32, 0x3a, 0x44, 0x44, 0x44, 0x3a, 0x32, 0x4a, 0x48, 0x48, 0x30, 0x3a, 0x41,
71
+ 0x41, 0x21, 0x7a, 0x3a, 0x42, 0x40, 0x20, 0x78, 0x00, 0x9d, 0xa0, 0xa0, 0x7d, 0x3d, 0x42, 0x42,
72
+ 0x42, 0x3d, 0x3d, 0x40, 0x40, 0x40, 0x3d, 0x3c, 0x24, 0xff, 0x24, 0x24, 0x48, 0x7e, 0x49, 0x43,
73
+ 0x66, 0x2b, 0x2f, 0xfc, 0x2f, 0x2b, 0xff, 0x09, 0x29, 0xf6, 0x20, 0xc0, 0x88, 0x7e, 0x09, 0x03,
74
+ 0x20, 0x54, 0x54, 0x79, 0x41, 0x00, 0x00, 0x44, 0x7d, 0x41, 0x30, 0x48, 0x48, 0x4a, 0x32, 0x38,
75
+ 0x40, 0x40, 0x22, 0x7a, 0x00, 0x7a, 0x0a, 0x0a, 0x72, 0x7d, 0x0d, 0x19, 0x31, 0x7d, 0x26, 0x29,
76
+ 0x29, 0x2f, 0x28, 0x26, 0x29, 0x29, 0x29, 0x26, 0x30, 0x48, 0x4d, 0x40, 0x20, 0x38, 0x08, 0x08,
77
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x2f, 0x10, 0xc8, 0xac, 0xba, 0x2f, 0x10, 0x28, 0x34,
78
+ 0xfa, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x08, 0x14, 0x2a, 0x14, 0x22, 0x22, 0x14, 0x2a, 0x14, 0x08,
79
+ 0x55, 0x00, 0x55, 0x00, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0xff, 0x55, 0xff, 0x55, 0xff, 0x00,
80
+ 0x00, 0x00, 0xff, 0x00, 0x10, 0x10, 0x10, 0xff, 0x00, 0x14, 0x14, 0x14, 0xff, 0x00, 0x10, 0x10,
81
+ 0xff, 0x00, 0xff, 0x10, 0x10, 0xf0, 0x10, 0xf0, 0x14, 0x14, 0x14, 0xfc, 0x00, 0x14, 0x14, 0xf7,
82
+ 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0xff, 0x14, 0x14, 0xf4, 0x04, 0xfc, 0x14, 0x14, 0x17, 0x10,
83
+ 0x1f, 0x10, 0x10, 0x1f, 0x10, 0x1f, 0x14, 0x14, 0x14, 0x1f, 0x00, 0x10, 0x10, 0x10, 0xf0, 0x00,
84
+ 0x00, 0x00, 0x00, 0x1f, 0x10, 0x10, 0x10, 0x10, 0x1f, 0x10, 0x10, 0x10, 0x10, 0xf0, 0x10, 0x00,
85
+ 0x00, 0x00, 0xff, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xff, 0x10, 0x00, 0x00,
86
+ 0x00, 0xff, 0x14, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x1f, 0x10, 0x17, 0x00, 0x00, 0xfc,
87
+ 0x04, 0xf4, 0x14, 0x14, 0x17, 0x10, 0x17, 0x14, 0x14, 0xf4, 0x04, 0xf4, 0x00, 0x00, 0xff, 0x00,
88
+ 0xf7, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0xf7, 0x00, 0xf7, 0x14, 0x14, 0x14, 0x17, 0x14,
89
+ 0x10, 0x10, 0x1f, 0x10, 0x1f, 0x14, 0x14, 0x14, 0xf4, 0x14, 0x10, 0x10, 0xf0, 0x10, 0xf0, 0x00,
90
+ 0x00, 0x1f, 0x10, 0x1f, 0x00, 0x00, 0x00, 0x1f, 0x14, 0x00, 0x00, 0x00, 0xfc, 0x14, 0x00, 0x00,
91
+ 0xf0, 0x10, 0xf0, 0x10, 0x10, 0xff, 0x10, 0xff, 0x14, 0x14, 0x14, 0xff, 0x14, 0x10, 0x10, 0x10,
92
+ 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x10, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0,
93
+ 0xf0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
94
+ 0x38, 0x44, 0x44, 0x38, 0x44, 0xfc, 0x4a, 0x4a, 0x4a, 0x34, 0x7e, 0x02, 0x02, 0x06, 0x06, 0x02,
95
+ 0x7e, 0x02, 0x7e, 0x02, 0x63, 0x55, 0x49, 0x41, 0x63, 0x38, 0x44, 0x44, 0x3c, 0x04, 0x40, 0x7e,
96
+ 0x20, 0x1e, 0x20, 0x06, 0x02, 0x7e, 0x02, 0x02, 0x99, 0xa5, 0xe7, 0xa5, 0x99, 0x1c, 0x2a, 0x49,
97
+ 0x2a, 0x1c, 0x4c, 0x72, 0x01, 0x72, 0x4c, 0x30, 0x4a, 0x4d, 0x4d, 0x30, 0x30, 0x48, 0x78, 0x48,
98
+ 0x30, 0xbc, 0x62, 0x5a, 0x46, 0x3d, 0x3e, 0x49, 0x49, 0x49, 0x00, 0x7e, 0x01, 0x01, 0x01, 0x7e,
99
+ 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x44, 0x44, 0x5f, 0x44, 0x44, 0x40, 0x51, 0x4a, 0x44, 0x40, 0x40,
100
+ 0x44, 0x4a, 0x51, 0x40, 0x00, 0x00, 0xff, 0x01, 0x03, 0xe0, 0x80, 0xff, 0x00, 0x00, 0x08, 0x08,
101
+ 0x6b, 0x6b, 0x08, 0x36, 0x12, 0x36, 0x24, 0x36, 0x06, 0x0f, 0x09, 0x0f, 0x06, 0x00, 0x00, 0x18,
102
+ 0x18, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x30, 0x40, 0xff, 0x01, 0x01, 0x00, 0x1f, 0x01, 0x01,
103
+ 0x1e, 0x00, 0x19, 0x1d, 0x17, 0x12, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00,
104
+ ];
105
+ /**
106
+ * Render the font as a C++ byte-array literal (16 bytes per line). Used by
107
+ * adapters that need the table emitted into the synthesized translation unit.
108
+ *
109
+ * Example output:
110
+ * static const uint8_t glcdfont[] = {
111
+ * 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x5b, 0x4f, 0x5b, 0x3e, ...
112
+ * ...
113
+ * };
114
+ */
115
+ export function renderGlcdfontArray(name, type = "uint8_t") {
116
+ const lines = [];
117
+ for (let i = 0; i < GLCDFONT_BYTES.length; i += 16) {
118
+ const row = GLCDFONT_BYTES.slice(i, i + 16)
119
+ .map((b) => "0x" + b.toString(16).padStart(2, "0"))
120
+ .join(", ");
121
+ lines.push(` ${row},`);
122
+ }
123
+ return `static const ${type} ${name}[] = {\n${lines.join("\n")}\n};`;
124
+ }
@@ -1,4 +1,6 @@
1
1
  import type { DisplayHALOp } from "./display-op-ir.js";
2
+ import type { ResolvedDisplay, TouchProfile, TouchAdapterCodegen } from "./display-profile.js";
3
+ import type { DisplayAdapterCode } from "./display-adapter.js";
2
4
  export interface GraphicsCapacity {
3
5
  /** Max nodes the retained tree may hold on this target. */
4
6
  maxNodes: number;
@@ -15,6 +17,32 @@ export interface PlatformGraphicsStrategy {
15
17
  code?: string;
16
18
  expression?: string;
17
19
  } | undefined;
20
+ /**
21
+ * True if this strategy emits its own display adapters (AVR, ESP32). When
22
+ * false or undefined, generateDisplayAdapter() falls back to the built-in
23
+ * Adafruit registry — the Arduino path, unchanged.
24
+ */
25
+ providesDisplayAdapter?(): boolean;
26
+ /**
27
+ * Returns the adapter code for one display, or undefined to defer to the
28
+ * built-in Adafruit registry. Only called when providesDisplayAdapter()
29
+ * returns true.
30
+ */
31
+ resolveDisplayAdapter?(display: ResolvedDisplay): DisplayAdapterCode | undefined;
32
+ /**
33
+ * True if this strategy emits its own touch adapters (ESP32 native). When
34
+ * false or undefined, generateTouchAdapter() falls back to the built-in
35
+ * library switch (the Arduino path, unchanged).
36
+ */
37
+ providesTouchAdapter?(): boolean;
38
+ /**
39
+ * Returns the touch adapter codegen for the given touch profile, or
40
+ * undefined to defer to the built-in library switch. Only called when
41
+ * providesTouchAdapter() returns true. Returning undefined for an
42
+ * unsupported library (e.g. XPT2046 on native IDF) lets the dispatch
43
+ * surface a clear compile-time error instead of emitting incompatible code.
44
+ */
45
+ resolveTouchAdapter?(touch: TouchProfile): TouchAdapterCodegen | undefined;
18
46
  /** Display driver ids this framework provides (e.g. new Set(["ili9341"])). */
19
47
  supportedDisplayDrivers(): ReadonlySet<string>;
20
48
  /** Target color format — drives transpile-time color resolution.