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

UserModExample - examples for config/ui #50

Open
netmindz opened this issue Apr 22, 2024 · 11 comments
Open

UserModExample - examples for config/ui #50

netmindz opened this issue Apr 22, 2024 · 11 comments
Assignees

Comments

@netmindz
Copy link
Collaborator

The UserModExample should show how you display a module in the UI that allows you to request values to be saved to the model/config

@netmindz
Copy link
Collaborator Author

We also need a nicer syntax for setting a label of the input than all this

ui->initPassword(parentVar, "pw", "", 32, false, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
    case f_UIFun:
      ui->setLabel(var, "Password");
      return true;
    default: return false;
  }});

@ewoudwijma
Copy link
Collaborator

Agree this is a lot of code overhead. The reason uiFun was added that storing this in the model json will create a very big model and it is only descriptive. So the ui now asks for this by triggering uiFun.
so open for better ideas.
It is less worse if also other triggers are implemented here (changeFun etc), because it uses the same setup.

note that this whole structure is a way to implement class like functionality. Alternatively each initNumber etc is a (singleton) class with methods like fx.uiFun or fx.changeFun implemented .
I did not do that because we have a lot of classes / instances in that case, but maybe reconsider this …

@ewowi
Copy link
Owner

ewowi commented Oct 1, 2024

Hi Will,, it took some time but the solution is in latest commit:

MoonModules@1388bdf

This is only for Effects.layers, but next commits will deal with all of Star

@netmindz
Copy link
Collaborator Author

netmindz commented Oct 2, 2024

Great. Good to hear there is some progress. I look forward to seeing the new user friendly syntax

Do you have something in mind you are aiming for?

@ewowi
Copy link
Owner

ewowi commented Oct 2, 2024

What do you mean with aiming ?
Om the longer term aiming for StarBase to be the Linux, macOS or windows for esp32 devices 😁

@netmindz
Copy link
Collaborator Author

netmindz commented Oct 2, 2024

We agree that this syntax isn't very nice

ui->initPassword(parentVar, "pw", "", 32, false, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case f_UIFun:
ui->setLabel(var, "Password");
return true;
default: return false;
}});

But do you know yet what the new one will be, once you have written it?

@ewowi
Copy link
Owner

ewowi commented Oct 2, 2024

ui->initPassword(parentVar, "password", "", 32, false, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
default: return false;
}});

the varFun will stay to catch events (until we find a more syntax friendly version.

  • it allows for code to be in one place
  • It is needed for a minimal footprint of string related info (eg comments or dropdown values : using a string but not also needing long term memory to store that string
  • More optimizations in the pipeline

@ewowi
Copy link
Owner

ewowi commented Oct 2, 2024

And now this variable can be retrieved by using the parent id, which will be wifi in this case
Eg findVar(“wifi”, “password”)
And the ui will show wifi password
And html id=“wifi.password”
So cleaner than just pw somewhere in the code

@ewowi
Copy link
Owner

ewowi commented Oct 2, 2024

And I also want to implement pubsub

so you can say

Notify (“wifi”, “password”, onChange, ‘do something’…

@netmindz
Copy link
Collaborator Author

netmindz commented Oct 3, 2024

Yeah that would be really helpful to get the bidirectional changes between Star and HomeAssistant working in an efficient manner

@ewowi
Copy link
Owner

ewowi commented Oct 9, 2024

All setLabels except for two occasions where it is conditional completely gone now.
Code looks much cleaner, because the cryptic var names to preserve uniqueness gone now (uniqueness is now the combi of parent var name and var name (pid,id)
Both in StarBase and StarLight
Can we close the issue ?

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

No branches or pull requests

3 participants