How to control Screenly OSE with gestures using the Flick

Anthias |
How to control Screenly OSE with gestures using the Flick

Last week our friends over at Pi Supply launched a cool new product called Flick. In short, it’s a HAT (i.e. add-on board) for the Raspberry Pi that enables you to use gestures to control the Raspberry Pi.

A pi-topCEED running Screenly OSE

I got my hands on one of these and the first thing that came to my mind was to use it to add gesture controls for Screenly OSE.

Setup

First, you need to install the driver and Python library for the Flick, this is as simple as typing in one command. Once installed, you can use the test application to ensure that it is working properly.

With the Flick installed, install Screenly OSE. Similarly, it’s just one line of code. This installation will however take a bit longer, as it requires a fair number of dependencies to be installed.

In terms of hardware, my particular setup is using a pi-topCEED, which is a great little hardware kit. It also hides the board behind plexiglass, creating a better looking device. Unfortunately, since I didn’t have any pi-topPROTO, I had to run a separate power cable to power the Raspberry Pi in order to use it with the Flick.

I had to disable the pi-top power supply to the Raspberry Pi to fit the Flick HAT.

I had to disable the pi-top power supply to the Raspberry Pi to fit the Flick HAT.

Integration

Since my objective was simply to detect movement, the coding part was very straight forward. In short, the script below simply compares the previous and current state of the sensor to determine if there was a movement. If a movement is detected, the script sends a SIGUSR1 signal to viewer.py which causes it to jump to the next image.

#!/usr/bin/env python

import flicklib
import subprocess
from time import sleep
from copy import copy


@flicklib.move()
def move(x, y, z):
  global xyz
  xyz = [x,y,z]


def main():
  global xyz
  xyz = [0,0,0]
  old_xyz = [0,0,0]

  while True:
    if old_xyz != xyz:
      print 'Detected movement. Sending Bat-signal to Screenly!'
      subprocess.call(['pkill', '-SIGUSR1', '-f', 'viewer.py'])
      sleep(1)
    old_xyz = copy(xyz)
    sleep(0.3)


if __name__ == "__main__":
  main()

The approach is very much similar to the approach used in the previous article How to add a physical button to Screenly OSE using Node-RED.

Happy hacking!

Picture of Viktor Petersson
Viktor Petersson View Profile
CEO and Co-founder of Screenly. Viktor loves taking ideas and turning them into products and services. You can frequently find him on the speaking circuit around the globe. He spent a big part of his adult life as a digital nomad. Viktor is also passionate about DevOps and IoT security. You can find Viktor on Twitter under @vpetersson.

Recent Posts

Blog Post | December 16, 2024

Screenly Changelog Episode 6

Read More

Display your best content with Screenly digital signs.

Screenly is loaded with features to make digital signage management easy.

footer screen image
manage cookies