Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple HALs #95

Closed
troky opened this issue May 11, 2022 · 7 comments
Closed

Multiple HALs #95

troky opened this issue May 11, 2022 · 7 comments

Comments

@troky
Copy link

troky commented May 11, 2022

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.

@jandelgado
Copy link
Owner

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

@troky
Copy link
Author

troky commented May 16, 2022

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

@jandelgado
Copy link
Owner

jandelgado commented May 17, 2022

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

@troky
Copy link
Author

troky commented May 17, 2022

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...

@jandelgado
Copy link
Owner

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.

@troky
Copy link
Author

troky commented May 22, 2022

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

@github-actions
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants