element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Pi IoT
  • Challenges & Projects
  • Design Challenges
  • Pi IoT
  • More
  • Cancel
Pi IoT
Blog [Pi IoT] Alarm Clock #19: Kiosk
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fvan
  • Date Created: 22 Aug 2016 8:05 AM Date Created
  • Views 811 views
  • Likes 4 likes
  • Comments 0 comments
  • fvan_piiot
  • piiot
  • kiosk
  • chromium
Related
Recommended

[Pi IoT] Alarm Clock #19: Kiosk

fvan
fvan
22 Aug 2016

  • Browser
  • Kiosk
  • Navigation
    • Trellis
    • Demo

 

In order to be able to visualise the home control interface on the touch screen, a browser is required. The resolution of the touch screen is limited to 800x480, so every pixel counts. By putting the browser in full screen mode and hiding all the navigation bars, maximum space is made available. This is often referred to as "kiosk mode".

image

 

Browser

 

Rick has already demonstrated how to put the stock browser "Epiphany" in kiosk mode. In order to try something different and be able to compare with Rick's solution, I decided to use the Chromium browser instead.

 

Chromium is not available in the default repositories. But according to this thread, Chromium can be sourced from the Ubuntu repositories, in order to install on Raspbian Jessie.

 

First, add the new source:

 

pi@piiot1:~ $ sudo nano /etc/apt/sources.list.d/chromium-ppa.list

deb http://ppa.launchpad.net/canonical-chromium-builds/stage/ubuntu vivid main

 

Apply the key to verify the downloaded packages:

 

pi@piiot1:~ $ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DB69B232436DAC4B50BDC59E4E1B983C5B393194

 

Update your package list and install chromium:

 

pi@piiot1:~ $ sudo apt-get update

pi@piiot1:~ $ sudo apt install chromium-browser

 

Test the installation by launching the browser. I tried it via SSH and got following error:

 

pi@piiot1:~ $ chromium-browser
[16670:16670:0818/222510:ERROR:browser_main_loop.cc(271)] Gtk: cannot open display:

 

To solve this issue, specify which display to use the browser with (the touch screen):

 

pi@piiot1:~ $ chromium-browser --display=:0

 

Tadaaa! Chromium is installed and running on Raspberry Pi. image

 

Kiosk

 

With Chromium installed and executable, let's take a look at some interesting switches. Switches are command line parameters that can be passed when launching Chromium, altering its behaviour and/or appearance.

 

For my application, these seemed like the most relevant switches:

  • --display: specify the display to launch the browser on
  • --kiosk: enable kiosk mode, full screen without toolbars or menus
  • --noerrdialogs: do not display any error dialogs
  • --disable-pinch: disable pinching to zoom
  • --overscroll-history-navigation: disable swiping left and right to navigate back and forth between pages

 

Launching the full command can then be done as follows:

 

pi@piiot1:~ $ chromium-browser --display=:0 --kiosk --noerrdialogs --disable-pinch --overscroll-history-navigation=0 http://element14.com

 

Navigation

 

At startup, the Chromium browser is started with different tabs. These tabs are not visible due to the kiosk mode though (and can't accidentally be closed either). In order to navigate between these tabs and refresh their content, we need to know how to simulate the correct keypresses, triggering the tab switching.

 

This is done as follows:

 

pi@piiot1:~ $ xte "keydown Control_L" "key 3" -x:0 && xte "key F5" -x:0

 

What this does, is switch tab by simulating the "CTRL + <TAB_ID>" combination, optionally followed by an "F5", refreshing the selected tab.

 

Trellis

 

In order to implement this tab switching functionality, I'm using the 4x4 button matrix called Trellis, which I introduced in my previous post. It connects to the I2C pins and requires two software libraries to be installed.

 

On the hardware side, nothing fancy: connect the Trellis to the I2C pins and power it via the 5V pin:

image

 

 

On the software side, start by installing some dependencies, if not yet installed:

 

pi@piiot1:~ $ sudo apt-get install build-essential python-pip python-dev python-smbus git

 

Download and install Adafruit's Python GPIO library:

 

pi@piiot1:~ $ git clone https://github.com/adafruit/Adafruit_Python_GPIO
pi@piiot1:~ $ cd Adafruit_Python_GPIO/
pi@piiot1:~/Adafruit_Python_GPIO $ sudo python setup.py install
pi@piiot1:~/Adafruit_Python_GPIO $ cd ..

 

Download Adafruit's Python Trellis library, in order to apply some changes before installation:

 

pi@piiot1:~ $ git clone https://github.com/tdicola/Adafruit_Trellis_Python
pi@piiot1:~ $ cd Adafruit_Trellis_Python/

 

Update the Trellis library to make use of the GPIO library:

 

pi@piiot1:~/Adafruit_Trellis_Python $ nano Adafruit_Trellis.py
...
try:
        #import Adafruit_I2C
        import Adafruit_GPIO.I2C as I2C
...
        def begin(self, addr = 0x70, bus = -1):
                """Initialize the Trellis at the provided I2C address and bus number."""
                #self._i2c = Adafruit_I2C.Adafruit_I2C(addr, bus)
                self._i2c = I2C.Device(addr, bus)
...

 

Install the updated library:

 

pi@piiot1:~/Adafruit_Trellis_Python $ sudo python setup.py install
pi@piiot1:~/Adafruit_Trellis_Python $ cd examples/

 

Depending on whether or not the I2C address was changed by shorting some pads at the back, adapt the code to take into account the correct address:

 

pi@piiot1:~/Adafruit_Trellis_Python/examples $ nano TrellisTest.py
...
trellis.begin((0x72, I2C_BUS))
...

 

Test the installation by running the example script:

 

pi@piiot1:~/Adafruit_Trellis_Python/examples $ sudo python TrellisTest.py
Trellis Demo
Press Ctrl-C to quit.
v8
v11
v8
v11
v8
v8
v0
v0

 

The Trellis keypad is now installed and usable!

 

Demo

 

Adding the "xte" commands to a modified Trellis Python script, the tab switching is implemented.

 

The below script does the following:

  • stop all running chromium browsers and launch a new one with 4 tabs
  • listen for keypresses on the first 4 buttons
  • if a button is pressed, turn of the previous button's led, and turn on this one
  • select the matching tab in the browser

 

#!/usr/bin/env python

import time
import os
import Adafruit_Trellis

trellis = Adafruit_Trellis.Adafruit_TrellisSet(Adafruit_Trellis.Adafruit_Trellis())
trellis.begin((0x72, 1))

for i in range(16):
        trellis.clrLED(i)
        trellis.writeDisplay()
        time.sleep(0.05)

os.system("sudo killall chromium-browser ; chromium-browser --display=:0 --noerrdialogs --kiosk --disable-pinch --overscroll-history-navigation=0 http://element14.com http://raspberrypi.org http://enocean.com http://frederickvandenbosch.be &")

j = 0
trellis.setLED(0)

while True:
  time.sleep(0.03)

  if trellis.readSwitches():
    for i in range(0, 4):
      if trellis.justPressed(i):
        trellis.clrLED(j)
        trellis.setLED(i)
        j = i
        os.system("xte 'keydown Control_L' 'key " + str(i+1) + "' -x:0")
        trellis.writeDisplay()

 

The visual result:

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

Almost there! I should now finalise the enclosure of the second unit, finish the voice commands and define the different views. *stress level rising*

 


image

 


Navigate to the next or previous post using the arrows.

image
  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube