nightshift

This commit is contained in:
tilman
2016-12-27 02:05:51 +01:00
parent 6455b109ee
commit 16dd53d1c6
7 changed files with 123 additions and 12 deletions
+6 -4
View File
@@ -22,8 +22,9 @@ BUTTON_PAUSE = 0.4
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s.%(msecs)d %(levelname)s - %(message)s') logging.basicConfig(level=logging.DEBUG, format='%(asctime)s.%(msecs)d %(levelname)s - %(message)s')
logging.info('Initializing') logging.info('Initializing')
# photo sensor on PIN 17
GPIO.setmode(GPIO.BCM) GPIO.setmode(GPIO.BCM)
# photo sensor on PIN 17
GPIO.setup(17, GPIO.IN) GPIO.setup(17, GPIO.IN)
# IR LED on PIN 22 # IR LED on PIN 22
@@ -45,12 +46,12 @@ photo_sensor_still_active = False
try: try:
logging.info('Start moc server') logging.info('Start moc server')
subprocess.call(["padsp", "mocp", "--server"]) subprocess.call(["mocp", "--server"])
subprocess.call(["mocp", "--clear"]) subprocess.call(["mocp", "--clear"])
subprocess.call(["mocp", "-l", SOUND_OK]) subprocess.call(["mocp", "-l", SOUND_OK])
while True: while True:
time.sleep(0.01) time.sleep(0.05)
if (GPIO.input(9) == False): if (GPIO.input(9) == False):
logging.debug('mocp --previous') logging.debug('mocp --previous')
@@ -74,7 +75,7 @@ try:
logging.debug('Photo sensor active, activating light and camera') logging.debug('Photo sensor active, activating light and camera')
subprocess.call(["mocp", "-l", SOUND_SCANNING]) subprocess.call(["mocp", "-l", SOUND_SCANNING])
# turn LED on # turn LED onGPIO.wait_for_edge(23, GPIO.FALLING)
GPIO.output(27, GPIO.HIGH) GPIO.output(27, GPIO.HIGH)
# scan QR code # scan QR code
@@ -166,6 +167,7 @@ try:
# the photo sensor is not blocked (anymore) # the photo sensor is not blocked (anymore)
photo_sensor_still_active = False photo_sensor_still_active = False
# Exit when Ctrl-C is pressed # Exit when Ctrl-C is pressed
except KeyboardInterrupt: except KeyboardInterrupt:
logging.info('Close moc server') logging.info('Close moc server')
+61 -2
View File
@@ -42,7 +42,7 @@ sudo nano /etc/ntp.conf
sudo /etc/init.d/ntp restart sudo /etc/init.d/ntp restart
date date
sudo apt install lirc zbar-tools mc moc python3 python-rpi.gpio python3-rpi.gpio sudo apt install lirc zbar-tools mc moc fswebcam python3 python-rpi.gpio python3-rpi.gpio
# PHAT DAC (https://learn.pimoroni.com/tutorial/phat/raspberry-pi-phat-dac-install) # PHAT DAC (https://learn.pimoroni.com/tutorial/phat/raspberry-pi-phat-dac-install)
curl -sS get.pimoroni.com/phatdac | bash curl -sS get.pimoroni.com/phatdac | bash
@@ -51,6 +51,65 @@ curl -sS get.pimoroni.com/phatdac | bash
mocp mocp
sudo nano /etc/modprobe.d/alsa-base.conf sudo nano /etc/modprobe.d/alsa-base.conf
# Webcam-Test
python3 lighton.py
sudo fswebcam -r 320x240 -d /dev/video0 -v ~/test.jpg
python3 lightoff.py
# enable lirc in /boot/config.txt and add parameters
sudo nano /boot/config.txt
# # Uncomment this to enable the lirc-rpi module
# dtoverlay=lirc-rpi,gpio_in_pin=23,gpio_out_pin=22
##### DIESER SCHRITT HILFT NICHTS. Man muss immer noch lirc manuell laden mit "sudo lircd -d /dev/lirc0", bevor man einen Befehl absetzen kann (s.u.).
# add lirc configuration to /etc/modules (gpio_in_pin wird mit ungenutztem PIN belegt, weil der default PIN 18 schon vom PHAT DAC verwendet wird)
sudo nano /etc/modules
# lirc_dev
# lirc_rpi gpio_in_pin=23 gpio_out_pin=22
#####
# add lirc configuration to /etc/lirc/hardware.conf
sudo nano /etc/lirc/hardware.conf
# LIRCD_ARGS="--uinput"
# LOAD_MODULES=true
# DRIVER="default"
# DEVICE="/dev/lirc0"
# MODULES="lirc_rpi"
# LIRCD_CONF=""
# LIRCMD_CONF=""
sudo reboot
# copy the JBL remote configuration in /etc/lirc/lircd.conf
# --> lirc_jbl_iiip.conf
sudo /etc/init.d/lirc restart
# turn on music, list available commands and test remote control
mocp -S && mocp -l ~/adele.mp3
sudo lircd -d /dev/lirc0
irsend LIST JBLIIIP ""
## Der Befehl muss 2x schnell hintereinander gesendet werden. Offensichtlich muss die Konfiguration noch verbessert werden.
irsend SEND_ONCE JBLIIIP KEY_MUTE
# ------ HIER WEITER
# install python bottle web framework - http://bottlepy.org
sudo apt-get install python-pip
sudo pip install bottle
@@ -62,7 +121,7 @@ sudo nano /etc/modprobe.d/alsa-base.conf
# GEHT LEIDER NICHT WEGEN KNISTERN # GEHT LEIDER NICHT WEGEN KNISTERN (BRUMMSCHLEIFE)
# USB Soundkarte verbinden, dann # USB Soundkarte verbinden, dann
lsusb lsusb
alsamixer # -> zeigt oben das aktive Sounddevice an. Mit F6 kann man die Liste aller Devices anzeigen alsamixer # -> zeigt oben das aktive Sounddevice an. Mit F6 kann man die Liste aller Devices anzeigen
Binary file not shown.
Binary file not shown.
+48
View File
@@ -0,0 +1,48 @@
#!/usr/bin/env python2.7
# script by Alex Eames http://RasPi.tv
# http://RasPi.tv/how-to-use-interrupts-with-python-on-the-raspberry-pi-and-rpi-gpio-part-3
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
# GPIO 23 & 17 set up as inputs, pulled up to avoid false detection.
# Both ports are wired to connect to GND on button press.
# So we'll be setting up falling edge detection for both
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# GPIO 24 set up as an input, pulled down, connected to 3V3 on button press
GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
# now we'll define two threaded callback functions
# these will run in another thread when our events are detected
def my_callback(channel):
print "falling edge detected on 17"
def my_callback2(channel):
print "falling edge detected on 23"
print "Make sure you have a button connected so that when pressed"
print "it will connect GPIO port 23 (pin 16) to GND (pin 6)\n"
print "You will also need a second button connected so that when pressed"
print "it will connect GPIO port 24 (pin 18) to 3V3 (pin 1)\n"
print "You will also need a third button connected so that when pressed"
print "it will connect GPIO port 17 (pin 11) to GND (pin 14)"
raw_input("Press Enter when ready\n>")
# when a falling edge is detected on port 17, regardless of whatever
# else is happening in the program, the function my_callback will be run
GPIO.add_event_detect(17, GPIO.FALLING, callback=my_callback, bouncetime=300)
# when a falling edge is detected on port 23, regardless of whatever
# else is happening in the program, the function my_callback2 will be run
# 'bouncetime=300' includes the bounce control written into interrupts2a.py
GPIO.add_event_detect(23, GPIO.FALLING, callback=my_callback2, bouncetime=300)
try:
print "Waiting for rising edge on port 24"
GPIO.wait_for_edge(24, GPIO.RISING)
print "Rising edge detected on port 24. Here endeth the third lesson."
except KeyboardInterrupt:
GPIO.cleanup() # clean up GPIO on CTRL+C exit
GPIO.cleanup() # clean up GPIO on normal exit
+1 -1
View File
@@ -13,7 +13,7 @@
begin remote begin remote
name /home/pi/remote-jbl-iiip.conf name JBLIIIP
bits 16 bits 16
flags SPACE_ENC|CONST_LENGTH flags SPACE_ENC|CONST_LENGTH
eps 30 eps 30
+7 -5
View File
@@ -2,8 +2,10 @@
## Hardware ## Hardware
- PHAT DAC installieren - http://www.instructables.com/id/Multiroom-Client-With-Raspberry-Pi-ZERO-and-PHAT-D/?ALLSTEPS - PHAT DAC installieren - http://www.instructables.com/id/Multiroom-Client-With-Raspberry-Pi-ZERO-and-PHAT-D/?ALLSTEPS
- Lautstärke über IR regeln - JBL-Fernbedienung nach Musikraketen-Anleitung auslesen - Lautstärke über IR regeln
- JBL-Fernbedienung nach Musikraketen-Anleitung auslesen
- PoC Fernsteuerung
### CNY70 ### CNY70
- https://www.youtube.com/watch?v=KLkNqmqXVtA - Fehler in der Schaltungsskizze! Muss NPN- statt PNP-Transistor sein. - https://www.youtube.com/watch?v=KLkNqmqXVtA - Fehler in der Schaltungsskizze! Muss NPN- statt PNP-Transistor sein.
@@ -17,11 +19,11 @@
## Scripting ## Scripting
- Bugfix <prev> - Bugfix <prev>
- PoC IR-LED - Interrupts statt busy waiting: http://raspi.tv/2013/how-to-use-interrupts-with-python-on-the-raspberry-pi-and-rpi-gpio-part-3
- run statt call https://docs.python.org/3/library/subprocess.html
## Gehäuse ## Gehäuse
- Buttons per Acryl-Transfer beschriften? https://shop.heise.de/katalog/inhalt-333f53 - Buttons per Acryl-Transfer beschriften? ch.16.05.110-115.pdf