# Listener software (Mplayer + drivers)

## Summary

User: grace
Hostname: listener.local
Password: emergence
Running mplayer, soundcard library, lcd graphics library, and custom python code for text printing logic.

## Bill of Materials

- Raspberry pi zero wh - https://www.waveshare.com/product/raspberry-pi/boards-kits/raspberry-pi-zero-2-w-cat/raspberry-pi-zero-2-w.htm?sku=21038
- Waveshare UPS with 1000mah battery - https://www.waveshare.com/ups-hat-c.htm
- Waveshare sound card hat with speakers- https://www.waveshare.com/wm8960-audio-hat.htm
- 1602 LCD screen - https://www.waveshare.com/lcd1602-i2c-module-blue.htm?sku=30496
- Jumper wires - https://www.waveshare.com/product/accessories/adapters-cables-antennas/jumper-wires/jumper-wire-1-pin-2.54-pitch-200mm.htm
- mini HDMI to hdmi cable - https://hosatech.com/products/video/hdmi/hdmc-400/
- micro USB male to usb a femail adapter - https://www.amazon.com/dp/B01C6032G0
- Keyboard with usb a cable - https://www.amazon.com/AmazonBasics-Matte-Keyboard-QWERTY-Layout/dp/B07WJ5D3H4/

## Hardware assembly

- Solder header to the pi if not pre-soldered
- Plug the battery into the UPS board
- Screw the UPS to the pi
- Screw a next level of standoffs to the pi
- Put the audio hat on the pi's headers, and screw it to the standoffs
- Plug in the speakers
- Plug the jumper wires into the screen and the pi according to the [screen-wiring.png](screen-wiring.png) file (via https://peppe8o.com/1602-lcd-raspberry-pi-display/).

## Pre work

1. install raspian lite 64 for raspi zero
2. configure user and wifi and turn on ssh services when you install
3. boot
4. find the ip address of the pi and ssh to it

## Setup instructions

### Creature comforts

1. sudo apt update && install git vim zsh
2. sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

### Install Waveshare soud card drivers

#### Install drivers

Following instructions instructions at https://www.waveshare.com/wiki/WM8960_Audio_HAT

1. git clone https://github.com/waveshare/WM8960-Audio-HAT
2. cd WM8960-Audio-HAT
3. sudo ./install.sh
4. sudo reboot
5. sudo dkms status
6. Check the output of dkms to confirm that drivers installed correctly
7. sudo apt install mplayer

#### Test radio

mplayer -playlist http://blackportaldetroit.com:1313/portal.m3u

#### Daemonize radio

sudo vim /lib/systemd/system/player.service

```
[Unit]
Description=Listenign Service
[Service]
User=root
Type=simple
Restart=on-failure
RestartSec=5
WorkingDirectory=/home/grace
ExecStart=mplayer -playlist http://108.204.128.201:1313/portal.m3u

[Install]
WantedBy=multi-user.target
```

sudo systemctl daemon-reload
sudo systemctl enable player

sudo reboot

#### Raise volume

alsamixer
sudo alsactl store

### LCD screen and sound processing logic

Install software from this repo

1. sudo raspi-config
2. enable i2c in interface options
3. i2cdetect -y 1
4. confirm that i2cdetect tells you the address 27.

5. curl https://get.volta.sh | bash
6. volta install node
7. git clone git@git.featherboaz.com:boazsender/portal.git

8. cd portal && npm install
9. npx prisma generate && npx prisma db push && npx prisma db seed

10. sudo vim /lib/systemd/system/screen.service

```
[Unit]
Description=Screen Service
[Service]
User=root
Type=simple
Restart=on-failure
RestartSec=5
WorkingDirectory=/home/grace
ExecStart=/home/grace/.volta/bin/node /home/grace/portal/build/screen.js

[Install]
WantedBy=multi-user.target
```

11. sudo systemctl daemon-reload
12. sudo systemctl enable screen
