added button to clean shutdown the pi
added the adafruit 60 neopixel display code to show the actual time as analog clockpy3
parent
d2c4ef06a6
commit
a5d4cfb5e2
21
README.txt
21
README.txt
|
@ -4,21 +4,13 @@ the button has an RGB led to show status
|
|||
|
||||
how to install
|
||||
==============
|
||||
# login as user pi
|
||||
sudo apt-get install unclutter xdotool git-core screen imagemagick
|
||||
cd ~
|
||||
git clone https://github.com/syn2cat/doorbuzz.git
|
||||
|
||||
put into /etc/rc.local the following line:
|
||||
su pi -c '/home/pi/doorbuzz/buzzctrl.sh' &
|
||||
|
||||
sudo vi /etc/xdg/lxsession/LXDE/autostart
|
||||
remove screensaver
|
||||
cd ~
|
||||
sudo apt-get install unclutter xdotool git-core screen imagemagick
|
||||
git clone git://git.drogon.net/wiringPi
|
||||
cd wiringPi
|
||||
./build
|
||||
cd ~
|
||||
|
||||
mkdir -p /home/pi/.config/lxsession/LXDE/
|
||||
cat > /home/pi/.config/lxsession/LXDE/autostart <<"EOF"
|
||||
|
@ -26,18 +18,11 @@ cat > /home/pi/.config/lxsession/LXDE/autostart <<"EOF"
|
|||
@xset -dpms
|
||||
@xset s noblank
|
||||
@unclutter -display :0 -noevents -grab
|
||||
@./doorbuzz/buzzctrl.sh
|
||||
@./doorbuzz/videoplayer.sh
|
||||
@sudo python ./doorbuzz/shutdownbutton.py
|
||||
EOF
|
||||
|
||||
https://learn.adafruit.com/neopixels-on-raspberry-pi/software
|
||||
sudo apt-get install build-essential python-dev git scons swig
|
||||
git clone https://github.com/jgarff/rpi_ws281x.git
|
||||
cd rpi_ws281x
|
||||
scons
|
||||
cd python
|
||||
sudo python setup.py install
|
||||
|
||||
cd doorbuzz
|
||||
|
||||
connect the button and LED to pins as shown in buzzctrl.sh
|
||||
create a file "secret.txt" containing the http://user:pass@10.1.1.xx part of the URL
|
||||
|
|
|
@ -8,13 +8,16 @@ from math import *
|
|||
from neopixel import *
|
||||
|
||||
# LED strip configuration:
|
||||
LED_COUNT = 1 # Number of LED pixels.
|
||||
LED_COUNT = 61 # Number of LED pixels.
|
||||
LED_PIN = 18 # GPIO pin connected to the pixels (must support PWM!).
|
||||
LED_FREQ_HZ = 800000 # LED signal frequency in hertz (usually 800khz)
|
||||
LED_DMA = 5 # DMA channel to use for generating signal (try 5)
|
||||
LED_BRIGHTNESS = 100 # Set to 0 for darkest and 255 for brightest
|
||||
LED_INVERT = False # True to invert the signal (when using NPN transistor level shift)
|
||||
|
||||
def clockcalc(value):
|
||||
return 1+((30+int(value))%60)
|
||||
|
||||
# Main program logic follows:
|
||||
if __name__ == '__main__':
|
||||
# Create NeoPixel object with appropriate configuration.
|
||||
|
@ -56,7 +59,17 @@ if __name__ == '__main__':
|
|||
pulsewidth=50
|
||||
while True:
|
||||
for i in range(pulsewidth):
|
||||
color=Color(0,0,0)
|
||||
for j in range(0,60):
|
||||
strip.setPixelColor(clockcalc(j), color)
|
||||
trigo=sin(i/pulsewidth*pi)
|
||||
strip.setPixelColor(0, Color(int(r*trigo),int(g*trigo),int(b*trigo)))
|
||||
color=Color(int(r*trigo),int(g*trigo),int(b*trigo))
|
||||
clockpos=int(time.strftime('%I',time.localtime()))*5
|
||||
for j in range(-2,3):
|
||||
strip.setPixelColor(clockcalc(clockpos+j),Color(30,30,30))
|
||||
for j in range(0,60,5):
|
||||
strip.setPixelColor(clockcalc(j), color)
|
||||
strip.setPixelColor(clockcalc(time.strftime('%M',time.localtime())),Color(30,0,0))
|
||||
strip.setPixelColor(clockcalc(time.strftime('%S',time.localtime())),Color(0,30,0))
|
||||
strip.show()
|
||||
time.sleep(50/1000.0)
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
buttonpin=24
|
||||
import RPi.GPIO as GPIO
|
||||
import time
|
||||
import os
|
||||
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
|
||||
GPIO.setup(buttonpin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
|
||||
|
||||
while True:
|
||||
print "waiting..."
|
||||
try:
|
||||
GPIO.wait_for_edge(buttonpin, GPIO.FALLING)
|
||||
print('Button Pressed')
|
||||
os.system("shutdown now -h")
|
||||
except KeyboardInterrupt:
|
||||
GPIO.cleanup() # clean up GPIO on CTRL+C exit
|
||||
GPIO.cleanup() #
|
|
@ -17,6 +17,7 @@ do
|
|||
while read video
|
||||
do
|
||||
omxplayer "$video" </dev/null
|
||||
sleep 2
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue