jled icon indicating copy to clipboard operation
jled copied to clipboard

Multiple HALs

Open troky opened this issue 2 years ago • 6 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.

troky avatar May 11 '22 06:05 troky

I'll provide an example showing how to drive built-in ESP32 PWM's and an PCA9685 driver in the next days.

jandelgado avatar May 15 '22 19:05 jandelgado

Driving PCA9685 (creating new HAL) is not a problem. I want to have std::list<JLed> of different HAL types.

troky avatar May 16 '22 05:05 troky

Could you please provide an example what the exact problem is (code)?

jandelgado avatar May 17 '22 08:05 jandelgado

There is no (abstract) base class/interface that coul be used. For example: I need std:: list<JLedBase*>() where list elemnts can be JLed<HalType1>, JLed<Haltype2>, etc... so I can cast JLed<Haltype1> to JLedBase and call JLedBase->On() function etc...

troky avatar May 17 '22 09:05 troky

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.

jandelgado avatar May 20 '22 09:05 jandelgado

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 *>()

troky avatar May 22 '22 08:05 troky

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

github-actions[bot] avatar Aug 21 '22 01:08 github-actions[bot]