Skip to content

Instantly share code, notes, and snippets.

@adammhaile
Created April 13, 2018 17:23
Show Gist options
  • Save adammhaile/5ca6a378aa482f2da0f48752827aab01 to your computer and use it in GitHub Desktop.
Save adammhaile/5ca6a378aa482f2da0f48752827aab01 to your computer and use it in GitHub Desktop.
from __future__ import print_function, division
BASE_SCRIPT = """
S{power}
G90
G0 X{x} Y{y} F12000
G91
G1 X10 F500
G90
G0 X300 Y550 F12000
"""
pmin, pmax = (40, 75)
xmax = 1200
ymax = 600
for y in range(0, ymax+1, 200):
for x in range(0, xmax+1, 400):
dist_factor = (x + y) / (xmax + ymax)
power = int(pmin + ((pmax - pmin) * dist_factor))
gcode = BASE_SCRIPT.format(x=x, y=y, power=power)
power_per = int((power / 255.0) * 100)
print('***** {}% @ x={}, y={} *****'.format(power_per, x, y))
print(gcode)
print('')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment