Rover
demo-kit/ es lo que simula el dispositivo para la demostración en la página de inicio. El dispositivo en sí no lo necesita.
demo-kit/ es lo que simula el dispositivo para la demostración en la página de inicio. El dispositivo en sí no lo necesita.
// Writes page.h from ../../ui/rover.html and ../../ui/manifest.json, so that the sketch can serve both from
// its flash. Run it again whenever the page changes:
//
// node make-page.mjs
//
// Node built-ins only.
import { readFileSync, writeFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
const here = (path) => fileURLToPath(new URL(path, import.meta.url));
const DELIMITER = 'CZROVER';
const page = readFileSync(here('../../ui/rover.html'), 'utf8').replace(/\r\n/g, '\n');
const manifest = JSON.stringify(JSON.parse(readFileSync(here('../../ui/manifest.json'), 'utf8')));
for (const [name, text] of [['rover.html', page], ['manifest.json', manifest]]) {
if (text.includes(`)${DELIMITER}"`)) throw new Error(`${name} contains the raw string's end, )${DELIMITER}"`);
if (text.includes('\0')) throw new Error(`${name} contains a NUL character`);
}
const bytes = Buffer.byteLength(page);
if (bytes > 2 * 1024 * 1024) throw new Error('rover.html is larger than 2 MB, the limit for a device UI');
writeFileSync(
here('page.h'),
`// Written by make-page.mjs from ../../ui/rover.html and ../../ui/manifest.json. Do not edit; run it again.
#pragma once
#include <Arduino.h>
const size_t ROVER_PAGE_LENGTH = ${bytes};
const char ROVER_MANIFEST[] PROGMEM = R"${DELIMITER}(${manifest})${DELIMITER}";
const char ROVER_PAGE[] PROGMEM = R"${DELIMITER}(${page})${DELIMITER}";
`,
);
console.log(`page.h: the page is ${bytes} bytes, the manifest ${Buffer.byteLength(manifest)}.`);