Adding buttons to Web GUI
Forums:
Hi, I read a post by @Adam about using voice recognition and adding extra buttons to it. I'd like to do something similar but without voice recognition but would like to add more buttons and a second Picoborg Reverse and be able to control all the motors via the Web GUI.for speed control
Ive managed to create buttons for various speeds.
Idealy I would need buttons for forward/reverse,left and right ( M1+M2 Picoborg Rev 1) and forward/reverse (M1 Picoborg Rev 2).
Any help would be greatly appreciated.
john
piborg
Sat, 05/18/2019 - 23:00
Permalink
Response in the other thread
For anyone else who is interested, please see my response here :)
clankerr02
Tue, 05/12/2020 - 14:47
Permalink
More help needed regarding buttons
Hope you're all safe and well. Have a bit of time now to get back into my various projects.
As i will be running my picoborg reverse based robot headless, starting from cron and being controlled via web ui is there a way to add a button on the web ui to shut the raspberry pi down safely ?
Also Ive tried using a battborg to power the raspberry pi connected to the pico borg reverse from an 18v 4.ah rechargeable drill battery but I get a low voltage indicator on my desktop, is this normal with the battborg and isit something to worry about ? BTW my motors are not connected to the battery.
Cheers & keep safe.
piborg
Tue, 05/12/2020 - 19:07
Permalink
Shutdown button
Adding a shutdown button is fairly easy :)
All we need the script to do is call the command
sudo shutdown -h now
- this will shut everything down in the same way as the shutdown button does on the desktop.First we will need the
os
module to run the command. Add it to the imports at the top:Now look for the following line:
Above it we will add another section that will respond to the
/shutdown
URL:Most of that code simply returns the message "Shutting down..." to the browser. The last line uses
os.system
to run the shutdown command mentioned before.At this point entering that sub-page will shut the Pi down (e.g. http://192.168.0.100/shutdown), all we need now is a button to do that.
The next steps will need to be done in both the
/
and /hold sections if you want the button on both.Start by looking for the
Off
function in the HTML code:This opens the
/off
page to turn the motors off.Make a copy below it called
Shutdown
which goes to/shutdown
instead.Now look for the HTML line for the Photo button (towards the bottom of the section):
Make a copy below it with a different name which calls
Shutdown()
instead:There should now be a button labelled "Shutdown" near the bottom of the page next to the photo button :)
clankerr02
Wed, 05/13/2020 - 19:38
Permalink
shut down button
Thanks, works like a dream.
i have noticed a /hold there is a section called key management. What keys do these refer to? are they on the keyboard attached to the pi or on the device viewing the Pi ?
Thanks again.
piborg
Wed, 05/13/2020 - 21:30
Permalink
Keyboard controls
That feature was kindly added by wingers recently :)
It is intended to detect the arrow keys on the viewing device only, works while the keys are held.
See added touch mode /touch,and keyboard control added to /hold mode
clankerr02
Mon, 05/18/2020 - 15:57
Permalink
Keyboard controls-update
Hi, ive used these controls on my laptop conected wirelessly to the Pi and its brilliant ! Thanks @wingers.
I took it a step further. I downloaded a programme Joytokey (https://joytokey.net/en/) remapped the buttons to match my arrow keys and am now able to use my generic game cotroller connected to my laptop to control my robot. similar to the old renote joy. Hope this helps others.
BTW How are is the Keyboard numbered? is there a generic map?
Thanks again.
piborg
Mon, 05/18/2020 - 17:30
Permalink
JavaScript key codes
There is a great page for getting the keycodes here: https://keycode.info/
There is a pattern to the mapping, but it is not obvious :)
piborg
Tue, 05/12/2020 - 19:12
Permalink
BattBorg low voltage indicator
This is fairly common, usually nothing to worry about. In most cases it will not affect anything, but if you are using USB or GPIO devices which need a precise 5V supply it may cause problems (most don't).
Usually the cause is too much resistance in the 3-pin cable between the BattBorg / PicoBorg Reverse and the Raspberry Pi carrying the 5V and GND connections. This can be reduced by using shorter cables and / or ones with a thicker conductor inside.