diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b68812e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+archiv
+*.pyc
+
diff --git a/.pydevproject b/.pydevproject
index 7cc0692..d7e7c54 100644
--- a/.pydevproject
+++ b/.pydevproject
@@ -1,8 +1,8 @@
-
-
-python
-python 3.0
-
-/RP_RemoteControl
-
-
+
+
+python
+python interpreter
+
+/RP_RemoteControl
+
+
diff --git a/Doc/wpa_supplicant.conf.txt b/Doc/wpa_supplicant.conf.txt
index 7a2c894..0f7847b 100644
--- a/Doc/wpa_supplicant.conf.txt
+++ b/Doc/wpa_supplicant.conf.txt
@@ -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
}
-
diff --git a/README.md b/README.md
index 5a67d8c..7d0d9f7 100644
--- a/README.md
+++ b/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
\ No newline at end of file
diff --git a/SimpleWebControl/simple_server.py b/SimpleWebControl/simple_server.py
index 386845d..9d80f91 100644
--- a/SimpleWebControl/simple_server.py
+++ b/SimpleWebControl/simple_server.py
@@ -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)
diff --git a/mc_control.sh b/mc_control.sh
index 68278af..392ea5a 100755
--- a/mc_control.sh
+++ b/mc_control.sh
@@ -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
\ No newline at end of file
+exit 0
diff --git a/mc_control/mc_statemachine.py b/mc_control/mc_statemachine.py
index e5bb2cc..e9db48a 100644
--- a/mc_control/mc_statemachine.py
+++ b/mc_control/mc_statemachine.py
@@ -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):
diff --git a/pyface_simulation/__init__.py b/pyface_simulation/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/pyface_simulation/__pycache__/__init__.cpython-32.pyc b/pyface_simulation/__pycache__/__init__.cpython-32.pyc
deleted file mode 100644
index 756a421..0000000
Binary files a/pyface_simulation/__pycache__/__init__.cpython-32.pyc and /dev/null differ
diff --git a/pyface_simulation/__pycache__/pifacedigitalio.cpython-32.pyc b/pyface_simulation/__pycache__/pifacedigitalio.cpython-32.pyc
deleted file mode 100644
index 4337ad1..0000000
Binary files a/pyface_simulation/__pycache__/pifacedigitalio.cpython-32.pyc and /dev/null differ
diff --git a/pyface_simulation/pifacedigitalio.py b/pyface_simulation/pifacedigitalio.py
deleted file mode 100644
index 7b0ac96..0000000
--- a/pyface_simulation/pifacedigitalio.py
+++ /dev/null
@@ -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
\ No newline at end of file
diff --git a/utils/fgpio.py b/utils/fgpio.py
new file mode 100644
index 0000000..67d50f9
--- /dev/null
+++ b/utils/fgpio.py
@@ -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)
+
\ No newline at end of file
diff --git a/www/mc.html b/www/mc.html
index 7e2298c..3c30f2e 100644
--- a/www/mc.html
+++ b/www/mc.html
@@ -72,7 +72,7 @@
@@ -99,7 +99,7 @@
@@ -129,7 +129,7 @@
@@ -160,7 +160,7 @@