simplyprint: implement direct layer detection
Klipper now has the ability to report the current layer on properly configured slicers. Prefer this value if available, otherwise fall back to layer detection. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
c48fe7307a
commit
91e48200d6
|
@ -844,8 +844,8 @@ class SimplyPrint(Subscribable):
|
||||||
def _update_job_progress(self) -> None:
|
def _update_job_progress(self) -> None:
|
||||||
job_info: Dict[str, Any] = {}
|
job_info: Dict[str, Any] = {}
|
||||||
est_time = self.cache.metadata.get("estimated_time")
|
est_time = self.cache.metadata.get("estimated_time")
|
||||||
if est_time is not None:
|
|
||||||
last_stats: Dict[str, Any] = self.job_state.get_last_stats()
|
last_stats: Dict[str, Any] = self.job_state.get_last_stats()
|
||||||
|
if est_time is not None:
|
||||||
duration: float = last_stats["print_duration"]
|
duration: float = last_stats["print_duration"]
|
||||||
time_left = max(0, int(est_time - duration + .5))
|
time_left = max(0, int(est_time - duration + .5))
|
||||||
last_time_left = self.cache.job_info.get("time", time_left + 60.)
|
last_time_left = self.cache.job_info.get("time", time_left + 60.)
|
||||||
|
@ -860,6 +860,8 @@ class SimplyPrint(Subscribable):
|
||||||
pct_prog = int(progress * 100 + .5)
|
pct_prog = int(progress * 100 + .5)
|
||||||
if pct_prog != self.cache.job_info.get("progress", 0):
|
if pct_prog != self.cache.job_info.get("progress", 0):
|
||||||
job_info["progress"] = int(progress * 100 + .5)
|
job_info["progress"] = int(progress * 100 + .5)
|
||||||
|
layer: Optional[int] = last_stats.get("info", {}).get("current_layer")
|
||||||
|
if layer is None:
|
||||||
layer = self.layer_detect.layer
|
layer = self.layer_detect.layer
|
||||||
if layer != self.cache.job_info.get("layer", -1):
|
if layer != self.cache.job_info.get("layer", -1):
|
||||||
job_info["layer"] = layer
|
job_info["layer"] = layer
|
||||||
|
|
Loading…
Reference in New Issue