Multiple HALs
troky opened this issue · 7 comments
Is it possible to implement multiple HALs ont he same board/project?
For example, I have ESP32 board with PCA9635 I2C driver and I want to use them both using JLed library at the same time, e.g. some LEDs are connected to ESP32 pins, and some are connected to PCA9635.
I have created custom HAL class but I dont know how to instantiate both HALs at the same time.
I'll provide an example showing how to drive built-in ESP32 PWM's and an PCA9685 driver in the next days.
Driving PCA9685 (creating new HAL) is not a problem. I want to have std::list of different HAL types.
Could you please provide an example what the exact problem is (code
)?
There is no (abstract) base class/interface that coul be used.
For example: I need std:: list<JLedBase*>() where list elemnts can be JLed, JLed, etc... so I can cast JLed to JLedBase and call JLedBase->On() function etc...
There is intentionally no base class to keep the memory footprint low. But coincidentially I am working on a feature allowing to stuff different objects like JLed
objects or JLedSequence
objects recursively into a JLedSequence
. I'll try to provide a branch that you can test in the next days.
Well, for test, I de-templated your TLed class and made it abstract adding two virtual functions: analogWrite() and millis() and now I can create derived class from public TLed and implement those two funcions just like you do it in separate hal class. Problem solved... now I can have std::list<TLed *>()
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days