Compare commits

..

171 commits

Author SHA1 Message Date
Limor "Ladyada" Fried
48a6ea9f86
Merge pull request #355 from makermelissa/main
Fix the con2fbmap helper in adafruit-pitft to work with all displays
2025-08-27 09:27:49 -04:00
Melissa LeBlanc-Williams
c87a354258 Fix the con2fbmap helper to work with all displays 2025-08-26 15:44:18 -07:00
Melissa LeBlanc-Williams
aa955c4376
Merge pull request #353 from makermelissa/main
Update i2samp.py to provide i2s volume control
2025-08-20 12:44:32 -07:00
Melissa LeBlanc-Williams
b4ce00a899 Uncomment /dev/zero stuff 2025-08-16 14:06:10 -07:00
Melissa LeBlanc-Williams
88467546ee Update i2samp.py to provide i2s volume control 2025-08-16 14:00:18 -07:00
Limor "Ladyada" Fried
5547ffd352
Merge pull request #352 from makermelissa/main
Host the lgpio package
2025-08-15 21:56:14 -04:00
Melissa LeBlanc-Williams
57cca7fd7d Host the lgpio package 2025-08-15 14:59:49 -07:00
Melissa LeBlanc-Williams
adcb740a19
Merge pull request #348 from makermelissa/pitft-updates
Added PiTFT V2 and stripping out old stuff
2025-08-11 11:49:04 -07:00
Melissa LeBlanc-Williams
2bbb0844ea Remove unused import 2025-08-06 15:04:46 -07:00
Melissa LeBlanc-Williams
e2af79a70b Remove old file 2025-08-06 15:02:40 -07:00
Melissa LeBlanc-Williams
7ba3f50d36 Add labwc support 2025-08-06 14:59:03 -07:00
Melissa LeBlanc-Williams
d14339d748 Fixed console mode, touch now working 2025-07-26 12:18:38 -07:00
Melissa LeBlanc-Williams
292185d7b9 Removed old stuff and updated so it's now in a working state 2025-07-18 15:22:46 -07:00
foamyguy
ae88fed18c
Merge pull request #349 from FoamyGuy/quality_notes
update quality info about triple matrix
2025-07-15 08:12:30 -05:00
foamyguy
10dd2cd969 update quality info about triple matrix 2025-07-14 10:51:13 -05:00
Melissa LeBlanc-Williams
160bf98cff Added PiTFT V2 and stripping out old stuff 2025-07-09 14:52:51 -07:00
Melissa LeBlanc-Williams
923d409ffd
Merge pull request #347 from makermelissa/main
Apply Pi 5 requirement changes to Blinka Installer
2025-06-24 08:08:47 -07:00
Melissa LeBlanc-Williams
fccc7ebe48 Use the recommended lgpio setup procedure 2025-06-23 10:18:25 -07:00
Melissa LeBlanc-Williams
e55fd74098 Apply Pi 5 requirement changes 2025-06-23 09:37:22 -07:00
Carter Nelson
cc13749b5e
Merge pull request #346 from caternuson/rgb_matrix_update
Update rgb-matrix.sh
2025-06-17 07:33:51 -07:00
caternuson
a29743d6af update rgb-matrix.sh 2025-06-17 06:57:46 -07:00
Melissa LeBlanc-Williams
47308a7f1a
Merge pull request #345 from makermelissa/main
Add user to hardware groups in Blinka installer
2025-05-26 11:45:19 -07:00
Melissa LeBlanc-Williams
14c7b7d931 Add user to hardware groups in Blinka installer 2025-05-26 11:22:08 -07:00
Limor "Ladyada" Fried
a29da80873
Merge pull request #344 from makermelissa/main
Add some checks to remove displaying errors
2025-05-21 13:57:38 -04:00
Melissa LeBlanc-Williams
908629430e Add some checks to remove displaying errors 2025-05-20 15:34:36 -07:00
Melissa LeBlanc-Williams
3448db64f0
Merge pull request #342 from makermelissa/main
Fix expected get_boot_config to return folder
2025-04-09 12:52:17 -07:00
Melissa LeBlanc-Williams
242d1275ac Fix expected get_boot_config to return folder 2025-04-07 11:15:29 -07:00
Melissa LeBlanc-Williams
5bb26d8d98
Merge pull request #339 from makermelissa/main
Add working voice bonnet installer and service
2025-03-19 12:28:19 -07:00
Melissa LeBlanc-Williams
7a508dce22 Add working voice bonnet installer and service 2025-03-18 15:28:30 -07:00
Limor "Ladyada" Fried
d7109fa827
Merge pull request #338 from mikeysklar/bootdir-configtxt
adafruit-pitft.py boot_dir
2025-03-10 10:35:21 -04:00
Mikey Sklar
94b83cbef9 adafruit-pitft.py boot_dir
fix for  /boot/firmware vs /boot logic for the config.txt location
2025-03-08 17:28:45 -08:00
Melissa LeBlanc-Williams
d18a31bfec
Merge pull request #337 from makermelissa/main
Update python scripts with new shell features
2025-03-05 14:46:13 -08:00
Melissa LeBlanc-Williams
3cc46f8bdb Update python scripts with new shell features 2025-03-05 13:17:12 -08:00
Melissa LeBlanc-Williams
7fa847b6b8
Merge pull request #332 from mikeysklar/pitft-raspi-config-args
bookworm update effects adafruit-pitft.py
2025-01-30 11:32:57 -08:00
Mikey Sklar
ff822bf77c bookworm update effects adafruit-pitft.py
Minor argument change to rapsi-config do_wayland setting.
2025-01-29 10:46:40 -08:00
Limor "Ladyada" Fried
a68ef4b415
Merge pull request #330 from makermelissa/main
Update blinka installer to handle unsupported Pis
2025-01-15 15:58:20 -05:00
Melissa LeBlanc-Williams
1c3435509f Merge branch 'main' of https://github.com/adafruit/Raspberry-Pi-Installer-Scripts 2025-01-15 12:40:15 -08:00
Melissa LeBlanc-Williams
faac4e8be3
Merge pull request #327 from riktam/adafruit#326
Fix enable and disable of Wayland.
2025-01-15 12:40:09 -08:00
Melissa LeBlanc-Williams
3dc39067e8 Update blinka installer to handle unsupported Pis 2025-01-15 12:38:32 -08:00
Limor "Ladyada" Fried
bbeb37b210
Merge pull request #329 from makermelissa/main
Updated Blinka installer to at least install the correct packages
2024-11-20 13:27:12 -05:00
Melissa LeBlanc-Williams
b997ee5a0d Updated Blinka installer to at least install the correct packages 2024-11-18 12:49:40 -08:00
Riktam
e240b61dd0 Fix enable and disable of Wayland. 2024-09-24 00:04:14 +02:00
Limor "Ladyada" Fried
ad19b39863
Merge pull request #324 from mikeysklar/pi5-blinkatest-fix
pi5 GPIO packages fix
2024-09-22 16:46:42 -04:00
Mikey Sklar
3a16bf08c0 pi5 GPIO packages fix
Necessary for blinkatest.py to run without errors on a Pi 5.
2024-09-20 13:01:54 -07:00
Melissa LeBlanc-Williams
9e85cf0c8e
Merge pull request #317 from arrio464/patch-1
upstream: no longer use asoc_xxx() compatible macro
2024-06-07 10:23:36 -07:00
arrio464
a51231a067
upstream: no longer use asoc_xxx() compatible macro
After linux 6.10-rc2, kernel remove asoc_xxx() compatible macro.
So use original prototypes instead.
2024-06-07 15:39:07 +08:00
Melissa LeBlanc-Williams
7b6fced70c
Merge pull request #311 from mikeysklar/pitft35r-drm
drm added for PiTFT 3.5" resistive
2024-05-22 09:08:41 -07:00
Mikey Sklar
2309e7b8ea remove drm hardcode
switch to tinydrm_install logic
2024-05-03 12:11:25 -07:00
Mikey Sklar
fb589e49b7 drm added for PiTFT 3.5" resistive
The PiTFT 3.5" resistive display requires a drm flag to work with Pi Zero and 3B versions of Bookworm. Tested on Pi4 and Pi5 as well.
2024-05-03 09:28:12 -07:00
Melissa LeBlanc-Williams
bf97fa1b88
Merge pull request #309 from makermelissa/main
Update script to use X11 for PiTFT Touch displays
2024-04-30 10:26:02 -07:00
Melissa LeBlanc-Williams
8c9862e1c5 Update script to use X11 for PiTFT Touch displays 2024-04-30 09:47:28 -07:00
Melissa LeBlanc-Williams
1417285467
Merge pull request #305 from makermelissa/main
Updated and converted i2samp script
2024-04-26 19:56:26 -07:00
Melissa LeBlanc-Williams
06deceb470 Updated and converted i2samp script 2024-04-17 13:58:27 -07:00
Melissa LeBlanc-Williams
db8e46f7c5
Merge pull request #304 from makermelissa/main
Don't comment out kms driver for mipi display
2024-04-16 11:18:04 -07:00
Melissa LeBlanc-Williams
163fc2ff2f Don't comment out kms driver for mipi display 2024-04-15 16:14:45 -07:00
Melissa LeBlanc-Williams
3942f2cbd7
Merge pull request #303 from LostNulide/patch-1
Fix #274
2024-04-15 15:11:55 -07:00
LostNulide
d7d1417be5
Update i2smic.py to a more futureproof design 2024-04-15 23:19:02 +02:00
LostNulide
b5c25be3bf
Fix #274
This Commit depends on the Merge-Request #23 for the Adafruit_Python_Shell https://github.com/adafruit/Adafruit_Python_Shell/pull/23
2024-04-15 19:24:02 +02:00
Melissa LeBlanc-Williams
02c6b18f1c
Merge pull request #300 from makermelissa/main
Add Kippah ar1100.py script updated for latest pi
2024-04-03 08:44:13 -07:00
Melissa LeBlanc-Williams
6ecf6252b5 Add Kippah ar1100.py script updated for latest pi 2024-04-02 15:34:39 -07:00
Melissa LeBlanc-Williams
b204f2b4b5
Merge pull request #298 from makermelissa/main
Fix bullseye compatibility with pitft script
2024-02-28 08:24:24 -08:00
Melissa LeBlanc-Williams
bfafc77e36 Fix bullseye compatibility with pitft script 2024-02-27 16:13:40 -08:00
Melissa LeBlanc-Williams
ff79220c58
Merge pull request #297 from makermelissa/main
Add blinka installer backwards compatibility with bullseye
2024-02-27 10:37:05 -08:00
Melissa LeBlanc-Williams
103b133885 Add blinka installer backwards compatibility with bullseye 2024-02-27 08:47:56 -08:00
Melissa LeBlanc-Williams
0173a1f2cd
Merge pull request #294 from makermelissa/st7789
Integrate ST7789 MIPI Script into main PiTFT Script
2024-01-31 09:57:13 -08:00
Melissa LeBlanc-Williams
219781e115 Integrate ST7789 MIPI Script into main PiTFT Script 2024-01-30 16:53:18 -08:00
Melissa LeBlanc-Williams
c8b097bdb4
Merge pull request #293 from makermelissa/PiTFTs
Update PiTFT overlays and add resistive PiTFTs
2024-01-30 12:27:21 -08:00
Melissa LeBlanc-Williams
e406acfa31 Update PiTFT overlays and add resistive PiTFTs 2024-01-30 10:13:48 -08:00
Melissa LeBlanc-Williams
a6c6d5dc16
Merge pull request #291 from makermelissa/main
Update 2.8-inch Capacitive PiTFT
2024-01-26 11:39:14 -08:00
Melissa LeBlanc-Williams
34817dcd3a Fix capacitive touch rotations 2024-01-26 11:38:50 -08:00
Melissa LeBlanc-Williams
5eb36455d7 Add script updates too 2024-01-22 17:34:05 -08:00
Melissa LeBlanc-Williams
5532bfc5fb Update 2.8-inch Capacitive PiTFT 2024-01-22 17:33:36 -08:00
Melissa LeBlanc-Williams
da7d04a3a7
Merge pull request #290 from makermelissa/main
Update PiTFT Script and 2.2 inch overlay for Bookworm/Pi 5
2024-01-22 17:32:15 -08:00
Melissa LeBlanc-Williams
001096d826 Merge branch 'main' of https://github.com/adafruit/Raspberry-Pi-Installer-Scripts 2024-01-22 15:11:13 -08:00
Melissa LeBlanc-Williams
4ba53896e2 Update PiTFT Script and 2.2 inch overlay for Bookworm/Pi 5 2024-01-22 15:11:03 -08:00
Melissa LeBlanc-Williams
243a52d4b6
Merge pull request #288 from makermelissa/main
Fix mipi script from messing with kms and fkms drivers
2024-01-17 12:22:43 -08:00
Melissa LeBlanc-Williams
ed6e75053e Merge branch 'main' of https://github.com/adafruit/Raspberry-Pi-Installer-Scripts 2024-01-17 11:11:38 -08:00
Melissa LeBlanc-Williams
f728f7638b Fix mipi script from messing with kms and fkms drivers 2024-01-17 11:11:28 -08:00
Limor "Ladyada" Fried
b8d16b01e0
Merge pull request #285 from makermelissa/main
Add voice bonnet/braincraft hat script to ensure DTOs are enabled
2024-01-05 17:39:52 -05:00
Melissa LeBlanc-Williams
0706b27819 Add /boot/config.txt symlink fix 2024-01-05 10:29:02 -08:00
Melissa LeBlanc-Williams
27ac7a9614 Add voice bonnet/braincraft hat script to ensure DTOs are enabled 2024-01-05 10:08:38 -08:00
Melissa LeBlanc-Williams
8f6c615f1c
Merge pull request #283 from makermelissa/main
Update i2samp to work on bookworm
2023-12-27 10:15:42 -08:00
Melissa LeBlanc-Williams
e6fec6078a Add fallback location to i2samp 2023-12-27 09:59:14 -08:00
Melissa LeBlanc-Williams
a59177c897 Update i2samp to work on bookworm 2023-12-27 09:53:34 -08:00
Melissa LeBlanc-Williams
caba9aa589
Merge pull request #282 from makermelissa/i2smic
Add Pi B Rev 2 to i2smic board list
2023-12-26 14:26:39 -08:00
Melissa LeBlanc-Williams
fc6ff17730 Add Pi B Rev 2 2023-12-26 13:55:12 -08:00
Melissa LeBlanc-Williams
30b4c740b9
Merge pull request #281 from makermelissa/main
Allow 'disabled' to be passed in via command line in spi-reassign script
2023-12-22 11:20:53 -08:00
Melissa LeBlanc-Williams
f5cfbca4c6 Bug fix for when both are disabled 2023-12-22 10:15:01 -08:00
Melissa LeBlanc-Williams
011ede8124 Allow 'disabled' to be passed in via command line in reassign script 2023-12-22 10:09:30 -08:00
Melissa LeBlanc-Williams
46632797b5
Merge pull request #279 from makermelissa/main
Update SPI reassignment script for Bookworm
2023-12-20 10:27:00 -08:00
Melissa LeBlanc-Williams
2bb0a8c447 Update SPI reassignment script for Bookworm 2023-12-20 10:14:09 -08:00
Melissa LeBlanc-Williams
4e477c8ba6
Merge pull request #278 from makermelissa/main
Fix mipi script bug
2023-12-19 15:31:56 -08:00
Melissa LeBlanc-Williams
a122af2e43 Fix mipi script bug 2023-12-19 15:30:36 -08:00
Melissa LeBlanc-Williams
9391a10c30
Merge pull request #272 from makermelissa/main
New /boot/config.txt fix
2023-11-06 16:22:24 -08:00
Melissa LeBlanc-Williams
64b9fd8bf4 New /boot/config.txt fix 2023-11-06 15:00:36 -08:00
Melissa LeBlanc-Williams
9710557648
Merge pull request #269 from ziyadedher/patch-1
Bump `rpi-rgb-led-matrix` commit to `a3eea9`
2023-11-02 08:22:09 -07:00
Ziyad Edher
1370f9e5c3
Bump rpi-rgb-led-matrix commit to a3eea9 2023-10-31 17:23:18 -07:00
Melissa LeBlanc-Williams
a282edbda5
Merge pull request #267 from makermelissa/main
Add libgpiod to Blinak installer for Pi 5
2023-10-23 10:11:31 -07:00
Melissa LeBlanc-Williams
117ca53fce Add libgpiod to Blinak installer for Pi 5 2023-10-23 10:10:39 -07:00
Melissa LeBlanc-Williams
b0028ac12c
Merge pull request #265 from makermelissa/main 2023-10-20 18:21:34 -07:00
Melissa LeBlanc-Williams
8ab58b59ed Change some py packages to be installed via apt-get 2023-10-20 14:21:48 -07:00
Melissa LeBlanc-Williams
4c4f24a076 Merge branch 'main' of https://github.com/adafruit/Raspberry-Pi-Installer-Scripts 2023-10-20 14:17:10 -07:00
Melissa LeBlanc-Williams
2c73c400fa
Merge pull request #266 from caternuson/rpiconfig_update
Update raspi-config serial enable
2023-10-20 13:38:28 -07:00
caternuson
bde69a70be update serial enable 2023-10-20 13:34:13 -07:00
Melissa LeBlanc-Williams
def7058ee9 Update script version number 2023-10-20 13:13:25 -07:00
Melissa LeBlanc-Williams
ebcc4936f7 Update pitft to run in venv 2023-10-20 11:06:44 -07:00
Melissa LeBlanc-Williams
a113de6afb
Merge pull request #262 from Paulpanther/main
Fix bug in python version check in raspi-blinka.py
2023-10-13 13:16:47 -07:00
Paul Methfessel
26404d7674
Fix bug in python version check in raspi-blinka.py
The file checked the python version by comparing the major and minor versions. However, the variables compared were strings, making '11' > '8' -> False, when in fact it should have been true.
I converted the versions to integers before comparing, so that versions 10 and above are accepted
2023-10-13 21:51:29 +02:00
Melissa LeBlanc-Williams
4d091776d4
Merge pull request #260 from makermelissa/blinka-install-fix
Fix issue where blinka installs as root
2023-09-14 12:39:08 -07:00
Melissa LeBlanc-Williams
0b17bc3964
Merge pull request #258 from makermelissa/main
Update python version checking for versions > 3.9
2023-09-13 12:43:40 -07:00
Melissa LeBlanc-Williams
9a97fa0b40 Merge branch 'main' of https://github.com/adafruit/Raspberry-Pi-Installer-Scripts 2023-09-13 08:54:23 -07:00
Melissa LeBlanc-Williams
92766ff60f
Merge pull request #261 from makermelissa/libgpiod-fix 2023-09-12 18:07:28 -07:00
Melissa LeBlanc-Williams
4996d5b48d make more readable 2023-09-12 15:00:25 -07:00
Melissa LeBlanc-Williams
2772ebb1f3 Fix outdated libgpiod script 2023-09-12 14:56:54 -07:00
Melissa LeBlanc-Williams
0aba7ce7fd Remove extra code 2023-09-12 12:55:55 -07:00
Melissa LeBlanc-Williams
189997aae8 Fix issue where blinka installs as root 2023-09-12 12:53:17 -07:00
Melissa LeBlanc-Williams
f9a67937b5 Merge branch 'main' of https://github.com/adafruit/Raspberry-Pi-Installer-Scripts 2023-09-11 08:27:53 -07:00
Melissa LeBlanc-Williams
472040cf8f Update python version checking for versions > 3.9 2023-09-11 08:27:43 -07:00
Limor "Ladyada" Fried
43914b6163
Merge pull request #257 from mifi/main-1
fix `click` install
2023-08-20 18:08:49 -04:00
Mikael Finstad
63377adde5
fix click install
currently:

