Repository navigation
feat: add LilkaModules library and lilka/config INI module - #40
Conversation
New PlatformIO library lib/lilka_modules with drivers for the Lilka v2 extension modules: - GPS (NEO-M8N): UART + NMEA parser (GGA, RMC, GSA, GSV) - CAN (SN65HVD232): TWAI wrapper - IR (KY-005 + KY-022): RMT TX/RX, NEC / Samsung / Sony SIRC codec - LORA (SX1262 / SX1268): polled IRQs, TCXO, RF switch - RF: nRF24L01+ and CC1101 - GYRO MAGNET: BMI260 (optional Bosch config blob) and TMAG5273 Also: - lilka::mod::resources: pin/peripheral ownership tracking - LILKA_EXT_RX / LILKA_EXT_TX in config.h (header pins 3 and 4) - LuaLS stubs for the new Keira Lua modules, serial.begin rx/tx args - releases.yml publishes lib/lilka_modules to the registry too
|
Examples should be moved to examples repo : https://github.com/lilka-dev/examples Config for hardware require more scalability: suggested to create lilka/config module which would be able to parse .ini files from /sd/.lilka/config Requirements: zero dependencies, since ini parsing algorithm have trivial implementation. STL-container like accessors( .begin(), .end(), has_key() ), store in a hashtable form to improve search speed This module later can be integrated in other lilka-sdk parts, specifically pins config per board. Provide fallback values for LILKA_VERSION 2. |
lilka/config: - IniTable: zero-dependency INI parser stored in a hash table (chaining, FNV-1a, case-insensitive sections/keys) with STL-like accessors: begin()/end(), find(), has_key(), size(), empty(), plus typed getters - lilka::config: built-in hardware values for LILKA_VERSION 2 (from config.h macros), then /sd/.lilka/config/*.ini in alphabetical order, later values override earlier ones; loaded in lilka::begin() after the SD card LilkaModules: - driver pin defaults read from lilka::config sections (gps, can, ir, lora, rf, gyro_magnet) via pins::get(); compile-time pin constants removed - example moved to lilka-dev/examples
|
while config is landed, it's still unused by any of modules. |
|
@frostmorn Do you want all modules—such as audio, buzzer, battery, etc.—to have this configuration as well? |
|
@black-ghost-off yes, it would be convenient for any module in future to use .ini like configuration. this may open us a possibility for hotswap/change configuration later, with .ini files with pinmaps specified by user somewhere on sdcard |
|
so you boot a system, check if .ini hardware files present for initializing specific hardware. also it would allow us to use any pin any other way, removing sdcard would allow to init default state. this may allow user to configure lilka differently without changing code, firmware, etc. it sound logical to have that feature in sdk, so would be less boilerplate in custom firmwares. though we can't support aaaall existing hardware, rather supported by lilka-dev, since dependency management part might be nightmare, and let's be real, it's not designed around that idea. but some freedom we can get |
|
I think it out of this scope. It can be in feature PR's. This PR just for one reason, give us support for new LUA modules. |
|
for fast feature it works, in general it can be another pr, no problem |
Summary
Adds
lib/lilka_modules(LilkaModules), a separate PlatformIO library with drivers for the Lilka v2 extension modules. Keira uses it for new Lua modules (gps,can,ir,lora,nrf24,cc1101,imu,mag) — companion PR in lilka-dev/keira.lilka::mod::Ir,IrCodec(NEC, Samsung, Sony SIRC)lilka::mod::SX126xlilka::mod::Nrf24,lilka::mod::Cc1101lilka::mod::Gps,Nmealilka::mod::Bmi260,lilka::mod::Tmag5273lilka::mod::CanDesign:
lilka::begin().Configfield; defaults come fromlilka::config(see below) viapins::get(section, key). SPI/I2C drivers take the bus and never start/stop it.lilka::mod::resourcestracks pin/peripheral ownership (Keira uses it so an app and a service can't drive the same pins).NmeaandIrCodechave no hardware access and build on a PC.BMI260_CONFIG_LICENSE); passed to the driver as pointer + length, so it can come from flash, a file, or be skipped.Other changes:
config.h:LILKA_EXT_RX/LILKA_EXT_TX(GPIO44/43, header pins 3 and 4).serial.begingets optionalrx,tx.releases.yml: version and publishlib/lilka_modulesto the registry next tolib/lilka, so Keira can depend onlilka/LilkaModules.lilka/config(review feedback)New core module
lib/lilka/src/lilka/config/:lilka::IniTable— zero-dependency INI parser (libc only) stored in a hash table (separate chaining, FNV-1a, case-insensitive sections/keys). STL-like accessors:begin()/end()(range-for),find(),has_key(),size(),empty(), plusget(),getInt()(dec/hex),getFloat(),getBool(),set(),erase().;/#comments (also inline), quoted values.lilka::config— loads built-in values forLILKA_VERSION == 2first (generated from theconfig.hmacros: sectionsext,gps,can,ir,lora,rf,gyro_magnet), then/sd/.lilka/config/*.iniin alphabetical order; later values override earlier ones. Called fromlilka::begin()right after the SD card is mounted (config.reload(); notbegin(), which is the iterator). Defaults are also available beforebegin().Examples moved to lilka-dev/examples#6 (
lib/lilka_modules/examplesremoved).Testing
symlink://to both libraries); no new warnings; clang-format and cppcheck clean on the new code. The LoRa example in lilka-dev/examples builds too.IniTableunit-tested on the host with ASan/UBSan: comments, quotes, case-insensitivity, overrides,find/erase, growth to 1000 keys, range-for, over-long lines, and parsing the built-in v2 defaults (35 keys).NmeaandIrCodecunit-tested on the host (multi-constellation GSV, bad checksums; NEC 8/16-bit + repeat, Samsung, Sony 12/15/20 with ±90 µs distortion).