-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemoCodeFromPi.py
More file actions
62 lines (42 loc) · 1.2 KB
/
Copy pathDemoCodeFromPi.py
File metadata and controls
62 lines (42 loc) · 1.2 KB
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
from octorest import OctoRest
from gpiozero import Motor
from time import sleep
import gpiod
chip = gpiod.Chip('gpiochip4')
pin_one = 23
pin_two = 24
motor = Motor(forward = pin_one, backward = pin_two)
def client(url, apikey):
"""Creates and returns an instance of the OctoRest client.
Args:
url - the url to the OctoPrint server
apikey - the apikey from the OctoPrint server found in settings
"""
try:
client = OctoRest(url=url, apikey=apikey)
return client
except ConnectionError as ex:
# Handle exception as you wish
print(ex)
def toggle_home(client):
"""Toggles the current print (if printing it pauses and
if paused it starts printing) and then homes all of
the printers axes.
Args:
client - the OctoRest client
"""
print("Homing your 3d printer...")
client.home()
def full_home():
theclient = client("http://192.168.86.130:5000","vXUq-MOmzAclkDo8Eh7dScOVOrrYJMvJMxmdYAfG-p8")
toggle_home(theclient)
def demo_motor():
print("started")
motor.forward()
sleep(5)
motor.stop()
motor.close
print("stopped")
def main():
print("Started")
main()