-
Notifications
You must be signed in to change notification settings - Fork 2
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
Simplify leaf adding with one-line commands #36
Comments
Thanks for the suggestion. As always, there should be a tradeoff between simplicity and flexibility. What about a combination of
This will achieve those goals:
The drawback is that an user can potentially create bugs or crashes if the parameter sequence is not respected |
The solution you proposed is very flexible but in my opinion is even more difficult to understand for a beginner user than the current method :) Let's see it from another perspective. Now when you create a leaf you use "standard" functions (_init_create, _init_double, etc.) in a "specific" combination that depends on the leaf type. So the way you create a leaf cannot be considered "generic" because it's leaf-dependent.
With the _fastcreate method you use a single "specific" function for each leaf. It's also leaf-dependent, as before, but simpler.
I understand that the _fastcreate function in C would not be self-explaining regarding its parameters (in python it could have been different), but with proper docs or code templates I believe it would be much simpler for a user to create a leaf and less error-prone than the current method. Maybe a single leaf-dependent parameter struct could be a way to show to users what they are setting? However these are just suggestions! |
Thanks for giving me another perspective. We're almost on a phylosophical side, that is what means 'simple' :)
But at the end this entire framework has the ultimate goal to make life easier. So you won! I'll add it to the TODO list. User can still approach the 'traditional' way, that is thought also to be ready for higher level automations, and i'll write some _fastcreate functions on the already built leaves. |
Here's your _fastcreate function, I've put a demo in blink board:
Just let me know if you are OK with that, thanks |
👍👍 very good, thanks In order to be consistent, probably for a given leaf type all .h/.c should have the same name convention of the leaf function names and configs, as suggested above. P.S.: there's probably a copy-paste typo at the end of gn_gpio_fastcreate() |
When you want to add a leaf you need to use several commands which could probably be summarized in simple one-line ones.
Example.
To add a moisture capacity sensor this is the way now:
It could be summarized with something like:
where implicitly "under the hood" all the other parameters are set. E.g., probably nobody would change that "4096" and a standard user when creates a leaf wants it active.
It could be:
In case 1, leaf should have a standard and common "name" to use in every function/parameter definition/file names, in order to make it easy to know the name of the "fastcreate" function.
For example capacity moisture sensors have file names and config called "capacity_moisture_sensor" but parameters called "CMS". This may generate confusion.
Temperature ds18b20 sensors, instead, maintain the same name everywhere.
The text was updated successfully, but these errors were encountered: