@typecad/cuttlefish 0.1.0-alpha.2 → 1.0.0-alpha.10

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 (222) hide show
  1. package/README.md +10 -10
  2. package/dist/api/board-types.d.ts +1 -1
  3. package/dist/api/config.d.ts +32 -0
  4. package/dist/api/index.d.ts +1 -1
  5. package/dist/api/schema/types.d.ts +15 -0
  6. package/dist/api/shared/async-runtime-static.d.ts +12 -1
  7. package/dist/api/shared/async-runtime-static.js +69 -24
  8. package/dist/api/shared/async-symbol-detector.d.ts +11 -0
  9. package/dist/api/shared/async-symbol-detector.js +140 -0
  10. package/dist/api/shared/async-types.d.ts +24 -0
  11. package/dist/api/shared/coop-scheduler.d.ts +60 -0
  12. package/dist/api/shared/coop-scheduler.js +149 -0
  13. package/dist/api/shared/display-adapter.d.ts +4 -3
  14. package/dist/api/shared/display-adapter.js +15 -118
  15. package/dist/api/shared/display-adapters/sdl.js +38 -31
  16. package/dist/api/shared/display-profile.d.ts +47 -25
  17. package/dist/api/shared/display-profile.js +31 -164
  18. package/dist/api/shared/framework-manifest-registry.d.ts +9 -0
  19. package/dist/api/shared/framework-manifest-registry.js +27 -0
  20. package/dist/api/shared/framework-manifest.d.ts +595 -0
  21. package/dist/api/shared/framework-manifest.js +193 -0
  22. package/dist/api/shared/glcdfont.d.ts +12 -0
  23. package/dist/api/shared/glcdfont.js +124 -0
  24. package/dist/api/shared/graphics-strategy.d.ts +37 -0
  25. package/dist/api/shared/hal-op-ir.d.ts +764 -1
  26. package/dist/api/shared/hal-op-ir.js +129 -1
  27. package/dist/api/shared/index.d.ts +20 -2
  28. package/dist/api/shared/index.js +25 -1
  29. package/dist/api/shared/ir-core.d.ts +4 -0
  30. package/dist/api/shared/ir-declarations.d.ts +6 -0
  31. package/dist/api/shared/native-display-op-resolver.d.ts +10 -0
  32. package/dist/api/shared/native-display-op-resolver.js +64 -0
  33. package/dist/api/shared/platform-strategy.d.ts +119 -2
  34. package/dist/api/shared/polyfill-helper-registry.js +18 -1
  35. package/dist/api/shared/promise-runtime.d.ts +1 -1
  36. package/dist/api/shared/promise-runtime.js +95 -13
  37. package/dist/api/shared/toolchain-types.d.ts +17 -0
  38. package/dist/api/shared/types.d.ts +8 -0
  39. package/dist/api/shared/validate-framework-manifest.d.ts +28 -0
  40. package/dist/api/shared/validate-framework-manifest.js +494 -0
  41. package/dist/api/shared/worker-runtime-polyfill.d.ts +22 -0
  42. package/dist/api/shared/worker-runtime-polyfill.js +34 -0
  43. package/dist/api/shared/worker-runtime.d.ts +69 -0
  44. package/dist/api/shared/worker-runtime.js +163 -0
  45. package/dist/cli-utils.d.ts +1 -0
  46. package/dist/cli-utils.js +3 -1
  47. package/dist/cli.js +249 -32
  48. package/dist/config-loader.d.ts +7 -2
  49. package/dist/config-loader.js +23 -3
  50. package/dist/config-schema.d.ts +112 -70
  51. package/dist/config-schema.js +14 -0
  52. package/dist/contract/board-generator.d.ts +17 -0
  53. package/dist/contract/board-generator.js +57 -0
  54. package/dist/contract/contract-parser.d.ts +217 -0
  55. package/dist/contract/contract-parser.js +224 -0
  56. package/dist/contract/index.d.ts +22 -0
  57. package/dist/contract/index.js +68 -0
  58. package/dist/create/board-codegen.js +4 -4
  59. package/dist/create/board-generators.js +4 -5
  60. package/dist/create/board-spec.d.ts +72 -75
  61. package/dist/create/board-spec.js +0 -1
  62. package/dist/create/framework-catalog.d.ts +64 -0
  63. package/dist/create/framework-catalog.js +136 -0
  64. package/dist/create/index.d.ts +5 -1
  65. package/dist/create/index.js +3 -1
  66. package/dist/create/init-scaffold.d.ts +12 -3
  67. package/dist/create/init-scaffold.js +49 -14
  68. package/dist/create/init-templates.d.ts +4 -0
  69. package/dist/create/init-templates.js +263 -17
  70. package/dist/create/init-wizard.js +41 -27
  71. package/dist/create/install-deps.d.ts +32 -0
  72. package/dist/create/install-deps.js +46 -0
  73. package/dist/debug/preprocessor.js +178 -39
  74. package/dist/debug/types.d.ts +23 -0
  75. package/dist/diagnostics/mermaid-builder.d.ts +1 -1
  76. package/dist/diagnostics/mermaid-builder.js +34 -24
  77. package/dist/emit/compliance/arxml-writer.d.ts +11 -0
  78. package/dist/emit/compliance/arxml-writer.js +34 -0
  79. package/dist/emit/compliance/compliance-context.d.ts +57 -0
  80. package/dist/emit/compliance/compliance-context.js +113 -0
  81. package/dist/emit/compliance/deviation-ledger.d.ts +27 -0
  82. package/dist/emit/compliance/deviation-ledger.js +47 -0
  83. package/dist/emit/compliance/deviation-writer.d.ts +30 -0
  84. package/dist/emit/compliance/deviation-writer.js +37 -0
  85. package/dist/emit/compliance/index.d.ts +7 -0
  86. package/dist/emit/compliance/index.js +6 -0
  87. package/dist/emit/compliance/rule-engine.d.ts +13 -0
  88. package/dist/emit/compliance/rule-engine.js +101 -0
  89. package/dist/emit/compliance/rules.d.ts +16 -0
  90. package/dist/emit/compliance/rules.js +191 -0
  91. package/dist/emit/compliance/types.d.ts +59 -0
  92. package/dist/emit/compliance/types.js +8 -0
  93. package/dist/emit/cpp-emitter.js +4 -3
  94. package/dist/emit/emitters/class-emitter.js +6 -1
  95. package/dist/emit/emitters/emitter-context.d.ts +28 -1
  96. package/dist/emit/emitters/function-emitter-impl.js +153 -53
  97. package/dist/emit/emitters/line-appender.js +19 -0
  98. package/dist/emit/emitters/line-marker.d.ts +38 -0
  99. package/dist/emit/emitters/line-marker.js +39 -0
  100. package/dist/emit/emitters/output-finalizer.d.ts +6 -0
  101. package/dist/emit/emitters/output-finalizer.js +101 -12
  102. package/dist/emit/emitters/setup.d.ts +17 -0
  103. package/dist/emit/emitters/setup.js +372 -30
  104. package/dist/emit/emitters/top-level-prep.js +8 -0
  105. package/dist/emit/emitters/type-decl-emitter.js +28 -3
  106. package/dist/emit/emitters/ui-emitter.js +33 -9
  107. package/dist/emit/expression-renderer.d.ts +1 -1
  108. package/dist/emit/expression-renderer.js +91 -6
  109. package/dist/emit/route-hal-op.js +18 -5
  110. package/dist/emit/snprintf-helpers.js +15 -4
  111. package/dist/emit/statement-renderer.d.ts +10 -0
  112. package/dist/emit/statement-renderer.js +34 -5
  113. package/dist/emit/utils/async-state-machine.js +221 -125
  114. package/dist/emit/utils/hal-op-cpp-type.d.ts +6 -0
  115. package/dist/emit/utils/hal-op-cpp-type.js +40 -0
  116. package/dist/framework-package.js +2 -0
  117. package/dist/framework-registry.d.ts +17 -0
  118. package/dist/install/framework-catalog.d.ts +53 -0
  119. package/dist/install/framework-catalog.js +107 -0
  120. package/dist/install/handle-install.d.ts +35 -0
  121. package/dist/install/handle-install.js +177 -0
  122. package/dist/install/index.d.ts +4 -0
  123. package/dist/install/index.js +3 -0
  124. package/dist/ir/adc-range-validation.js +40 -26
  125. package/dist/ir/build-ir-state.d.ts +1 -0
  126. package/dist/ir/build-ir-state.js +14 -0
  127. package/dist/ir/build-ir.js +9 -5
  128. package/dist/ir/call-graph.js +16 -0
  129. package/dist/ir/expression-to-ir.js +207 -6
  130. package/dist/ir/feature-registry.js +7 -25
  131. package/dist/ir/function-builder.js +22 -0
  132. package/dist/ir/hal/hal-emitter.d.ts +5 -2
  133. package/dist/ir/hal/hal-emitter.js +50 -18
  134. package/dist/ir/hal/hal-parser.d.ts +6 -0
  135. package/dist/ir/hal/hal-parser.js +81 -0
  136. package/dist/ir/hal/hal-plugins.js +733 -1
  137. package/dist/ir/identifier-collector.js +35 -0
  138. package/dist/ir/interrupt-analysis.d.ts +5 -1
  139. package/dist/ir/interrupt-analysis.js +16 -19
  140. package/dist/ir/memory-budget-validation.js +1 -0
  141. package/dist/ir/network-validation.d.ts +4 -0
  142. package/dist/ir/network-validation.js +184 -0
  143. package/dist/ir/ownership-analysis.js +39 -1
  144. package/dist/ir/peripheral-ownership.js +5 -0
  145. package/dist/ir/peripheral-validation.d.ts +1 -1
  146. package/dist/ir/peripheral-validation.js +6 -3
  147. package/dist/ir/pin-alias-conflict.d.ts +1 -1
  148. package/dist/ir/pin-alias-conflict.js +2 -1
  149. package/dist/ir/pin-capability-validation.js +71 -32
  150. package/dist/ir/pin-mode-validation.d.ts +2 -2
  151. package/dist/ir/pin-mode-validation.js +54 -18
  152. package/dist/ir/pin-safety.d.ts +1 -1
  153. package/dist/ir/pin-safety.js +2 -1
  154. package/dist/ir/program-analysis.d.ts +81 -0
  155. package/dist/ir/program-analysis.js +429 -0
  156. package/dist/ir/pulldown-validation.d.ts +1 -1
  157. package/dist/ir/pulldown-validation.js +2 -1
  158. package/dist/ir/pwm-timer-sharing.d.ts +1 -1
  159. package/dist/ir/pwm-timer-sharing.js +2 -1
  160. package/dist/ir/render-expr.js +11 -0
  161. package/dist/ir/resource-analysis.js +2 -0
  162. package/dist/ir/timer0-pwm-timing-conflict.d.ts +1 -1
  163. package/dist/ir/timer0-pwm-timing-conflict.js +2 -1
  164. package/dist/ir/timing-validation.d.ts +6 -1
  165. package/dist/ir/timing-validation.js +61 -13
  166. package/dist/ir/transformers/call-statement.js +105 -0
  167. package/dist/ir/transformers/expressions.js +62 -0
  168. package/dist/ir/transformers/hal-call-resolver.js +21 -0
  169. package/dist/ir/transformers/hal-emit-helpers.js +1 -1
  170. package/dist/ir/transformers/namespace-methods.js +17 -12
  171. package/dist/ir/transformers/ui-reactive.js +2 -2
  172. package/dist/ir/transformers/variables.js +137 -19
  173. package/dist/ir/try-catch-validation.js +2 -0
  174. package/dist/ir/type-resolution.js +20 -2
  175. package/dist/ir/ui-element-auto-wire.js +7 -5
  176. package/dist/ir/unit-suspicion-validation.js +9 -7
  177. package/dist/ir/utils/map-statements.d.ts +4 -0
  178. package/dist/ir/utils/map-statements.js +79 -0
  179. package/dist/ir/validation-orchestrator.js +15 -8
  180. package/dist/ir/worker-analysis.d.ts +10 -0
  181. package/dist/ir/worker-analysis.js +261 -0
  182. package/dist/libdef/c-to-decl.d.ts +27 -0
  183. package/dist/libdef/c-to-decl.js +397 -0
  184. package/dist/libdef/component-decls.d.ts +2 -0
  185. package/dist/libdef/component-decls.js +6 -0
  186. package/dist/libdef/component-discovery.d.ts +43 -0
  187. package/dist/libdef/component-discovery.js +83 -0
  188. package/dist/libdef/cpp-to-decl.d.ts +9 -0
  189. package/dist/libdef/cpp-to-decl.js +72 -0
  190. package/dist/libdef/registry.js +5 -2
  191. package/dist/lint-cache.d.ts +59 -0
  192. package/dist/lint-cache.js +257 -0
  193. package/dist/orchestrator/graph-builder.js +14 -9
  194. package/dist/platform/coop-scheduler-runtime.d.ts +19 -0
  195. package/dist/platform/coop-scheduler-runtime.js +41 -0
  196. package/dist/platform/generic-strategy.d.ts +15 -3
  197. package/dist/platform/generic-strategy.js +49 -4
  198. package/dist/safety/safety-bridge.d.ts +11 -0
  199. package/dist/safety/safety-bridge.js +48 -0
  200. package/dist/safety/sidecar-bridge.d.ts +5 -0
  201. package/dist/safety/sidecar-bridge.js +22 -0
  202. package/dist/safety-hook.d.ts +79 -0
  203. package/dist/safety-hook.js +35 -0
  204. package/dist/testing.d.ts +8 -2
  205. package/dist/testing.js +9 -2
  206. package/dist/transpile.d.ts +3 -0
  207. package/dist/transpile.js +191 -49
  208. package/dist/types.d.ts +22 -3
  209. package/dist/ui-hook.d.ts +17 -3
  210. package/dist/utils/cli.js +122 -2
  211. package/dist/utils/fs.d.ts +13 -0
  212. package/dist/utils/fs.js +50 -0
  213. package/dist/utils/ui.js +3 -1
  214. package/package.json +23 -3
  215. package/dist/api/shared/display-adapters/eink-mono.d.ts +0 -2
  216. package/dist/api/shared/display-adapters/eink-mono.js +0 -53
  217. package/dist/api/shared/display-adapters/ssd1309.d.ts +0 -2
  218. package/dist/api/shared/display-adapters/ssd1309.js +0 -136
  219. package/dist/api/shared/display-adapters/st7796.d.ts +0 -2
  220. package/dist/api/shared/display-adapters/st7796.js +0 -132
  221. package/dist/ir/heap-array-validation.d.ts +0 -24
  222. package/dist/ir/heap-array-validation.js +0 -29