```
sudo apt-get install python3-pip click
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package click
```
2023-08-16 13:54:58 +02:00
Melissa LeBlanc-Williams
2e3f8e6dc3
Merge pull request #255 from Lovmong/main
Please restore i2samp.h support for Raspbian buster system.
2023-08-11 08:15:05 -07:00
Lovmong
04509fac88
restore support for Raspbian buster 2023-08-11 15:59:24 +08:00
Melissa LeBlanc-Williams
339cccfbdd
Merge pull request #252 from makermelissa/main
Fix Capacitive 2.8-inch PiTFT touch
2023-05-31 13:13:12 -07:00
Melissa LeBlanc-Williams
b73b9d51a2 Fix Capacitive 2.8-inch PiTFT touch 2023-05-31 09:16:14 -07:00
Melissa LeBlanc-Williams
866f780c55
Merge pull request #251 from makermelissa/pitft114_offset
Updated and fixed ST7789v driver
2023-05-30 08:16:55 -07:00
Melissa LeBlanc-Williams
97a7d43e85 Updated and fixed ST7789v driver 2023-05-26 17:06:41 -07:00
Melissa LeBlanc-Williams
d49b6e9d95
Merge pull request #250 from makermelissa/fix_i2smic
Fix i2smic
2023-05-19 16:23:43 -07:00
Melissa LeBlanc-Williams
e078e2723f
Merge pull request #249 from makermelissa/fix_rotation
Change rotation to rotate for ST7789 displays
2023-05-19 16:23:28 -07:00
Melissa LeBlanc-Williams
169377cc43 Fix i2smic by checking if userspace and kernel space are the same 2023-05-12 11:25:59 -07:00
Melissa LeBlanc-Williams
4c85441000 Change rotation to rotate for ST7789 displays 2023-05-12 09:12:05 -07:00
Melissa LeBlanc-Williams
b3e3a1ad66
Merge pull request #246 from makermelissa/main
Only compile st7789 driver if necessary
2023-04-05 08:15:34 -07:00
Melissa LeBlanc-Williams
5c5fb7995a Only compile st7789 driver if necessary 2023-04-04 16:03:12 -07:00
Melissa LeBlanc-Williams
59958b8774
Merge pull request #245 from wise-introvert/patch-1
docs: add an alternative package if original fails
2023-03-23 15:59:19 -07:00
Fardeen Panjwani
108f4e381b
docs(libgpiod): fix typo 2023-03-23 18:24:12 -04:00
Fardeen Panjwani
16054b3687
docs: add an alternative package if original fails
The old instructions mentioned adafruit-python**3**-shell as a dependency but when I tried to install the package I found out that the package didn't exist ( or deprecated I think ) and I was able to use adafruit-python-shell instead. So, I thought I might add the package to the instructions in case anyone else runs into the same issue as me.
2023-03-23 18:10:54 -04:00
Melissa LeBlanc-Williams
f9928f941f
Merge pull request #240 from BasdeWinter/BasdeWinter-patch-1
Update raspi-blinka.py
2023-02-13 08:25:44 -08:00
BasdeWinter
d262dedd1f
Update raspi-blinka.py
fixes a "< operator cannot be used to compare NonType with int" error on a RPI-Zero-W
2023-02-07 18:52:45 +01:00
Phillip Burgess
0445056459 Remove Arcade Bonnet test (moved to Retrogame repo instead) 2023-01-03 14:59:31 -08:00
Phillip Burgess
3355934bb1 Add Arcade Bonnet tester 2023-01-03 13:30:51 -08:00
Melissa LeBlanc-Williams
3a6a8f7b5c
Merge pull request #237 from adafruit/pb-arcade-bonnet-python3
Arcade Bonnet: update to use python3
2022-12-28 09:50:13 -08:00
Phillip Burgess
46ef973fbb Arcade Bonnet: python3-dev not needed in apt-get line 2022-12-28 09:05:48 -08:00
Phillip Burgess
9e48166f87 Arcade Bonnet: python3-ify 2022-12-27 18:40:14 -08:00
Melissa LeBlanc-Williams
60950ddddd Fix bug report YAML 2022-11-30 11:50:27 -08:00
Melissa LeBlanc-Williams
a3532a8961
Merge pull request #236 from makermelissa/main
Add Bug report template and additional conversions
2022-11-30 11:45:03 -08:00
Melissa LeBlanc-Williams
de02991724 Add Bug report template to reduce asking for additional details 2022-11-30 09:25:30 -08:00
Melissa LeBlanc-Williams
2ebeece160
Merge pull request #234 from makermelissa/main
Update readme, move scripts, bug fixes
2022-11-11 17:11:36 -08:00
Melissa LeBlanc-Williams
bc4b07e658 Update readme, move scripts, bug fixes 2022-11-11 17:04:12 -08:00
Melissa LeBlanc-Williams
501435743e
Merge pull request #180 from beasteers/i2smic-nonint-patch-2
Make i2smic.py noninteractive
2022-11-09 10:36:38 -08:00
Melissa LeBlanc-Williams
08283cf58a Remove unused import os 2022-11-09 10:32:56 -08:00
Melissa LeBlanc-Williams
bc463b1099 Simplified code 2022-11-09 10:31:57 -08:00
Melissa LeBlanc-Williams
45dc7155b2 Merge branch 'main' of https://github.com/adafruit/Raspberry-Pi-Installer-Scripts into i2smic-nonint-patch-2 2022-11-09 09:54:37 -08:00
Melissa LeBlanc-Williams
18ab65af41
Merge pull request #233 from makermelissa/main
Fix rotation parameter for ST7789 displays
2022-11-04 08:04:28 -07:00
Melissa LeBlanc-Williams
2f8e05b9fc Fix rotation parameter for ST7789 displays 2022-11-03 17:25:46 -07:00
Melissa LeBlanc-Williams
2971dd189d
Merge pull request #231 from makermelissa/i2samp-update
Updated i2samp to run on 64-bit Raspberry Pi OS
2022-10-31 10:00:21 -07:00
Melissa LeBlanc-Williams
62a7515f84 Updated i2samp to run on 64-bit Raspberry Pi OS 2022-10-06 14:20:44 -07:00
Melissa LeBlanc-Williams
a779800e50
Merge pull request #229 from Kingfrankbob/main
Update rgb-matrix.sh With Spelling and some other useful things
2022-08-22 08:03:54 -07:00
Kingfrankbob
f5f8189b9b
Update rgb-matrix.sh 2022-08-19 17:59:52 -05:00
Melissa LeBlanc-Williams
5c21b388c5
Merge pull request #223 from makermelissa/main
Use user's home directory by default
2022-06-06 09:20:49 -06:00
Melissa LeBlanc-Williams
4188dec3f9 Use user's home directory by default 2022-06-03 09:05:03 -07:00
Melissa LeBlanc-Williams
8cfa5451a4
Merge pull request #222 from makermelissa/main
Added ability to specify boot directory as parameter
2022-06-03 09:06:16 -06:00
Melissa LeBlanc-Williams
6b60331f91 Added ability to specify boot directory as parameter 2022-06-01 13:45:14 -07:00
Melissa LeBlanc-Williams
95b2af2be8
Merge pull request #221 from makermelissa/main
Add initial working MIPI installer script and touch drivers
2022-04-26 14:51:46 -07:00
Melissa LeBlanc-Williams
4848a15557 Add initial working MIPI installer script and touch drivers 2022-04-26 14:14:45 -07:00
Melissa LeBlanc-Williams
b9438288ed
Merge pull request #220 from NickEngmann/main
fix(adafruit-pitft.py): libts dependency
2022-04-14 12:25:28 -07:00
Cyril "Nick" Engmann
9a03fea228
fix(adafruit-pitft.py): libts dependency 2022-04-14 15:18:25 -04:00
Melissa LeBlanc-Williams
ee839aa276
Merge pull request #218 from makermelissa/main
Added Raspberry Pi 400 support to i2smic
2022-03-21 13:46:28 -07:00
Melissa LeBlanc-Williams
23179eafe9 Added Raspberry Pi 400 support to i2smic 2022-03-21 10:16:57 -07:00
Melissa LeBlanc-Williams
5ed76a329e
Merge pull request #216 from makermelissa/main
Updated backlight to be on for latest kernel
2022-03-10 13:44:38 -08:00
Melissa LeBlanc-Williams
95b56a005c Updated backlight to be on for latest kernel 2022-03-10 09:40:03 -08:00
Paint Your Dragon
d25d137daf
Merge pull request #214 from adafruit/pb-matrix-python2or3
rgb-matrix.sh: add checks for Python 2 & 3, only install what’s right
2022-03-04 18:10:44 -08:00
Bea Steers
16de141786
make i2smic noninteractive 2021-05-27 14:10:11 -04:00
57 changed files with 3865 additions and 385 deletions

68
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View file

@ -0,0 +1,68 @@
name: 🐞 Bug Report
description: Create a bug report to help us improve
labels:
- bug
body:
- type: markdown
attributes:
value: >-
Thanks! for using the installer scripts. Now that you have encountered a
bug... you can file a report for it.
- type: textarea
id: script
attributes:
label: Script Command
description: >-
Include the exact command you're running with any parameters. There are quite
a handful of scripts and knowing which one is helpful. :)
placeholder: sudo python3 adafruit-pitft.py --display=28r --rotation=90 --install-type=console
render: shell
validations:
required: true
- type: textarea
id: os
attributes:
label: Operating System
description: >-
Which OS was the script running under? Include details such as if it
was 32 or 64-bit, Whether it was the Lite of Full Desktop version. If it's on an older or newer
kernel, include that as well.
placeholder: |
64-bit Raspberry Pi OS Lite with Bullseye
validations:
required: true
- type: textarea
id: hardware
attributes:
label: Hardware
description: This is the board or computer you are running the script on.
placeholder: |
Raspberry Pi 4B
validations:
required: true
- type: textarea
id: behavior
attributes:
label: Behavior
description: What happens when you run the script above? Include error messages (if any).
placeholder: |
An error occurs at line 459 with this message...
validations:
required: true
- type: textarea
id: description
attributes:
label: Description
description: Optionally, describe the bug in more detail.
placeholder: |
- I selected options 1, then 3, then 4...
- Only happens when...
- might be related to #123...
- type: textarea
id: more-info
attributes:
label: Additional information
description: >-
Optionally, add any other information like hardware connection, scope
output etc. If you have already done some debugging, mention it here.
placeholder: Removing [this](url) line resolves the issue.

7
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View file

@ -0,0 +1,7 @@
contact_links:
- name: 🔗 Adafruit Forum
url: https://forums.adafruit.com/
about: Official Adafruit technical support forum. Good for getting help on getting a project working.
- name: 🔗 Adafruit Discord
url: https://adafru.it/discord
about: Unofficial chat with many helpful folks and normally prompt replies.

View file

@ -0,0 +1,11 @@
---
name: 🚀 Feature Request
about: Suggest an idea for this project
title: ''
labels: 'enhancement'
assignees: ''
---
<!-- If you have an idea for any new features and enhancements to any of our scripts 🚀
and would love ❤ to see what ideas you have for us... 🙂 -->

View file

@ -2,6 +2,36 @@
Some scripts for helping install Adafruit HATs, bonnets, add-on's, & friends! Some scripts for helping install Adafruit HATs, bonnets, add-on's, & friends!
Based heavily on get.pimoroni.com scripts! Many scripts are based heavily on get.pimoroni.com scripts!
* Install i2s amplifier with: curl -sS https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/i2samp.sh | bash * Install i2s amplifier with: curl -sS https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/i2samp.sh | bash
## Python Scripts
We are in the process of converting our Shell Scripts to Python. Instructions for running specific scripts are available in the [Adafruit Learning System](https://learn.adafruit.com/). Here are the general setup instructions.
### Dependencies
- Python 3
- [Adafruit_Python_Shell](https://github.com/adafruit/Adafruit_Python_Shell)
- [Click](https://pypi.org/project/click/)
### Prepare your system
To install the dependencies for the python scripts, run the following commands:
```bash
sudo apt-get install python3-pip
sudo pip3 install --upgrade click
sudo pip3 install --upgrade setuptools
sudo pip3 install --upgrade adafruit-python-shell
```
Then to run the python script, type the following replacing "scriptname.py" with the actual script name:
```bash
sudo python3 scriptname.py
```
## Old Shell Scripts
If you were directed here from an external site and the script you were looking for appears to be missing, you can either use the newer python script or check the [converted_shell_scripts](https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/tree/main/converted_shell_scripts) folder to use the old shell scripts.

723
adafruit-pitft.py Executable file → Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,10 @@
"""
Adafruit Raspberry Pi Fan Service Setup Script
(C) Adafruit Industries, Creative Commons 3.0 - Attribution Share Alike
Converted to Python by Melissa LeBlanc-Williams for Adafruit Industries
"""
import os import os
try: try:
@ -40,7 +47,7 @@ Run time < 1 minute. Reboot not required.""")
# check init system (technique borrowed from raspi-config): # check init system (technique borrowed from raspi-config):
shell.group = 'FAN' shell.group = 'FAN'
shell.info('Checking init system...') shell.info('Checking init system...')
if shell.run_command("which systemctl", True) and shell.run_command("systemctl | grep '\-\.mount'", True): if shell.run_command("which systemctl", suppress_message=True) and shell.run_command("systemctl | grep '\-\.mount'", suppress_message=True):
print("Found systemd, OK!") print("Found systemd, OK!")
elif os.path.isfile("/etc/init.d/cron") and not os.path.islink("/etc/init.d/cron"): elif os.path.isfile("/etc/init.d/cron") and not os.path.islink("/etc/init.d/cron"):
shell.bail("Found sysvinit, but we require systemd") shell.bail("Found sysvinit, but we require systemd")

237
ar1100.py Normal file
View file

@ -0,0 +1,237 @@
#!/usr/bin/python
import usb.core
import usb.util
import time
import os
import pygame
from pygame.locals import *
def mapnum(x, in_min, in_max, out_min, out_max):
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
CALIBRATED_5IN_800x480 = [
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x55, 0x80, 0x05, 0x05, 0x40, 0x03, 0x00, 0x20, 0x00, 0x50, 0x00, 0x80, 0x00, 0xb0, 0x00, 0xe0,
0x00, 0x20, 0x00, 0x50, 0x00, 0x80, 0x00, 0xb0, 0x00, 0xe0, 0x4d, 0x2a, 0x3a, 0x2b, 0xcb, 0x56,
0xb5, 0x29, 0x18, 0x82, 0xe9, 0x29, 0x41, 0xad, 0x06, 0x2b, 0x16, 0xd9, 0x42, 0x2a, 0x45, 0x29,
0x82, 0x53, 0x10, 0x56, 0xda, 0x54, 0x99, 0x81, 0xcf, 0x55, 0x5e, 0xac, 0xec, 0x55, 0x83, 0xd8,
0xcf, 0x55, 0xf1, 0x29, 0x3d, 0x82, 0xa0, 0x55, 0x11, 0x82, 0x22, 0x81, 0x4b, 0x81, 0x47, 0xad,
0xc2, 0x82, 0x06, 0xd9, 0xc8, 0x82, 0x65, 0x2a, 0xda, 0xac, 0xc1, 0x55, 0xa3, 0xac, 0xeb, 0x80,
0x26, 0xae, 0x27, 0xac, 0xd9, 0xad, 0x8e, 0xd8, 0xd9, 0xae, 0x8b, 0x28, 0xb9, 0xda, 0x9a, 0x54,
0x59, 0xdb, 0x1e, 0x7f, 0x78, 0xdc, 0x0f, 0xad, 0xdd, 0xdc, 0x88, 0xd8, 0xde, 0xdb, 0x00, 0x00,
]
CALIBRATED_7IN_800x480 = [
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x55, 0x80, 0x03, 0x03, 0x40, 0x02, 0x00, 0x20, 0x00, 0x80, 0x00, 0xe0, 0x00, 0xb0, 0x00, 0xe0,
0x00, 0x20, 0x00, 0x80, 0x00, 0xe0, 0x00, 0xb0, 0x00, 0xe0, 0x7f, 0x22, 0x5c, 0x2d, 0xbf, 0x7d,
0xdd, 0x2a, 0xaf, 0xdc, 0xf3, 0x2b, 0x21, 0x23, 0xb2, 0x82, 0xb4, 0x80, 0x4c, 0x82, 0x40, 0xde,
0xe7, 0x85, 0x42, 0x23, 0xcc, 0xd6, 0xda, 0x7e, 0x7d, 0xd7, 0xd9, 0xdc, 0x8b, 0xd8, 0x83, 0xd8,
0xcf, 0x55, 0xf1, 0x29, 0x3d, 0x82, 0xa0, 0x55, 0x11, 0x82, 0x22, 0x81, 0x4b, 0x81, 0x47, 0xad,
0xc2, 0x82, 0x06, 0xd9, 0xc8, 0x82, 0x65, 0x2a, 0xda, 0xac, 0xc1, 0x55, 0xa3, 0xac, 0xeb, 0x80,
0x26, 0xae, 0x27, 0xac, 0xd9, 0xad, 0x8e, 0xd8, 0xd9, 0xae, 0x8b, 0x28, 0xb9, 0xda, 0x9a, 0x54,
0x59, 0xdb, 0x1e, 0x7f, 0x78, 0xdc, 0x0f, 0xad, 0xdd, 0xdc, 0x88, 0xd8, 0xde, 0xdb, 0x00, 0x00,
]
writeeeprom = CALIBRATED_5IN_800x480;
USB_MODE_GENERIC = [0x55, 0x01, 0x70]
USB_MODE_MOUSE = [0x55, 0x01, 0x71]
MCP_VID = 0x04D8
MOUSE_PID = 0x0C02
GENERIC_PID = 0x0C01
# Try to locate it as a mouse:
dev = usb.core.find(idVendor=MCP_VID, idProduct=MOUSE_PID)
if dev:
# first endpoint
interface = 0
endpoint = dev[0][(0,0)][0]
# if the OS kernel already claimed the device, which is most likely true
# thanks to http://stackoverflow.com/questions/8218683/pyusb-cannot-set-configuration
if dev.is_kernel_driver_active(interface) is True:
# tell the kernel to detach
dev.detach_kernel_driver(interface)
# claim the device
usb.util.claim_interface(dev, interface)
# try to send it command to swap to generic HID
try:
# turn into HID
# bReq, wVal, wIndex, data
ret = dev.ctrl_transfer(0x21, 0x09, 0x0003, 0x0000, [0x55, 0x01, 0x70])
if (ret == 3):
print("Turned into HID!")
except:
# failed to get data for this request
print("Failed to turn into HID")
exit(-1)
# Try to locate it as a mouse:
dev = usb.core.find(idVendor=MCP_VID, idProduct=GENERIC_PID)
if (not dev):
print("Couldn't find generic either :/")
exit(-1)
print("Found Generic!")
interface = 0
endpoint = dev[0][(0,0)][1]
while True:
#try:
if dev.is_kernel_driver_active(interface) is True:
# tell the kernel to detach
dev.detach_kernel_driver(interface)
# claim the device
usb.util.claim_interface(dev, interface)
time.sleep(1)
dev.set_configuration()
break
#except:
# print("retrying set config...")
print("Writing EEPROM...")
for addr in range (0x60, 0xFF, 8):
msg = [0x55, 0x04 + 8, 0x29, 0x00, addr, 8]
msg.extend(writeeeprom[addr-0x60:addr-0x60+8])
#print(msg)
#print(', '.join([hex(i) for i in msg]))
ret = dev.write(1, msg)
#print("Wrote : ", ret)
ret = dev.read(0x81, 64)
#print("Read : ", readeeprom.extend(ret[4:20]))
#print(', '.join([hex(i) for i in ret[0:4]]))
if ret[2] != 0:
print("Failed to write")
exit(-1)
print("Reading EEPROM...")
readeeprom = []
for addr in range (0x60, 0xF8 , 16):
msg = [0x55, 0x04, 0x28, 0x00, addr, 16]
ret = dev.write(1, msg)
#print("Wrote :", ret)
ret = dev.read(0x81, 64)
#print("Read :",ret)
readeeprom.extend(ret[4:20])
#print(', '.join([hex(i) for i in ret[4:20]]))
for i in range(len(readeeprom)):
print(("0x%02x," % readeeprom[i]), end='')
if (i % 16 == 15):
print("")
#print(", 0x%2X".join([hex (i) for i in readeeprom]))
# compare eeproms
if (writeeeprom != readeeprom):
print("Failed to write eeprom correctly (verification fail)")
exit(-1)
print("EEPROM verified OK!")
# try to send it command to swap to generic HID
try:
# turn into Mouse
# bReq, wVal, wIndex, data
ret = dev.ctrl_transfer(0x21, 0x09, 0x0003, 0x0000, [0x55, 0x01, 0x71])
if (ret == 3):
print("Turned into Mouse!")
except:
# failed to get data for this request
print("Failed to turn into Mouse")
exit(-1)
try:
# release the device
usb.util.release_interface(dev, interface)
# reattach the device to the OS kernel
dev.attach_kernel_driver(interface)
except:
pass
time.sleep(3)
# Try to locate it as a mouse:
dev = usb.core.find(idVendor=MCP_VID, idProduct=MOUSE_PID)
if not dev:
print("No mouse :(")
exit(-1)
# first endpoint
interface = 0
endpoint = dev[0][(0,0)][0]
# if the OS kernel already claimed the device, which is most likely true
# thanks to http://stackoverflow.com/questions/8218683/pyusb-cannot-set-configuration
if dev.is_kernel_driver_active(interface) is True:
# tell the kernel to detach
dev.detach_kernel_driver(interface)
# claim the device
usb.util.claim_interface(dev, interface)
# set up pygame
white = (255, 255, 255)
w = 800
h = 480
# Output to the LCD instead of the console
os.putenv("DISPLAY", ":0")
pygame.init()
screen = pygame.display.set_mode((w, h))
running = 1
img = pygame.image.load('gradient800x480.jpg')
screen.fill((white))
screen.blit(img,(0,0))
pygame.display.flip()
while running:
for event in pygame.event.get():
print(event)
if event.type == QUIT:
exit(0)
elif event.type == KEYDOWN:
if event.key == K_ESCAPE:
pygame.quit()
exit(0)
try:
data = dev.read(endpoint.bEndpointAddress,endpoint.wMaxPacketSize)
#print(data)
x = data[1] + (data[2] << 8)
y = data[3] + (data[4] << 8)
#print(x, y)
x = mapnum(x, 0, 4096, 0, w)
y = mapnum(y, 0, 4096, 0, h)
print(x, y)
pygame.draw.circle(screen, white, (x,y), 10)
pygame.display.flip()
except usb.core.USBError as e:
data = None
if e.args == ('Operation timed out',):
continue
# release the device
usb.util.release_interface(dev, interface)
# reattach the device to the OS kernel
dev.attach_kernel_driver(interface)

View file

@ -110,8 +110,8 @@ echo "Updating package index files..."
apt-get update apt-get update
echo "Installing Python libraries..." echo "Installing Python libraries..."
apt-get install -y --force-yes python-pip python-dev python-smbus apt-get install -y python3-pip
pip install evdev pip3 install evdev smbus
echo "Installing Adafruit code in /boot..." echo "Installing Adafruit code in /boot..."
cd /tmp cd /tmp
@ -158,10 +158,10 @@ fi
grep arcadeBonnet.py /etc/rc.local >/dev/null grep arcadeBonnet.py /etc/rc.local >/dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
# arcadeBonnet.py already in rc.local, but make sure correct: # arcadeBonnet.py already in rc.local, but make sure correct:
sed -i "s/^.*arcadeBonnet.py.*$/cd \/boot;python arcadeBonnet.py \&/g" /etc/rc.local >/dev/null sed -i "s/^.*arcadeBonnet.py.*$/cd \/boot;python3 arcadeBonnet.py \&/g" /etc/rc.local >/dev/null
else else
# Insert arcadeBonnet.py into rc.local before final 'exit 0' # Insert arcadeBonnet.py into rc.local before final 'exit 0'
sed -i "s/^exit 0/cd \/boot;python arcadeBonnet.py \&\\nexit 0/g" /etc/rc.local >/dev/null sed -i "s/^exit 0/cd \/boot;python3 arcadeBonnet.py \&\\nexit 0/g" /etc/rc.local >/dev/null
fi fi
# Add udev rule (will overwrite if present) # Add udev rule (will overwrite if present)

View file

@ -31,10 +31,10 @@ forcesudo="no" # whether the script requires to be ran with root privileges
promptreboot="no" # whether the script should always prompt user to reboot promptreboot="no" # whether the script should always prompt user to reboot
mininstall="no" # whether the script enforces minimum install routine mininstall="no" # whether the script enforces minimum install routine
customcmd="yes" # whether to execute commands specified before exit customcmd="yes" # whether to execute commands specified before exit
armhfonly="yes" # whether the script is allowed to run on other arch
armv6="yes" # whether armv6 processors are supported armv6="yes" # whether armv6 processors are supported
armv7="yes" # whether armv7 processors are supported armv7="yes" # whether armv7 processors are supported
armv8="yes" # whether armv8 processors are supported armv8="yes" # whether armv8 processors are supported
arm64="yes" # whether arm64 processors are supported
raspbianonly="no" # whether the script is allowed to run on other OSes raspbianonly="no" # whether the script is allowed to run on other OSes
osreleases=( "Raspbian" ) # list os-releases supported osreleases=( "Raspbian" ) # list os-releases supported
oswarning=( "Debian" "Kano" "Mate" "PiTop" "Ubuntu" ) # list experimental os-releases oswarning=( "Debian" "Kano" "Mate" "PiTop" "Ubuntu" ) # list experimental os-releases
@ -46,14 +46,19 @@ ASK_TO_REBOOT=false
CURRENT_SETTING=false CURRENT_SETTING=false
UPDATE_DB=false UPDATE_DB=false
BOOTCMD=/boot/cmdline.txt BOOTCMD=/boot/firmware/cmdline.txt
CONFIG=/boot/config.txt CONFIG=/boot/firmware/config.txt
APTSRC=/etc/apt/sources.list APTSRC=/etc/apt/sources.list
INITABCONF=/etc/inittab INITABCONF=/etc/inittab
BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf
LOADMOD=/etc/modules LOADMOD=/etc/modules
DTBODIR=/boot/overlays DTBODIR=/boot/overlays
# Fall back to old location
if ! test -f $CONFIG; then
CONFIG=/boot/config.txt
fi
# function define # function define
confirm() { confirm() {
@ -139,9 +144,13 @@ sysreboot() {
} }
arch_check() { arch_check() {
IS_ARM64=false
IS_ARMHF=false IS_ARMHF=false
IS_ARMv6=false IS_ARMv6=false
if uname -m | grep "aarch64" > /dev/null; then
IS_ARM64=true
fi
if uname -m | grep "armv.l" > /dev/null; then if uname -m | grep "armv.l" > /dev/null; then
IS_ARMHF=true IS_ARMHF=true
if uname -m | grep "armv6l" > /dev/null; then if uname -m | grep "armv6l" > /dev/null; then
@ -233,7 +242,7 @@ raspbian_check() {
elif cat /etc/os-release | grep "buster" > /dev/null; then elif cat /etc/os-release | grep "buster" > /dev/null; then
IS_SUPPORTED=false && IS_EXPERIMENTAL=true IS_SUPPORTED=false && IS_EXPERIMENTAL=true
elif cat /etc/os-release | grep "stretch" > /dev/null; then elif cat /etc/os-release | grep "stretch" > /dev/null; then
IS_SUPPORTED=false && IS_EXPERIMENTAL=true IS_SUPPORTED=false && IS_EXPERIMENTAL=false
elif cat /etc/os-release | grep "jessie" > /dev/null; then elif cat /etc/os-release | grep "jessie" > /dev/null; then
IS_SUPPORTED=true && IS_EXPERIMENTAL=false IS_SUPPORTED=true && IS_EXPERIMENTAL=false
elif cat /etc/os-release | grep "wheezy" > /dev/null; then elif cat /etc/os-release | grep "wheezy" > /dev/null; then
@ -265,13 +274,16 @@ if [ $debugmode != "no" ]; then
newline newline
fi fi
if ! $IS_ARMHF; then if ! $IS_ARMHF && ! $IS_ARM64; then
warning "This hardware is not supported, sorry!" warning "This hardware is not supported, sorry!"
warning "Config files have been left untouched" warning "Config files have been left untouched"
newline && exit 1 newline && exit 1
fi fi
if $IS_ARMv8 && [ $armv8 == "no" ]; then if $IS_ARM64 && [ $arm64 == "no" ]; then
warning "Sorry, your CPU is not supported by this installer"
newline && exit 1
elif $IS_ARMv8 && [ $armv8 == "no" ]; then
warning "Sorry, your CPU is not supported by this installer" warning "Sorry, your CPU is not supported by this installer"
newline && exit 1 newline && exit 1
elif $IS_ARMv7 && [ $armv7 == "no" ]; then elif $IS_ARMv7 && [ $armv7 == "no" ]; then

View file

@ -16,7 +16,7 @@ Then do the following
# Installing raspberrypi-kernel-headers works only if you haven't messed with # Installing raspberrypi-kernel-headers works only if you haven't messed with
# the rpi-update thing. # the rpi-update thing.
# If you did, then you would have to do the rpi-source method # If you did, then you would have to do the rpi-source method
# to get the kernel headers. See: # to get the kernel headers. See:
# https://learn.adafruit.com/adafruit-i2s-mems-microphone-breakout/raspberry-pi-wiring-and-test#kernel-compiling # https://learn.adafruit.com/adafruit-i2s-mems-microphone-breakout/raspberry-pi-wiring-and-test#kernel-compiling
$ sudo apt install dkms raspberrypi-kernel-headers $ sudo apt install dkms raspberrypi-kernel-headers
@ -24,8 +24,8 @@ $ sudo apt install dkms raspberrypi-kernel-headers
$ sudo dpkg -i snd-i2s-rpi-dkms_0.0.2_all.deb $ sudo dpkg -i snd-i2s-rpi-dkms_0.0.2_all.deb
# For this to work, remember to modify these first: # For this to work, remember to modify these first:
# /boot/config.txt -> dtparam=i2s=on # /boot/firmware/config.txt -> dtparam=i2s=on
# and # and
# /etc/modules -> snd-bcm2835 # /etc/modules -> snd-bcm2835
# remember to reboot # remember to reboot

View file

@ -38,7 +38,7 @@
* N.B. playback vs capture is determined by the codec choice * N.B. playback vs capture is determined by the codec choice
* */ * */
static struct asoc_simple_card_info card_info; static struct simple_card_info card_info;
static struct platform_device card_device; static struct platform_device card_device;
/* /*
@ -56,7 +56,7 @@ void device_release_callback(struct device *dev) { /* do nothing */ };
/* /*
* Setup the card info * Setup the card info
*/ */
static struct asoc_simple_card_info default_card_info = { static struct simple_card_info default_card_info = {
.card = "snd_rpi_i2s_card", // -> snd_soc_card.name .card = "snd_rpi_i2s_card", // -> snd_soc_card.name
.name = "simple-card_codec_link", // -> snd_soc_dai_link.name .name = "simple-card_codec_link", // -> snd_soc_dai_link.name
.codec = "snd-soc-dummy", // "dmic-codec", // -> snd_soc_dai_link.codec_name .codec = "snd-soc-dummy", // "dmic-codec", // -> snd_soc_dai_link.codec_name

136
i2samp.py Normal file
View file

@ -0,0 +1,136 @@
import os
try:
from adafruit_shell import Shell
from clint.textui import colored
except ImportError:
raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell")
shell = Shell()
BLACKLIST = "/etc/modprobe.d/raspi-blacklist.conf"
PRODUCT_NAME = "I2S Amplifier"
OVERLAY = "googlevoicehat-soundcard"
def driver_loaded(driver_name):
return shell.run_command(f"lsmod | grep -q '{driver_name}'", suppress_message=True)
def main():
reboot = False
shell.clear()
if not shell.is_raspberry_pi():
shell.bail("Non-Raspberry Pi board detected.")
print("\nThis script will install everything needed to use\n"
f"{PRODUCT_NAME}.\n")
print(colored.red("--- Warning ---"))
print("\nAlways be careful when running scripts and commands\n"
"copied from the internet. Ensure they are from a\n"
"trusted source.\n")
if not shell.prompt("Do you wish to continue?"):
print("\nAborting...")
shell.exit()
print("\nChecking hardware requirements...")
# Enable I2S overlay
config = shell.get_boot_config()
if config is None:
shell.bail("No Device Tree Detected, not supported")
print(f"\nAdding Device Tree Entry to {config}")
if shell.pattern_search(config, f"^dtoverlay={OVERLAY}$"):
print("dtoverlay already active")
else:
shell.write_text_file(config, f"dtoverlay={OVERLAY}")
reboot = True
if os.path.exists(BLACKLIST):
print("\nCommenting out Blacklist entry in", BLACKLIST)
shell.pattern_replace(BLACKLIST, "^blacklist[[:space:]]*snd_soc_max98357a.*", "#blacklist snd_soc_max98357a")
shell.pattern_replace(BLACKLIST, "^blacklist[[:space:]]*snd_soc_max98357a_i2c.*", "#blacklist snd_soc_max98357a_i2c")
shell.pattern_replace(BLACKLIST, "^blacklist[[:space:]]*snd_soc_max98357a.*", "#blacklist snd_soc_max98357a")
print("Configuring sound output")
if os.path.exists("/etc/asound.conf"):
if os.path.exists("/etc/asound.conf.old"):
shell.remove("/etc/asound.conf.old")
shell.move("/etc/asound.conf", "/etc/asound.conf.old")
shell.write_text_file("~/asound.conf",
"""
pcm.speakerbonnet {
type hw card 0
}
pcm.dmixer {
type dmix
ipc_key 1024
ipc_perm 0666
slave {
pcm "speakerbonnet"
period_time 0
period_size 1024
buffer_size 8192
rate 44100
channels 2
}
}
ctl.dmixer {
type hw card 0
}
pcm.softvol {
type softvol
slave.pcm "dmixer"
control.name "PCM"
control.card 0
}
ctl.softvol {
type hw card 0
}
pcm.!default {
type plug
slave.pcm "softvol"
}
""")
shell.move("~/asound.conf", "/etc/asound.conf")
print("Installing aplay systemd unit")
shell.write_text_file("/etc/systemd/system/aplay.service", """
[Unit]
Description=Invoke aplay from /dev/zero at system start.
[Service]
ExecStart=/usr/bin/aplay -D default -t raw -r 44100 -c 2 -f S16_LE /dev/zero
[Install]
WantedBy=multi-user.target""", append=False)
shell.run_command("sudo systemctl daemon-reload")
shell.run_command("sudo systemctl disable aplay")
print("\nYou can optionally activate '/dev/zero' playback in\n"
"the background at boot. This will remove all\n"
"popping/clicking but does use some processor time.\n\n")
if shell.prompt("Activate '/dev/zero' playback in background? [RECOMMENDED]\n", default="y"):
shell.run_command("sudo systemctl enable aplay")
reboot = True
if driver_loaded("max98357a"):
print(f"\nWe can now test your {PRODUCT_NAME}")
shell.warn("Set your speakers at a low volume if possible!")
if shell.prompt("Do you wish to test your system now?"):
print("Testing...")
shell.run_command("speaker-test -l5 -c2 -t wav")
print("\n" + colored.green("All done!"))
print("\nEnjoy your new $productname!")
if reboot:
shell.prompt_reboot()
# Main function
if __name__ == "__main__":
shell.require_root()
main()

View file

@ -1,3 +1,5 @@
import os
try: try:
from adafruit_shell import Shell from adafruit_shell import Shell
except ImportError: except ImportError:
@ -7,6 +9,7 @@ shell = Shell()
def main(): def main():
shell.clear() shell.clear()
boot_config = shell.get_boot_config()
print("""This script downloads and installs print("""This script downloads and installs
I2S microphone support. I2S microphone support.
""") """)
@ -14,16 +17,18 @@ I2S microphone support.
shell.bail("Non-Raspberry Pi board detected.") shell.bail("Non-Raspberry Pi board detected.")
pi_model = shell.get_board_model() pi_model = shell.get_board_model()
print("{} detected.\n".format(pi_model)) print("{} detected.\n".format(pi_model))
if pi_model in ("RASPBERRY_PI_ZERO", "RASPBERRY_PI_ZERO_W"): if pi_model in ("RASPBERRY_PI_ZERO", "RASPBERRY_PI_ZERO_W", "RASPBERRY_PI_B_REV2"):
pimodel_select = 0 pimodel_select = 0
elif pi_model in ("RASPBERRY_PI_2B", "RASPBERRY_PI_3B", "RASPBERRY_PI_3B_PLUS", "RASPBERRY_PI_3A_PLUS", "RASPBERRY_PI_ZERO_2_W"): elif pi_model in ("RASPBERRY_PI_2B", "RASPBERRY_PI_3B", "RASPBERRY_PI_3B_PLUS", "RASPBERRY_PI_3A_PLUS", "RASPBERRY_PI_ZERO_2_W"):
pimodel_select = 1 pimodel_select = 1
elif pi_model in ("RASPBERRY_PI_4B", "RASPBERRY_PI_CM4"): elif pi_model in ("RASPBERRY_PI_4B", "RASPBERRY_PI_CM4", "RASPBERRY_PI_400"):
pimodel_select = 2 pimodel_select = 2
else: else:
shell.bail("Unsupported Pi board detected.") shell.bail("Unsupported Pi board detected.")
auto_load = shell.prompt("Auto load module at boot?") auto_load = (
not shell.argument_exists('noautoload') and
shell.prompt("Auto load module at boot?", force_arg="autoload"))
print(""" print("""
Installing...""") Installing...""")
@ -52,16 +57,21 @@ Installing...""")
) )
# Enable I2S overlay # Enable I2S overlay
shell.run_command("sed -i -e 's/#dtparam=i2s/dtparam=i2s/g' /boot/config.txt") shell.run_command(f"sed -i -e 's/#dtparam=i2s/dtparam=i2s/g' {boot_config}")
# Done # Done
print("""DONE. print("""DONE.
Settings take effect on next boot. Settings take effect on next boot.
""") """)
shell.prompt_reboot() if not shell.argument_exists('noreboot'):
shell.prompt_reboot(force_arg="reboot")
# Main function # Main function
if __name__ == "__main__": if __name__ == "__main__":
shell.require_root() shell.require_root()
# Probably not necessary for now because the Pi 5 doesn't work anyway
if shell.is_raspberry_pi_os() and shell.is_kernel_userspace_mismatched() and shell.is_pi5_or_newer():
shell.bail("Unable to proceed on Pi 5 or newer boards with a with a 32-bit OS. Please reinstall with a 64-bit OS.")
shell.check_kernel_userspace_mismatch()
main() main()

