aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-03-19 15:17:53 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-03-19 15:17:53 -0400
commit99f3c992389b0d072c6c06d1246daf01a8e1c8c2 (patch)
tree36571a1a43779091ebc3d07ffc8769ad767d008a /klippy/extras
parentaba04bf3bd17463a38eb616f73531e60bb9dba73 (diff)
downloadkutter-99f3c992389b0d072c6c06d1246daf01a8e1c8c2.tar.gz
kutter-99f3c992389b0d072c6c06d1246daf01a8e1c8c2.tar.xz
kutter-99f3c992389b0d072c6c06d1246daf01a8e1c8c2.zip
display: Round temperature and position to nearest whole number
The "%d" formatting truncates a floating point number - use "%.0f" to show a rounded number. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras')
-rw-r--r--klippy/extras/display.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/klippy/extras/display.py b/klippy/extras/display.py
index ebbbe2d4..fa639873 100644
--- a/klippy/extras/display.py
+++ b/klippy/extras/display.py
@@ -578,15 +578,15 @@ class PrinterLCD:
def draw_heater(self, x, y, info):
temperature, target = info['temperature'], info['target']
if target and abs(temperature - target) > 2.:
- s = "%3d%s%d" % (temperature, self.lcd_chip.char_right_arrow, target)
+ s = "%3.0f%s%.0f" % (
+ temperature, self.lcd_chip.char_right_arrow, target)
else:
- s = "%3d" % (temperature,)
+ s = "%3.0f" % (temperature,)
if self.lcd_type == 'hd44780':
s += self.lcd_chip.char_degrees
self.lcd_chip.write_text(x, y, s)
def draw_percent(self, x, y, width, value):
- value = int(value * 100.)
- self.lcd_chip.write_text(x, y, ("%d%%" % (value)).center(width))
+ self.lcd_chip.write_text(x, y, ("%d%%" % (value * 100.,)).center(width))
def draw_time(self, x, y, seconds):
seconds = int(seconds)
self.lcd_chip.write_text(x, y, "%02d:%02d" % (
@@ -595,7 +595,7 @@ class PrinterLCD:
status = toolhead_info['status']
if status == 'Printing' or gcode_info['busy']:
pos = self.toolhead.get_position()
- status = "X%-4dY%-4dZ%-5.2f" % (pos[0], pos[1], pos[2])
+ status = "X%-4.0fY%-4.0fZ%-5.2f" % (pos[0], pos[1], pos[2])
self.lcd_chip.write_text(x, y, status)
def load_config(config):