bed_mesh: change how profiles with points instead of matrix are handled
This commit is contained in:
parent
b91566c718
commit
af075cdf65
@ -78,8 +78,6 @@ class Printer:
|
|||||||
self.output_pin_count += 1
|
self.output_pin_count += 1
|
||||||
elif section == "pwm_tool":
|
elif section == "pwm_tool":
|
||||||
self.pwm_tools_count += 1
|
self.pwm_tools_count += 1
|
||||||
elif section == "bed_mesh":
|
|
||||||
self.process_bed_mesh(x)
|
|
||||||
elif section in (
|
elif section in (
|
||||||
"led",
|
"led",
|
||||||
"neopixel",
|
"neopixel",
|
||||||
@ -90,9 +88,7 @@ class Printer:
|
|||||||
self.ledcount += 1
|
self.ledcount += 1
|
||||||
|
|
||||||
self.tools = sorted(self.tools)
|
self.tools = sorted(self.tools)
|
||||||
|
|
||||||
self.log_counts(printer_info)
|
self.log_counts(printer_info)
|
||||||
|
|
||||||
self.process_update(data)
|
self.process_update(data)
|
||||||
|
|
||||||
def log_counts(self, printer_info):
|
def log_counts(self, printer_info):
|
||||||
@ -104,19 +100,6 @@ class Printer:
|
|||||||
logging.info(f"# PWM tools: {self.pwm_tools_count}")
|
logging.info(f"# PWM tools: {self.pwm_tools_count}")
|
||||||
logging.info(f"# Leds: {self.ledcount}")
|
logging.info(f"# Leds: {self.ledcount}")
|
||||||
|
|
||||||
def process_bed_mesh(self, x):
|
|
||||||
try:
|
|
||||||
r = self.config[x]
|
|
||||||
r['x_count'] = int(r['x_count'])
|
|
||||||
r['y_count'] = int(r['y_count'])
|
|
||||||
r['max_x'] = float(r['max_x'])
|
|
||||||
r['min_x'] = float(r['min_x'])
|
|
||||||
r['max_y'] = float(r['max_y'])
|
|
||||||
r['min_y'] = float(r['min_y'])
|
|
||||||
r['points'] = [[float(j.strip()) for j in i.split(",")] for i in r['points'].strip().split("\n")]
|
|
||||||
except KeyError:
|
|
||||||
logging.debug(f"Couldn't load mesh {x}: {self.config[x]}")
|
|
||||||
|
|
||||||
def stop_tempstore_updates(self):
|
def stop_tempstore_updates(self):
|
||||||
if self.store_timeout is not None:
|
if self.store_timeout is not None:
|
||||||
GLib.source_remove(self.store_timeout)
|
GLib.source_remove(self.store_timeout)
|
||||||
|
@ -29,17 +29,20 @@ class BedMap(Gtk.DrawingArea):
|
|||||||
for key, value in bm.items():
|
for key, value in bm.items():
|
||||||
if key == 'profiles':
|
if key == 'profiles':
|
||||||
continue
|
continue
|
||||||
logging.info(f"{key}: {value}")
|
|
||||||
if radius:
|
if radius:
|
||||||
self.mesh_radius = float(radius)
|
self.mesh_radius = float(radius)
|
||||||
if 'mesh_min' in bm:
|
if 'mesh_min' in bm:
|
||||||
self.mesh_min = bm['mesh_min']
|
self.mesh_min = bm['mesh_min']
|
||||||
|
elif 'min_x' in bm and 'min_y' in bm:
|
||||||
|
self.mesh_min = (float(bm['min_x']), float(bm['min_y']))
|
||||||
if 'mesh_max' in bm:
|
if 'mesh_max' in bm:
|
||||||
self.mesh_max = bm['mesh_max']
|
self.mesh_max = bm['mesh_max']
|
||||||
|
elif 'max_x' in bm and 'max_y' in bm:
|
||||||
|
self.mesh_max = (float(bm['max_x']), float(bm['max_y']))
|
||||||
if 'probed_matrix' in bm:
|
if 'probed_matrix' in bm:
|
||||||
bm = bm['probed_matrix']
|
bm = bm['probed_matrix']
|
||||||
elif 'points' in bm:
|
elif 'points' in bm:
|
||||||
bm = bm['points']
|
bm = self.transform_points_to_matrix(bm['points'])
|
||||||
else:
|
else:
|
||||||
self.bm = None
|
self.bm = None
|
||||||
return
|
return
|
||||||
@ -65,6 +68,11 @@ class BedMap(Gtk.DrawingArea):
|
|||||||
if self.rotation in (90, 180, 270):
|
if self.rotation in (90, 180, 270):
|
||||||
self.bm = self.rotate_matrix(self.bm)
|
self.bm = self.rotate_matrix(self.bm)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def transform_points_to_matrix(points):
|
||||||
|
rows = points.strip().split('\n')
|
||||||
|
return [list(map(float, row.split(','))) for row in rows]
|
||||||
|
|
||||||
def rotate_matrix(self, matrix):
|
def rotate_matrix(self, matrix):
|
||||||
if self.rotation == 90:
|
if self.rotation == 90:
|
||||||
new_max = [self.mesh_max[1], self.mesh_min[0]]
|
new_max = [self.mesh_max[1], self.mesh_min[0]]
|
||||||
@ -132,6 +140,7 @@ class BedMap(Gtk.DrawingArea):
|
|||||||
for i, row in enumerate(self.bm):
|
for i, row in enumerate(self.bm):
|
||||||
ty = (gheight / rows * i)
|
ty = (gheight / rows * i)
|
||||||
by = ty + gheight / rows
|
by = ty + gheight / rows
|
||||||
|
column: float
|
||||||
for j, column in enumerate(row):
|
for j, column in enumerate(row):
|
||||||
if self.mesh_radius > 0 and self.round_bed_skip(i, j, row, rows, columns):
|
if self.mesh_radius > 0 and self.round_bed_skip(i, j, row, rows, columns):
|
||||||
continue
|
continue
|
||||||
@ -170,7 +179,7 @@ class BedMap(Gtk.DrawingArea):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def colorbar(value):
|
def colorbar(value: float):
|
||||||
rmax = 0.25
|
rmax = 0.25
|
||||||
color = min(1, max(0, 1 - 1 / rmax * abs(value)))
|
color = min(1, max(0, 1 - 1 / rmax * abs(value)))
|
||||||
if value > 0:
|
if value > 0:
|
||||||
|
@ -128,9 +128,12 @@ class Panel(ScreenPanel):
|
|||||||
if 'mesh_origin' in mesh:
|
if 'mesh_origin' in mesh:
|
||||||
self.mesh_origin = self._csv_to_array(mesh['mesh_origin'])
|
self.mesh_origin = self._csv_to_array(mesh['mesh_origin'])
|
||||||
logging.info(f"Mesh Radius: {self.mesh_radius} Origin: {self.mesh_origin}")
|
logging.info(f"Mesh Radius: {self.mesh_radius} Origin: {self.mesh_origin}")
|
||||||
else:
|
elif 'mesh_min' in mesh and 'mesh_max' in mesh:
|
||||||
self.mesh_min = self._csv_to_array(mesh['mesh_min'])
|
self.mesh_min = self._csv_to_array(mesh['mesh_min'])
|
||||||
self.mesh_max = self._csv_to_array(mesh['mesh_max'])
|
self.mesh_max = self._csv_to_array(mesh['mesh_max'])
|
||||||
|
elif 'min_x' in mesh and 'min_y' in mesh and 'max_x' in mesh and 'max_y' in mesh:
|
||||||
|
self.mesh_min = [float(mesh['min_x']), float(mesh['min_y'])]
|
||||||
|
self.mesh_max = [float(mesh['max_x']), float(mesh['max_y'])]
|
||||||
if 'zero_reference_position' in self._printer.get_config_section("bed_mesh"):
|
if 'zero_reference_position' in self._printer.get_config_section("bed_mesh"):
|
||||||
self.zero_ref = self._csv_to_array(mesh['zero_reference_position'])
|
self.zero_ref = self._csv_to_array(mesh['zero_reference_position'])
|
||||||
if "probe" not in functions:
|
if "probe" not in functions:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user