114
install_wm8960.sh Normal file
View file

@ -0,0 +1,114 @@
#!/usr/bin/env bash
set -o xtrace
set -o errexit
set -o pipefail
set -o nounset
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (use sudo)" 1>&2
exit 1
fi
if [ ! -f /etc/rpi-issue ]; then
echo "Sorry, this drivers only works on raspberry pi"
exit 1
fi
#download the archive
rm -rf WM8960-Audio-HAT
git clone https://github.com/waveshare/WM8960-Audio-HAT
cd WM8960-Audio-HAT
apt-get -y update
apt-get -y install raspberrypi-kernel-headers --no-install-recommends --no-install-suggests
apt-get -y install dkms git i2c-tools libasound2-plugins --no-install-recommends --no-install-suggests
apt-get -y clean
# locate currently installed kernels (may be different to running kernel if
# it's just been updated)
kernels=$(ls /lib/modules)
function install_module {
ver="1.0"
# we create a dir with this version to ensure that 'dkms remove' won't delete
# the sources during kernel updates
marker="0.0.0"
src=$1
mod=$2
if [[ -d /var/lib/dkms/$mod/$ver/$marker ]]; then
rmdir /var/lib/dkms/$mod/$ver/$marker
fi
if [[ -e /usr/src/$mod-$ver || -e /var/lib/dkms/$mod/$ver ]]; then
dkms remove --force -m $mod -v $ver --all || true
rm -rf /usr/src/$mod-$ver
fi
mkdir -p /usr/src/$mod-$ver
cp -a $src/* /usr/src/$mod-$ver/
dkms add -m $mod -v $ver
for kernel in $kernels
do
# It works for kernels greater than or equal 6.5
if [ $(echo "$kernel 6.5" | awk '{if ($1 >= $2) print 1; else print 0}') -eq 0 ]; then
continue
fi
dkms build "$kernel" -k "$kernel" --kernelsourcedir "/lib/modules/$kernel/build" -m $mod -v $ver &&
dkms install --force "$kernel" -k "$kernel" -m $mod -v $ver
done
mkdir -p /var/lib/dkms/$mod/$ver/$marker
}
install_module "./" "wm8960-soundcard"
# install dtbos
cp wm8960-soundcard.dtbo /boot/overlays
#set kernel modules
grep -q "^i2c-dev$" /etc/modules || \
echo "i2c-dev" >> /etc/modules
grep -q "^snd-soc-wm8960$" /etc/modules || \
echo "snd-soc-wm8960" >> /etc/modules
grep -q "^snd-soc-wm8960-soundcard$" /etc/modules || \
echo "snd-soc-wm8960-soundcard" >> /etc/modules
# set modprobe blacklist
grep -q "^blacklist snd_bcm2835$" /etc/modprobe.d/raspi-blacklist.conf || \
echo "blacklist snd_bcm2835" >> /etc/modprobe.d/raspi-blacklist.conf
#set dtoverlays
sed -i -e 's:#dtparam=i2s=on:dtparam=i2s=on:g' /boot/firmware/config.txt || true
sed -i -e 's:#dtparam=i2c_arm=on:dtparam=i2c_arm=on:g' /boot/firmware/config.txt || true
grep -q "^dtoverlay=i2s-mmap$" /boot/firmware/config.txt || \
echo "dtoverlay=i2s-mmap" >> /boot/firmware/config.txt
grep -q "^dtparam=i2s=on$" /boot/firmware/config.txt || \
echo "dtparam=i2s=on" >> /boot/firmware/config.txt
grep -q "^dtoverlay=wm8960-soundcard$" /boot/firmware/config.txt || \
echo "dtoverlay=wm8960-soundcard" >> /boot/firmware/config.txt
#install config files
mkdir -p /etc/wm8960-soundcard
cp *.conf /etc/wm8960-soundcard
cp *.state /etc/wm8960-soundcard
#set service
cp wm8960-soundcard /usr/bin/
chmod -x wm8960-soundcard.service
cp wm8960-soundcard.service /lib/systemd/system/
systemctl enable wm8960-soundcard.service
#cleanup
cd ..
rm -rf WM8960-Audio-HAT
echo "------------------------------------------------------"
echo "Please reboot your raspberry pi to apply all settings"
echo "Enjoy!"
echo "------------------------------------------------------"

View file

@ -1,3 +1,10 @@
"""
Adafruit Raspberry Pi Joy Bonnet Setup Script
(C) Adafruit Industries, Creative Commons 3.0 - Attribution Share Alike
Converted to Python by Melissa LeBlanc-Williams for Adafruit Industries
"""
try: try:
from adafruit_shell import Shell from adafruit_shell import Shell
except ImportError: except ImportError:
@ -49,7 +56,7 @@ EXISTING INSTALLATION, IF ANY, WILL BE OVERWRITTEN.
print(""" print("""
Starting installation... Starting installation...
Updating package index files...""") Updating package index files...""")
shell.run_command('sudo apt-get update', True) shell.run_command('sudo apt-get update', suppress_message=True)
print("Installing Python libraries...") print("Installing Python libraries...")
shell.run_command('sudo apt-get install -y python3-pip python3-dev python3-smbus') shell.run_command('sudo apt-get install -y python3-pip python3-dev python3-smbus')
@ -107,7 +114,7 @@ Updating package index files...""")
Settings take effect on next boot. Settings take effect on next boot.
""") """)
shell.prompt_reboot() shell.prompt_reboot()
# Main function # Main function
if __name__ == "__main__": if __name__ == "__main__":
shell.require_root() shell.require_root()

View file

@ -1,14 +1,15 @@
# Instructions! # Instructions!
# cd ~ # cd ~
# sudo apt-get install python3-pip # sudo apt-get install python3-pip
# sudo pip3 install --upgrade adafruit-python3-shell click # sudo pip3 install --upgrade adafruit-python-shell click
# wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/libgpiod.py # wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/libgpiod.py
# sudo python3 libgpiod.py # sudo python3 libgpiod.py
import sys
try: try:
import click import click
except ImportError: except ImportError:
raise RuntimeError("The library 'Click' was not found. To install, try typing: sudo pip3 install Click==7.0") raise RuntimeError("The library 'Click' was not found. To install, try typing: sudo pip3 install --upgrade click")
try: try:
from adafruit_shell import Shell from adafruit_shell import Shell
except ImportError: except ImportError:
@ -20,19 +21,17 @@ shell.group = 'LIBGPIOD'
@click.command() @click.command()
@click.option('-l', '--legacy', is_flag=True, help="Install a legacy version of libgpiod for systems with older libraries") @click.option('-l', '--legacy', is_flag=True, help="Install a legacy version of libgpiod for systems with older libraries")
def main(legacy): def main(legacy):
print("""Installing build requirements - this may take a few minutes! print("Installing build requirements - this may take a few minutes!\n")
""")
# install generic linux packages required # install generic linux packages required
shell.run_command("sudo apt-get update") shell.run_command("sudo apt-get update")
shell.run_command("sudo apt-get install -y autoconf autoconf-archive automake build-essential git libtool pkg-config python3-dev python3-setuptools swig3.0 wget") shell.run_command("sudo apt-get install -y autoconf autoconf-archive automake build-essential git libtool pkg-config python3-dev python3-setuptools swig4.0 wget")
# for raspberry pi we need... # for raspberry pi we need...
shell.run_command("sudo apt-get install -y raspberrypi-kernel-headers") shell.run_command("sudo apt-get install -y raspberrypi-kernel-headers")
build_dir = shell.run_command("mktemp -d /tmp/libgpiod.XXXX", return_output=True) build_dir = shell.run_command("mktemp -d /tmp/libgpiod.XXXX", return_output=True).strip()
print("""Cloning libgpiod repository to {} print(f"Cloning libgpiod repository to {build_dir}\n")
""".format(build_dir))
shell.chdir(build_dir) shell.chdir(build_dir)
shell.run_command("git clone git://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git .") shell.run_command("git clone git://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git .")
@ -40,8 +39,7 @@ def main(legacy):
if legacy: if legacy:
shell.run_command("git checkout v1.4.2 -b v1.4.2") shell.run_command("git checkout v1.4.2 -b v1.4.2")
print("""Building libgpiod print("Building libgpiod\n")
""")
include_path = shell.run_command("python3 -c \"from sysconfig import get_paths; print(get_paths()['include'])\"", return_output=True) include_path = shell.run_command("python3 -c \"from sysconfig import get_paths; print(get_paths()['include'])\"", return_output=True)
@ -49,10 +47,11 @@ def main(legacy):
shell.run_command("./autogen.sh --enable-tools=yes --prefix=/usr/local/ --enable-bindings-python CFLAGS=\"-I/{}\" && make && sudo make install && sudo ldconfig".format(include_path)) shell.run_command("./autogen.sh --enable-tools=yes --prefix=/usr/local/ --enable-bindings-python CFLAGS=\"-I/{}\" && make && sudo make install && sudo ldconfig".format(include_path))
if shell.exists("bindings/python/.libs"): if shell.exists("bindings/python/.libs"):
# This is not the right way to do this, but it works version = sys.version_info
shell.run_command("sudo cp bindings/python/.libs/gpiod.so /usr/local/lib/python3.?/dist-packages/") python_folder = f"python{version.major}.{version.minor}"
shell.run_command("sudo cp bindings/python/.libs/gpiod.la /usr/local/lib/python3.?/dist-packages/") shell.run_command(f"sudo cp bindings/python/.libs/gpiod.so /usr/local/lib/{python_folder}/dist-packages/")
shell.run_command("sudo cp bindings/python/.libs/gpiod.a /usr/local/lib/python3.?/dist-packages/") shell.run_command(f"sudo cp bindings/python/.libs/gpiod.la /usr/local/lib/{python_folder}/dist-packages/")
shell.run_command(f"sudo cp bindings/python/.libs/gpiod.a /usr/local/lib/{python_folder}/dist-packages/")
shell.exit() shell.exit()
# Main function # Main function

View file

@ -0,0 +1,36 @@
# Adafruit HX8257 PiTFT Plus TFT LCD Screen
# width=480,height=320
command 0x01 # _SWRESET and Delay 100ms
delay 100
command 0xB9 0xFF 0x83 0x57 # _SETC and delay 500ms
delay 250
delay 250
command 0xB3 0x80 0x00 0x06 0x06 # _SETRGB 0x80 enables SDO pin (0x00 disables)
command 0xB6 0x25 # _SETCOM -1.52V
command 0xB0 0x68 # _SETOSC Normal mode 70Hz, Idle mode 55 Hz
command 0xCC 0x05 # _SETPANEL BGR, Gate direction swapped
command 0xB1 0x00 0x15 0x1C 0x1C 0x83 0xAA # _SETPWR1 Not deep standby BT VSPR VSNR AP
command 0xC0 0x50 0x50 0x01 0x3C 0x1E 0x08 # _SETSTBA OPON normal OPON idle STBA GEN
command 0xB4 0x02 0x40 0x00 0x2A 0x2A 0x0D 0x78 # _SETCYC NW 0x02 RTN DIV DUM DUM GDON GDOFF
# _SETGAMMA
command 0xE0 0x02 0x0A 0x11 0x1d 0x23 0x35 0x41 0x4b 0x4b 0x42 0x3A 0x27 0x1B 0x08 0x09 0x03 0x02 0x0A 0x11 0x1d 0x23 0x35 0x41 0x4b 0x4b 0x42 0x3A 0x27 0x1B 0x08 0x09 0x03 0x00 0x01
command 0x3A 0x55 # _COLMOD 16 bit
# Command 36h sets the read order from frame memory to the display panel
# Remember to swap width/height on 90/270 rotations
command 0x36 0x00 # rotation 0
#command 0x36 0xA0 # rotation 90
#command 0x36 0xC0 # rotation 180
#command 0x36 0x60 # rotation 270
command 0x35 0x00 # _TEON TW off
command 0x44 0x00 0x02 # _TEARLINE
command 0x11 # _SLPOUT
delay 150
command 0x29 # _DISPON
delay 50

View file

@ -0,0 +1,48 @@
# Adafruit ILI9341 PiTFT TFT LCD Screen
# width=320,height=240
command 0x01 # Software reset
delay 128
command 0xEF 0x03 0x80 0x02
command 0xCF 0x00 0xC1 0x30
command 0xED 0x64 0x03 0x12 0x81
command 0xE8 0x85 0x00 0x78
command 0xCB 0x39 0x2C 0x00 0x34 0x02
command 0xF7 0x20
command 0xEA 0x00 0x00
command 0xc0 0x23 # Power control VRH[5:0]
command 0xc1 0x10 # Power control SAP[2:0];BT[3:0]
command 0xc5 0x3e 0x28 # VCM control
command 0xc7 0x86 # VCM control2
#define MADCTL_MY 0x80 ///< Bottom to top
#define MADCTL_MX 0x40 ///< Right to left
#define MADCTL_MV 0x20 ///< Reverse Mode
#define MADCTL_ML 0x10 ///< LCD refresh Bottom to top
#define MADCTL_RGB 0x00 ///< Red-Green-Blue pixel order
#define MADCTL_BGR 0x08 ///< Blue-Green-Red pixel order
#define MADCTL_MH 0x04 ///< LCD refresh right to left
# Command 36h sets the read order from frame memory to the display panel
# Remember to swap width/height on 90/270 rotations
command 0x36 0x88 # rotation 0
#command 0x36 0xE8 # rotation 90
#command 0x36 0x48 # rotation 180
#command 0x36 0x28 # rotation 270
command 0x37 0x00 # Vertical scroll zero
command 0x3a 0x55 # COLMOD: Pixel Format Set
command 0xb1 0x00 0x18 # Frame Rate Control (In Normal Mode/Full Colors)
command 0xb6 0x08 0x82 0x27 # Display Function Control
command 0xF2 0x00 # 3Gamma Function Disable
command 0x26 0x01 # Gamma curve selected
# Set Gamma
command 0xe0 0x0F 0x31 0x2B 0x0C 0x0E 0x08 0x4E 0xF1 0x37 0x07 0x10 0x03 0x0E 0x09 0x00
command 0xe1 0x00 0x0E 0x14 0x03 0x11 0x07 0x31 0xC1 0x48 0x08 0x0F 0x0C 0x31 0x36 0x0F
command 0x11 # Exit Sleep
delay 120
command 0x29 # Display on
delay 120

View file

@ -0,0 +1,29 @@
# Adafruit ST7789 MiniPiTFT LCD and TFT Bonnet
# width=240,height=240
command 0x01 # _SWRESET and Delay 150ms
delay 150
command 0x11 # _SLPOUT and Delay 10ms
delay 10
command 0x3A 0x55 # _COLMOD and Delay 10ms
delay 10
command 0x36 0x08 # _MADCTL Botton->Top Refresh
command 0x21 # _INVON Hack and Delay 10ms
delay 10
command 0x13 # _NORON and Delay 10ms
delay 10
# Command 36h sets the read order from frame memory to the display panel
# Remember to swap width/height on 90/270 rotations if required
command 0x36 0x00 # rotation 0
#command 0x36 0xA0 # rotation 90
#command 0x36 0xC0 # rotation 180
#command 0x36 0x60 # rotation 270
command 0x29 # _DISPON and Delay 500ms
delay 250
delay 250

View file

@ -0,0 +1,559 @@
"""
Adafruit PiTFT MIPI Display Installer Script
(C) Adafruit Industries, Creative Commons 3.0 - Attribution Share Alike
Written by Melissa LeBlanc-Williams for Adafruit Industries
"""
import time
import os
try:
import click
except ImportError:
raise RuntimeError("The library 'Click' was not found. To install, try typing: pip3 install Click")
try:
from adafruit_shell import Shell
except ImportError:
raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: pip3 install adafruit-python-shell")
shell = Shell()
shell.group = 'PITFT-MIPI'
__version__ = "1.0.1"
"""
This is the main configuration. Displays should be placed in the order
they are to appear in the menu.
"""
config = [
{
"type": "28r",
"menulabel": "PiTFT 2.4\", 2.8\" or 3.2\" resistive (240x320)",
"product": "2.8\" resistive, PID 1601",
"touchscreen": {
"identifier": "STMPE Touchscreen Calibration",
"product": "stmpe",
"transforms": {
"0": "0.988809 -0.023645 0.060523 -0.028817 1.003935 0.034176 0 0 1",
"90": "0.014773 -1.132874 1.033662 1.118701 0.009656 -0.065273 0 0 1",
"180": "-1.115235 -0.010589 1.057967 -0.005964 -1.107968 1.025780 0 0 1",
"270": "-0.033192 1.126869 -0.014114 -1.115846 0.006580 1.050030 0 0 1",
},
"calibrations": {
"0": "4232 11 -879396 1 5786 -752768 65536",
"90": "33 -5782 21364572 4221 35 -1006432 65536",
"180": "-4273 61 16441290 4 -5772 21627524 65536",
"270": "-9 5786 -784608 -4302 19 16620508 65536",
},
"overlay": "touch-stmpe",
},
"mipi_data": {
"command_bin": "adafruit_ili9341_drm",
"gpio": "dc-gpio=25",
"viewport": {
"90": "width=320,height=240",
"180": "width=240,height=320",
"270": "width=320,height=240",
"0": "width=240,height=320",
},
},
"width": 320,
"height": 240,
},
{
"type": "22",
"menulabel": "PiTFT 2.2\" no touch",
"product": "2.2\" no touch",
"mipi_data": {
"command_bin": "adafruit_ili9341_drm",
"gpio": "dc-gpio=25",
"viewport": {
"90": "width=320,height=240",
"180": "width=240,height=320",
"270": "width=320,height=240",
"0": "width=240,height=320",
},
},
"width": 320,
"height": 240,
},
{
"type": "28c",
"menulabel": "PiTFT 2.8\" capacitive touch",
"product": "2.8\" capacitive, PID 1983",
"touchscreen": {
"identifier": "FocalTech Touchscreen Calibration",
"product": "EP0110M09",
"transforms": {
"0": "-1 0 1 0 -1 1 0 0 1",
"90": "0 1 0 -1 0 1 0 0 1",
"180": "1 0 0 0 1 0 0 0 1",
"270": "0 -1 1 1 0 0 0 0 1",
},
"calibrations": "320 65536 0 -65536 0 15728640 65536",
"overlay": "touch-ft6236",
},
"mipi_data": {
"command_bin": "adafruit_ili9341_drm",
"gpio": "dc-gpio=25",
"viewport": {
"90": "width=320,height=240",
"180": "width=240,height=320",
"270": "width=320,height=240",
"0": "width=240,height=320",
},
},
"width": 320,
"height": 240,
},
{
"type": "35r",
"menulabel": "PiTFT 3.5\" resistive touch",
"product": "3.5\" Resistive",
"touchscreen": {
"identifier": "STMPE Touchscreen Calibration",
"product": "stmpe",
"transforms": {
"0": "-1.098388 0.003455 1.052099 0.005512 -1.093095 1.026309 0 0 1",
"90": "-0.000087 1.094214 -0.028826 -1.091711 -0.004364 1.057821 0 0 1",
"180": "1.102807 0.000030 -0.066352 0.001374 1.085417 -0.027208 0 0 1",
"270": "0.003893 -1.087542 1.025913 1.084281 0.008762 -0.060700 0 0 1",
},
"calibrations": {
"0": "5724 -6 -1330074 26 8427 -1034528 65536",
"90": "5 8425 -978304 -5747 61 22119468 65536",
"180": "-5682 -1 22069150 13 -8452 32437698 65536",
"270": "3 -8466 32440206 5703 -1 -1308696 65536",
},
"overlay": "touch-stmpe",
},
"mipi_data": {
"command_bin": "adafruit_hx8357_drm",
"gpio": "dc-gpio=25",
"viewport": {
"90": "width=480,height=320",
"180": "width=320,height=480",
"270": "width=480,height=320",
"0": "width=320,height=480",
},
},
"width": 480,
"height": 320,
"x11_scale": 1.5,
},
{
"type": "st7789_240x240",
"menulabel": "PiTFT Mini 1.3\" or 1.54\" display",
"product": "1.54\" or 1.3\" no touch",
"mipi_data": {
"command_bin": "adafruit_st7789_drm",
"gpio": "dc-gpio=25,backlight-gpio=22",
"viewport": {
"0": "width=240,height=240",
"90": "width=240,height=240,x-offset=80",
"180": "width=240,height=240,y-offset=80",
"270": "width=240,height=240",
},
},
"width": 240,
"height": 240,
},
{
"type": "st7789_240x320",
"menulabel": "ST7789V 2.0\" no touch",
"product": "2.0\" no touch",
"mipi_data": {
"command_bin": "adafruit_st7789_drm",
"gpio": "dc-gpio=25,backlight-gpio=22",
"viewport": {
"0": "width=320,height=240",
"90": "width=240,height=320",
"180": "width=320,height=240",
"270": "width=240,height=320",
},
},
"width": 320,
"height": 240,
},
{
"type": "st7789_240x135",
"menulabel": "MiniPiTFT 1.14\" display",
"product": "1.14\" no touch",
"mipi_data": {
"command_bin": "adafruit_st7789_drm",
"gpio": "dc-gpio=25,backlight-gpio=22",
"viewport": {
"0": "width=136,height=240,x-offset=52,y-offset=40",
"90": "width=240,height=136,y-offset=52,x-offset=40",
"180": "width=136,height=240,x-offset=52,y-offset=40",
"270": "width=240,height=136,y-offset=52,x-offset=40",
},
},
"width": 240,
"height": 135,
},
{
"type": "st7789v_bonnet_240x240",
"menulabel": "BrainCraft HAT or TFT 1.3\" Bonnet + Joystick",
"product": "1.3\" Joystick",
"mipi_data": {
"command_bin": "adafruit_st7789_drm",
"gpio": "dc-gpio=25,backlight-gpio=26",
"viewport": {
"0": "width=240,height=240",
"90": "width=240,height=240,x-offset=80",
"180": "width=240,height=240,y-offset=80",
"270": "width=240,height=240",
},
},
"width": 240,
"height": 240,
},
]
# default mipi data
mipi_data = {
"speed": 40000000,
"spi": "spi0-0",
}
PITFT_ROTATIONS = ("90", "180", "270", "0")
UPDATE_DB = False
SYSTEMD = None
MIPI_MINIMUM_KERNEL = 5.15
pitft_config = None
pitftrot = None
auto_reboot = None
def warn_exit(message):
shell.warn(message)
shell.exit(1)
def print_version(ctx, param, value):
if not value or ctx.resilient_parsing:
return
print("Adafruit PiTFT Helper v{}".format(__version__))
shell.exit(1)
def progress(ellipsis_count):
for i in range(ellipsis_count):
print("...", end='')
time.sleep(1)
print("")
def sysupdate():
global UPDATE_DB
if not UPDATE_DB:
print("Updating apt indexes...", end='')
progress(3)
if not shell.run_command('sudo apt update', suppress_message=True):
warn_exit("Apt failed to update indexes!")
if not shell.run_command('sudo apt-get update', suppress_message=True):
warn_exit("Apt failed to update indexes!")
print("Reading package lists...")
progress(3)
UPDATE_DB = True
return True
############################ Sub-Scripts ############################
def softwareinstall():
print("Installing Pre-requisite Software...This may take a few minutes!")
if not shell.run_command("apt-get install -y libts0", suppress_message=True):
if not shell.run_command("apt-get install -y tslib"):
if not shell.run_command("apt-get install -y libts-dev"):
warn_exit("Apt failed to install TSLIB!")
if not shell.run_command("apt-get install -y bc fbi git python3-dev python3-pip python3-smbus python3-spidev evtest libts-bin device-tree-compiler libraspberrypi-dev build-essential python3-evdev"):
warn_exit("Apt failed to install software!")
return True
def uninstall_bootconfigtxt():
"""Remove any old flexfb/fbtft stuff"""
if shell.pattern_search(f"{boot_dir}/config.txt", "adafruit-pitft-helper"):
print(f"Already have an adafruit-pitft-helper section in {boot_dir}/config.txt.")
print("Removing old section...")
shell.run_command(f"cp {boot_dir}/config.txt {boot_dir}/configtxt.bak")
shell.pattern_replace(f"{boot_dir}/config.txt", '\n# --- added by adafruit-pitft-helper.*?\n# --- end adafruit-pitft-helper.*?\n', multi_line=True)
return True
def update_configtxt():
f"""update {boot_dir}/config.txt with appropriate values"""
uninstall_bootconfigtxt()
# Driver does not work if hdmi_force_hotplug=1 is present
shell.pattern_replace(f"{boot_dir}/config.txt", "hdmi_force_hotplug=1", "hdmi_force_hotplug=0")
display_overlay = f"dtoverlay=mipi-dbi-spi,{mipi_data['spi']},speed=40000000"
display_overlay += f"\ndtparam=compatible={mipi_data['command_bin']}\\0panel-mipi-dbi-spi"
viewport = ""
if mipi_data['viewport'][pitftrot] is not None:
viewport = mipi_data['viewport'][pitftrot]
display_overlay += f"\ndtparam={viewport}"
if "gpio" in mipi_data:
display_overlay += f"\ndtparam={mipi_data['gpio']}"
# Touch Overlay
touch_overlay = ""
if "touchscreen" in pitft_config and "overlay" in pitft_config["touchscreen"]:
# use dtc to compile and copy overlay
touch_overlay = pitft_config["touchscreen"]["overlay"]
shell.run_command(f"dtc -I dts -O dtb -o {boot_dir}/overlays/{touch_overlay}.dtbo overlays/{touch_overlay}.dts")
touch_overlay = f"\ndtoverlay={touch_overlay}"
date = shell.date()
shell.write_text_file(f"{boot_dir}/config.txt", f"""
# --- added by adafruit-pitft-helper {date} ---
[all]
dtparam=spi=on
dtparam=i2c1=on
dtparam=i2c_arm=on
{display_overlay}
{touch_overlay}
# --- end adafruit-pitft-helper {date} ---
""")
return True
def update_udev():
shell.write_text_file("/etc/udev/rules.d/95-touchmouse.rules", """
SUBSYSTEM=="input", ATTRS{name}=="touchmouse", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"
""", append=False)
shell.write_text_file("/etc/udev/rules.d/95-ftcaptouch.rules", """
SUBSYSTEM=="input", ATTRS{name}=="EP0110M09", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"
SUBSYSTEM=="input", ATTRS{name}=="generic ft5x06*", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"
""", append=False)
shell.write_text_file("/etc/udev/rules.d/95-stmpe.rules", """
SUBSYSTEM=="input", ATTRS{name}=="*stmpe*", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"
""", append=False)
return True
def compile_display_fw():
command_src = "mipi/panel.txt"
# We could just copy the file to panel.txt, edit that, then remove it after
shell.copy(f"mipi/{mipi_data['command_bin']}.txt", command_src)
# Make sure each of the lines with "# rotation" starts with exactly 1 # and no more
shell.pattern_replace(command_src, "^#*(.*?# rotation.*?$)", "#\\1")
# Uncomment the one for the rotation we are going for
shell.pattern_replace(command_src, "^#(.*?# rotation " + pitftrot + ".*?$)", "\\1")
# Download the mipi-dbi-cmd script if it doesn't exist
if not shell.exists("mipi-dbi-cmd"):
shell.run_command("wget https://raw.githubusercontent.com/notro/panel-mipi-dbi/main/mipi-dbi-cmd")
shell.run_command("chmod +x mipi-dbi-cmd")
# Run the mipi-dbi-script and output directly to the /lib/firmware folder
shell.run_command(f"./mipi-dbi-cmd /lib/firmware/{mipi_data['command_bin']}.bin mipi/panel.txt")
shell.remove(command_src)
return True
def update_pointercal():
if "calibrations" in pitft_config["touchscreen"]:
if isinstance(pitft_config["touchscreen"]["calibrations"], dict):
shell.write_text_file("/etc/pointercal", pitft_config["touchscreen"]["calibrations"][pitftrot])
else:
shell.write_text_file("/etc/pointercal", pitft_config["touchscreen"]["calibrations"])
return True
def install_mipi():
global mipi_data
if "mipi_data" in pitft_config:
mipi_data.update(pitft_config['mipi_data'])
if not compile_display_fw():
shell.bail("Unable to compile MIPI firmware")
# if there's X11 installed...
if shell.exists("/etc/lightdm"):
print("Setting raspi-config to boot to desktop w/o login...")
shell.run_command("raspi-config nonint do_boot_behaviour B4")
# Disable overscan compensation (use full screen):
shell.run_command("raspi-config nonint do_overscan 1")
if not update_configtxt():
shell.bail(f"Unable to update {boot_dir}/config.txt")
return True
def update_xorg():
if "touchscreen" in pitft_config:
transform = "Option \"TransformationMatrix\" \"{}\"".format(pitft_config["touchscreen"]["transforms"][pitftrot])
shell.write_text_file("/usr/share/X11/xorg.conf.d/20-calibration.conf", f"""
Section "InputClass"
Identifier "{pitft_config["touchscreen"]["identifier"]}"
MatchProduct "{pitft_config["touchscreen"]["product"]}"
MatchDevicePath "/dev/input/event*"
Driver "libinput"
{transform}
EndSection
""",
append=False,
)
return True
def get_config_types():
types = []
for item in config:
types.append(item["type"])
return types
def get_config(type):
for item in config:
if item["type"] == type:
return item
return None
def success():
global auto_reboot
shell.info("Success!")
print("""
Settings take effect on next boot.
""")
if auto_reboot is None:
auto_reboot = shell.prompt("REBOOT NOW?", default="y")
if not auto_reboot:
print("Exiting without reboot.")
shell.exit()
print("Reboot started...")
shell.reboot()
shell.exit()
####################################################### MAIN
target_homedir = "/home/pi"
username = os.environ["SUDO_USER"]
user_homedir = os.path.expanduser(f"~{username}")
if shell.isdir(user_homedir):
target_homedir = user_homedir
boot_dir = "/boot/firmware"
if not shell.exists(boot_dir) or not shell.isdir(boot_dir):
boot_dir = "/boot"
@click.command()
@click.option('-v', '--version', is_flag=True, callback=print_version, expose_value=False, is_eager=True, help="Print version information")
@click.option('-u', '--user', nargs=1, default=target_homedir, type=str, help="Specify path of primary user's home directory", show_default=True)
@click.option('--display', nargs=1, default=None, help="Specify a display option (1-{}) or type {}".format(len(config), get_config_types()))
@click.option('--rotation', nargs=1, default=None, type=int, help="Specify a rotation option (1-4) or degrees {}".format(tuple(sorted([int(x) for x in PITFT_ROTATIONS]))))
@click.option('--reboot', nargs=1, default=None, type=click.Choice(['yes', 'no']), help="Specify whether to reboot after the script is finished")
@click.option('--boot', nargs=1, default=boot_dir, type=str, help="Specify the boot directory", show_default=True)
def main(user, display, rotation, reboot, boot):
global target_homedir, pitft_config, pitftrot, auto_reboot, boot_dir
shell.clear()
if user != target_homedir:
target_homedir = user
print(f"Homedir = {target_homedir}")
if boot != boot_dir:
if shell.isdir(boot):
boot_dir = boot
print(f"Boot dir = {boot_dir}")
else:
print(f"{boot} not found or not a directory. Using {boot_dir} instead.")
print("""This script downloads and installs
PiTFT Support using userspace touch
controls and a DTO for display drawing.
one of several configuration files.
Run time of up to 5 minutes. Reboot required!
""")
if reboot is not None:
auto_reboot = reboot.lower() == 'yes'
# Check that the user is running the minimum kernel on this device
if not shell.kernel_minimum(MIPI_MINIMUM_KERNEL):
shell.warn(f"In order to continue, you will need to update your kernel to a minimum of {MIPI_MINIMUM_KERNEL}. ")
if shell.get_os() == "Raspbian":
shell.info("It looks like you are running this on a Raspberry Pi. You can update it to the latest version by running 'sudo rpi-update'.")
shell.exit()
if display in [str(x) for x in range(1, len(config) + 1)]:
pitft_config = config[int(display) - 1]
print("Display Type: {}".format(pitft_config["menulabel"]))
elif display in get_config_types():
pitft_config = get_config(display)
print("Display Type: {}".format(pitft_config["menulabel"]))
else:
# Build menu from config
selections = []
for item in config:
option = "{} ({}x{})".format(item['menulabel'], item['width'], item['height'])
selections.append(option)
selections.append("Quit without installing")
PITFT_SELECT = shell.select_n("Select configuration:", selections)
if PITFT_SELECT == len(config) + 1:
shell.exit(1)
pitft_config = config[PITFT_SELECT - 1]
if rotation is not None and 1 <= rotation <= 4:
pitftrot = PITFT_ROTATIONS[rotation - 1]
print("Rotation: {}".format(pitftrot))
elif str(rotation) in PITFT_ROTATIONS:
pitftrot = str(rotation)
print("Rotation: {}".format(pitftrot))
else:
PITFT_ROTATE = shell.select_n(
"Select rotation:", (
"90 degrees (landscape)",
"180 degrees (portrait)",
"270 degrees (landscape)",
"0 degrees (portrait)"
))
pitftrot = PITFT_ROTATIONS[PITFT_ROTATE - 1]
if 'rotations' in pitft_config and isinstance(pitft_config['rotations'], dict) and pitftrot in pitft_config['rotations'] and pitft_config['rotations'][pitftrot] is None:
shell.bail("""Unfortunately {rotation} degrees for the {display} is not working at this time. Please
restart the script and choose a different orientation.""".format(rotation=pitftrot, display=pitft_config["menulabel"]))
# check init system (technique borrowed from raspi-config):
shell.info('Checking init system...')
if shell.run_command("which systemctl", suppress_message=True) and shell.run_command("systemctl | grep '\-\.mount'", suppress_message=True):
SYSTEMD = True
print("Found systemd")
elif os.path.isfile("/etc/init.d/cron") and not os.path.islink("/etc/init.d/cron"):
SYSTEMD = False
print("Found sysvinit")
else:
shell.bail("Unrecognised init system")
if shell.grep("boot", "/proc/mounts"):
print("/boot is mounted")
else:
print("/boot must be mounted. if you think it's not, quit here and try: sudo mount /dev/mmcblk0p1 /boot")
if shell.prompt("Continue?"):
print("Proceeding.")
else:
shell.bail("Aborting.")
if not shell.isdir(target_homedir):
shell.bail("{} must be an existing directory (use -u /home/foo to specify)".format(target_homedir))
shell.info("System update")
if not sysupdate():
shell.bail("Unable to apt-get update")
shell.info("Installing Python libraries & Software...")
if not softwareinstall():
shell.bail("Unable to install software")
shell.info("Adding MIPI support...")
if not install_mipi():
shell.bail("Unable to configure mipi")
shell.info(f"Updating {boot_dir}/config.txt...")
if not update_configtxt():
shell.bail(f"Unable to update {boot_dir}/config.txt")
if "touchscreen" in pitft_config:
shell.info("Updating SysFS rules for Touchscreen...")
if not update_udev():
shell.bail("Unable to update /etc/udev/rules.d")
shell.info("Updating TSLib default calibration...")
if not update_pointercal():
shell.bail("Unable to update /etc/pointercal")
if shell.exists("/etc/lightdm"):
shell.info("Updating X11 default calibration...")
if not update_xorg():
shell.bail("Unable to update calibration")
success()
# Main function
if __name__ == "__main__":
shell.require_root()
main()

View file

@ -43,7 +43,7 @@
#size-cells = <0>; #size-cells = <0>;
pitft: pitft@0{ pitft: pitft@0{
compatible = "sitronix,st7789v"; compatible = "fbtft,minipitft13";
reg = <0>; reg = <0>;
pinctrl-names = "default"; pinctrl-names = "default";
pinctrl-0 = <&pitft_pins>; pinctrl-0 = <&pitft_pins>;
@ -54,7 +54,7 @@
txbuflen = <32768>; txbuflen = <32768>;
buswidth = <8>; buswidth = <8>;
dc-gpios = <&gpio 25 0>; dc-gpios = <&gpio 25 0>;
led-gpios = <&gpio 26 1>; led-gpios = <&gpio 26 0>;
debug = <0>; debug = <0>;
}; };
}; };

View file

@ -43,7 +43,7 @@
#size-cells = <0>; #size-cells = <0>;
pitft: pitft@0{ pitft: pitft@0{
compatible = "sitronix,st7789v"; compatible = "fbtft,minipitft13";
reg = <0>; reg = <0>;
pinctrl-names = "default"; pinctrl-names = "default";
pinctrl-0 = <&pitft_pins>; pinctrl-0 = <&pitft_pins>;
@ -54,7 +54,7 @@
txbuflen = <32768>; txbuflen = <32768>;
buswidth = <8>; buswidth = <8>;
dc-gpios = <&gpio 25 0>; dc-gpios = <&gpio 25 0>;
led-gpios = <&gpio 26 1>; led-gpios = <&gpio 26 0>;
debug = <0>; debug = <0>;
}; };
}; };

View file

@ -0,0 +1,71 @@
/*
* Device Tree overlay for pitft by Adafruit
*
*/
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835";
fragment@0 {
target = <&spidev0>;
__overlay__ {
status = "disabled";
};
};
fragment@1 {
target = <&spidev1>;
__overlay__ {
status = "disabled";
};
};
fragment@2 {
target = <&gpio>;
__overlay__ {
pitft_pins: pitft_pins {
brcm,pins = <25>;
brcm,function = <1>; /* out */
brcm,pull = <0>; /* none */
};
};
};
fragment@3 {
target = <&spi0>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
pitft: pitft@0{
compatible = "ilitek,ili9340";
reg = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pitft_pins>;
spi-max-frequency = <32000000>;
rotate = <90>;
fps = <25>;
bgr;
buswidth = <8>;
dc-gpios = <&gpio 25 0>;
debug = <0>;
};
};
};
__overrides__ {
speed = <&pitft>,"spi-max-frequency:0";
rotate = <&pitft>,"rotate:0", /* fbtft */
<&pitft>,"rotation:0"; /* drm */
fps = <&pitft>,"fps:0";
debug = <&pitft>,"debug:0";
drm = <&pitft>,"compatible=adafruit,yx240qv29";
};
};

