|
3 months ago | |
---|---|---|
baconscript@8056c0098a | 3 months ago | |
.gitignore | 1 year ago | |
.gitmodules | 1 year ago | |
LICENSE.md | 1 year ago | |
README.md | 3 months ago | |
buttond.py | 3 months ago | |
buttons.cfg | 1 year ago | |
buttons.service | 1 year ago | |
server.cfg | 1 year ago |
Use buttons connected to a Rasberry Pi GPIO to trigger Hog 4 comment macros.
If you are new to Raspberry Pi consider reading some brief introductory tips.
Install Raspbian the usual way.
Enable the ssh server.
> touch /Volumes/boot/ssh
Eject the SD card and boot the Raspberry Pi.
Use SSH to log into the Pi from your computers Command Line (Windows) or Terminal (Mac):
> ssh pi@PI_IP_ADDRESS
The default password is raspberry
.
Use sudo raspi-config
to;
Update the package manager and install the aptitude program.
> sudo apt-get update
> sudo apt-get install aptitude
> sudo aptitude upgrade
> sudo shutdown -r now
> sudo aptitude install git python3-pip python3-gpiozero
> sudo pip3 install gpiozero antlr4-python3-runtime python-osc
/home/pi
:> cd /home/pi
If you didn't notice any change you might already be in the correct directory. You can confirm this by using the command
pwd
to print the working directory. It should print:/home/pi
> git clone --recurse-submodules https://git.company235.com/kevin/ContactPi.git
> cd ContactPi
> sudo cp buttons.service /lib/systemd/system/buttons.service
> sudo systemctl daemon-reload
> sudo systemctl enable buttons.service
> sudo systemctl start buttons.service
You may use any of the numbered GPIO pins available on the PI:
Nano is a command line text editor that is available by default on the Pi. For a usage overview, read The Beginner's Guide to Nano
> nano buttons.cfg
This file configures which Raspberry Pi GPIO pins trigger which comment macros.
The button
section contains a comma separated list of named button sections.
This is a sample buttons.cfg file:
[button]
names=switch1,switch2,switch3,switch4
[switch1]
pin: 12
close: "gl21/2"
open: "gl21/1"
[switch2]
pin: 16
close: "gl22/2"
open: "gl22/1"
[switch3]
pin: 20
close: "gl23/2"
open: "gl23/1"
[switch4]
pin: 21
close: "gl24/2"
open: "gl24/1"
ContactPi uses Bacon Script to abstract the underlying OSC. The README file of that project contains additional details about the syntax for configuring comment macros.
ctrl+x
to exit.> nano server.cfg
Contact Pi only sends OSC commands to the first server in this list unless the net number is explicitly specified in the comment macro.
EXAMPLEh22
.
This is a sample server.cfg file:
[network]
hogs = hog4_235, hedgehog_235, server_pc, server_rackhog
[hog4_235]
ip: 10.235.1.53
port: 7001
net: 53
[hedgehog_235]
ip: 10.235.1.63
port: 7001
net: 63
[server_pc]
ip: 10.235.1.12
port: 7001
net: 12
[server_rackhog]
ip: 10.235.1.22
port: 7001
net: 22
Once the file has been configured ctrl+x
to exit.
Restart buttons.service to apply changes.
> sudo systemctl restart buttons.service
buttons
systemd service.> sudo systemctl status buttons.service
● buttons.service - OSC Button Watcher
Loaded: loaded (/lib/systemd/system/buttons.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2020-11-20 14:27:43 EST; 3s ago
Main PID: 1032 (python3)
Tasks: 6 (limit: 1433)
CGroup: /system.slice/buttons.service
└─1032 /usr/bin/python3 /home/pi/ContactPi/buttond.py
Nov 20 14:27:43 raspberrypi systemd[1]: Started OSC Button Watcher.
Nov 20 14:27:43 raspberrypi python3[1032]: Adding Hog device at net# 53
Nov 20 14:27:43 raspberrypi python3[1032]: Adding Hog device at net# 63
Nov 20 14:27:43 raspberrypi python3[1032]: Adding Hog device at net# 12
Nov 20 14:27:43 raspberrypi python3[1032]: Adding Hog device at net# 22