Skip to content

Commit

Permalink
Add time support
Browse files Browse the repository at this point in the history
  • Loading branch information
sckunkle committed Feb 5, 2020
1 parent 6912ef6 commit 6b57c1a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions mbotmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import json
import sys
import tempfile
import copy
import math


def generateMetajson(temp, vardict):
Expand All @@ -20,12 +21,14 @@ def generateMetajson(temp, vardict):
],
"heat_platform": {3},
"extruder": "0"
}}
}},
"duration_s": {4}
}}
"""
meta = meta.format(vardict['tool0temp'], vardict['tool1temp'],
vardict['bedtemp'],
'true' if vardict['heatbed'] else 'false')
'true' if vardict['heatbed'] else 'false',
int(math.ceil(vardict['time'])))
with open('{}/meta.json'.format(temp), 'w') as metafile:
metafile.write(meta)
return
Expand Down Expand Up @@ -77,15 +80,16 @@ def createToolpath(filename, temp):
'tool0temp': 0,
'tool1temp': 0,
'bedtemp': 0,
'heatbed': False
'heatbed': False,
'time': 0.0
}
print('lines processed:')
print(printline.format(0, progresslen, 0/progresslen), end='')
"""
Quick reference:
G0/G1 is move
M104 is set_toolhead_temperature
M140 sets bed temp
M140 sets bed temp
M106 is fan_duty (sets fan)
M107 is toggle_fan (off)
G90 toggles absolute positioning
Expand All @@ -108,6 +112,7 @@ def createToolpath(filename, temp):
if len(line) == 2 and line[1][0] == 'F':
axis['feedrate'] = float(line[1][1:]) / 60.0
else: # Normal move
prev = copy.copy(axis) # copy previous pos for timing
for ax in line[1:]:
if ax[0] == 'E':
axis['a'] = float(ax[1:])
Expand All @@ -126,6 +131,11 @@ def createToolpath(filename, temp):
'z': False},
axis,
[])
# get time traveled by the equasion
# time = sqrt((x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2)/feedrate
distance = math.dist([axis['x'], axis['y'], axis['z']],
[prev['x'], prev['y'], prev['z']])
printersettings['time'] += distance/axis['feedrate']
elif line[0] == 'M104':
for ax in line[1:]:
if ax[0] == 'T':
Expand Down

0 comments on commit 6b57c1a

Please sign in to comment.