View file

@ -0,0 +1,114 @@
/*
* Device Tree overlay for Adafruit PiTFT 2.4" resistive touch screen with tsc2007
*
*/
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835";
fragment@0 {
target = <&spi0>;
__overlay__ {
status = "okay";
};
};
fragment@2 {
target = <&spidev0>;
__overlay__ {
status = "disabled";
};
};
fragment@3 {
target = <&spidev1>;
__overlay__ {
status = "disabled";
};
};
fragment@4 {
target = <&gpio>;
__overlay__ {
adafruit_2_4_tft_pins: adafruit_2_4_tft_pins {
brcm,pins = <25 24 18>;
brcm,function = <1 0 1>; /* out in out*/
brcm,pull = <0 2 2>; /* none up up */
};
};
};
fragment@5 {
target = <&spi0>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
cs-gpios = <&gpio 8 1>;
adafruit_2_4_tft: adafruit_2_4_tft@0{
compatible = "adafruit,yx240qv29";
reg = <0>;
pinctrl-names = "default";
pinctrl-0 = <&adafruit_2_4_tft_pins>;
spi-max-frequency = <32000000>;
rotation = <90>;
reset-gpios = <&gpio 23 0>;
dc-gpios = <&gpio 25 0>;
};
};
};
fragment@7 {
target = <&i2c1>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
tsc2007: tsc2007@48 {
compatible = "ti,tsc2007";
reg = <0x48>;
ti,fuzzx = <4>;
ti,fuzzy = <4>;
ti,max-rt = <3700>;
ti,fuzzz = <4>;
ti,x-plate-ohms = <180>;
panel = <&adafruit_2_4_tft>;
pinctrl-0 = <&adafruit_2_4_tft_pins>;
interrupt-parent = <&gpio>;
interrupts = <24 2>;
gpios = <&gpio 24 1>;
};
};
};
fragment@8 {
target-path = "/soc";
__overlay__ {
backlight: backlight {
compatible = "gpio-backlight";
pinctrl-0 = <&adafruit_2_4_tft_pins>;
gpios = <&gpio 18 2>;
default-on;
};
};
};
__overrides__ {
speed = <&adafruit_2_4_tft>,"spi-max-frequency:0";
rotate = <&adafruit_2_4_tft>,"rotation:0";
fps = <&adafruit_2_4_tft>,"fps:0";
debug = <&adafruit_2_4_tft>,"debug:0";
// xohms = <&tsc2007>,"touchscreen-x-plate-ohms;0";
// swapxy = <&tsc2007>,"touchscreen-swapped-x-y?";
};
};

