I’ve been talking with @geofrancis, @ktrussell, and @BenBBB regarding the development of several device drivers. It seems there’s a longstanding desire for ArduPilot to support discrete temperature sensors like the DS18B20 or even simple resistive sensors, but there’s never much traction on the topic.
For the moment, GeoMuir and I are most interested in developing a “port expander” of sorts using a microprocessor as an I2C bridge and leveraging the new I2C Lua bindings to make use of it, such that 1-Wire sensors or even other GPIO devices could be made available to the scripting environment.
read_registers() binding looks like it reads only a single byte at a time, while actual I2C devices under HAL get a
transfer() function capable of serial read/write, and generic HAL devices have a
read_registers() function that wraps it.
Is there a good method to bind the
read_registers() functions in a more flexible way? Would it require a Lua specific helper in the HAL library (like some of the IMU bindings), or is there a less intrusive way to avoid this “byte-banging" behavior with I2C comms in Lua?
Or could it be as simple as allowing a second argument in the
read_registers() binding rather than the literal
1? Maybe that was a very intentional design choice and I’m just unaware of the reasoning.
I have to admit, the binding generator syntax isn’t always the easiest for me to comprehend…