# onsetswitch Use buttons connected to a Rasberry Pi GPIO to trigger Hog 4 comment macros. ## Prep * Install Raspbian [the usual way.](https://www.raspberrypi.org/documentation/installation/installing-images/README.md) * Enable the ssh server. On a mac: ```sh touch /Volumes/boot/ssh ``` * Eject the SD card and boot the Raspberry Pi. * Use SSH to log into the Pi: ```sh ssh pi@raspberrypi ``` * Use raspi-config to; ```sh sudo raspi-config ``` * set locale * set timezone * enable ssh server * enlarge the file-system to fill the SD card * reboot * Update the Apt and install aptitude ```sh sudo apt-get update sudo apt-get install aptitude ``` * Use aptitude to upgrade the Pi. ```sh sudo aptitude upgrade ``` * Reboot the Pi. ```sh sudo shutdown -r now ``` * Logging back into the Pi, install sane set of software packages. ```sh sudo aptitude install git python3-pip python3-gpiozero sudo pip3 install gpiozero antlr4-python3-runtime python-osc ``` ## Installing ```sh cd /home/pi git clone --recurse-submodules https://git.company235.com/kevin/onsetswitch.git cd onsetswitch ``` ## Configuring ### Input Connect one side of the button to ground, the other to a GPIO pin. ![](https://gpiozero.readthedocs.io/en/stable/_images/button_bb.svg) Configure the buttons: ```sh nano buttons.cfg ``` ### Output Configure the Hog4 OSC server: ```sh nano server.cfg ``` ## Enabling on Boot Link the onsetswitch service file to systemd: ``` sudo cp buttons.service /lib/systemd/system/buttons.service ``` Enable the service at startup: ```sh sudo systemctl daemon-reload sudo systemctl enable buttons.service ``` Start the buttond service: ``` sudo systemctl start buttons.service sudo systemctl status buttons.service ```