View file

@ -0,0 +1,93 @@
/*
* Device Tree overlay for Adafruit PiTFT 2.8" capacitive touch screen
*
*/
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835";
fragment@0 {
target = <&spi0>;
__overlay__ {
status = "okay";
};
};
fragment@1 {
target = <&spidev0>;
__overlay__ {
status = "disabled";
};
};
fragment@2 {
target = <&gpio>;
__overlay__ {
pitft_pins: pitft_pins {
brcm,pins = <24 25>;
brcm,function = <0 1>; /* in out */
brcm,pull = <2 0>; /* pullup none */
};
};
};
fragment@3 {
target = <&spi0>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
pitft: pitft@0{
compatible = "ilitek,ili9340";
reg = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pitft_pins>;
spi-max-frequency = <32000000>;
rotate = <90>;
fps = <25>;
bgr;
buswidth = <8>;
dc-gpios = <&gpio 25 0>;
debug = <0>;
};
};
};
fragment@4 {
target = <&i2c1>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
ft6236: ft6236@38 {
compatible = "focaltech,ft6236";
reg = <0x38>;
interrupt-parent = <&gpio>;
interrupts = <24 2>;
touchscreen-size-x = <240>;
touchscreen-size-y = <320>;
};
};
};
__overrides__ {
speed = <&pitft>,"spi-max-frequency:0";
rotate = <&pitft>,"rotate:0", /* fbtft */
<&pitft>,"rotation:0"; /* drm */
fps = <&pitft>,"fps:0";
debug = <&pitft>,"debug:0";
drm = <&pitft>,"compatible=adafruit,yx240qv29";
touch-sizex = <&ft6236>,"touchscreen-size-x:0";
touch-sizey = <&ft6236>,"touchscreen-size-y:0";
touch-invx = <&ft6236>,"touchscreen-inverted-x?";
touch-invy = <&ft6236>,"touchscreen-inverted-y?";
touch-swapxy = <&ft6236>,"touchscreen-swapped-x-y?";
};
};

View file

@ -0,0 +1,126 @@
/*
* Device Tree overlay for Adafruit PiTFT 2.8" resistive touch screen
*
*/
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835";
fragment@0 {
target = <&spi0>;
__overlay__ {
status = "okay";
};
};
fragment@1 {
target = <&spidev0>;
__overlay__ {
status = "disabled";
};
};
fragment@2 {
target = <&spidev1>;
__overlay__ {
status = "disabled";
};
};
fragment@3 {
target = <&gpio>;
__overlay__ {
pitft_pins: pitft_pins {
brcm,pins = <24 25>;
brcm,function = <0 1>; /* in out */
brcm,pull = <2 0>; /* pullup none */
};
};
};
fragment@4 {
target = <&spi0>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
pitft: pitft@0{
compatible = "ilitek,ili9340";
reg = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pitft_pins>;
spi-max-frequency = <32000000>;
rotate = <90>;
fps = <25>;
bgr;
buswidth = <8>;
dc-gpios = <&gpio 25 0>;
debug = <0>;
};
pitft_ts@1 {
/* needed to avoid dtc warning */
#address-cells = <1>;
#interrupt-cells = <1>;
compatible = "st,stmpe610";
reg = <1>;
spi-max-frequency = <500000>;
interrupts = <24 2>; /* high-to-low edge triggered */
interrupt-parent = <&gpio>;
interrupt-controller;
stmpe_touchscreen: stmpe_touchscreen {
compatible = "st,stmpe-ts";
st,sample-time = <4>;
st,mod-12b = <1>;
st,ref-sel = <0>;
st,adc-freq = <2>;
st,ave-ctrl = <3>;
st,touch-det-delay = <4>;
st,settling = <2>;
st,fraction-z = <7>;
st,i-drive = <0>;
};
stmpe_gpio: stmpe_gpio {
#gpio-cells = <2>;
compatible = "st,stmpe-gpio";
/*
* only GPIO2 is wired/available
* and it is wired to the backlight
*/
st,norequest-mask = <0x7b>;
};
};
};
};
fragment@5 {
target-path = "/soc";
__overlay__ {
backlight {
compatible = "gpio-backlight";
gpios = <&stmpe_gpio 2 0>;
default-on;
};
};
};
__overrides__ {
speed = <&pitft>,"spi-max-frequency:0";
rotate = <&pitft>,"rotate:0", /* fbtft */
<&pitft>,"rotation:0"; /* drm */
fps = <&pitft>,"fps:0";
debug = <&pitft>,"debug:0";
drm = <&pitft>,"compatible=adafruit,yx240qv29";
touch-invx = <&stmpe_touchscreen>,"touchscreen-inverted-x?";
touch-invy = <&stmpe_touchscreen>,"touchscreen-inverted-y?";
touch-swapxy = <&stmpe_touchscreen>,"touchscreen-swapped-x-y?";
};
};

View file

@ -0,0 +1,127 @@
/*
* Device Tree overlay for Adafruit PiTFT 3.5" resistive touch screen
*
*/
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835";
fragment@0 {
target = <&spi0>;
__overlay__ {
status = "okay";
};
};
fragment@1 {
target = <&spidev0>;
__overlay__ {
status = "disabled";
};
};
fragment@2 {
target = <&spidev1>;
__overlay__ {
status = "disabled";
};
};
fragment@3 {
target = <&gpio>;
__overlay__ {
pitft_pins: pitft_pins {
brcm,pins = <24 25>;
brcm,function = <0 1>; /* in out */
brcm,pull = <2 0>; /* pullup none */
};
};
};
fragment@4 {
target = <&spi0>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
pitft: pitft@0{
compatible = "himax,hx8357d";
reg = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pitft_pins>;
spi-max-frequency = <32000000>;
rotate = <90>;
fps = <25>;
bgr;
buswidth = <8>;
dc-gpios = <&gpio 25 0>;
debug = <0>;
};
pitft_ts@1 {
/* needed to avoid dtc warning */
#address-cells = <1>;
#interrupt-cells = <1>;
compatible = "st,stmpe610";
reg = <1>;
spi-max-frequency = <500000>;
interrupts = <24 2>; /* high-to-low edge triggered */
interrupt-parent = <&gpio>;
interrupt-controller;
stmpe_touchscreen: stmpe_touchscreen {
compatible = "st,stmpe-ts";
st,sample-time = <4>;
st,mod-12b = <1>;
st,ref-sel = <0>;
st,adc-freq = <2>;
st,ave-ctrl = <3>;
st,touch-det-delay = <4>;
st,settling = <2>;
st,fraction-z = <7>;
st,i-drive = <0>;
};
stmpe_gpio: stmpe_gpio {
#gpio-cells = <2>;
compatible = "st,stmpe-gpio";
/*
* only GPIO2 is wired/available
* and it is wired to the backlight
*/
st,norequest-mask = <0x7b>;
};
};
};
};
fragment@5 {
target-path = "/soc";
__overlay__ {
backlight: backlight {
compatible = "gpio-backlight";
gpios = <&stmpe_gpio 2 0>;
default-on;
};
};
};
__overrides__ {
speed = <&pitft>,"spi-max-frequency:0";
rotate = <&pitft>,"rotate:0", /* fbtft */
<&pitft>,"rotation:0"; /* drm */
fps = <&pitft>,"fps:0";
debug = <&pitft>,"debug:0";
drm = <&pitft>,"compatible=adafruit,yx350hv15",
<&pitft>,"backlight:0=",<&backlight>;
touch-invx = <&stmpe_touchscreen>,"touchscreen-inverted-x?";
touch-invy = <&stmpe_touchscreen>,"touchscreen-inverted-y?";
touch-swapxy = <&stmpe_touchscreen>,"touchscreen-swapped-x-y?";
};
};

View file

@ -54,7 +54,7 @@
txbuflen = <32768>; txbuflen = <32768>;
buswidth = <8>; buswidth = <8>;
dc-gpios = <&gpio 25 0>; dc-gpios = <&gpio 25 0>;
led-gpios = <&gpio 12 1>; led-gpios = <&gpio 12 0>;
debug = <0>; debug = <0>;
}; };
}; };

View file

@ -43,7 +43,7 @@
#size-cells = <0>; #size-cells = <0>;
pitft: pitft@0{ pitft: pitft@0{
compatible = "sitronix,st7789v"; compatible = "fbtft,minipitft13";
reg = <0>; reg = <0>;
pinctrl-names = "default"; pinctrl-names = "default";
pinctrl-0 = <&pitft_pins>; pinctrl-0 = <&pitft_pins>;
@ -53,12 +53,12 @@
height = <240>; height = <240>;
buswidth = <8>; buswidth = <8>;
dc-gpios = <&gpio 25 0>; dc-gpios = <&gpio 25 0>;
led-gpios = <&gpio 26 1>; led-gpios = <&gpio 26 0>;
debug = <0>; debug = <0>;
}; };
}; };
}; };
fragment@3 { fragment@3 {
target-path = "/"; target-path = "/";
__overlay__ { __overlay__ {

53
overlays/touch-ft6236.dts Normal file
View file

@ -0,0 +1,53 @@
/*
* Device Tree overlay for the Focaltech FT6236 capacitive
* touch screen controller on the Adafruit PiTFT
*
*/
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
fragment@0 {
target = <&gpio>;
__overlay__ {
pitft_pins: pitft_pins {
brcm,pins = <24>;
brcm,function = <0>; /* in out */
brcm,pull = <2>; /* pullup none */
};
};
};
fragment@1 {
target = <&i2c1>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
ft6236: ft6236@38 {
compatible = "focaltech,ft6236";
reg = <0x38>;
pinctrl-names = "default";
pinctrl-0 = <&pitft_pins>;
interrupt-parent = <&gpio>;
interrupts = <24 2>;
touchscreen-size-x = <240>;
touchscreen-size-y = <320>;
};
};
};
__overrides__ {
touch-sizex = <&ft6236>,"touchscreen-size-x?";
touch-sizey = <&ft6236>,"touchscreen-size-y?";
touch-invx = <&ft6236>,"touchscreen-inverted-x?";
touch-invy = <&ft6236>,"touchscreen-inverted-y?";
touch-swapxy = <&ft6236>,"touchscreen-swapped-x-y?";
};
};

81
overlays/touch-stmpe.dts Normal file
View file

@ -0,0 +1,81 @@
/*
* Device Tree overlay for the STMPE resistive
* touch screen controller on the Adafruit PiTFT
*/
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
fragment@0 {
target = <&spi0>;
__overlay__ {
status = "okay";
};
};
fragment@1 {
target = <&spidev1>;
__overlay__ {
status = "disabled";
};
};
fragment@2 {
target = <&gpio>;
__overlay__ {
pitft_pins: pitft_pins {
brcm,pins = <24>;
brcm,function = <0>; /* in out */
brcm,pull = <2>; /* pullup none */
};
};
};
fragment@3 {
target = <&spi0>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
pitft: pitft_ts@1 {
compatible = "st,stmpe610";
reg = <1>;
pinctrl-names = "default";
pinctrl-0 = <&pitft_pins>;
spi-max-frequency = <500000>;
irq-gpio = <&gpio 24 0x2>; /* IRQF_TRIGGER_FALLING */
interrupts = <24 2>; /* high-to-low edge triggered */
interrupt-parent = <&gpio>;
interrupt-controller;
stmpe_touchscreen {
compatible = "st,stmpe-ts";
st,sample-time = <4>;
st,mod-12b = <1>;
st,ref-sel = <0>;
st,adc-freq = <2>;
st,ave-ctrl = <3>;
st,touch-det-delay = <4>;
st,settling = <2>;
st,fraction-z = <7>;
st,i-drive = <0>;
};
stmpe_gpio: stmpe_gpio {
#gpio-cells = <2>;
compatible = "st,stmpe-gpio";
/*
* only GPIO2 is wired/available
* and it is wired to the backlight
*/
st,norequest-mask = <0x7b>;
};
};
};
};
};

BIN
packages/lgpio.zip Normal file

Binary file not shown.

129
pi-touch-cam.py Executable file
View file

@ -0,0 +1,129 @@
"""
Adafruit Pi Touch Cam Setup Script
(C) Adafruit Industries, Creative Commons 3.0 - Attribution Share Alike
Converted to Python by Melissa LeBlanc-Williams for Adafruit Industries
Note: Currently Untested
"""
try:
from adafruit_shell import Shell
except ImportError:
raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell")
import os
shell = Shell()
shell.group="Retrogame"
def main():
shell.clear()
print("""This script will install and/or modify
packages needed for the Adafruit Pi
Camera project. It requires that the
adafruit-pitft.sh installer script (for
PiTFT display support) was run first.
Operations performed include:
- In /boot/firmware/config.txt, enable camera
- apt-get update
- Install Python libraries:
picamera, pygame, PIL
- Downgrade SDL library for pygame
touch compatibility
- Download Dropbox Updater and
Adafruit Pi Cam software
Run time 5+ minutes. Reboot required.
""")
boot_config = shell.get_boot_config()
if not shell.prompt("CONTINUE?", default='n'):
print("Canceled.")
shell.exit()
print("Continuing...")
if shell.grep("dtoverlay=pitft", boot_config):
shell.bail(f"PiTFT overlay not in {boot_config}.\n"
"Download & run adafruit-pitft.py first.\n"
"Canceling.")
print("Configuring camera + PiTFT settings...")
# Set PiTFT speed to 80 MHz, 60 Hz
shell.pattern_replace(boot_config, "speed=.*,fps=.*", "speed=80000000,fps=60")
# Check if Pi camera is enabled. If not, add it...
shell.reconfig(boot_config, "^start_x=.*", "start_x=1")
# gpu_mem must be >= 128 MB for camera to work
result = shell.pattern_search(boot_config, "^gpu_mem=", return_match=True)
if not result:
# gpu_mem isn't set. Add to config
shell.write_text_file(boot_config, "\ngpu_mem=128", append=True)
elif result.group(1) < 128:
# gpu_mem present but too small; increase to 128MB
shell.reconfig(boot_config, "^gpu_mem=.*", "gpu_mem=128")
print("Installing prerequisite packages...")
# Enable Wheezy package sources (for SDL downgrade)
shell.write_text_file("/etc/apt/sources.list.d/wheezy.list", "deb http://archive.raspbian.org/raspbian wheezy main\n", append=True)
# Set 'stable' as default package source (current OS)
shell.write_text_file("/etc/apt/apt.conf.d/10defaultRelease", "APT::Default-release \"stable\";\n", append=True)
# Set priority for libsdl from Wheezy higher than current package
shell.write_text_file("/etc/apt/preferences.d/libsdl", (
"Package: libsdl1.2debian\n"
"Pin: release n=stretch\n"
"Pin-Priority: -10\n"
"Pin: release n=jessie\n"
"Pin-Priority: -10\n"
"Package: libsdl1.2debian\n"
"Pin: release n=wheezy\n"
"Pin-Priority:900\n"
))
# Update the APT package index files, install Python libraries
print("Updating System Packages")
if not shell.run_command("sudo apt-get update"):
shell.bail("Apt failed to update indexes!")
print("Installing packages...")
if not shell.run_command("sudo apt-get -y --force-yes install python-picamera python-pygame python-imaging"):
shell.bail("Apt failed to install software!")
print("Downgrading SDL library...")
if not shell.run_command("apt-get -y --force-yes install libsdl1.2debian/wheezy"):
shell.bail("Apt failed to downgrade SDL library!")
print("Downloading Dropbox uploader and")
print("Adafruit Pi Cam to home directory...")
shell.chdir("~pi")
shell.run_command("wget https://github.com/andreafabrizi/Dropbox-Uploader/archive/master.zip")
shell.run_command("unzip master.zip")
shell.remove("master.zip")
shell.move("Dropbox-Uploader-master", "Dropbox-Uploader")
shell.run_command("wget https://github.com/adafruit/adafruit-pi-cam/archive/master.zip")
shell.run_command("unzip master.zip")
shell.remove("master.zip")
shell.chown("Dropbox-Uploader", "pi", recursive=True)
shell.chown("adafruit-pi-cam-master", "pi", recursive=True)
# Add lines to /etc/rc.local (commented out by default):
shell.pattern_replace("/etc/rc.local", "^exit 0", "# Enable this line to run camera at startup:\n# cd /home/pi/adafruit-pi-cam-master ; sudo python cam.py\n\nexit 0")
# Prompt to reboot!
print("\nCamera and PiTFT settings won't take")
print("effect until next boot.")
shell.prompt_reboot()
# Main function
if __name__ == "__main__":
shell.require_root()
main()

