1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
---
title: a kiosk for my kitchen
date: 2020-08-05
---
{% extends 'templates/base.html' %}
{% block body %}
<nav>
<a href='/projects'>> projects</a>
</nav>
<header>
<h1>{{ title }}</h1>
</header>
<article>
{% markdown %}
In a corner of my kitchen, there is a little touchscreen interface for "kitchen things".
Below is why I have that, what it's made of, and how it works.
## Why?
There are two main reasons why I want a kitchen kiosk unit:
- I have too Internet of Things things in my kitchen, and getting my phone out to control it is annoying.
- I want to record when I drink coffee, when I snack, etc, and getting my phone out to log that is annoying.
## What?
I already have a Raspberry Pi in the Kitchen to provide [WiFi](/wifi) and [audio](/multi-room-audio), so extending that is a good start.
I could create a custom control panel with physical buttons, but adding a touchscreen to an existing unit is easier.
So I got the official Raspberry Pi touchscreen, a stand for the screen, and voila, the hardware side is done.
## How?
Continuing with the theme of minimal effort for maximum gain, I decided to use my existing skills and implement the UI with a website:
- I can hack up a webserver pretty fast.
- Chromium has a kiosk mode.
- Chromium can handle rendering and input.
This means that all I need to do is make Chromium start on boot, and write a simple webserver!
From a standard Raspbian image, install the relevant softwares:
$ sudo apt install chromium lightdm xinput
Then, create a user to run Chromium, here called `kiosk`:
$ sudo adduser kiosk
Next, we're going to use `lightdm` to bring up Xorg and automatically log in as `kiosk`:
$ cat /etc/lightdm/lightdm.conf
[Seat:seat0]
type=local
pam-service=lightdm-autologin
autologin-user=kiosk
autologin-user-timeout=0
xserver-command = X -nocursor
For our `kiosk` user to set the brightness, we need to add a `udev` rule to make it writeable:
$ cat /etc/udev/rules.d/50-backlight.rules
SUBSYSTEM=="backlight",RUN+="/bin/chmod 666 /sys/class/backlight/%k/brightness /sys/class/backlight/%k/bl_power"
Finally, `kiosk`'s graphical login script (`~/.xsession`) will set the brightness and display-sleep modes, then start Chromium:
$ cat /home/kiosk/.xsession
readonly standby_seconds=60
readonly suspend_seconds=60
readonly off_seconds=60
readonly brightness_percent=50
# TODO: write a custom UI webserver.
readonly website="https://ethulhu.co.uk"
xset dpms "${standby_seconds}" "${suspend_seconds}" "${off_seconds}"
echo "${brightness_percent}" > /sys/class/backlight/rpi_backlight/brightness
exec chromium --noerrdialogs --kiosk --incognito "${website}"
Reboot the Raspberry Pi, and it should automatically log in as `kiosk` and run the website.
{% endmarkdown %}
</article>
{% endblock %}
|