Misc. Notes
===

###### 2019-11-01

* [Raspberry Pi Configuration](https://www.raspberrypi.org/documentation/configuration/)

Custom Splash Screen
---

[src](https://yingtongli.me/blog/2016/12/21/splash.html)

In `/boot/config.txt`, add:

```
disable_spash=1
```

optionally:

```
disable_overscan=1
```

---

In `/boot/cmdline.txt`, add:

```
logo.nologo consoleblank=0 loglevel=1 quiet
```

---

By hand run

```
systemctl disable getty@tty1
```

---

```
apt install fbi
```

Create `/etc/systemd/system/splashscreen.service`:

```
[Unit]
Description=Splash screen
DefaultDependencies=no
After=local-fs.target

[Service]
ExecStart=/usr/bin/fbi -d /dev/fb0 --noverbose -a /opt/splash.png
StandardInput=tty
StandardOutput=tty

[Install]
WantedBy=sysinit.target
```

With `/opt/splash.png` 

---

Might need to kill `fbi` when starting the kiosk.

---

#### update

using this [guide](https://scribles.net/customizing-boot-up-screen-on-raspberry-pi/) instead, you can change the splash screen in:

```
/usr/share/plymouth/themes/pix/splash.png
```

to something custom.

### Custumizing X

[src](https://www.ketzler.de/2017/12/installing-chromium-on-raspberry-pi-without-desktop/) and [src](https://www.matteomattei.com/web-kiosk-with-raspberry-pi-and-read-only-sd/)

```
apt-get install matchbox-window-manager

```

into somthing like `start-kiosk.sh`
```
#!/bin/sh

export BASEDIR=/home/pi

/usr/bin/matchbox-window-manager -use_cursor no -use_titlebar no & 

#/usr/bin/chromium-browser  --no-sandbox

# clear out warning bar on chromium
#
tmpfn=`mktemp`
jq '.profile.exited_cleanly = true' $BASEDIR/.config/chromium/Preferences | jq '.profile.exit_type = "Normal"' > $tmpfn
mv $tmpfn $BASEDIR/.config/chromium/Preferences

# start chromium in kiosk mode
#

xset s noblank
xset s off
xset -dpms
unclutter -idle 0.05 -root &

#/usr/bin/chromium-browser --noerrdialogs --disable-infobars --kiosk ./html/index.html
#
#  --no-sandbox \
#  --disable-application-cache \
/usr/bin/chromium-browser \
  --test-type \
  --no-sandbox \
  --noerrdialogs \
  --disable-infobars \
  --aggressive-cache-discard \
  --incognito \
  --disable-pinch \
  --overscroll-history-navigation=0 \
  --kiosk \
  'http://localhost:60535'
```

`--test-type` is needed to get rid of the `--no-sandbox` warning and the `--no-sandbox` is needed
or else chromium crashes when being used by `xinit` (see [here](https://groups.google.com/a/chromium.org/forum/#!topic/chromium-discuss/O4WpwWvGz4A)).

---

```
update-alternatives --config x-window-manager
update-alternatives --display x-window-manager
```

---

Note I was having problems with the 'dim' function as it wasn't executing correctly
(needed to be root instead of pi) and the display was wrong.

One way to discover which display is being used is:

```
# ps aux | grep xserver
root       808  0.0  0.0   3872   704 ?        S    Jan30   0:00 xinit /home/bus/bin/start-kiosk.sh -- /etc/X11/xinit/xserverrc :0 -auth /tmp/serverauth.vJgHr6zsRs
root      3354  0.0  0.0   3872   788 tty1     S+   Jan30   0:00 xinit /home/bus/bin/start-kiosk.sh -- /etc/X11/xinit/xserverrc :1 vt1 -keeptty -auth /tmp/serverauth.HSj8JTM2IM
root     27449  0.0  0.0   7348   524 pts/1    S+   05:48   0:00 grep xserver
```

---

From [an SO answer](https://unix.stackexchange.com/questions/209746/how-to-resolve-no-protocol-specified-for-su-user), need to load the 'magic cookie' for
X communication:

```
su - <otheruser> -c "unset XAUTHORITY; xauth add $(xauth list)"
```

### Packages

```
sudo apt install -y sox espeak mplayer ffmpeg alsa-utils
```

### Sound

Use `raspi-config` to force audio through the 3.5mm audio jack.

There's an issue with the HDMI 'going to sleep' and cutting off
the first two seconds of the audio if nothing is being played
through it.
The 3.5mm jack seems to not have that issue.

---

The 3.5mm jack has a lot of noise on the line.
The fix looks to be using a USB speaker.
For now we'll go with the 3.5mm jack but this will
eventually need replacement.

### Monitor

To get monitor resolution:

```
fbset -s
```

### System Setup

Make sure the following are installed:

```
apt install -y espeak mplayer
```

---

Enable ssh server (for debugging and setup):

```
systemctl enable ssh
systemctl start ssh
```

---

Run `raspi-config` and select option `4` for the screen (640x480 @ 60Hz):

```
raspi-config
```

---

Make sure to manually set volume on the waveshare screen (default is set at 50) from the buttons provided on the left.

---

Remove `libreoffice` to free up space (around 0.5Gb):

```
apt remove -y libreoffice libreoffice-base-core libreoffice-common libreoffice-core libreoffice-help-common libreoffice-help-en-gb libreoffice-help-en-us libreoffice-l10n-en-gb libreoffice-style-colibre libreoffice-style-tango
apt autoremove -y --purge

```

```
apt-get purge wolfram-engine scratch scratch2
```

---

Disable bluetooth:

```
echo 'dtoverlay=pi3-disable-bt >> /boot/config.txt
```

and related services (from [here](https://scribles.net/disabling-bluetooth-on-raspberry-pi/)):

```
systemctl disable hciuart.service
systemctl disable bluealsa.service
systemctl disable bluetooth.service
```

### GPRS fiddling

I'm still trying to get GPRS to work consistently.

Once the system is setup, it seems like it's pretty consistent, but getting `/dev/ttyGPRS` to be
consistently tied to the appropriate device is proving difficult...sometimes `/dev/ttyAMA0` works,
sometimes it's `/dev/serial0`, sometimes it's `/dev/ttyUSB0`, othertimes it looks like `/dev/ttyUSB2` works.

I notice messages of this sort happening most recently which could or could not be related to the the GPRS not working (`/var/log/syslog`):

```
Jan 30 11:56:23 raspberrypi systemd[1]: serial-getty@ttyAMA0.service: Succeeded.
Jan 30 11:56:23 raspberrypi systemd[1]: serial-getty@ttyAMA0.service: Service RestartSec=100ms expired, scheduling restart.
Jan 30 11:56:23 raspberrypi systemd[1]: serial-getty@ttyAMA0.service: Scheduled restart job, restart counter is at 198.
Jan 30 11:56:23 raspberrypi systemd[1]: Stopped Serial Getty on ttyAMA0.
Jan 30 11:56:23 raspberrypi systemd[1]: Started Serial Getty on ttyAMA0.
```

I followed [this](https://raspberrypi.stackexchange.com/questions/39165/how-can-i-stop-the-auto-login-console-and-getty-in-raspbian-8-jessie):

```
systemctl stop serial-getty@ttyAMA0.service
```

Disable permanently (SO answer suggested the ['mask'](https://raspberrypi.stackexchange.com/questions/47671/why-my-program-wont-communicate-through-ttyama0-on-raspbian-jessie)):


```
systemctl disable serial-getty@ttyAMA0.service
systemctl mask serial-getty@ttyAMA0.service
```



### Other References

* [raspberrypi.org: cmdline.txt](https://www.raspberrypi.org/documentation/configuration/cmdline-txt.md)
* [raspberrypi.org: 'How do I find out the display resolution?'](https://www.raspberrypi.org/forums/viewtopic.php?t=19817)
* [elinux.com: RPiconfig](https://elinux.org/RPiconfig)