View file

@ -1,18 +1,21 @@
""" """
Adafruit Raspberry Pi Blinka Setup Script Adafruit Raspberry Pi Blinka Setup Script
(C) Adafruit Industries, Creative Commons 3.0 - Attribution Share Alike (C) Adafruit Industries, Creative Commons 3.0 - Attribution Share Alike
Written by Melissa LeBlanc-Williams for Adafruit Industries
""" """
import os
try: try:
from adafruit_shell import Shell from adafruit_shell import Shell
except ImportError: except ImportError:
raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell") raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell")
import os
shell = Shell() shell = Shell()
shell.group="Blinka" shell.group="Blinka"
default_python = 3 default_python = 3
blinka_minimum_python_version = 3.6 blinka_minimum_python_version = 3.8
def default_python_version(numeric=True): def default_python_version(numeric=True):
version = shell.run_command("python -c 'import platform; print(platform.python_version())'", suppress_message=True, return_output=True) version = shell.run_command("python -c 'import platform; print(platform.python_version())'", suppress_message=True, return_output=True)
@ -34,8 +37,14 @@ def check_blinka_python_version():
Check the Python 3 version for Blinka (which may be a later version than we're running this script with) Check the Python 3 version for Blinka (which may be a later version than we're running this script with)
""" """
print("Making sure the required version of Python is installed") print("Making sure the required version of Python is installed")
if get_python3_version() < blinka_minimum_python_version: current = get_python3_version(False)
shell.bail("Blinka requires a minimum of Python version {} to install. Please update your OS!".format(blinka_minimum_python_version)) current_major, current_minor = current.split(".")[0:2]
required_major, required_minor = str(blinka_minimum_python_version).split(".")[0:2]
if int(current_major) >= int(required_major) and int(current_minor) >= int(required_minor):
return
shell.bail("Blinka requires a minimum of Python version {} to install, current one is {}. Please update your OS!".format(blinka_minimum_python_version, current))
def sys_update(): def sys_update():
print("Updating System Packages") print("Updating System Packages")
@ -54,7 +63,8 @@ def set_raspiconfig():
print("Enabling SPI") print("Enabling SPI")
shell.run_command("sudo raspi-config nonint do_spi 0") shell.run_command("sudo raspi-config nonint do_spi 0")
print("Enabling Serial") print("Enabling Serial")
shell.run_command("sudo raspi-config nonint do_serial 0") if not shell.run_command("sudo raspi-config nonint do_serial_hw 0", suppress_message=True):
shell.run_command("sudo raspi-config nonint do_serial 0")
print("Enabling SSH") print("Enabling SSH")
shell.run_command("sudo raspi-config nonint do_ssh 0") shell.run_command("sudo raspi-config nonint do_ssh 0")
print("Enabling Camera") print("Enabling Camera")
@ -71,21 +81,59 @@ def update_python():
shell.run_command("sudo update-alternatives --skip-auto --config python") shell.run_command("sudo update-alternatives --skip-auto --config python")
def update_pip(): def update_pip():
print("Making sure PIP is installed") print("Making sure PIP and setuptools is installed")
shell.run_command("sudo apt-get install -y python3-pip") shell.run_command("sudo apt-get install --upgrade -y python3-pip python3-setuptools")
shell.run_command("sudo pip3 install --upgrade setuptools")
def install_blinka(): def install_blinka(user=False):
print("Installing latest version of Blinka locally") print("Installing latest version of Blinka locally")
shell.run_command("sudo apt-get install -y i2c-tools libgpiod-dev") shell.run_command("sudo apt-get install -y i2c-tools libgpiod-dev python3-libgpiod")
shell.run_command("pip3 install --upgrade RPi.GPIO") pip_command = "pip3 install --upgrade"
shell.run_command("pip3 install --upgrade adafruit-blinka") username = None
if user:
username = os.environ["SUDO_USER"]
shell.run_command(f"{pip_command} adafruit-blinka", run_as_user=username)
# Custom function to run additional commands for Pi 5
def check_and_install_for_pi5(pi_model, user=False):
if shell.is_pi5_or_newer():
username = None
if user:
# Username should be used for PIP install commands
username = os.environ["SUDO_USER"]
print("Detected Raspberry Pi 5, applying additional fixes...")
if shell.exists("lg"):
shell.remove("lg")
shell.run_command("sudo apt-get install -y wget swig python3-dev python3-setuptools")
# Temporarily install setuptools to as root for the build process
shell.run_command("sudo pip3 install -U setuptools", run_as_user=username)
shell.run_command("wget https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/raw/refs/heads/main/packages/lgpio.zip")
shell.run_command("unzip lgpio.zip")
if shell.exists("lgpio.zip"):
shell.remove("lgpio.zip")
shell.chdir("lgpio")
shell.run_command("make")
shell.run_command("sudo make install")
# Remove setuptools after the build process is complete
shell.run_command("sudo pip3 uninstall -y setuptools", run_as_user=username)
else:
print(f"Detected {pi_model}, no additional fixes needed.")
def check_user_groups():
# Check if the user has the groups i2c, spi, gpio, input, and video. If the user is not in a group, then they need to be added.
groups = shell.run_command("groups", suppress_message=True, return_output=True).split()
required_groups = ["i2c", "spi", "gpio", "input", "video"]
for group in required_groups:
if group not in groups:
print(f"Adding user to the group: {group}.")
shell.run_command(f"sudo usermod -aG {group} {os.environ['SUDO_USER']}")
def main(): def main():
global default_python global default_python
shell.clear() shell.clear()
# Check Raspberry Pi and Bail # Check Raspberry Pi and Bail
pi_model = shell.get_board_model() pi_model = shell.get_board_model()
if not shell.is_raspberry_pi():
shell.bail("This model of Raspberry Pi is not currently supported by Blinka")
print("""This script configures your print("""This script configures your
Raspberry Pi and installs Blinka Raspberry Pi and installs Blinka
""") """)
@ -104,7 +152,7 @@ Raspberry Pi and installs Blinka
default_python = 0 default_python = 0
if not shell.prompt("Continue?"): if not shell.prompt("Continue?"):
shell.exit() shell.exit()
elif default_python_version() < 3: elif int(default_python_version()) < 3:
shell.warn("WARNING Default System python version is {}. It will be updated to Version 3.".format(default_python_version(False))) shell.warn("WARNING Default System python version is {}. It will be updated to Version 3.".format(default_python_version(False)))
default_python = 2 default_python = 2
if not shell.prompt("Continue?"): if not shell.prompt("Continue?"):
@ -114,7 +162,11 @@ Raspberry Pi and installs Blinka
set_raspiconfig() set_raspiconfig()
update_python() update_python()
update_pip() update_pip()
install_blinka() install_blinka(True)
check_user_groups()
# Check and install any Pi 5 fixes if detected
check_and_install_for_pi5(pi_model, True)
# Done # Done
print("""DONE. print("""DONE.

View file

@ -6,12 +6,11 @@ Adafruit Raspberry Pi SPI Chip Enable Reassignment Script
try: try:
import click import click
except ImportError: except ImportError:
raise RuntimeError("The library 'Click' was not found. To install, try typing: sudo pip3 install Click") raise RuntimeError("The library 'Click' was not found. To install, try typing: sudo pip3 install --upgrade click")
try: try:
from adafruit_shell import Shell from adafruit_shell import Shell
except ImportError: except ImportError:
raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell") raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell")
import os
shell = Shell() shell = Shell()
shell.group="SPI Reassign" shell.group="SPI Reassign"
@ -19,21 +18,37 @@ shell.group="SPI Reassign"
allowed_gpios = (4, 5, 6, 7, 8, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) allowed_gpios = (4, 5, 6, 7, 8, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27)
spi0_default_pins = (8, 7) spi0_default_pins = (8, 7)
DISABLE_GPIO_TEXT = "Disabled"
boot_dir = "/boot/firmware"
if not shell.exists(boot_dir) or not shell.isdir(boot_dir):
boot_dir = "/boot"
""" """
For now this will only ask about SPI0, but we can later add SPI1 For now this will only ask about SPI0, but we can later add SPI1
""" """
def valid_pins(ce0_pin, ce1_pin): def valid_pins(ce0_pin, ce1_pin):
if ce0_pin is None or ce1_pin is None: if ce0_pin is None and ce1_pin is not None:
return False return False
if ce0_pin == ce1_pin: if ce0_pin is not None and ce0_pin == ce1_pin:
return False return False
if int(ce0_pin) not in allowed_gpios: if ce0_pin is not None and int(ce0_pin) not in allowed_gpios:
return False return False
if int(ce1_pin) not in allowed_gpios: if ce1_pin is not None and int(ce1_pin) not in allowed_gpios:
return False return False
return True return True
def convert_option(pin):
if pin == "disabled":
return None
return int(pin)
def valid_options(ce0_option, ce1_option):
if ce0_option is None or ce1_option is None:
return False
return valid_pins(convert_option(ce0_option), convert_option(ce1_option))
def disable_spi(): def disable_spi():
print("Disabling SPI") print("Disabling SPI")
shell.run_command("sudo raspi-config nonint do_spi 1") shell.run_command("sudo raspi-config nonint do_spi 1")
@ -42,23 +57,39 @@ def enable_spi():
print("Enabling SPI") print("Enabling SPI")
shell.run_command("sudo raspi-config nonint do_spi 0") shell.run_command("sudo raspi-config nonint do_spi 0")
def spi_disabled():
return shell.run_command("sudo raspi-config nonint get_spi", suppress_message=True, return_output=True).strip() == "1"
def remove_custom(): def remove_custom():
shell.pattern_replace("/boot/config.txt", 'dtoverlay=spi0-2cs,cs.*?\n', multi_line=True) shell.pattern_replace(f"{boot_dir}/config.txt", 'dtoverlay=spi0-[0-2]cs,cs.*?\n', multi_line=True)
def format_gpio(gpio):
if gpio is None:
return DISABLE_GPIO_TEXT
return f"GPIO {gpio}"
def gpio_options(pool):
options = []
for gpio in pool:
options.append(format_gpio(gpio))
return options
def write_new_custom(ce0_pin, ce1_pin): def write_new_custom(ce0_pin, ce1_pin):
if (ce0_pin, ce1_pin) == spi0_default_pins: if (ce0_pin, ce1_pin) != spi0_default_pins:
enable_spi()
else:
overlay_command = "dtoverlay=spi0-2cs" overlay_command = "dtoverlay=spi0-2cs"
if ce0_pin != spi0_default_pins[0]: if ce0_pin is None and ce1_pin is None:
overlay_command = "dtoverlay=spi0-0cs"
elif ce1_pin is None:
overlay_command = "dtoverlay=spi0-1cs"
if ce0_pin != spi0_default_pins[0] and ce0_pin is not None:
overlay_command += ",cs0_pin={}".format(ce0_pin) overlay_command += ",cs0_pin={}".format(ce0_pin)
if ce1_pin != spi0_default_pins[1]: if ce1_pin != spi0_default_pins[1] and ce1_pin is not None:
overlay_command += ",cs1_pin={}".format(ce1_pin) overlay_command += ",cs1_pin={}".format(ce1_pin)
shell.write_text_file("/boot/config.txt", overlay_command + "\n") shell.write_text_file(f"{boot_dir}/config.txt", overlay_command + "\n")
@click.command() @click.command()
@click.option('--ce0', nargs=1, default=None, help="Specify a GPIO for CE0") @click.option('--ce0', nargs=1, default=None, help="Specify a GPIO for CE0 or 'disabled' to disable", type=str)
@click.option('--ce1', nargs=1, default=None, help="Specify a GPIO for CE1") @click.option('--ce1', nargs=1, default=None, help="Specify a GPIO for CE1 or 'disabled' to disable", type=str)
@click.option('--reboot', nargs=1, default=None, type=click.Choice(['yes', 'no']), help="Specify whether to reboot after the script is finished") @click.option('--reboot', nargs=1, default=None, type=click.Choice(['yes', 'no']), help="Specify whether to reboot after the script is finished")
def main(ce0, ce1, reboot): def main(ce0, ce1, reboot):
ask_reboot = True ask_reboot = True
@ -66,9 +97,10 @@ def main(ce0, ce1, reboot):
if reboot is not None: if reboot is not None:
ask_reboot = False ask_reboot = False
auto_reboot = reboot.lower() == 'yes' auto_reboot = reboot.lower() == 'yes'
if valid_pins(ce0, ce1): if valid_options(ce0, ce1):
ce0 = convert_option(ce0)
ce1 = convert_option(ce1)
remove_custom() remove_custom()
disable_spi()
write_new_custom(ce0, ce1) write_new_custom(ce0, ce1)
if auto_reboot: if auto_reboot:
shell.reboot() shell.reboot()
@ -87,6 +119,16 @@ lines doesn't interfere with CircuitPython.
Run time of < 1 minute. Reboot required for Run time of < 1 minute. Reboot required for
changes to take effect! changes to take effect!
""") """)
menu_options = [
"Reassign SPI Chip Enable Pins",
"Reset to Defaults Pins",
"Disable SPI",
"Exit",
]
if spi_disabled():
menu_options[2] = "Enable SPI"
shell.info("{} detected.\n".format(pi_model)) shell.info("{} detected.\n".format(pi_model))
if not shell.is_raspberry_pi(): if not shell.is_raspberry_pi():
shell.bail("Non-Raspberry Pi board detected. This must be run on a Raspberry Pi") shell.bail("Non-Raspberry Pi board detected. This must be run on a Raspberry Pi")
@ -94,37 +136,39 @@ changes to take effect!
if os_identifier != "Raspbian": if os_identifier != "Raspbian":
shell.bail("Sorry, the OS detected was {}. This script currently only runs on Raspberry Pi OS.".format(os_identifier)) shell.bail("Sorry, the OS detected was {}. This script currently only runs on Raspberry Pi OS.".format(os_identifier))
menu_selection = shell.select_n( menu_selection = shell.select_n(
"Select an option:", ( "Select an option:", menu_options
"Reassign SPI Chip Enable Pins",
"Reset to Defaults Pins",
"Disable SPI",
"Exit",
)
) )
if menu_selection == 1: if menu_selection == 1:
while True: while True:
# Reassign # Reassign
gpio_pool = list(allowed_gpios) gpio_pool = list(allowed_gpios)
gpio_pool.append(None)
# Ask for pin for CE0 # Ask for pin for CE0
ce0_selection = shell.select_n("Select a new GPIO for CE0", ["GPIO {}".format(x) for x in gpio_pool]) ce0_selection = shell.select_n("Select a new GPIO for CE0", gpio_options(gpio_pool))
ce0_pin = gpio_pool[ce0_selection - 1] ce0_pin = gpio_pool[ce0_selection - 1]
gpio_pool.remove(ce0_pin) if ce0_pin is not None:
# Ask for pin for CE1 gpio_pool.remove(ce0_pin)
ce1_selection = shell.select_n("Select a new GPIO for CE1", ["GPIO {}".format(x) for x in gpio_pool]) # Ask for pin for CE1
ce1_pin = gpio_pool[ce1_selection - 1] ce1_selection = shell.select_n("Select a new GPIO for CE1", gpio_options(gpio_pool))
if shell.prompt("The new GPIO {} for CE0 and GPIO {} for CE1. Is this correct?".format(ce0_pin, ce1_pin)): ce1_pin = gpio_pool[ce1_selection - 1]
else:
ce1_pin = None
if shell.prompt(f"The new settings will be {format_gpio(ce0_pin)} for CE0 and {format_gpio(ce1_pin)} for CE1. Is this correct?"):
break break
remove_custom() remove_custom()
disable_spi()
write_new_custom(ce0_pin, ce1_pin) write_new_custom(ce0_pin, ce1_pin)
if spi_disabled():
enable_spi()
elif menu_selection == 2: elif menu_selection == 2:
# Reset to Defaults # Reset to Defaults
remove_custom() remove_custom()
enable_spi()
elif menu_selection == 3: elif menu_selection == 3:
# Disable # Enable/Disable SPI
remove_custom() if spi_disabled():
disable_spi() enable_spi()
else:
disable_spi()
remove_custom()
elif menu_selection == 4: elif menu_selection == 4:
# Exit # Exit
shell.exit(0) shell.exit(0)

98
retrogame.py Executable file
View file

@ -0,0 +1,98 @@
"""
Adafruit Retrogame Setup Script
(C) Adafruit Industries, Creative Commons 3.0 - Attribution Share Alike
Converted to Python by Melissa LeBlanc-Williams for Adafruit Industries
Note: Currently Untested
"""
try:
from adafruit_shell import Shell
except ImportError:
raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell")
import os
shell = Shell()
shell.group="Retrogame"
def main():
shell.clear()
print("""This script downloads and installs
retrogame, a GPIO-to-keypress utility
for adding buttons and joysticks, plus
one of several configuration files.
Run time <1 minute. Reboot recommended.
""")
# Grouped by config name and menu label
config = {
"pigrrl2": "PiGRRL 2 controls",
"pocket": "Pocket PiGRRL",
"zero": "PiGRRL Zero",
"super": "Super Game Pi",
"2button": "Two buttons + joystick",
"6button": "Six buttons + joystick",
"bonnet": "Adafruit Arcade Bonnet",
"cupcade-orig": "Cupcade (gen 1 & 2 only)"
}
RETROGAME_SELECT = shell.select_n(
"Select configuration:", list(config.values()) + ["Quit without installing"]
)
if RETROGAME_SELECT <= len(config):
CONFIG_NAME = list(config.keys())[RETROGAME_SELECT-1]
if shell.exists("/boot/retrogame.cfg"):
print("/boot/retrogame.cfg already exists.\n"
"Continuing will overwrite file.\n")
if not shell.prompt("CONTINUE?", default='n'):
print("Canceled.")
shell.exit()
print("Downloading, installing retrogame...", end="")
# Download to tmpfile because might already be running
if shell.run_command("curl -f -s -o /tmp/retrogame https://raw.githubusercontent.com/adafruit/Adafruit-Retrogame/master/retrogame"):
shell.move("/tmp/retrogame", "/usr/local/bin/")
os.chmod("/usr/local/bin/retrogame", 0o755)
print("OK")
else:
print("ERROR")
print("Downloading, installing retrogame.cfg...", end="")
if shell.run_command(f"curl -f -s -o /boot/retrogame.cfg https://raw.githubusercontent.com/adafruit/Adafruit-Retrogame/master/configs/retrogame.cfg.{CONFIG_NAME}"):
print("OK")
else:
print("ERROR")
print("Performing other system configuration...", end="")
# Add udev rule (will overwrite if present)
shell.write_text_file("/etc/udev/rules.d/10-retrogame.rules", (
r"SUBSYSTEM==\"input\", ATTRS{name}==\"retrogame\", "
r"ENV{ID_INPUT_KEYBOARD}=\"1\""
))
if CONFIG_NAME == "bonnet":
# If Bonnet, make sure I2C is enabled. Call the I2C
# setup function in raspi-config (noninteractive):
shell.run_command("raspi-config nonint do_i2c 0")
# Start on boot
if shell.run_command("grep retrogame /etc/rc.local", suppress_message=True):
# retrogame already in rc.local, but make sure correct:
shell.pattern_replace("/etc/rc.local", "^.*retrogame.*$", "/usr/local/bin/retrogame &")
else:
# Insert retrogame into rc.local before final 'exit 0'
shell.pattern_replace("/etc/rc.local", "^exit 0", "/usr/local/bin/retrogame &\nexit 0")
print("OK")
shell.prompt_reboot()
print("Done")
# Main function
if __name__ == "__main__":
shell.require_root()
main()

View file

