Prusa MINI Firmware overview
g29_auto Namespace Reference

Functions

def has_g1 (line)
 
def find_axis (line, axis)
 
def set_mima (line)
 
def find_z (gcode, start_at_line=0)
 
def z_parse (gcode, start_at_line=0, end_at_line=0)
 
def get_lines (gcode, minimum)
 

Variables

string folder = './'
 
string my_file = 'test.gcode'
 
int min_g1 = 3
 
int max_g1 = 100000000
 
string g29_keyword = 'g29'
 
string output_file = folder + 'g29_' + my_file
 
string input_file = folder + my_file
 
int min_size = 40
 
int probing_points = 3
 
int min_x = 500
 
int min_y = min_x
 
int max_x = -500
 
int max_y = max_x
 
float last_z = 0.001
 
int layer = 0
 
int lines_of_g1 = 0
 
list gcode = []
 
int lines = 0
 
 start
 
 end
 
 offset_x = int((min_size - (max_x - min_x)) / 2 + 0.5)
 
 offset_y = int((min_size - (max_y - min_y)) / 2 + 0.5)
 
string new_command
 
 out_file = open(output_file, 'w')
 
 in_file = open(input_file, 'r')
 

Function Documentation

◆ has_g1()

def g29_auto.has_g1 (   line)
48 def has_g1(line):
49  return line[:2].upper() == "G1"
50 
51 
52 # find position in g1 (x,y,z)

◆ find_axis()

def g29_auto.find_axis (   line,
  axis 
)
53 def find_axis(line, axis):
54  found = False
55  number = ""
56  for char in line:
57  if found:
58  if char == ".":
59  number += char
60  elif char == "-":
61  number += char
62  else:
63  try:
64  int(char)
65  number += char
66  except ValueError:
67  break
68  else:
69  found = char.upper() == axis.upper()
70  try:
71  return float(number)
72  except ValueError:
73  return None
74 
75 
76 # save the min or max-values for each axis
Here is the caller graph for this function:

◆ set_mima()

def g29_auto.set_mima (   line)
77 def set_mima(line):
78  global min_x, max_x, min_y, max_y, last_z
79 
80  current_x = find_axis(line, 'x')
81  current_y = find_axis(line, 'y')
82 
83  if current_x is not None:
84  min_x = min(current_x, min_x)
85  max_x = max(current_x, max_x)
86  if current_y is not None:
87  min_y = min(current_y, min_y)
88  max_y = max(current_y, max_y)
89 
90  return min_x, max_x, min_y, max_y
91 
92 
93 # find z in the code and return it
Here is the call graph for this function:

◆ find_z()

def g29_auto.find_z (   gcode,
  start_at_line = 0 
)
94 def find_z(gcode, start_at_line=0):
95  for i in range(start_at_line, len(gcode)):
96  my_z = find_axis(gcode[i], 'Z')
97  if my_z is not None:
98  return my_z, i
99 
100 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ z_parse()

def g29_auto.z_parse (   gcode,
  start_at_line = 0,
  end_at_line = 0 
)
101 def z_parse(gcode, start_at_line=0, end_at_line=0):
102  i = start_at_line
103  all_z = []
104  line_between_z = []
105  z_at_line = []
106  # last_z = 0
107  last_i = -1
108 
109  while len(gcode) > i:
110  try:
111  z, i = find_z(gcode, i + 1)
112  except TypeError:
113  break
114 
115  all_z.append(z)
116  z_at_line.append(i)
117  temp_line = i - last_i -1
118  line_between_z.append(i - last_i - 1)
119  # last_z = z
120  last_i = i
121  if 0 < end_at_line <= i or temp_line >= min_g1:
122  # print('break at line {} at heigth {}'.format(i, z))
123  break
124 
125  line_between_z = line_between_z[1:]
126  return all_z, line_between_z, z_at_line
127 
128 
129 # get the lines which should be the first layer
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_lines()

def g29_auto.get_lines (   gcode,
  minimum 
)
130 def get_lines(gcode, minimum):
131  i = 0
132  all_z, line_between_z, z_at_line = z_parse(gcode, end_at_line=max_g1)
133  for count in line_between_z:
134  i += 1
135  if count > minimum:
136  # print('layer: {}:{}'.format(z_at_line[i-1], z_at_line[i]))
137  return z_at_line[i - 1], z_at_line[i]
138 
139 
Here is the call graph for this function:

Variable Documentation

◆ folder

string g29_auto.folder = './'

◆ my_file

string g29_auto.my_file = 'test.gcode'

◆ min_g1

int g29_auto.min_g1 = 3

◆ max_g1

int g29_auto.max_g1 = 100000000

◆ g29_keyword

string g29_auto.g29_keyword = 'g29'

◆ output_file

string g29_auto.output_file = folder + 'g29_' + my_file

◆ input_file

string g29_auto.input_file = folder + my_file

◆ min_size

int g29_auto.min_size = 40

◆ probing_points

int g29_auto.probing_points = 3

◆ min_x

g29_auto.min_x = 500

◆ min_y

g29_auto.min_y = min_x

◆ max_x

g29_auto.max_x = -500

◆ max_y

g29_auto.max_y = max_x

◆ last_z

float g29_auto.last_z = 0.001

◆ layer

int g29_auto.layer = 0

◆ lines_of_g1

int g29_auto.lines_of_g1 = 0

◆ gcode

list g29_auto.gcode = []

◆ lines

int g29_auto.lines = 0

◆ start

g29_auto.start

◆ end

g29_auto.end

◆ offset_x

g29_auto.offset_x = int((min_size - (max_x - min_x)) / 2 + 0.5)

◆ offset_y

g29_auto.offset_y = int((min_size - (max_y - min_y)) / 2 + 0.5)

◆ new_command

string g29_auto.new_command
Initial value:
1 = 'G29 L{0} R{1} F{2} B{3} P{4}\n'.format(min_x,
2  max_x,
3  min_y,
4  max_y,
5  probing_points)

◆ out_file

g29_auto.out_file = open(output_file, 'w')

◆ in_file

g29_auto.in_file = open(input_file, 'r')
g29_auto.find_axis
def find_axis(line, axis)
Definition: g29_auto.py:53
g29_auto.find_z
def find_z(gcode, start_at_line=0)
Definition: g29_auto.py:94
max
#define max(a, b)
Definition: wiring_constants.h:40
g29_auto.set_mima
def set_mima(line)
Definition: g29_auto.py:77
g29_auto.has_g1
def has_g1(line)
Definition: g29_auto.py:48
min
#define min(a, b)
Definition: wiring_constants.h:36
createSpeedLookupTable.int
int
Definition: createSpeedLookupTable.py:15
g29_auto.z_parse
def z_parse(gcode, start_at_line=0, end_at_line=0)
Definition: g29_auto.py:101
g29_auto.get_lines
def get_lines(gcode, minimum)
Definition: g29_auto.py:130