-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
1022 add programable buttons to webui #1026
Conversation
- merged from #1026 - provided 5 programmable buttons in the webui.
@Ezward - This is a great improvement, if we can use the web controller on the mobile phone. Can you please also update the version? You'll need to rebase, because I just merged the VESC PR. |
- if key is a string, set the value directly.
- this will take a dictionary and add each individual key/value pair to vehicle memory - it will optionally insert a prefix into the output key/value - this will be used to write the button presses returned by the webUI into working memory.
- buttons, "w1" to "w5" - button presses are returned by the LocalWebController part - the dictionary of button presses isthen processed in the template using the ExplodeDict part to turn the dictionary into individual memory values
- this is just a demo of how to handle these button presses
e168d3a
to
ca70f87
Compare
@DocGarbanzo Thank you for the review, I've rebased and updated version="4.3.20" |
donkeycar/parts/explode.py
Outdated
|
||
def run(self, key_values): | ||
if type(key_values) is dict: | ||
for key in key_values: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better:
for key, value in key_values.items():
self.memory[self.prefix + key] = value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made that change, thanks.
buttons = self.buttons | ||
self.buttons = {} | ||
for button in buttons: | ||
if buttons[button]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this only be:
if button
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I'm checking to see if there is a button press. I'm not checking to see if there is a button. So if the Button is pressed then buttons[button] is true, so I want to clear it so we only see the button press once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah got it, buttons
is a dict
, so probably we should try to avoid a duplicated lookup and iterate through buttons.items()
which returns keys and values together?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made that change. It reads better now also. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Issue #1022
This PR adds 5 general purpose buttons to the webui. Presses of these buttons can be processed by other donkeycar parts as input values.
I've added code into the complete.py template that shows how to process the button presses. That is just there to test. Eventually we can decide if we want to add standard behavior to these buttons or add another mechanism for adding behaviors that can be configured.
This is what the webui looks like on a phone (sorry, github seems to be ignoring sizing and force width to fit)
This is what it looks like on desktop