-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdebug.py
85 lines (55 loc) · 2.81 KB
/
debug.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import logging
import os
import time
import RPi.GPIO as GPIO
import Adafruit_ADS1x15
import pigpio
import config
import physical_control_v2 as physical_control
import interface_v2 as interface
pi = pigpio.pi()
frankies_log = interface.FrankiesLog().logger
stepper_sprocket_01 = physical_control.Stepper(pi=pi,
logger=frankies_log,
dir_pin=config.GPIO_STEPPER_0_DIR,
on_pin=config.GPIO_STEPPER_0_ON,
step_pin=config.GPIO_STEPPER_0_STEP,
mode0_pin=config.GPIO_STEPPER_0_MODE0,
mode1_pin=config.GPIO_STEPPER_0_MODE1,
mode2_pin=config.GPIO_STEPPER_0_MODE2 )
stepper_sprocket_02 = physical_control.Stepper(pi=pi,
logger=frankies_log,
dir_pin=config.GPIO_STEPPER_2_DIR,
on_pin=config.GPIO_STEPPER_2_ON,
step_pin=config.GPIO_STEPPER_2_STEP,
mode0_pin=config.GPIO_STEPPER_2_MODE0,
mode1_pin=config.GPIO_STEPPER_2_MODE1,
mode2_pin=config.GPIO_STEPPER_2_MODE2 )
try:
for x in range(1):
stepper_sprocket_01.change_step_res(config.STEPPER_FLOATS[3])
stepper_sprocket_02.change_step_res(config.STEPPER_FLOATS[3])
stepper_sprocket_01.advance_frame()
if stepper_sprocket_01.current_mode != "STEPPER":
stepper_sprocket_01.stop = False
stepper_sprocket_01.current_mode = "STEPPER"
if stepper_sprocket_01.logger:
stepper_sprocket_01.logger.debug("Stepper mode enabled.")
else:
print "Stepper mode enabled."
if not stepper_sprocket_01.stop and stepper_sprocket_01.steps:
stepper_sprocket_01.turn_on()
stepper_sprocket_02.turn_on()
if stepper_sprocket_01.rewind:
stepper_sprocket_01.pi.write(stepper_sprocket_01.dir_pin, not stepper_sprocket_01.default_dir)
else:
stepper_sprocket_01.pi.write(stepper_sprocket_01.dir_pin, stepper_sprocket_01.default_dir)
for step in range(stepper_sprocket_01.steps):
if not stepper_sprocket_01.stop:
stepper_sprocket_01.one_step()
stepper_sprocket_02.one_step()
stepper_sprocket_01.turn_off()
stepper_sprocket_02.turn_off()
except KeyboardInterrupt:
stepper_sprocket_01.turn_off()
stepper_sprocket_02.turn_off()