@ -7,9 +7,11 @@
# we reference a specific commit (update this as needed): # we reference a specific commit (update this as needed):
GITUSER=https://github.com/hzeller GITUSER=https://github.com/hzeller
REPO=rpi-rgb-led-matrix REPO=rpi-rgb-led-matrix
COMMIT=45d3ab5d6cff6e0c14da58930d662822627471fc COMMIT=7a503494378a67f3baa4ac680cecbae2703cc58f
# Previously: COMMIT=a3eea997a9254b83ab2de97ae80d83588f696387
# Previously: COMMIT=45d3ab5d6cff6e0c14da58930d662822627471fc
# Previously: COMMIT=21410d2b0bac006b4a1661594926af347b3ce334 # Previously: COMMIT=21410d2b0bac006b4a1661594926af347b3ce334
# Previously: COMMIT=e3dd56dcc0408862f39cccc47c1d9dea1b0fb2d2 # Previously: COMMIT=e3dd56dcc0408862f39cccc47c1d9dea1b0fb2d2
if [ $(id -u) -ne 0 ]; then if [ $(id -u) -ne 0 ]; then
echo "Installer must be run as root." echo "Installer must be run as root."
@ -17,8 +19,13 @@ if [ $(id -u) -ne 0 ]; then
exit 1 exit 1
fi fi
HAS_PYTHON2=$( [ ! $(which python2) ] ; echo $?) HAS_PYTHON2=$(which python2)
HAS_PYTHON3=$( [ ! $(which python3) ] ; echo $?) HAS_PYTHON3=$(which python3)
if [ $HAS_PYTHON2 ] && ! [ $HAS_PYTHON3 ]; then
"Python 2 not supported. Must use Python 3."
exit 0
fi
clear clear
@ -32,10 +39,10 @@ echo "- Configure boot options"
echo "Run time ~15 minutes. Some options require reboot." echo "Run time ~15 minutes. Some options require reboot."
echo "EXISTING INSTALLATION, IF ANY, WILL BE OVERWRITTEN." echo "EXISTING INSTALLATION, IF ANY, WILL BE OVERWRITTEN."
echo echo
echo -n "CONTINUE? [y/N] " echo -n "CONTINUE? [y/n] "
read read
if [[ ! "$REPLY" =~ ^(yes|y|Y)$ ]]; then if [[ ! "$REPLY" =~ ^(yes|y|Y)$ ]]; then
echo "Canceled." echo "Canceled. "
exit 0 exit 0
fi fi
@ -83,7 +90,7 @@ INTERFACES=( \
) )
QUALITY_OPTS=( \ QUALITY_OPTS=( \
"Quality (disables sound, requires soldering)" \ "Quality (disables sound, requires soldering on single matrix Bonnet/HAT)" \
"Convenience (sound on, no soldering)" \ "Convenience (sound on, no soldering)" \
) )
@ -115,7 +122,7 @@ INTERFACE_TYPE=$?
if [ $INTERFACE_TYPE -eq 1 ]; then if [ $INTERFACE_TYPE -eq 1 ]; then
# For matrix HAT, ask about RTC install # For matrix HAT, ask about RTC install
echo echo
echo -n "Install realtime clock support? [y/N] " echo -n "Install realtime clock support? [y/n] "
read read
if [[ "$REPLY" =~ (yes|y|Y)$ ]]; then if [[ "$REPLY" =~ (yes|y|Y)$ ]]; then
INSTALL_RTC=1 INSTALL_RTC=1
@ -147,11 +154,14 @@ echo "Now you must choose between QUALITY and CONVENIENCE."
echo echo
echo "QUALITY: best output from the LED matrix requires" echo "QUALITY: best output from the LED matrix requires"
echo "commandeering hardware normally used for sound, plus" echo "commandeering hardware normally used for sound, plus"
echo "some soldering. If you choose this option, there will" echo "some soldering on the single matrix Bonnet/HAT. If"
echo "you choose this option, there will"
echo "be NO sound from the audio jack or HDMI (USB audio" echo "be NO sound from the audio jack or HDMI (USB audio"
echo "adapters will work and sound best anyway), AND you" echo "adapters will work and sound best anyway), AND you"
echo "must SOLDER a wire between GPIO4 and GPIO18 on the" echo "must SOLDER a wire between GPIO4 and GPIO18 on the"
echo "Bonnet or HAT board." echo "single matrix Bonnet or HAT board. For the Triple LED"
echo "Matrix Bonnet choose QUALITY, and No soldering is"
echo "required."
echo echo
echo "CONVENIENCE: sound works normally, no extra soldering." echo "CONVENIENCE: sound works normally, no extra soldering."
echo "Images on the LED matrix are not quite as steady, but" echo "Images on the LED matrix are not quite as steady, but"
@ -178,10 +188,10 @@ if [ $QUALITY_MOD -eq 0 ]; then
echo "and GPIO18, and internal sound is DISABLED!" echo "and GPIO18, and internal sound is DISABLED!"
fi fi
echo echo
echo -n "CONTINUE? [y/N] " echo -n "CONTINUE? [y/n] "
read read
if [[ ! "$REPLY" =~ ^(yes|y|Y)$ ]]; then if [[ ! "$REPLY" =~ ^(yes|y|Y)$ ]]; then
echo "Canceled." echo "Canceled. "
exit 0 exit 0
fi fi
@ -208,12 +218,7 @@ echo "Updating package index files..."
apt-get update apt-get update
echo "Downloading prerequisites..." echo "Downloading prerequisites..."
if [ $HAS_PYTHON2 ]; then apt-get install -y python3-dev python3-pillow cython3
apt-get install -y --force-yes python2.7-dev python-pillow
fi
if [ $HAS_PYTHON3 ]; then
apt-get install -y --force-yes python3-dev python3-pillow
fi
echo "Downloading RGB matrix software..." echo "Downloading RGB matrix software..."
curl -L $GITUSER/$REPO/archive/$COMMIT.zip -o $REPO-$COMMIT.zip curl -L $GITUSER/$REPO/archive/$COMMIT.zip -o $REPO-$COMMIT.zip
@ -223,37 +228,12 @@ mv $REPO-$COMMIT rpi-rgb-led-matrix
echo "Building RGB matrix software..." echo "Building RGB matrix software..."
cd rpi-rgb-led-matrix cd rpi-rgb-led-matrix
USER_DEFINES="" USER_DEFINES=""
#if [ $SLOWDOWN_GPIO -lt 5 ]; then if [ $QUALITY_MOD -eq 1 ]; then
# USER_DEFINES+=" -DRGB_SLOWDOWN_GPIO=$SLOWDOWN_GPIO"
#fi
#if [ $MATRIX_SIZE --lt 3 ]; then
# USER_DEFINES+=" -DLED_COLS=${MATRIX_WIDTHS[$MATRIX_SIZE]}"
# USER_DEFINES+=" -DLED_ROWS=${MATRIX_HEIGHTS[$MATRIX_SIZE]}"
#fi
if [ $QUALITY_MOD -eq 0 ]; then
if [ $HAS_PYTHON2 ]; then
# Build and install for Python 2.7...
make clean
make install-python HARDWARE_DESC=adafruit-hat-pwm USER_DEFINES="$USER_DEFINES" PYTHON=$(which python2)
fi
if [ $HAS_PYTHON3 ]; then
# Do over for Python 3...
make clean
make install-python HARDWARE_DESC=adafruit-hat-pwm USER_DEFINES="$USER_DEFINES" PYTHON=$(which python3)
fi
else
USER_DEFINES+=" -DDISABLE_HARDWARE_PULSES" USER_DEFINES+=" -DDISABLE_HARDWARE_PULSES"
if [ $HAS_PYTHON2 ]; then
# Build then install for Python 2.7...
make clean
make install-python HARDWARE_DESC=adafruit-hat USER_DEFINES="$USER_DEFINES" PYTHON=$(which python2)
fi
if [ $HAS_PYTHON3 ]; then
# Do over for Python 3...
make clean
make install-python HARDWARE_DESC=adafruit-hat USER_DEFINES="$USER_DEFINES" PYTHON=$(which python3)
fi
fi fi
make clean
make build-python USER_DEFINES="$USER_DEFINES"
# Change ownership to user calling sudo # Change ownership to user calling sudo
chown -R $SUDO_USER:$(id -g $SUDO_USER) `pwd` chown -R $SUDO_USER:$(id -g $SUDO_USER) `pwd`
@ -266,19 +246,18 @@ if [ $INSTALL_RTC -ne 0 ]; then
# Enable I2C for RTC # Enable I2C for RTC
raspi-config nonint do_i2c 0 raspi-config nonint do_i2c 0
# Do additional RTC setup for DS1307 # Do additional RTC setup for DS1307
reconfig /boot/config.txt "^.*dtoverlay=i2c-rtc.*$" "dtoverlay=i2c-rtc,ds1307" reconfig /boot/firmware/config.txt "^.*dtoverlay=i2c-rtc.*$" "dtoverlay=i2c-rtc,ds1307"
apt-get -y remove fake-hwclock apt-get -y remove fake-hwclock
update-rc.d -f fake-hwclock remove update-rc.d -f fake-hwclock remove
sudo sed --in-place '/if \[ -e \/run\/systemd\/system \] ; then/,+2 s/^#*/#/' /lib/udev/hwclock-set sed --in-place '/if \[ -e \/run\/systemd\/system \] ; then/,+2 s/^#*/#/' /lib/udev/hwclock-set
fi fi
if [ $QUALITY_MOD -eq 0 ]; then if [ $QUALITY_MOD -eq 0 ]; then
# Disable sound ('easy way' -- kernel module not blacklisted) # Disable sound via blacklist
reconfig /boot/config.txt "^.*dtparam=audio.*$" "dtparam=audio=off" echo "blacklist snd_bcm2835" > /etc/modprobe.d/blacklist-rgb-matrix.conf
else else
# Enable sound (ditto) # Remove from blacklist
reconfig /boot/config.txt "^.*dtparam=audio.*$" "dtparam=audio=on" rm -f /etc/modprobe.d/blacklist-rgb-matrix.conf
fi fi
# PROMPT FOR REBOOT -------------------------------------------------------- # PROMPT FOR REBOOT --------------------------------------------------------
@ -289,14 +268,15 @@ echo "Settings take effect on next boot."
if [ $INSTALL_RTC -ne 0 ]; then if [ $INSTALL_RTC -ne 0 ]; then
echo "RTC will be enabled then but time must be set" echo "RTC will be enabled then but time must be set"
echo "up using the 'date' and 'hwclock' commands." echo "up using the 'date' and 'hwclock' commands."
echo "ref: https://learn.adafruit.com/adding-a-real-time-clock-to-raspberry-pi/set-rtc-time#sync-time-from-pi-to-rtc"
fi fi
echo echo
echo -n "REBOOT NOW? [y/N] " echo -n "REBOOT NOW? [y/n] "
read read
if [[ ! "$REPLY" =~ ^(yes|y|Y)$ ]]; then if [[ ! "$REPLY" =~ ^(yes|y|Y)$ ]]; then
echo "Exiting without reboot." echo "Exiting without reboot."
exit 0 exit 0
fi fi
echo "Reboot started..." echo "Reboot process started..."
reboot reboot
sleep infinity sleep infinity

View file

