()
| 2458 | } |
| 2459 | |
| 2460 | async function exportAllIconsTftRgb565Client() { |
| 2461 | setIconHint("Exporting TFT RGB565…"); |
| 2462 | |
| 2463 | let out = ""; |
| 2464 | out += "// Auto-generated by DisplayKit (Icon List → Export TFT)\n"; |
| 2465 | out += "#pragma once\n\n"; |
| 2466 | out += "#include <Arduino.h>\n"; |
| 2467 | out += "#include <pgmspace.h>\n\n"; |
| 2468 | out += "// Note: any transparent pixels are mapped to the current DisplayKit background color.\n\n"; |
| 2469 | |
| 2470 | for (let idx = 0; idx < FILE_ICONS.length; idx++) { |
| 2471 | const ic = FILE_ICONS[idx]; |
| 2472 | const size = inferSizeFromPath(ic.file); |
| 2473 | const w = size?.w || undefined; |
| 2474 | const h = size?.h || undefined; |
| 2475 | try { |
| 2476 | const converted = await loadPngToRgb565(withCacheBust(ic.url), bgColor, w, h, null); |
| 2477 | const sym = safeSymbolFromPath(ic.file); |
| 2478 | const name = `icon_${sym}_${converted.w}x${converted.h}`; |
| 2479 | const total = converted.w * converted.h; |
| 2480 | out += `// ${ic.file}\n`; |
| 2481 | out += `const uint16_t ${name}[${total}] PROGMEM = {\n`; |
| 2482 | for (let i = 0; i < converted.rgb565.length; i++) { |
| 2483 | const isLast = i === converted.rgb565.length - 1; |
| 2484 | if (i % 12 === 0) out += " "; |
| 2485 | out += uint16ToHexWord(converted.rgb565[i]); |
| 2486 | out += isLast ? "" : ", "; |
| 2487 | if (i % 12 === 11 || isLast) out += "\n"; |
| 2488 | } |
| 2489 | out += "};\n\n"; |
| 2490 | } catch (e) { |
| 2491 | out += `// ${ic.file}\n`; |
| 2492 | out += `// ERROR: ${e && e.message ? e.message : "conversion failed"}\n\n`; |
| 2493 | } |
| 2494 | } |
| 2495 | |
| 2496 | downloadText("displaykit_icons_rgb565.h", out); |
| 2497 | setIconHint("Exported: displaykit_icons_rgb565.h"); |
| 2498 | } |
| 2499 | |
| 2500 | async function exportAllIconsTftRgb565() { |
| 2501 | if (!FILE_ICONS.length) { |
no test coverage detected