├── simpleLCD.service
├── encoder.py
├── README.md
├── printerInterface.py
├── DWIN_Screen.py
├── LICENSE
└── dwinlcd.py
/simpleLCD.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=My LCD Service
3 | After=multi-user.target
4 |
5 | [Service]
6 | Type=idle
7 | ExecStartPre=/bin/sleep 30
8 | ExecStart=/bin/sh -c '/usr/bin/env python3 /home/pi/DWIN_T5UIC1_LCD/run.py > /tmp/lcd.log 2>&1'
9 |
10 | [Install]
11 | WantedBy=multi-user.target
12 |
13 |
--------------------------------------------------------------------------------
/encoder.py:
--------------------------------------------------------------------------------
1 | # Class to monitor a rotary encoder and update a value. You can either read the value when you need it, by calling getValue(), or
2 | # you can configure a callback which will be called whenever the value changes.
3 |
4 | import RPi.GPIO as GPIO
5 |
6 | class Encoder:
7 |
8 | def __init__(self, leftPin, rightPin, callback=None):
9 | self.leftPin = leftPin
10 | self.rightPin = rightPin
11 | self.value = 0
12 | self.state = '00'
13 | self.direction = None
14 | self.callback = callback
15 | GPIO.setup(self.leftPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
16 | GPIO.setup(self.rightPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
17 | GPIO.add_event_detect(self.leftPin, GPIO.BOTH, callback=self.transitionOccurred)
18 | GPIO.add_event_detect(self.rightPin, GPIO.BOTH, callback=self.transitionOccurred)
19 |
20 | def transitionOccurred(self, channel):
21 | p1 = GPIO.input(self.leftPin)
22 | p2 = GPIO.input(self.rightPin)
23 | newState = "{}{}".format(p1, p2)
24 |
25 | if self.state == "00": # Resting position
26 | if newState == "01": # Turned right 1
27 | self.direction = "R"
28 | elif newState == "10": # Turned left 1
29 | self.direction = "L"
30 |
31 | elif self.state == "01": # R1 or L3 position
32 | if newState == "11": # Turned right 1
33 | self.direction = "R"
34 | elif newState == "00": # Turned left 1
35 | if self.direction == "L":
36 | self.value = self.value - 1
37 | if self.callback is not None:
38 | self.callback(self.value)
39 |
40 | elif self.state == "10": # R3 or L1
41 | if newState == "11": # Turned left 1
42 | self.direction = "L"
43 | elif newState == "00": # Turned right 1
44 | if self.direction == "R":
45 | self.value = self.value + 1
46 | if self.callback is not None:
47 | self.callback(self.value)
48 |
49 | else: # self.state == "11"
50 | if newState == "01": # Turned left 1
51 | self.direction = "L"
52 | elif newState == "10": # Turned right 1
53 | self.direction = "R"
54 | elif newState == "00": # Skipped an intermediate 01 or 10 state, but if we know direction then a turn is complete
55 | if self.direction == "L":
56 | self.value = self.value - 1
57 | if self.callback is not None:
58 | self.callback(self.value)
59 | elif self.direction == "R":
60 | self.value = self.value + 1
61 | if self.callback is not None:
62 | self.callback(self.value)
63 |
64 | self.state = newState
65 |
66 | def getValue(self):
67 | return self.value
68 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DWIN_T5UIC1_LCD
2 |
3 | ## Python class for the Ender 3 V2 LCD runing klipper3d with OctoPrint / Moonraker
4 |
5 | https://www.klipper3d.org
6 |
7 | https://octoprint.org/
8 |
9 | https://github.com/arksine/moonraker
10 |
11 |
12 | ## Setup:
13 |
14 | ### [Disable Linux serial console](https://www.raspberrypi.org/documentation/configuration/uart.md)
15 | By default, the primary UART is assigned to the Linux console. If you wish to use the primary UART for other purposes, you must reconfigure Raspberry Pi OS. This can be done by using raspi-config:
16 |
17 | * Start raspi-config: `sudo raspi-config.`
18 | * Select option 3 - Interface Options.
19 | * Select option P6 - Serial Port.
20 | * At the prompt Would you like a login shell to be accessible over serial? answer 'No'
21 | * At the prompt Would you like the serial port hardware to be enabled? answer 'Yes'
22 | * Exit raspi-config and reboot the Pi for changes to take effect.
23 |
24 | For full instructions on how to use Device Tree overlays see [this page](https://www.raspberrypi.org/documentation/configuration/device-tree.md).
25 |
26 | In brief, add a line to the `/boot/config.txt` file to apply a Device Tree overlay.
27 |
28 | dtoverlay=disable-bt
29 |
30 | ### [Enabling Klipper's API socket](https://www.klipper3d.org/API_Server.html)
31 | By default, the Klipper's API socket is not enabled. In order to use the API server, the file /etc/default/klipper need to be updated form
32 |
33 | KLIPPY_ARGS="/home/pi/klipper/klippy/klippy.py /home/pi/printer.cfg -l /tmp/klippy.log"
34 | To:
35 |
36 | KLIPPY_ARGS="/home/pi/klipper/klippy/klippy.py /home/pi/printer.cfg -a /tmp/klippy_uds -l /tmp/klippy.log"
37 |
38 | ### Library requirements
39 |
40 | Thanks to [wolfstlkr](https://www.reddit.com/r/ender3v2/comments/mdtjvk/octoprint_klipper_v2_lcd/gspae7y)
41 |
42 | `sudo apt-get install python3-pip python3-gpiozero python3-serial git`
43 |
44 | `sudo pip3 install multitimer`
45 |
46 | `git clone https://github.com/odwdinc/DWIN_T5UIC1_LCD.git`
47 |
48 |
49 | ### Wire the display
50 | * Display <-> Raspberry Pi GPIO BCM
51 | * Rx = GPIO14 (Tx)
52 | * Tx = GPIO15 (Rx)
53 | * Ent = GPIO13
54 | * A = GPIO19
55 | * B = GPIO26
56 | * Vcc = 2 (5v)
57 | * Gnd = 6 (GND)
58 |
59 | ### Run The Code
60 |
61 | Enter the downloaded DWIN_T5UIC1_LCD folder.
62 | Make new file run.py and add
63 |
64 | ```python
65 | #!/usr/bin/env python3
66 | from dwinlcd import DWIN_LCD
67 |
68 | encoder_Pins = (26, 19)
69 | button_Pin = 13
70 | LCD_COM_Port = '/dev/ttyAMA0'
71 | API_Key = 'XXXXXX'
72 |
73 | DWINLCD = DWIN_LCD(
74 | LCD_COM_Port,
75 | encoder_Pins,
76 | button_Pin,
77 | API_Key
78 | )
79 | ```
80 |
81 | Run with `python3 ./run.py`
82 |
83 | # Run at boot:
84 |
85 | Note: Delay of 30s after boot to allow webservices to settal.
86 |
87 | path of `run.py` is expected to be `/home/pi/DWIN_T5UIC1_LCD/run.py`
88 |
89 | `sudo chmod +x run.py`
90 |
91 | `sudo chmod +x simpleLCD.service`
92 |
93 | `sudo mv simpleLCD.service /lib/systemd/system/simpleLCD.service`
94 |
95 | `sudo chmod 644 /lib/systemd/system/simpleLCD.service`
96 |
97 | `sudo systemctl daemon-reload`
98 |
99 | `sudo systemctl enable simpleLCD.service`
100 |
101 | `sudo reboot`
102 |
103 |
104 |
105 | # Status:
106 |
107 | ## Working:
108 |
109 | Print Menu:
110 |
111 | * List / Print jobs from OctoPrint / Moonraker
112 | * Auto swiching from to Print Menu on job start / end.
113 | * Display Print time, Progress, Temps, and Job name.
114 | * Pause / Resume / Cancle Job
115 | * Tune Menu: Print speed & Temps
116 |
117 | Perpare Menu:
118 |
119 | * Move / Jog toolhead
120 | * Disable stepper
121 | * Auto Home
122 | * Z offset (PROBE_CALIBRATE)
123 | * Preheat
124 | * cooldown
125 |
126 | Info Menu
127 |
128 | * Shows printer info.
129 |
130 | ## Notworking:
131 | * Save / Loding Preheat setting, hardcode on start can be changed in menu but will not retane on restart.
132 | * The Control: Motion Menu
133 |
--------------------------------------------------------------------------------
/printerInterface.py:
--------------------------------------------------------------------------------
1 | import threading
2 | import errno
3 | import select
4 | import socket
5 | import json
6 | import requests
7 | from requests.exceptions import ConnectionError
8 | import atexit
9 |
10 |
11 | class xyze_t:
12 | x = 0.0
13 | y = 0.0
14 | z = 0.0
15 | e = 0.0
16 | home_x = False
17 | home_y = False
18 | home_z = False
19 |
20 | def homing(self):
21 | self.home_x = False
22 | self.home_y = False
23 | self.home_z = False
24 |
25 |
26 | class AxisEnum:
27 | X_AXIS = 0
28 | A_AXIS = 0
29 | Y_AXIS = 1
30 | B_AXIS = 1
31 | Z_AXIS = 2
32 | C_AXIS = 2
33 | E_AXIS = 3
34 | X_HEAD = 4
35 | Y_HEAD = 5
36 | Z_HEAD = 6
37 | E0_AXIS = 3
38 | E1_AXIS = 4
39 | E2_AXIS = 5
40 | E3_AXIS = 6
41 | E4_AXIS = 7
42 | E5_AXIS = 8
43 | E6_AXIS = 9
44 | E7_AXIS = 10
45 | ALL_AXES = 0xFE
46 | NO_AXIS = 0xFF
47 |
48 |
49 | class HMI_value_t:
50 | E_Temp = 0
51 | Bed_Temp = 0
52 | Fan_speed = 0
53 | print_speed = 100
54 | Max_Feedspeed = 0.0
55 | Max_Acceleration = 0.0
56 | Max_Jerk = 0.0
57 | Max_Step = 0.0
58 | Move_X_scale = 0.0
59 | Move_Y_scale = 0.0
60 | Move_Z_scale = 0.0
61 | Move_E_scale = 0.0
62 | offset_value = 0.0
63 | show_mode = 0 # -1: Temperature control 0: Printing temperature
64 |
65 |
66 | class HMI_Flag_t:
67 | language = 0
68 | pause_flag = False
69 | pause_action = False
70 | print_finish = False
71 | done_confirm_flag = False
72 | select_flag = False
73 | home_flag = False
74 | heat_flag = False # 0: heating done 1: during heating
75 | ETempTooLow_flag = False
76 | leveling_offset_flag = False
77 | feedspeed_axis = AxisEnum()
78 | acc_axis = AxisEnum()
79 | jerk_axis = AxisEnum()
80 | step_axis = AxisEnum()
81 |
82 |
83 | class buzz_t:
84 | def tone(self, t, n):
85 | pass
86 |
87 |
88 | class material_preset_t:
89 | def __init__(self, name, hotend_temp, bed_temp, fan_speed=100):
90 | self.name = name
91 | self.hotend_temp = hotend_temp
92 | self.bed_temp = bed_temp
93 | self.fan_speed = fan_speed
94 |
95 |
96 | class klippySocket:
97 | def __init__(self, uds_filename, callback=None):
98 | self.webhook_socket_create(uds_filename)
99 | self.lock = threading.Lock()
100 | self.poll = select.poll()
101 | self.stop_threads = False
102 | self.poll.register(self.webhook_socket, select.POLLIN | select.POLLHUP)
103 | self.socket_data = ""
104 | self.t = threading.Thread(target=self.polling)
105 | self.callback = callback
106 | self.lines = []
107 | self.t.start()
108 | atexit.register(self.klippyExit)
109 |
110 | def klippyExit(self):
111 | print("Shuting down Klippy Socket")
112 | self.stop_threads = True
113 | self.t.join()
114 |
115 | def webhook_socket_create(self, uds_filename):
116 | self.webhook_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
117 | self.webhook_socket.setblocking(0)
118 | print("Waiting for connect to %s\n" % (uds_filename,))
119 | while 1:
120 | try:
121 | self.webhook_socket.connect(uds_filename)
122 | except socket.error as e:
123 | if e.errno == errno.ECONNREFUSED:
124 | time.sleep(0.1)
125 | continue
126 | print(
127 | "Unable to connect socket %s [%d,%s]\n" % (
128 | uds_filename, e.errno,
129 | errno.errorcode[e.errno]
130 | ))
131 | exit(-1)
132 | break
133 | print("Connection.\n")
134 |
135 | def process_socket(self):
136 | data = self.webhook_socket.recv(4096).decode()
137 | if not data:
138 | print("Socket closed\n")
139 | exit(0)
140 | parts = data.split('\x03')
141 | parts[0] = self.socket_data + parts[0]
142 | self.socket_data = parts.pop()
143 | for line in parts:
144 | if self.callback:
145 | self.callback(line)
146 |
147 | def queue_line(self, line):
148 | with self.lock:
149 | self.lines.append(line)
150 |
151 | def send_line(self):
152 | if len(self.lines) == 0:
153 | return
154 | line = self.lines.pop(0).strip()
155 | if not line or line.startswith('#'):
156 | return
157 | try:
158 | m = json.loads(line)
159 | except JSONDecodeError:
160 | print("ERROR: Unable to parse line\n")
161 | return
162 | cm = json.dumps(m, separators=(',', ':'))
163 | wdm = '{}\x03'.format(cm)
164 | self.webhook_socket.send(wdm.encode())
165 |
166 | def polling(self):
167 | while True:
168 | if self.stop_threads:
169 | break
170 | res = self.poll.poll(1000.)
171 | for fd, event in res:
172 | self.process_socket()
173 | with self.lock:
174 | self.send_line()
175 |
176 |
177 | class octoprintSocket:
178 | def __init__(self, address, port, api_key):
179 | self.s = requests.Session()
180 | self.s.headers.update({
181 | 'X-Api-Key': api_key,
182 | 'Content-Type': 'application/json'
183 | })
184 | self.base_address = 'http://' + address + ':' + str(port)
185 |
186 |
187 | class PrinterData:
188 | HAS_HOTEND = True
189 | HOTENDS = 1
190 | HAS_HEATED_BED = True
191 | HAS_FAN = False
192 | HAS_ZOFFSET_ITEM = True
193 | HAS_ONESTEP_LEVELING = False
194 | HAS_PREHEAT = True
195 | HAS_BED_PROBE = True
196 | PREVENT_COLD_EXTRUSION = True
197 | EXTRUDE_MINTEMP = 170
198 | EXTRUDE_MAXLENGTH = 200
199 |
200 | HEATER_0_MAXTEMP = 275
201 | HEATER_0_MINTEMP = 5
202 | HOTEND_OVERSHOOT = 15
203 |
204 | MAX_E_TEMP = (HEATER_0_MAXTEMP - (HOTEND_OVERSHOOT))
205 | MIN_E_TEMP = HEATER_0_MINTEMP
206 |
207 | BED_OVERSHOOT = 10
208 | BED_MAXTEMP = 150
209 | BED_MINTEMP = 5
210 |
211 | BED_MAX_TARGET = (BED_MAXTEMP - (BED_OVERSHOOT))
212 | MIN_BED_TEMP = BED_MINTEMP
213 |
214 | X_MIN_POS = 0.0
215 | Y_MIN_POS = 0.0
216 | Z_MIN_POS = 0.0
217 | Z_MAX_POS = 200
218 |
219 | Z_PROBE_OFFSET_RANGE_MIN = -20
220 | Z_PROBE_OFFSET_RANGE_MAX = 20
221 |
222 | buzzer = buzz_t()
223 |
224 | BABY_Z_VAR = 3.1
225 | feedrate_percentage = 100
226 | temphot = 0
227 | tempbed = 0
228 |
229 | HMI_ValueStruct = HMI_value_t()
230 | HMI_flag = HMI_Flag_t()
231 |
232 | current_position = xyze_t()
233 |
234 | thermalManager = {
235 | 'temp_bed': {'celsius': 20, 'target': 120},
236 | 'temp_hotend': [{'celsius': 20, 'target': 120}],
237 | 'fan_speed': [100]
238 | }
239 |
240 | material_preset = [
241 | material_preset_t('PLA', 180, 60),
242 | material_preset_t('ABS', 210, 100)
243 | ]
244 | fliles = None
245 | MACHINE_SIZE = "220x220x250"
246 | SHORT_BUILD_VERSION = "1.00"
247 | CORP_WEBSITE_E = "https://www.klipper3d.org/"
248 |
249 | def __init__(self, octoPrint_API_Key, octoPrint_URL='127.0.0.1'):
250 | self.op = octoprintSocket(octoPrint_URL, 80, octoPrint_API_Key)
251 | self.status = None
252 | print(self.op.base_address)
253 | self.ks = klippySocket('/tmp/klippy_uds', callback=self.klippy_callback)
254 | subscribe = {
255 | "id": 4001,
256 | "method": "objects/subscribe",
257 | "params": {
258 | "objects": {
259 | "toolhead": [
260 | "position"
261 | ]
262 | },
263 | "response_template": {}
264 | }
265 | }
266 | self.klippy_z_offset = '{"id": 4002, "method": "objects/query", "params": {"objects": {"configfile": ["config"]}}}'
267 | self.klippy_home = '{"id": 4003, "method": "objects/query", "params": {"objects": {"toolhead": ["homed_axes"]}}}'
268 |
269 | self.ks.queue_line(json.dumps(subscribe))
270 | self.ks.queue_line(self.klippy_z_offset)
271 | self.ks.queue_line(self.klippy_home)
272 |
273 | # ------------- Klipper Function ----------
274 |
275 | def klippy_callback(self, line):
276 | klippyData = json.loads(line)
277 | status = None
278 | if 'result' in klippyData:
279 | if 'status' in klippyData['result']:
280 | status = klippyData['result']['status']
281 | if 'params' in klippyData:
282 | if 'status' in klippyData['params']:
283 | status = klippyData['params']['status']
284 |
285 | if status:
286 | if 'toolhead' in status:
287 | if 'position' in status['toolhead']:
288 | self.current_position.x = status['toolhead']['position'][0]
289 | self.current_position.y = status['toolhead']['position'][1]
290 | self.current_position.z = status['toolhead']['position'][2]
291 | self.current_position.e = status['toolhead']['position'][3]
292 | if 'homed_axes' in status['toolhead']:
293 | if 'x' in status['toolhead']['homed_axes']:
294 | self.current_position.home_x = True
295 | if 'y' in status['toolhead']['homed_axes']:
296 | self.current_position.home_y = True
297 | if 'z' in status['toolhead']['homed_axes']:
298 | self.current_position.home_z = True
299 |
300 | if 'configfile' in status:
301 | if 'config' in status['configfile']:
302 | if 'bltouch' in status['configfile']['config']:
303 | if 'z_offset' in status['configfile']['config']['bltouch']:
304 | if status['configfile']['config']['bltouch']['z_offset']:
305 | self.BABY_Z_VAR = float(status['configfile']['config']['bltouch']['z_offset'])
306 |
307 | # print(status)
308 |
309 | def ishomed(self):
310 | if self.current_position.home_x and self.current_position.home_y and self.current_position.home_z:
311 | return True
312 | else:
313 | self.ks.queue_line(self.klippy_home)
314 | return False
315 |
316 | def offset_z(self, new_offset):
317 | print('new z offset:', new_offset)
318 | self.BABY_Z_VAR = new_offset
319 | self.queue('ACCEPT')
320 |
321 | def add_mm(self, axs, new_offset):
322 | gc = 'TESTZ Z={}'.format(new_offset)
323 | print(axs, gc)
324 | self.queue(gc)
325 |
326 | def probe_calibrate(self):
327 | self.queue('G28')
328 | self.queue('PROBE_CALIBRATE')
329 | self.queue('G1 Z0')
330 |
331 | # ------------- OctoPrint Function ----------
332 |
333 | def getREST(self, path):
334 | r = self.op.s.get(self.op.base_address + path)
335 | d = r.content.decode('utf-8')
336 | try:
337 | return json.loads(d)
338 | except JSONDecodeError:
339 | print('Decoding JSON has failed')
340 | return None
341 |
342 | def postREST(self, path, json):
343 | self.op.s.post(self.op.base_address + path, json=json)
344 |
345 | def init_Webservices(self):
346 | try:
347 | requests.get(self.op.base_address)
348 | except ConnectionError:
349 | print('Web site does not exist')
350 | return
351 | else:
352 | print('Web site exists')
353 | if self.getREST('/api/printer') is None:
354 | return
355 | self.update_variable()
356 | ppp = self.getREST('/api/printerprofiles/_default')
357 | self.SHORT_BUILD_VERSION = ppp['model']
358 | self.MACHINE_SIZE = "{}x{}x{}".format(
359 | int(ppp['volume']['depth']),
360 | int(ppp['volume']['width']),
361 | int(ppp['volume']['height'])
362 | )
363 | self.X_MAX_POS = int(ppp['volume']['width'])
364 | self.Y_MAX_POS = int(ppp['volume']['depth'])
365 |
366 | def GetFiles(self, refresh=False):
367 | if not self.fliles or refresh:
368 | self.fliles = self.getREST('/api/files')["files"]
369 | names = []
370 | for fl in self.fliles:
371 | names.append(fl["display"])
372 | return names
373 |
374 | def update_variable(self):
375 | self.state = self.getREST('/api/printer')
376 | Update = False
377 | if self.state:
378 | if "temperature" in self.state:
379 | if self.state["temperature"]["bed"]["actual"]:
380 | if self.thermalManager['temp_bed']['celsius'] != int(self.state["temperature"]["bed"]["actual"]):
381 | self.thermalManager['temp_bed']['celsius'] = int(self.state["temperature"]["bed"]["actual"])
382 | Update = True
383 |
384 | if self.state["temperature"]["bed"]["target"]:
385 | if self.thermalManager['temp_bed']['target'] != int(self.state["temperature"]["bed"]["target"]):
386 | self.thermalManager['temp_bed']['target'] = int(self.state["temperature"]["bed"]["target"])
387 | Update = True
388 |
389 | if self.state["temperature"]["tool0"]["target"]:
390 | if self.thermalManager['temp_hotend'][0]['target'] != int(self.state["temperature"]["tool0"]["target"]):
391 | self.thermalManager['temp_hotend'][0]['target'] = int(self.state["temperature"]["tool0"]["target"])
392 | Update = True
393 |
394 | if self.state["temperature"]["tool0"]["actual"]:
395 | if self.thermalManager['temp_hotend'][0]['celsius'] != int(self.state["temperature"]["tool0"]["actual"]):
396 | self.thermalManager['temp_hotend'][0]['celsius'] = int(self.state["temperature"]["tool0"]["actual"])
397 | Update = True
398 | self.job_Info = self.getREST('/api/job')
399 | if self.job_Info:
400 | self.file_name = self.job_Info['job']['file']['name']
401 | self.status = self.job_Info['state']
402 | self.HMI_flag.print_finish = self.getPercent() == 100.0
403 | return Update
404 |
405 | def printingIsPaused(self):
406 | return self.job_Info['state'] == "Paused" or self.job_Info['state'] == "Pausing"
407 |
408 | def getPercent(self):
409 | if self.job_Info["progress"]["completion"]:
410 | return self.job_Info["progress"]["completion"]
411 | else:
412 | return 0
413 |
414 | def duration(self):
415 | if self.job_Info["progress"]["printTimeLeft"]:
416 | return self.job_Info["progress"]["printTime"]
417 | return 0
418 |
419 | def remain(self):
420 | if self.job_Info["progress"]["printTimeLeft"]:
421 | return self.job_Info["progress"]["printTimeLeft"]
422 | return self.job_Info["progress"]["printTime"]
423 |
424 | def openAndPrintFile(self, filenum):
425 | self.file_name = self.fliles[filenum]["name"]
426 | self.postREST('/api/files/local/' + self.file_name, json={'command': 'select', 'print': True})
427 |
428 | def queue(self, gcode):
429 | print('Sending gcode: ', gcode)
430 | self.postREST('/api/printer/command', json={'command': gcode})
431 |
432 | def cancel_job(self):
433 | print('Canceling job:')
434 | self.postREST('/api/job', json={'command': 'cancel'})
435 |
436 | def pause_job(self):
437 | print('Pauseing job:')
438 | self.postREST('/api/job', json={'command': 'pause'})
439 |
440 | def resume_job(self):
441 | print('Resumeing job:')
442 | self.pause_job()
443 |
444 | def set_feedrate(self, fr):
445 | self.feedrate_percentage = fr
446 | self.postREST('/api/printer/printhead', json={'command': 'feedrate', 'factor': fr})
447 |
448 | def home(self, homeZ=False):
449 | axes = ["x", "y"]
450 | if homeZ:
451 | axes.append("z")
452 | print('Homeing:', axes)
453 | self.postREST('/api/printer/printhead', json={'command': 'home', 'axes': axes})
454 |
455 | def jog(self, x=False, y=False, z=False, e=False, speed=None):
456 | if e:
457 | json = {'command': 'extrude'}
458 | json['amount'] = e
459 | print('Extruding:', json)
460 | self.postREST('/api/printer/tool', json)
461 | return
462 |
463 | json = {'command': 'jog', 'absolute': True}
464 | if x:
465 | json['x'] = x
466 | if y:
467 | json['y'] = y
468 | if z:
469 | json['z'] = z
470 | if speed is not None:
471 | json['speed'] = speed
472 | print('Joging', json)
473 | self.postREST('/api/printer/printhead', json=json)
474 |
475 | def disable_all_heaters(self):
476 | self.postREST('/api/printer/bed', json={'command': 'target', 'target': 0})
477 | self.postREST('/api/printer/tool', json={'command': 'target', 'targets': {"tool0": 0}})
478 |
479 | def zero_fan_speeds(self):
480 | pass
481 |
482 | def preheat(self, profile):
483 | print('preheating:', profile)
484 | if profile == "ABS":
485 | self.postREST('/api/printer/bed', json={'command': 'target', 'target': self.material_preset[1].bed_temp})
486 | self.postREST('/api/printer/tool', json={'command': 'target', 'targets': {"tool0": self.material_preset[1].hotend_temp}})
487 |
488 | elif profile == "PLA":
489 | self.postREST('/api/printer/bed', json={'command': 'target', 'target': self.material_preset[0].bed_temp})
490 | self.postREST('/api/printer/tool', json={'command': 'target', 'targets': {"tool0": self.material_preset[0].hotend_temp}})
491 |
492 | def save_settings(self):
493 | print('saveing settings')
494 | return True
495 |
496 | def setTargetHotend(self, val, num):
497 | print('new Hotend Target:', num, 'Temp:', val)
498 | if num == 0:
499 | self.postREST('/api/printer/tool', json={'command': 'target', 'targets': {"tool0": val}})
500 | else:
501 | self.postREST('/api/printer/bed', json={'command': 'target', 'target': val})
502 |
--------------------------------------------------------------------------------
/DWIN_Screen.py:
--------------------------------------------------------------------------------
1 | import time
2 | import math
3 | import serial
4 | import struct
5 |
6 |
7 | class T5UIC1_LCD:
8 | address = 0x2A
9 | DWIN_BufTail = [0xCC, 0x33, 0xC3, 0x3C]
10 | DWIN_SendBuf = []
11 | databuf = [None] * 26
12 | recnum = 0
13 |
14 | RECEIVED_NO_DATA = 0x00
15 | RECEIVED_SHAKE_HAND_ACK = 0x01
16 |
17 | FHONE = b'\xAA'
18 |
19 | DWIN_WIDTH = 272
20 | DWIN_HEIGHT = 480
21 |
22 | # 3-.0:The font size, 0x00-0x09, corresponds to the font size below:
23 | # 0x00=6*12 0x01=8*16 0x02=10*20 0x03=12*24 0x04=14*28
24 | # 0x05=16*32 0x06=20*40 0x07=24*48 0x08=28*56 0x09=32*64
25 |
26 | font6x12 = 0x00
27 | font8x16 = 0x01
28 | font10x20 = 0x02
29 | font12x24 = 0x03
30 | font14x28 = 0x04
31 | font16x32 = 0x05
32 | font20x40 = 0x06
33 | font24x48 = 0x07
34 | font28x56 = 0x08
35 | font32x64 = 0x09
36 |
37 | # Color
38 | Color_White = 0xFFFF
39 | Color_Yellow = 0xFF0F
40 | Color_Bg_Window = 0x31E8 # Popup background color
41 | Color_Bg_Blue = 0x1125 # Dark blue background color
42 | Color_Bg_Black = 0x0841 # Black background color
43 | Color_Bg_Red = 0xF00F # Red background color
44 | Popup_Text_Color = 0xD6BA # Popup font background color
45 | Line_Color = 0x3A6A # Split line color
46 | Rectangle_Color = 0xEE2F # Blue square cursor color
47 | Percent_Color = 0xFE29 # Percentage color
48 | BarFill_Color = 0x10E4 # Fill color of progress bar
49 | Select_Color = 0x33BB # Selected color
50 |
51 | DWIN_FONT_MENU = font8x16
52 | DWIN_FONT_STAT = font10x20
53 | DWIN_FONT_HEAD = font10x20
54 |
55 | # Dwen serial screen initialization
56 | # Passing parameters: serial port number
57 | # DWIN screen uses serial port 1 to send
58 | def __init__(self, USARTx):
59 | self.MYSERIAL1 = serial.Serial(USARTx, 115200, timeout=1)
60 | # self.bus = SMBus(1)
61 | # self.DWIN_SendBuf = self.FHONE
62 | print("\nDWIN handshake ")
63 | while not self.Handshake():
64 | pass
65 | print("DWIN OK.")
66 | self.JPG_ShowAndCache(0)
67 | self.Frame_SetDir(1)
68 | self.UpdateLCD()
69 |
70 | def Byte(self, bval):
71 | self.DWIN_SendBuf += int(bval).to_bytes(1, byteorder='big')
72 |
73 | def Word(self, wval):
74 | self.DWIN_SendBuf += int(wval).to_bytes(2, byteorder='big')
75 |
76 | def Long(self, lval):
77 | self.DWIN_SendBuf += int(lval).to_bytes(4, byteorder='big')
78 |
79 | def D64(self, value):
80 | self.DWIN_SendBuf += int(value).to_bytes(8, byteorder='big')
81 |
82 | def String(self, string):
83 | self.DWIN_SendBuf += string.encode('utf-8')
84 |
85 | # Send the data in the buffer and the packet end
86 | def Send(self):
87 | # for i in self.DWIN_BufTail:
88 | # self.Byte(i)
89 | # self.bus.write_i2c_block_data(self.address, 0, self.DWIN_SendBuf)
90 | # self.bus.write_i2c_block_data(self.address, 0, self.DWIN_BufTail)
91 |
92 | self.MYSERIAL1.write(self.DWIN_SendBuf)
93 | self.MYSERIAL1.write(self.DWIN_BufTail)
94 |
95 | self.DWIN_SendBuf = self.FHONE
96 | time.sleep(0.001)
97 |
98 | def Read(self, lend=1):
99 | bit = self.bus.read_i2c_block_data(self.address, 0, lend)
100 | if lend == 1:
101 | return bytes(bit)
102 | return bit
103 |
104 | # /*-------------------------------------- System variable function --------------------------------------*/
105 |
106 | # Handshake (1: Success, 0: Fail)
107 | def Handshake(self):
108 | i = 0
109 | self.Byte(0x00)
110 | self.Send()
111 | time.sleep(0.1)
112 | # while (self.recnum < 26):
113 | while (self.MYSERIAL1.in_waiting and self.recnum < 26):
114 | # self.databuf[self.recnum] = struct.unpack('B', self.Read())[0]
115 | self.databuf[self.recnum] = struct.unpack('B', self.MYSERIAL1.read())[0]
116 |
117 | # ignore the invalid data
118 | if self.databuf[0] != 0xAA: # prevent the program from running.
119 | if(self.recnum > 0):
120 | self.recnum = 0
121 | self.databuf = [None] * 26
122 | continue
123 | time.sleep(.010)
124 | self.recnum += 1
125 | return (self.recnum >= 3 and self.databuf[0] == 0xAA and self.databuf[1] == 0 and chr(self.databuf[2]) == 'O' and chr(self.databuf[3]) == 'K')
126 |
127 | # Set the backlight luminance
128 | # luminance: (0x00-0xFF)
129 | def Backlight_SetLuminance(self, luminance):
130 | self.Byte(0x30)
131 | self.Byte(_MAX(luminance, 0x1F))
132 | self.Send()
133 |
134 | # Set screen display direction
135 | # dir: 0=0°, 1=90°, 2=180°, 3=270°
136 | def Frame_SetDir(self, dir):
137 | self.Byte(0x34)
138 | self.Byte(0x5A)
139 | self.Byte(0xA5)
140 | self.Byte(dir)
141 | self.Send()
142 |
143 | # Update display
144 | def UpdateLCD(self):
145 | self.Byte(0x3D)
146 | self.Send()
147 |
148 | # /*---------------------------------------- Drawing functions ----------------------------------------*/
149 |
150 | # Clear screen
151 | # color: Clear screen color
152 | def Frame_Clear(self, color):
153 | self.Byte(0x01)
154 | self.Word(color)
155 | self.Send()
156 |
157 | # Draw a point
158 | # width: point width 0x01-0x0F
159 | # height: point height 0x01-0x0F
160 | # x,y: upper left point
161 | def Draw_Point(self, width, height, x, y):
162 | self.Byte(0x02)
163 | self.Byte(width)
164 | self.Byte(height)
165 | self.Word(x)
166 | self.Word(y)
167 | self.Send()
168 |
169 | # ___________________________________Draw points ____________________________________________\\
170 | # Command: frame header + command + color of drawing point + pixel size of drawing point (Nx, Ny) + position of drawing point [(X1,Y1)+(X2,Y2)+.........]+ End of frame
171 | # Set point; processing time=0.4*Nx*Ny*number of set points uS.
172 | # Color: Set point color.
173 | # Nx: Actual pixel size in X direction, 0x01-0x0F.
174 | # Ny: Actual pixel size in Y direction, 0x01-0x0F.
175 | # (Xn, Yn): Set point coordinate sequence.
176 | # Example: AA 02 F8 00 04 04 00 08 00 08 CC 33 C3 3C
177 | # /**************Drawing point protocol command can draw multiple points at a time (this function only draws pixels in one position) ********** *****/
178 | def DrawPoint(self, Color, Nx, Ny, X1, Y1): # Draw some
179 | self.Byte(0x02)
180 | self.Word(Color)
181 | self.Byte(int(Nx))
182 | self.Byte(int(Ny))
183 | self.Word(int(X1))
184 | self.Word(int(Y1))
185 | self.Send()
186 |
187 | # Draw a line
188 | # color: Line segment color
189 | # xStart/yStart: Start point
190 | # xEnd/yEnd: End point
191 | def Draw_Line(self, color, xStart, yStart, xEnd, yEnd):
192 | self.Byte(0x03)
193 | self.Word(color)
194 | self.Word(xStart)
195 | self.Word(yStart)
196 | self.Word(xEnd)
197 | self.Word(yEnd)
198 | self.Send()
199 |
200 | # Draw a rectangle
201 | # mode: 0=frame, 1=fill, 2=XOR fill
202 | # color: Rectangle color
203 | # xStart/yStart: upper left point
204 | # xEnd/yEnd: lower right point
205 | def Draw_Rectangle(self, mode, color, xStart, yStart, xEnd, yEnd):
206 | self.Byte(0x05)
207 | self.Byte(mode)
208 | self.Word(color)
209 | self.Word(xStart)
210 | self.Word(yStart)
211 | self.Word(xEnd)
212 | self.Word(yEnd)
213 | self.Send()
214 |
215 | # Move a screen area
216 | # mode: 0, circle shift; 1, translation
217 | # dir: 0=left, 1=right, 2=up, 3=down
218 | # dis: Distance
219 | # color: Fill color
220 | # xStart/yStart: upper left point
221 | # xEnd/yEnd: bottom right point
222 | def Frame_AreaMove(self, mode, dir, dis, color, xStart, yStart, xEnd, yEnd):
223 | self.Byte(0x09)
224 | self.Byte((mode << 7) | dir)
225 | self.Word(dis)
226 | self.Word(color)
227 | self.Word(xStart)
228 | self.Word(yStart)
229 | self.Word(xEnd)
230 | self.Word(yEnd)
231 | self.Send()
232 |
233 | # ____________________________Draw a circle________________________________\\
234 | # Color: circle color
235 | # x0: the abscissa of the center of the circle
236 | # y0: ordinate of the center of the circle
237 | # r: circle radius
238 | def Draw_Circle(self, Color, x0, y0, r): # Draw a circle
239 | b = 0
240 | a = 0
241 | while(a <= b):
242 | b = math.sqrt(r * r - a * a)
243 | while(a == 0):
244 | b = b - 1
245 | break
246 | self.DrawPoint(Color, 1, 1, x0 + a, y0 + b) # Draw some sector 1
247 | self.DrawPoint(Color, 1, 1, x0 + b, y0 + a) # Draw some sector 2
248 | self.DrawPoint(Color, 1, 1, x0 + b, y0 - a) # Draw some sector 3
249 | self.DrawPoint(Color, 1, 1, x0 + a, y0 - b) # Draw some sector 4
250 |
251 | self.DrawPoint(Color, 1, 1, x0 - a, y0 - b) # Draw some sector 5
252 | self.DrawPoint(Color, 1, 1, x0 - b, y0 - a) # Draw some sector 6
253 | self.DrawPoint(Color, 1, 1, x0 - b, y0 + a) # Draw some sector 7
254 | self.DrawPoint(Color, 1, 1, x0 - a, y0 + b) # Draw some sector 8
255 | a += 1
256 |
257 | # ____________________________Circular Filling________________________________\\
258 | # FColor: circle fill color
259 | # x0: the abscissa of the center of the circle
260 | # y0: ordinate of the center of the circle
261 | # r: circle radius
262 | def CircleFill(self, FColor, x0, y0, r): # Round filling
263 | b = 0
264 | for i in range(r, 0, -1):
265 | a = 0
266 | while(a <= b):
267 | b = math.sqrt(i * i - a * a)
268 | while(a == 0):
269 | b = b - 1
270 | break
271 | self.DrawPoint(FColor, 2, 2, x0 + a, y0 + b) # Draw some sector 1
272 | self.DrawPoint(FColor, 2, 2, x0 + b, y0 + a) # raw some sector 2
273 | self.DrawPoint(FColor, 2, 2, x0 + b, y0 - a) # Draw some sector 3
274 | self.DrawPoint(FColor, 2, 2, x0 + a, y0 - b) # Draw some sector 4
275 |
276 | self.DrawPoint(FColor, 2, 2, x0 - a, y0 - b) # Draw some sector 5
277 | self.DrawPoint(FColor, 2, 2, x0 - b, y0 - a) # Draw some sector 6
278 | self.DrawPoint(FColor, 2, 2, x0 - b, y0 + a) # Draw some sector 7
279 | self.DrawPoint(FColor, 2, 2, x0 - a, y0 + b) # Draw some sector 8
280 | a = a + 2
281 |
282 | # /*---------------------------------------- Text related functions ----------------------------------------*/
283 |
284 | # Draw a string
285 | # widthAdjust: True=self-adjust character width; False=no adjustment
286 | # bShow: True=display background color; False=don't display background color
287 | # size: Font size
288 | # color: Character color
289 | # bColor: Background color
290 | # x/y: Upper-left coordinate of the string
291 | # *string: The string
292 | def Draw_String(self, widthAdjust, bShow, size, color, bColor, x, y, string):
293 | self.Byte(0x11)
294 | # Bit 7: widthAdjust
295 | # Bit 6: bShow
296 | # Bit 5-4: Unused (0)
297 | # Bit 3-0: size
298 | self.Byte((widthAdjust * 0x80) | (bShow * 0x40) | size)
299 | self.Word(color)
300 | self.Word(bColor)
301 | self.Word(x)
302 | self.Word(y)
303 | self.String(string)
304 | self.Send()
305 |
306 | # Draw a positive integer
307 | # bShow: True=display background color; False=don't display background color
308 | # zeroFill: True=zero fill; False=no zero fill
309 | # zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
310 | # size: Font size
311 | # color: Character color
312 | # bColor: Background color
313 | # iNum: Number of digits
314 | # x/y: Upper-left coordinate
315 | # value: Integer value
316 | def Draw_IntValue(self, bShow, zeroFill, zeroMode, size, color, bColor, iNum, x, y, value):
317 | self.Byte(0x14)
318 | # Bit 7: bshow
319 | # Bit 6: 1 = signed; 0 = unsigned number;
320 | # Bit 5: zeroFill
321 | # Bit 4: zeroMode
322 | # Bit 3-0: size
323 | self.Byte((bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size)
324 | self.Word(color)
325 | self.Word(bColor)
326 | self.Byte(iNum)
327 | self.Byte(0) # fNum
328 | self.Word(x)
329 | self.Word(y)
330 | self.D64(value)
331 | self.Send()
332 |
333 | # Draw a floating point number
334 | # bShow: True=display background color; False=don't display background color
335 | # zeroFill: True=zero fill; False=no zero fill
336 | # zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
337 | # size: Font size
338 | # color: Character color
339 | # bColor: Background color
340 | # iNum: Number of whole digits
341 | # fNum: Number of decimal digits
342 | # x/y: Upper-left point
343 | # value: Float value
344 | def Draw_FloatValue(self, bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value):
345 | self.Byte(0x14)
346 | self.Byte((bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size)
347 | self.Word(color)
348 | self.Word(bColor)
349 | self.Byte(iNum)
350 | self.Byte(fNum)
351 | self.Word(x)
352 | self.Word(y)
353 | self.Long(value)
354 | self.Send()
355 |
356 | def Draw_Signed_Float(self, size, bColor, iNum, fNum, x, y, value):
357 | if value < 0:
358 | self.Draw_String(False, True, size, self.Color_White, bColor, x - 6, y, "-")
359 | self.Draw_FloatValue(True, True, 0, size, self.Color_White, bColor, iNum, fNum, x, y, -value)
360 | else:
361 | self.Draw_String(False, True, size, self.Color_White, bColor, x - 6, y, " ")
362 | self.Draw_FloatValue(True, True, 0, size, self.Color_White, bColor, iNum, fNum, x, y, value)
363 |
364 | # /*---------------------------------------- Picture related functions ----------------------------------------*/
365 |
366 | # Draw JPG and cached in #0 virtual display area
367 | # id: Picture ID
368 | def JPG_ShowAndCache(self, id):
369 | self.Word(0x2200)
370 | self.Byte(id)
371 | self.Send() # AA 23 00 00 00 00 08 00 01 02 03 CC 33 C3 3C
372 |
373 | # Draw an Icon
374 | # libID: Icon library ID
375 | # picID: Icon ID
376 | # x/y: Upper-left point
377 | def ICON_Show(self, libID, picID, x, y):
378 | if x > self.DWIN_WIDTH - 1:
379 | x = self.DWIN_WIDTH - 1
380 | if y > self.DWIN_HEIGHT - 1:
381 | y = self.DWIN_HEIGHT - 1
382 | self.Byte(0x23)
383 | self.Word(x)
384 | self.Word(y)
385 | self.Byte(0x80 | libID)
386 | self.Byte(picID)
387 | self.Send()
388 |
389 | # Unzip the JPG picture to a virtual display area
390 | # n: Cache index
391 | # id: Picture ID
392 | def JPG_CacheToN(self, n, id):
393 | self.Byte(0x25)
394 | self.Byte(n)
395 | self.Byte(id)
396 | self.Send()
397 |
398 | def JPG_CacheTo1(self, id):
399 | self.JPG_CacheToN(1, id)
400 |
401 | # Copy area from virtual display area to current screen
402 | # cacheID: virtual area number
403 | # xStart/yStart: Upper-left of virtual area
404 | # xEnd/yEnd: Lower-right of virtual area
405 | # x/y: Screen paste point
406 | def Frame_AreaCopy(self, cacheID, xStart, yStart, xEnd, yEnd, x, y):
407 | self.Byte(0x27)
408 | self.Byte(0x80 | cacheID)
409 | self.Word(xStart)
410 | self.Word(yStart)
411 | self.Word(xEnd)
412 | self.Word(yEnd)
413 | self.Word(x)
414 | self.Word(y)
415 | self.Send()
416 |
417 | def Frame_TitleCopy(self, id, x1, y1, x2, y2):
418 | self.Frame_AreaCopy(id, x1, y1, x2, y2, 14, 8)
419 |
420 | # Animate a series of icons
421 | # animID: Animation ID; 0x00-0x0F
422 | # animate: True on; False off;
423 | # libID: Icon library ID
424 | # picIDs: Icon starting ID
425 | # picIDe: Icon ending ID
426 | # x/y: Upper-left point
427 | # interval: Display time interval, unit 10mS
428 | def ICON_Animation(self, animID, animate, libID, picIDs, picIDe, x, y, interval):
429 | if x > self.DWIN_WIDTH - 1:
430 | x = self.DWIN_WIDTH - 1
431 | if y > self.DWIN_HEIGHT - 1:
432 | y = self.DWIN_HEIGHT - 1
433 | self.Byte(0x28)
434 | self.Word(x)
435 | self.Word(y)
436 | # Bit 7: animation on or off
437 | # Bit 6: start from begin or end
438 | # Bit 5-4: unused (0)
439 | # Bit 3-0: animID
440 | self.Byte((animate * 0x80) | 0x40 | animID)
441 | self.Byte(libID)
442 | self.Byte(picIDs)
443 | self.Byte(picIDe)
444 | self.Byte(interval)
445 | self.Send()
446 |
447 | # Animation Control
448 | # state: 16 bits, each bit is the state of an animation id
449 | def ICON_AnimationControl(self, state):
450 | self.Byte(0x28)
451 | self.Word(state)
452 | self.Send()
453 |
454 | # ____________________________Display QR code ________________________________\\
455 | # QR_Pixel: The pixel size occupied by each point of the QR code: 0x01-0x0F (1-16)
456 | # (Nx, Ny): The coordinates of the upper left corner displayed by the QR code
457 | # str: multi-bit data
458 | # /**************The size of the QR code is (46*QR_Pixel)*(46*QR_Pixle) dot matrix************/
459 | def QR_Code(self, QR_Pixel, Xs, Ys, data): # Display QR code
460 | self.Byte(0x21) # Display QR code instruction
461 | self.Word(Xs) # Two-dimensional code Xs coordinate high eight
462 | self.Word(Ys) # The Ys coordinate of the QR code is eight high
463 |
464 | if(QR_Pixel <= 6): # Set the upper limit of pixels according to the actual screen size
465 | self.Byte(QR_Pixel) # Two-dimensional code pixel size
466 | else:
467 | self.Byte(0x06) # The pixel size of the QR code exceeds the default of 1
468 | self.String(data)
469 | self.Send()
470 | # /*---------------------------------------- Memory functions ----------------------------------------*/
471 | # The LCD has an additional 32KB SRAM and 16KB Flash
472 |
473 | # Data can be written to the sram and save to one of the jpeg page files
474 |
475 | # Write Data Memory
476 | # command 0x31
477 | # Type: Write memory selection; 0x5A=SRAM; 0xA5=Flash
478 | # Address: Write data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
479 | # Data: data
480 | #
481 | # Flash writing returns 0xA5 0x4F 0x4B
482 |
483 | # Read Data Memory
484 | # command 0x32
485 | # Type: Read memory selection; 0x5A=SRAM; 0xA5=Flash
486 | # Address: Read data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
487 | # Length: leangth of data to read; 0x01-0xF0
488 | #
489 | # Response:
490 | # Type, Address, Length, Data
491 |
492 | # Write Picture Memory
493 | # Write the contents of the 32KB SRAM data memory into the designated image memory space
494 | # Issued: 0x5A, 0xA5, PIC_ID
495 | # Response: 0xA5 0x4F 0x4B
496 | #
497 | # command 0x33
498 | # 0x5A, 0xA5
499 | # PicId: Picture Memory location, 0x00-0x0F
500 | #
501 | # Flash writing returns 0xA5 0x4F 0x4B
502 | # def sendPicture(self, PicId, SRAM, Address, data):
503 | # self.Byte(0x31)
504 | # if SRAM:
505 | # self.Byte(0x5A)
506 | # else:
507 | # self.Byte(0xA5)
508 | # self.Word(Address)
509 | # self.DWIN_SendBuf += data
510 | # self.Send()
511 |
512 | # --------------------------------------------------------------#
513 | # --------------------------------------------------------------#
514 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/dwinlcd.py:
--------------------------------------------------------------------------------
1 | import time
2 | import multitimer
3 | import atexit
4 |
5 | from encoder import Encoder
6 | from RPi import GPIO
7 |
8 | from printerInterface import PrinterData
9 | from DWIN_Screen import T5UIC1_LCD
10 |
11 |
12 | def current_milli_time():
13 | return round(time.time() * 1000)
14 |
15 |
16 | def _MAX(lhs, rhs):
17 | if lhs > rhs:
18 | return lhs
19 | else:
20 | return rhs
21 |
22 |
23 | def _MIN(lhs, rhs):
24 | if lhs < rhs:
25 | return lhs
26 | else:
27 | return rhs
28 |
29 |
30 | class select_t:
31 | now = 0
32 | last = 0
33 |
34 | def set(self, v):
35 | self.now = self.last = v
36 |
37 | def reset(self):
38 | self.set(0)
39 |
40 | def changed(self):
41 | c = (self.now != self.last)
42 | if c:
43 | self.last = self.now
44 | return c
45 |
46 | def dec(self):
47 | if (self.now):
48 | self.now -= 1
49 | return self.changed()
50 |
51 | def inc(self, v):
52 | if (self.now < (v - 1)):
53 | self.now += 1
54 | else:
55 | self.now = (v - 1)
56 | return self.changed()
57 |
58 |
59 | class DWIN_LCD:
60 |
61 | TROWS = 6
62 | MROWS = TROWS - 1 # Total rows, and other-than-Back
63 | TITLE_HEIGHT = 30 # Title bar height
64 | MLINE = 53 # Menu line height
65 | LBLX = 60 # Menu item label X
66 | MENU_CHR_W = 8
67 | STAT_CHR_W = 10
68 |
69 | dwin_abort_flag = False # Flag to reset feedrate, return to Home
70 |
71 | MSG_STOP_PRINT = "Stop Print"
72 | MSG_PAUSE_PRINT = "Pausing..."
73 |
74 | DWIN_SCROLL_UP = 2
75 | DWIN_SCROLL_DOWN = 3
76 |
77 | select_page = select_t()
78 | select_file = select_t()
79 | select_print = select_t()
80 | select_prepare = select_t()
81 |
82 | select_control = select_t()
83 | select_axis = select_t()
84 | select_temp = select_t()
85 | select_motion = select_t()
86 | select_tune = select_t()
87 | select_PLA = select_t()
88 | select_ABS = select_t()
89 |
90 | index_file = MROWS
91 | index_prepare = MROWS
92 | index_control = MROWS
93 | index_leveling = MROWS
94 | index_tune = MROWS
95 |
96 | MainMenu = 0
97 | SelectFile = 1
98 | Prepare = 2
99 | Control = 3
100 | Leveling = 4
101 | PrintProcess = 5
102 | AxisMove = 6
103 | TemperatureID = 7
104 | Motion = 8
105 | Info = 9
106 | Tune = 10
107 | PLAPreheat = 11
108 | ABSPreheat = 12
109 | MaxSpeed = 13
110 | MaxSpeed_value = 14
111 | MaxAcceleration = 15
112 | MaxAcceleration_value = 16
113 | MaxJerk = 17
114 | MaxJerk_value = 18
115 | Step = 19
116 | Step_value = 20
117 |
118 | # Last Process ID
119 | Last_Prepare = 21
120 |
121 | # Back Process ID
122 | Back_Main = 22
123 | Back_Print = 23
124 |
125 | # Date variable ID
126 | Move_X = 24
127 | Move_Y = 25
128 | Move_Z = 26
129 | Extruder = 27
130 | ETemp = 28
131 | Homeoffset = 29
132 | BedTemp = 30
133 | FanSpeed = 31
134 | PrintSpeed = 32
135 |
136 | Print_window = 33
137 | Popup_Window = 34
138 |
139 | MINUNITMULT = 10
140 |
141 | ENCODER_DIFF_NO = 0 # no state
142 | ENCODER_DIFF_CW = 1 # clockwise rotation
143 | ENCODER_DIFF_CCW = 2 # counterclockwise rotation
144 | ENCODER_DIFF_ENTER = 3 # click
145 | ENCODER_WAIT = 150
146 | EncoderRate = False
147 |
148 | SCROLL_UPDATE_INTERVAL = 2000
149 |
150 | dwin_zoffset = 0.0
151 | last_zoffset = 0.0
152 |
153 | # Picture ID
154 | Start_Process = 0
155 | Language_English = 1
156 | Language_Chinese = 2
157 |
158 | # ICON ID
159 | ICON = 0x09
160 |
161 | ICON_LOGO = 0
162 | ICON_Print_0 = 1
163 | ICON_Print_1 = 2
164 | ICON_Prepare_0 = 3
165 | ICON_Prepare_1 = 4
166 | ICON_Control_0 = 5
167 | ICON_Control_1 = 6
168 | ICON_Leveling_0 = 7
169 | ICON_Leveling_1 = 8
170 | ICON_HotendTemp = 9
171 | ICON_BedTemp = 10
172 | ICON_Speed = 11
173 | ICON_Zoffset = 12
174 | ICON_Back = 13
175 | ICON_File = 14
176 | ICON_PrintTime = 15
177 | ICON_RemainTime = 16
178 | ICON_Setup_0 = 17
179 | ICON_Setup_1 = 18
180 | ICON_Pause_0 = 19
181 | ICON_Pause_1 = 20
182 | ICON_Continue_0 = 21
183 | ICON_Continue_1 = 22
184 | ICON_Stop_0 = 23
185 | ICON_Stop_1 = 24
186 | ICON_Bar = 25
187 | ICON_More = 26
188 |
189 | ICON_Axis = 27
190 | ICON_CloseMotor = 28
191 | ICON_Homing = 29
192 | ICON_SetHome = 30
193 | ICON_PLAPreheat = 31
194 | ICON_ABSPreheat = 32
195 | ICON_Cool = 33
196 | ICON_Language = 34
197 |
198 | ICON_MoveX = 35
199 | ICON_MoveY = 36
200 | ICON_MoveZ = 37
201 | ICON_Extruder = 38
202 |
203 | ICON_Temperature = 40
204 | ICON_Motion = 41
205 | ICON_WriteEEPROM = 42
206 | ICON_ReadEEPROM = 43
207 | ICON_ResumeEEPROM = 44
208 | ICON_Info = 45
209 |
210 | ICON_SetEndTemp = 46
211 | ICON_SetBedTemp = 47
212 | ICON_FanSpeed = 48
213 | ICON_SetPLAPreheat = 49
214 | ICON_SetABSPreheat = 50
215 |
216 | ICON_MaxSpeed = 51
217 | ICON_MaxAccelerated = 52
218 | ICON_MaxJerk = 53
219 | ICON_Step = 54
220 | ICON_PrintSize = 55
221 | ICON_Version = 56
222 | ICON_Contact = 57
223 | ICON_StockConfiguraton = 58
224 | ICON_MaxSpeedX = 59
225 | ICON_MaxSpeedY = 60
226 | ICON_MaxSpeedZ = 61
227 | ICON_MaxSpeedE = 62
228 | ICON_MaxAccX = 63
229 | ICON_MaxAccY = 64
230 | ICON_MaxAccZ = 65
231 | ICON_MaxAccE = 66
232 | ICON_MaxSpeedJerkX = 67
233 | ICON_MaxSpeedJerkY = 68
234 | ICON_MaxSpeedJerkZ = 69
235 | ICON_MaxSpeedJerkE = 70
236 | ICON_StepX = 71
237 | ICON_StepY = 72
238 | ICON_StepZ = 73
239 | ICON_StepE = 74
240 | ICON_Setspeed = 75
241 | ICON_SetZOffset = 76
242 | ICON_Rectangle = 77
243 | ICON_BLTouch = 78
244 | ICON_TempTooLow = 79
245 | ICON_AutoLeveling = 80
246 | ICON_TempTooHigh = 81
247 | ICON_NoTips_C = 82
248 | ICON_NoTips_E = 83
249 | ICON_Continue_C = 84
250 | ICON_Continue_E = 85
251 | ICON_Cancel_C = 86
252 | ICON_Cancel_E = 87
253 | ICON_Confirm_C = 88
254 | ICON_Confirm_E = 89
255 | ICON_Info_0 = 90
256 | ICON_Info_1 = 91
257 |
258 | MENU_CHAR_LIMIT = 24
259 | STATUS_Y = 360
260 |
261 | MOTION_CASE_RATE = 1
262 | MOTION_CASE_ACCEL = 2
263 | MOTION_CASE_JERK = MOTION_CASE_ACCEL + 0
264 | MOTION_CASE_STEPS = MOTION_CASE_JERK + 1
265 | MOTION_CASE_TOTAL = MOTION_CASE_STEPS
266 |
267 | PREPARE_CASE_MOVE = 1
268 | PREPARE_CASE_DISA = 2
269 | PREPARE_CASE_HOME = 3
270 | PREPARE_CASE_ZOFF = PREPARE_CASE_HOME + 1
271 | PREPARE_CASE_PLA = PREPARE_CASE_ZOFF + 1
272 | PREPARE_CASE_ABS = PREPARE_CASE_PLA + 1
273 | PREPARE_CASE_COOL = PREPARE_CASE_ABS + 1
274 | PREPARE_CASE_LANG = PREPARE_CASE_COOL + 0
275 | PREPARE_CASE_TOTAL = PREPARE_CASE_LANG
276 |
277 | CONTROL_CASE_TEMP = 1
278 | CONTROL_CASE_MOVE = 2
279 | CONTROL_CASE_INFO = 3
280 | CONTROL_CASE_TOTAL = 3
281 |
282 | TUNE_CASE_SPEED = 1
283 | TUNE_CASE_TEMP = (TUNE_CASE_SPEED + 1)
284 | TUNE_CASE_BED = (TUNE_CASE_TEMP + 1)
285 | TUNE_CASE_FAN = (TUNE_CASE_BED + 0)
286 | TUNE_CASE_ZOFF = (TUNE_CASE_FAN + 0)
287 | TUNE_CASE_TOTAL = TUNE_CASE_ZOFF
288 |
289 | TEMP_CASE_TEMP = (0 + 1)
290 | TEMP_CASE_BED = (TEMP_CASE_TEMP + 1)
291 | TEMP_CASE_FAN = (TEMP_CASE_BED + 0)
292 | TEMP_CASE_PLA = (TEMP_CASE_FAN + 1)
293 | TEMP_CASE_ABS = (TEMP_CASE_PLA + 1)
294 | TEMP_CASE_TOTAL = TEMP_CASE_ABS
295 |
296 | PREHEAT_CASE_TEMP = (0 + 1)
297 | PREHEAT_CASE_BED = (PREHEAT_CASE_TEMP + 1)
298 | PREHEAT_CASE_FAN = (PREHEAT_CASE_BED + 0)
299 | PREHEAT_CASE_SAVE = (PREHEAT_CASE_FAN + 1)
300 | PREHEAT_CASE_TOTAL = PREHEAT_CASE_SAVE
301 |
302 | # Dwen serial screen initialization
303 | # Passing parameters: serial port number
304 | # DWIN screen uses serial port 1 to send
305 | def __init__(self, USARTx, encoder_pins, button_pin, octoPrint_API_Key):
306 | GPIO.setmode(GPIO.BCM)
307 | self.encoder = Encoder(encoder_pins[0], encoder_pins[1])
308 | self.button_pin = button_pin
309 | GPIO.setup(self.button_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
310 | GPIO.add_event_detect(self.button_pin, GPIO.BOTH, callback=self.encoder_has_data)
311 | self.encoder.callback = self.encoder_has_data
312 | self.EncodeLast = 0
313 | self.EncodeMS = current_milli_time() + self.ENCODER_WAIT
314 | self.next_rts_update_ms = 0
315 | self.last_cardpercentValue = 101
316 | self.lcd = T5UIC1_LCD(USARTx)
317 | self.timer = multitimer.MultiTimer(interval=2, function=self.EachMomentUpdate)
318 | self.pd = PrinterData(octoPrint_API_Key)
319 | self.HMI_ShowBoot()
320 | print("Boot looks good")
321 | print("Testing Web-services")
322 | self.pd.init_Webservices()
323 | while self.pd.status is None:
324 | print("No Web-services")
325 | self.pd.init_Webservices()
326 | self.HMI_ShowBoot("Web-service still loading")
327 | self.HMI_Init()
328 | self.HMI_StartFrame(False)
329 |
330 | def lcdExit(self):
331 | print("Shutting down the LCD")
332 | self.JPG_ShowAndCache(0)
333 | self.Frame_SetDir(1)
334 | self.UpdateLCD()
335 | self.timer.stop()
336 | GPIO.remove_event_detect(self.button_pin)
337 |
338 | def MBASE(self, L):
339 | return 49 + self.MLINE * L
340 |
341 | def HMI_SetLanguageCache(self):
342 | self.lcd.JPG_CacheTo1(self.Language_English)
343 |
344 | def HMI_SetLanguage(self):
345 | self.HMI_SetLanguageCache()
346 |
347 | def HMI_ShowBoot(self, mesg=None):
348 | if mesg:
349 | self.lcd.Draw_String(
350 | False, False, self.lcd.DWIN_FONT_STAT,
351 | self.lcd.Color_White, self.lcd.Color_Bg_Black,
352 | 10, 50,
353 | mesg
354 | )
355 | for t in range(0, 100, 2):
356 | self.lcd.ICON_Show(self.ICON, self.ICON_Bar, 15, 260)
357 | self.lcd.Draw_Rectangle(1, self.lcd.Color_Bg_Black, 15 + t * 242 / 100, 260, 257, 280)
358 | self.lcd.UpdateLCD()
359 | time.sleep(.020)
360 |
361 | def HMI_Init(self):
362 | # HMI_SDCardInit()
363 |
364 | self.HMI_SetLanguage()
365 | self.timer.start()
366 | atexit.register(self.lcdExit)
367 |
368 | def HMI_StartFrame(self, with_update):
369 | self.last_status = self.pd.status
370 | if self.pd.status == "Printing":
371 | self.Goto_PrintProcess()
372 | elif self.pd.status == "Operational":
373 | self.Goto_MainMenu()
374 | else:
375 | self.Goto_MainMenu()
376 | self.Draw_Status_Area(with_update)
377 |
378 | def HMI_MainMenu(self):
379 | encoder_diffState = self.get_encoder_state()
380 | if (encoder_diffState == self.ENCODER_DIFF_NO):
381 | return
382 | if (encoder_diffState == self.ENCODER_DIFF_CW):
383 | if(self.select_page.inc(4)):
384 | if self.select_page.now == 0:
385 | self.ICON_Print()
386 | if self.select_page.now == 1:
387 | self.ICON_Print()
388 | self.ICON_Prepare()
389 | if self.select_page.now == 2:
390 | self.ICON_Prepare()
391 | self.ICON_Control()
392 | if self.select_page.now == 3:
393 | self.ICON_Control()
394 | if self.pd.HAS_ONESTEP_LEVELING:
395 | self.ICON_Leveling(True)
396 | else:
397 | self.ICON_StartInfo(True)
398 | elif (encoder_diffState == self.ENCODER_DIFF_CCW):
399 | if (self.select_page.dec()):
400 | if self.select_page.now == 0:
401 | self.ICON_Print()
402 | self.ICON_Prepare()
403 | elif self.select_page.now == 1:
404 | self.ICON_Prepare()
405 | self.ICON_Control()
406 | elif self.select_page.now == 2:
407 | self.ICON_Control()
408 | if self.pd.HAS_ONESTEP_LEVELING:
409 | self.ICON_Leveling(False)
410 | else:
411 | self.ICON_StartInfo(False)
412 | elif self.select_page.now == 3:
413 | if self.pd.HAS_ONESTEP_LEVELING:
414 | self.ICON_Leveling(True)
415 | else:
416 | self.ICON_StartInfo(True)
417 | elif (encoder_diffState == self.ENCODER_DIFF_ENTER):
418 | if self.select_page.now == 0: # Print File
419 | self.checkkey = self.SelectFile
420 | self.Draw_Print_File_Menu()
421 | if self.select_page.now == 1: # Prepare
422 | self.checkkey = self.Prepare
423 | self.select_prepare.reset()
424 | self.index_prepare = self.MROWS
425 | self.Draw_Prepare_Menu()
426 | if self.select_page.now == 2: # Control
427 | self.checkkey = self.Control
428 | self.select_control.reset()
429 | self.index_control = self.MROWS
430 | self.Draw_Control_Menu()
431 | if self.select_page.now == 3: # Leveling or Info
432 | if self.pd.HAS_ONESTEP_LEVELING:
433 | self.checkkey = self.Leveling
434 | self.HMI_Leveling()
435 | else:
436 | self.checkkey = self.Info
437 | self.Draw_Info_Menu()
438 |
439 | self.lcd.UpdateLCD()
440 |
441 | def HMI_SelectFile(self):
442 | encoder_diffState = self.get_encoder_state()
443 | hasUpDir = False # !card.flag.workDirIsRoot;
444 | if (encoder_diffState == self.ENCODER_DIFF_NO):
445 | return
446 |
447 | fullCnt = len(self.pd.GetFiles())
448 |
449 | if (encoder_diffState == self.ENCODER_DIFF_CW and fullCnt):
450 | if (self.select_file.inc(1 + fullCnt)):
451 | itemnum = self.select_file.now - 1 # -1 for "Back"
452 | if (self.select_file.now > self.MROWS and self.select_file.now > self.index_file): # Cursor past the bottom
453 | self.index_file = self.select_file.now # New bottom line
454 | self.Scroll_Menu(self.DWIN_SCROLL_UP)
455 | self.Draw_SDItem(itemnum, self.MROWS) # Draw and init the shift name
456 | else:
457 | self.Move_Highlight(1, self.select_file.now + self.MROWS - self.index_file) # Just move highlight
458 | elif (encoder_diffState == self.ENCODER_DIFF_CCW and fullCnt):
459 | if (self.select_file.dec()):
460 | itemnum = self.select_file.now - 1 # -1 for "Back"
461 | if (self.select_file.now < self.index_file - self.MROWS): # Cursor past the top
462 | self.index_file -= 1 # New bottom line
463 | self.Scroll_Menu(self.DWIN_SCROLL_DOWN)
464 | if (self.index_file == self.MROWS):
465 | self.Draw_Back_First()
466 | else:
467 | self.Draw_SDItem(itemnum, 0) # Draw the item (and init shift name)
468 | else:
469 | self.Move_Highlight(-1, self.select_file.now + self.MROWS - self.index_file) # Just move highlight
470 | elif (encoder_diffState == self.ENCODER_DIFF_ENTER):
471 | if (self.select_file.now == 0): # Back
472 | self.select_page.set(0)
473 | self.Goto_MainMenu()
474 | else:
475 | filenum = self.select_file.now - 1
476 | # Reset highlight for next entry
477 | self.select_print.reset()
478 | self.select_file.reset()
479 |
480 | # // Start choice and print SD file
481 | self.pd.HMI_flag.heat_flag = True
482 | self.pd.HMI_flag.print_finish = False
483 | self.pd.HMI_ValueStruct.show_mode = 0
484 |
485 | self.pd.openAndPrintFile(filenum)
486 | self.Goto_PrintProcess()
487 |
488 | self.lcd.UpdateLCD()
489 |
490 | def HMI_Prepare(self):
491 | encoder_diffState = self.get_encoder_state()
492 | if (encoder_diffState == self.ENCODER_DIFF_NO):
493 | return
494 |
495 | if (encoder_diffState == self.ENCODER_DIFF_CW):
496 | if (self.select_prepare.inc(1 + self.PREPARE_CASE_TOTAL)):
497 | if (self.select_prepare.now > self.MROWS and self.select_prepare.now > self.index_prepare):
498 | self.index_prepare = self.select_prepare.now
499 |
500 | # Scroll up and draw a blank bottom line
501 | self.Scroll_Menu(self.DWIN_SCROLL_UP)
502 | self.Draw_Menu_Icon(self.MROWS, self.ICON_Axis + self.select_prepare.now - 1)
503 |
504 | # Draw "More" icon for sub-menus
505 | if (self.index_prepare < 7):
506 | self.Draw_More_Icon(self.MROWS - self.index_prepare + 1)
507 |
508 | if self.pd.HAS_HOTEND:
509 | if (self.index_prepare == self.PREPARE_CASE_ABS):
510 | self.Item_Prepare_ABS(self.MROWS)
511 | if self.pd.HAS_PREHEAT:
512 | if (self.index_prepare == self.PREPARE_CASE_COOL):
513 | self.Item_Prepare_Cool(self.MROWS)
514 | else:
515 | self.Move_Highlight(1, self.select_prepare.now + self.MROWS - self.index_prepare)
516 |
517 | elif (encoder_diffState == self.ENCODER_DIFF_CCW):
518 | if (self.select_prepare.dec()):
519 | if (self.select_prepare.now < self.index_prepare - self.MROWS):
520 | self.index_prepare -= 1
521 | self.Scroll_Menu(self.DWIN_SCROLL_DOWN)
522 |
523 | if (self.index_prepare == self.MROWS):
524 | self.Draw_Back_First()
525 | else:
526 | self.Draw_Menu_Line(0, self.ICON_Axis + self.select_prepare.now - 1)
527 |
528 | if (self.index_prepare < 7):
529 | self.Draw_More_Icon(self.MROWS - self.index_prepare + 1)
530 |
531 | if (self.index_prepare == 6):
532 | self.Item_Prepare_Move(0)
533 | elif (self.index_prepare == 7):
534 | self.Item_Prepare_Disable(0)
535 | elif (self.index_prepare == 8):
536 | self.Item_Prepare_Home(0)
537 | else:
538 | self.Move_Highlight(-1, self.select_prepare.now + self.MROWS - self.index_prepare)
539 |
540 | elif (encoder_diffState == self.ENCODER_DIFF_ENTER):
541 | if (self.select_prepare.now == 0): # Back
542 | self.select_page.set(1)
543 | self.Goto_MainMenu()
544 |
545 | elif self.select_prepare.now == self.PREPARE_CASE_MOVE: # Axis move
546 | self.checkkey = self.AxisMove
547 | self.select_axis.reset()
548 | self.Draw_Move_Menu()
549 | self.lcd.Draw_FloatValue(
550 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
551 | 3, 1, 216, self.MBASE(1), self.pd.current_position.x * self.MINUNITMULT
552 | )
553 | self.lcd.Draw_FloatValue(
554 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
555 | 3, 1, 216, self.MBASE(2), self.pd.current_position.y * self.MINUNITMULT
556 | )
557 | self.lcd.Draw_FloatValue(
558 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
559 | 3, 1, 216, self.MBASE(3), self.pd.current_position.z * self.MINUNITMULT
560 | )
561 | self.pd.queue("G92 E0")
562 | self.pd.current_position.e = self.pd.HMI_ValueStruct.Move_E_scale = 0
563 | self.lcd.Draw_Signed_Float(self.lcd.font8x16, self.lcd.Color_Bg_Black, 3, 1, 216, self.MBASE(4), 0)
564 | elif self.select_prepare.now == self.PREPARE_CASE_DISA: # Disable steppers
565 | self.pd.queue("M84")
566 | elif self.select_prepare.now == self.PREPARE_CASE_HOME: # Homing
567 | self.checkkey = self.Last_Prepare
568 | self.index_prepare = self.MROWS
569 | self.pd.queue("G28")
570 | self.pd.current_position.homing()
571 | self.pd.HMI_flag.home_flag = True
572 | self.Popup_Window_Home()
573 | elif self.select_prepare.now == self.PREPARE_CASE_ZOFF: # Z-offset
574 | self.checkkey = self.Homeoffset
575 | self.pd.probe_calibrate()
576 | self.pd.HMI_ValueStruct.show_mode = -4
577 | self.pd.HMI_ValueStruct.offset_value = self.pd.BABY_Z_VAR * 100
578 | self.dwin_zoffset = self.pd.HMI_ValueStruct.offset_value / 100.0
579 |
580 | self.lcd.Draw_Signed_Float(
581 | self.lcd.font8x16, self.lcd.Select_Color, 2, 2, 202,
582 | self.MBASE(self.PREPARE_CASE_ZOFF + self.MROWS - self.index_prepare),
583 | self.pd.HMI_ValueStruct.offset_value
584 | )
585 | self.EncoderRate = True
586 |
587 | elif self.select_prepare.now == self.PREPARE_CASE_PLA: # PLA preheat
588 | self.pd.preheat("PLA")
589 |
590 | elif self.select_prepare.now == self.PREPARE_CASE_ABS: # ABS preheat
591 | self.pd.preheat("ABS")
592 |
593 | elif self.select_prepare.now == self.PREPARE_CASE_COOL: # Cool
594 | if self.pd.HAS_FAN:
595 | self.pd.zero_fan_speeds()
596 | self.pd.disable_all_heaters()
597 |
598 | elif self.select_prepare.now == self.PREPARE_CASE_LANG: # Toggle Language
599 | self.HMI_ToggleLanguage()
600 | self.Draw_Prepare_Menu()
601 | self.lcd.UpdateLCD()
602 |
603 | def HMI_Control(self):
604 | encoder_diffState = self.get_encoder_state()
605 | if (encoder_diffState == self.ENCODER_DIFF_NO):
606 | return
607 |
608 | if (encoder_diffState == self.ENCODER_DIFF_CW):
609 | if (self.select_control.inc(1 + self.CONTROL_CASE_TOTAL)):
610 | if (self.select_control.now > self.MROWS and self.select_control.now > self.index_control):
611 | self.index_control = self.select_control.now
612 | self.Scroll_Menu(self.DWIN_SCROLL_UP)
613 | self.Draw_Menu_Icon(self.MROWS, self.ICON_Temperature + self.index_control - 1)
614 | self.Draw_More_Icon(self.CONTROL_CASE_TEMP + self.MROWS - self.index_control) # Temperature >
615 | self.Draw_More_Icon(self.CONTROL_CASE_MOVE + self.MROWS - self.index_control) # Motion >
616 | if (self.index_control > self.MROWS):
617 | self.Draw_More_Icon(self.CONTROL_CASE_INFO + self.MROWS - self.index_control) # Info >
618 | self.lcd.Frame_AreaCopy(1, 0, 104, 24, 114, self.LBLX, self.MBASE(self.CONTROL_CASE_INFO - 1))
619 | else:
620 | self.Move_Highlight(1, self.select_control.now + self.MROWS - self.index_control)
621 | elif (encoder_diffState == self.ENCODER_DIFF_CCW):
622 | if (self.select_control.dec()):
623 | if (self.select_control.now < self.index_control - self.MROWS):
624 | self.index_control -= 1
625 | self.Scroll_Menu(self.DWIN_SCROLL_DOWN)
626 | if (self.index_control == self.MROWS):
627 | self.Draw_Back_First()
628 | else:
629 | self.Draw_Menu_Line(0, self.ICON_Temperature + self.select_control.now - 1)
630 | self.Draw_More_Icon(0 + self.MROWS - self.index_control + 1) # Temperature >
631 | self.Draw_More_Icon(1 + self.MROWS - self.index_control + 1) # Motion >
632 | else:
633 | self.Move_Highlight(-1, self.select_control.now + self.MROWS - self.index_control)
634 | elif (encoder_diffState == self.ENCODER_DIFF_ENTER):
635 | if (self.select_control.now == 0): # Back
636 | self.select_page.set(2)
637 | self.Goto_MainMenu()
638 | if (self.select_control.now == self.CONTROL_CASE_TEMP): # Temperature
639 | self.checkkey = self.TemperatureID
640 | self.pd.HMI_ValueStruct.show_mode = -1
641 | self.select_temp.reset()
642 | self.Draw_Temperature_Menu()
643 | if (self.select_control.now == self.CONTROL_CASE_MOVE): # Motion
644 | self.checkkey = self.Motion
645 | self.select_motion.reset()
646 | self.Draw_Motion_Menu()
647 | if (self.select_control.now == self.CONTROL_CASE_INFO): # Info
648 | self.checkkey = self.Info
649 | self.Draw_Info_Menu()
650 |
651 | self.lcd.UpdateLCD()
652 |
653 | def HMI_Info(self):
654 | encoder_diffState = self.get_encoder_state()
655 | if (encoder_diffState == self.ENCODER_DIFF_NO):
656 | return
657 | if (encoder_diffState == self.ENCODER_DIFF_ENTER):
658 | if self.pd.HAS_ONESTEP_LEVELING:
659 | self.checkkey = self.Control
660 | self.select_control.set(self.CONTROL_CASE_INFO)
661 | self.Draw_Control_Menu()
662 | else:
663 | self.select_page.set(3)
664 | self.Goto_MainMenu()
665 | self.lcd.UpdateLCD()
666 |
667 | def HMI_Printing(self):
668 | encoder_diffState = self.get_encoder_state()
669 | if (encoder_diffState == self.ENCODER_DIFF_NO):
670 | return
671 | if (self.pd.HMI_flag.done_confirm_flag):
672 | if (encoder_diffState == self.ENCODER_DIFF_ENTER):
673 | self.pd.HMI_flag.done_confirm_flag = False
674 | self.dwin_abort_flag = True # Reset feedrate, return to Home
675 | return
676 |
677 | if (encoder_diffState == self.ENCODER_DIFF_CW):
678 | if (self.select_print.inc(3)):
679 | if self.select_print.now == 0:
680 | self.ICON_Tune()
681 | elif self.select_print.now == 1:
682 | self.ICON_Tune()
683 | if (self.pd.printingIsPaused()):
684 | self.ICON_Continue()
685 | else:
686 | self.ICON_Pause()
687 | elif self.select_print.now == 2:
688 | if (self.pd.printingIsPaused()):
689 | self.ICON_Continue()
690 | else:
691 | self.ICON_Pause()
692 | self.ICON_Stop()
693 | elif (encoder_diffState == self.ENCODER_DIFF_CCW):
694 | if (self.select_print.dec()):
695 | if self.select_print.now == 0:
696 | self.ICON_Tune()
697 | if (self.pd.printingIsPaused()):
698 | self.ICON_Continue()
699 | else:
700 | self.ICON_Pause()
701 | elif self.select_print.now == 1:
702 | if (self.pd.printingIsPaused()):
703 | self.ICON_Continue()
704 | else:
705 | self.ICON_Pause()
706 | self.ICON_Stop()
707 | elif self.select_print.now == 2:
708 | self.ICON_Stop()
709 | elif (encoder_diffState == self.ENCODER_DIFF_ENTER):
710 | if self.select_print.now == 0: # Tune
711 | self.checkkey = self.Tune
712 | self.pd.HMI_ValueStruct.show_mode = 0
713 | self.select_tune.reset()
714 | self.index_tune = self.MROWS
715 | self.Draw_Tune_Menu()
716 | elif self.select_print.now == 1: # Pause
717 | if (self.pd.HMI_flag.pause_flag):
718 | self.ICON_Pause()
719 | self.pd.resume_job()
720 | else:
721 | self.pd.HMI_flag.select_flag = True
722 | self.checkkey = self.Print_window
723 | self.Popup_window_PauseOrStop()
724 | elif self.select_print.now == 2: # Stop
725 | self.pd.HMI_flag.select_flag = True
726 | self.checkkey = self.Print_window
727 | self.Popup_window_PauseOrStop()
728 | self.lcd.UpdateLCD()
729 |
730 | # Pause and Stop window */
731 | def HMI_PauseOrStop(self):
732 | encoder_diffState = self.get_encoder_state()
733 | if (encoder_diffState == self.ENCODER_DIFF_NO):
734 | return
735 | if (encoder_diffState == self.ENCODER_DIFF_CW):
736 | self.Draw_Select_Highlight(False)
737 | elif (encoder_diffState == self.ENCODER_DIFF_CCW):
738 | self.Draw_Select_Highlight(True)
739 | elif (encoder_diffState == self.ENCODER_DIFF_ENTER):
740 | if (self.select_print.now == 1): # pause window
741 | if (self.pd.HMI_flag.select_flag):
742 | self.pd.HMI_flag.pause_action = True
743 | self.ICON_Continue()
744 | self.pd.pause_job()
745 | self.Goto_PrintProcess()
746 | elif (self.select_print.now == 2): # stop window
747 | if (self.pd.HMI_flag.select_flag):
748 | self.dwin_abort_flag = True # Reset feedrate, return to Home
749 | self.pd.cancel_job()
750 | self.Goto_MainMenu()
751 | else:
752 | self.Goto_PrintProcess() # cancel stop
753 | self.lcd.UpdateLCD()
754 |
755 | # Tune */
756 | def HMI_Tune(self):
757 | encoder_diffState = self.get_encoder_state()
758 | if (encoder_diffState == self.ENCODER_DIFF_NO):
759 | return
760 | if (encoder_diffState == self.ENCODER_DIFF_CW):
761 | if (self.select_tune.inc(1 + self.TUNE_CASE_TOTAL)):
762 | if (self.select_tune.now > self.MROWS and self.select_tune.now > self.index_tune):
763 | self.index_tune = self.select_tune.now
764 | self.Scroll_Menu(self.DWIN_SCROLL_UP)
765 | else:
766 | self.Move_Highlight(1, self.select_tune.now + self.MROWS - self.index_tune)
767 | elif (encoder_diffState == self.ENCODER_DIFF_CCW):
768 | if (self.select_tune.dec()):
769 | if (self.select_tune.now < self.index_tune - self.MROWS):
770 | self.index_tune -= 1
771 | self.Scroll_Menu(self.DWIN_SCROLL_DOWN)
772 | if (self.index_tune == self.MROWS):
773 | self.Draw_Back_First()
774 | else:
775 | self.Move_Highlight(-1, self.select_tune.now + self.MROWS - self.index_tune)
776 | elif (encoder_diffState == self.ENCODER_DIFF_ENTER):
777 | if self.select_tune.now == 0: # Back
778 | self.select_print.set(0)
779 | self.Goto_PrintProcess()
780 | if self.select_tune.now == self.TUNE_CASE_SPEED: # Print speed
781 | self.checkkey = self.PrintSpeed
782 | self.pd.HMI_ValueStruct.print_speed = self.pd.feedrate_percentage
783 | self.lcd.Draw_IntValue(
784 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Select_Color,
785 | 3, 216, self.MBASE(self.TUNE_CASE_SPEED + self.MROWS - self.index_tune),
786 | self.pd.feedrate_percentage
787 | )
788 | self.EncoderRate = True
789 |
790 | self.lcd.UpdateLCD()
791 |
792 | def HMI_PrintSpeed(self):
793 | encoder_diffState = self.get_encoder_state()
794 | if (encoder_diffState == self.ENCODER_DIFF_NO):
795 | return
796 |
797 | if (encoder_diffState == self.ENCODER_DIFF_CW):
798 | self.pd.HMI_ValueStruct.print_speed += 1
799 |
800 | elif (encoder_diffState == self.ENCODER_DIFF_CCW):
801 | self.pd.HMI_ValueStruct.print_speed -= 1
802 |
803 | elif (encoder_diffState == self.ENCODER_DIFF_ENTER):
804 | self.checkkey = self.Tune
805 | self.pd.encoderRate = False
806 | self.pd.set_feedrate(self.pd.HMI_ValueStruct.print_speed)
807 |
808 | self.lcd.Draw_IntValue(
809 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
810 | 3, 216, self.MBASE(self.select_tune.now + self.MROWS - self.index_tune),
811 | self.pd.HMI_ValueStruct.print_speed
812 | )
813 |
814 | def HMI_AxisMove(self):
815 | encoder_diffState = self.get_encoder_state()
816 | if (encoder_diffState == self.ENCODER_DIFF_NO):
817 | return
818 |
819 | if self.pd.PREVENT_COLD_EXTRUSION:
820 | # popup window resume
821 | if (self.pd.HMI_flag.ETempTooLow_flag):
822 | if (encoder_diffState == self.ENCODER_DIFF_ENTER):
823 | self.pd.HMI_flag.ETempTooLow_flag = False
824 | self.pd.current_position.e = self.pd.HMI_ValueStruct.Move_E_scale = 0
825 | self.Draw_Move_Menu()
826 | self.lcd.Draw_FloatValue(
827 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
828 | 3, 1, 216, self.MBASE(1),
829 | self.pd.HMI_ValueStruct.Move_X_scale
830 | )
831 | self.lcd.Draw_FloatValue(
832 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
833 | 3, 1, 216, self.MBASE(2),
834 | self.pd.HMI_ValueStruct.Move_Y_scale
835 | )
836 | self.lcd.Draw_FloatValue(
837 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
838 | 3, 1, 216, self.MBASE(3),
839 | self.pd.HMI_ValueStruct.Move_Z_scale
840 | )
841 | self.lcd.Draw_Signed_Float(
842 | self.lcd.font8x16, self.lcd.Color_Bg_Black, 3, 1, 216, self.MBASE(4), 0
843 | )
844 | self.lcd.UpdateLCD()
845 | return
846 | # Avoid flicker by updating only the previous menu
847 | if (encoder_diffState == self.ENCODER_DIFF_CW):
848 | if (self.select_axis.inc(1 + 4)):
849 | self.Move_Highlight(1, self.select_axis.now)
850 | elif (encoder_diffState == self.ENCODER_DIFF_CCW):
851 | if (self.select_axis.dec()):
852 | self.Move_Highlight(-1, self.select_axis.now)
853 | elif (encoder_diffState == self.ENCODER_DIFF_ENTER):
854 | if self.select_axis.now == 0: # Back
855 | self.checkkey = self.Prepare
856 | self.select_prepare.set(1)
857 | self.index_prepare = self.MROWS
858 | self.Draw_Prepare_Menu()
859 |
860 | elif self.select_axis.now == 1: # axis move
861 | self.checkkey = self.Move_X
862 | self.pd.HMI_ValueStruct.Move_X_scale = self.pd.current_position.x * self.MINUNITMULT
863 | self.lcd.Draw_FloatValue(
864 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Select_Color,
865 | 3, 1, 216, self.MBASE(1),
866 | self.pd.HMI_ValueStruct.Move_X_scale
867 | )
868 | self.EncoderRate = True
869 | elif self.select_axis.now == 2: # Y axis move
870 | self.checkkey = self.Move_Y
871 | self.pd.HMI_ValueStruct.Move_Y_scale = self.pd.current_position.y * self.MINUNITMULT
872 | self.lcd.Draw_FloatValue(
873 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Select_Color,
874 | 3, 1, 216, self.MBASE(2),
875 | self.pd.HMI_ValueStruct.Move_Y_scale
876 | )
877 | self.EncoderRate = True
878 | elif self.select_axis.now == 3: # Z axis move
879 | self.checkkey = self.Move_Z
880 | self.pd.HMI_ValueStruct.Move_Z_scale = self.pd.current_position.z * self.MINUNITMULT
881 | self.lcd.Draw_FloatValue(
882 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Select_Color,
883 | 3, 1, 216, self.MBASE(3),
884 | self.pd.HMI_ValueStruct.Move_Z_scale
885 | )
886 | self.EncoderRate = True
887 | elif self.select_axis.now == 4: # Extruder
888 | # window tips
889 | if self.pd.PREVENT_COLD_EXTRUSION:
890 | if (self.pd.thermalManager['temp_hotend'][0]['celsius'] < self.pd.EXTRUDE_MINTEMP):
891 | self.pd.HMI_flag.ETempTooLow_flag = True
892 | self.Popup_Window_ETempTooLow()
893 | self.lcd.UpdateLCD()
894 | return
895 | self.checkkey = self.Extruder
896 | self.pd.HMI_ValueStruct.Move_E_scale = self.pd.current_position.e * self.MINUNITMULT
897 | self.lcd.Draw_Signed_Float(
898 | self.lcd.font8x16, self.lcd.Select_Color, 3, 1, 216, self.MBASE(4),
899 | self.pd.HMI_ValueStruct.Move_E_scale
900 | )
901 | self.EncoderRate = True
902 | self.lcd.UpdateLCD()
903 |
904 | def HMI_Move_X(self):
905 | encoder_diffState = self.get_encoder_state()
906 | if (encoder_diffState == self.ENCODER_DIFF_NO):
907 | return
908 | elif (encoder_diffState == self.ENCODER_DIFF_ENTER):
909 | self.checkkey = self.AxisMove
910 | self.EncoderRate = False
911 | self.lcd.Draw_FloatValue(
912 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
913 | 3, 1, 216, self.MBASE(1),
914 | self.pd.HMI_ValueStruct.Move_X_scale
915 | )
916 | self.pd.jog(x=self.pd.current_position.x)
917 | self.lcd.UpdateLCD()
918 | return
919 | elif (encoder_diffState == self.ENCODER_DIFF_CW):
920 | self.pd.HMI_ValueStruct.Move_X_scale += 1
921 | elif (encoder_diffState == self.ENCODER_DIFF_CCW):
922 | self.pd.HMI_ValueStruct.Move_X_scale -= 1
923 |
924 | if self.pd.HMI_ValueStruct.Move_X_scale < (self.pd.X_MIN_POS) * self.MINUNITMULT:
925 | self.pd.HMI_ValueStruct.Move_X_scale = (self.pd.X_MIN_POS) * self.MINUNITMULT
926 |
927 | if self.pd.HMI_ValueStruct.Move_X_scale > (self.pd.X_MAX_POS) * self.MINUNITMULT:
928 | self.pd.HMI_ValueStruct.Move_X_scale = (self.pd.X_MAX_POS) * self.MINUNITMULT
929 |
930 | self.pd.current_position.x = self.pd.HMI_ValueStruct.Move_X_scale / 10
931 | self.lcd.Draw_FloatValue(
932 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Select_Color,
933 | 3, 1, 216, self.MBASE(1), self.pd.HMI_ValueStruct.Move_X_scale)
934 | self.lcd.UpdateLCD()
935 |
936 | def HMI_Move_Y(self):
937 | encoder_diffState = self.get_encoder_state()
938 | if (encoder_diffState == self.ENCODER_DIFF_NO):
939 | return
940 | elif (encoder_diffState == self.ENCODER_DIFF_ENTER):
941 | self.checkkey = self.AxisMove
942 | self.EncoderRate = False
943 | self.lcd.Draw_FloatValue(
944 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
945 | 3, 1, 216, self.MBASE(2),
946 | self.pd.HMI_ValueStruct.Move_Y_scale
947 | )
948 | self.pd.jog(y=self.pd.current_position.y)
949 | self.lcd.UpdateLCD()
950 | return
951 | elif (encoder_diffState == self.ENCODER_DIFF_CW):
952 | self.pd.HMI_ValueStruct.Move_Y_scale += 1
953 | elif (encoder_diffState == self.ENCODER_DIFF_CCW):
954 | self.pd.HMI_ValueStruct.Move_Y_scale -= 1
955 |
956 | if self.pd.HMI_ValueStruct.Move_Y_scale < (self.pd.Y_MIN_POS) * self.MINUNITMULT:
957 | self.pd.HMI_ValueStruct.Move_Y_scale = (self.pd.Y_MIN_POS) * self.MINUNITMULT
958 |
959 | if self.pd.HMI_ValueStruct.Move_Y_scale > (self.pd.Y_MAX_POS) * self.MINUNITMULT:
960 | self.pd.HMI_ValueStruct.Move_Y_scale = (self.pd.Y_MAX_POS) * self.MINUNITMULT
961 |
962 | self.pd.current_position.y = self.pd.HMI_ValueStruct.Move_Y_scale / 10
963 | self.lcd.Draw_FloatValue(
964 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Select_Color,
965 | 3, 1, 216, self.MBASE(2), self.pd.HMI_ValueStruct.Move_Y_scale)
966 | self.lcd.UpdateLCD()
967 |
968 | def HMI_Move_Z(self):
969 | encoder_diffState = self.get_encoder_state()
970 | if (encoder_diffState == self.ENCODER_DIFF_NO):
971 | return
972 | elif (encoder_diffState == self.ENCODER_DIFF_ENTER):
973 | self.checkkey = self.AxisMove
974 | self.EncoderRate = False
975 | self.lcd.Draw_FloatValue(
976 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
977 | 3, 1, 216, self.MBASE(3),
978 | self.pd.HMI_ValueStruct.Move_Z_scale
979 | )
980 | self.pd.jog(z=self.pd.current_position.z)
981 | self.lcd.UpdateLCD()
982 | return
983 | elif (encoder_diffState == self.ENCODER_DIFF_CW):
984 | self.pd.HMI_ValueStruct.Move_Z_scale += 1
985 | elif (encoder_diffState == self.ENCODER_DIFF_CCW):
986 | self.pd.HMI_ValueStruct.Move_Z_scale -= 1
987 |
988 | if self.pd.HMI_ValueStruct.Move_Z_scale < (self.pd.Z_MIN_POS) * self.MINUNITMULT:
989 | self.pd.HMI_ValueStruct.Move_Z_scale = (self.pd.Z_MIN_POS) * self.MINUNITMULT
990 |
991 | if self.pd.HMI_ValueStruct.Move_Z_scale > (self.pd.Z_MAX_POS) * self.MINUNITMULT:
992 | self.pd.HMI_ValueStruct.Move_Z_scale = (self.pd.Z_MAX_POS) * self.MINUNITMULT
993 |
994 | self.pd.current_position.z = self.pd.HMI_ValueStruct.Move_Z_scale / 10
995 | self.lcd.Draw_FloatValue(
996 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Select_Color,
997 | 3, 1, 216, self.MBASE(3), self.pd.HMI_ValueStruct.Move_Z_scale)
998 | self.lcd.UpdateLCD()
999 |
1000 | def HMI_Move_E(self):
1001 | self.pd.last_E_scale = 0
1002 | encoder_diffState = self.get_encoder_state()
1003 | if (encoder_diffState == self.ENCODER_DIFF_NO):
1004 | return
1005 |
1006 | elif (encoder_diffState == self.ENCODER_DIFF_ENTER):
1007 | self.checkkey = self.AxisMove
1008 | self.EncoderRate = False
1009 | self.pd.last_E_scale = self.pd.HMI_ValueStruct.Move_E_scale
1010 | self.lcd.Draw_Signed_Float(
1011 | self.lcd.font8x16, self.lcd.Color_Bg_Black, 3, 1, 216,
1012 | self.MBASE(4), self.pd.HMI_ValueStruct.Move_E_scale
1013 | )
1014 | self.pd.jog(e=self.pd.current_position.e)
1015 | self.lcd.UpdateLCD()
1016 | elif (encoder_diffState == self.ENCODER_DIFF_CW):
1017 | self.pd.HMI_ValueStruct.Move_E_scale += 1
1018 | elif (encoder_diffState == self.ENCODER_DIFF_CCW):
1019 | self.pd.HMI_ValueStruct.Move_E_scale -= 1
1020 |
1021 | if ((self.pd.HMI_ValueStruct.Move_E_scale - self.pd.last_E_scale) > (self.pd.EXTRUDE_MAXLENGTH) * self.MINUNITMULT):
1022 | self.pd.HMI_ValueStruct.Move_E_scale = self.pd.last_E_scale + (self.pd.EXTRUDE_MAXLENGTH) * self.MINUNITMULT
1023 | elif ((self.pd.last_E_scale - self.pd.HMI_ValueStruct.Move_E_scale) > (self.pd.EXTRUDE_MAXLENGTH) * self.MINUNITMULT):
1024 | self.pd.HMI_ValueStruct.Move_E_scale = self.pd.last_E_scale - (self.pd.EXTRUDE_MAXLENGTH) * self.MINUNITMULT
1025 | self.pd.current_position.e = self.pd.HMI_ValueStruct.Move_E_scale / 10
1026 | self.lcd.Draw_Signed_Float(self.lcd.font8x16, self.lcd.Select_Color, 3, 1, 216, self.MBASE(4), self.pd.HMI_ValueStruct.Move_E_scale)
1027 | self.lcd.UpdateLCD()
1028 |
1029 | def HMI_Temperature(self):
1030 | encoder_diffState = self.get_encoder_state()
1031 | if (encoder_diffState == self.ENCODER_DIFF_NO):
1032 | return
1033 |
1034 | if (encoder_diffState == self.ENCODER_DIFF_CW):
1035 | if (self.select_temp.inc(1 + self.TEMP_CASE_TOTAL)):
1036 | self.Move_Highlight(1, self.select_temp.now)
1037 | elif (encoder_diffState == self.ENCODER_DIFF_CCW):
1038 | if (self.select_temp.dec()):
1039 | self.Move_Highlight(-1, self.select_temp.now)
1040 | elif (encoder_diffState == self.ENCODER_DIFF_ENTER):
1041 | if self.select_temp.now == 0: # back
1042 | self.checkkey = self.Control
1043 | self.select_control.set(1)
1044 | self.index_control = self.MROWS
1045 | self.Draw_Control_Menu()
1046 | elif self.select_temp.now == self.TEMP_CASE_TEMP: # Nozzle temperature
1047 | self.checkkey = self.ETemp
1048 | self.pd.HMI_ValueStruct.E_Temp = self.pd.thermalManager['temp_hotend'][0]['target']
1049 | self.lcd.Draw_IntValue(
1050 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Select_Color,
1051 | 3, 216, self.MBASE(1),
1052 | self.pd.thermalManager['temp_hotend'][0]['target']
1053 | )
1054 | self.pd.encoderRate = True
1055 | elif self.select_temp.now == self.TEMP_CASE_BED: # Bed temperature
1056 | self.checkkey = self.BedTemp
1057 | self.pd.HMI_ValueStruct.Bed_Temp = self.pd.thermalManager['temp_bed']['target']
1058 | self.lcd.Draw_IntValue(
1059 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Select_Color,
1060 | 3, 216, self.MBASE(2),
1061 | self.pd.thermalManager['temp_bed']['target']
1062 | )
1063 | self.pd.encoderRate = True
1064 | elif self.select_temp.now == self.TEMP_CASE_FAN: # Fan speed
1065 | self.checkkey = self.FanSpeed
1066 | self.pd.HMI_ValueStruct.Fan_speed = self.pd.thermalManager['fan_speed'][0]
1067 | self.lcd.Draw_IntValue(
1068 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Select_Color,
1069 | 3, 216, self.MBASE(3), self.pd.thermalManager['fan_speed'][0]
1070 | )
1071 | self.pd.encoderRate = True
1072 |
1073 | elif self.select_temp.now == self.TEMP_CASE_PLA: # PLA preheat setting
1074 | self.checkkey = self.PLAPreheat
1075 | self.select_PLA.reset()
1076 | self.pd.HMI_ValueStruct.show_mode = -2
1077 |
1078 | self.Clear_Main_Window()
1079 | self.lcd.Frame_TitleCopy(1, 56, 16, 141, 28) # "PLA Settings"
1080 | self.lcd.Frame_AreaCopy(1, 157, 76, 181, 86, self.LBLX, self.MBASE(self.PREHEAT_CASE_TEMP))
1081 | self.lcd.Frame_AreaCopy(1, 197, 104, 238, 114, self.LBLX + 27, self.MBASE(self.PREHEAT_CASE_TEMP))
1082 | self.lcd.Frame_AreaCopy(1, 1, 89, 83, 101, self.LBLX + 71, self.MBASE(self.PREHEAT_CASE_TEMP)) # PLA nozzle temp
1083 | if self.pd.HAS_HEATED_BED:
1084 | self.lcd.Frame_AreaCopy(1, 157, 76, 181, 86, self.LBLX, self.MBASE(self.PREHEAT_CASE_BED) + 3)
1085 | self.lcd.Frame_AreaCopy(1, 240, 104, 264, 114, self.LBLX + 27, self.MBASE(self.PREHEAT_CASE_BED) + 3)
1086 | self.lcd.Frame_AreaCopy(1, 1, 89, 83, 101, self.LBLX + 54, self.MBASE(self.PREHEAT_CASE_BED) + 3) # PLA bed temp
1087 | if self.pd.HAS_FAN:
1088 | self.lcd.Frame_AreaCopy(1, 157, 76, 181, 86, self.LBLX, self.MBASE(self.PREHEAT_CASE_FAN))
1089 | self.lcd.Frame_AreaCopy(1, 0, 119, 64, 132, self.LBLX + 27, self.MBASE(self.PREHEAT_CASE_FAN)) # PLA fan speed
1090 |
1091 | self.lcd.Frame_AreaCopy(1, 97, 165, 229, 177, self.LBLX, self.MBASE(self.PREHEAT_CASE_SAVE)) # Save PLA configuration
1092 |
1093 | self.Draw_Back_First()
1094 | i = 1
1095 | self.Draw_Menu_Line(i, self.ICON_SetEndTemp)
1096 | self.lcd.Draw_IntValue(
1097 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1098 | 3, 216, self.MBASE(i),
1099 | self.pd.material_preset[0].hotend_temp
1100 | )
1101 | if self.pd.HAS_HEATED_BED:
1102 | i += 1
1103 | self.Draw_Menu_Line(i, self.ICON_SetBedTemp)
1104 | self.lcd.Draw_IntValue(
1105 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1106 | 3, 216, self.MBASE(i),
1107 | self.pd.material_preset[0].bed_temp
1108 | )
1109 | if self.pd.HAS_FAN:
1110 | i += 1
1111 | self.Draw_Menu_Line(i, self.ICON_FanSpeed)
1112 | self.lcd.Draw_IntValue(
1113 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1114 | 3, 216, self.MBASE(i),
1115 | self.pd.material_preset[0].fan_speed
1116 | )
1117 | i += 1
1118 | self.Draw_Menu_Line(i, self.ICON_WriteEEPROM)
1119 | elif self.select_temp.now == self.TEMP_CASE_ABS: # ABS preheat setting
1120 | self.checkkey = self.ABSPreheat
1121 | self.select_ABS.reset()
1122 | self.pd.HMI_ValueStruct.show_mode = -3
1123 | self.Clear_Main_Window()
1124 | self.lcd.Frame_TitleCopy(1, 56, 16, 141, 28) # "ABS Settings"
1125 | self.lcd.Frame_AreaCopy(1, 172, 76, 198, 86, self.LBLX, self.MBASE(self.PREHEAT_CASE_TEMP))
1126 | self.lcd.Frame_AreaCopy(1, 197, 104, 238, 114, self.LBLX + 27, self.MBASE(self.PREHEAT_CASE_TEMP))
1127 | self.lcd.Frame_AreaCopy(1, 1, 89, 83, 101, self.LBLX + 71, self.MBASE(self.PREHEAT_CASE_TEMP)) # ABS nozzle temp
1128 | if self.pd.HAS_HEATED_BED:
1129 | self.lcd.Frame_AreaCopy(1, 172, 76, 198, 86, self.LBLX, self.MBASE(self.PREHEAT_CASE_BED) + 3)
1130 | self.lcd.Frame_AreaCopy(1, 240, 104, 264, 114, self.LBLX + 27, self.MBASE(self.PREHEAT_CASE_BED) + 3)
1131 | self.lcd.Frame_AreaCopy(1, 1, 89, 83, 101, self.LBLX + 54, self.MBASE(self.PREHEAT_CASE_BED) + 3) # ABS bed temp
1132 | if self.pd.HAS_FAN:
1133 | self.lcd.Frame_AreaCopy(1, 172, 76, 198, 86, self.LBLX, self.MBASE(self.PREHEAT_CASE_FAN))
1134 | self.lcd.Frame_AreaCopy(1, 0, 119, 64, 132, self.LBLX + 27, self.MBASE(self.PREHEAT_CASE_FAN)) # ABS fan speed
1135 |
1136 | self.lcd.Frame_AreaCopy(1, 97, 165, 229, 177, self.LBLX, self.MBASE(self.PREHEAT_CASE_SAVE))
1137 | self.lcd.Frame_AreaCopy(1, 172, 76, 198, 86, self.LBLX + 33, self.MBASE(self.PREHEAT_CASE_SAVE)) # Save ABS configuration
1138 |
1139 | self.Draw_Back_First()
1140 | i = 1
1141 | self.Draw_Menu_Line(i, self.ICON_SetEndTemp)
1142 | self.lcd.Draw_IntValue(
1143 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1144 | 3, 216, self.MBASE(i),
1145 | self.pd.material_preset[1].hotend_temp
1146 | )
1147 | if self.pd.HAS_HEATED_BED:
1148 | i += 1
1149 | self.Draw_Menu_Line(i, self.ICON_SetBedTemp)
1150 | self.lcd.Draw_IntValue(
1151 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1152 | 3, 216, self.MBASE(i),
1153 | self.pd.material_preset[1].bed_temp
1154 | )
1155 | if self.pd.HAS_FAN:
1156 | i += 1
1157 | self.Draw_Menu_Line(i, self.ICON_FanSpeed)
1158 | self.lcd.Draw_IntValue(
1159 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1160 | 3, 216, self.MBASE(i),
1161 | self.pd.material_preset[1].fan_speed
1162 | )
1163 | i += 1
1164 | self.Draw_Menu_Line(i, self.ICON_WriteEEPROM)
1165 |
1166 | self.lcd.UpdateLCD()
1167 |
1168 | def HMI_PLAPreheatSetting(self):
1169 | encoder_diffState = self.get_encoder_state()
1170 | if (encoder_diffState == self.ENCODER_DIFF_NO):
1171 | return
1172 | # Avoid flicker by updating only the previous menu
1173 | elif (encoder_diffState == self.ENCODER_DIFF_CW):
1174 | if (self.select_PLA.inc(1 + self.PREHEAT_CASE_TOTAL)):
1175 | self.Move_Highlight(1, self.select_PLA.now)
1176 | elif (encoder_diffState == self.ENCODER_DIFF_CCW):
1177 | if (self.select_PLA.dec()):
1178 | self.Move_Highlight(-1, self.select_PLA.now)
1179 | elif (encoder_diffState == self.ENCODER_DIFF_ENTER):
1180 |
1181 | if self.select_PLA.now == 0: # Back
1182 | self.checkkey = self.TemperatureID
1183 | self.select_temp.now = self.TEMP_CASE_PLA
1184 | self.pd.HMI_ValueStruct.show_mode = -1
1185 | self.Draw_Temperature_Menu()
1186 | elif self.select_PLA.now == self.PREHEAT_CASE_TEMP: # Nozzle temperature
1187 | self.checkkey = self.ETemp
1188 | self.pd.HMI_ValueStruct.E_Temp = self.pd.material_preset[0].hotend_temp
1189 | self.lcd.Draw_IntValue(
1190 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Select_Color,
1191 | 3, 216, self.MBASE(self.PREHEAT_CASE_TEMP),
1192 | self.pd.material_preset[0].hotend_temp
1193 | )
1194 | self.pd.encoderRate = True
1195 | elif self.select_PLA.now == self.PREHEAT_CASE_BED: # Bed temperature
1196 | self.checkkey = self.BedTemp
1197 | self.pd.HMI_ValueStruct.Bed_Temp = self.pd.material_preset[0].bed_temp
1198 | self.lcd.Draw_IntValue(
1199 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Select_Color,
1200 | 3, 216, self.MBASE(self.PREHEAT_CASE_BED),
1201 | self.pd.material_preset[0].bed_temp
1202 | )
1203 | self.pd.encoderRate = True
1204 | elif self.select_PLA.now == self.PREHEAT_CASE_FAN: # Fan speed
1205 | self.checkkey = self.FanSpeed
1206 | self.pd.HMI_ValueStruct.Fan_speed = self.pd.material_preset[0].fan_speed
1207 | self.lcd.Draw_IntValue(
1208 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Select_Color,
1209 | 3, 216, self.MBASE(self.PREHEAT_CASE_FAN),
1210 | self.pd.material_preset[0].fan_speed
1211 | )
1212 | self.pd.encoderRate = True
1213 | elif self.select_PLA.now == self.PREHEAT_CASE_SAVE: # Save PLA configuration
1214 | success = self.pd.save_settings()
1215 | self.HMI_AudioFeedback(success)
1216 | self.lcd.UpdateLCD()
1217 |
1218 | def HMI_ABSPreheatSetting(self):
1219 | encoder_diffState = self.get_encoder_state()
1220 | if (encoder_diffState == self.ENCODER_DIFF_NO):
1221 | return
1222 | # Avoid flicker by updating only the previous menu
1223 | elif (encoder_diffState == self.ENCODER_DIFF_CW):
1224 | if (self.select_ABS.inc(1 + self.PREHEAT_CASE_TOTAL)):
1225 | self.Move_Highlight(1, self.select_ABS.now)
1226 | elif (encoder_diffState == self.ENCODER_DIFF_CCW):
1227 | if (self.select_ABS.dec()):
1228 | self.Move_Highlight(-1, self.select_ABS.now)
1229 | elif (encoder_diffState == self.ENCODER_DIFF_ENTER):
1230 |
1231 | if self.select_ABS.now == 0: # Back
1232 | self.checkkey = self.TemperatureID
1233 | self.select_temp.now = self.TEMP_CASE_ABS
1234 | self.pd.HMI_ValueStruct.show_mode = -1
1235 | self.Draw_Temperature_Menu()
1236 |
1237 | elif self.select_ABS.now == self.PREHEAT_CASE_TEMP: # Nozzle temperature
1238 | self.checkkey = self.ETemp
1239 | self.pd.HMI_ValueStruct.E_Temp = self.pd.material_preset[1].hotend_temp
1240 | print(self.pd.HMI_ValueStruct.E_Temp)
1241 | self.lcd.Draw_IntValue(
1242 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Select_Color,
1243 | 3, 216, self.MBASE(self.PREHEAT_CASE_TEMP),
1244 | self.pd.material_preset[1].hotend_temp
1245 | )
1246 | self.pd.encoderRate = True
1247 | elif self.select_ABS.now == self.PREHEAT_CASE_BED: # Bed temperature
1248 | self.checkkey = self.BedTemp
1249 | self.pd.HMI_ValueStruct.Bed_Temp = self.pd.material_preset[1].bed_temp
1250 | self.lcd.Draw_IntValue(
1251 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Select_Color,
1252 | 3, 216, self.MBASE(self.PREHEAT_CASE_BED),
1253 | self.pd.material_preset[1].bed_temp
1254 | )
1255 | self.pd.encoderRate = True
1256 | elif self.select_ABS.now == self.PREHEAT_CASE_FAN: # Fan speed
1257 | self.checkkey = self.FanSpeed
1258 | self.pd.HMI_ValueStruct.Fan_speed = self.pd.material_preset[1].fan_speed
1259 | self.lcd.Draw_IntValue(
1260 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Select_Color,
1261 | 3, 216, self.MBASE(self.PREHEAT_CASE_FAN),
1262 | self.pd.material_preset[1].fan_speed
1263 | )
1264 | self.pd.encoderRate = True
1265 | elif self.select_ABS.now == self.PREHEAT_CASE_SAVE: # Save PLA configuration
1266 | success = self.pd.save_settings()
1267 | self.HMI_AudioFeedback(success)
1268 | self.lcd.UpdateLCD()
1269 |
1270 | def HMI_ETemp(self):
1271 | encoder_diffState = self.get_encoder_state()
1272 | if (encoder_diffState == self.ENCODER_DIFF_NO):
1273 | return
1274 |
1275 | if self.pd.HMI_ValueStruct.show_mode == -1:
1276 | temp_line = self.TEMP_CASE_TEMP
1277 | elif self.pd.HMI_ValueStruct.show_mode == -2:
1278 | temp_line = self.PREHEAT_CASE_TEMP
1279 | elif self.pd.HMI_ValueStruct.show_mode == -3:
1280 | temp_line = self.PREHEAT_CASE_TEMP
1281 | else:
1282 | temp_line = self.TUNE_CASE_TEMP + self.MROWS - self.index_tune
1283 |
1284 | if (encoder_diffState == self.ENCODER_DIFF_ENTER):
1285 | self.pd.encoderRate = False
1286 | if (self.pd.HMI_ValueStruct.show_mode == -1): # temperature
1287 | self.checkkey = self.TemperatureID
1288 | self.lcd.Draw_IntValue(
1289 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1290 | 3, 216, self.MBASE(temp_line),
1291 | self.pd.HMI_ValueStruct.E_Temp
1292 | )
1293 | elif (self.pd.HMI_ValueStruct.show_mode == -2):
1294 | self.checkkey = self.PLAPreheat
1295 | self.pd.material_preset[0].hotend_temp = self.pd.HMI_ValueStruct.E_Temp
1296 | self.lcd.Draw_IntValue(
1297 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1298 | 3, 216, self.MBASE(temp_line),
1299 | self.pd.material_preset[0].hotend_temp
1300 | )
1301 | return
1302 | elif (self.pd.HMI_ValueStruct.show_mode == -3):
1303 | self.checkkey = self.ABSPreheat
1304 | self.pd.material_preset[1].hotend_temp = self.pd.HMI_ValueStruct.E_Temp
1305 | self.lcd.Draw_IntValue(
1306 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1307 | 3, 216, self.MBASE(temp_line),
1308 | self.pd.material_preset[1].hotend_temp
1309 | )
1310 | return
1311 | else: # tune
1312 | self.checkkey = self.Tune
1313 | self.lcd.Draw_IntValue(
1314 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1315 | 3, 216, self.MBASE(temp_line),
1316 | self.pd.HMI_ValueStruct.E_Temp
1317 | )
1318 | self.pd.setTargetHotend(self.pd.HMI_ValueStruct.E_Temp, 0)
1319 | return
1320 |
1321 | elif (encoder_diffState == self.ENCODER_DIFF_CW):
1322 | self.pd.HMI_ValueStruct.E_Temp += 1
1323 |
1324 | elif (encoder_diffState == self.ENCODER_DIFF_CCW):
1325 | self.pd.HMI_ValueStruct.E_Temp -= 1
1326 |
1327 | # E_Temp limit
1328 | if self.pd.HMI_ValueStruct.E_Temp > self.pd.MAX_E_TEMP:
1329 | self.pd.HMI_ValueStruct.E_Temp = self.pd.MAX_E_TEMP
1330 | if self.pd.HMI_ValueStruct.E_Temp < self.pd.MIN_E_TEMP:
1331 | self.pd.HMI_ValueStruct.E_Temp = self.pd.MIN_E_TEMP
1332 | # E_Temp value
1333 | self.lcd.Draw_IntValue(
1334 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Select_Color,
1335 | 3, 216, self.MBASE(temp_line),
1336 | self.pd.HMI_ValueStruct.E_Temp
1337 | )
1338 |
1339 | def HMI_BedTemp(self):
1340 | encoder_diffState = self.get_encoder_state()
1341 | if (encoder_diffState == self.ENCODER_DIFF_NO):
1342 | return
1343 |
1344 | if self.pd.HMI_ValueStruct.show_mode == -1:
1345 | bed_line = self.TEMP_CASE_BED
1346 | elif self.pd.HMI_ValueStruct.show_mode == -2:
1347 | bed_line = self.PREHEAT_CASE_BED
1348 | elif self.pd.HMI_ValueStruct.show_mode == -3:
1349 | bed_line = self.PREHEAT_CASE_BED
1350 | else:
1351 | bed_line = self.TUNE_CASE_TEMP + self.MROWS - self.index_tune
1352 |
1353 | if (encoder_diffState == self.ENCODER_DIFF_ENTER):
1354 | self.pd.encoderRate = False
1355 | if (self.pd.HMI_ValueStruct.show_mode == -1): # temperature
1356 | self.checkkey = self.TemperatureID
1357 | self.lcd.Draw_IntValue(
1358 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1359 | 3, 216, self.MBASE(bed_line),
1360 | self.pd.HMI_ValueStruct.Bed_Temp
1361 | )
1362 | elif (self.pd.HMI_ValueStruct.show_mode == -2):
1363 | self.checkkey = self.PLAPreheat
1364 | self.pd.material_preset[0].bed_temp = self.pd.HMI_ValueStruct.Bed_Temp
1365 | self.lcd.Draw_IntValue(
1366 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1367 | 3, 216, self.MBASE(bed_line),
1368 | self.pd.material_preset[0].bed_temp
1369 | )
1370 | return
1371 | elif (self.pd.HMI_ValueStruct.show_mode == -3):
1372 | self.checkkey = self.ABSPreheat
1373 | self.pd.material_preset[1].bed_temp = self.pd.HMI_ValueStruct.Bed_Temp
1374 | self.lcd.Draw_IntValue(
1375 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1376 | 3, 216, self.MBASE(bed_line),
1377 | self.pd.material_preset[1].bed_temp
1378 | )
1379 | return
1380 | else: # tune
1381 | self.checkkey = self.Tune
1382 | self.lcd.Draw_IntValue(
1383 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1384 | 3, 216, self.MBASE(bed_line),
1385 | self.pd.HMI_ValueStruct.Bed_Temp
1386 | )
1387 | self.pd.setTargetHotend(self.pd.HMI_ValueStruct.Bed_Temp, 0)
1388 | return
1389 |
1390 | elif (encoder_diffState == self.ENCODER_DIFF_CW):
1391 | self.pd.HMI_ValueStruct.Bed_Temp += 1
1392 |
1393 | elif (encoder_diffState == self.ENCODER_DIFF_CCW):
1394 | self.pd.HMI_ValueStruct.Bed_Temp -= 1
1395 |
1396 | # Bed_Temp limit
1397 | if self.pd.HMI_ValueStruct.Bed_Temp > self.pd.BED_MAX_TARGET:
1398 | self.pd.HMI_ValueStruct.Bed_Temp = self.pd.BED_MAX_TARGET
1399 | if self.pd.HMI_ValueStruct.Bed_Temp < self.pd.MIN_BED_TEMP:
1400 | self.pd.HMI_ValueStruct.Bed_Temp = self.pd.MIN_BED_TEMP
1401 | # Bed_Temp value
1402 | self.lcd.Draw_IntValue(
1403 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Select_Color,
1404 | 3, 216, self.MBASE(bed_line),
1405 | self.pd.HMI_ValueStruct.Bed_Temp
1406 | )
1407 |
1408 | # ---------------------Todo--------------------------------#
1409 |
1410 | def HMI_Motion(self):
1411 | encoder_diffState = self.get_encoder_state()
1412 | if (encoder_diffState == self.ENCODER_DIFF_NO):
1413 | return
1414 | if (encoder_diffState == self.ENCODER_DIFF_CW):
1415 | if (self.select_motion.inc(1 + self.MOTION_CASE_TOTAL)):
1416 | self.Move_Highlight(1, self.select_motion.now)
1417 | elif (encoder_diffState == self.ENCODER_DIFF_CCW):
1418 | if (self.select_motion.dec()):
1419 | self.Move_Highlight(-1, self.select_motion.now)
1420 | elif (encoder_diffState == self.ENCODER_DIFF_ENTER):
1421 | if self.select_motion.now == 0: # back
1422 | self.checkkey = self.Control
1423 | self.select_control.set(self.CONTROL_CASE_MOVE)
1424 | self.index_control = self.MROWS
1425 | self.Draw_Control_Menu()
1426 | self.lcd.UpdateLCD()
1427 |
1428 | def HMI_Zoffset(self):
1429 | encoder_diffState = self.get_encoder_state()
1430 | if (encoder_diffState == self.ENCODER_DIFF_NO):
1431 | return
1432 |
1433 | zoff_line = 0
1434 | if self.pd.HMI_ValueStruct.show_mode == -4:
1435 | zoff_line = self.PREPARE_CASE_ZOFF + self.MROWS - self.index_prepare
1436 | else:
1437 | zoff_line = self.TUNE_CASE_ZOFF + self.MROWS - self.index_tune
1438 |
1439 | if (encoder_diffState == self.ENCODER_DIFF_ENTER):
1440 | self.pd.encoderRate = False
1441 | if self.pd.HAS_BED_PROBE:
1442 | self.pd.offset_z(self.dwin_zoffset)
1443 | if (self.pd.HMI_ValueStruct.show_mode == -4):
1444 | self.checkkey = self.Prepare
1445 | if self.pd.HAS_BED_PROBE:
1446 | self.lcd.Draw_Signed_Float(
1447 | self.lcd.font8x16, self.lcd.Color_Bg_Black, 2, 2, 202, self.MBASE(zoff_line),
1448 | self.pd.BABY_Z_VAR * 100
1449 | )
1450 | else:
1451 | self.lcd.Draw_Signed_Float(
1452 | self.lcd.font8x16, self.lcd.Color_Bg_Black, 2, 2, 202, self.MBASE(zoff_line),
1453 | self.pd.HMI_ValueStruct.offset_value
1454 | )
1455 | else:
1456 | self.checkkey = self.Tune
1457 | if self.pd.HAS_BED_PROBE:
1458 | self.lcd.Draw_Signed_Float(
1459 | self.lcd.font8x16, self.lcd.Color_Bg_Black, 2, 2, 202, self.MBASE(zoff_line),
1460 | self.pd.BABY_Z_VAR * 100
1461 | )
1462 | else:
1463 | self.lcd.Draw_Signed_Float(
1464 | self.lcd.font8x16, self.lcd.Color_Bg_Black, 2, 2, 202, self.MBASE(zoff_line),
1465 | self.pd.HMI_ValueStruct.offset_value
1466 | )
1467 | self.lcd.UpdateLCD()
1468 | return
1469 |
1470 | elif (encoder_diffState == self.ENCODER_DIFF_CW):
1471 | self.pd.HMI_ValueStruct.offset_value += 1
1472 | elif (encoder_diffState == self.ENCODER_DIFF_CCW):
1473 | self.pd.HMI_ValueStruct.offset_value -= 1
1474 |
1475 | if (self.pd.HMI_ValueStruct.offset_value < (self.pd.Z_PROBE_OFFSET_RANGE_MIN) * 100):
1476 | self.pd.HMI_ValueStruct.offset_value = self.pd.Z_PROBE_OFFSET_RANGE_MIN * 100
1477 | elif (self.pd.HMI_ValueStruct.offset_value > (self.pd.Z_PROBE_OFFSET_RANGE_MAX) * 100):
1478 | self.pd.HMI_ValueStruct.offset_value = self.pd.Z_PROBE_OFFSET_RANGE_MAX * 100
1479 |
1480 | self.last_zoffset = self.dwin_zoffset
1481 | self.dwin_zoffset = self.pd.HMI_ValueStruct.offset_value / 100.0
1482 | self.pd.add_mm('Z', self.dwin_zoffset - self.last_zoffset)
1483 | self.lcd.Draw_Signed_Float(
1484 | self.lcd.font8x16, self.lcd.Select_Color, 2, 2, 202,
1485 | self.MBASE(zoff_line),
1486 | self.pd.HMI_ValueStruct.offset_value
1487 | )
1488 | self.lcd.UpdateLCD()
1489 |
1490 | def HMI_MaxSpeed(self):
1491 | encoder_diffState = self.get_encoder_state()
1492 | if (encoder_diffState == self.ENCODER_DIFF_NO):
1493 | return
1494 |
1495 | def HMI_MaxAcceleration(self):
1496 | encoder_diffState = self.get_encoder_state()
1497 | if (encoder_diffState == self.ENCODER_DIFF_NO):
1498 | return
1499 |
1500 | def HMI_MaxJerk(self):
1501 | encoder_diffState = self.get_encoder_state()
1502 | if (encoder_diffState == self.ENCODER_DIFF_NO):
1503 | return
1504 |
1505 | def HMI_Step(self):
1506 | encoder_diffState = self.get_encoder_state()
1507 | if (encoder_diffState == self.ENCODER_DIFF_NO):
1508 | return
1509 |
1510 | def HMI_MaxFeedspeedXYZE(self):
1511 | encoder_diffState = self.get_encoder_state()
1512 | if (encoder_diffState == self.ENCODER_DIFF_NO):
1513 | return
1514 |
1515 | def HMI_MaxAccelerationXYZE(self):
1516 | encoder_diffState = self.get_encoder_state()
1517 | if (encoder_diffState == self.ENCODER_DIFF_NO):
1518 | return
1519 |
1520 | def HMI_MaxJerkXYZE(self):
1521 | encoder_diffState = self.get_encoder_state()
1522 | if (encoder_diffState == self.ENCODER_DIFF_NO):
1523 | return
1524 |
1525 | def HMI_StepXYZE(self):
1526 | encoder_diffState = self.get_encoder_state()
1527 | if (encoder_diffState == self.ENCODER_DIFF_NO):
1528 | return
1529 |
1530 | # --------------------------------------------------------------#
1531 | # --------------------------------------------------------------#
1532 |
1533 | def Draw_Status_Area(self, with_update):
1534 | # Clear the bottom area of the screen
1535 | self.lcd.Draw_Rectangle(1, self.lcd.Color_Bg_Black, 0, self.STATUS_Y, self.lcd.DWIN_WIDTH, self.lcd.DWIN_HEIGHT - 1)
1536 | #
1537 | # Status Area
1538 | #
1539 | if self.pd.HAS_HOTEND:
1540 | self.lcd.ICON_Show(self.ICON, self.ICON_HotendTemp, 13, 381)
1541 | self.lcd.Draw_IntValue(
1542 | True, True, 0, self.lcd.DWIN_FONT_STAT,
1543 | self.lcd.Color_White, self.lcd.Color_Bg_Black,
1544 | 3, 33, 382,
1545 | self.pd.thermalManager['temp_hotend'][0]['celsius']
1546 | )
1547 | self.lcd.Draw_String(
1548 | False, False, self.lcd.DWIN_FONT_STAT,
1549 | self.lcd.Color_White, self.lcd.Color_Bg_Black,
1550 | 33 + 3 * self.STAT_CHR_W + 5, 383,
1551 | "/"
1552 | )
1553 | self.lcd.Draw_IntValue(
1554 | True, True, 0, self.lcd.DWIN_FONT_STAT,
1555 | self.lcd.Color_White, self.lcd.Color_Bg_Black, 3, 33 + 4 * self.STAT_CHR_W + 6, 382,
1556 | self.pd.thermalManager['temp_hotend'][0]['target']
1557 | )
1558 |
1559 | if self.pd.HOTENDS > 1:
1560 | self.lcd.ICON_Show(self.ICON, self.ICON_HotendTemp, 13, 381)
1561 |
1562 | if self.pd.HAS_HEATED_BED:
1563 | self.lcd.ICON_Show(self.ICON, self.ICON_BedTemp, 158, 381)
1564 | self.lcd.Draw_IntValue(
1565 | True, True, 0, self.lcd.DWIN_FONT_STAT, self.lcd.Color_White,
1566 | self.lcd.Color_Bg_Black, 3, 178, 382,
1567 | self.pd.thermalManager['temp_bed']['celsius']
1568 | )
1569 | self.lcd.Draw_String(
1570 | False, False, self.lcd.DWIN_FONT_STAT, self.lcd.Color_White,
1571 | self.lcd.Color_Bg_Black, 178 + 3 * self.STAT_CHR_W + 5, 383,
1572 | "/"
1573 | )
1574 | self.lcd.Draw_IntValue(
1575 | True, True, 0, self.lcd.DWIN_FONT_STAT,
1576 | self.lcd.Color_White, self.lcd.Color_Bg_Black, 3, 178 + 4 * self.STAT_CHR_W + 6, 382,
1577 | self.pd.thermalManager['temp_bed']['target']
1578 | )
1579 |
1580 | self.lcd.ICON_Show(self.ICON, self.ICON_Speed, 13, 429)
1581 | self.lcd.Draw_IntValue(
1582 | True, True, 0, self.lcd.DWIN_FONT_STAT,
1583 | self.lcd.Color_White, self.lcd.Color_Bg_Black, 3, 33 + 2 * self.STAT_CHR_W, 429,
1584 | self.pd.feedrate_percentage
1585 | )
1586 | self.lcd.Draw_String(
1587 | False, False, self.lcd.DWIN_FONT_STAT,
1588 | self.lcd.Color_White, self.lcd.Color_Bg_Black, 33 + 5 * self.STAT_CHR_W + 2, 429,
1589 | "%"
1590 | )
1591 |
1592 | if self.pd.HAS_ZOFFSET_ITEM:
1593 | self.lcd.ICON_Show(self.ICON, self.ICON_Zoffset, 158, 428)
1594 | self.lcd.Draw_Signed_Float(self.lcd.DWIN_FONT_STAT, self.lcd.Color_Bg_Black, 2, 2, 178, 429, self.pd.BABY_Z_VAR * 100)
1595 |
1596 | # if with_update:
1597 | # self.lcd.UpdateLCD()
1598 | # time.sleep(.005)
1599 |
1600 | def Draw_Title(self, title):
1601 | self.lcd.Draw_String(False, False, self.lcd.DWIN_FONT_HEAD, self.lcd.Color_White, self.lcd.Color_Bg_Blue, 14, 4, title)
1602 |
1603 | def Draw_Popup_Bkgd_105(self):
1604 | self.lcd.Draw_Rectangle(1, self.lcd.Color_Bg_Window, 14, 105, 258, 374)
1605 |
1606 | def Draw_More_Icon(self, line):
1607 | self.lcd.ICON_Show(self.ICON, self.ICON_More, 226, self.MBASE(line) - 3)
1608 |
1609 | def Draw_Menu_Cursor(self, line):
1610 | self.lcd.Draw_Rectangle(1, self.lcd.Rectangle_Color, 0, self.MBASE(line) - 18, 14, self.MBASE(line + 1) - 20)
1611 |
1612 | def Draw_Menu_Icon(self, line, icon):
1613 | self.lcd.ICON_Show(self.ICON, icon, 26, self.MBASE(line) - 3)
1614 |
1615 | def Draw_Menu_Line(self, line, icon=False, label=False):
1616 | if (label):
1617 | self.lcd.Draw_String(False, False, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black, self.LBLX, self.MBASE(line) - 1, label)
1618 | if (icon):
1619 | self.Draw_Menu_Icon(line, icon)
1620 | self.lcd.Draw_Line(self.lcd.Line_Color, 16, self.MBASE(line) + 33, 256, self.MBASE(line) + 34)
1621 |
1622 | # The "Back" label is always on the first line
1623 | def Draw_Back_Label(self):
1624 | self.lcd.Frame_AreaCopy(1, 226, 179, 256, 189, self.LBLX, self.MBASE(0))
1625 |
1626 | # Draw "Back" line at the top
1627 | def Draw_Back_First(self, is_sel=True):
1628 | self.Draw_Menu_Line(0, self.ICON_Back)
1629 | self.Draw_Back_Label()
1630 | if (is_sel):
1631 | self.Draw_Menu_Cursor(0)
1632 |
1633 | def draw_move_en(self, line):
1634 | self.lcd.Frame_AreaCopy(1, 69, 61, 102, 71, self.LBLX, line) # "Move"
1635 |
1636 | def draw_max_en(self, line):
1637 | self.lcd.Frame_AreaCopy(1, 245, 119, 269, 129, self.LBLX, line) # "Max"
1638 |
1639 | def draw_max_accel_en(self, line):
1640 | self.draw_max_en(line)
1641 | self.lcd.Frame_AreaCopy(1, 1, 135, 79, 145, self.LBLX + 27, line) # "Acceleration"
1642 |
1643 | def draw_speed_en(self, inset, line):
1644 | self.lcd.Frame_AreaCopy(1, 184, 119, 224, 132, self.LBLX + inset, line) # "Speed"
1645 |
1646 | def draw_jerk_en(self, line):
1647 | self.lcd.Frame_AreaCopy(1, 64, 119, 106, 129, self.LBLX + 27, line) # "Jerk"
1648 |
1649 | def draw_steps_per_mm(self, line):
1650 | self.lcd.Frame_AreaCopy(1, 1, 151, 101, 161, self.LBLX, line) # "Steps-per-mm"
1651 |
1652 | # Display an SD item
1653 | def Draw_SDItem(self, item, row=0):
1654 | fl = self.pd.GetFiles()[item]
1655 | self.Draw_Menu_Line(row, self.ICON_File, fl)
1656 |
1657 | def Draw_Select_Highlight(self, sel):
1658 | self.pd.HMI_flag.select_flag = sel
1659 | if sel:
1660 | c1 = self.lcd.Select_Color
1661 | c2 = self.lcd.Color_Bg_Window
1662 | else:
1663 | c1 = self.lcd.Color_Bg_Window
1664 | c2 = self.lcd.Select_Color
1665 | self.lcd.Draw_Rectangle(0, c1, 25, 279, 126, 318)
1666 | self.lcd.Draw_Rectangle(0, c1, 24, 278, 127, 319)
1667 | self.lcd.Draw_Rectangle(0, c2, 145, 279, 246, 318)
1668 | self.lcd.Draw_Rectangle(0, c2, 144, 278, 247, 319)
1669 |
1670 | def Draw_Popup_Bkgd_60(self):
1671 | self.lcd.Draw_Rectangle(1, self.lcd.Color_Bg_Window, 14, 60, 258, 330)
1672 |
1673 | def Draw_Printing_Screen(self):
1674 | self.lcd.Frame_AreaCopy(1, 40, 2, 92, 14, 14, 9) # Tune
1675 | self.lcd.Frame_AreaCopy(1, 0, 44, 96, 58, 41, 188) # Pause
1676 | self.lcd.Frame_AreaCopy(1, 98, 44, 152, 58, 176, 188) # Stop
1677 |
1678 | def Draw_Print_ProgressBar(self, Percentrecord=None):
1679 | if not Percentrecord:
1680 | Percentrecord = self.pd.getPercent()
1681 | self.lcd.ICON_Show(self.ICON, self.ICON_Bar, 15, 93)
1682 | self.lcd.Draw_Rectangle(1, self.lcd.BarFill_Color, 16 + Percentrecord * 240 / 100, 93, 256, 113)
1683 | self.lcd.Draw_IntValue(True, True, 0, self.lcd.font8x16, self.lcd.Percent_Color, self.lcd.Color_Bg_Black, 2, 117, 133, Percentrecord)
1684 | self.lcd.Draw_String(False, False, self.lcd.font8x16, self.lcd.Percent_Color, self.lcd.Color_Bg_Black, 133, 133, "%")
1685 |
1686 | def Draw_Print_ProgressElapsed(self):
1687 | elapsed = self.pd.duration() # print timer
1688 | self.lcd.Draw_IntValue(True, True, 1, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black, 2, 42, 212, elapsed / 3600)
1689 | self.lcd.Draw_String(False, False, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black, 58, 212, ":")
1690 | self.lcd.Draw_IntValue(True, True, 1, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black, 2, 66, 212, (elapsed % 3600) / 60)
1691 |
1692 | def Draw_Print_ProgressRemain(self):
1693 | remain_time = self.pd.remain()
1694 | self.lcd.Draw_IntValue(True, True, 1, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black, 2, 176, 212, remain_time / 3600)
1695 | self.lcd.Draw_String(False, False, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black, 192, 212, ":")
1696 | self.lcd.Draw_IntValue(True, True, 1, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black, 2, 200, 212, (remain_time % 3600) / 60)
1697 |
1698 | def Draw_Print_File_Menu(self):
1699 | self.Clear_Title_Bar()
1700 | self.lcd.Frame_TitleCopy(1, 52, 31, 137, 41) # "Print file"
1701 | self.Redraw_SD_List()
1702 |
1703 | def Draw_Prepare_Menu(self):
1704 | self.Clear_Main_Window()
1705 | scroll = self.MROWS - self.index_prepare
1706 | self.lcd.Frame_TitleCopy(1, 178, 2, 229, 14) # "Prepare"
1707 | self.Draw_Back_First(self.select_prepare.now == 0) # < Back
1708 | if scroll + self.PREPARE_CASE_MOVE <= self.MROWS:
1709 | self.Item_Prepare_Move(self.PREPARE_CASE_MOVE) # Move >
1710 | if scroll + self.PREPARE_CASE_DISA <= self.MROWS:
1711 | self.Item_Prepare_Disable(self.PREPARE_CASE_DISA) # Disable Stepper
1712 | if scroll + self.PREPARE_CASE_HOME <= self.MROWS:
1713 | self.Item_Prepare_Home(self.PREPARE_CASE_HOME) # Auto Home
1714 | if self.pd.HAS_ZOFFSET_ITEM:
1715 | if scroll + self.PREPARE_CASE_ZOFF <= self.MROWS:
1716 | self.Item_Prepare_Offset(self.PREPARE_CASE_ZOFF) # Edit Z-Offset / Babystep / Set Home Offset
1717 | if self.pd.HAS_HOTEND:
1718 | if scroll + self.PREPARE_CASE_PLA <= self.MROWS:
1719 | self.Item_Prepare_PLA(self.PREPARE_CASE_PLA) # Preheat PLA
1720 | if scroll + self.PREPARE_CASE_ABS <= self.MROWS:
1721 | self.Item_Prepare_ABS(self.PREPARE_CASE_ABS) # Preheat ABS
1722 | if self.pd.HAS_PREHEAT:
1723 | if scroll + self.PREPARE_CASE_COOL <= self.MROWS:
1724 | self.Item_Prepare_Cool(self.PREPARE_CASE_COOL) # Cooldown
1725 | if (self.select_prepare.now):
1726 | self.Draw_Menu_Cursor(self.select_prepare.now)
1727 |
1728 | def Draw_Control_Menu(self):
1729 | self.Clear_Main_Window()
1730 | self.Draw_Back_First(self.select_control.now == 0)
1731 | self.lcd.Frame_TitleCopy(1, 128, 2, 176, 12) # "Control"
1732 | self.lcd.Frame_AreaCopy(1, 1, 89, 83, 101, self.LBLX, self.MBASE(self.CONTROL_CASE_TEMP)) # Temperature >
1733 | self.lcd.Frame_AreaCopy(1, 84, 89, 128, 99, self.LBLX, self.MBASE(self.CONTROL_CASE_MOVE)) # Motion >
1734 | self.lcd.Frame_AreaCopy(1, 0, 104, 25, 115, self.LBLX, self.MBASE(self.CONTROL_CASE_INFO)) # Info >
1735 |
1736 | if self.select_control.now and self.select_control.now < self.MROWS:
1737 | self.Draw_Menu_Cursor(self.select_control.now)
1738 |
1739 | # # Draw icons and lines
1740 | self.Draw_Menu_Line(1, self.ICON_Temperature)
1741 | self.Draw_More_Icon(1)
1742 | self.Draw_Menu_Line(2, self.ICON_Motion)
1743 | self.Draw_More_Icon(2)
1744 | self.Draw_Menu_Line(3, self.ICON_Info)
1745 | self.Draw_More_Icon(3)
1746 |
1747 | def Draw_Info_Menu(self):
1748 | self.Clear_Main_Window()
1749 |
1750 | self.lcd.Draw_String(
1751 | False, False, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1752 | (self.lcd.DWIN_WIDTH - len(self.pd.MACHINE_SIZE) * self.MENU_CHR_W) / 2, 122,
1753 | self.pd.MACHINE_SIZE
1754 | )
1755 | self.lcd.Draw_String(
1756 | False, False, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1757 | (self.lcd.DWIN_WIDTH - len(self.pd.SHORT_BUILD_VERSION) * self.MENU_CHR_W) / 2, 195,
1758 | self.pd.SHORT_BUILD_VERSION
1759 | )
1760 | self.lcd.Frame_TitleCopy(1, 190, 16, 215, 26) # "Info"
1761 | self.lcd.Frame_AreaCopy(1, 120, 150, 146, 161, 124, 102)
1762 | self.lcd.Frame_AreaCopy(1, 146, 151, 254, 161, 82, 175)
1763 | self.lcd.Frame_AreaCopy(1, 0, 165, 94, 175, 89, 248)
1764 | self.lcd.Draw_String(
1765 | False, False, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1766 | (self.lcd.DWIN_WIDTH - len(self.pd.CORP_WEBSITE_E) * self.MENU_CHR_W) / 2, 268,
1767 | self.pd.CORP_WEBSITE_E
1768 | )
1769 | self.Draw_Back_First()
1770 | for i in range(3):
1771 | self.lcd.ICON_Show(self.ICON, self.ICON_PrintSize + i, 26, 99 + i * 73)
1772 | self.lcd.Draw_Line(self.lcd.Line_Color, 16, self.MBASE(2) + i * 73, 256, 156 + i * 73)
1773 |
1774 | def Draw_Tune_Menu(self):
1775 | self.Clear_Main_Window()
1776 | self.lcd.Frame_AreaCopy(1, 94, 2, 126, 12, 14, 9)
1777 | self.lcd.Frame_AreaCopy(1, 1, 179, 92, 190, self.LBLX, self.MBASE(self.TUNE_CASE_SPEED)) # Print speed
1778 | if self.pd.HAS_HOTEND:
1779 | self.lcd.Frame_AreaCopy(1, 197, 104, 238, 114, self.LBLX, self.MBASE(self.TUNE_CASE_TEMP)) # Hotend...
1780 | self.lcd.Frame_AreaCopy(1, 1, 89, 83, 101, self.LBLX + 44, self.MBASE(self.TUNE_CASE_TEMP)) # Temperature
1781 | if self.pd.HAS_HEATED_BED:
1782 | self.lcd.Frame_AreaCopy(1, 240, 104, 264, 114, self.LBLX, self.MBASE(self.TUNE_CASE_BED)) # Bed...
1783 | self.lcd.Frame_AreaCopy(1, 1, 89, 83, 101, self.LBLX + 27, self.MBASE(self.TUNE_CASE_BED)) # ...Temperature
1784 | # if self.pd.HAS_FAN:
1785 | # self.lcd.Frame_AreaCopy(1, 0, 119, 64, 132, self.LBLX, self.MBASE(self.TUNE_CASE_FAN)) # Fan speed
1786 | # if self.pd.HAS_ZOFFSET_ITEM:
1787 | # self.lcd.Frame_AreaCopy(1, 93, 179, 141, 189, self.LBLX, self.MBASE(self.TUNE_CASE_ZOFF)) # Z-offset
1788 | self.Draw_Back_First(self.select_tune.now == 0)
1789 | if (self.select_tune.now):
1790 | self.Draw_Menu_Cursor(self.select_tune.now)
1791 |
1792 | self.Draw_Menu_Line(self.TUNE_CASE_SPEED, self.ICON_Speed)
1793 | self.lcd.Draw_IntValue(
1794 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1795 | 3, 216, self.MBASE(self.TUNE_CASE_SPEED), self.pd.feedrate_percentage)
1796 |
1797 | if self.pd.HAS_HOTEND:
1798 | self.Draw_Menu_Line(self.TUNE_CASE_TEMP, self.ICON_HotendTemp)
1799 | self.lcd.Draw_IntValue(
1800 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1801 | 3, 216, self.MBASE(self.TUNE_CASE_TEMP),
1802 | self.pd.thermalManager['temp_hotend'][0]['target']
1803 | )
1804 | if self.pd.HAS_HEATED_BED:
1805 | self.Draw_Menu_Line(self.TUNE_CASE_BED, self.ICON_BedTemp)
1806 | self.lcd.Draw_IntValue(
1807 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1808 | 3, 216, self.MBASE(self.TUNE_CASE_BED), self.pd.thermalManager['temp_bed']['target'])
1809 | # if self.pd.HAS_FAN:
1810 | # self.Draw_Menu_Line(self.TUNE_CASE_FAN, self.ICON_FanSpeed)
1811 | # self.lcd.Draw_IntValue(
1812 | # True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1813 | # 3, 216, self.MBASE(self.TUNE_CASE_FAN),
1814 | # self.pd.thermalManager['fan_speed'][0]
1815 | # )
1816 | # if self.pd.HAS_ZOFFSET_ITEM:
1817 | # self.Draw_Menu_Line(self.TUNE_CASE_ZOFF, self.ICON_Zoffset)
1818 | # self.lcd.Draw_Signed_Float(
1819 | # self.lcd.font8x16, self.lcd.Color_Bg_Black, 2, 2, 202, self.MBASE(self.TUNE_CASE_ZOFF), self.pd.BABY_Z_VAR * 100
1820 | # )
1821 |
1822 | def Draw_Temperature_Menu(self):
1823 | self.Clear_Main_Window()
1824 | self.lcd.Frame_TitleCopy(1, 56, 16, 141, 28) # "Temperature"
1825 | if self.pd.HAS_HOTEND:
1826 | self.lcd.Frame_AreaCopy(1, 197, 104, 238, 114, self.LBLX, self.MBASE(self.TEMP_CASE_TEMP)) # Nozzle...
1827 | self.lcd.Frame_AreaCopy(1, 1, 89, 83, 101, self.LBLX + 44, self.MBASE(self.TEMP_CASE_TEMP)) # ...Temperature
1828 | if self.pd.HAS_HEATED_BED:
1829 | self.lcd.Frame_AreaCopy(1, 240, 104, 264, 114, self.LBLX, self.MBASE(self.TEMP_CASE_BED)) # Bed...
1830 | self.lcd.Frame_AreaCopy(1, 1, 89, 83, 101, self.LBLX + 27, self.MBASE(self.TEMP_CASE_BED)) # ...Temperature
1831 | if self.pd.HAS_FAN:
1832 | self.lcd.Frame_AreaCopy(1, 0, 119, 64, 132, self.LBLX, self.MBASE(self.TEMP_CASE_FAN)) # Fan speed
1833 | if self.pd.HAS_HOTEND:
1834 | self.lcd.Frame_AreaCopy(1, 107, 76, 156, 86, self.LBLX, self.MBASE(self.TEMP_CASE_PLA)) # Preheat...
1835 | self.lcd.Frame_AreaCopy(1, 157, 76, 181, 86, self.LBLX + 52, self.MBASE(self.TEMP_CASE_PLA)) # ...PLA
1836 | self.lcd.Frame_AreaCopy(1, 131, 119, 182, 132, self.LBLX + 79, self.MBASE(self.TEMP_CASE_PLA)) # PLA setting
1837 | self.lcd.Frame_AreaCopy(1, 107, 76, 156, 86, self.LBLX, self.MBASE(self.TEMP_CASE_ABS)) # Preheat...
1838 | self.lcd.Frame_AreaCopy(1, 172, 76, 198, 86, self.LBLX + 52, self.MBASE(self.TEMP_CASE_ABS)) # ...ABS
1839 | self.lcd.Frame_AreaCopy(1, 131, 119, 182, 132, self.LBLX + 81, self.MBASE(self.TEMP_CASE_ABS)) # ABS setting
1840 |
1841 | self.Draw_Back_First(self.select_temp.now == 0)
1842 | if (self.select_temp.now):
1843 | self.Draw_Menu_Cursor(self.select_temp.now)
1844 |
1845 | # Draw icons and lines
1846 | i = 0
1847 | if self.pd.HAS_HOTEND:
1848 | i += 1
1849 | self.Draw_Menu_Line(self.ICON_SetEndTemp + (self.TEMP_CASE_TEMP) - 1)
1850 | self.lcd.Draw_IntValue(
1851 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1852 | 3, 216, self.MBASE(i),
1853 | self.pd.thermalManager['temp_hotend'][0]['target']
1854 | )
1855 | if self.pd.HAS_HEATED_BED:
1856 | i += 1
1857 | self.Draw_Menu_Line(self.ICON_SetEndTemp + (self.TEMP_CASE_BED) - 1)
1858 | self.lcd.Draw_IntValue(
1859 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1860 | 3, 216, self.MBASE(i),
1861 | self.pd.thermalManager['temp_bed']['target']
1862 | )
1863 | if self.pd.HAS_FAN:
1864 | i += 1
1865 | self.Draw_Menu_Line(self.ICON_SetEndTemp + (self.TEMP_CASE_FAN) - 1)
1866 | self.lcd.Draw_IntValue(
1867 | True, True, 0, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black,
1868 | 3, 216, self.MBASE(i),
1869 | self.pd.thermalManager['fan_speed'][0]
1870 | )
1871 | if self.pd.HAS_HOTEND:
1872 | # PLA/ABS items have submenus
1873 | i += 1
1874 | self.Draw_Menu_Line(self.ICON_SetEndTemp + (self.TEMP_CASE_PLA) - 1)
1875 | self.Draw_More_Icon(i)
1876 | i += 1
1877 | self.Draw_Menu_Line(self.ICON_SetEndTemp + (self.TEMP_CASE_ABS) - 1)
1878 | self.Draw_More_Icon(i)
1879 |
1880 | def Draw_Motion_Menu(self):
1881 | self.Clear_Main_Window()
1882 | self.lcd.Frame_TitleCopy(1, 144, 16, 189, 26) # "Motion"
1883 | self.draw_max_en(self.MBASE(self.MOTION_CASE_RATE))
1884 | self.draw_speed_en(27, self.MBASE(self.MOTION_CASE_RATE)) # "Max Speed"
1885 | self.draw_max_accel_en(self.MBASE(self.MOTION_CASE_ACCEL)) # "Max Acceleration"
1886 | self.draw_steps_per_mm(self.MBASE(self.MOTION_CASE_STEPS)) # "Steps-per-mm"
1887 |
1888 | self.Draw_Back_First(self.select_motion.now == 0)
1889 | if (self.select_motion.now):
1890 | self.Draw_Menu_Cursor(self.select_motion.now)
1891 |
1892 | i = 1
1893 | self.Draw_Menu_Line(self.ICON_MaxSpeed + (self.MOTION_CASE_RATE) - 1)
1894 | self.Draw_More_Icon(i)
1895 | i += 1
1896 | self.Draw_Menu_Line(self.ICON_MaxSpeed + (self.MOTION_CASE_ACCEL) - 1)
1897 | self.Draw_More_Icon(i)
1898 | i += 1
1899 | self.Draw_Menu_Line(self.ICON_MaxSpeed + (self.MOTION_CASE_STEPS) - 1)
1900 | self.Draw_More_Icon(i)
1901 |
1902 | def Draw_Move_Menu(self):
1903 | self.Clear_Main_Window()
1904 | self.lcd.Frame_TitleCopy(1, 231, 2, 265, 12) # "Move"
1905 | self.draw_move_en(self.MBASE(1))
1906 | self.say_x(36, self.MBASE(1)) # "Move X"
1907 | self.draw_move_en(self.MBASE(2))
1908 | self.say_y(36, self.MBASE(2)) # "Move Y"
1909 | self.draw_move_en(self.MBASE(3))
1910 | self.say_z(36, self.MBASE(3)) # "Move Z"
1911 | if self.pd.HAS_HOTEND:
1912 | self.lcd.Frame_AreaCopy(1, 123, 192, 176, 202, self.LBLX, self.MBASE(4)) # "Extruder"
1913 |
1914 | self.Draw_Back_First(self.select_axis.now == 0)
1915 | if (self.select_axis.now):
1916 | self.Draw_Menu_Cursor(self.select_axis.now)
1917 |
1918 | # Draw separators and icons
1919 | for i in range(4):
1920 | self.Draw_Menu_Line(i + 1, self.ICON_MoveX + i)
1921 |
1922 | # --------------------------------------------------------------#
1923 | # --------------------------------------------------------------#
1924 |
1925 | def Goto_MainMenu(self):
1926 | self.checkkey = self.MainMenu
1927 | self.Clear_Main_Window()
1928 |
1929 | self.lcd.Frame_AreaCopy(1, 0, 2, 39, 12, 14, 9)
1930 | self.lcd.ICON_Show(self.ICON, self.ICON_LOGO, 71, 52)
1931 |
1932 | self.ICON_Print()
1933 | self.ICON_Prepare()
1934 | self.ICON_Control()
1935 | if self.pd.HAS_ONESTEP_LEVELING:
1936 | self.ICON_Leveling(self.select_page.now == 3)
1937 | else:
1938 | self.ICON_StartInfo(self.select_page.now == 3)
1939 |
1940 | def Goto_PrintProcess(self):
1941 | self.checkkey = self.PrintProcess
1942 | self.Clear_Main_Window()
1943 | self.Draw_Printing_Screen()
1944 |
1945 | self.ICON_Tune()
1946 | if (self.pd.printingIsPaused()):
1947 | self.ICON_Continue()
1948 | else:
1949 | self.ICON_Pause()
1950 | self.ICON_Stop()
1951 |
1952 | # Copy into filebuf string before entry
1953 | name = self.pd.file_name
1954 | npos = _MAX(0, self.lcd.DWIN_WIDTH - len(name) * self.MENU_CHR_W) / 2
1955 | self.lcd.Draw_String(False, False, self.lcd.font8x16, self.lcd.Color_White, self.lcd.Color_Bg_Black, npos, 60, name)
1956 |
1957 | self.lcd.ICON_Show(self.ICON, self.ICON_PrintTime, 17, 193)
1958 | self.lcd.ICON_Show(self.ICON, self.ICON_RemainTime, 150, 191)
1959 |
1960 | self.Draw_Print_ProgressBar()
1961 | self.Draw_Print_ProgressElapsed()
1962 | self.Draw_Print_ProgressRemain()
1963 |
1964 | # --------------------------------------------------------------#
1965 | # --------------------------------------------------------------#
1966 |
1967 | def Clear_Title_Bar(self):
1968 | self.lcd.Draw_Rectangle(1, self.lcd.Color_Bg_Blue, 0, 0, self.lcd.DWIN_WIDTH, 30)
1969 |
1970 | def Clear_Menu_Area(self):
1971 | self.lcd.Draw_Rectangle(1, self.lcd.Color_Bg_Black, 0, 31, self.lcd.DWIN_WIDTH, self.STATUS_Y)
1972 |
1973 | def Clear_Main_Window(self):
1974 | self.Clear_Title_Bar()
1975 | self.Clear_Menu_Area()
1976 |
1977 | def Clear_Popup_Area(self):
1978 | self.Clear_Title_Bar()
1979 | self.lcd.Draw_Rectangle(1, self.lcd.Color_Bg_Black, 0, 31, self.lcd.DWIN_WIDTH, self.lcd.DWIN_HEIGHT)
1980 |
1981 | def Popup_window_PauseOrStop(self):
1982 | self.Clear_Main_Window()
1983 | self.Draw_Popup_Bkgd_60()
1984 | if(self.select_print.now == 1):
1985 | self.lcd.Draw_String(
1986 | False, True, self.lcd.font8x16, self.lcd.Popup_Text_Color, self.lcd.Color_Bg_Window,
1987 | (272 - 8 * 11) / 2, 150,
1988 | self.MSG_PAUSE_PRINT
1989 | )
1990 | elif (self.select_print.now == 2):
1991 | self.lcd.Draw_String(
1992 | False, True, self.lcd.font8x16, self.lcd.Popup_Text_Color, self.lcd.Color_Bg_Window,
1993 | (272 - 8 * 10) / 2, 150,
1994 | self.MSG_STOP_PRINT
1995 | )
1996 | self.lcd.ICON_Show(self.ICON, self.ICON_Confirm_E, 26, 280)
1997 | self.lcd.ICON_Show(self.ICON, self.ICON_Cancel_E, 146, 280)
1998 | self.Draw_Select_Highlight(True)
1999 |
2000 | def Popup_Window_Home(self, parking=False):
2001 | self.Clear_Main_Window()
2002 | self.Draw_Popup_Bkgd_60()
2003 | self.lcd.ICON_Show(self.ICON, self.ICON_BLTouch, 101, 105)
2004 | if parking:
2005 | self.lcd.Draw_String(
2006 | False, True, self.lcd.font8x16, self.lcd.Popup_Text_Color, self.lcd.Color_Bg_Window,
2007 | (272 - 8 * (7)) / 2, 230, "Parking")
2008 | else:
2009 | self.lcd.Draw_String(
2010 | False, True, self.lcd.font8x16, self.lcd.Popup_Text_Color, self.lcd.Color_Bg_Window,
2011 | (272 - 8 * (10)) / 2, 230, "Homing XYZ")
2012 |
2013 | self.lcd.Draw_String(
2014 | False, True, self.lcd.font8x16, self.lcd.Popup_Text_Color, self.lcd.Color_Bg_Window,
2015 | (272 - 8 * 23) / 2, 260, "Please wait until done.")
2016 |
2017 | def Popup_Window_ETempTooLow(self):
2018 | self.Clear_Main_Window()
2019 | self.Draw_Popup_Bkgd_60()
2020 | self.lcd.ICON_Show(self.ICON, self.ICON_TempTooLow, 102, 105)
2021 | self.lcd.Draw_String(
2022 | False, True, self.lcd.font8x16, self.lcd.Popup_Text_Color,
2023 | self.lcd.Color_Bg_Window, 20, 235,
2024 | "Nozzle is too cold"
2025 | )
2026 | self.lcd.ICON_Show(self.ICON, self.ICON_Confirm_E, 86, 280)
2027 |
2028 | def Erase_Menu_Cursor(self, line):
2029 | self.lcd.Draw_Rectangle(1, self.lcd.Color_Bg_Black, 0, self.MBASE(line) - 18, 14, self.MBASE(line + 1) - 20)
2030 |
2031 | def Erase_Menu_Text(self, line):
2032 | self.lcd.Draw_Rectangle(1, self.lcd.Color_Bg_Black, self.LBLX, self.MBASE(line) - 14, 271, self.MBASE(line) + 28)
2033 |
2034 | def Move_Highlight(self, ffrom, newline):
2035 | self.Erase_Menu_Cursor(newline - ffrom)
2036 | self.Draw_Menu_Cursor(newline)
2037 |
2038 | def Add_Menu_Line(self):
2039 | self.Move_Highlight(1, self.MROWS)
2040 | self.lcd.Draw_Line(self.lcd.Line_Color, 16, self.MBASE(self.MROWS + 1) - 20, 256, self.MBASE(self.MROWS + 1) - 19)
2041 |
2042 | def Scroll_Menu(self, dir):
2043 | self.lcd.Frame_AreaMove(1, dir, self.MLINE, self.lcd.Color_Bg_Black, 0, 31, self.lcd.DWIN_WIDTH, 349)
2044 | if dir == self.DWIN_SCROLL_DOWN:
2045 | self.Move_Highlight(-1, 0)
2046 | elif dir == self.DWIN_SCROLL_UP:
2047 | self.Add_Menu_Line()
2048 |
2049 | # Redraw the first set of SD Files
2050 | def Redraw_SD_List(self):
2051 | self.select_file.reset()
2052 | self.index_file = self.MROWS
2053 | self.Clear_Menu_Area() # Leave title bar unchanged
2054 | self.Draw_Back_First()
2055 | fl = self.pd.GetFiles()
2056 | ed = len(fl)
2057 | if ed > 0:
2058 | if ed > self.MROWS:
2059 | ed = self.MROWS
2060 | for i in range(ed):
2061 | self.Draw_SDItem(i, i + 1)
2062 | else:
2063 | self.lcd.Draw_Rectangle(1, self.lcd.Color_Bg_Red, 10, self.MBASE(3) - 10, self.lcd.DWIN_WIDTH - 10, self.MBASE(4))
2064 | self.lcd.Draw_String(False, False, self.lcd.font16x32, self.lcd.Color_Yellow, self.lcd.Color_Bg_Red, ((self.lcd.DWIN_WIDTH) - 8 * 16) / 2, self.MBASE(3), "No Media")
2065 |
2066 | def CompletedHoming(self):
2067 | self.pd.HMI_flag.home_flag = False
2068 | if (self.checkkey == self.Last_Prepare):
2069 | self.checkkey = self.Prepare
2070 | self.select_prepare.now = self.PREPARE_CASE_HOME
2071 | self.index_prepare = self.MROWS
2072 | self.Draw_Prepare_Menu()
2073 | elif (self.checkkey == self.Back_Main):
2074 | self.pd.HMI_ValueStruct.print_speed = self.pd.feedrate_percentage = 100
2075 | # dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z)
2076 | # planner.finish_and_disable()
2077 | self.Goto_MainMenu()
2078 |
2079 | def say_x(self, inset, line):
2080 | self.lcd.Frame_AreaCopy(1, 95, 104, 102, 114, self.LBLX + inset, line) # "X"
2081 |
2082 | def say_y(self, inset, line):
2083 | self.lcd.Frame_AreaCopy(1, 104, 104, 110, 114, self.LBLX + inset, line) # "Y"
2084 |
2085 | def say_z(self, inset, line):
2086 | self.lcd.Frame_AreaCopy(1, 112, 104, 120, 114, self.LBLX + inset, line) # "Z"
2087 |
2088 | def say_e(self, inset, line):
2089 | self.lcd.Frame_AreaCopy(1, 237, 119, 244, 129, self.LBLX + inset, line) # "E"
2090 |
2091 | # --------------------------------------------------------------#
2092 | # --------------------------------------------------------------#
2093 |
2094 | def ICON_Print(self):
2095 | if self.select_page.now == 0:
2096 | self.lcd.ICON_Show(self.ICON, self.ICON_Print_1, 17, 130)
2097 | self.lcd.Draw_Rectangle(0, self.lcd.Color_White, 17, 130, 126, 229)
2098 | self.lcd.Frame_AreaCopy(1, 1, 451, 31, 463, 57, 201)
2099 | else:
2100 | self.lcd.ICON_Show(self.ICON, self.ICON_Print_0, 17, 130)
2101 | self.lcd.Frame_AreaCopy(1, 1, 423, 31, 435, 57, 201)
2102 |
2103 | def ICON_Prepare(self):
2104 | if self.select_page.now == 1:
2105 | self.lcd.ICON_Show(self.ICON, self.ICON_Prepare_1, 145, 130)
2106 | self.lcd.Draw_Rectangle(0, self.lcd.Color_White, 145, 130, 254, 229)
2107 | self.lcd.Frame_AreaCopy(1, 33, 451, 82, 466, 175, 201)
2108 | else:
2109 | self.lcd.ICON_Show(self.ICON, self.ICON_Prepare_0, 145, 130)
2110 | self.lcd.Frame_AreaCopy(1, 33, 423, 82, 438, 175, 201)
2111 |
2112 | def ICON_Control(self):
2113 | if self.select_page.now == 2:
2114 | self.lcd.ICON_Show(self.ICON, self.ICON_Control_1, 17, 246)
2115 | self.lcd.Draw_Rectangle(0, self.lcd.Color_White, 17, 246, 126, 345)
2116 | self.lcd.Frame_AreaCopy(1, 85, 451, 132, 463, 48, 318)
2117 | else:
2118 | self.lcd.ICON_Show(self.ICON, self.ICON_Control_0, 17, 246)
2119 | self.lcd.Frame_AreaCopy(1, 85, 423, 132, 434, 48, 318)
2120 |
2121 | def ICON_Leveling(self, show):
2122 | if show:
2123 | self.lcd.ICON_Show(self.ICON, self.ICON_Leveling_1, 145, 246)
2124 | self.lcd.Draw_Rectangle(0, self.lcd.Color_White, 145, 246, 254, 345)
2125 | self.lcd.Frame_AreaCopy(1, 84, 437, 120, 449, 182, 318)
2126 | else:
2127 | self.lcd.ICON_Show(self.ICON, self.ICON_Leveling_0, 145, 246)
2128 | self.lcd.Frame_AreaCopy(1, 84, 465, 120, 478, 182, 318)
2129 |
2130 | def ICON_StartInfo(self, show):
2131 | if show:
2132 | self.lcd.ICON_Show(self.ICON, self.ICON_Info_1, 145, 246)
2133 | self.lcd.Draw_Rectangle(0, self.lcd.Color_White, 145, 246, 254, 345)
2134 | self.lcd.Frame_AreaCopy(1, 132, 451, 159, 466, 186, 318)
2135 | else:
2136 | self.lcd.ICON_Show(self.ICON, self.ICON_Info_0, 145, 246)
2137 | self.lcd.Frame_AreaCopy(1, 132, 423, 159, 435, 186, 318)
2138 |
2139 | def ICON_Tune(self):
2140 | if (self.select_print.now == 0):
2141 | self.lcd.ICON_Show(self.ICON, self.ICON_Setup_1, 8, 252)
2142 | self.lcd.Draw_Rectangle(0, self.lcd.Color_White, 8, 252, 87, 351)
2143 | self.lcd.Frame_AreaCopy(1, 0, 466, 34, 476, 31, 325)
2144 | else:
2145 | self.lcd.ICON_Show(self.ICON, self.ICON_Setup_0, 8, 252)
2146 | self.lcd.Frame_AreaCopy(1, 0, 438, 32, 448, 31, 325)
2147 |
2148 | def ICON_Continue(self):
2149 | if (self.select_print.now == 1):
2150 | self.lcd.ICON_Show(self.ICON, self.ICON_Continue_1, 96, 252)
2151 | self.lcd.Draw_Rectangle(0, self.lcd.Color_White, 96, 252, 175, 351)
2152 | self.lcd.Frame_AreaCopy(1, 1, 452, 32, 464, 121, 325)
2153 | else:
2154 | self.lcd.ICON_Show(self.ICON, self.ICON_Continue_0, 96, 252)
2155 | self.lcd.Frame_AreaCopy(1, 1, 424, 31, 434, 121, 325)
2156 |
2157 | def ICON_Pause(self):
2158 | if (self.select_print.now == 1):
2159 | self.lcd.ICON_Show(self.ICON, self.ICON_Pause_1, 96, 252)
2160 | self.lcd.Draw_Rectangle(0, self.lcd.Color_White, 96, 252, 175, 351)
2161 | self.lcd.Frame_AreaCopy(1, 177, 451, 216, 462, 116, 325)
2162 | else:
2163 | self.lcd.ICON_Show(self.ICON, self.ICON_Pause_0, 96, 252)
2164 | self.lcd.Frame_AreaCopy(1, 177, 423, 215, 433, 116, 325)
2165 |
2166 | def ICON_Stop(self):
2167 | if (self.select_print.now == 2):
2168 | self.lcd.ICON_Show(self.ICON, self.ICON_Stop_1, 184, 252)
2169 | self.lcd.Draw_Rectangle(0, self.lcd.Color_White, 184, 252, 263, 351)
2170 | self.lcd.Frame_AreaCopy(1, 218, 452, 249, 466, 209, 325)
2171 | else:
2172 | self.lcd.ICON_Show(self.ICON, self.ICON_Stop_0, 184, 252)
2173 | self.lcd.Frame_AreaCopy(1, 218, 423, 247, 436, 209, 325)
2174 |
2175 | def Item_Prepare_Move(self, row):
2176 | self.draw_move_en(self.MBASE(row)) # "Move >"
2177 | self.Draw_Menu_Line(row, self.ICON_Axis)
2178 | self.Draw_More_Icon(row)
2179 |
2180 | def Item_Prepare_Disable(self, row):
2181 | self.lcd.Frame_AreaCopy(1, 103, 59, 200, 74, self.LBLX, self.MBASE(row)) # Disable Stepper"
2182 | self.Draw_Menu_Line(row, self.ICON_CloseMotor)
2183 |
2184 | def Item_Prepare_Home(self, row):
2185 | self.lcd.Frame_AreaCopy(1, 202, 61, 271, 71, self.LBLX, self.MBASE(row)) # Auto Home"
2186 | self.Draw_Menu_Line(row, self.ICON_Homing)
2187 |
2188 | def Item_Prepare_Offset(self, row):
2189 | if self.pd.HAS_BED_PROBE:
2190 | self.lcd.Frame_AreaCopy(1, 93, 179, 141, 189, self.LBLX, self.MBASE(row)) # "Z-Offset"
2191 | self.lcd.Draw_Signed_Float(self.lcd.font8x16, self.lcd.Color_Bg_Black, 2, 2, 202, self.MBASE(row), self.pd.BABY_Z_VAR * 100)
2192 | else:
2193 | self.lcd.Frame_AreaCopy(1, 1, 76, 106, 86, self.LBLX, self.MBASE(row)) # "..."
2194 | self.Draw_Menu_Line(row, self.ICON_SetHome)
2195 |
2196 | def Item_Prepare_PLA(self, row):
2197 | self.lcd.Frame_AreaCopy(1, 107, 76, 156, 86, self.LBLX, self.MBASE(row)) # Preheat"
2198 | self.lcd.Frame_AreaCopy(1, 157, 76, 181, 86, self.LBLX + 52, self.MBASE(row)) # PLA"
2199 | self.Draw_Menu_Line(row, self.ICON_PLAPreheat)
2200 |
2201 | def Item_Prepare_ABS(self, row):
2202 | self.lcd.Frame_AreaCopy(1, 107, 76, 156, 86, self.LBLX, self.MBASE(row)) # "Preheat"
2203 | self.lcd.Frame_AreaCopy(1, 172, 76, 198, 86, self.LBLX + 52, self.MBASE(row)) # "ABS"
2204 | self.Draw_Menu_Line(row, self.ICON_ABSPreheat)
2205 |
2206 | def Item_Prepare_Cool(self, row):
2207 | self.lcd.Frame_AreaCopy(1, 200, 76, 264, 86, self.LBLX, self.MBASE(row)) # "Cooldown"
2208 | self.Draw_Menu_Line(row, self.ICON_Cool)
2209 |
2210 | # --------------------------------------------------------------#
2211 | # --------------------------------------------------------------#
2212 |
2213 | def EachMomentUpdate(self):
2214 | # variable update
2215 | update = self.pd.update_variable()
2216 | if self.last_status != self.pd.status:
2217 | self.last_status = self.pd.status
2218 | if self.pd.status == "Printing":
2219 | self.Goto_PrintProcess()
2220 | elif self.pd.status == "Operational":
2221 | self.Goto_MainMenu()
2222 |
2223 | if (self.checkkey == self.PrintProcess):
2224 | if (self.pd.HMI_flag.print_finish and not self.pd.HMI_flag.done_confirm_flag):
2225 | self.pd.HMI_flag.print_finish = False
2226 | self.pd.HMI_flag.done_confirm_flag = True
2227 | # show percent bar and value
2228 | self.Draw_Print_ProgressBar(0)
2229 | # show print done confirm
2230 | self.lcd.Draw_Rectangle(1, self.lcd.Color_Bg_Black, 0, 250, self.lcd.DWIN_WIDTH - 1, self.STATUS_Y)
2231 | self.lcd.ICON_Show(self.ICON, self.ICON_Confirm_E, 86, 283)
2232 | elif (self.pd.HMI_flag.pause_flag != self.pd.printingIsPaused()):
2233 | # print status update
2234 | self.pd.HMI_flag.pause_flag = self.pd.printingIsPaused()
2235 | if (self.pd.HMI_flag.pause_flag):
2236 | self.ICON_Continue()
2237 | else:
2238 | self.ICON_Pause()
2239 | self.Draw_Print_ProgressBar()
2240 | self.Draw_Print_ProgressElapsed()
2241 | self.Draw_Print_ProgressRemain()
2242 |
2243 | if self.pd.HMI_flag.home_flag:
2244 | if self.pd.ishomed():
2245 | self.CompletedHoming()
2246 |
2247 | if update:
2248 | self.Draw_Status_Area(update)
2249 | self.lcd.UpdateLCD()
2250 |
2251 | def encoder_has_data(self, val):
2252 | if self.checkkey == self.MainMenu:
2253 | self.HMI_MainMenu()
2254 | elif self.checkkey == self.SelectFile:
2255 | self.HMI_SelectFile()
2256 | elif self.checkkey == self.Prepare:
2257 | self.HMI_Prepare()
2258 | elif self.checkkey == self.Control:
2259 | self.HMI_Control()
2260 | elif self.checkkey == self.PrintProcess:
2261 | self.HMI_Printing()
2262 | elif self.checkkey == self.Print_window:
2263 | self.HMI_PauseOrStop()
2264 | elif self.checkkey == self.AxisMove:
2265 | self.HMI_AxisMove()
2266 | elif self.checkkey == self.TemperatureID:
2267 | self.HMI_Temperature()
2268 | elif self.checkkey == self.Motion:
2269 | self.HMI_Motion()
2270 | elif self.checkkey == self.Info:
2271 | self.HMI_Info()
2272 | elif self.checkkey == self.Tune:
2273 | self.HMI_Tune()
2274 | elif self.checkkey == self.PLAPreheat:
2275 | self.HMI_PLAPreheatSetting()
2276 | elif self.checkkey == self.ABSPreheat:
2277 | self.HMI_ABSPreheatSetting()
2278 | elif self.checkkey == self.MaxSpeed:
2279 | self.HMI_MaxSpeed()
2280 | elif self.checkkey == self.MaxAcceleration:
2281 | self.HMI_MaxAcceleration()
2282 | elif self.checkkey == self.MaxJerk:
2283 | self.HMI_MaxJerk()
2284 | elif self.checkkey == self.Step:
2285 | self.HMI_Step()
2286 | elif self.checkkey == self.Move_X:
2287 | self.HMI_Move_X()
2288 | elif self.checkkey == self.Move_Y:
2289 | self.HMI_Move_Y()
2290 | elif self.checkkey == self.Move_Z:
2291 | self.HMI_Move_Z()
2292 | elif self.checkkey == self.Extruder:
2293 | self.HMI_Move_E()
2294 | elif self.checkkey == self.ETemp:
2295 | self.HMI_ETemp()
2296 | elif self.checkkey == self.Homeoffset:
2297 | self.HMI_Zoffset()
2298 | elif self.checkkey == self.BedTemp:
2299 | self.HMI_BedTemp()
2300 | # elif self.checkkey == self.FanSpeed:
2301 | # self.HMI_FanSpeed()
2302 | elif self.checkkey == self.PrintSpeed:
2303 | self.HMI_PrintSpeed()
2304 | elif self.checkkey == self.MaxSpeed_value:
2305 | self.HMI_MaxFeedspeedXYZE()
2306 | elif self.checkkey == self.MaxAcceleration_value:
2307 | self.HMI_MaxAccelerationXYZE()
2308 | elif self.checkkey == self.MaxJerk_value:
2309 | self.HMI_MaxJerkXYZE()
2310 | elif self.checkkey == self.Step_value:
2311 | self.HMI_StepXYZE()
2312 |
2313 | def get_encoder_state(self):
2314 | if not self.EncoderRate:
2315 | if self.EncodeMS > current_milli_time():
2316 | return self.ENCODER_DIFF_NO
2317 | self.EncodeMS = current_milli_time() + self.ENCODER_WAIT
2318 |
2319 | if self.encoder.value < self.EncodeLast:
2320 | self.EncodeLast = self.encoder.value
2321 | return self.ENCODER_DIFF_CW
2322 | elif self.encoder.value > self.EncodeLast:
2323 | self.EncodeLast = self.encoder.value
2324 | return self.ENCODER_DIFF_CCW
2325 | elif not GPIO.input(self.button_pin):
2326 | return self.ENCODER_DIFF_ENTER
2327 | else:
2328 | return self.ENCODER_DIFF_NO
2329 |
2330 | def HMI_AudioFeedback(self, success=True):
2331 | if (success):
2332 | self.pd.buzzer.tone(100, 659)
2333 | self.pd.buzzer.tone(10, 0)
2334 | self.pd.buzzer.tone(100, 698)
2335 | else:
2336 | self.pd.buzzer.tone(40, 440)
2337 |
--------------------------------------------------------------------------------