@@ -1,136 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // SSD1309 OLED display adapter — 1-bit monochrome OLED panels over I2C.
3
- //
4
- // Targets the Adafruit_SSD1306 library (which supports SSD1309 via the same
5
- // API). The SSD1306 is a page-buffered Adafruit_GFX subclass: draw into its
6
- // buffer via drawPixel/fillRect, then call display() to flush over I2C.
7
- // Colors are 1-bit (SSD1306_WHITE / SSD1306_BLACK). The runtime's
8
- // UI_NATIVE_MONO snap converts 565 → black/white at the draw choke points.
9
- //
10
- // The SSD1306 IS the backing store (its internal buffer), so this adapter
11
- // follows the e-ink deferred-refresh pattern: the runtime draws dirty rects
12
- // into the buffer, then display_partial_refresh() flushes. The SSD1306 has
13
- // no true partial refresh — display() flushes the full page buffer — but
14
- // the dirty-rect tracking still minimizes draw calls into the buffer.
15
- //
16
- // I2C wiring: SDA/SCL (Wire bus) + reset pin + I2C address (default 0x3C).
17
- // ---------------------------------------------------------------------------
18
- export const ssd1309Adapter = (display) => {
19
- const w = display.width;
20
- const h = display.height;
21
- const reset = display._mountReset;
22
- const address = display._mountAddress;
23
- const rotation = display.rotation ?? 0;
24
- return {
25
- includes: [
26
- `#define CuttlefishDisplayTarget Adafruit_GFX`,
27
- `#define CuttlefishCanvas16 GFXcanvas16`,
28
- `#define SSD1306_NO_SPLASH`,
29
- `#include <Adafruit_GFX.h>`,
30
- `#include <Adafruit_SSD1306.h>`,
31
- `#include <Wire.h>`,
32
- ].join("\n"),
33
- // I2C constructor: Adafruit_SSD1306(width, height, &Wire, resetPin)
34
- declaration: `Adafruit_SSD1306 __tc_display(${w}, ${h}, &Wire, ${reset});`,
35
- functions: [
36
- `// --- Display adapter: SSD1309 OLED (1-bit mono, I2C, page-buffered) ---`,
37
- `static inline void display_init() {`,
38
- ` // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally.`,
39
- ` __tc_display.begin(SSD1306_SWITCHCAPVCC, 0x${address.toString(16)});`,
40
- ` __tc_display.setRotation(${rotation});`,
41
- ` __tc_display.clearDisplay();`,
42
- ` __tc_display.display();`,
43
- `}`,
44
- ``,
45
- `static inline void display_fillScreen(uint32_t color) {`,
46
- ` __tc_display.fillScreen(color ? SSD1306_WHITE : SSD1306_BLACK);`,
47
- `}`,
48
- `static inline CuttlefishDisplayTarget* display_defaultTarget() { return &__tc_display; }`,
49
- `static inline int16_t display_width() { return __tc_display.width(); }`,
50
- `static inline int16_t display_height() { return __tc_display.height(); }`,
51
- `static inline void display_startWrite() {}`,
52
- `static inline void display_endWrite() {}`,
53
- `static int16_t __ssd1309_addr_x = 0;`,
54
- `static int16_t __ssd1309_addr_y = 0;`,
55
- `static int16_t __ssd1309_addr_w = 0;`,
56
- `static int16_t __ssd1309_addr_h = 0;`,
57
- `static uint32_t __ssd1309_addr_cursor = 0;`,
58
- `static inline void display_setAddrWindow(int16_t x, int16_t y, int16_t w, int16_t h) {`,
59
- ` __ssd1309_addr_x = x;`,
60
- ` __ssd1309_addr_y = y;`,
61
- ` __ssd1309_addr_w = w;`,
62
- ` __ssd1309_addr_h = h;`,
63
- ` __ssd1309_addr_cursor = 0;`,
64
- `}`,
65
- `static inline void display_writePixels(UI_COLOR_T* pixels, uint32_t count) {`,
66
- ` // SSD1306 is page-buffered — write into the GFX buffer via drawPixel.`,
67
- ` if (__ssd1309_addr_w <= 0 || __ssd1309_addr_h <= 0) return;`,
68
- ` uint32_t windowPixels = (uint32_t)__ssd1309_addr_w * (uint32_t)__ssd1309_addr_h;`,
69
- ` for (uint32_t i = 0; i < count; i++) {`,
70
- ` if (__ssd1309_addr_cursor >= windowPixels) break;`,
71
- ` uint32_t pos = __ssd1309_addr_cursor++;`,
72
- ` int16_t px = (int16_t)(__ssd1309_addr_x + (int16_t)(pos % (uint32_t)__ssd1309_addr_w));`,
73
- ` int16_t py = (int16_t)(__ssd1309_addr_y + (int16_t)(pos / (uint32_t)__ssd1309_addr_w));`,
74
- ` __tc_display.drawPixel(px, py, pixels[i] ? SSD1306_WHITE : SSD1306_BLACK);`,
75
- ` }`,
76
- `}`,
77
- ``,
78
- `// The SSD1306 has no true partial refresh — display() flushes the full`,
79
- `// page buffer. The runtime's dirty-rect tracking still minimizes the draw`,
80
- `// calls INTO the buffer (only dirty nodes are redrawn); this just publishes`,
81
- `// the result. Called once per frame after the dirty-rect union is drawn.`,
82
- `static inline void display_partial_refresh(int16_t x, int16_t y, int16_t w, int16_t h) {`,
83
- ` (void)x; (void)y; (void)w; (void)h;`,
84
- ` __tc_display.display();`,
85
- `}`,
86
- // ── Canvas (offscreen GFXcanvas16 for AA text / scroll compositing) ──
87
- `static inline uint16_t ssd_mono(uint16_t c);`,
88
- `static inline CuttlefishCanvas16* display_createCanvas(int16_t w, int16_t h) { return new GFXcanvas16(w, h); }`,
89
- `static inline CuttlefishCanvas16* display_createCanvasPsram(int16_t w, int16_t h) {`,
90
- `#if defined(ESP32) && defined(BOARD_HAS_PSRAM)`,
91
- ` return new (ps_malloc(sizeof(GFXcanvas16))) GFXcanvas16(w, h);`,
92
- `#else`,
93
- ` (void)w; (void)h;`,
94
- ` return nullptr;`,
95
- `#endif`,
96
- `}`,
97
- `static inline void display_deleteCanvas(CuttlefishCanvas16* canvas) { delete canvas; }`,
98
- `static inline int16_t display_canvasWidth(CuttlefishCanvas16* c) { return c->width(); }`,
99
- `static inline int16_t display_canvasHeight(CuttlefishCanvas16* c) { return c->height(); }`,
100
- `static inline uint16_t* display_canvasBuffer(CuttlefishCanvas16* c) { return c->getBuffer(); }`,
101
- `static inline uint16_t display_canvasGetPixel(CuttlefishCanvas16* c, int16_t x, int16_t y) { return c->getPixel(x, y); }`,
102
- `static inline void display_canvasFillScreen(CuttlefishCanvas16* c, UI_COLOR_T color) { c->fillScreen(ssd_mono((uint16_t)color)); }`,
103
- `static inline void display_canvasFillRect(CuttlefishCanvas16* c, int16_t x, int16_t y, int16_t w, int16_t h, UI_COLOR_T color) { c->fillRect(x, y, w, h, ssd_mono((uint16_t)color)); }`,
104
- // ── Color conversion: runtime uses 0xffff/0x0000 (565 mono snap), but the
105
- // SSD1306's drawPixel switch only accepts 0/1/2. Convert any nonzero to 1. ──
106
- `static inline uint16_t ssd_mono(uint16_t c) { return c ? SSD1306_WHITE : SSD1306_BLACK; }`,
107
- // ── Target-polymorphic draw (panel + canvas share CuttlefishDisplayTarget*) ──
108
- `static inline void display_targetDrawPixel(CuttlefishDisplayTarget* t, int16_t x, int16_t y, UI_COLOR_T color) { t->drawPixel(x, y, ssd_mono((uint16_t)color)); }`,
109
- `static inline int16_t display_targetWidth(CuttlefishDisplayTarget* t) { return t->width(); }`,
110
- `static inline int16_t display_targetHeight(CuttlefishDisplayTarget* t) { return t->height(); }`,
111
- `static inline void display_targetDrawRGBBitmap(CuttlefishDisplayTarget* t, int16_t x, int16_t y, const UI_COLOR_T* b, int16_t w, int16_t h) {`,
112
- ` if (!b || w <= 0 || h <= 0) return;`,
113
- ` for (int16_t yy = 0; yy < h; yy++) {`,
114
- ` for (int16_t xx = 0; xx < w; xx++) {`,
115
- ` t->drawPixel((int16_t)(x + xx), (int16_t)(y + yy), ssd_mono((uint16_t)b[(int32_t)yy * w + xx]));`,
116
- ` }`,
117
- ` }`,
118
- `}`,
119
- `static inline void display_targetFillRect(CuttlefishDisplayTarget* t, int16_t x, int16_t y, int16_t w, int16_t h, UI_COLOR_T color) { t->fillRect(x, y, w, h, ssd_mono((uint16_t)color)); }`,
120
- `static inline void display_targetDrawFastHLine(CuttlefishDisplayTarget* t, int16_t x, int16_t y, int16_t w, UI_COLOR_T color) { t->drawFastHLine(x, y, w, ssd_mono((uint16_t)color)); }`,
121
- `static inline void display_targetDrawFastVLine(CuttlefishDisplayTarget* t, int16_t x, int16_t y, int16_t h, UI_COLOR_T color) { t->drawFastVLine(x, y, h, ssd_mono((uint16_t)color)); }`,
122
- `static inline void display_targetFillRoundRect(CuttlefishDisplayTarget* t, int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, UI_COLOR_T color) { t->fillRoundRect(x, y, w, h, r, ssd_mono((uint16_t)color)); }`,
123
- `static inline void display_targetDrawRect(CuttlefishDisplayTarget* t, int16_t x, int16_t y, int16_t w, int16_t h, UI_COLOR_T color) { t->drawRect(x, y, w, h, ssd_mono((uint16_t)color)); }`,
124
- `static inline void display_targetDrawRoundRect(CuttlefishDisplayTarget* t, int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, UI_COLOR_T color) { t->drawRoundRect(x, y, w, h, r, ssd_mono((uint16_t)color)); }`,
125
- `static inline void display_targetDrawLine(CuttlefishDisplayTarget* t, int16_t x0, int16_t y0, int16_t x1, int16_t y1, UI_COLOR_T color) { t->drawLine(x0, y0, x1, y1, ssd_mono((uint16_t)color)); }`,
126
- `static inline void display_targetFillCircle(CuttlefishDisplayTarget* t, int16_t x, int16_t y, int16_t r, UI_COLOR_T color) { t->fillCircle(x, y, r, ssd_mono((uint16_t)color)); }`,
127
- `static inline void display_targetDrawCircle(CuttlefishDisplayTarget* t, int16_t x, int16_t y, int16_t r, UI_COLOR_T color) { t->drawCircle(x, y, r, ssd_mono((uint16_t)color)); }`,
128
- `static inline void display_targetSetCursor(CuttlefishDisplayTarget* t, int16_t x, int16_t y) { t->setCursor(x, y); }`,
129
- `static inline void display_targetSetTextColor(CuttlefishDisplayTarget* t, UI_COLOR_T fg) { t->setTextColor(ssd_mono((uint16_t)fg)); }`,
130
- `static inline void display_targetSetTextColorBg(CuttlefishDisplayTarget* t, UI_COLOR_T fg, UI_COLOR_T bg) { t->setTextColor(ssd_mono((uint16_t)fg), ssd_mono((uint16_t)bg)); }`,
131
- `static inline void display_targetSetTextSize(CuttlefishDisplayTarget* t, uint8_t s) { t->setTextSize(s); }`,
132
- `static inline void display_targetSetTextWrap(CuttlefishDisplayTarget* t, bool w) { t->setTextWrap(w); }`,
133
- `static inline void display_targetPrint(CuttlefishDisplayTarget* t, const char* s) { t->print(s); }`,
134
- ].join("\n"),
135
- };
136
- };
@@ -1,2 +0,0 @@
1
- import type { DisplayAdapterGenerator } from "../display-adapter.js";
2
- export declare const st7796Adapter: DisplayAdapterGenerator;
@@ -1,132 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // ST7796S display adapter — targets the Adafruit_ST7735_and_ST7789_Library
3
- // fork that exposes the Adafruit_ST7796S class (320×480 SPI TFT).
4
- //
5
- // Color mode: RGB565 only. The Adafruit_ST7796S init sequence hardcodes
6
- // ST77XX_COLMOD = 0x55 (16-bit/pixel). RGB666/18-bit would require patching
7
- // the library's init array (0x55 → 0x66) AND overriding Adafruit_SPITFT's
8
- // 565-native writePixels — out of scope for v1. Requesting rgb666 throws.
9
- //
10
- // Init API: Adafruit_ST7796S requires init(w,h,rowOff,colOff,colorOrder) to
11
- // send the panel init sequence. begin(freq) alone would skip it (blank panel).
12
- // SPI frequency handling: init() runs the panel command sequence and initializes
13
- // Adafruit_SPITFT. If the profile requests a frequency, update the transaction
14
- // settings with setSPISpeed() after init; do not call initSPI() a second time.
15
- // ---------------------------------------------------------------------------
16
- export const st7796Adapter = (display) => {
17
- const cs = display._mountCs;
18
- const dc = display._mountDc;
19
- const rst = display._mountRst;
20
- const rotation = display.rotation ?? 1;
21
- const spiFreq = display.spiFrequency;
22
- const invertDisplay = display.invertDisplay;
23
- const colorOrder = display.colorOrder === "bgr" ? "ST7796S_BGR" : "ST7796S_RGB";
24
- if (display.colorFormat === "rgb666" || display.colorFormat === "rgb888") {
25
- throw new Error(`RGB666/RGB888 is not supported by the Adafruit_ST7796S library: ` +
26
- `its init sequence hardcodes COLMOD=0x55 (RGB565). Use colorFormat: "rgb565". ` +
27
- `True 18-bit support requires patching the library init array and overriding ` +
28
- `Adafruit_SPITFT's 565-native writePixels — tracked as a follow-up.`);
29
- }
30
- const includes = [
31
- "#define CuttlefishDisplayTarget Adafruit_GFX",
32
- "#define CuttlefishCanvas16 GFXcanvas16",
33
- "#include <Adafruit_GFX.h>",
34
- "#include <Adafruit_ST7796S.h>",
35
- ].join("\n");
36
- const inversionLines = invertDisplay === undefined
37
- ? []
38
- : [
39
- ` __tc_display.startWrite();`,
40
- ` __tc_display.writeCommand(${invertDisplay ? "ST77XX_INVON" : "ST77XX_INVOFF"});`,
41
- ` __tc_display.endWrite();`,
42
- ];
43
- return {
44
- includes,
45
- declaration: `Adafruit_ST7796S __tc_display = Adafruit_ST7796S(${cs}, ${dc}, ${rst});`,
46
- functions: [
47
- `// --- Display adapter: ST7796S (RGB565) ---`,
48
- `static inline void display_init() {`,
49
- ` __tc_display.init(320, 480, 0, 0, ${colorOrder});`,
50
- spiFreq ? ` __tc_display.setSPISpeed(${spiFreq});` : ``,
51
- ...inversionLines,
52
- ` __tc_display.setRotation(${rotation});`,
53
- ` __tc_display.fillScreen(0x0000);`,
54
- `}`,
55
- ``,
56
- `static inline void display_fillScreen(UI_COLOR_T color) { __tc_display.fillScreen((uint16_t)color); }`,
57
- `static inline CuttlefishDisplayTarget* display_defaultTarget() { return &__tc_display; }`,
58
- `static inline int16_t display_width() { return __tc_display.width(); }`,
59
- `static inline int16_t display_height() { return __tc_display.height(); }`,
60
- ``,
61
- `static inline void display_startWrite() { __tc_display.startWrite(); }`,
62
- `static inline void display_endWrite() { __tc_display.endWrite(); }`,
63
- `static inline void display_setAddrWindow(int16_t x, int16_t y, int16_t w, int16_t h) {`,
64
- ` __tc_display.setAddrWindow(x, y, w, h);`,
65
- `}`,
66
- `static inline void display_writePixels(uint16_t* pixels, uint32_t count) {`,
67
- ` __tc_display.writePixels(pixels, count);`,
68
- `}`,
69
- ``,
70
- `static inline CuttlefishCanvas16* display_createCanvas(int16_t w, int16_t h) {`,
71
- ` return new GFXcanvas16(w, h);`,
72
- `}`,
73
- `static inline CuttlefishCanvas16* display_createCanvasPsram(int16_t w, int16_t h) {`,
74
- `#if defined(ESP32) && defined(BOARD_HAS_PSRAM)`,
75
- ` return new (ps_malloc(sizeof(GFXcanvas16))) GFXcanvas16(w, h);`,
76
- `#else`,
77
- ` (void)w; (void)h;`,
78
- ` return nullptr;`,
79
- `#endif`,
80
- `}`,
81
- `static inline void display_deleteCanvas(CuttlefishCanvas16* canvas) { delete canvas; }`,
82
- `static inline int16_t display_canvasWidth(CuttlefishCanvas16* canvas) { return canvas->width(); }`,
83
- `static inline int16_t display_canvasHeight(CuttlefishCanvas16* canvas) { return canvas->height(); }`,
84
- `static inline uint16_t* display_canvasBuffer(CuttlefishCanvas16* canvas) { return canvas->getBuffer(); }`,
85
- `static inline uint16_t display_canvasGetPixel(CuttlefishCanvas16* canvas, int16_t x, int16_t y) { return canvas->getPixel(x, y); }`,
86
- `static inline void display_canvasFillScreen(CuttlefishCanvas16* canvas, UI_COLOR_T color) { canvas->fillScreen((uint16_t)color); }`,
87
- `static inline void display_canvasFillRect(CuttlefishCanvas16* canvas, int16_t x, int16_t y, int16_t w, int16_t h, UI_COLOR_T color) {`,
88
- ` canvas->fillRect(x, y, w, h, (uint16_t)color);`,
89
- `}`,
90
- ``,
91
- `static inline void display_targetDrawPixel(CuttlefishDisplayTarget* target, int16_t x, int16_t y, UI_COLOR_T color) { target->drawPixel(x, y, (uint16_t)color); }`,
92
- `static inline int16_t display_targetWidth(CuttlefishDisplayTarget* target) { return target->width(); }`,
93
- `static inline int16_t display_targetHeight(CuttlefishDisplayTarget* target) { return target->height(); }`,
94
- `static inline void display_targetDrawRGBBitmap(CuttlefishDisplayTarget* target, int16_t x, int16_t y, const uint16_t* bitmap, int16_t w, int16_t h) {`,
95
- ` target->drawRGBBitmap(x, y, bitmap, w, h);`,
96
- `}`,
97
- `static inline void display_targetFillRect(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t w, int16_t h, UI_COLOR_T color) {`,
98
- ` target->fillRect(x, y, w, h, (uint16_t)color);`,
99
- `}`,
100
- `static inline void display_targetDrawFastHLine(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t w, UI_COLOR_T color) {`,
101
- ` target->drawFastHLine(x, y, w, (uint16_t)color);`,
102
- `}`,
103
- `static inline void display_targetDrawFastVLine(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t h, UI_COLOR_T color) {`,
104
- ` target->drawFastVLine(x, y, h, (uint16_t)color);`,
105
- `}`,
106
- `static inline void display_targetFillRoundRect(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, UI_COLOR_T color) {`,
107
- ` target->fillRoundRect(x, y, w, h, r, (uint16_t)color);`,
108
- `}`,
109
- `static inline void display_targetDrawRect(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t w, int16_t h, UI_COLOR_T color) {`,
110
- ` target->drawRect(x, y, w, h, (uint16_t)color);`,
111
- `}`,
112
- `static inline void display_targetDrawRoundRect(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, UI_COLOR_T color) {`,
113
- ` target->drawRoundRect(x, y, w, h, r, (uint16_t)color);`,
114
- `}`,
115
- `static inline void display_targetDrawLine(CuttlefishDisplayTarget* target, int16_t x0, int16_t y0, int16_t x1, int16_t y1, UI_COLOR_T color) {`,
116
- ` target->drawLine(x0, y0, x1, y1, (uint16_t)color);`,
117
- `}`,
118
- `static inline void display_targetFillCircle(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t r, UI_COLOR_T color) {`,
119
- ` target->fillCircle(x, y, r, (uint16_t)color);`,
120
- `}`,
121
- `static inline void display_targetDrawCircle(CuttlefishDisplayTarget* target, int16_t x, int16_t y, int16_t r, UI_COLOR_T color) {`,
122
- ` target->drawCircle(x, y, r, (uint16_t)color);`,
123
- `}`,
124
- `static inline void display_targetSetCursor(CuttlefishDisplayTarget* target, int16_t x, int16_t y) { target->setCursor(x, y); }`,
125
- `static inline void display_targetSetTextColor(CuttlefishDisplayTarget* target, UI_COLOR_T fg) { target->setTextColor((uint16_t)fg); }`,
126
- `static inline void display_targetSetTextColorBg(CuttlefishDisplayTarget* target, UI_COLOR_T fg, UI_COLOR_T bg) { target->setTextColor((uint16_t)fg, (uint16_t)bg); }`,
127
- `static inline void display_targetSetTextSize(CuttlefishDisplayTarget* target, uint8_t size) { target->setTextSize(size); }`,
128
- `static inline void display_targetSetTextWrap(CuttlefishDisplayTarget* target, bool wrap) { target->setTextWrap(wrap); }`,
129
- `static inline void display_targetPrint(CuttlefishDisplayTarget* target, const char* text) { target->print(text); }`,
130
- ].join("\n"),
131
- };
132
- };
@@ -1,24 +0,0 @@
1
- import type { Diagnostic } from '../types.js';
2
- import type { BoardConstants } from './board-resolver.js';
3
- import type { StatementIR } from '../api/index.js';
4
- import type { PlatformStrategy } from '../api/shared/index.js';
5
- /**
6
- * @deprecated Heap allocation is now validated at emit time by the platform
7
- * strategy's `profileDiagnostics` (see framework-arduino `collectHeapAllocationDiagnostics`).
8
- * This build-time stub returns no diagnostics. Kept to preserve the
9
- * `validation-orchestrator.ts` import; remove that call site when convenient.
10
- */
11
- export declare function validateHeapArrayUsage(_program: {
12
- topLevelStatements: StatementIR[];
13
- functions: Array<{
14
- statements: StatementIR[];
15
- }>;
16
- classes: Array<{
17
- methods: Array<{
18
- statements: StatementIR[];
19
- }>;
20
- constructor?: {
21
- statements: StatementIR[];
22
- };
23
- }>;
24
- }, _boardConstants: BoardConstants | undefined, _strategy?: PlatformStrategy): Diagnostic[];
@@ -1,29 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // Heap Allocation Validator (retired — moved to the emit-time profile gate)
3
- //
4
- // Heap allocation via `new` on no-heap architectures (AVR, etc.) is now
5
- // rejected by the Arduino strategy's `profileDiagnostics`
6
- // (`framework-arduino/src/strategy.ts` `collectHeapAllocationDiagnostics`).
7
- //
8
- // WHY THE MOVE: this build-time validator keyed off `boardConstants.architecture`,
9
- // which is only populated when an MCU/board `import` is present. Programs with
10
- // no such import silently bypassed it — so demo #33's `new Accumulator()`
11
- // passed while a HAL-importing demo's `new Blinker()` failed, for the same
12
- // source pattern. The profile-time gate derives `arch` from the FQBN
13
- // (`frameworkData.buildTarget`), so it fires regardless of import structure
14
- // (demo #34 Finding A). It also keys off the `newClassName` marker a user-class
15
- // `new` tags its raw IR node with (set in `expression-to-ir.ts`), making
16
- // detection structural rather than textual.
17
- //
18
- // The export is kept (returns `[]`) so `validation-orchestrator.ts`'s import
19
- // stays valid; the real work happens at emit time.
20
- // ---------------------------------------------------------------------------
21
- /**
22
- * @deprecated Heap allocation is now validated at emit time by the platform
23
- * strategy's `profileDiagnostics` (see framework-arduino `collectHeapAllocationDiagnostics`).
24
- * This build-time stub returns no diagnostics. Kept to preserve the
25
- * `validation-orchestrator.ts` import; remove that call site when convenient.
26
- */
27
- export function validateHeapArrayUsage(_program, _boardConstants, _strategy) {
28
- return [];
29
- }