@cella-lang/arduino

中文文档
0.1.202611090959发布于 2026/11/09Apache-2.0零依赖近 30 天下载 1.1万

Arduino and ESP32/ESP8266 for Cella Lang, on @cella-lang/cpp: the boards' cores and libraries from their C++ sources (pins, timers and interrupts, Serial, LCD, servo, DHT, EEPROM, WiFi), a simulated clock, and sensor values supplied by the host — compiled

原始使用文档
文档目录6 节
  1. Programs
  2. The core and the libraries
  3. The environment's inputs
  4. Verdicts
  5. Entries
  6. Loading

@cella-lang/arduino

Arduino, ESP32 and ESP8266 for the Cella proof checker, as a compiled module pack: C++17 on a board. The board is the program's environment: it decides the data model (the same int is 16 bits on an Uno and 32 bits on an ESP32), and its core and libraries are modeled from their C++ sources.

Depends on @cella-lang/cpp, @cella-lang/cfamily and @cella-lang/machine.

Programs

The JSON of @cella-lang/cfamily's syntax with "lang": {"k": "langCpp"} and a board: {"k": "prog", …, "board": "uno"}.

Boardsintdouble
uno (also arduino), nano16 bits32 bits
esp32, esp32c3, esp32s3, esp32s3Cam, nodemcuEsp8266, wemosD1Mini32 bits64 bits

An unknown board makes the verdict invalid. A program with setup and loop and no main runs like a sketch: setup once, then loop until 5 simulated seconds. A program that defines its own entry (main on the AVR boards, app_main on the ESP32) runs that instead of the core's.

The core and the libraries

The core: pins, time, map, tone and noTone, pulseIn, the board's constants ({"k": "eConst", "name": "LED_BUILTIN"}), Serial, Serial1…, and String. As in a real sketch, a library's names come with its header ({"k": "iInclude", "header": "Servo.h"}): EEPROM.h, Servo.h, DHT.h, LiquidCrystal.h, LiquidCrystal_I2C.h, and on the ESP boards WiFi.h (WiFi.localIP() is an IPAddress, printed as a.b.c.d). Library objects are ordinary objects: declare them with tClass and call their methods with eMCall. The models follow the AVR core, arduino-esp32 3.0.7 and esp8266/Arduino 3.1.2. arduino.boardInfo "uno" lists what a sketch on a board can name: its constants, serial ports, global objects and library classes.

The environment's inputs

The program's JSON may carry the environment's inputs over time beside "board":

"inputs": [{"t": 1500, "key": "analog:A0", "value": 100}]

t is in milliseconds; an input applies once the simulated clock reaches it, and one that names a device waits until the device is declared. The keys:

KeyInput
analog:A0an analog pin's reading
digital:2a digital pin's level
echo:10the width of the pulse pulseIn reads on a pin, in microseconds (none given: no pulse)
touch:4what touchRead reads on a pin (the ESP32 boards with touch; none given: 75)
dht:<name>.temperature, dht:<name>.humiditya DHT sensor's readings (the sensor answers when both are given; with either missing it is unplugged)
wifithe status WiFi.begin ends with, as a wl_status_t (none given: WL_CONNECTED)
eeprom:<address>an EEPROM cell's content at power-on

Devices are named after the variable that declares them (s, lcd, an array's elements arm[0], arm[1]), in the keys and in env alike; an object with no variable (a member, a temporary) is dev<n>. The inputs are the run's environment, not the program's syntax: only this package's entries read them, and a C or C++ program without a board that carries them is invalid.

Verdicts

The verdict JSON of @cella-lang/cfamily, with what the hardware did:

  • pins: each change of a pin's value, {t, pin, value} (the PWM duty when set, else the level); at most 1000, and pinsTruncated says when more were dropped;
  • env: the hardware at the end: the clock, the loops run, each pin's mode, level, PWM and tone, the servos, the LCDs' rows and the EEPROM cells written.

Entries

  • arduino.verdict src input fuel: the verdict; input is what Serial reads. A verdict proved by the kernels: kernel_verdict_in("arduino", "arduino.verdict", …) in cella-lang.
  • arduino.types src candidates: the type query (format in @cella-lang/cfamily).
  • arduino.boardInfo name: what a sketch on the board can name.
  • arduino.withInputs src inputs: the program's JSON with inputs as its "inputs", for a host written in Cella (a JavaScript host sets the field).
  • The debugger, for cella-lang/dap: load (applies the program's "inputs"), run, stopConf, stopKind, stopNode, stopOut, stopErr, stopDetail, divergences, feed, globals, frames, setVarErr, setVarConf, env (the hardware of a paused run, as the wiring panel shows it), setInput key value (an input changed while paused), clockMs (the simulated clock); and report input fuel session, a whole run with all the input given at once. cella-lang/dap records the inputs changed while debugging, and inputScript() gives them back as the "inputs" a verdict replays.

Loading

Load the packs into the cella-lang build named by index.json (checkerHash, cbfVersion; the peerDependencies pin it): the standard modules in index.requires["cella-lang"].modules, the packages in index.requires.packages (each the same way), then this package's modules in the order of index.modules.arduino.deps. cella-lang's README (Official packages) has the code.

版本与发布记录

@cella-lang/arduino 共发布 61 个版本,首次发布于 2026/10/30;过去 12 个月发布了 61 个版本。

版本发布日期距今
0.1.202611090959latest2026/11/09今天
0.1.2026110909552026/11/09今天
0.1.2026110822142026/11/09今天
0.1.2026110809592026/11/081 天前
0.1.2026110805242026/11/081 天前
0.1.2026110804152026/11/081 天前

关于 @cella-lang/arduino 的常见问题

@cella-lang/arduino 是什么?

Arduino and ESP32/ESP8266 for Cella Lang, on @cella-lang/cpp: the boards' cores and libraries from their C++ sources (pins, timers and interrupts, Serial, LCD, servo, DHT, EEPROM, WiFi), a simulated clock, and sensor values supplied by the host — compiled

如何安装 @cella-lang/arduino?

在项目目录运行 npm install @cella-lang/arduino,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:cella-lang(0.1.202611090954)、@cella-lang/cpp(0.1.202611090959)、@cella-lang/cfamily(0.1.202611090959)、@cella-lang/machine(0.1.202611090959)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cella-lang/arduino 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/cella-lang__arduino 是否存在。

@cella-lang/arduino 可以商用吗?

@cella-lang/arduino 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@cella-lang/arduino 的下载量有多少?

根据 npm 官方下载统计,@cella-lang/arduino 在 2026/10/10 – 2026/11/08 这 30 天内被下载 11,062 次,日均约 369 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cella-lang/arduino 还在维护吗?

最新版本 0.1.202611090959 发布于 2026/11/09(今天);至今共发布 61 个版本,其中过去 12 个月发布了 61 个;首次发布于 2026/10/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。