@ -1,13 +1,14 @@
""" """
Adafruit Raspberry Pi Script to Pin a specific version of the rpi kernel and firmware Adafruit Raspberry Pi Script to Pin a specific version of the rpi kernel and firmware
(C) Adafruit Industries, Creative Commons 3.0 - Attribution Share Alike (C) Adafruit Industries, Creative Commons 3.0 - Attribution Share Alike
Converted to Python by Melissa LeBlanc-Williams for Adafruit Industries
""" """
try: try:
from adafruit_shell import Shell from adafruit_shell import Shell
except ImportError: except ImportError:
raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell") raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell")
import os
shell = Shell() shell = Shell()
shell.group = 'PINNING' shell.group = 'PINNING'
@ -39,19 +40,18 @@ def main():
] ]
new_packages = [] new_packages = []
for package in packagelist: for package in packagelist:
filename = "{}_{}_armhf.deb".format(package, version) filename = f"{package}_{version}_armhf.deb"
new_packages.append(filename) new_packages.append(filename)
shell.run_command("wget --continue -O {} {}".format(filename, base + filename)) shell.run_command("wget --continue -O {} {}".format(filename, base + filename))
shell.run_command("dpkg -i " + " ".join(new_packages)) shell.run_command("dpkg -i " + " ".join(new_packages))
for package in packagelist: for package in packagelist:
write_text_file("/etc/apt/preferences.d/99-adafruit-pin-kernel", shell.write_text_file("/etc/apt/preferences.d/99-adafruit-pin-kernel", (
"""Package: {} f"Package: {package}\n"
Pin: version {} f"Pin: version {version}\n"
Pin-Priority:999 f"Pin-Priority:999\n\n"
))
""".format(package, version))
shell.prompt_reboot() shell.prompt_reboot()
# Main function # Main function

163
rtc.py Executable file
View file

@ -0,0 +1,163 @@
"""
Adafruit Raspberry Pi Real Time Clock Setup Script
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
This script is licensed under the terms of the MIT license.
Unless otherwise noted, code reproduced herein
was written for this script.
Originally written by the - The Pimoroni Crew -
Converted to Python by Melissa LeBlanc-Williams for Adafruit Industries
Note: Currently Untested
"""
try:
from adafruit_shell import Shell
except ImportError:
raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell")
shell = Shell()
productname = "Real Time Clock module" # the name of the product to install
rtcsubtype = "ds1307"
baseurl = "http://www.adafru.it"
scriptname = "rtc.py" # the name of this script
spacereq = 1 # minimum size required on root partition in MB
debugmode = False # whether the script should use debug routines
debuguser = None # optional test git user to use in debug mode
debugpoint = None # optional git repo branch or tag to checkout
forcesudo = True # whether the script requires to be ran with root privileges
promptreboot = False # whether the script should always prompt user to reboot
customcmd = True # whether to execute commands specified before exit
i2creq = True # whether the i2c interface is required
i2sreq = False # whether the i2s interface is required
spireq = False # whether the spi interface is required
uartreq = False # whether uart communication is required
armhfonly = True # whether the script is allowed to run on other arch
armv6 = True # whether armv6 processors are supported
armv7 = True # whether armv7 processors are supported
armv8 = True # whether armv8 processors are supported
raspbianonly = True # whether the script is allowed to run on other OSes
macosxsupport = False # whether Mac OS X is supported by the script
osreleases = ( "Raspbian" ) # list os-releases supported
oswarning = ( "Debian", "Ubuntu", "Mate" ) # list experimental os-releases
squeezesupport = False # whether Squeeze is supported
wheezysupport = False # whether Wheezy is supported
jessiesupport = True # whether Jessie is supported
DEVICE_TREE = True
ASK_TO_REBOOT = False
CURRENT_SETTING = False
UPDATED_DB = False
BOOTCMD = "/boot/cmdline.txt"
CONFIG = shell.get_boot_config()
APTSRC = "/etc/apt/sources.list"
INITABCONF = "/etc/inittab"
BLACKLIST = "/etc/modprobe.d/raspi-blacklist.conf"
LOADMOD = "/etc/modules"
DTBODIR = "/boot/overlays"
def raspbian_old():
return shell.get_raspbian_version() in ("wheezy", "squeeze")
def dt_check():
# Check if /boot/firmware/config.txt exists and de
return shell.exists(CONFIG) and not shell.pattern_search(CONFIG, "^device_tree=$")
#Perform all global variables declarations as well as function definition
#above this section for clarity, thanks!
def main():
os_release = shell.get_raspbian_version()
IS_SUPPORTED = os_release in osreleases
IS_EXPERIMENTAL = os_release in oswarning
if not shell.is_armhf() or shell.is_arm64():
shell.bail("This hardware is not supported, sorry!\n"
"Config files have been left untouched")
if shell.is_raspberry_pi_os():
if not wheezysupport and raspbian_old():
shell.bail(
"\n--- Warning ---\n"
f"The {productname} installer\n"
"does not work on this version of Raspbian.\n"
r"Check https://github.com/{gitusername}/{gitreponame}"
"\nfor additional information and support")
elif raspbianonly:
shell.bail("This script is intended for Raspbian on a Raspberry Pi!")
else:
if not IS_SUPPORTED and not IS_EXPERIMENTAL:
shell.bail(
"Your operating system is not supported, sorry!\n"
"Config files have been left untouched")
if forcesudo:
shell.require_root()
print(f"\nThis script will install everything needed to use {productname}\n")
shell.warn(
"--- Warning ---\n"
"Always be careful when running scripts and commands\n"
"copied from the internet. Ensure they are from a\n"
"trusted source.\n"
"\n"
"If you want to see what this script does before\n"
"running it, you should run:\n"
" \curl -sS $baseurl/$scriptname\n"
"\n"
)
if shell.prompt("Do you wish to continue?", force_arg="y", default="n"):
print("\nChecking hardware requirements...")
if i2creq == "yes":
print()
if shell.prompt("Hardware requires I2C, enable now?", force_arg="y", default="n"):
shell.run_command("sudo raspi-config nonint do_i2c 0")
if not dt_check():
shell.bail(
"Device Tree support required!\n"
"Config files have been left untouched\n"
)
rtc_values = ("ds1307", "ds3231", "pcf8523")
rtcsubtype = rtc_values[shell.select_n("What RTC would you like to install?", rtc_values) - 1]
print("Disabling any current RTC")
shell.run_command(f"sudo sed --in-place '/dtoverlay[[:space:]]*=[[:space:]]*i2c-rtc/d' {CONFIG}")
print(f"Adding DT overlay for {rtcsubtype}")
shell.write_text_file(CONFIG, f"dtoverlay=i2c-rtc,{rtcsubtype}", append=True)
print("Removing fake-hwclock")
shell.run_command("sudo apt-get -y remove fake-hwclock")
shell.run_command("sudo update-rc.d -f fake-hwclock remove")
if not shell.exists("/lib/udev/hwclock-set"):
shell.bail("Couldn't find /lib/udev/hwclock-set")
shell.warn("Configuring HW Clock")
shell.run_command("sudo sed --in-place '/if \[ -e \/run\/systemd\/system \] ; then/,+2 s/^#*/#/' /lib/udev/hwclock-set")
shell.prompt_reboot()
else:
shell.warn("\nAborting...")
# Main function
if __name__ == "__main__":
main()

View file

@ -7,9 +7,13 @@
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/interrupt.h>
#include <linux/completion.h>
#include <linux/module.h> #include <linux/module.h>
#include <video/mipi_display.h> #include <video/mipi_display.h>
#include "fbtft.h" #include "fbtft.h"
@ -66,13 +70,68 @@ enum st7789v_command {
#define MADCTL_MX BIT(6) /* bitmask for column address order */ #define MADCTL_MX BIT(6) /* bitmask for column address order */
#define MADCTL_MY BIT(7) /* bitmask for page address order */ #define MADCTL_MY BIT(7) /* bitmask for page address order */
static u32 col1_offset = 0; /* 60Hz for 16.6ms, configured as 2*16.6ms */
static u32 col2_offset = 0; #define PANEL_TE_TIMEOUT_MS 33
static u32 row1_offset = 0;
static u32 row2_offset = 0; static struct completion panel_te; /* completion for panel TE line */
static int irq_te; /* Linux IRQ for LCD TE line */
static u32 col_start_offset = 0;
static u32 col_end_offset = 0;
static u32 row_start_offset = 0;
static u32 row_end_offset = 0;
static short x_offset = 0; static short x_offset = 0;
static short y_offset = 0; static short y_offset = 0;
static irqreturn_t panel_te_handler(int irq, void *data)
{
complete(&panel_te);
return IRQ_HANDLED;
}
/*
* init_tearing_effect_line() - init tearing effect line.
* @par: FBTFT parameter object.
*
* Return: 0 on success, or a negative error code otherwise.
*/
static int init_tearing_effect_line(struct fbtft_par *par)
{
struct device *dev = par->info->device;
struct gpio_desc *te;
int rc, irq;
te = gpiod_get_optional(dev, "te", GPIOD_IN);
if (IS_ERR(te))
return dev_err_probe(dev, PTR_ERR(te), "Failed to request te GPIO\n");
/* if te is NULL, indicating no configuration, directly return success */
if (!te) {
irq_te = 0;
return 0;
}
irq = gpiod_to_irq(te);
/* GPIO is locked as an IRQ, we may drop the reference */
gpiod_put(te);
if (irq < 0)
return irq;
irq_te = irq;
init_completion(&panel_te);
/* The effective state is high and lasts no more than 1000 microseconds */
rc = devm_request_irq(dev, irq_te, panel_te_handler,
IRQF_TRIGGER_RISING, "TE_GPIO", par);
if (rc)
return dev_err_probe(dev, rc, "TE IRQ request failed.\n");
disable_irq_nosync(irq_te);
return 0;
}
/** /**
* init_display() - initialize the display controller * init_display() - initialize the display controller
* *
@ -89,6 +148,14 @@ static short y_offset = 0;
*/ */
static int init_display(struct fbtft_par *par) static int init_display(struct fbtft_par *par)
{ {
int rc;
par->fbtftops.reset(par);
rc = init_tearing_effect_line(par);
if (rc)
return rc;
/* turn off sleep mode */ /* turn off sleep mode */
write_reg(par, MIPI_DCS_EXIT_SLEEP_MODE); write_reg(par, MIPI_DCS_EXIT_SLEEP_MODE);
mdelay(120); mdelay(120);
@ -144,6 +211,10 @@ static int init_display(struct fbtft_par *par)
*/ */
write_reg(par, PWCTRL1, 0xA4, 0xA1); write_reg(par, PWCTRL1, 0xA4, 0xA1);
/* TE line output is off by default when powering on */
if (irq_te)
write_reg(par, MIPI_DCS_SET_TEAR_ON, 0x00);
write_reg(par, MIPI_DCS_SET_DISPLAY_ON); write_reg(par, MIPI_DCS_SET_DISPLAY_ON);
if (HSD20_IPS) if (HSD20_IPS)
@ -152,7 +223,51 @@ static int init_display(struct fbtft_par *par)
return 0; return 0;
} }
static void minipitft_set_addr_win(struct fbtft_par *par, int xs, int ys, /*
* write_vmem() - write data to display.
* @par: FBTFT parameter object.
* @offset: offset from screen_buffer.
* @len: the length of data to be writte.
*
* Return: 0 on success, or a negative error code otherwise.
*/
static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
{
struct device *dev = par->info->device;
int ret;
if (irq_te) {
enable_irq(irq_te);
reinit_completion(&panel_te);
ret = wait_for_completion_timeout(&panel_te,
msecs_to_jiffies(PANEL_TE_TIMEOUT_MS));
if (ret == 0)
dev_err(dev, "wait panel TE timeout\n");
disable_irq(irq_te);
}
switch (par->pdata->display.buswidth) {
case 8:
ret = fbtft_write_vmem16_bus8(par, offset, len);
break;
case 9:
ret = fbtft_write_vmem16_bus9(par, offset, len);
break;
case 16:
ret = fbtft_write_vmem16_bus16(par, offset, len);
break;
default:
dev_err(dev, "Unsupported buswidth %d\n",
par->pdata->display.buswidth);
ret = 0;
break;
}
return ret;
}
static void minipitft13_set_addr_win(struct fbtft_par *par, int xs, int ys,
int xe, int ye) int xe, int ye)
{ {
xs += x_offset; xs += x_offset;
@ -185,35 +300,36 @@ static int set_var(struct fbtft_par *par)
madctl_par |= MADCTL_BGR; madctl_par |= MADCTL_BGR;
if (width < 240) { if (width < 240) {
// Display is centered // Smaller displays are centered
row1_offset = row2_offset = (int)((320 - height + 1) / 2); row_start_offset = row_end_offset = (int)((320 - height + 1) / 2);
col1_offset = (int)((240 - width) / 2); col_start_offset = (int)((240 - width) / 2);
col2_offset = (int)((240 - width + 1) / 2); col_end_offset = (int)((240 - width + 1) / 2); // Account for extra pixel
} else { } else {
row1_offset = 0; // Larger displays are left-aligned
row2_offset = (320 - height); row_start_offset = 0;
col1_offset = col2_offset = (240 - width); row_end_offset = (320 - height);
col_start_offset = col_end_offset = 0;
} }
switch (par->info->var.rotate) { switch (par->info->var.rotate) {
case 0: case 0:
x_offset = col1_offset; x_offset = col_start_offset;
y_offset = row1_offset; y_offset = row_start_offset;
break; break;
case 90: case 90:
madctl_par |= (MADCTL_MV | MADCTL_MY); madctl_par |= (MADCTL_MV | MADCTL_MY);
x_offset = row1_offset; x_offset = row_start_offset;
y_offset = col1_offset; y_offset = col_start_offset;
break; break;
case 180: case 180:
madctl_par |= (MADCTL_MX | MADCTL_MY); madctl_par |= (MADCTL_MX | MADCTL_MY);
x_offset = col2_offset; x_offset = col_end_offset;
y_offset = row2_offset; y_offset = row_end_offset;
break; break;
case 270: case 270:
madctl_par |= (MADCTL_MV | MADCTL_MX); madctl_par |= (MADCTL_MV | MADCTL_MX);
x_offset = row2_offset; x_offset = row_end_offset;
y_offset = col2_offset; y_offset = col_end_offset;
break; break;
default: default:
return -EINVAL; return -EINVAL;
@ -304,14 +420,23 @@ static struct fbtft_display display = {
.gamma = HSD20_IPS_GAMMA, .gamma = HSD20_IPS_GAMMA,
.fbtftops = { .fbtftops = {
.init_display = init_display, .init_display = init_display,
.write_vmem = write_vmem,
.set_var = set_var, .set_var = set_var,
.set_gamma = set_gamma, .set_gamma = set_gamma,
.blank = blank, .blank = blank,
.set_addr_win = minipitft_set_addr_win,
}, },
}; };
FBTFT_REGISTER_DRIVER(DRVNAME, "sitronix,st7789v", &display); int variant_minipitft13(struct fbtft_display *display)
{
display->fbtftops.set_addr_win = minipitft13_set_addr_win;
return 0;
}
FBTFT_REGISTER_DRIVER_START(&display)
FBTFT_COMPATIBLE("sitronix,st7789v")
FBTFT_VARIANT_COMPATIBLE("fbtft,minipitft13", variant_minipitft13)
FBTFT_REGISTER_DRIVER_END(DRVNAME, &display);
MODULE_ALIAS("spi:" DRVNAME); MODULE_ALIAS("spi:" DRVNAME);
MODULE_ALIAS("platform:" DRVNAME); MODULE_ALIAS("platform:" DRVNAME);
@ -320,4 +445,4 @@ MODULE_ALIAS("platform:st7789v");
MODULE_DESCRIPTION("FB driver for the ST7789V LCD Controller"); MODULE_DESCRIPTION("FB driver for the ST7789V LCD Controller");
MODULE_AUTHOR("Dennis Menschel"); MODULE_AUTHOR("Dennis Menschel");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");

View file

@ -240,7 +240,7 @@ struct fbtft_par {
int fbtft_write_buf_dc(struct fbtft_par *par, void *buf, size_t len, int dc); int fbtft_write_buf_dc(struct fbtft_par *par, void *buf, size_t len, int dc);
__printf(5, 6) __printf(5, 6)
void fbtft_dbg_hex(const struct device *dev, int groupsize, void fbtft_dbg_hex(const struct device *dev, int groupsize,
void *buf, size_t len, const char *fmt, ...); const void *buf, size_t len, const char *fmt, ...);
struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
struct device *dev, struct device *dev,
struct fbtft_platform_data *pdata); struct fbtft_platform_data *pdata);
@ -253,7 +253,7 @@ int fbtft_init_display(struct fbtft_par *par);
int fbtft_probe_common(struct fbtft_display *display, struct spi_device *sdev, int fbtft_probe_common(struct fbtft_display *display, struct spi_device *sdev,
struct platform_device *pdev, struct platform_device *pdev,
const struct of_device_id *dt_ids); const struct of_device_id *dt_ids);
int fbtft_remove_common(struct device *dev, struct fb_info *info); void fbtft_remove_common(struct device *dev, struct fb_info *info);
/* fbtft-io.c */ /* fbtft-io.c */
int fbtft_write_spi(struct fbtft_par *par, void *buf, size_t len); int fbtft_write_spi(struct fbtft_par *par, void *buf, size_t len);
@ -282,11 +282,11 @@ static int fbtft_driver_probe_spi(struct spi_device *spi) \
return fbtft_probe_common(_display, spi, NULL, dt_ids); \ return fbtft_probe_common(_display, spi, NULL, dt_ids); \
} \ } \
\ \
static int fbtft_driver_remove_spi(struct spi_device *spi) \ static void fbtft_driver_remove_spi(struct spi_device *spi) \
{ \ { \
struct fb_info *info = spi_get_drvdata(spi); \ struct fb_info *info = spi_get_drvdata(spi); \
\ \
return fbtft_remove_common(&spi->dev, info); \ fbtft_remove_common(&spi->dev, info); \
} \ } \
\ \
static int fbtft_driver_probe_pdev(struct platform_device *pdev) \ static int fbtft_driver_probe_pdev(struct platform_device *pdev) \
@ -298,7 +298,8 @@ static int fbtft_driver_remove_pdev(struct platform_device *pdev) \
{ \ { \
struct fb_info *info = platform_get_drvdata(pdev); \ struct fb_info *info = platform_get_drvdata(pdev); \
\ \
return fbtft_remove_common(&pdev->dev, info); \ fbtft_remove_common(&pdev->dev, info); \
return 0; \
} \ } \
\ \
static const struct of_device_id dt_ids[] = { static const struct of_device_id dt_ids[] = {
@ -343,7 +344,10 @@ static int __init fbtft_driver_module_init(void) \
ret = spi_register_driver(&fbtft_driver_spi_driver); \ ret = spi_register_driver(&fbtft_driver_spi_driver); \
if (ret < 0) \ if (ret < 0) \
return ret; \ return ret; \
return platform_driver_register(&fbtft_driver_platform_driver); \ ret = platform_driver_register(&fbtft_driver_platform_driver); \
if (ret < 0) \
spi_unregister_driver(&fbtft_driver_spi_driver); \
return ret; \
} \ } \
\ \
static void __exit fbtft_driver_module_exit(void) \ static void __exit fbtft_driver_module_exit(void) \
@ -355,6 +359,46 @@ static void __exit fbtft_driver_module_exit(void) \
module_init(fbtft_driver_module_init); \ module_init(fbtft_driver_module_init); \
module_exit(fbtft_driver_module_exit); module_exit(fbtft_driver_module_exit);
#define FBTFT_REGISTER_SPI_DRIVER(_name, _comp_vend, _comp_dev, _display) \
\
static const struct of_device_id dt_ids[] = { \
{ .compatible = _comp_vend "," _comp_dev }, \
{}, \
}; \
\
static int fbtft_driver_probe_spi(struct spi_device *spi) \
{ \
return fbtft_probe_common(_display, spi, NULL, dt_ids); \
} \
\
static void fbtft_driver_remove_spi(struct spi_device *spi) \
{ \
struct fb_info *info = spi_get_drvdata(spi); \
\
fbtft_remove_common(&spi->dev, info); \
} \
\
MODULE_DEVICE_TABLE(of, dt_ids); \
\
static const struct spi_device_id spi_ids[] = { \
{ .name = _comp_dev }, \
{}, \
}; \
\
MODULE_DEVICE_TABLE(spi, spi_ids); \
\
static struct spi_driver fbtft_driver_spi_driver = { \
.driver = { \
.name = _name, \
.of_match_table = dt_ids, \
}, \
.id_table = spi_ids, \
.probe = fbtft_driver_probe_spi, \
.remove = fbtft_driver_remove_spi, \
}; \
\
module_spi_driver(fbtft_driver_spi_driver);
#define FBTFT_REGISTER_DRIVER(_name, _compatible, _display) \ #define FBTFT_REGISTER_DRIVER(_name, _compatible, _display) \
FBTFT_REGISTER_DRIVER_START(_display) \ FBTFT_REGISTER_DRIVER_START(_display) \
FBTFT_COMPATIBLE(_compatible) \ FBTFT_COMPATIBLE(_compatible) \
@ -433,4 +477,4 @@ do { \
(num) * sizeof(type), format, ##arg); \ (num) * sizeof(type), format, ##arg); \
} while (0) } while (0)
#endif /* __LINUX_FBTFT_H */ #endif /* __LINUX_FBTFT_H */

14
st7789_module/reload.sh Normal file
View file

@ -0,0 +1,14 @@
#!/bin/bash
# Unload
sudo dtoverlay -r drm-minipitft114
sudo modprobe -r fb_st7789v
sudo modprobe -r fbtft
# Compile
sudo make
# Load again
sudo modprobe fbtft
sudo insmod ./fb_st7789v.ko
sudo dtoverlay drm-minipitft114

View file

@ -0,0 +1,3 @@
# udev rule for Focaltouch Capactive Touchscreen
SUBSYSTEM=="input", ATTRS{name}=="EP0110M09", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"
SUBSYSTEM=="input", ATTRS{name}=="generic ft5x06*", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"

2
templates/95-stmpe.rules Normal file
View file

@ -0,0 +1,2 @@
udev rule for STMPE Resistive Touchscreen Controller
SUBSYSTEM=="input", ATTRS{name}=="*stmpe*", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"

View file

@ -0,0 +1 @@
SUBSYSTEM=="input", ATTRS{name}=="touchmouse", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"

View file

@ -0,0 +1,14 @@
# udev rules for SPI TFT DRM devices to create reliable symlinks
# Supports ili9341, st7789, and other SPI TFT displays
# Rule for ili9341 DRM device (and other SPI TFT displays)
SUBSYSTEM=="drm", KERNEL=="card*", KERNELS=="spi0.0", DRIVERS=="ili9341", SYMLINK+="dri/spitft"
# Generic rule for any SPI TFT display on spi0.0
SUBSYSTEM=="drm", KERNEL=="card*", KERNELS=="spi0.0", SUBSYSTEMS=="spi", SYMLINK+="dri/spitft"
# Rule for st7789 displays (add when needed)
SUBSYSTEM=="drm", KERNEL=="card*", KERNELS=="spi0.0", DRIVERS=="st7789", SYMLINK+="dri/spitft"
# Alternative rule using device path pattern
SUBSYSTEM=="drm", KERNEL=="card*", DEVPATH=="*/spi0/spi0.0/drm/card*", SYMLINK+="dri/spitft"

View file

@ -0,0 +1,5 @@
# udev rule for TSC2007 touchscreen to create /dev/input/touchscreen symlink and apply transformation
SUBSYSTEM=="input", KERNEL=="event*", ATTRS{name}=="TSC2007 Touchscreen", SYMLINK+="input/touchscreen", ENV{LIBINPUT_CALIBRATION_MATRIX}="{calibration_matrix}"
# Backup rule using touchscreen capability and TSC2007 name pattern
SUBSYSTEM=="input", KERNEL=="event*", ENV{ID_INPUT_TOUCHSCREEN}=="1", ATTRS{name}=="*TSC2007*", SYMLINK+="input/touchscreen", ENV{LIBINPUT_CALIBRATION_MATRIX}="{calibration_matrix}"

View file

@ -0,0 +1,25 @@
#!/bin/bash
# Wait for TFT framebuffer to be ready
echo "Waiting for SPI TFT framebuffer..."
# Wait up to 30 seconds for /dev/fb0 or /dev/fb1 to appear
for i in {1..300}; do
for fbdev in 0 1; do
if [ -e /dev/fb$fbdev ]; then
echo "Found /dev/fb$fbdev, checking if it's {display_type}..."
# Check if it's actually the ili9341 device
if dmesg | grep -q "{display_type}.*fb$fbdev"; then
echo "{display_type} framebuffer ready, mapping console..."
con2fbmap 1 $fbdev
echo "Console mapped to framebuffer $fbdev"
exit 0
fi
fi
done
sleep 0.1
done
echo "Timeout waiting for SPI TFT framebuffer"
exit 1

View file

@ -0,0 +1,14 @@
[Unit]
Description=Map console to framebuffer for SPI TFT
After=multi-user.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/con2fbmap-helper.sh
RemainAfterExit=yes
StandardOutput=journal
StandardError=journal
TimeoutStartSec=60
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,8 @@
# --- added by adafruit-pitft-helper {date} ---
[all]
hdmi_force_hotplug=1 # required for cases when HDMI is not plugged in!
dtparam=spi=on
dtparam=i2c1=on
dtparam=i2c_arm=on
{overlay}
# --- end adafruit-pitft-helper {date} ---

11
templates/fbcp.service Normal file
View file

@ -0,0 +1,11 @@
[Unit]
Description=Framebuffer copy utility for PiTFT
After=network.target
[Service]
Type=simple
ExecStartPre=/bin/sleep 10
ExecStart=/usr/local/bin/fbcp
[Install]
WantedBy=multi-user.target

430
voice_bonnet.sh Executable file
View file

@ -0,0 +1,430 @@
#!/bin/bash
: <<'DISCLAIMER'
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
This script is licensed under the terms of the MIT license.
Unless otherwise noted, code reproduced herein
was written for this script.
- The Pimoroni Crew - (modified by Adafruit!)
DISCLAIMER
# script control variables
productname="voice bonnet/BrainCraft HAT" # the name of the product to install
scriptname="voice_bonnet" # the name of this script
spacereq=1 # minimum size required on root partition in MB
debugmode="no" # whether the script should use debug routines
debuguser="none" # optional test git user to use in debug mode
debugpoint="none" # optional git repo branch or tag to checkout
forcesudo="no" # whether the script requires to be ran with root privileges
promptreboot="no" # whether the script should always prompt user to reboot
mininstall="no" # whether the script enforces minimum install routine
customcmd="yes" # whether to execute commands specified before exit
armv6="yes" # whether armv6 processors are supported
armv7="yes" # whether armv7 processors are supported
armv8="yes" # whether armv8 processors are supported
arm64="yes" # whether arm64 processors are supported
raspbianonly="no" # whether the script is allowed to run on other OSes
osreleases=( "Raspbian" ) # list os-releases supported
oswarning=( "Debian" "Kano" "Mate" "PiTop" "Ubuntu" ) # list experimental os-releases
osdeny=( "Darwin" "Kali" ) # list os-releases specifically disallowed
FORCE=$1
DEVICE_TREE=true
ASK_TO_REBOOT=false
CURRENT_SETTING=false
UPDATE_DB=false
BOOTCMD=/boot/firmware/cmdline.txt
CONFIG=/boot/firmware/config.txt
APTSRC=/etc/apt/sources.list
INITABCONF=/etc/inittab
BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf
LOADMOD=/etc/modules
DTBODIR=/boot/overlays
# Fall back to old location
if ! test -f $CONFIG; then
CONFIG=/boot/config.txt
fi
# function define
confirm() {
if [ "$FORCE" == '-y' ]; then
true
else
read -r -p "$1 [y/N] " response < /dev/tty
if [[ $response =~ ^(yes|y|Y)$ ]]; then
true
else
false
fi
fi
}
prompt() {
read -r -p "$1 [y/N] " response < /dev/tty
if [[ $response =~ ^(yes|y|Y)$ ]]; then
true
else
false
fi
}
success() {
echo -e "$(tput setaf 2)$1$(tput sgr0)"
}
inform() {
echo -e "$(tput setaf 6)$1$(tput sgr0)"
}
warning() {
echo -e "$(tput setaf 1)$1$(tput sgr0)"
}
newline() {
echo ""
}
progress() {
count=0
until [ $count -eq $1 ]; do
echo -n "..." && sleep 1
((count++))
done
echo
}
sudocheck() {
if [ $(id -u) -ne 0 ]; then
echo -e "Install must be run as root. Try 'sudo ./$scriptname'\n"
exit 1
fi
}
sysclean() {
sudo apt-get clean && sudo apt-get autoclean
sudo apt-get -y autoremove &> /dev/null
}
sysupdate() {
if ! $UPDATE_DB; then
echo "Updating apt indexes..." && progress 3 &
sudo apt-get update 1> /dev/null || { warning "Apt failed to update indexes!" && exit 1; }
echo "Reading package lists..."
progress 3 && UPDATE_DB=true
fi
}
sysupgrade() {
sudo apt-get upgrade
sudo apt-get clean && sudo apt-get autoclean
sudo apt-get -y autoremove &> /dev/null
}
sysreboot() {
warning "Some changes made to your system require"
warning "your computer to reboot to take effect."
newline
if prompt "Would you like to reboot now?"; then
sync && sudo reboot
fi
}
# Given a filename, a regex pattern to match and a replacement string,
# perform replacement if found, else append replacement to end of file.
# (# $1 = filename, $2 = pattern to match, $3 = replacement)
reconfig() {
grep $2 $1 >/dev/null
if [ $? -eq 0 ]; then
# Pattern found; replace in file
sed -i "s/$2/$3/g" $1 >/dev/null
else
# Not found; append (silently)
echo $3 | sudo tee -a $1 >/dev/null
fi
}
# If /boot/firmware/config.txt exists, make sure /boot/config.txt is a symlink to it
fix_config_symlink() {
if [ -f /boot/firmware/config.txt ]; then
if [ ! -L /boot/config.txt ]; then
warning "/boot/config.txt was overwritten as a file by another script."
if confirm "/boot/config.txt will be moved to /boot/firmware/config.txt and the symlink restored. Do you wish to continue?"; then
sudo mv /boot/config.txt /boot/firmware/config.txt
sudo ln -s /boot/firmware/config.txt /boot/config.txt
fi
fi
fi
}
arch_check() {
IS_ARM64=false
IS_ARMHF=false
IS_ARMv6=false
if uname -m | grep "aarch64" > /dev/null; then
IS_ARM64=true
fi
if uname -m | grep "armv.l" > /dev/null; then
IS_ARMHF=true
if uname -m | grep "armv6l" > /dev/null; then
IS_ARMv6=true
fi
fi
}
os_check() {
IS_RASPBIAN=false
IS_MACOSX=false
IS_SUPPORTED=false
IS_EXPERIMENTAL=false
if [ -f /etc/os-release ]; then
if cat /etc/os-release | grep "Raspbian" > /dev/null; then
IS_RASPBIAN=true && IS_SUPPORTED=true
fi
if command -v apt-get > /dev/null; then
for os in ${osreleases[@]}; do
if cat /etc/os-release | grep $os > /dev/null; then
IS_SUPPORTED=true && IS_EXPERIMENTAL=false
fi
done
for os in ${oswarning[@]}; do
if cat /etc/os-release | grep $os > /dev/null; then
IS_SUPPORTED=false && IS_EXPERIMENTAL=true
fi
done
for os in ${osdeny[@]}; do
if cat /etc/os-release | grep $os > /dev/null; then
IS_SUPPORTED=false && IS_EXPERIMENTAL=false
fi
done
fi
fi
if [ -d ~/.kano-settings ] || [ -d ~/.kanoprofile ]; then
IS_RASPBIAN=false
for os in ${oswarning[@]}; do
if [ $os == "Kano" ]; then
IS_SUPPORTED=false && IS_EXPERIMENTAL=true
fi
done
for os in ${osdeny[@]}; do
if [ $os == "Kano" ]; then
IS_SUPPORTED=false && IS_EXPERIMENTAL=false
fi
done
fi
if [ -f ~/.pt-dashboard-config ] || [ -d ~/.pt-dashboard ] || [ -d ~/.pt-os-dashboard ]; then
IS_RASPBIAN=false
for os in ${oswarning[@]}; do
if [ $os == "PiTop" ]; then
IS_SUPPORTED=false && IS_EXPERIMENTAL=true
fi
done
for os in ${osdeny[@]}; do
if [ $os == "PiTop" ]; then
IS_SUPPORTED=false && IS_EXPERIMENTAL=false
fi
done
fi
if [ -d ~/.config/ubuntu-mate ]; then
for os in ${osdeny[@]}; do
if [ $os == "Mate" ]; then
IS_SUPPORTED=false && IS_EXPERIMENTAL=false
fi
done
fi
if uname -s | grep "Darwin" > /dev/null; then
IS_MACOSX=true
for os in ${osdeny[@]}; do
if [ $os == "Darwin" ]; then
IS_SUPPORTED=false && IS_EXPERIMENTAL=false
fi
done
fi
}
raspbian_check() {
IS_SUPPORTED=false
IS_EXPERIMENTAL=false
if [ -f /etc/os-release ]; then
if cat /etc/os-release | grep "/sid" > /dev/null; then
IS_SUPPORTED=false && IS_EXPERIMENTAL=true
elif cat /etc/os-release | grep "bullseye" > /dev/null; then
IS_SUPPORTED=false && IS_EXPERIMENTAL=true
elif cat /etc/os-release | grep "buster" > /dev/null; then
IS_SUPPORTED=false && IS_EXPERIMENTAL=true
elif cat /etc/os-release | grep "stretch" > /dev/null; then
IS_SUPPORTED=false && IS_EXPERIMENTAL=false
elif cat /etc/os-release | grep "jessie" > /dev/null; then
IS_SUPPORTED=true && IS_EXPERIMENTAL=false
elif cat /etc/os-release | grep "wheezy" > /dev/null; then
IS_SUPPORTED=true && IS_EXPERIMENTAL=false
else
IS_SUPPORTED=false && IS_EXPERIMENTAL=false
fi
fi
}
: <<'MAINSTART'
Perform all global variables declarations as well as function definition
above this section for clarity, thanks!
MAINSTART
# checks and init
arch_check
os_check
if [ $debugmode != "no" ]; then
echo "USER_HOME is $USER_HOME" && newline
echo "IS_RASPBIAN is $IS_RASPBIAN"
echo "IS_MACOSX is $IS_MACOSX"
echo "IS_SUPPORTED is $IS_SUPPORTED"
echo "IS_EXPERIMENTAL is $IS_EXPERIMENTAL"
newline
fi
if ! $IS_ARMHF && ! $IS_ARM64; then
warning "This hardware is not supported, sorry!"
warning "Config files have been left untouched"
newline && exit 1
fi
if $IS_ARM64 && [ $arm64 == "no" ]; then
warning "Sorry, your CPU is not supported by this installer"
newline && exit 1
elif $IS_ARMv8 && [ $armv8 == "no" ]; then
warning "Sorry, your CPU is not supported by this installer"
newline && exit 1
elif $IS_ARMv7 && [ $armv7 == "no" ]; then
warning "Sorry, your CPU is not supported by this installer"
newline && exit 1
elif $IS_ARMv6 && [ $armv6 == "no" ]; then
warning "Sorry, your CPU is not supported by this installer"
newline && exit 1
fi
if [ $raspbianonly == "yes" ] && ! $IS_RASPBIAN;then
warning "This script is intended for Raspbian on a Raspberry Pi!"
newline && exit 1
fi
if $IS_RASPBIAN; then
raspbian_check
if ! $IS_SUPPORTED && ! $IS_EXPERIMENTAL; then
newline && warning "--- Warning ---" && newline
echo "The $productname installer"
echo "does not work on this version of Raspbian."
echo "Check https://github.com/$gitusername/$gitreponame"
echo "for additional information and support"
newline && exit 1
fi
fi
if ! $IS_SUPPORTED && ! $IS_EXPERIMENTAL; then
warning "Your operating system is not supported, sorry!"
newline && exit 1
fi
if $IS_EXPERIMENTAL; then
warning "Support for your operating system is experimental. Please visit"
warning "forums.adafruit.com if you experience issues with this product."
newline
fi
if [ $forcesudo == "yes" ]; then
sudocheck
fi
newline
echo "This script will install everything needed to use"
echo "$productname"
newline
warning "--- Warning ---"
newline
echo "Always be careful when running scripts and commands"
echo "copied from the internet. Ensure they are from a"
echo "trusted source."
newline
echo "If you want to see what this script does before"
echo "running it, you should run:"
echo " \curl -sS github.com/adafruit/Raspberry-Pi-Installer-Scripts/$scriptname"
newline
if confirm "Do you wish to continue?"; then
newline
echo "Checking hardware requirements..."
fix_config_symlink
if [ -e $CONFIG ] && grep -q "^device_tree=$" $CONFIG; then
DEVICE_TREE=false
fi
if $DEVICE_TREE; then
newline
echo "Adding Device Tree Entry to $CONFIG"
if [ -e $CONFIG ] && grep -q "^dtoverlay=seeed-2mic-voicecard$" $CONFIG; then
echo "dtoverlay already active"
else
echo "dtoverlay=seeed-2mic-voicecard" | sudo tee -a $CONFIG
ASK_TO_REBOOT=true
fi
if [ -e $CONFIG ] && grep -q "^dtoverlay=i2s-mmap$" $CONFIG; then
echo "i2s mmap dtoverlay already active"
else
echo "dtoverlay=i2s-mmap" | sudo tee -a $CONFIG
ASK_TO_REBOOT=true
fi
if [ -e $CONFIG ] && grep -q "^dtparam=i2s=on$" $CONFIG; then
echo "i2s interface already enabled"
else
reconfig $CONFIG "^#dtparam=i2s=on$" "dtparam=i2s=on"
ASK_TO_REBOOT=true
fi
else
newline
echo "No Device Tree Detected, not supported"
newline
exit 1
fi
newline
success "All done!"
newline
echo "Enjoy your new $productname!"
newline
if [ $promptreboot == "yes" ] || $ASK_TO_REBOOT; then
sysreboot
fi
else
newline
echo "Aborting..."
newline
fi
exit 0

12
wm8960-soundcard.service Normal file
View file

@ -0,0 +1,12 @@
[Unit]
Description=WM8960 Soundcard service
After=alsa-restore.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/wm8960-soundcard
User=root
[Install]
WantedBy=sysinit.target