Repository navigation
Architecture
English | Português (BR)
How the firmware is organized, what runs on top of what, and where to touch for each kind of change.
+--------------------------------------------------------------+
| data/ (LittleFS partition at /local) |
| System apps in JavaScript: Settings, App Store, |
| Installer, Terminal, Help, Web Server, Snake, demos |
+------------------------------^-------------------------------+
| Duktape (ES5)
+------------------------------|-------------------------------+
| main/ (ESP-IDF app component, C++) |
| Kernel/Core CelerKernel: Duktape heap, runs main.js |
| Runtime JSBindings + Js*.cpp: System / Net / FS |
| UI Kui (canvas/screen/widget), docked keyboard |
| Launcher discovers apps in /local/apps and /sd/apps |
| Display virtual 240x320 -> physical, theme, icons |
| FileSystem LittleFS (/local) + SD (/sd), atomic writes |
| WebManager httpd + file manager + OTA upload + portal |
| OTA OtaManager: update.json v2 + download Range |
| USBDevice CelerShell, HostLink (celerctl), SerialLink |
| Bluetooth CelerLink (pairing) + CelerNet (mesh) |
| Pack PackId, Provision, Resources: the pack |
| Boards/<b>/ per-board HAL (pins, display, traits) |
+------------------------------^-------------------------------+
| includes/REQUIRES
+------------------------------|-------------------------------+
| components/ (CelerOS-owned + vendored third parties) |
| Network (NetworkManager: sole radio owner), Http, System |
| (SystemInfo), Storage (NVS), Utility (Event/Singleton), |
| ErrorCodes, LovyanGFX, duktape |
+--------------------------------------------------------------+
The unused remainder of the old shared esp_components lib was removed
from the tree (Oct 2026) — everything in components/ is built. The old
code remains reachable in git history through the archive/esp_components
tag (or the upstream repo).
app_main calls celerSetup() once and celerLoop() forever
(main/main.cpp):
-
Board::init— HAL of the compiled board (main/Boards/<board>/) -
UI::init(w, h)— display and the virtual 240x320 layout -
FileSystem::init— LittleFS at/local, SD at/sd -
SerialLink→USBDevice— thecelerctlchannel -
Backlight→TimeManager(NTP/timezone) →Alarms→CelerKernel::init— the Duktape heap -
AppServices(the svchost) →WebManager::startAsync(touch calibration runs here on the CYD's first boot) -
LauncherUIandkui::Navigator::begin+WatchPanels, then push of the launcher (or the board's home app)
The main loop runs on the main task: Navigator::tick(),
WebManager::tick() (deferred reboot after a web OTA),
TimeManager::tick(), the power/screen ticks and
delay(PowerPolicy::loopDelayMs()) — JS apps pump the same ticks from
System.present().
- Globals exposed by the bindings (
main/Runtime/JSBindings.cpp+Js{System,Net,Fs,Gfx,Gpio,Keypad,Link,SystemApps,Storage,Timers,Sensors, Phone,Ai,Mic,Wake}.cpp):System,Net,FS,Storage,Sensors,Phone,AI,MicandWakeWord(the last ones depend on the build/hardware) plusCelerLink(the BLE link, on Bluetooth builds). - Apps are pure ES5 (no
Promise— the builtin was compiled out of Duktape), with a blockingwhileloop andSystem.delay(). - All geometry is drawn in virtual 240x320 coordinates and scaled by
UI::sx()/sy()— apps never see physical pixels. - The API level (
System.getAPILevel(), currently 62) is the feature-detection contract for apps. History: 1 base (draw/touch/GPIO/FS/time) · 2Net· 3 system apps in JS · 5 docked keyboard · 6 custom topbar + streamingNet.download· 7 RGB LED, light sensor/auto-brightness, speaker, masked prompts · 8 relays · 9 Celer Link (BLE) · 10 servos + robot hardware (battery, mic, touch pad, NeoPixel) · 11 Celer Link code pairing + keyboard{hint:"num"}(numeric page) · 12setTimeout/setInterval,Storage(private NVS), multi-sprites, binaryFS.readFile/writeFile,setTextDatum· 13Sensors.*(watch IMU: accel/steps, raise-to-wake) · 14 Celer Link pairing on by default · 15 the watch experience (notification center, persistent alarms/timer, quick panels,Phone.*Gadgetbridge,batteryInfo) · 16 watchface plugins (watchface.js+System.launchApp) · 17System.button()(headless devkit) · 18AI(async chat, DeepSeek/OpenRouter) · 19Mic.*(16 kHz WAV recording,micpermission) · 20 function calling (toolCalls) +WakeWord.*(on-device "Hi Celer") · 22 theUI.*toolkit · 23 multi-file apps withrequire()· 28 native canvas + sprite pool · 30–33 shared deps (deps.json), native verlet physics, sfx mixing, rigid bodies · 42 single app.zip package · 43 multitouch (System.getTouches) · 48 USB Host + the OS input bus · 49Net.requestwith headers +System.epoch()· 50 background services with network/OTA (svchost) · 51 screen state (System.isScreenOn/screenState) · 52 WiFi setup as a JS app (celeros.wifi) + optionalAIbuild + S3 UI extras · 53 service network window (System.wifiWake) · 54 generic I²C bus (System.i2c) · 55 native drivers (System.encoderPCNT,System.dht,System.gpio.servoUs) · 56 the app contract enforced on device (theapp.jsonapigate,mainhonored,App.info(),Net.fetchwith typed errors) · 57–58 loadable native code (System.native*on S3 + PSRAM: CLRN blob in a PSRAM scratch,BT.*gamepad transport) · 59 alpha blending (System.setAlpha) · 60 native frame access (System.nativeScreen/nativeGrab) · 61 the gamepad as OS input (Input.pad/padStatebroadcast channel fed by the resident Controle BT driver) · 62 BLE keyboards and mice (BT.state().kindclassified from the Report Map, the physical keyboard types into every text field, theceleros.hiddep). - An optional Duktape debugger (
CONFIG_CELEROS_JS_DEBUGGER, default on the ESP32-S3 targets) exposes breakpoints/step/eval over the celerctl channel (celerctl debug). - ULP-RISC-V coprocessors stand guard while the main cores sleep: the
deep-sleep sentinel on the watch (
Boards/waveshare-watch/WatchUlp.cpp) and the battery watchdog on the dog (Boards/spotpear-dog/DogUlp.cpp). - When adding/calling a new API: bump
CELEROS_API_LEVEL, document it in both languages ofJS_API_Guideand add a stub to thetest/js_harness/run.jsharness.
| Task | Where |
|---|---|
| Add a source file |
CELEROS_SRCS in main/CMakeLists.txt (it is not a glob) |
| Version / API level bump |
main/CMakeLists.txt (CELEROS_VERSION, CELEROS_API_LEVEL) and the root project(VERSION) — keep both in sync |
| New board |
main/Boards/<b>/ + elseif in CMake + boards/<b>/sdkconfig.defaults + updates/<channel>/update.json
|
| Gestures/touch |
UI/Kui.cpp (TouchPump; touches injected by celerctl go through the TouchInjector) |
| Device side of celerctl |
USBDevice/HostLink.cpp (opcodes), SerialLink.cpp (UART) |
| Celer Link (BLE between devices) |
Bluetooth/CelerLink.cpp + Runtime/JsLink.cpp (CelerLink global) |
| The pack (mesh, resources, joining) |
Pack/ (PackId, Provision, Resources) + Bluetooth/CelerNet.cpp; design in Documentation/CelerNet_Design.pt-BR.md
|
| Web pages |
WebManager/*.html (re-embedded as gzipped headers at build time) |
| Wi-Fi radio / credentials |
components/Connection (NetworkManager singleton) |
Devices form a private network — the pack — where each one publishes its hardware (mic, camera, speaker, relays, sensors) as resources the others use. Three technologies are three pillars of it:
| Pillar | Role | Code |
|---|---|---|
| CelerLink | trust: pair by a 6-digit code; the bond then carries the pack key (sealed invite) |
Bluetooth/CelerLink.cpp, Pack/Provision.cpp
|
| CelerNet + resources | the mesh: encrypted BLE flooding, presence, leases, ESP-NOW data plane |
Bluetooth/CelerNet.cpp, Pack/Resources.cpp
|
| HostLink | the gateway: the computer joins over the USB cable as a virtual member pc-XXXX
|
USBDevice/HostLink.cpp, USBDevice/UsbRes.h
|
They share one identity (Pack/PackId: node id from the BT MAC, one
persistent name) and one key with three doors: password (Pack.join, shell
mesh join, celerctl mesh join), the CelerLink invite (Pack.invite, the
Matilha app) and the cable. Apps use Pack.* as the facade (JS API guide,
section 43).
-
Never board
#ifdefs outsidemain/Boards/<board>/— compile-time differences live in the board'sBoardTraits.h. - Logging via
celer_log_printf/println(goes to UART/CDC and thelogcatbuffer), never rawprintf. - Persistent state via
FileSystem::writeTextFile(tmp + rename, power-loss resistant). - Fallible operations return
ErrorCode(registry incomponents/ErrorCodes), notesp_err_t. - Singletons:
class X : public Singleton<X>with a token-taking ctor. -
Event<...>handlers only set flags —trigger()holds the mutex for the whole dispatch. - Never call
Storage::initialize()from components: it would mount SPIFFS over the partition CelerOS formats as LittleFS. The OS filesystem ismain/FileSystem. - Comments, logs and CLI strings are written in Portuguese, without accents. Text shown on screen (UI, toasts, app strings) may use accents: the fonts cover Latin-1.
| File | ~LOC | Role |
|---|---|---|
main/Runtime/JSBindings.cpp + Js*.cpp
|
~2.9 K | the whole JS surface |
main/WebManager/WebManager.cpp |
~960 | httpd, file manager, OTA upload, screen mirror |
main/Bluetooth/CelerLink.cpp |
~1070 | Celer Link: NimBLE GATT + advertising + code pairing (API 11) |
main/UI/Kui.cpp |
~900 | immediate-mode UI framework |
main/Launcher/Screens.cpp |
~810 | system screens |
main/FileSystem/FileSystem.cpp |
~640 | atomic FS + MD5 |
More detail per directory: the AGENTS.md files of main/,
components/, main/Runtime/
and Network/ in the repository.
Esta wiki e gerada automaticamente pelo CI a partir de wiki/ no repositorio. Edicoes feitas pela web serao sobrescritas.
Get started
Under the hood
Tools
Robotics
Wearables
Barebone
JavaScript apps
Contributing
Português (BR)