-
Notifications
You must be signed in to change notification settings - Fork 3
/
install-driver.sh
69 lines (58 loc) · 2.27 KB
/
install-driver.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
cd ~
echo "Installing Waveshare python libraries and PWM driver"
wget -O pantilthat.py https://raw.githubusercontent.com/pageauc/waveshare.pantilthat/main/pantilthat.py
# create python library module folders for python2 and python3
sudo mkdir -p /usr/local/lib/python2.7/dist-packages/waveshare
sudo cp pantilthat.py /usr/local/lib/python2.7/dist-packages/waveshare
sudo touch /usr/local/lib/python2.7/dist-packages/waveshare/__init__.py
sudo mkdir -p /usr/local/lib/python3.7/dist-packages/waveshare
sudo cp pantilthat.py /usr/local/lib/python3.7/dist-packages/waveshare
sudo touch /usr/local/lib/python3.7/dist-packages/waveshare/__init__.py
rm pantilthat.py
echo "Install Python 2 and 3 Dependencies"
sudo apt-get -yq install python-rpi.gpio
sudo apt-get -yq install python3-rpi.gpio
bcm_ver='73'
echo "$0 Install bcm2835-1.$bcm_ver Please wait ..."
echo "$0 Downloading http://www.airspayce.com/mikem/bcm2835/bcm2835-1.$bcm_ver.tar.gz"
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.$bcm_ver.tar.gz
tar -zxvf bcm2835-1.$bcm_ver.tar.gz
cd bcm2835-1.$bcm_ver
sudo ./configure
echo "$0 Compiling ..... One Moment Please"
sudo make
sudo make check
echo "$0 Running make install"
sudo make install
echo "$0 Performing Cleanup"
cd ~
rm bcm2835-1.$bcm_ver.tar.gz
sudo rm -r bcm2835-1.$bcm_ver
echo "$0 Completed Install of bcm2835-1.$bcm_ver"
echo "
-----------------------------------------------
Install Complete
-----------------------------------------------
INSTRUCTIONS Assumes you are comfortable with SSH and/or Terminal session commands
1. Ensure waveshare pantilt hardware is assembled and connected to the Raspberry Pi
2. Ensure I2C is Enabled using raspi-config whiptail menu system.
sudo raspi-config
Using whiptail menu select Interfacing then I2C and Enable.
Optionally you can Enable Pi Camera module support.
Example python script to center pantilthat.
Valid pan and tilt values are between -90 to +90 degrees
#!/usr/bin/env python
import time
import RPi.GPIO as GPIO
from pantilthat import PanTilt
pantilthat = PanTilt()
pantilthat.pan(0)
pantilthat.tilt(0)
time.sleep(0.1)
pantilthat.stop()
time.sleep(2) # Allow time for driver to stop
print('pantilthat at pan=0, tilt=0')
print('Bye ...')
Good Luck Claude ...
Bye"