corneliusmunz / legoino

Arduino Library for controlling Powered UP and Boost controllers
MIT License
257 stars 34 forks source link

Make connection flow easier #38

Open corneliusmunz opened 3 years ago

corneliusmunz commented 3 years ago

With more devices handled in an Arduino sketch the connection flow and the boilerplate code becomes more and more complicated. In this issue i want to discuss the requirements of a more easy way of the connection procedure. Initial thoughts came from @falk12 written in the following thread of another issue: https://github.com/corneliusmunz/legoino/issues/34#issuecomment-722257005

Main Goals:

falk12 commented 3 years ago

Hello

Here are some ideas to describe a hub. This might be done via a class or a structure. Some properties might be

They have to be coded(defined) by user and all used in a new "Conncet" routine, icluding init/isConnected/delay() and so on. Perhaps you add that as an additional routine (for backward compatibility)?

Other values might be filled automatically

And so on.

More values should be added if necessary

It could be useful to store other values like “hubButton”, as you can’t ask for the state within the program. (or is this still possible with the V 1.0.2 ?)

So the callback would have to store “true” and “false” when executed.

Another idea would be to have a byte per port to save the status:

1 no device attached 2 wrong device 3 correct device 4 port ready 5 callback running (?)

we could use this as an interface to any kind of display to show what is the status of the complete hub.

For my little project I choose a structure to do that. First as I am not that familiar with classes, second to use a loop code to stop all motors on all ports and shutdown all hubs when pressing on button.

Question: isn’t there a lot of overhead when reporting hubProperties, because the battery_Voltage changes rapidly, as well of rotations? Can you turn off notifications? Is this useful?