@typecad/ui 1.0.0-alpha.11 → 1.0.0-alpha.12

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.
@@ -0,0 +1,207 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Display + touch hardware catalog for the @typecad/ui integration wizard.
3
+ //
4
+ // Mirrors the built-in display profiles exported by @typecad/framework-arduino
5
+ // (src/displays/*.ts — BUILT_IN_PROFILES) and the TouchLibrary union in
6
+ // @typecad/cuttlefish's display-profile.ts. The wizard asks questions and
7
+ // fills defaults from these entries; the resulting object literal is written
8
+ // into the project's cuttlefish.config.ts `display` section.
9
+ //
10
+ // Keep this catalog in sync with the framework's BUILT_IN_PROFILES when a
11
+ // display or touch library is added there.
12
+ // ---------------------------------------------------------------------------
13
+ export const DISPLAY_CATALOG = [
14
+ {
15
+ id: "ili9341-spi",
16
+ label: "ILI9341 320×240 SPI TFT",
17
+ hint: '2.2"–3.2" color TFT modules, often with resistive touch',
18
+ profile: "ili9341-spi",
19
+ bus: "spi",
20
+ defaults: {
21
+ // ESP32 VSPI wiring used by the repo demos and the framework profile.
22
+ cs: 5,
23
+ dc: 21,
24
+ rst: 22,
25
+ // The ILI9341 built-in profile drives backlight GPIO 17 when the config
26
+ // omits `backlight` — surface that in the wizard's blank-answer hint.
27
+ backlightProfileDefault: 17,
28
+ spiFrequency: 40_000_000,
29
+ width: 320,
30
+ height: 240,
31
+ rotation: 1,
32
+ colorOrder: "rgb",
33
+ antialias: true,
34
+ },
35
+ arduinoLibraries: ["Adafruit GFX Library", "Adafruit ILI9341"],
36
+ wiringNote: "Defaults assume ESP32 VSPI: SCK=18, MOSI=23, MISO=19.",
37
+ },
38
+ {
39
+ id: "st7796-spi",
40
+ label: "ST7796S 320×480 SPI TFT",
41
+ hint: '3.5"/4" color TFT modules, often with FT6336U capacitive touch',
42
+ profile: "st7796-spi",
43
+ bus: "spi",
44
+ defaults: {
45
+ // Wiring proven on the repo's ESP32-S3 demo hardware (demos/demo-st).
46
+ cs: 5,
47
+ dc: 17,
48
+ rst: 16,
49
+ backlight: null,
50
+ spiFrequency: 80_000_000,
51
+ width: 480,
52
+ height: 320,
53
+ nativeWidth: 320,
54
+ nativeHeight: 480,
55
+ rotation: 1,
56
+ colorOrder: "bgr",
57
+ invert: false,
58
+ antialias: true,
59
+ },
60
+ arduinoLibraries: ["Adafruit GFX Library", "Adafruit ST7735 and ST7789 Library"],
61
+ wiringNote: "Defaults assume ESP32 VSPI: SCK=18, MOSI=23, MISO=19. Adafruit_ST7796S.h comes from the" +
62
+ " Adafruit_ST7735_and_ST7789 fork bundled in the typecode demos (demos/demo-st/lib) —" +
63
+ " copy it into your sketchbook libraries/ if your Library Manager copy lacks the class.",
64
+ },
65
+ {
66
+ id: "ssd1309-i2c",
67
+ label: "SSD1309 128×64 monochrome OLED (I2C)",
68
+ hint: "1-bit OLED panels driven via the Adafruit_SSD1306 API",
69
+ profile: "ssd1309-i2c",
70
+ bus: "i2c",
71
+ defaults: {
72
+ address: 0x3c,
73
+ width: 128,
74
+ height: 64,
75
+ rotation: 0,
76
+ antialias: false,
77
+ },
78
+ arduinoLibraries: ["Adafruit GFX Library", "Adafruit SSD1306"],
79
+ },
80
+ {
81
+ id: "sdl",
82
+ label: "Desktop simulator window (no hardware)",
83
+ hint: "native target — renders your UI in an SDL2 window",
84
+ driver: "sdl",
85
+ bus: "none",
86
+ defaults: {
87
+ width: 320,
88
+ height: 240,
89
+ rotation: 0,
90
+ antialias: true,
91
+ },
92
+ },
93
+ {
94
+ id: "custom",
95
+ label: "Custom display — enter driver, bus, and pins manually",
96
+ hint: "any controller not listed above",
97
+ bus: "spi",
98
+ defaults: {},
99
+ },
100
+ ];
101
+ export const TOUCH_CATALOG = [
102
+ {
103
+ id: "none",
104
+ label: "No touch (display only)",
105
+ hint: "skip touch configuration",
106
+ kind: "none",
107
+ defaults: {},
108
+ },
109
+ {
110
+ id: "XPT2046_Touchscreen",
111
+ label: "XPT2046 resistive (SPI)",
112
+ hint: "the resistive controller on most ILI9341 modules",
113
+ kind: "spi",
114
+ defaults: {
115
+ cs: 15,
116
+ // Typical raw-ADC range for 320×240 modules; refine per panel.
117
+ calibration: { xMin: 375, xMax: 3950, yMin: 200, yMax: 3750 },
118
+ },
119
+ arduinoLibrary: "XPT2046_Touchscreen",
120
+ },
121
+ {
122
+ id: "FT6336U",
123
+ label: "FT6336U capacitive (I2C)",
124
+ hint: "on many ST7796S 320×480 modules",
125
+ kind: "i2c",
126
+ defaults: {
127
+ i2cAddress: 0x38,
128
+ i2cFrequency: 400_000,
129
+ },
130
+ // The framework's FT6336U adapter includes RAK14014_FT6336U.h.
131
+ arduinoLibrary: "RAK14014-FT6336U",
132
+ },
133
+ {
134
+ id: "GT911",
135
+ label: "GT911 capacitive (I2C)",
136
+ hint: "common on larger IPS panels",
137
+ kind: "i2c",
138
+ defaults: {
139
+ i2cAddress: 0x5d,
140
+ i2cFrequency: 400_000,
141
+ },
142
+ arduinoLibrary: "GT911",
143
+ },
144
+ {
145
+ id: "CST816S",
146
+ label: "CST816S capacitive (I2C)",
147
+ hint: "on many compact ESP32 display boards",
148
+ kind: "i2c",
149
+ defaults: {
150
+ i2cAddress: 0x15,
151
+ i2cFrequency: 400_000,
152
+ },
153
+ arduinoLibrary: "CST816S",
154
+ },
155
+ {
156
+ id: "Adafruit_TouchScreen",
157
+ label: "Adafruit 4-wire resistive (analog pins)",
158
+ hint: '2.4"/2.8" Adafruit shields with XP/YP/XM/YM analog pins',
159
+ kind: "analog",
160
+ defaults: {
161
+ analogPins: { xp: 24, yp: 25, xm: 26, ym: 27, rx: 300 },
162
+ calibration: { xMin: 100, xMax: 900, yMin: 120, yMax: 900 },
163
+ },
164
+ arduinoLibrary: "Adafruit TouchScreen",
165
+ },
166
+ {
167
+ id: "Adafruit_STMPE610",
168
+ label: "STMPE610 resistive (SPI)",
169
+ hint: 'Adafruit 2.8" TFT touch cape controller',
170
+ kind: "spi",
171
+ defaults: {
172
+ cs: 14,
173
+ calibration: { xMin: 375, xMax: 3950, yMin: 200, yMax: 3750 },
174
+ },
175
+ arduinoLibrary: "Adafruit STMPE610",
176
+ },
177
+ {
178
+ id: "adapter",
179
+ label: "Custom touch adapter file",
180
+ hint: "path to your own TypeScript adapter",
181
+ kind: "adapter",
182
+ defaults: {},
183
+ },
184
+ ];
185
+ /**
186
+ * Collect GPIO collisions between the display wiring and the touch wiring so
187
+ * the wizard can warn before writing the config (a shared pin is almost
188
+ * always a mis-entered default rather than real hardware).
189
+ */
190
+ export function findPinConflicts(displayPins, touchPins) {
191
+ const conflicts = [];
192
+ const claimed = new Map();
193
+ for (const [displayKey, displayValue] of Object.entries(displayPins)) {
194
+ if (displayValue === undefined)
195
+ continue;
196
+ claimed.set(displayValue, displayKey);
197
+ }
198
+ for (const [touchKey, touchValue] of Object.entries(touchPins)) {
199
+ if (touchValue === undefined)
200
+ continue;
201
+ const owner = claimed.get(touchValue);
202
+ if (owner !== undefined) {
203
+ conflicts.push(`display.${owner} and touch.${touchKey} are both wired to GPIO ${touchValue}`);
204
+ }
205
+ }
206
+ return conflicts;
207
+ }
@@ -0,0 +1,7 @@
1
+ export { DISPLAY_CATALOG, TOUCH_CATALOG, findPinConflicts, } from "./display-catalog.js";
2
+ export type { DisplayCatalogEntry, TouchCatalogEntry, WizardBus, WizardTouchKind, } from "./display-catalog.js";
3
+ export { findCuttlefishConfig, findSyntaxError, readConfigSection, readEntryPath, renderDisplayBody, renderDisplayProperty, upsertDisplaySection, } from "./config-writer.js";
4
+ export type { ConfigRecord, RenderDisplayOptions, UpsertDisplayResult, } from "./config-writer.js";
5
+ export { renderStarterUi } from "./starter-ui.js";
6
+ export { runIntegrationWizard } from "./integration-wizard.js";
7
+ export type { WizardRunResult, WizardStreams } from "./integration-wizard.js";
@@ -0,0 +1,10 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Public surface of the @typecad/ui integration wizard (`npx @typecad/ui
3
+ // --config`). Pure helpers (catalog, rendering, config splicing, starter
4
+ // template) are exported for tests and tooling; the interactive flow lives in
5
+ // integration-wizard.ts.
6
+ // ---------------------------------------------------------------------------
7
+ export { DISPLAY_CATALOG, TOUCH_CATALOG, findPinConflicts, } from "./display-catalog.js";
8
+ export { findCuttlefishConfig, findSyntaxError, readConfigSection, readEntryPath, renderDisplayBody, renderDisplayProperty, upsertDisplaySection, } from "./config-writer.js";
9
+ export { renderStarterUi } from "./starter-ui.js";
10
+ export { runIntegrationWizard } from "./integration-wizard.js";
@@ -0,0 +1,15 @@
1
+ export interface WizardRunResult {
2
+ exitCode: number;
3
+ /** Absolute path of the config that was written, when a write happened. */
4
+ configPath?: string;
5
+ }
6
+ /** Optional stream overrides so tests can drive the interactive flow. */
7
+ export interface WizardStreams {
8
+ input?: NodeJS.ReadableStream;
9
+ output?: NodeJS.WritableStream;
10
+ }
11
+ /**
12
+ * Run the interactive integration wizard. Returns a process exit code
13
+ * (0 = wrote (or deliberately declined), 1 = blocked before writing).
14
+ */
15
+ export declare function runIntegrationWizard(cwd?: string, streams?: WizardStreams): Promise<WizardRunResult>;