replace piface with gpiozero lib
This commit is contained in:
parent
a123f5e36d
commit
7573a32573
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
archiv
|
||||
*.pyc
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?eclipse-pydev version="1.0"?><pydev_project>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">python</pydev_property>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 3.0</pydev_property>
|
||||
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
|
||||
<path>/RP_RemoteControl</path>
|
||||
</pydev_pathproperty>
|
||||
</pydev_project>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?eclipse-pydev version="1.0"?><pydev_project>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">python</pydev_property>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
|
||||
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
|
||||
<path>/RP_RemoteControl</path>
|
||||
</pydev_pathproperty>
|
||||
</pydev_project>
|
||||
|
@ -1,4 +1,4 @@
|
||||
# sudo cat ./etc/wpa_supplicant/wpa_supplicant.conf
|
||||
# sudo cat ./etc/wpa_supplicant/wpa_supplicant.conf
|
||||
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
|
||||
update_config=1
|
||||
|
||||
@ -10,4 +10,3 @@ network={
|
||||
pairwise=CCMP
|
||||
auth_alg=OPEN
|
||||
}
|
||||
|
||||
|
48
README.md
48
README.md
@ -1,21 +1,51 @@
|
||||
Raspberry PI Allgemein
|
||||
# RP_Jalousiecontrol
|
||||
allows web based remote control of Jalousie
|
||||
|
||||
## requirements
|
||||
|
||||
### hardware
|
||||
Rasperry PI
|
||||
|
||||
### software
|
||||
- python 3.x
|
||||
- raspberrian
|
||||
|
||||
## installation:
|
||||
|
||||
### debian packages
|
||||
sudo apt install git python3-pifacedigitalio python-pifacedigitalio
|
||||
|
||||
### checkout sources
|
||||
cd /var/lib
|
||||
sudo mkdir Jalousiecontrol
|
||||
sudo chown pi:pi Jalousiecontrol
|
||||
git clone https://gitea.devpool.net/stevo/RP_Jalousiecontrol.git
|
||||
|
||||
### copy startup scripts and enable autostart
|
||||
sudo cp ./mc_control.sh /etc/init.d/mc_control.sh
|
||||
sudo /etc/init.d/mc_control.sh start
|
||||
sudo /etc/init.d/mc_control.sh stop
|
||||
sudo update-rc.d mc_control.sh defaults
|
||||
|
||||
sudo raspi-config -> 5 - interface options -> P4 SPI -> enable kernel modules
|
||||
|
||||
|
||||
|
||||
# bookmarks
|
||||
|
||||
## Raspberry PI Allgemein
|
||||
- http://www.mikrocontroller.net/articles/Raspberry_Pi
|
||||
|
||||
Ajax, Java Script, CCS:
|
||||
## Ajax, Java Script, CCS:
|
||||
- http://flask.pocoo.org/docs/patterns/jquery/
|
||||
- http://xyzzyxyzzy.net/2012/07/01/ajax-fun-with-jquery-python/
|
||||
- http://getbootstrap.com/components/#panels
|
||||
- http://openbook.galileocomputing.de/javascript/
|
||||
- http://www.w3schools.com/js/js_htmldom_document.asp
|
||||
|
||||
Python webserver mit SSL
|
||||
## Python webserver mit SSL
|
||||
- http://www.piware.de/2011/01/creating-an-https-server-in-python/
|
||||
- http://code.activestate.com/recipes/442473-simple-http-server-supporting-ssl-secure-communica/
|
||||
|
||||
webserver atomatisch starten
|
||||
## webserver atomatisch starten
|
||||
- http://raspberrywebserver.com/serveradmin/run-a-script-on-start-up.html
|
||||
|
||||
sudo cp ./mc_control.sh /etc/init.d/mc_control.sh
|
||||
sudo /etc/init.d/mc_control.sh start
|
||||
sudo /etc/init.d/mc_control.sh stop
|
||||
sudo update-rc.d mc_control.sh defaults
|
@ -15,6 +15,9 @@ import time
|
||||
from urllib.parse import urlparse
|
||||
from utils.web import handle_file_request, get_my_ip
|
||||
from mc_control.mc_statemachine import mc_state_machine, mc_event
|
||||
from gpiozero import LED
|
||||
from gpiozero.pins.pigpio import PiGPIOFactory
|
||||
|
||||
|
||||
HOST_NAME = '' #'localhost'
|
||||
PORT_NUMBER = 8000
|
||||
@ -117,13 +120,23 @@ class myhandler(BaseHTTPRequestHandler):
|
||||
class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
|
||||
''' '''
|
||||
|
||||
def StartStateMachines():
|
||||
def StartStateMachines(factory):
|
||||
global sm
|
||||
sm = list()
|
||||
sm.append( mc_state_machine(0, 1))
|
||||
sm.append( mc_state_machine(2, 3))
|
||||
sm.append( mc_state_machine(4, 5))
|
||||
sm.append( mc_state_machine(6, 7))
|
||||
|
||||
up_1 = LED(16, pin_factory=factory)
|
||||
down_1 = LED(12, pin_factory=factory)
|
||||
up_2 = LED(6, pin_factory=factory)
|
||||
down_2 = LED(20, pin_factory=factory)
|
||||
up_3 = LED(13, pin_factory=factory)
|
||||
down_3 = LED(21, pin_factory=factory)
|
||||
up_4 = LED(19, pin_factory=factory)
|
||||
down_4 = LED(26, pin_factory=factory)
|
||||
|
||||
sm.append( mc_state_machine(up_1, down_1))
|
||||
sm.append( mc_state_machine(up_2, down_2))
|
||||
sm.append( mc_state_machine(up_3, down_3))
|
||||
sm.append( mc_state_machine(up_4, down_4))
|
||||
|
||||
def CloseStateMachines():
|
||||
global sm
|
||||
@ -136,7 +149,9 @@ def CloseStateMachines():
|
||||
if __name__ == '__main__':
|
||||
|
||||
global sm
|
||||
StartStateMachines()
|
||||
|
||||
factory = PiGPIOFactory(host='jalousiecontrol')
|
||||
StartStateMachines(factory)
|
||||
|
||||
httpd = ThreadedHTTPServer((HOST_NAME,PORT_NUMBER),myhandler)
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#! /bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: start and stop of the mc_control webservice
|
||||
# Required-Start:
|
||||
# Required-Stop:
|
||||
# Required-Start:
|
||||
# Required-Stop:
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: start and stop of the mc_control webservice
|
||||
@ -12,15 +12,15 @@
|
||||
# Aktionen
|
||||
case "$1" in
|
||||
start)
|
||||
/usr/bin/python3 /home/pi/10_RP_MotorControl/SimpleWebControl/simple_server.py &
|
||||
/usr/bin/python3 /var/lib/RP_Jalousiecontrol/SimpleWebControl/simple_server.py &
|
||||
;;
|
||||
stop)
|
||||
killall python3
|
||||
;;
|
||||
restart)
|
||||
killall python3
|
||||
/usr/bin/python3 /home/pi/10_RP_MotorControl/SimpleWebControl/simple_server.py &
|
||||
/usr/bin/python3 /var/lib/RP_Jalousiecontrol/SimpleWebControl/simple_server.py &
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
exit 0
|
||||
|
@ -18,13 +18,9 @@ DOWN - in down position
|
||||
from queue import Queue
|
||||
import threading
|
||||
from mc_control.mc_timer import mc_timer
|
||||
#from pyface_simulation import pifacedigitalio
|
||||
|
||||
|
||||
try:
|
||||
import pifacedigitalio #@UnresolvedImport
|
||||
except:
|
||||
from pyface_simulation import pifacedigitalio
|
||||
|
||||
|
||||
class Position():
|
||||
def __init__(self, min_value=0, max_value=100, step=1):
|
||||
@ -74,7 +70,8 @@ class mc_state_machine(threading.Thread):
|
||||
self.__running = True
|
||||
self.Port_Up = Port_Up
|
||||
self.Port_Down = Port_Down
|
||||
self.pfd = pifacedigitalio.PiFaceDigital() # creates a PiFace Digtal object
|
||||
#self.pfd = pifacedigitalio.PiFaceDigital() # creates a PiFace Digtal object
|
||||
|
||||
self.timeout_value = timeout_value # sec.
|
||||
self.PositionUpdateTimerPeriode = timeout_value/10 # sec.
|
||||
self.MotorTimeout = mc_timer()
|
||||
@ -122,22 +119,22 @@ class mc_state_machine(threading.Thread):
|
||||
print('MotorUp')
|
||||
print('Switch Port={} on'.format(self.Port_Up))
|
||||
print('Switch Port={} off'.format(self.Port_Down))
|
||||
self.pfd.leds[self.Port_Up].value = 1
|
||||
self.pfd.leds[self.Port_Down].value = 0
|
||||
self.Port_Up.on()
|
||||
self.Port_Down.off()
|
||||
|
||||
def MotorDown(self):
|
||||
print('MotorDown')
|
||||
print('Switch Port={} off'.format(self.Port_Up))
|
||||
print('Switch Port={} on'.format(self.Port_Down))
|
||||
self.pfd.leds[self.Port_Up].value = 0
|
||||
self.pfd.leds[self.Port_Down].value = 1
|
||||
self.Port_Up.off()
|
||||
self.Port_Down.on()
|
||||
|
||||
def MotorStop(self):
|
||||
print('MotorStop')
|
||||
print('Switch Port={} off'.format(self.Port_Up))
|
||||
print('Switch Port={} off'.format(self.Port_Down))
|
||||
self.pfd.leds[self.Port_Up].value = 0
|
||||
self.pfd.leds[self.Port_Down].value = 0
|
||||
self.Port_Up.off()
|
||||
self.Port_Down.off()
|
||||
|
||||
|
||||
def run(self):
|
||||
|
Binary file not shown.
Binary file not shown.
@ -1,32 +0,0 @@
|
||||
'''
|
||||
Created on 29.06.2014
|
||||
|
||||
@author: stevo
|
||||
'''
|
||||
|
||||
|
||||
|
||||
class RelayClass():
|
||||
value = 0
|
||||
|
||||
class LedClass():
|
||||
value = 0
|
||||
|
||||
class PiFaceDigital():
|
||||
|
||||
def __init__(self):
|
||||
self.relays = []
|
||||
self.relays.append( RelayClass())
|
||||
self.relays.append( RelayClass())
|
||||
|
||||
self.leds = []
|
||||
self.leds.append( LedClass())
|
||||
self.leds.append( LedClass())
|
||||
self.leds.append( LedClass())
|
||||
self.leds.append( LedClass())
|
||||
self.leds.append( LedClass())
|
||||
self.leds.append( LedClass())
|
||||
self.leds.append( LedClass())
|
||||
self.leds.append( LedClass())
|
||||
|
||||
return None
|
19
utils/fgpio.py
Normal file
19
utils/fgpio.py
Normal file
@ -0,0 +1,19 @@
|
||||
'''
|
||||
Created on Jun 3, 2019
|
||||
|
||||
@author: stevo
|
||||
'''
|
||||
|
||||
from gpiozero import LED
|
||||
from gpiozero.pins.pigpio import PiGPIOFactory
|
||||
from time import sleep
|
||||
|
||||
remote_factory = PiGPIOFactory(host='192.168.1.97')
|
||||
led = LED(21, pin_factory=remote_factory)
|
||||
|
||||
while True:
|
||||
led.on()
|
||||
sleep(5)
|
||||
led.off()
|
||||
sleep(5)
|
||||
|
@ -72,7 +72,7 @@
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
|
||||
Gruppe 1
|
||||
Alex 1
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
@ -99,7 +99,7 @@
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">
|
||||
Gruppe 2
|
||||
Alex 2
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
@ -129,7 +129,7 @@
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#collapseThree">
|
||||
Gruppe 3
|
||||
Linus 3
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
@ -160,7 +160,7 @@
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#collapseFour">
|
||||
Gruppe 4
|
||||
Linus 4
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user