MCPcopy Index your code
hub / github.com/cifertech/DisplayKit / exportAllIconsU8g2XbmClient

Function exportAllIconsU8g2XbmClient

app.js:2517–2557  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2515}
2516
2517async function exportAllIconsU8g2XbmClient() {
2518 setIconHint("Exporting U8g2 XBM…");
2519
2520 let out = "";
2521 out += "// Auto-generated by DisplayKit (Icon List → Export U8g2)\n";
2522 out += "#pragma once\n\n";
2523 out += "#include <Arduino.h>\n";
2524 out += "#include <pgmspace.h>\n\n";
2525 out += "// Use with: u8g2.drawXBMP(x, y, w, h, <name>);\n\n";
2526
2527 for (let idx = 0; idx < FILE_ICONS.length; idx++) {
2528 const ic = FILE_ICONS[idx];
2529 const size = inferSizeFromPath(ic.file);
2530 const w = size?.w || undefined;
2531 const h = size?.h || undefined;
2532 try {
2533 const converted = await loadPngToRgb565(withCacheBust(ic.url), "#000000", w, h, null);
2534 const sym = safeSymbolFromPath(ic.file);
2535 const name = `icon_${sym}_${converted.w}x${converted.h}_xbm`;
2536 const bytes = converted.monoBitmap || [];
2537 out += `// ${ic.file}\n`;
2538 out += `#define ${name}_width ${converted.w}\n`;
2539 out += `#define ${name}_height ${converted.h}\n`;
2540 out += `const unsigned char ${name}[${bytes.length}] PROGMEM = {\n`;
2541 for (let i = 0; i < bytes.length; i++) {
2542 const isLast = i === bytes.length - 1;
2543 if (i % 16 === 0) out += " ";
2544 out += bytesToHexByte(bytes[i]);
2545 out += isLast ? "" : ", ";
2546 if (i % 16 === 15 || isLast) out += "\n";
2547 }
2548 out += "};\n\n";
2549 } catch (e) {
2550 out += `// ${ic.file}\n`;
2551 out += `// ERROR: ${e && e.message ? e.message : "conversion failed"}\n\n`;
2552 }
2553 }
2554
2555 downloadText("displaykit_icons_xbm.h", out);
2556 setIconHint("Exported: displaykit_icons_xbm.h");
2557}
2558
2559async function exportAllIconsU8g2Xbm() {
2560 if (!FILE_ICONS.length) {

Callers 1

exportAllIconsU8g2XbmFunction · 0.85

Calls 7

setIconHintFunction · 0.85
inferSizeFromPathFunction · 0.85
loadPngToRgb565Function · 0.85
withCacheBustFunction · 0.85
safeSymbolFromPathFunction · 0.85
bytesToHexByteFunction · 0.85
downloadTextFunction · 0.85

Tested by

no test coverage detected