Magimedia
Posts: 33
Joined: Sun Feb 22, 2015 8:31 pm

Customising KWeb?

Fri Mar 20, 2015 8:42 pm

I want to interface a web page on the Pi with some hardware on the GPIO (mainly buttons and a couple of LEDs. I'm not sure of the best way to do this. I wondered if a plugin could be written for KWeb, or even customised and recompiled. What is the best way to approach this requirement?

gkreidl
Posts: 6307
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Customising KWeb?

Fri Mar 20, 2015 10:24 pm

It depends on the complexity of your project.

Action being issued from the web page are simple as kweb supports any kind of command, script, program with special links, buttons or forms.

Listening to events (button pressed) is not so easy but can be done for simple things, if you control kweb remotely from a script using xdotool. An easy way might be sending user definable keyboard commands (ALT+0 ... ALT+9I) to load special pages which in turn can execute commands etc.

Check the kweb manual for details and examples.

For more complex stuff you need a web server with kweb as front end.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

Magimedia
Posts: 33
Joined: Sun Feb 22, 2015 8:31 pm

Re: Customising KWeb?

Sat Mar 21, 2015 1:31 am

In terms of what would be most useful, would be the ability to read from, or write to, the GPIO pins from a Javascript library. Manipulating the stuff in Javascript is no problem once it's in, but interfacing with it is the issue. Is there anything in kweb that can do this, or plans to add it?

gkreidl
Posts: 6307
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Customising KWeb?

Sat Mar 21, 2015 5:15 am

Magimedia wrote:In terms of what would be most useful, would be the ability to read from, or write to, the GPIO pins from a Javascript library. Manipulating the stuff in Javascript is no problem once it's in, but interfacing with it is the issue. Is there anything in kweb that can do this, or plans to add it?
No. That would require interfacing to the DOM and the Javascript library which would make the browser ten times more complex that it is now.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

Magimedia
Posts: 33
Joined: Sun Feb 22, 2015 8:31 pm

Re: Customising KWeb?

Sat Mar 21, 2015 11:05 am

That's what I thought, hence wondering about a plugin. If I could write something in Python to do the main leg work, and then expose function calls to KWeb, it would make it infinitely expandable. It would seem a sensible feature for K Web too, since a kiosk could then be any customised display unit, including POS built to spec.

gkreidl
Posts: 6307
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Customising KWeb?

Sat Mar 21, 2015 11:22 am

Magimedia wrote:That's what I thought, hence wondering about a plugin. If I could write something in Python to do the main leg work, and then expose function calls to KWeb, it would make it infinitely expandable. It would seem a sensible feature for K Web too, since a kiosk could then be any customised display unit, including POS built to spec.
kweb already has a kind of plugin-interface (using Python scripts) and this is much more than any other browser supports, but that is only in one direction. Limited control from the outside is possible via xdotool.

For everything more complex, use a web server approach and some real time connection using AJAX calls.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

Magimedia
Posts: 33
Joined: Sun Feb 22, 2015 8:31 pm

Re: Customising KWeb?

Sat Mar 21, 2015 4:59 pm

So I need to learn how to setup websockets using Tornado or similar? As far as I know, using AJAX for browser-instigated stuff is fine, but it doesn't support push, so I'd have to use up a lot of CPU time repeatedly polling with AJAX calls, which would expect to eat a lot of CPU.

Any better methods than this, or is it time to sit down and start learning?

Magimedia
Posts: 33
Joined: Sun Feb 22, 2015 8:31 pm

Re: Customising KWeb?

Sat Mar 21, 2015 5:39 pm

Node.js ?

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Customising KWeb?

Sun Mar 22, 2015 9:58 am

It doesn't really matter what server , framework ,
framework + server or framework-with-integrated-server
you use. The mechanism you need is server push and has a
myriad of solutions (Long polling , Websockets , iframes , Server
Sent Events and more) and is language-agnostic on
the server-side.

You will propably still need JS in the browser though.
Have fun !


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

Return to “General discussion”