Browse Source

fixed librpip install script

gwillz 2 years ago
parent
commit
fe4448e56e
3 changed files with 31 additions and 19 deletions
  1. 2 0
      .gitignore
  2. 6 6
      README.md
  3. 23 13
      librpip.sh

+ 2 - 0
.gitignore

@@ -11,3 +11,5 @@ doc-style.css
 *.py~
 *.cfg~
 .coverage
+librpip-*/
+!librpip.sh

+ 6 - 6
README.md

@@ -68,20 +68,20 @@ wget http://librpip.frasersdev.net/wp-content/uploads/2016/03/librpip-0.3.2.tar.
 tar -xf librpip-0.3.2.tar.gz
 cd librpip-0.3.2/
 
+# create pwm group
+sudo groupadd -r pwm
+sudo usermod -aG pwm pi
+
 # install librpip
 ./configure
 make
 sudo make install
 
 # install pwm init service
-cp distro/arch/pwm-init.service /etc/systemd/system
+sudo cp distro/arch/pwm-init.service /etc/systemd/system
 sudo systemctl daemon-reload
 sudo systemctl enable pwm-init
 
-# create pwm group
-sudo groupadd -R pwm
-sudo usermod -aG pwm pi
-
 # add pwm to the boot config
 sudo su -c 'echo dtoverlay=pwm,pin=12,func=4 > /boot/config.txt'
 
@@ -100,7 +100,7 @@ Pin Channel Mapping
 | PWM  | Pin | func | mode |
 |------|-----|------|------|
 | PWM0 | 12  | 4    | alt0 |
-| PWM0 | 18  | 1    | alt5 |
+| PWM0 | 18  | 2    | alt5 |
 | PWM0 | 40  | 4    | alt0 |
 | PWM0 | 52  | 5    | alt1 |
 | PWM1 | 13  | 4    | alt0 |

+ 23 - 13
librpip.sh

@@ -1,23 +1,33 @@
-#!/usr/bin/bash
+#!/bin/bash
+
+# create pwm group
+sudo groupadd -r pwm
+sudo usermod -aG pwm pi
 
 # get librpip - this initializes the pwm clock and sets the correct permissions
-wget http://librpip.frasersdev.net/wp-content/uploads/2016/03/librpip-0.3.2.tar.gz
-tar -xf librpip-0.3.2.tar.gz
+if [[ ! -d "librpip-0.3.2" ]]; then
+  wget http://librpip.frasersdev.net/wp-content/uploads/2016/03/librpip-0.3.2.tar.gz
+  tar -xf librpip-0.3.2.tar.gz
+fi
 cd librpip-0.3.2/
 
-# install librpip
-./configure
-make
-sudo make install
+# build
+if [[ ! -e "./bin/pwmclk" ]]; then
+  ./configure
+  make
+fi
+
+# install
+[[ -d "/usr/local/bin/librpip-util" ]] || sudo make install
 
 # install pwm init service
-cp distro/arch/pwm-init.service /etc/systemd/system
+sudo cp distro/arch/pwm-init.service /etc/systemd/system
 sudo systemctl daemon-reload
 sudo systemctl enable pwm-init
 
-# create pwm group
-sudo groupadd -R pwm
-sudo usermod -aG pwm pi
-
 # add pwm to the boot config
-sudo su -c 'echo dtoverlay=pwm,pin=12,func=4 > /boot/config.txt'
+echo ""
+echo "add this to your /boot/config.txt"
+echo "##"
+echo "dtoverlay=pwm,pin=12,func=4"
+echo "##"