Compare commits

..
19 Commits
Author SHA1 Message Date
alfrix 8af5c0b2d4 Trace memory 2023-03-24 08:12:19 -06:00
alfrix da9f970231 print: refactors 2023-03-22 06:51:34 -06:00
alfrix 3417765223 job_status: fix panel not showing and not updating thumbnails
safeguard against thumbnail corruption or other errors fixes #893
better system to update name and thumbnails fixes #889
2023-03-19 05:55:30 -06:00
alfrix b963c55140 job_status: fix save endstop not working fixes #929 2023-03-17 07:50:50 -06:00
alfrix 2d8419ca13 fix desktop icon not appearing 2023-03-17 07:50:50 -06:00
Jookiaandalfrix 5f3827a2cb screen: Only switch layouts if the window has been majorly resized (#913)
* screen: Only switch layouts if the window has been majorly resized

Changing the layout can cause the window to resize on some systems.
This can create a feedback loop on systems with square displays.

Keep track of the vertical aspect ratio associated with the current
mode and only switch between vertical and horizontal mode when a
significant aspect ratio change has been detected.

* fixup

---------

Co-authored-by: alfrix <alfredomonclus@gmail.com>
2023-03-17 07:49:28 -06:00
alfrix d6f7bdcfe6 macros: use the new get_macro instead of get_config due to recent issues 2023-03-11 16:53:08 -06:00
alfrix 87c3f03719 fix issues caused by dfe1ac8d
fix #924
fix #923
2023-03-11 16:40:06 -06:00
Alfredo Monclus 094b90cf86 network: integrate networkmanager (#917)
fixes #881
this should be temporary until an implementation of sdbus-networkmanager
2023-03-11 07:43:10 -06:00
alfrixandAndriy 3220f084ec Update Ukranian close #914
Re-done due to merge conflicts

Co-authored-by: Andriy <40995038+komandrik@users.noreply.github.com>
2023-03-10 20:29:18 -06:00
alfrix dfe1ac8d2c macros: fix list not loading when there are extra spaces fixes #909 2023-03-10 20:03:28 -06:00
alfrix be473bf626 bed_level: fix auto-detect when there is no config file fixes #918 2023-03-10 06:43:02 -06:00
alfrix b353f8526e timeout requests to prevent locking 2023-03-09 07:32:46 -06:00
alfrix 122752b000 leakfix 2023-03-09 07:32:46 -06:00
alfrix 0f0c6f9b6e always maintain printers data, should avoid a bunch of issues 2023-03-09 07:32:46 -06:00
alfrix 18af1d1410 bed_level: add center screw close #863 2023-03-08 06:36:54 -06:00
alfrix 926d78de01 bed_level: remove screws only if in list and simplify detection fixes #910 2023-03-08 06:11:23 -06:00
alfrix a5b639fba2 bed_level: fix compatibility with python 3.7 2023-03-03 08:12:41 -06:00
Alfredo Monclusandczaky 55af0d753c bed_level: improve screw detection (#908)
* Use max_distance for fitting screws to buttons

The max distance is at most 1/3 of the diagonal,
depending on how many screws are there in horizontal or
vertical orientation.

This is a safe guard to prevent assigning screws to buttons
that would confuse the users, for very skewed screw configs.

use a smaller button scale fixes #891

Co-authored-by: alfrix <alfredomonclus@gmail.com>

Co-authored-by: czaky <jendrzej.w@lczak.net>
2023-03-01 07:41:43 -06:00
18 changed files with 1560 additions and 215 deletions

No files matched your search

+1 -1
View File
@@ -79,7 +79,7 @@ calibrate_y_position: 100
# Bed Screws # Bed Screws
# define the screw positons required for odd number of screws in a comma separated list # define the screw positons required for odd number of screws in a comma separated list
# possible values are: bl, br, bm, fl, fr, fm, lm, rm # possible values are: bl, br, bm, fl, fr, fm, lm, rm, center
# they correspond to back-left, back-right, back-middle, front-left, front-right, front-middle, left-middle, right-middle # they correspond to back-left, back-right, back-middle, front-left, front-right, front-middle, left-middle, right-middle
screw_positions: "" screw_positions: ""
+20 -9
View File
@@ -116,27 +116,38 @@ class KlippyGtk:
def Image(self, image_name=None, width=None, height=None): def Image(self, image_name=None, width=None, height=None):
if image_name is None: if image_name is None:
return Gtk.Image() return Gtk.Image()
pixbuf = self.PixbufFromIcon(image_name, width, height)
return Gtk.Image.new_from_pixbuf(pixbuf) if pixbuf is not None else Gtk.Image()
def PixbufFromIcon(self, filename, width=None, height=None):
width = width if width is not None else self.img_width width = width if width is not None else self.img_width
height = height if height is not None else self.img_height height = height if height is not None else self.img_height
filename = os.path.join(self.themedir, image_name) filename = os.path.join(self.themedir, filename)
for ext in ["svg", "png"]: for ext in ["svg", "png"]:
with contextlib.suppress(Exception): pixbuf = self.PixbufFromFile(f"{filename}.{ext}", int(width), int(height))
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(f"{filename}.{ext}", int(width), int(height)) if pixbuf is not None:
if pixbuf is not None: return pixbuf
return Gtk.Image.new_from_pixbuf(pixbuf) return None
logging.error(f"Unable to find image {filename}.{ext}")
return Gtk.Image()
@staticmethod @staticmethod
def PixbufFromFile(filename, width=-1, height=-1): def PixbufFromFile(filename, width=-1, height=-1):
return GdkPixbuf.Pixbuf.new_from_file_at_size(filename, int(width), int(height)) try:
return GdkPixbuf.Pixbuf.new_from_file_at_size(filename, int(width), int(height))
except Exception as e:
logging.exception(e)
logging.error(f"Unable to find image {filename}")
return None
def PixbufFromHttp(self, resource, width=-1, height=-1): def PixbufFromHttp(self, resource, width=-1, height=-1):
response = self.screen.apiclient.get_thumbnail_stream(resource) response = self.screen.apiclient.get_thumbnail_stream(resource)
if response is False: if response is False:
return None return None
stream = Gio.MemoryInputStream.new_from_data(response, None) stream = Gio.MemoryInputStream.new_from_data(response, None)
pixbuf = GdkPixbuf.Pixbuf.new_from_stream_at_scale(stream, int(width), int(height), True) try:
pixbuf = GdkPixbuf.Pixbuf.new_from_stream_at_scale(stream, int(width), int(height), True)
except Exception as e:
logging.exception(e)
return None
stream.close_async(2) stream.close_async(2)
return pixbuf return pixbuf
+1 -1
View File
@@ -37,7 +37,7 @@ class KlippyRest:
headers = {} if self.api_key is False else {"x-api-key": self.api_key} headers = {} if self.api_key is False else {"x-api-key": self.api_key}
data = False data = False
try: try:
response = requests.get(url, headers=headers) response = requests.get(url, headers=headers, timeout=3)
response.raise_for_status() response.raise_for_status()
if json: if json:
logging.debug(f"Sending request to {url}") logging.debug(f"Sending request to {url}")
File diff suppressed because it is too large. Load diff
Binary file not shown.
@@ -8,16 +8,16 @@ msgstr ""
"Project-Id-Version: 2022-09-04 14:53-0300\n" "Project-Id-Version: 2022-09-04 14:53-0300\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-11-30 18:17-0300\n" "POT-Creation-Date: 2022-11-30 18:17-0300\n"
"PO-Revision-Date: 2022-11-30 18:16-0300\n" "PO-Revision-Date: 2023-03-10 20:26-0600\n"
"Last-Translator: Andrii Komarovskyi\n" "Last-Translator: Andrii Komarovskyi\n"
"Language-Team: Andrii Komarovskyi\n" "Language-Team: Andrii Komarovskyi\n"
"Language: uk\n" "Language: uk\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && " "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"n%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n" "%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n"
"X-Generator: Poedit 3.2.1\n" "X-Generator: Poedit 2.4.2\n"
#, python-format #, python-format
msgid "%s will be updated to version" msgid "%s will be updated to version"
@@ -62,7 +62,7 @@ msgid "Apply %s%.2f offset to Probe?"
msgstr "Застосувати зміщення %s%.2f до зонда?" msgstr "Застосувати зміщення %s%.2f до зонда?"
msgid "Are you sure do you want to exclude the object?" msgid "Are you sure do you want to exclude the object?"
msgstr "" msgstr "Ви впевнені, що бажаєте виключити об’єкт?"
msgid "Are you sure you want to run Emergency Stop?" msgid "Are you sure you want to run Emergency Stop?"
msgstr "Ви впевнені, що хочете зробити аварійну зупинку?" msgstr "Ви впевнені, що хочете зробити аварійну зупинку?"
@@ -208,7 +208,7 @@ msgid "Exclude Object"
msgstr "Виключити об’єкт" msgstr "Виключити об’єкт"
msgid "Extra Large" msgid "Extra Large"
msgstr "" msgstr "Дуже Великий"
msgid "Extrude" msgid "Extrude"
msgstr "" msgstr ""
@@ -332,7 +332,7 @@ msgid "Invalid"
msgstr "Недійсний" msgstr "Недійсний"
msgid "Invalid password" msgid "Invalid password"
msgstr "" msgstr "Недійсний пароль"
msgid "Invert X" msgid "Invert X"
msgstr "Інвертувати X" msgstr "Інвертувати X"
@@ -409,7 +409,7 @@ msgid "Max Velocity"
msgstr "Макс. швидкість" msgstr "Макс. швидкість"
msgid "Maximum" msgid "Maximum"
msgstr "" msgstr "Максимум"
msgid "Measure Both" msgid "Measure Both"
msgstr "Виміряти все" msgstr "Виміряти все"
@@ -427,7 +427,7 @@ msgid "Menu"
msgstr "Меню" msgstr "Меню"
msgid "Mesh calibrate" msgid "Mesh calibrate"
msgstr "" msgstr "Калібрування сітки столу"
msgid "Modified" msgid "Modified"
msgstr "Змінено" msgstr "Змінено"
@@ -445,10 +445,10 @@ msgid "Name"
msgstr "Ім'я" msgstr "Ім'я"
msgid "Network" msgid "Network"
msgstr "Сітка" msgstr "Мережа"
msgid "Never" msgid "Never"
msgstr "" msgstr "Ніколи"
msgid "New" msgid "New"
msgstr "Новий" msgstr "Новий"
@@ -518,13 +518,13 @@ msgid "Print Time"
msgstr "Час друку" msgstr "Час друку"
msgid "Printer" msgid "Printer"
msgstr "" msgstr "Принтер"
msgid "Printer Connections" msgid "Printer Connections"
msgstr "Підключення принтера" msgstr "Підключення принтера"
msgid "Printer Select" msgid "Printer Select"
msgstr "" msgstr "Вибір Принтера"
msgid "Printing" msgid "Printing"
msgstr "Друк" msgstr "Друк"
@@ -536,7 +536,7 @@ msgid "Profile Name:"
msgstr "Ім'я профілю:" msgstr "Ім'я профілю:"
msgid "Provide KlipperScreen.log when asking for help.\n" msgid "Provide KlipperScreen.log when asking for help.\n"
msgstr "" msgstr "Надайте KlipperScreen.log, коли звертаєтесь по допомогу.\n"
msgid "Quad Gantry Level" msgid "Quad Gantry Level"
msgstr "Портальне вирівнювання" msgstr "Портальне вирівнювання"
@@ -557,7 +557,9 @@ msgid "Reference"
msgstr "Довідка" msgstr "Довідка"
msgid "Refresh" msgid "Refresh"
msgstr "Оновити" msgstr ""
"Перевірка\n"
"Оновлень"
msgid "Restart" msgid "Restart"
msgstr "Перезапуск" msgstr "Перезапуск"
@@ -580,7 +582,7 @@ msgid "Retraction Speed"
msgstr "Швидкість втягування" msgstr "Швидкість втягування"
msgid "Retry" msgid "Retry"
msgstr "" msgstr "Повторіть спробу"
msgid "Retrying" msgid "Retrying"
msgstr "Повторна спроба" msgstr "Повторна спроба"
@@ -633,10 +635,10 @@ msgid "Show"
msgstr "Показати" msgstr "Показати"
msgid "Show Heater Power" msgid "Show Heater Power"
msgstr "" msgstr "Показати Потужність Нагрівача"
msgid "Shutdown" msgid "Shutdown"
msgstr "вимкнувся" msgstr "Вимкнути"
msgid "Size" msgid "Size"
msgstr "Розмір" msgstr "Розмір"
@@ -714,7 +716,7 @@ msgid "Unretract Speed"
msgstr "Швидкість повернення" msgstr "Швидкість повернення"
msgid "Up To Date" msgid "Up To Date"
msgstr "Оновити" msgstr "Актуально"
msgid "Update" msgid "Update"
msgstr "Оновлення" msgstr "Оновлення"
+17 -26
View File
@@ -7,12 +7,12 @@ from gi.repository import GLib
class Printer: class Printer:
def __init__(self, state_cb): def __init__(self, state_cb, state_callbacks, busy_cb):
self.config = None self.config = {}
self.data = None self.data = {}
self.state = "disconnected" self.state = "disconnected"
self.state_cb = state_cb self.state_cb = state_cb
self.state_callbacks = None self.state_callbacks = state_callbacks
self.devices = {} self.devices = {}
self.power_devices = {} self.power_devices = {}
self.tools = [] self.tools = []
@@ -22,28 +22,9 @@ class Printer:
self.output_pin_count = 0 self.output_pin_count = 0
self.store_timeout = None self.store_timeout = None
self.tempstore = {} self.tempstore = {}
self.busy_cb = None self.busy_cb = busy_cb
self.busy = None self.busy = False
self.temperature_store_size = None self.tempstore_size = 1200
def reset(self):
self.config = None
self.data = None
self.state = None
self.state_cb = None
self.state_callbacks = None
self.devices = None
self.power_devices = None
self.tools = None
self.extrudercount = None
self.tempdevcount = None
self.fancount = None
self.output_pin_count = None
self.store_timeout = None
self.tempstore = None
self.busy_cb = None
self.busy = None
self.temperature_store_size = None
def reinit(self, printer_info, data): def reinit(self, printer_info, data):
self.config = data['configfile']['config'] self.config = data['configfile']['config']
@@ -174,6 +155,16 @@ class Printer:
def get_config_section(self, section): def get_config_section(self, section):
return self.config[section] if section in self.config else False return self.config[section] if section in self.config else False
def get_macro(self, macro):
return next(
(
self.config[key]
for key in self.config.keys()
if key.find(macro) > -1
),
False,
)
def get_fans(self): def get_fans(self):
fans = [] fans = []
if self.config_section_exists("fan"): if self.config_section_exists("fan"):
+2 -2
View File
@@ -49,11 +49,11 @@ class ScreenPanel:
def get_file_image(self, filename, width=None, height=None, small=False): def get_file_image(self, filename, width=None, height=None, small=False):
if not self._files.has_thumbnail(filename): if not self._files.has_thumbnail(filename):
return None return None
width = width if width is not None else self._gtk.img_width
height = height if height is not None else self._gtk.img_height
loc = self._files.get_thumbnail_location(filename, small) loc = self._files.get_thumbnail_location(filename, small)
if loc is None: if loc is None:
return None return None
width = width if width is not None else self._gtk.img_width
height = height if height is not None else self._gtk.img_height
if loc[0] == "file": if loc[0] == "file":
return self._gtk.PixbufFromFile(loc[1], width, height) return self._gtk.PixbufFromFile(loc[1], width, height)
if loc[0] == "http": if loc[0] == "http":
+1 -1
View File
@@ -5,7 +5,7 @@ import contextlib
import logging import logging
import uuid import uuid
import NetworkManager from ks_includes import NetworkManager
import dbus import dbus
from dbus.mainloop.glib import DBusGMainLoop from dbus.mainloop.glib import DBusGMainLoop
import gi import gi
+116 -71
View File
@@ -1,5 +1,6 @@
import logging import logging
import re import re
import math
import gi import gi
@@ -14,6 +15,29 @@ def create_panel(*args):
return BedLevelPanel(*args) return BedLevelPanel(*args)
# Find the screw closest to the point,
# but return None if the distance is above max_distance.
# If remove is set to true, the screw is also removed
# from the list of passed in screws.
def find_closest(screws, point, max_distance, remove=False):
if len(screws) == 0:
return None
closest = screws[0]
min_distance = math.hypot(closest[0] - point[0], closest[1] - point[1])
for screw in screws[1:]:
distance = math.hypot(screw[0] - point[0], screw[1] - point[1])
if distance < min_distance:
closest = screw
min_distance = distance
if min_distance > max_distance:
return None
if remove:
screws.remove(closest)
return closest
class BedLevelPanel(ScreenPanel): class BedLevelPanel(ScreenPanel):
def __init__(self, screen, title): def __init__(self, screen, title):
@@ -49,7 +73,8 @@ class BedLevelPanel(ScreenPanel):
self.y_offset = round(float(probe['y_offset']), 1) self.y_offset = round(float(probe['y_offset']), 1)
logging.debug(f"offset X: {self.x_offset} Y: {self.y_offset}") logging.debug(f"offset X: {self.x_offset} Y: {self.y_offset}")
# bed_screws uses NOZZLE positions # bed_screws uses NOZZLE positions
# screws_tilt_adjust uses PROBE positions and to be offseted for the buttons to work equal to bed_screws # screws_tilt_adjust uses PROBE positions and
# to be offseted for the buttons to work equal to bed_screws
new_screws = [ new_screws = [
[round(screw[0] + self.x_offset, 1), round(screw[1] + self.y_offset, 1)] [round(screw[0] + self.x_offset, 1), round(screw[1] + self.y_offset, 1)]
for screw in self.screws for screw in self.screws
@@ -60,6 +85,35 @@ class BedLevelPanel(ScreenPanel):
elif "bed_screws" in self._printer.get_config_section_list(): elif "bed_screws" in self._printer.get_config_section_list():
self.screws = self._get_screws("bed_screws") self.screws = self._get_screws("bed_screws")
logging.info(f"bed_screws: {self.screws}") logging.info(f"bed_screws: {self.screws}")
nscrews = len(self.screws)
# KS config
valid_positions = True
valid_screws = ["bl", "fl", "fr", "br", "bm", "fm", "lm", "rm", "center"]
if self.ks_printer_cfg is not None:
screw_positions = self.ks_printer_cfg.get("screw_positions", "")
if screw_positions:
screw_positions = [str(i.strip()) for i in screw_positions.split(',')]
logging.info(f"Positions: {screw_positions}")
for screw in screw_positions:
if screw not in valid_screws:
logging.error(f"Unknown screw: {screw}")
self._screen.show_popup_message(_("Unknown screw position") + f": {screw}")
valid_positions = False
if not (3 <= len(screw_positions) <= 9):
valid_positions = False
else:
if nscrews in (3, 5, 7):
valid_positions = False
screw_positions = valid_screws
rotation = self.ks_printer_cfg.getint("screw_rotation", 0)
logging.info(f"Rotation: {rotation}")
else:
if nscrews in (3, 5, 7):
valid_positions = False
screw_positions = valid_screws
if 'bed_screws' in self._config.get_config():
rotation = self._config.get_config()['bed_screws'].getint("rotation", 0)
logging.debug(f"Rotation: {rotation}")
# get dimensions # get dimensions
x_positions = {x[0] for x in self.screws} x_positions = {x[0] for x in self.screws}
@@ -70,89 +124,73 @@ class BedLevelPanel(ScreenPanel):
min_x = min(x_positions) min_x = min(x_positions)
max_x = max(x_positions) max_x = max(x_positions)
mid_x = round((min_x + max_x) / 2)
min_y = min(y_positions) min_y = min(y_positions)
max_y = max(y_positions) max_y = max(y_positions)
mid_y = round((min_y + max_y) / 2)
fl = [min_x, min_y] max_distance = math.ceil(
bl = [min_x, max_y] math.hypot(max_x - min_x, max_y - min_y)
br = [max_x, max_y] / min(self.x_cnt, self.y_cnt, 3)
fr = [max_x, min_y] )
if self.x_cnt == 3: logging.debug(f"Using max_distance: {max_distance} to fit: {len(self.screws)} screws.")
mid_x = [x for x in list(zip(*self.screws))[0] if x not in (min_x, max_x)][0]
fm = [mid_x, min_y]
bm = [mid_x, max_y]
else:
fm = bm = None
if self.y_cnt == 3:
mid_y = [y for y in list(zip(*self.screws))[1] if y not in (min_y, max_y)][0]
lm = [min_x, mid_y]
rm = [max_x, mid_y]
else:
lm = rm = None
logging.debug(f"Using {len(self.screws)}-screw locations [x,y] [{self.x_cnt}x{self.y_cnt}]") remaining_screws = self.screws[:]
self.buttons['bl'] = self._gtk.Button("bed-level-t-l", scale=2.5) fl = find_closest(remaining_screws, (min_x, min_y), max_distance, remove="fl" in screw_positions)
self.buttons['br'] = self._gtk.Button("bed-level-t-r", scale=2.5) bl = find_closest(remaining_screws, (min_x, max_y), max_distance, remove="bl" in screw_positions)
self.buttons['fl'] = self._gtk.Button("bed-level-b-l", scale=2.5) br = find_closest(remaining_screws, (max_x, max_y), max_distance, remove="br" in screw_positions)
self.buttons['fr'] = self._gtk.Button("bed-level-b-r", scale=2.5) fr = find_closest(remaining_screws, (max_x, min_y), max_distance, remove="fr" in screw_positions)
self.buttons['lm'] = self._gtk.Button("bed-level-l-m", scale=2.5)
self.buttons['rm'] = self._gtk.Button("bed-level-r-m", scale=2.5)
self.buttons['fm'] = self._gtk.Button("bed-level-b-m", scale=2.5)
self.buttons['bm'] = self._gtk.Button("bed-level-t-m", scale=2.5)
valid_positions = True fm = find_closest(remaining_screws, (mid_x, min_y), max_distance, remove="fm" in screw_positions)
if self.ks_printer_cfg is not None: bm = find_closest(remaining_screws, (mid_x, max_y), max_distance, remove="bm" in screw_positions)
screw_positions = self.ks_printer_cfg.get("screw_positions", "")
screw_positions = [str(i.strip()) for i in screw_positions.split(',')] lm = find_closest(remaining_screws, (min_x, mid_y), max_distance, remove="lm" in screw_positions)
logging.info(f"Positions: {screw_positions}") rm = find_closest(remaining_screws, (max_x, mid_y), max_distance, remove="rm" in screw_positions)
for screw in screw_positions:
if screw not in ("bl", "fl", "fr", "br", "bm", "fm", "lm", "rm", ""): center = find_closest(remaining_screws, (mid_x, mid_y), max_distance, remove="center" in screw_positions)
logging.error(f"Unknown screw: {screw}")
self._screen.show_popup_message(_("Unknown screw position") + f": {screw}") if len(remaining_screws) != 0:
valid_positions = False logging.debug(f"Screws not used: {remaining_screws}")
if not (3 <= len(screw_positions) <= 8):
valid_positions = False logging.debug(f"Using {len(self.screws) - len(remaining_screws)}/{len(self.screws)}-screw locations")
rotation = self.ks_printer_cfg.getint("screw_rotation", 0)
logging.info(f"Rotation: {rotation}") button_scale = 2
else:
valid_positions = False self.buttons['bl'] = self._gtk.Button("bed-level-t-l", scale=button_scale)
if 'bed_screws' in self._config.get_config(): self.buttons['br'] = self._gtk.Button("bed-level-t-r", scale=button_scale)
rotation = self._config.get_config()['bed_screws'].getint("rotation", 0) self.buttons['fl'] = self._gtk.Button("bed-level-b-l", scale=button_scale)
logging.debug(f"Rotation: {rotation}") self.buttons['fr'] = self._gtk.Button("bed-level-b-r", scale=button_scale)
self.buttons['lm'] = self._gtk.Button("bed-level-l-m", scale=button_scale)
self.buttons['rm'] = self._gtk.Button("bed-level-r-m", scale=button_scale)
self.buttons['fm'] = self._gtk.Button("bed-level-b-m", scale=button_scale)
self.buttons['bm'] = self._gtk.Button("bed-level-t-m", scale=button_scale)
self.buttons['center'] = self._gtk.Button("increase", scale=button_scale)
bedgrid = Gtk.Grid() bedgrid = Gtk.Grid()
nscrews = len(self.screws)
if valid_positions: if valid_positions:
if "bl" in screw_positions: if "bl" in screw_positions and bl:
bedgrid.attach(self.buttons['bl'], 1, 0, 1, 1) bedgrid.attach(self.buttons['bl'], 1, 0, 1, 1)
if "fl" in screw_positions: if "fl" in screw_positions and fl:
bedgrid.attach(self.buttons['fl'], 1, 2, 1, 1) bedgrid.attach(self.buttons['fl'], 1, 2, 1, 1)
if "fr" in screw_positions: if "fr" in screw_positions and fr:
bedgrid.attach(self.buttons['fr'], 3, 2, 1, 1) bedgrid.attach(self.buttons['fr'], 3, 2, 1, 1)
if "br" in screw_positions: if "br" in screw_positions and br:
bedgrid.attach(self.buttons['br'], 3, 0, 1, 1) bedgrid.attach(self.buttons['br'], 3, 0, 1, 1)
if "bm" in screw_positions: if "bm" in screw_positions and bm:
bedgrid.attach(self.buttons['bm'], 2, 0, 1, 1) bedgrid.attach(self.buttons['bm'], 2, 0, 1, 1)
if "fm" in screw_positions: if "fm" in screw_positions and fm:
bedgrid.attach(self.buttons['fm'], 2, 2, 1, 1) bedgrid.attach(self.buttons['fm'], 2, 2, 1, 1)
if "lm" in screw_positions: if "lm" in screw_positions and lm:
bedgrid.attach(self.buttons['lm'], 1, 1, 1, 1)
if "rm" in screw_positions:
bedgrid.attach(self.buttons['rm'], 3, 1, 1, 1)
elif nscrews in {4, 6, 8}:
bedgrid.attach(self.buttons['bl'], 1, 0, 1, 1)
bedgrid.attach(self.buttons['fl'], 1, 2, 1, 1)
bedgrid.attach(self.buttons['fr'], 3, 2, 1, 1)
bedgrid.attach(self.buttons['br'], 3, 0, 1, 1)
if self.x_cnt == 3:
bedgrid.attach(self.buttons['bm'], 2, 0, 1, 1)
bedgrid.attach(self.buttons['fm'], 2, 2, 1, 1)
if self.y_cnt == 3:
bedgrid.attach(self.buttons['lm'], 1, 1, 1, 1) bedgrid.attach(self.buttons['lm'], 1, 1, 1, 1)
if "rm" in screw_positions and rm:
bedgrid.attach(self.buttons['rm'], 3, 1, 1, 1) bedgrid.attach(self.buttons['rm'], 3, 1, 1, 1)
if "center" in screw_positions and center:
bedgrid.attach(self.buttons['center'], 2, 1, 1, 1)
self.buttons['center'].connect("clicked", self.go_to_position, center)
else: else:
label = Gtk.Label( label = Gtk.Label(
_("Bed screw configuration:") + f" {nscrews}\n\n" _("Bed screw configuration:") + f" {nscrews}\n\n"
@@ -253,7 +291,7 @@ class BedLevelPanel(ScreenPanel):
'fl': fl, 'fl': fl,
'lm': lm 'lm': lm
} }
self.screw_dict['center'] = center
grid.attach(bedgrid, 1, 0, 3, 2) grid.attach(bedgrid, 1, 0, 3, 2)
self.content.add(grid) self.content.add(grid)
@@ -261,9 +299,16 @@ class BedLevelPanel(ScreenPanel):
for key, value in self.screw_dict.items(): for key, value in self.screw_dict.items():
self.buttons[key].set_label(f"{value}") self.buttons[key].set_label(f"{value}")
def go_to_position(self, widget, position): def home(self):
# Test if all axes have been homed. Home if necessary.
if self._printer.get_stat("toolhead", "homed_axes") != "xyz": if self._printer.get_stat("toolhead", "homed_axes") != "xyz":
self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME) self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
# do Z_TILT_CALIBRATE if applicable.
if self._printer.config_section_exists("z_tilt"):
self._screen._ws.klippy.gcode_script(KlippyGcodes.Z_TILT)
def go_to_position(self, widget, position):
self.home()
logging.debug(f"Going to position: {position}") logging.debug(f"Going to position: {position}")
script = [ script = [
f"{KlippyGcodes.MOVE_ABSOLUTE}", f"{KlippyGcodes.MOVE_ABSOLUTE}",
@@ -284,8 +329,9 @@ class BedLevelPanel(ScreenPanel):
def process_busy(self, busy): def process_busy(self, busy):
for button in self.buttons: for button in self.buttons:
if button == "screws": if button == "screws":
self.buttons[button].set_sensitive(self._printer.config_section_exists("screws_tilt_adjust") self.buttons[button].set_sensitive(
and (not busy)) self._printer.config_section_exists("screws_tilt_adjust")
and (not busy))
continue continue
self.buttons[button].set_sensitive((not busy)) self.buttons[button].set_sensitive((not busy))
@@ -347,8 +393,7 @@ class BedLevelPanel(ScreenPanel):
return sorted(screws, key=lambda s: (float(s[1]), float(s[0]))) return sorted(screws, key=lambda s: (float(s[1]), float(s[0])))
def screws_tilt_calculate(self, widget): def screws_tilt_calculate(self, widget):
if self._printer.get_stat("toolhead", "homed_axes") != "xyz": self.home()
self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
self.response_count = 0 self.response_count = 0
self.buttons['screws'].set_sensitive(False) self.buttons['screws'].set_sensitive(False)
self._screen._ws.klippy.gcode_script("SCREWS_TILT_CALCULATE") self._screen._ws.klippy.gcode_script("SCREWS_TILT_CALCULATE")
+6 -1
View File
@@ -83,7 +83,12 @@ class MacroPanel(ScreenPanel):
"params": {}, "params": {},
} }
pattern = r'params\.(?P<param>..*)\|default\((?P<default>..*)\).*' pattern = r'params\.(?P<param>..*)\|default\((?P<default>..*)\).*'
gcode = self._printer.get_config_section(f"gcode_macro {macro}")["gcode"].split("\n") gcode = self._printer.get_macro(macro)
if gcode and "gcode" in gcode:
gcode = gcode["gcode"].split("\n")
else:
logging.debug(f"Couldn't load {macro}\n{gcode}")
return
i = 0 i = 0
for line in gcode: for line in gcode:
if line.startswith("{") and "params." in line: if line.startswith("{") and "params." in line:
+22 -17
View File
@@ -119,7 +119,7 @@ class JobStatusPanel(ScreenPanel):
overlay.add_overlay(box) overlay.add_overlay(box)
self.grid.attach(overlay, 0, 0, 1, 1) self.grid.attach(overlay, 0, 0, 1, 1)
self.labels['thumbnail'] = self._gtk.Image("file", self._screen.width / 4, self._screen.height / 4) self.labels['thumbnail'] = self._gtk.Image()
self.labels['info_grid'] = Gtk.Grid() self.labels['info_grid'] = Gtk.Grid()
self.labels['info_grid'].attach(self.labels['thumbnail'], 0, 0, 1, 1) self.labels['info_grid'].attach(self.labels['thumbnail'], 0, 0, 1, 1)
if self._printer.get_tools(): if self._printer.get_tools():
@@ -351,9 +351,14 @@ class JobStatusPanel(ScreenPanel):
def activate(self): def activate(self):
ps = self._printer.get_stat("print_stats") ps = self._printer.get_stat("print_stats")
self.set_state(ps['state']) self.set_state(ps['state'])
if 'filename' in ps and (ps['filename'] != self.filename):
logging.debug(f"Changing filename: '{self.filename}' to '{ps['filename']}'")
self.update_filename()
if self.flow_timeout is None: if self.flow_timeout is None:
self.flow_timeout = GLib.timeout_add_seconds(2, self.update_flow) self.flow_timeout = GLib.timeout_add_seconds(2, self.update_flow)
self._screen.base_panel_show_all() self._screen.base_panel_show_all()
logging.debug("Job_status panel")
self._screen.memory_trace()
def deactivate(self): def deactivate(self):
if self.flow_timeout is not None: if self.flow_timeout is not None:
@@ -394,7 +399,7 @@ class JobStatusPanel(ScreenPanel):
+ "\n\n" + "\n\n"
+ _("Saved offset: %s") % saved_z_offset) + _("Saved offset: %s") % saved_z_offset)
elif device == "endstop": elif device == "endstop":
label.set_label(_("Apply %.2f offset to Endstop?") % (sign, abs(self.zoffset))) label.set_label(_("Apply %s%.2f offset to Endstop?") % (sign, abs(self.zoffset)))
label.set_hexpand(True) label.set_hexpand(True)
label.set_halign(Gtk.Align.CENTER) label.set_halign(Gtk.Align.CENTER)
label.set_vexpand(True) label.set_vexpand(True)
@@ -610,13 +615,11 @@ class JobStatusPanel(ScreenPanel):
f"{1 + round((self.pos_z - self.f_layer_h) / self.layer_h)} / {self.labels['total_layers'].get_text()}") f"{1 + round((self.pos_z - self.f_layer_h) / self.layer_h)} / {self.labels['total_layers'].get_text()}")
if 'print_duration' in ps: if 'print_duration' in ps:
total_duration = ps['total_duration']
print_duration = ps['print_duration']
if 'filament_used' in ps: if 'filament_used' in ps:
self.labels['filament_used'].set_label(f"{float(ps['filament_used']) / 1000:.1f} m") self.labels['filament_used'].set_label(f"{float(ps['filament_used']) / 1000:.1f} m")
self.update_time_left(total_duration, print_duration, ps['filament_used']) self.update_time_left(ps['total_duration'], ps['print_duration'], ps['filament_used'])
else: else:
self.update_time_left(total_duration, print_duration) self.update_time_left(ps['total_duration'], ps['print_duration'])
elapsed_label = f"{self.labels['elapsed'].get_text()} {self.labels['duration'].get_text()}" elapsed_label = f"{self.labels['elapsed'].get_text()} {self.labels['duration'].get_text()}"
self.buttons['elapsed'].set_label(elapsed_label) self.buttons['elapsed'].set_label(elapsed_label)
@@ -770,16 +773,18 @@ class JobStatusPanel(ScreenPanel):
self.content.show_all() self.content.show_all()
def show_file_thumbnail(self): def show_file_thumbnail(self):
if self._files.has_thumbnail(self.filename): if self._screen.vertical_mode:
if self._screen.vertical_mode: width = self._screen.width * 0.9
width = self._screen.width * 0.9 height = self._screen.height / 4
height = self._screen.height / 4 else:
else: width = self._screen.width / 3
width = self._screen.width / 3 height = self._gtk.content_height * 0.47
height = self._gtk.content_height * 0.47 pixbuf = self.get_file_image(self.filename, width, height)
pixbuf = self.get_file_image(self.filename, width, height) logging.debug(self.filename)
if pixbuf is not None: if pixbuf is None:
self.labels['thumbnail'].set_from_pixbuf(pixbuf) logging.debug("no pixbuf")
pixbuf = self._gtk.PixbufFromIcon("file", width / 2, height / 2)
self.labels['thumbnail'].set_from_pixbuf(pixbuf)
def update_filename(self): def update_filename(self):
self.filename = self._printer.get_stat('print_stats', 'filename') self.filename = self._printer.get_stat('print_stats', 'filename')
@@ -812,7 +817,6 @@ class JobStatusPanel(ScreenPanel):
logging.info(f"Update Metadata. File: {self.filename} Size: {self.file_metadata['size']}") logging.info(f"Update Metadata. File: {self.filename} Size: {self.file_metadata['size']}")
if "estimated_time" in self.file_metadata and self.timeleft_type == "slicer": if "estimated_time" in self.file_metadata and self.timeleft_type == "slicer":
self.labels["est_time"].set_label(self.format_time(self.file_metadata['estimated_time'])) self.labels["est_time"].set_label(self.format_time(self.file_metadata['estimated_time']))
self.show_file_thumbnail()
if "object_height" in self.file_metadata: if "object_height" in self.file_metadata:
self.oheight = float(self.file_metadata['object_height']) self.oheight = float(self.file_metadata['object_height'])
self.labels['height'].set_label(f"{self.oheight} {self.mm}") self.labels['height'].set_label(f"{self.oheight} {self.mm}")
@@ -829,6 +833,7 @@ class JobStatusPanel(ScreenPanel):
self.file_metadata = {} self.file_metadata = {}
logging.debug("Cannot find file metadata. Listening for updated metadata") logging.debug("Cannot find file metadata. Listening for updated metadata")
self._screen.files.add_file_callback(self._callback_metadata) self._screen.files.add_file_callback(self._callback_metadata)
self.show_file_thumbnail()
def update_percent_complete(self): def update_percent_complete(self):
if self.state not in ["printing", "paused"]: if self.state not in ["printing", "paused"]:
+1 -1
View File
@@ -67,7 +67,7 @@ class MenuPanel(ScreenPanel):
self.grid.attach(self.labels[key], col, row, width, height) self.grid.attach(self.labels[key], col, row, width, height)
i += 1 i += 1
self.j2_data = None
return self.grid return self.grid
def create_menu_items(self): def create_menu_items(self):
+36 -26
View File
@@ -82,6 +82,7 @@ class PrintPanel(ScreenPanel):
if self.cur_directory != "gcodes": if self.cur_directory != "gcodes":
self.change_dir(None, "gcodes") self.change_dir(None, "gcodes")
self._refresh_files() self._refresh_files()
logging.debug("Print panel")
def add_directory(self, directory, show=True): def add_directory(self, directory, show=True):
parent_dir = os.path.dirname(directory) parent_dir = os.path.dirname(directory)
@@ -332,7 +333,10 @@ class PrintPanel(ScreenPanel):
directory = os.path.join("gcodes", os.path.dirname(filename)) if os.path.dirname(filename) else "gcodes" directory = os.path.join("gcodes", os.path.dirname(filename)) if os.path.dirname(filename) else "gcodes"
if directory not in self.filelist or os.path.basename(filename).startswith("."): if directory not in self.filelist or os.path.basename(filename).startswith("."):
return return
self.filelist[directory]["files"].pop(self.filelist[directory]["files"].index(os.path.basename(filename))) try:
self.filelist[directory]["files"].pop(self.filelist[directory]["files"].index(os.path.basename(filename)))
except Exception as e:
logging.exception(e)
dir_parts = directory.split(os.sep) dir_parts = directory.split(os.sep)
i = len(dir_parts) i = len(dir_parts)
while i > 1: while i > 1:
@@ -352,7 +356,10 @@ class PrintPanel(ScreenPanel):
self.dir_panels[parent_dir].show_all() self.dir_panels[parent_dir].show_all()
i -= 1 i -= 1
self.dir_panels[directory].remove(self.files[filename]) try:
self.dir_panels[directory].remove(self.files[filename])
except Exception as e:
logging.exception(e)
self.dir_panels[directory].show_all() self.dir_panels[directory].show_all()
self.files.pop(filename) self.files.pop(filename)
@@ -408,6 +415,7 @@ class PrintPanel(ScreenPanel):
def _refresh_files(self, widget=None): def _refresh_files(self, widget=None):
self._files.refresh_files() self._files.refresh_files()
self._screen.memory_trace()
def show_rename(self, widget, fullpath): def show_rename(self, widget, fullpath):
self.source = fullpath self.source = fullpath
@@ -417,35 +425,37 @@ class PrintPanel(ScreenPanel):
self.content.remove(child) self.content.remove(child)
if "rename_file" not in self.labels: if "rename_file" not in self.labels:
lbl = self._gtk.Label(_("Rename/Move:")) self._create_rename_box(fullpath)
lbl.set_halign(Gtk.Align.START)
lbl.set_hexpand(False)
self.labels['new_name'] = Gtk.Entry()
self.labels['new_name'].set_text(fullpath)
self.labels['new_name'].set_hexpand(True)
self.labels['new_name'].connect("activate", self.rename)
self.labels['new_name'].connect("focus-in-event", self._screen.show_keyboard)
save = self._gtk.Button("complete", _("Save"), "color3")
save.set_hexpand(False)
save.connect("clicked", self.rename)
box = Gtk.Box()
box.pack_start(self.labels['new_name'], True, True, 5)
box.pack_start(save, False, False, 5)
self.labels['rename_file'] = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
self.labels['rename_file'].set_valign(Gtk.Align.CENTER)
self.labels['rename_file'].set_hexpand(True)
self.labels['rename_file'].set_vexpand(True)
self.labels['rename_file'].pack_start(lbl, True, True, 5)
self.labels['rename_file'].pack_start(box, True, True, 5)
self.content.add(self.labels['rename_file']) self.content.add(self.labels['rename_file'])
self.labels['new_name'].set_text(fullpath[7:]) self.labels['new_name'].set_text(fullpath[7:])
self.labels['new_name'].grab_focus_without_selecting() self.labels['new_name'].grab_focus_without_selecting()
self.showing_rename = True self.showing_rename = True
def _create_rename_box(self, fullpath):
lbl = self._gtk.Label(_("Rename/Move:"))
lbl.set_halign(Gtk.Align.START)
lbl.set_hexpand(False)
self.labels['new_name'] = Gtk.Entry()
self.labels['new_name'].set_text(fullpath)
self.labels['new_name'].set_hexpand(True)
self.labels['new_name'].connect("activate", self.rename)
self.labels['new_name'].connect("focus-in-event", self._screen.show_keyboard)
save = self._gtk.Button("complete", _("Save"), "color3")
save.set_hexpand(False)
save.connect("clicked", self.rename)
box = Gtk.Box()
box.pack_start(self.labels['new_name'], True, True, 5)
box.pack_start(save, False, False, 5)
self.labels['rename_file'] = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
self.labels['rename_file'].set_valign(Gtk.Align.CENTER)
self.labels['rename_file'].set_hexpand(True)
self.labels['rename_file'].set_vexpand(True)
self.labels['rename_file'].pack_start(lbl, True, True, 5)
self.labels['rename_file'].pack_start(box, True, True, 5)
def hide_rename(self): def hide_rename(self):
self._screen.remove_keyboard() self._screen.remove_keyboard()
for child in self.content.get_children(): for child in self.content.get_children():
+60 -38
View File
@@ -10,6 +10,7 @@ import traceback # noqa
import locale import locale
import sys import sys
import gi import gi
import tracemalloc
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, GLib, Pango from gi.repository import Gtk, Gdk, GLib, Pango
@@ -82,7 +83,7 @@ class KlipperScreen(Gtk.Window):
panels = {} panels = {}
popup_message = None popup_message = None
screensaver = None screensaver = None
printer = None printers = printer = None
subscriptions = [] subscriptions = []
updating = False updating = False
_ws = None _ws = None
@@ -90,8 +91,11 @@ class KlipperScreen(Gtk.Window):
reinit_count = 0 reinit_count = 0
max_retries = 4 max_retries = 4
initialized = False initialized = False
initial_snapshot = None
switch_count = 0
def __init__(self, args, version): def __init__(self, args, version):
tracemalloc.start()
try: try:
super().__init__(title="KlipperScreen") super().__init__(title="KlipperScreen")
except Exception as e: except Exception as e:
@@ -122,7 +126,8 @@ class KlipperScreen(Gtk.Window):
self.set_resizable(True) self.set_resizable(True)
if not (self._config.get_main_config().get("width") or self._config.get_main_config().get("height")): if not (self._config.get_main_config().get("width") or self._config.get_main_config().get("height")):
self.fullscreen() self.fullscreen()
self.vertical_mode = self.width < self.height self.aspect_ratio = self.width / self.height
self.vertical_mode = self.aspect_ratio < 1.0
logging.info(f"Screen resolution: {self.width}x{self.height}") logging.info(f"Screen resolution: {self.width}x{self.height}")
self.theme = self._config.get_main_config().get('theme') self.theme = self._config.get_main_config().get('theme')
self.show_cursor = self._config.get_main_config().getboolean("show_cursor", fallback=False) self.show_cursor = self._config.get_main_config().getboolean("show_cursor", fallback=False)
@@ -151,13 +156,24 @@ class KlipperScreen(Gtk.Window):
self.initial_connection() self.initial_connection()
def initial_connection(self): def initial_connection(self):
printers = self._config.get_printers() self.printers = self._config.get_printers()
state_callbacks = {
"disconnected": self.state_disconnected,
"error": self.state_error,
"paused": self.state_paused,
"printing": self.state_printing,
"ready": self.state_ready,
"startup": self.state_startup,
"shutdown": self.state_shutdown
}
for printer in self.printers:
printer["data"] = Printer(state_execute, state_callbacks, self.process_busy_state)
default_printer = self._config.get_main_config().get('default_printer') default_printer = self._config.get_main_config().get('default_printer')
logging.debug(f"Default printer: {default_printer}") logging.debug(f"Default printer: {default_printer}")
if [True for p in printers if default_printer in p]: if [True for p in self.printers if default_printer in p]:
self.connect_printer(default_printer) self.connect_printer(default_printer)
elif len(printers) == 1: elif len(self.printers) == 1:
pname = list(printers[0])[0] pname = list(self.printers[0])[0]
self.connect_printer(pname) self.connect_printer(pname)
else: else:
self.base_panel.show_printer_select(True) self.base_panel.show_printer_select(True)
@@ -168,40 +184,27 @@ class KlipperScreen(Gtk.Window):
if self._ws is not None and self._ws.connected: if self._ws is not None and self._ws.connected:
self._ws.close() self._ws.close()
self.connected_printer = None self.connected_printer = None
self.printer.state = "disconnected"
if self.files: if self.files:
self.files.reset() self.files.reset()
self.files = None self.files = None
if self.printer:
self.printer.reset()
self.printer = None
self.connecting = True self.connecting = True
self.initialized = False self.initialized = False
data = {
"moonraker_host": "127.0.0.1",
"moonraker_port": "7125",
"moonraker_api_key": False
}
logging.info(f"Connecting to printer: {name}") logging.info(f"Connecting to printer: {name}")
for printer in self._config.get_printers(): for printer in self.printers:
pname = list(printer)[0] if name == list(printer)[0]:
if pname != name: ind = self.printers.index(printer)
continue break
data = printer[pname]
break self.printer = self.printers[ind]["data"]
self.apiclient = KlippyRest(
self.printers[ind][name]["moonraker_host"],
self.printers[ind][name]["moonraker_port"],
self.printers[ind][name]["moonraker_api_key"],
)
self.apiclient = KlippyRest(data["moonraker_host"], data["moonraker_port"], data["moonraker_api_key"])
self.printer = Printer(state_execute)
self.printer.state_callbacks = {
"disconnected": self.state_disconnected,
"error": self.state_error,
"paused": self.state_paused,
"printing": self.state_printing,
"ready": self.state_ready,
"startup": self.state_startup,
"shutdown": self.state_shutdown
}
self.printer.busy_cb = self.process_busy_state
self.printer_initializing(_("Connecting to %s") % name, remove=True) self.printer_initializing(_("Connecting to %s") % name, remove=True)
self._ws = KlippyWebsocket(self, self._ws = KlippyWebsocket(self,
@@ -210,13 +213,30 @@ class KlipperScreen(Gtk.Window):
"on_message": self._websocket_callback, "on_message": self._websocket_callback,
"on_close": self.websocket_disconnected "on_close": self.websocket_disconnected
}, },
data["moonraker_host"], self.printers[ind][name]["moonraker_host"],
data["moonraker_port"] self.printers[ind][name]["moonraker_port"],
) )
self.files = KlippyFiles(self) self.files = KlippyFiles(self)
self._ws.initial_connect() self._ws.initial_connect()
def memory_trace(self):
snapshot = tracemalloc.take_snapshot()
snapshot = snapshot.filter_traces((
tracemalloc.Filter(False, "<frozen importlib._bootstrap_external>"),
tracemalloc.Filter(False, "<unknown>"),
tracemalloc.Filter(False, tracemalloc.__file__),
))
if self.initial_snapshot is None:
self.initial_snapshot = snapshot
logging.debug("[ Initial memory snapshot ]")
else:
self.switch_count += 1
logging.debug("[ Top 10 memory diffs (Shown: %d times)]", self.switch_count)
top_stats = snapshot.compare_to(self.initial_snapshot, 'lineno')
for stat in top_stats[:10]:
logging.debug(stat)
def ws_subscribe(self): def ws_subscribe(self):
requested_updates = { requested_updates = {
"objects": { "objects": {
@@ -627,8 +647,6 @@ class KlipperScreen(Gtk.Window):
self.connected_printer = None self.connected_printer = None
self.files.reset() self.files.reset()
self.files = None self.files = None
self.printer.reset()
self.printer = None
self.initialized = False self.initialized = False
self.connect_printer(self.connecting_to_printer) self.connect_printer(self.connecting_to_printer)
@@ -966,9 +984,13 @@ class KlipperScreen(Gtk.Window):
def update_size(self, *args): def update_size(self, *args):
self.width, self.height = self.get_size() self.width, self.height = self.get_size()
if self.vertical_mode != (self.width < self.height): new_ratio = self.width / self.height
new_mode = new_ratio < 1.0
ratio_delta = abs(self.aspect_ratio - new_ratio)
if ratio_delta > 0.1 and self.vertical_mode != new_mode:
self.reload_panels() self.reload_panels()
self.vertical_mode = self.width < self.height self.vertical_mode = new_mode
self.aspect_ratio = new_ratio
def main(): def main():
+1
View File
@@ -168,6 +168,7 @@ add_desktop_file()
DESKTOP=$(<$SCRIPTPATH/KlipperScreen.desktop) DESKTOP=$(<$SCRIPTPATH/KlipperScreen.desktop)
mkdir -p $HOME/.local/share/applications/ mkdir -p $HOME/.local/share/applications/
echo "$DESKTOP" | tee $HOME/.local/share/applications/KlipperScreen.desktop > /dev/null echo "$DESKTOP" | tee $HOME/.local/share/applications/KlipperScreen.desktop > /dev/null
sudo cp $SCRIPTPATH/../styles/icon.svg /usr/share/icons/hicolor/scalable/apps/KlipperScreen.svg
} }
start_KlipperScreen() start_KlipperScreen()
+2 -1
View File
@@ -4,5 +4,6 @@ requests==2.28.2
websocket-client==1.5.1 websocket-client==1.5.1
pycairo==1.22.0 pycairo==1.22.0
PyGObject==3.42.2 PyGObject==3.42.2
python-networkmanager==2.2
python-mpv==0.5.2 python-mpv==0.5.2
six==1.16.0
dbus-python==1.3.2
+1 -1
View File
@@ -1,7 +1,7 @@
[Desktop Entry] [Desktop Entry]
Name=KlipperScreen Name=KlipperScreen
GenericName=Touch screen GUI for Klipper via Moonraker GenericName=Touch screen GUI for Klipper via Moonraker
Icon=$HOME/KlipperScreen/styles/icon.svg Icon=KlipperScreen
Exec=sh -c "$HOME/.KlipperScreen-env/bin/python $HOME/KlipperScreen/screen.py" Exec=sh -c "$HOME/.KlipperScreen-env/bin/python $HOME/KlipperScreen/screen.py"
Terminal=false Terminal=false
Type=Application Type=Application