From 6976e056842e23e28ad1439a5312a08917b6974e Mon Sep 17 00:00:00 2001 From: Bernd Reuther Date: Fri, 5 Mar 2021 15:57:53 +0100 Subject: [PATCH] =?UTF-8?q?route=20f=C3=BCr=20alle=203=20achsen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kamera_server.py | 23 +++++++++++++++++------ src/schrittmotor.py | 10 ++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/kamera_server.py b/kamera_server.py index c46747b..991367b 100644 --- a/kamera_server.py +++ b/kamera_server.py @@ -1,5 +1,6 @@ import RPi.GPIO as GPIO from flask import Flask, render_template, request +import threading import time import pigpio @@ -94,14 +95,24 @@ def action(changePin, action): return render_template('main.html', **templateData) -@kamera_server.route("/position//") +@kamera_server.route("/position/////") def motor_test(motor, position): - if motor == "drehen": - #m1.stop() - #m1.start() - m1.gehe_zu(int(position)) + if drehen == "drehen": + #m1.gehe_zu(int(position)) + th1 = motor_bewegen(m1, (int(pos1)) + th1.join() + + if kippen == "kippen": + #m1.gehe_zu(int(position)) + th2 = motor_bewegen(m2, (int(pos2)) + th3.join() + + if zoom == "zoom": + #m1.gehe_zu(int(position)) + th3 = motor_bewegen(m3, (int(pos3)) + th3.join() - return 'Drehen: ' + str(m1.pos) + return 'Drehen: ' + str(m1.pos) + ', Kippen: ' + str(m2.pos) + ', Zoom: ' + str(m3.pos) if __name__ == "__main__": kamera_server.run(host='0.0.0.0') diff --git a/src/schrittmotor.py b/src/schrittmotor.py index 770706a..872c242 100644 --- a/src/schrittmotor.py +++ b/src/schrittmotor.py @@ -179,6 +179,16 @@ class motor(): else: self.rueckwaerts(abs(temp_schritte)) +class motor_bewegen(threading.Thread): + def __init__(self, motor, position): + threading.Thread.__init__(self) + self.motor = motor + self.position = position + self.start() + + def run(self): + self.motor.gehe_zu(self.position) + def einzelschritt(spule, status, ges_schritte, schritt, t1, t2): w = (schritt * 100 / (ges_schritte - 1)) * 1.8 s = round(math.sin(math.radians(w)), 2)