Repository navigation
feat: add Lua modules for Lilka v2 extension modules - #155
Merged
black-ghost-off merged 2 commits intoNov 16, 2026
Merged
black-ghost-off merged 2 commits into
black-ghost-off merged 2 commits into
Conversation
New Lua modules backed by the LilkaModules SDK library: gps, can, ir,
lora, nrf24, cc1101, imu and mag. Each is an object created with
X.new{...}; it claims its pins and peripherals, so an app and a service
can't drive the same hardware, and releases them on close() or when the
script ends.
Existing bindings:
- serial.begin(baud, config, rx, tx): optional pins (default 47/48);
read() is binary-safe; no global HardwareSerial in src/apps
- spi.transfer accepts strings and an optional CS pin
- spi, i2c and serial claim their pins/peripherals
- Lua apps and services release all claimed hardware on exit
Docs: modules overview and a reference page with an example per module.
- lora, nrf24, cc1101, imu, mag, gps take their default pins (and GPS baud) from lilka::config, so they can be changed with INI files in /sd/.lilka/config; radio bindings report unconfigured pins - docs: short snippets per module, full scripts now live in lilka-dev/examples (LUA/modules); modules page explains the config
black-ghost-off
marked this pull request as ready for review
November 16, 2026 12:54
frostmorn
approved these changes
Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lua support for the Lilka v2 extension modules, on top of the new
LilkaModulesSDK library (lilka-dev/sdk#40).gpscanirloranrf24cc1101imumagEvery module is an object (
local radio = assert(lora.new{...}), thenradio:send("hi")). It claims its pins and peripherals throughlilka::mod::resources, so a Lua app and a Lua service can't drive the same hardware, and releases them onclose(), on__gc/<close>, or when the script ends.newreturnsnil, errorif the module isn't found and frees its pins right away.Changes to existing bindings:
serial.begin(baud, config, rx, tx): optional pins (default stays 47/48, so existing scripts keep working);read(n)is binary-safe; the globalHardwareSerialinsrc/appsis gone.spi.transferalso accepts strings and an optional CS pin;spi,i2candserialclaim their pins/peripherals.Pins: default pins (and GPS baud / IR carrier) come from
lilka::config(lilka-dev/sdk#40): built-in values for Lilka v2, overridable with INI files in/sd/.lilka/config/(e.g.[lora] nss = 21). Radio bindings raise a clear error if the board has no pins configured.Docs:
docs/lua/reference/modules.rstplus a page per module with a short snippet; full scripts are in lilka-dev/examples#6 (LUA/modules).Merge order
Draft until lilka-dev/sdk#40 is merged and released (needs both
lilka/LilkaModulesand thelilka/configmodule inlilka/Lilka).platformio.ininow depends onlilka/LilkaModules, which the SDK release workflow will publish; until then the firmware build fails withCould not find the package with 'lilka/LilkaModules'.Testing
symlink://(+36 KB flash for the modules), no new warnings; clang-format and cppcheck clean on the changed files (cppcheckmemleakon driver pointers owned by Lua userdata suppressed inline).