route für alle 3 achsen
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
				
			|||||||
import RPi.GPIO as GPIO
 | 
					import RPi.GPIO as GPIO
 | 
				
			||||||
from flask import Flask, render_template, request
 | 
					from flask import Flask, render_template, request
 | 
				
			||||||
 | 
					import threading
 | 
				
			||||||
import time
 | 
					import time
 | 
				
			||||||
import pigpio
 | 
					import pigpio
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -94,14 +95,24 @@ def action(changePin, action):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    return render_template('main.html', **templateData)
 | 
					    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):
 | 
					def motor_test(motor, position):
 | 
				
			||||||
    if motor == "drehen":
 | 
					    if drehen == "drehen":
 | 
				
			||||||
        #m1.stop()
 | 
					        #m1.gehe_zu(int(position))
 | 
				
			||||||
        #m1.start()
 | 
					        th1 = motor_bewegen(m1, (int(pos1))
 | 
				
			||||||
        m1.gehe_zu(int(position))
 | 
					        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__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
    kamera_server.run(host='0.0.0.0')
 | 
					    kamera_server.run(host='0.0.0.0')
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -179,6 +179,16 @@ class motor():
 | 
				
			|||||||
        else:
 | 
					        else:
 | 
				
			||||||
            self.rueckwaerts(abs(temp_schritte))
 | 
					            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):
 | 
					def einzelschritt(spule, status, ges_schritte, schritt, t1, t2):
 | 
				
			||||||
    w = (schritt * 100 / (ges_schritte - 1)) * 1.8
 | 
					    w = (schritt * 100 / (ges_schritte - 1)) * 1.8
 | 
				
			||||||
    s = round(math.sin(math.radians(w)), 2)
 | 
					    s = round(math.sin(math.radians(w)), 2)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user