7e8ac7f56697eb6d089fed8a8951c5b55c227ce3
DALI ESP-IDF Component
A lightweight C++ implementation of the DALI stack used in lib/dali/*.dart for gateway type 1 (USB UART) traffic. The component mirrors Dart method names so it can be used as an embedded replacement target.
Quick Start
- Add the component to your ESP-IDF project (e.g., via
EXTRA_COMPONENT_DIRS). - Provide UART callbacks when constructing
DaliComm:
DaliComm comm(
/* send */ [](const uint8_t* data, size_t len) {
// write bytes to the gateway UART
return my_uart_write(data, len) == ESP_OK;
},
/* read (optional) */ [](size_t len, uint32_t timeoutMs) -> std::vector<uint8_t> {
return my_uart_read(len, timeoutMs);
},
/* transact */ [](const uint8_t* data, size_t len) -> std::vector<uint8_t> {
my_uart_write(data, len);
return my_uart_read_response(); // should return the raw gateway reply
});
Dali dali(comm);
- Use the API just like the Dart version:
dali.base.setBright(5, 200); // direct arc power control
dali.base.off(5);
dali.base.dtSelect(8);
dali.dt8.setColorTemperature(5, 4000); // Kelvin
std::vector<int> rgb = dali.dt8.getColourRGB(5);
Behaviour Parity
- Frame formats match the Dart implementation:
[0x10, addr, cmd](send),[0x11, addr, cmd](extended),[0x12, addr, cmd](query with[0xFF, data]response). - Address encoding matches Dart helpers:
dec*2for direct arc,dec*2+1for command/query addresses. - Colour conversion utilities (
rgb2xy,xy2rgb, XYZ/LAB helpers) are ported fromlib/dali/color.dart. - Public APIs from
base.dart,dt8.dart,dt1.dart,addr.dart, anddecode.dartare exposed with matching method names. - App-side model parity modules are included for
device.dart,sequence.dart, andsequence_store.dartviadevice.hpp,sequence.hpp, andsequence_store.hpp. - Utility APIs from
errors.dart,log.dart,query_scheduler.dart, andbus_monitor.dartare available as embedded-friendly C++ headers.
Notes
- Optional query support: provide a
transactcallback that returns the gateway reply; otherwise, query methods returnstd::nullopt. Dalifacade ininclude/dali.hppmirrorslib/dali/dali.dartand wiresbase,decode,dt1,dt8, andaddrtogether.- The
t,d, andgparameters in Dart are not required here; timing/gateway selection is driven by your callbacks.
Description
Languages
C++
99.7%
CMake
0.3%