An audio loop recorder for raspberry pi.
These are the things the app is resposible for doing, in order to integrate with the soft power controller.
-
Set pin 8 (RSTOPPED) HIGH. It should already be high because it's used by the UART to transmit. But this keeps it high until the raspi is very nearly shutdown.
-
Set pin 12 (RBOOTED) HIGH. This will tell the soft power controller that the raspi has fully booted.
-
Read pin 13 (SHUTDOWN). On HIGH, shut the raspi down.
-
Read pins 10 (BATTERY STATUS DATA) and 11 (BATTERY STATUS CLOCK) to get the current battery level.
npm run watch
npm run client:start
npm run server:start
npm run build
-
Download the Lite version of Raspbian and copy to an SD card. You want the Lite version because it comes with a lot less crap and we can just install what we need instead.
-
Set up your raspberry pi.
-
Install these packages:
apt-get install vim git
-
Install node (might need to change the wget URL here to a newer version):
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh | bash # you might need to re-login here to get nvm in your path nvm install stable # this installed version 8.5.0 for me
-
Make sure the user you're running as is a member of the
gpio
group:usermod -aG gpio username
The rotary encoder I have (https://www.adafruit.com/product/377) has two leads for the push-button and three for the rotary encoder. Apparently the three rotary encoder pins use Gray code.
button button
+--|---------|--+
| |
| |
| |
+--|----|----|--+
L GND R
I'm not sure if this is really Gray code. It's just what I figured out messing around with the encoder. I have my L
and R
pins set high initially. This is the process I used for reading the code from the encoder:
- Both pins start high and will remain high until the encoder is turned.
- One pin goes low: a turn has been initiated (it doesn't matter which pin goes low)
- Both pins are low: about to get the direction the encoder turned.
- One pin goes high:
- If
L
goes high, it's a clockwise turn - If
R
goes high, it's a counter-clockwise turn
- If
- Both pins will go high again and everything resets.
Here are graphs of the patterns. You'll notice that they both pins start and end high; the reset state.
Clockwise turn
L / -__--
R / --__-
States
L1, R1
L0, R1
L0, R0
L1, R0
L1, R1
Counter-clockwise turn
L / --__-
R / -__--
States
L1, R1
L1, R0
L0, R0
L0, R1
L1, R1
This lets you build a state machine that works with rpio
's polling mechanism, where the direction is read at the end, just before both pins go high again.
-
These are the pin connections I used:
Description TFT Pin Raspi Pin TFT Data Out (MISO) 33 21 Clock (SCLK) 37 23 TFT Data In (MOSI) 34 19 D/C 36 18 Reset 10 16 Chip Select 38 24 -
See list of supported devices for module:
sudo modprobe fbtft_device name=list; dmesg | tail -50
We want
adafruit28
-
Edit
/etc/modprobe.d/fbtft.conf
and add the following:options fbtft_device name=adafruit28 cs=0 gpios=reset:23,dc:24 rotate=0
-
Edit
/etc/modules-load.d/fbtft.conf
and add:spi-bcm2835 fbtft_device
-
Add the following the end of the line in
/boot/cmdline.txt
(right afterrootwait
)fbcon=map:10 fbcon=font:VGA8x8 logo.nologo
-
For a better console font:
sudo dpkg-reconfigure console-setup
and select: UTF 8 > Guess optimal... > Terminus > 6x12 -
Turn on console output:
sudo con2fbmap 1 1
-
Restart
To output to the screen, modify permissions on /dev/tty1
:
sudo chmod 666 /dev/tty1
Send text to the screen via ssh:
echo -ne "asdf" > /dev/tty1
Wake the screen up if it's gone to sleep:
echo -ne "\033[9;0]" > /dev/tty1
Clear the screen:
echo -ne "\033[2J" > /dev/tty1
Disable the blinking cursor:
echo -ne '\033[?17;0;0c' > /dev/tty1
Edit /boot/cmdline.txt
and add this to the end of the line:
consoleblank=0
I set things up to login to a specific user on startup and run the project app.
-
Automatically login to the
app
user, edit/etc/systemd/system/getty.target.wants/[email protected]
and add this line under[Service]
:ExecStart=-/sbin/agetty --autologin app --noclear %I $TERM
-
Enable the service:
systemctl enable getty@tty1
-
Run a specific program, add this to end of
app
's.bashrc
file:# clear the screen echo -ne "\033[2J" # start the app cd /home/app/charloop && node app.js
-
Install
fbi
:apt-get install fbi
-
Create
/etc/systemd/system/splashscreen.service
with:[Unit] Description=Splash screen DefaultDependencies=no After=local-fs.target [Service] ExecStart=/usr/bin/fbi --noverbose -a /opt/splash.png StandardInput=tty StandardOutput=tty [Install] WantedBy=sysinit.target
-
Copy your splash image to
/opt/splash.png
. Make it240x320
to exactly fit the screen. -
Enable the service:
systemctl enable splashscreen
-
This might remove some: edit
/boot/cmdline.txt
and add:quiet loglevel=3
-
This will clear the screen after everything else is run, so at least you see less text after the splash screen goes away. Add this to the end of
etc/rc.local
:# clears the screen echo -ne "\033[2J"
-
Disable the motd. Edit
/etc/pam.d/login
, comment out these lines:#session optional pam_lastlog.so #session optional pam_motd.so motd=/run/motd.dynamic #session optional pam_motd.so noupdate #session optional pam_mail.so standard
-
Remove some extra login messages and clear the screen on the login prompt:
sudo su - clear > /etc/issue
Bluetooth was causing a pin to stay high, that I was hoping to use to determine when the Raspi shut down. Also, bluetooth isn't used and will just waste power.
- Add this to
/boot/config.txt
:
# Disable Bluetooth
dtoverlay=pi3-disable-bt
- Disable related services:
sudo systemctl disable bluetooth.service
- Restart
I want to use a "soft power" switch to turn the Raspi on/off (because it's a computer, yo). I don't want it to consume any power while it's off. I came up with an idea that I think will work. I'll include a schematic and a state machien diagram hopefully. It uses an ATTiny85. The code is in the soft-power
folder.
NOTE: The makefile uses avr-gcc
and avrdude
to compile and upload. It also assumes you're using a usbtiny
programmer, like the Sparkfun Pocket AVR Programmer.
-
Connect your programmer
-
Compile and upload
$ cd soft-power $ make upload
- Raspberry Pi 3 - Model B
- Analog to Digital Converter - MCP3002
- SparkFun microB USB Breakout
- 2.8" TFT Display with Resistive Touchscreen
- Adafruit 50 pin 0.5mm pitch FPC Adapter. The pin numbering on this is reversed from what the pins will actually be when you plug in the ribbon cable for the 2.8" display. This may not be true of all displays, so check the ribbon cable and connector before soldering stuff.
- 50-pin 0.5mm pitch top-contact FPC SMT Connector
- Rotary Encoder
- Rail-to-Rail Op Amp
- Copy image to SD card (Mac)
- Enable headless SSH
- Set up Chromium kiosk mode on Raspbian Lite
- Raspberry Pi pinout
- A guitar pedal made with Raspberry Pi
- Guitar pedal curcuit diagram