diff --git a/kamera_server.py b/kamera_server.py index 3d45219..592cad2 100644 --- a/kamera_server.py +++ b/kamera_server.py @@ -81,17 +81,14 @@ def action(changePin, action): return render_template('main.html', **templateData) -@kamera_server.route("/motor1_test") -def motor_test(): - #m2.pwm4.ChangeFrequency(freq_halten) - m1.stop() - m1.start() - m1.vorwaerts(10) - time.sleep(2) - m1.rueckwaerts(10) - #print('Motortest') - # Pass the template data into the template main.html and return it to the user - return 'fertig' +@kamera_server.route("//") +def motor_test(motor, position): + if motor == "drehen": + m1.stop() + m1.start() + m1.gehe_zu(int(position)) + + return 'Drehen: ' + m1.pos if __name__ == "__main__": kamera_server.run(host='0.0.0.0') diff --git a/src/schrittmotor.py b/src/schrittmotor.py index b08dd2d..83af57a 100644 --- a/src/schrittmotor.py +++ b/src/schrittmotor.py @@ -137,6 +137,14 @@ class motor(): self.rueckwaerts(self.schritte_max, 1) self.pos = 0 + def gehe_zu(self, position): + temp_schritte = int(position) - self.pos + + if temp_schritte > 0: + self.vorwaerts(temp_schritte) + else: + self.rueckwaerts(temp_schritte) + 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)