-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.sh
151 lines (101 loc) · 3.95 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
sudo usermod -a -G i2c,spi,gpio pi
# Linux packages
sudo apt install -y libmpv2 build-essential libpython3-dev libdbus-1-dev libglib2.0-dev libcairo2-dev libxt-dev libgirepository1.0-dev
#install uv
#uv venv venv
# source venv/bin/activate
export LDFLAGS="-lm"
uv pip install python3-mpv gpiozero pillow luma.oled requests adafruit-blinka adafruit-circuitpython-bme280 rpi-lgpio pi-ina219 pi-rc522 pycairo PyGObject
sudo apt install -y python3-venv libdbus-1-dev libudev-dev libical-dev libreadline-dev bluez-tools libglib2.0-dev libgirepository1.0-dev libcairo2-dev
# For luma.oled
sudo apt install -y python-dev python3-dev python-pip libfreetype6-dev libjpeg-dev build-essential libopenjp2-7 libtiff5
# For IR
sudo apt install -y lirc python-pylirc liblirc-dev
# sudo modprobe lirc_dev
# sudo modprobe lirc_rpi gpio_in_pin=17 gpio_out_pin=23
# sudo nano /boot/config.txt
# dtoverlay=lirc-rpi,gpio_in_pin=17,gpio_out_pin=23
# autologin pi
https://maker-tutorials.com/raspberry-pi-benutzer-automatisch-anmelden-booten/
cat /etc/systemd/system/[email protected]/autologin.conf
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin pi --noclear %I 38400 linux
# keep app running (may not work becuase of xdg_ and dbus session bus address env variables
sudo loginctl enable-linger pi
=======
# enable feature when installing pillow
(venv) pip3.9 install --upgrade Pillow --global-option="build_ext" --global-option="--enable-[feature]"
# Python venv
python3 -m venv venv
source venv/bin/activate
pip3 install wheel cython
pip3 install python-mpv luma.oled pi-rc522 adafruit-circuitpython-bme680 adafruit-circuitpython-bme280 pygobject requests xmltodict pi-ina219 evdev dbus-python
sudo mv /etc/lirc/lircd.conf.dist /etc/lirc/lircd.conf
git clone https://github.com/tompreston/python-lirc.git
find python-lirc -name '*.pyx' -exec cython {} \;
pip3 install python-lirc/
rm -rf python-lirc
## Bluetooth
# git clone https://github.com/bluez/bluez.git
# pactl load-module module-bluetooth-discover
### Patches
# In venv/lib/python3.7/site-packages/adafruit_bme680.py replace "address=0x77" with "address=0x76". The address is hardcoded for some reason...
# In venv/lib/python3.7/site-packages/pirc522/rfid.py
# def wait_for_tag(self, timeout = 1):
# # enable IRQ on detect
# self.init()
# self.irq.clear()
# self.dev_write(0x04, 0x00)
# self.dev_write(0x02, 0xA0)
# # wait for it
# waiting = True
# waited = 0
# while waiting:
# self.dev_write(0x09, 0x26)
# self.dev_write(0x01, 0x0C)
# self.dev_write(0x0D, 0x87)
# waiting = not self.irq.wait(0.1)
#
# waited += 0.1
#
# if timeout <= waited:
# print("waited enough")
# break
#
# self.irq.clear()
# self.init()
# Add timeout
# In venv/lib/python3.7/site-packages/pirc522/rfid.py
# set pinmode to BCM and change the PINs to BCM not Board Pins
# set RST, IRQ an CE Pins to match documentation (16, 26, 1)
# at line 40 and 41, all settings depend on wiering wiring
#def __init__(self, bus=0, device=1, speed=1000000, pin_rst=16,
# pin_ce=1, pin_irq=26, pin_mode=GPIO.BCM):
# IN mpv.py change line ~50 `backend = CDLL(sofile)` to `backend = CDLL('/usr/local/lib/libmpv.so')`
# setup to autologin user in console mode
# Systemd service
# $ systemctl --user daemon-reload
# $ systemctl --user enable [email protected]
# # reboot or $ systemctl --user start [email protected]
# $ cat ~/.config/systemd/user/[email protected]
# [Unit]
# Description=wladio
# After=time-sync.target
# RestartSec=2
# StartLimitIntervalSec=10
# StartLimitBurst=100
# [Service]
# Type=simple
# TimeoutStartSec=5
# Restart=always
# RestartSec=10
# ExecStart=/home/pi/wladio/venv/bin/python3 main.py
# WorkingDirectory=/home/pi/wladio/radio
# [Install]
# WantedBy=default.target
# pi update
## ic2
check i2c devices with i2cdetect -l / i2cdetect -y busnum eg
i2cdetect -l
i2cdetect -y 1