route für alle 3 achsen

This commit is contained in:
Bernd Reuther 2021-03-05 15:57:53 +01:00
parent b0116b7e49
commit 6976e05684
2 changed files with 27 additions and 6 deletions

View File

@ -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/<motor>/<position>")
@kamera_server.route("/position/<drehen>/<pos1/<kippen>/<pos2>/<zoom>/<pos3>")
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()
return 'Drehen: ' + str(m1.pos)
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) + ', Kippen: ' + str(m2.pos) + ', Zoom: ' + str(m3.pos)
if __name__ == "__main__":
kamera_server.run(host='0.0.0.0')

View File

@ -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)