Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a4c556f25 | ||
|
|
67e04248c3 | ||
|
|
08a7057668 | ||
|
|
6d71022dbf | ||
|
|
972c869e62 | ||
|
|
c36aa4b430 | ||
|
|
90950101d8 | ||
|
|
67d61d164c | ||
|
|
cc59ec68d0 | ||
|
|
48c276d22f | ||
|
|
728f9cfa0f | ||
|
|
1c0e4fbf86 | ||
|
|
f7484c3df5 | ||
|
|
b70e84a7ee | ||
|
|
16c2c64904 | ||
|
|
70c93ee878 | ||
|
|
1b7146c8ec | ||
|
|
ac2e9de2d4 | ||
|
|
8204e3ab17 | ||
|
|
f0f4581241 | ||
|
|
d5fc92c1af | ||
|
|
906da8550e | ||
|
|
2f25ef2040 | ||
|
|
3b62439939 | ||
|
|
557dd86364 | ||
|
|
aeea57bd2f | ||
|
|
186c8026cf | ||
|
|
7db6a541f2 | ||
|
|
2341642cc2 | ||
|
|
2ffe6809fd | ||
|
|
2626899d53 | ||
|
|
6e8f904983 | ||
|
|
cc5b87eefe | ||
|
|
85a2ba116c | ||
|
|
c2be717fa9 | ||
|
|
c57760d857 | ||
|
|
891539c5ff | ||
|
|
87d346e541 | ||
|
|
f223f74f7f | ||
|
|
df5ac88f84 | ||
|
|
8733292dc3 | ||
|
|
8df55012d7 | ||
|
|
18a55fab2e | ||
|
|
ca9960871d | ||
|
|
127237fd76 | ||
|
|
ca9f869ac3 | ||
|
|
d29c0ab063 | ||
|
|
33beb60af9 | ||
|
|
29f78bda5e | ||
|
|
1a8e6dd250 | ||
|
|
12c0e9f5b1 | ||
|
|
952d46da24 | ||
|
|
929efa8e41 | ||
|
|
fb840f2404 | ||
|
|
19e0ff5028 |
No files matched your search
@@ -1,147 +0,0 @@
|
||||
{
|
||||
"preheat_options": {
|
||||
"PLA": {
|
||||
"tool": 195,
|
||||
"bed": 40
|
||||
},
|
||||
"ABS":{
|
||||
"tool": 220,
|
||||
"bed": 90
|
||||
}
|
||||
},
|
||||
"mainmenu": [
|
||||
{
|
||||
"name": "Homing",
|
||||
"icon": "home",
|
||||
"panel": "menu",
|
||||
"items": [
|
||||
{
|
||||
"name": "Home All",
|
||||
"icon": "home",
|
||||
"method": "printer.gcode.script",
|
||||
"params": {"script": "G28"}
|
||||
},
|
||||
{
|
||||
"name": "Home X",
|
||||
"icon": "home-x",
|
||||
"method": "printer.gcode.script",
|
||||
"params": {"script": "G28 X"}
|
||||
},
|
||||
{
|
||||
"name": "Home Y",
|
||||
"icon": "home-y",
|
||||
"method": "printer.gcode.script",
|
||||
"params": {"script": "G28 Y"}
|
||||
},
|
||||
{
|
||||
"name": "Home Z",
|
||||
"icon": "home-z",
|
||||
"method": "printer.gcode.script",
|
||||
"params": {"script": "G28 Z"}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Preheat",
|
||||
"icon": "heat-up",
|
||||
"panel": "preheat"
|
||||
},
|
||||
{
|
||||
"name": "Actions" ,
|
||||
"icon": "actions",
|
||||
"panel": "menu",
|
||||
"items": [
|
||||
{
|
||||
"name": "Move",
|
||||
"icon": "move",
|
||||
"panel": "move"
|
||||
},
|
||||
{
|
||||
"name": "Extrude",
|
||||
"icon": "filament",
|
||||
"panel": "extrude"
|
||||
},
|
||||
{
|
||||
"name": "Fan",
|
||||
"icon": "fan",
|
||||
"panel": "fan"
|
||||
},
|
||||
{
|
||||
"name": "Temperature",
|
||||
"icon": "heat-up",
|
||||
"panel": "temperature"
|
||||
},
|
||||
{
|
||||
"name": "Disable Motors",
|
||||
"icon": "motor-off",
|
||||
"method": "printer.gcode.script",
|
||||
"params": {"script": "M18"},
|
||||
"command": {
|
||||
"method": "printer.gcode.script",
|
||||
"params": {"script": "M18"}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Configuration",
|
||||
"icon": "control",
|
||||
"panel": "menu",
|
||||
"items": [
|
||||
{
|
||||
"name": "Bed Level",
|
||||
"icon": "bed-level",
|
||||
"panel": "bed_level"
|
||||
},
|
||||
{
|
||||
"name": "ZOffsets",
|
||||
"icon": "z-offset-increase",
|
||||
"panel": "zcalibrate"
|
||||
},
|
||||
{
|
||||
"name": "Network",
|
||||
"icon": "network",
|
||||
"panel": "network"
|
||||
},
|
||||
{
|
||||
"name": "System",
|
||||
"icon": "info",
|
||||
"panel": "system"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Print",
|
||||
"icon": "print",
|
||||
"panel": "print"
|
||||
}
|
||||
],
|
||||
"printmenu": [
|
||||
{
|
||||
"name": "Temperature",
|
||||
"icon": "heat-up",
|
||||
"panel": "temperature"
|
||||
},
|
||||
{
|
||||
"name": "Tuning",
|
||||
"icon": "fan",
|
||||
"panel": "finetune"
|
||||
},
|
||||
{
|
||||
"name": "Network",
|
||||
"icon": "network",
|
||||
"panel": "network"
|
||||
},
|
||||
{
|
||||
"name": "System",
|
||||
"icon": "info",
|
||||
"panel": "system"
|
||||
},
|
||||
{
|
||||
"name": "Extrude",
|
||||
"icon": "filament",
|
||||
"panel": "extrude"
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import json
|
||||
import requests
|
||||
import logging
|
||||
|
||||
|
||||
|
||||
class KlippyRest:
|
||||
def __init__(self, ip, port=7125):
|
||||
self.ip = ip
|
||||
self.port = port
|
||||
|
||||
def get_info(self):
|
||||
return self.send_request("server/info")
|
||||
|
||||
def send_request(self, method):
|
||||
r = requests.get("http://%s:%s/%s" % (self.ip, self.port, method))
|
||||
if r.status_code != 200:
|
||||
return False
|
||||
|
||||
#TODO: Try/except
|
||||
data = json.loads(r.content)
|
||||
|
||||
return data
|
||||
@@ -10,53 +10,23 @@ Current feature list:
|
||||
- [x] Fan control
|
||||
- [x] Disable steppers
|
||||
- [x] Configure Z Offset using PROBE_CALIBRATE
|
||||
- [ ] Print tuning (Z Babystepping, Speed Control, Flow Control)
|
||||
- [x] Print tuning (Z Babystepping, Speed Control, Flow Control)
|
||||
- [x] Manual bed leveling assist
|
||||
- [x] Using thumbnails from prusa on job status page
|
||||
- [ ] Better system panel
|
||||
- [ ] Wifi selection
|
||||
- [ ] Manual bed leveling assist
|
||||
- [ ] Using thumbnails from prusa on job status page
|
||||
- [ ] Scale UI based off of resolution
|
||||
|
||||
|
||||
More details to come...
|
||||
|
||||
### Required Hardware
|
||||
KlipperScreen should run on any HDMI touchscreen that you can connect to a raspberry pi. The required video driver may
|
||||
KlipperScreen should run on any HDMI touchscreen that you can connect to a computer. The required video driver may
|
||||
be slightly different depending on what model you get. I am developing on a 1024x600 resolution screen. Due to this,
|
||||
other resolutions may not be scaled properly at this moment. UI scaling is a future development item.
|
||||
|
||||
#### Configure Hardware
|
||||
### Links
|
||||
|
||||
Add the following to _/boot/config.txt_. You can alter the hdmi_cvt to your screen specifications. This example is setup
|
||||
for a resolution of 1024x600 and a refresh rate of 60hz.
|
||||
```
|
||||
hdmi_cvt=1024 600 60 6 0 0 0
|
||||
hdmi_group=2
|
||||
hdmi_mode=87
|
||||
hdmi_drive=2
|
||||
```
|
||||
* Development has been using 1024x600 for a screen resolution. Other resolutions may have issues currently
|
||||
[Installation](docs/Installation.md)
|
||||
|
||||
After changing _/boot/config.txt_ you must reboot your raspberry pi. Please also ensure you followed setting up your screen via the screen instructions. This will likely have a xorg.conf.d file for input from the touchscreen that you need to create.
|
||||
|
||||
### Installation
|
||||
|
||||
Follow the instructions to install klipper and moonraker.
|
||||
klipper: https://github.com/KevinOConnor/klipper/
|
||||
moonraker: https://github.com/Arksine/moonraker
|
||||
|
||||
Ensure that 127.0.0.1 is a trusted client for moonraker, such as in this example:
|
||||
```
|
||||
[authorization]
|
||||
trusted_clients:
|
||||
127.0.0.1
|
||||
```
|
||||
|
||||
For moonraker, ensure that 127.0.0.1 is a trusted client:
|
||||
|
||||
Run _scripts/KlipperScreen-install.sh_
|
||||
This script will install packages that are listed under manual install, create a
|
||||
python virtual environment at ${HOME}/.KlipperScreen-env and install a systemd
|
||||
service file.
|
||||
|
||||
As an option to do development or interact with KlipperScreen from your computer, you may install tigervnc-scraping-server and VNC to your pi instance. Follow tigervnc server setup procedures for details on how to do that.
|
||||
[Configuration](docs/Configuration.md)
|
||||
@@ -1,207 +1,68 @@
|
||||
# Configuration
|
||||
|
||||
In the KlipperScreen folder, a file _KlipperScreen.config_ allows for configuration of the screen. The configuration
|
||||
file is a json formatted file. There are three main options to configure.
|
||||
```
|
||||
{
|
||||
"preheat_options",
|
||||
"mainmenu",
|
||||
"printmenu"
|
||||
}
|
||||
```
|
||||
In the KlipperScreen folder, a file _KlipperScreen.conf_ allows for configuration of the screen. This document will
|
||||
detail how to configure KlipperScreen. A default config is included here: [ks_includes/KlipperScreen.conf](../ks_includes/KlipperScreen.conf)
|
||||
|
||||
|
||||
## Preheat Options
|
||||
Under preheat options, you may specify pre-defined temperatures for easy warmup. Each material should be formatted as
|
||||
follows:
|
||||
```
|
||||
"Material": {
|
||||
"tool": 195,
|
||||
"bed": 40
|
||||
}
|
||||
```
|
||||
Tool is the extruder temperature, bed is the heated bed temperature. An example configuration for PLA and abs would be
|
||||
like this:
|
||||
```
|
||||
"preheat_options": {
|
||||
"PLA": {
|
||||
"tool": 195,
|
||||
"bed": 40
|
||||
},
|
||||
"ABS":{
|
||||
"tool": 220,
|
||||
"bed": 90
|
||||
}
|
||||
}
|
||||
[preheat my_temp_setting]
|
||||
# Temperature for the heated bed
|
||||
bed: 40
|
||||
# Temperature for the tools
|
||||
extruder: 195
|
||||
```
|
||||
|
||||
## Main menu
|
||||
## Menu
|
||||
This allows a custom configuration for the menu displayed while the printer is idle. You can use sub-menus to group
|
||||
different items and there are several panel options available. It is possible to have a gcode script run on a menu
|
||||
button press.
|
||||
|
||||
Available panels:
|
||||
* bed_level: Manual bed level
|
||||
* extrude: Controls for extrusion
|
||||
* fan: Controls fan speed
|
||||
* finetune: Controls for fine-tuning print settings such as z-babystepping or extrustion rate
|
||||
* menu: Allows for a sub-menu
|
||||
* move: Controls the print head
|
||||
* network: Network information panel
|
||||
* preheat: Preheat bed/tools
|
||||
* system: System information panel
|
||||
* temperature: Controls temperature settings
|
||||
* zcalibrate: Calibrating a probe
|
||||
button press. There are two menus available in KlipperScreen, __main and __print. The __main menu is displayed while the
|
||||
printer is idle. The __print menu is accessible from the printing status page.
|
||||
|
||||
A menu item is configured as follows:
|
||||
```
|
||||
{
|
||||
"name": "Name displayed",
|
||||
"icon": "file name from icons folder",
|
||||
"panel": "panel from above options",
|
||||
# Optional parameters
|
||||
"items": [] # Items for a submenu
|
||||
"method": "printer.gcode.script" # Moonraker method for a request
|
||||
"params": {} # Parameters for the moonraker method
|
||||
}
|
||||
[menu __main my_menu_item]
|
||||
# To build a sub-menu of this menu item, you would next use [menu __main my_menu_item sub_menu_item]
|
||||
name: Item Name
|
||||
icon: home
|
||||
# Optional Parameters
|
||||
# Panel from the panels listed below
|
||||
panel: preheat
|
||||
# Moonraker method to call when the item is selected
|
||||
method: printer.gcode.script
|
||||
# Parameters that would be passed with the method above
|
||||
params: {"script":"G28 X"}
|
||||
# Enable allows hiding of a menu if the condition is false. This statement is evaluated in Jinja2
|
||||
# Available variables are listed below.
|
||||
enable: {{ printer.power_devices.count > 0 }}
|
||||
```
|
||||
Available panels are listed here: [docs/panels.md](panels.md)
|
||||
|
||||
Certain variables are available for conditional testing of the enable statement:
|
||||
```
|
||||
printer.power_devices.count # Number of power devices configured in Moonraker
|
||||
```
|
||||
|
||||
|
||||
A sample configuration of a main menu would be as follows:
|
||||
```
|
||||
"mainmenu": [
|
||||
{
|
||||
"name": "Homing",
|
||||
"icon": "home",
|
||||
"panel": "menu",
|
||||
"items": [
|
||||
{
|
||||
"name": "Home All",
|
||||
"icon": "home",
|
||||
"method": "printer.gcode.script",
|
||||
"params": {"script": "G28"}
|
||||
},
|
||||
{
|
||||
"name": "Home X",
|
||||
"icon": "home-x",
|
||||
"method": "printer.gcode.script",
|
||||
"params": {"script": "G28 X"}
|
||||
},
|
||||
{
|
||||
"name": "Home Y",
|
||||
"icon": "home-y",
|
||||
"method": "printer.gcode.script",
|
||||
"params": {"script": "G28 Y"}
|
||||
},
|
||||
{
|
||||
"name": "Home Z",
|
||||
"icon": "home-z",
|
||||
"method": "printer.gcode.script",
|
||||
"params": {"script": "G28 Z"}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Preheat",
|
||||
"icon": "heat-up",
|
||||
"panel": "preheat"
|
||||
},
|
||||
{
|
||||
"name": "Actions" ,
|
||||
"icon": "actions",
|
||||
"panel": "menu",
|
||||
"items": [
|
||||
{
|
||||
"name": "Move",
|
||||
"icon": "move",
|
||||
"panel": "move"
|
||||
},
|
||||
{
|
||||
"name": "Extrude",
|
||||
"icon": "filament",
|
||||
"panel": "extrude"
|
||||
},
|
||||
{
|
||||
"name": "Fan",
|
||||
"icon": "fan",
|
||||
"panel": "fan"
|
||||
},
|
||||
{
|
||||
"name": "Temperature",
|
||||
"icon": "heat-up",
|
||||
"panel": "temperature"
|
||||
},
|
||||
{
|
||||
"name": "Disable Motors",
|
||||
"icon": "motor-off",
|
||||
"method": "printer.gcode.script",
|
||||
"params": {"script": "M18"},
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Configuration",
|
||||
"icon": "control",
|
||||
"panel": "menu",
|
||||
"items": [
|
||||
{
|
||||
"name": "Bed Level",
|
||||
"icon": "bed-level",
|
||||
"panel": "bed_level"
|
||||
},
|
||||
{
|
||||
"name": "ZOffsets",
|
||||
"icon": "z-offset-increase",
|
||||
"panel": "zcalibrate"
|
||||
},
|
||||
{
|
||||
"name": "Network",
|
||||
"icon": "network",
|
||||
"panel": "network"
|
||||
},
|
||||
{
|
||||
"name": "System",
|
||||
"icon": "info",
|
||||
"panel": "system"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Print",
|
||||
"icon": "print",
|
||||
"panel": "print"
|
||||
}
|
||||
]
|
||||
```
|
||||
[menu __main homing]
|
||||
name: Homing
|
||||
icon: home
|
||||
|
||||
## Print menu
|
||||
The print menu controls items that are available during a print job. Certain panels, such as movement or homing, are
|
||||
panels that shouldn't be displayed during a print as they could cause print errors. A default configuration is below:
|
||||
[menu __main preheat]
|
||||
name: Preheat
|
||||
icon: heat-up
|
||||
panel: preheat
|
||||
|
||||
```
|
||||
"printmenu": [
|
||||
{
|
||||
"name": "Temperature",
|
||||
"icon": "heat-up",
|
||||
"panel": "temperature"
|
||||
},
|
||||
{
|
||||
"name": "Tuning",
|
||||
"icon": "fan",
|
||||
"panel": "finetune"
|
||||
},
|
||||
{
|
||||
"name": "Network",
|
||||
"icon": "network",
|
||||
"panel": "network"
|
||||
},
|
||||
{
|
||||
"name": "System",
|
||||
"icon": "info",
|
||||
"panel": "system"
|
||||
},
|
||||
{
|
||||
"name": "Extrude",
|
||||
"icon": "filament",
|
||||
"panel": "extrude"
|
||||
}
|
||||
]
|
||||
[menu __main print]
|
||||
name: Print
|
||||
icon: print
|
||||
panel: print
|
||||
|
||||
[menu __main homing homeall]
|
||||
name: Home All
|
||||
icon: home
|
||||
method: printer.gcode.script
|
||||
params: {"script":"G28"}
|
||||
```
|
||||
@@ -0,0 +1,40 @@
|
||||
### Required Hardware
|
||||
KlipperScreen should run on any HDMI touchscreen that you can connect to a computer. The required video driver may
|
||||
be slightly different depending on what model you get. I am developing on a 1024x600 resolution screen. Due to this,
|
||||
other resolutions may not be scaled properly at this moment. UI scaling is a future development item.
|
||||
|
||||
#### Configure Hardware
|
||||
|
||||
Add the following to _/boot/config.txt_. You can alter the hdmi_cvt to your screen specifications. This example is setup
|
||||
for a resolution of 1024x600 and a refresh rate of 60hz.
|
||||
```
|
||||
hdmi_cvt=1024 600 60 6 0 0 0
|
||||
hdmi_group=2
|
||||
hdmi_mode=87
|
||||
hdmi_drive=2
|
||||
```
|
||||
* Development has been using 1024x600 for a screen resolution. Other resolutions may have issues currently
|
||||
|
||||
After changing _/boot/config.txt_ you must reboot your raspberry pi. Please also ensure you followed setting up your screen via the screen instructions. This will likely have a xorg.conf.d file for input from the touchscreen that you need to create.
|
||||
|
||||
### Installation
|
||||
|
||||
Follow the instructions to install klipper and moonraker.
|
||||
klipper: https://github.com/KevinOConnor/klipper/
|
||||
moonraker: https://github.com/Arksine/moonraker
|
||||
|
||||
Ensure that 127.0.0.1 is a trusted client for moonraker, such as in this example:
|
||||
```
|
||||
[authorization]
|
||||
trusted_clients:
|
||||
127.0.0.1
|
||||
```
|
||||
|
||||
For moonraker, ensure that 127.0.0.1 is a trusted client:
|
||||
|
||||
Run _scripts/KlipperScreen-install.sh_
|
||||
This script will install packages that are listed under manual install, create a
|
||||
python virtual environment at ${HOME}/.KlipperScreen-env and install a systemd
|
||||
service file.
|
||||
|
||||
As an option to do development or interact with KlipperScreen from your computer, you may install tigervnc-scraping-server and VNC to your pi instance. Follow tigervnc server setup procedures for details on how to do that.
|
||||
@@ -1,4 +1,21 @@
|
||||
## Changelog
|
||||
|
||||
#### 2020 12 02
|
||||
* Change panel layout: Added Title, Back, Emergency Stop, and Home to panels.
|
||||
|
||||
#### 2020 11 28
|
||||
* Add option for enable in menu for configuration. This can hide certain options
|
||||
* Add Power panel to control power devices via moonraker
|
||||
* Add klipper version to system panel
|
||||
|
||||
#### 2020 11 18
|
||||
* Changed configuration file format.
|
||||
* Moved default configuration file to an include folder.
|
||||
* Added ability to do a confirm dialog from a menu item when running a script
|
||||
* Added "Save Config" button to default configuration's Configuration menu.
|
||||
|
||||
#### 2020 11 14
|
||||
* Update print panel to include line wrapping for longer filenames
|
||||
|
||||
#### 2020 11 13
|
||||
* Fine Tuning Panel is now fully functional: Z BabyStepping, Fan Speed, Speed Factor, and Extrusion Factor
|
||||
|
After Width: | Height: | Size: 86 KiB |
|
After Width: | Height: | Size: 86 KiB |
|
After Width: | Height: | Size: 45 KiB |
|
After Width: | Height: | Size: 131 KiB |
|
After Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 93 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 267 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 95 KiB |
|
After Width: | Height: | Size: 86 KiB |
@@ -2,14 +2,70 @@
|
||||
|
||||
### Index
|
||||
* [Main menu](#main-menu)
|
||||
* [Move](#move)
|
||||
* [Preheat](#preheat)
|
||||
* [Job Status](#job-status)
|
||||
* [bed_level](#bed-level)
|
||||
* [extrude](#extrude)
|
||||
* [fan](#fan)
|
||||
* [fine_tune](#finetune)
|
||||
* [move](#move)
|
||||
* [network](#network)
|
||||
* [preheat](#preheat)
|
||||
* [print](#print)
|
||||
* [system](#system)
|
||||
* [temperature](#temperature)
|
||||
* [zcalibrate](#zcalibrate)
|
||||
|
||||
|
||||
### Main Menu
|
||||

|
||||

|
||||
|
||||
### Job Status
|
||||

|
||||
|
||||
### Bed Level
|
||||
type: bed_level
|
||||

|
||||
|
||||
### Extrude
|
||||
type: extrude
|
||||

|
||||
|
||||
### Fan
|
||||
type: fan
|
||||

|
||||
|
||||
### Fine Tune
|
||||
type: fine_tune
|
||||

|
||||
|
||||
### Menu
|
||||
type: menu
|
||||

|
||||
|
||||
### Move
|
||||

|
||||
type: move
|
||||

|
||||
|
||||
### Network
|
||||
type: network
|
||||

|
||||
|
||||
### Preheat
|
||||

|
||||
type: preheat
|
||||

|
||||
|
||||
### Print
|
||||
type: print
|
||||

|
||||
|
||||
### System
|
||||
type: system
|
||||

|
||||
|
||||
### Temperature
|
||||
type: temperature
|
||||

|
||||
|
||||
### Z Calibrate
|
||||
type: zcalibrate
|
||||

|
||||
@@ -0,0 +1,152 @@
|
||||
[preheat PLA]
|
||||
bed = 40
|
||||
extruder = 195
|
||||
|
||||
[preheat ABS]
|
||||
bed = 90
|
||||
extruder = 220
|
||||
|
||||
[menu __main]
|
||||
name: Main Menu
|
||||
|
||||
[menu __main homing]
|
||||
name: Homing
|
||||
icon: home
|
||||
|
||||
[menu __main preheat]
|
||||
name: Preheat
|
||||
icon: heat-up
|
||||
panel: preheat
|
||||
|
||||
[menu __main actions]
|
||||
name: Actions
|
||||
icon: actions
|
||||
|
||||
[menu __main config]
|
||||
name: Configuration
|
||||
icon: control
|
||||
|
||||
[menu __main print]
|
||||
name: Print
|
||||
icon: print
|
||||
panel: print
|
||||
|
||||
[menu __main homing homeall]
|
||||
name: Home All
|
||||
icon: home
|
||||
method: printer.gcode.script
|
||||
params: {"script":"G28"}
|
||||
|
||||
[menu __main homing homex]
|
||||
name: Home X
|
||||
icon: home
|
||||
method: printer.gcode.script
|
||||
params: {"script":"G28 X"}
|
||||
|
||||
[menu __main homing homey]
|
||||
name: Home Y
|
||||
icon: home
|
||||
method: printer.gcode.script
|
||||
params: {"script":"G28 Y"}
|
||||
|
||||
[menu __main homing homez]
|
||||
name: Home Z
|
||||
icon: home
|
||||
method: printer.gcode.script
|
||||
params: {"script":"G28 Z"}
|
||||
|
||||
[menu __main homing homexy]
|
||||
name: Home XY
|
||||
icon: home
|
||||
method: printer.gcode.script
|
||||
params: {"script":"G28 X Y"}
|
||||
|
||||
[menu __main actions move]
|
||||
name: Move
|
||||
icon: move
|
||||
panel: move
|
||||
|
||||
[menu __main actions extrude]
|
||||
name: Extrude
|
||||
icon: filament
|
||||
panel: extrude
|
||||
|
||||
[menu __main actions fan]
|
||||
name: Fan
|
||||
icon: fan
|
||||
panel: fan
|
||||
|
||||
[menu __main actions temperature]
|
||||
name: Temperature
|
||||
icon: heat-up
|
||||
panel: temperature
|
||||
|
||||
[menu __main actions power]
|
||||
name: Power
|
||||
icon: shutdown
|
||||
panel: power
|
||||
enable: {{ printer.power_devices.count > 0 }}
|
||||
|
||||
[menu __main actions disablemotors]
|
||||
name: Disable Motors
|
||||
icon: motor-off
|
||||
method: printer.gcode.script
|
||||
params: {"script":"M18"}
|
||||
|
||||
[menu __main config bedlevel]
|
||||
name: Bed Level
|
||||
icon: bed-level
|
||||
panel: bed_level
|
||||
|
||||
[menu __main config zoffset]
|
||||
name: Z Calibrate
|
||||
icon: z-offset-increase
|
||||
panel: zcalibrate
|
||||
|
||||
[menu __main config network]
|
||||
name: Network
|
||||
icon: network
|
||||
panel: network
|
||||
|
||||
[menu __main config system]
|
||||
name: System
|
||||
icon: info
|
||||
panel: system
|
||||
|
||||
[menu __main config save]
|
||||
name: Save Config
|
||||
icon: complete
|
||||
method: printer.gcode.script
|
||||
params: {"script":"SAVE_CONFIG"}
|
||||
confirm:
|
||||
Save configuration.
|
||||
|
||||
Klipper will reboot
|
||||
|
||||
[menu __print]
|
||||
name: Print Control
|
||||
|
||||
[menu __print temperature]
|
||||
name: Temperature
|
||||
icon: heat-up
|
||||
panel: temperature
|
||||
|
||||
[menu __print tuning]
|
||||
name: Fine Tuning
|
||||
icon: fan
|
||||
panel: fine_tune
|
||||
|
||||
[menu __print network]
|
||||
name: Network
|
||||
icon: network
|
||||
panel: network
|
||||
|
||||
[menu __print system]
|
||||
name: System
|
||||
icon: info
|
||||
panel: system
|
||||
|
||||
[menu __print extrude]
|
||||
name: Extrude
|
||||
icon: filament
|
||||
panel: extrude
|
||||
@@ -1,209 +1,206 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GdkPixbuf, GLib
|
||||
import os
|
||||
klipperscreendir = os.getcwd()
|
||||
|
||||
class KlippyGtk:
|
||||
labels = {}
|
||||
|
||||
@staticmethod
|
||||
def Label(label, style):
|
||||
l = Gtk.Label(label)
|
||||
if style != False:
|
||||
l.get_style_context().add_class(style)
|
||||
return l
|
||||
|
||||
@staticmethod
|
||||
def ImageLabel(image_name, text, size=20, style=False):
|
||||
box1 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=15)
|
||||
image = Gtk.Image()
|
||||
#TODO: update file reference
|
||||
image.set_from_file(klipperscreendir + "/styles/z-bolt/images/" + str(image_name) + ".svg")
|
||||
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(klipperscreendir + "/styles/z-bolt/images/" + str(image_name) + ".svg", 20, 20, True)
|
||||
image.set_from_pixbuf(pixbuf)
|
||||
|
||||
label = Gtk.Label()
|
||||
label.set_text(text)
|
||||
box1.add(image) #, size, size)
|
||||
box1.add(label)
|
||||
|
||||
if style != False:
|
||||
ctx = box1.get_style_context()
|
||||
ctx.add_class(style)
|
||||
|
||||
return {"l": label, "b": box1}
|
||||
|
||||
@staticmethod
|
||||
def Image(image_name, style=False, width=None, height=None):
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(klipperscreendir + "/styles/z-bolt/images/" + str(image_name) + ".svg")
|
||||
|
||||
if height != None and width != None:
|
||||
pixbuf = pixbuf.scale_simple(width, height, GdkPixbuf.InterpType.BILINEAR)
|
||||
|
||||
return Gtk.Image.new_from_pixbuf(pixbuf)
|
||||
|
||||
@staticmethod
|
||||
def ImageFromFile(filename, style=False, width=None, height=None):
|
||||
if height != -1 or width != -1:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(filename, width, height, True)
|
||||
else:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename)
|
||||
|
||||
return Gtk.Image.new_from_pixbuf(pixbuf)
|
||||
|
||||
@staticmethod
|
||||
def PixbufFromFile(filename, style=False, width=None, height=None):
|
||||
if height != -1 or width != -1:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(filename, width, height, True)
|
||||
else:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename)
|
||||
|
||||
return pixbuf
|
||||
|
||||
@staticmethod
|
||||
def ProgressBar(style=False):
|
||||
bar = Gtk.ProgressBar()
|
||||
|
||||
if style != False:
|
||||
ctx = bar.get_style_context()
|
||||
ctx.add_class(style)
|
||||
|
||||
return bar
|
||||
|
||||
@staticmethod
|
||||
def Button(label=None, style=None):
|
||||
b = Gtk.Button(label=label)
|
||||
b.set_hexpand(True)
|
||||
b.set_vexpand(True)
|
||||
b.set_can_focus(False)
|
||||
b.props.relief = Gtk.ReliefStyle.NONE
|
||||
|
||||
if style != None:
|
||||
b.get_style_context().add_class(style)
|
||||
|
||||
return b
|
||||
|
||||
@staticmethod
|
||||
def ButtonImage(image_name, label=None, style=None, height=None, width=None):
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(klipperscreendir + "/styles/z-bolt/images/" + str(image_name) + ".svg")
|
||||
|
||||
if height != None and width != None:
|
||||
pixbuf = pixbuf.scale_simple(width, height, GdkPixbuf.InterpType.BILINEAR)
|
||||
|
||||
|
||||
img = Gtk.Image.new_from_pixbuf(pixbuf)
|
||||
|
||||
b = Gtk.Button(label=label)
|
||||
b.set_image(img)
|
||||
b.set_hexpand(True)
|
||||
b.set_vexpand(True)
|
||||
b.set_can_focus(False)
|
||||
b.set_image_position(Gtk.PositionType.TOP)
|
||||
b.set_always_show_image(True)
|
||||
b.props.relief = Gtk.ReliefStyle.NONE
|
||||
|
||||
if style != None:
|
||||
b.get_style_context().add_class(style)
|
||||
|
||||
return b
|
||||
|
||||
@staticmethod
|
||||
def ConfirmDialog(screen, text, buttons, callback=None, *args):
|
||||
dialog = Gtk.Dialog()
|
||||
#TODO: Factor other resolutions in
|
||||
dialog.set_default_size(984, 580)
|
||||
dialog.set_resizable(False)
|
||||
dialog.set_transient_for(screen)
|
||||
dialog.set_modal(True)
|
||||
|
||||
for button in buttons:
|
||||
dialog.add_button(button_text=button['name'], response_id=button['response'])
|
||||
|
||||
dialog.connect("response", callback, *args)
|
||||
dialog.get_style_context().add_class("dialog")
|
||||
|
||||
content_area = dialog.get_content_area()
|
||||
content_area.set_margin_start(15)
|
||||
content_area.set_margin_end(15)
|
||||
content_area.set_margin_top(15)
|
||||
content_area.set_margin_bottom(15)
|
||||
|
||||
label = Gtk.Label()
|
||||
label.set_line_wrap(True)
|
||||
label.set_size_request(800, -1)
|
||||
label.set_markup(text)
|
||||
label.get_style_context().add_class("text")
|
||||
table = Gtk.Table(1, 1, False)
|
||||
table.attach(label, 0, 1, 0, 1, Gtk.AttachOptions.SHRINK | Gtk.AttachOptions.FILL)
|
||||
table.set_vexpand(True)
|
||||
table.set_halign(Gtk.Align.CENTER)
|
||||
table.set_valign(Gtk.Align.CENTER)
|
||||
content_area.add(table)
|
||||
|
||||
dialog.show_all()
|
||||
|
||||
return dialog
|
||||
|
||||
|
||||
@staticmethod
|
||||
def ToggleButtonImage(image_name, label, style=False):
|
||||
img = Gtk.Image.new_from_file(klipperscreendir + "/styles/z-bolt/images/" + str(image_name) + ".svg")
|
||||
|
||||
b = Gtk.ToggleButton(label=label)
|
||||
#b.props.relief = Gtk.RELIEF_NONE
|
||||
b.set_image(img)
|
||||
b.set_hexpand(True)
|
||||
b.set_vexpand(True)
|
||||
b.set_can_focus(False)
|
||||
b.set_image_position(Gtk.PositionType.TOP)
|
||||
b.set_always_show_image(True)
|
||||
b.props.relief = Gtk.ReliefStyle.NONE
|
||||
|
||||
if style != False:
|
||||
ctx = b.get_style_context()
|
||||
ctx.add_class(style)
|
||||
|
||||
return b
|
||||
|
||||
@staticmethod
|
||||
def HomogeneousGrid():
|
||||
g = Gtk.Grid()
|
||||
g.set_row_homogeneous(True)
|
||||
g.set_column_homogeneous(True)
|
||||
return g
|
||||
|
||||
@staticmethod
|
||||
def ToggleButton(text):
|
||||
b = Gtk.ToggleButton(text)
|
||||
b.props.relief = Gtk.ReliefStyle.NONE
|
||||
b.set_hexpand(True)
|
||||
b.set_vexpand(True)
|
||||
return b
|
||||
|
||||
@staticmethod
|
||||
def formatFileName(name):
|
||||
name = name.split('/')[-1] if "/" in name else name
|
||||
name = name.split('.gcod')[0] if ".gcode" in name else name
|
||||
if len(name) > 25:
|
||||
return name[0:25] + "\n" + name[25:50]
|
||||
return name
|
||||
|
||||
|
||||
@staticmethod
|
||||
def formatTimeString(seconds):
|
||||
time = int(seconds)
|
||||
text = ""
|
||||
if int(time/3600) !=0:
|
||||
text += str(int(time/3600))+"h "
|
||||
text += str(int(time/60)%60)+"m "+str(time%60)+"s"
|
||||
return text
|
||||
|
||||
@staticmethod
|
||||
def formatTemperatureString(temp, target):
|
||||
if (target > temp-2 and target < temp+2) or round(target,0) == 0:
|
||||
return str(round(temp,2)) + "°C" #°C →"
|
||||
return str(round(temp,2)) + "°C → " + str(round(target,2)) + "°C"
|
||||
# -*- coding: utf-8 -*-
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GdkPixbuf, GLib
|
||||
import os
|
||||
klipperscreendir = os.getcwd()
|
||||
|
||||
class KlippyGtk:
|
||||
labels = {}
|
||||
|
||||
@staticmethod
|
||||
def Label(label, style):
|
||||
l = Gtk.Label(label)
|
||||
if style != False:
|
||||
l.get_style_context().add_class(style)
|
||||
return l
|
||||
|
||||
@staticmethod
|
||||
def ImageLabel(image_name, text, size=20, style=False):
|
||||
box1 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=15)
|
||||
image = Gtk.Image()
|
||||
#TODO: update file reference
|
||||
image.set_from_file(klipperscreendir + "/styles/z-bolt/images/" + str(image_name) + ".svg")
|
||||
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(klipperscreendir + "/styles/z-bolt/images/" + str(image_name) + ".svg", 20, 20, True)
|
||||
image.set_from_pixbuf(pixbuf)
|
||||
|
||||
label = Gtk.Label()
|
||||
label.set_text(text)
|
||||
box1.add(image)
|
||||
box1.add(label)
|
||||
|
||||
if style != False:
|
||||
ctx = box1.get_style_context()
|
||||
ctx.add_class(style)
|
||||
|
||||
return {"l": label, "b": box1}
|
||||
|
||||
@staticmethod
|
||||
def Image(image_name, style=False, width=None, height=None):
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(klipperscreendir + "/styles/z-bolt/images/" + str(image_name) + ".svg")
|
||||
|
||||
if height != None and width != None:
|
||||
pixbuf = pixbuf.scale_simple(width, height, GdkPixbuf.InterpType.BILINEAR)
|
||||
|
||||
return Gtk.Image.new_from_pixbuf(pixbuf)
|
||||
|
||||
@staticmethod
|
||||
def ImageFromFile(filename, style=False, width=None, height=None):
|
||||
if height != -1 or width != -1:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(filename, width, height, True)
|
||||
else:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename)
|
||||
|
||||
return Gtk.Image.new_from_pixbuf(pixbuf)
|
||||
|
||||
@staticmethod
|
||||
def PixbufFromFile(filename, style=False, width=None, height=None):
|
||||
if height != -1 or width != -1:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(filename, width, height, True)
|
||||
else:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename)
|
||||
|
||||
return pixbuf
|
||||
|
||||
@staticmethod
|
||||
def ProgressBar(style=False):
|
||||
bar = Gtk.ProgressBar()
|
||||
|
||||
if style != False:
|
||||
ctx = bar.get_style_context()
|
||||
ctx.add_class(style)
|
||||
|
||||
return bar
|
||||
|
||||
@staticmethod
|
||||
def Button(label=None, style=None):
|
||||
b = Gtk.Button(label=label)
|
||||
b.set_hexpand(True)
|
||||
b.set_vexpand(True)
|
||||
b.set_can_focus(False)
|
||||
b.props.relief = Gtk.ReliefStyle.NONE
|
||||
|
||||
if style != None:
|
||||
b.get_style_context().add_class(style)
|
||||
|
||||
return b
|
||||
|
||||
@staticmethod
|
||||
def ButtonImage(image_name, label=None, style=None, height=None, width=None):
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(klipperscreendir + "/styles/z-bolt/images/" + str(image_name) + ".svg")
|
||||
|
||||
if height != None and width != None:
|
||||
pixbuf = pixbuf.scale_simple(width, height, GdkPixbuf.InterpType.BILINEAR)
|
||||
|
||||
|
||||
img = Gtk.Image.new_from_pixbuf(pixbuf)
|
||||
|
||||
b = Gtk.Button(label=label)
|
||||
b.set_image(img)
|
||||
b.set_hexpand(True)
|
||||
b.set_vexpand(True)
|
||||
b.set_can_focus(False)
|
||||
b.set_image_position(Gtk.PositionType.TOP)
|
||||
b.set_always_show_image(True)
|
||||
b.props.relief = Gtk.ReliefStyle.NONE
|
||||
|
||||
if style != None:
|
||||
b.get_style_context().add_class(style)
|
||||
|
||||
return b
|
||||
|
||||
@staticmethod
|
||||
def Dialog(screen, buttons, content, callback=None, *args):
|
||||
dialog = Gtk.Dialog()
|
||||
dialog.set_default_size(screen.width - 15, screen.height - 15)
|
||||
dialog.set_resizable(False)
|
||||
dialog.set_transient_for(screen)
|
||||
dialog.set_modal(True)
|
||||
|
||||
for button in buttons:
|
||||
dialog.add_button(button_text=button['name'], response_id=button['response'])
|
||||
|
||||
dialog.connect("response", callback, *args)
|
||||
dialog.get_style_context().add_class("dialog")
|
||||
|
||||
grid = Gtk.Grid()
|
||||
grid.set_size_request(screen.width - 60, -1)
|
||||
grid.set_vexpand(True)
|
||||
grid.set_halign(Gtk.Align.CENTER)
|
||||
grid.set_valign(Gtk.Align.CENTER)
|
||||
grid.add(content)
|
||||
|
||||
content_area = dialog.get_content_area()
|
||||
content_area.set_margin_start(15)
|
||||
content_area.set_margin_end(15)
|
||||
content_area.set_margin_top(15)
|
||||
content_area.set_margin_bottom(15)
|
||||
content_area.add(grid)
|
||||
|
||||
dialog.show_all()
|
||||
|
||||
return dialog, grid
|
||||
|
||||
|
||||
@staticmethod
|
||||
def ToggleButtonImage(image_name, label, style=False):
|
||||
img = Gtk.Image.new_from_file(klipperscreendir + "/styles/z-bolt/images/" + str(image_name) + ".svg")
|
||||
|
||||
b = Gtk.ToggleButton(label=label)
|
||||
#b.props.relief = Gtk.RELIEF_NONE
|
||||
b.set_image(img)
|
||||
b.set_hexpand(True)
|
||||
b.set_vexpand(True)
|
||||
b.set_can_focus(False)
|
||||
b.set_image_position(Gtk.PositionType.TOP)
|
||||
b.set_always_show_image(True)
|
||||
b.props.relief = Gtk.ReliefStyle.NONE
|
||||
|
||||
if style != False:
|
||||
ctx = b.get_style_context()
|
||||
ctx.add_class(style)
|
||||
|
||||
return b
|
||||
|
||||
@staticmethod
|
||||
def HomogeneousGrid(width=None, height=None):
|
||||
g = Gtk.Grid()
|
||||
g.set_row_homogeneous(True)
|
||||
g.set_column_homogeneous(True)
|
||||
if width != None and height != None:
|
||||
g.set_size_request(width, height)
|
||||
return g
|
||||
|
||||
@staticmethod
|
||||
def ToggleButton(text):
|
||||
b = Gtk.ToggleButton(text)
|
||||
b.props.relief = Gtk.ReliefStyle.NONE
|
||||
b.set_hexpand(True)
|
||||
b.set_vexpand(True)
|
||||
return b
|
||||
|
||||
@staticmethod
|
||||
def formatFileName(name):
|
||||
name = name.split('/')[-1] if "/" in name else name
|
||||
name = name.split('.gcod')[0] if ".gcode" in name else name
|
||||
if len(name) > 25:
|
||||
return name[0:25] + "\n" + name[25:50]
|
||||
return name
|
||||
|
||||
|
||||
@staticmethod
|
||||
def formatTimeString(seconds):
|
||||
time = int(seconds)
|
||||
text = ""
|
||||
if int(time/3600) !=0:
|
||||
text += str(int(time/3600))+"h "
|
||||
text += str(int(time/60)%60)+"m "+str(time%60)+"s"
|
||||
return text
|
||||
|
||||
@staticmethod
|
||||
def formatTemperatureString(temp, target):
|
||||
if (target > temp-2 and target < temp+2) or round(target,0) == 0:
|
||||
return str(round(temp,2)) + "°C" #°C →"
|
||||
return str(round(temp)) + " → " + str(round(target)) + "°C"
|
||||
@@ -0,0 +1,32 @@
|
||||
import json
|
||||
import requests
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.KlippyRest")
|
||||
|
||||
class KlippyRest:
|
||||
def __init__(self, ip, port=7125):
|
||||
self.ip = ip
|
||||
self.port = port
|
||||
|
||||
def get_server_info(self):
|
||||
return self.send_request("server/info")
|
||||
|
||||
def get_printer_info(self):
|
||||
return self.send_request("printer/info")
|
||||
|
||||
def send_request(self, method):
|
||||
url = "http://%s:%s/%s" % (self.ip, self.port, method)
|
||||
logger.debug("Sending request to %s" % url)
|
||||
r = requests.get(url)
|
||||
if r.status_code != 200:
|
||||
return False
|
||||
|
||||
#TODO: Try/except
|
||||
try:
|
||||
data = json.loads(r.content)
|
||||
except:
|
||||
logger.exception("Unable to parse response from moonraker:\n %s" % r.content)
|
||||
return False
|
||||
|
||||
return data
|
||||
@@ -13,7 +13,7 @@ logger = logging.getLogger("KlipperScreen.KlipperWebsocket")
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
from KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
|
||||
#f = open("/home/pi/.moonraker_api_key", "r")
|
||||
api_key = "" #f.readline()
|
||||
@@ -35,8 +35,8 @@ api = {
|
||||
class KlippyWebsocket(threading.Thread):
|
||||
_req_id = 0
|
||||
connected = False
|
||||
|
||||
callback_table = {}
|
||||
timeout = None
|
||||
|
||||
def __init__(self, screen, callback):
|
||||
threading.Thread.__init__(self)
|
||||
@@ -47,16 +47,17 @@ class KlippyWebsocket(threading.Thread):
|
||||
self._url = "127.0.0.1:7125"
|
||||
|
||||
def connect (self):
|
||||
r = requests.get(
|
||||
"http://%s%s" % (self._url, api['oneshot_token']['url']),
|
||||
headers={"x-api-key":api_key}
|
||||
)
|
||||
if r.status_code != 200:
|
||||
logger.info("Failed to retrieve oneshot token")
|
||||
return
|
||||
#r = requests.get(
|
||||
# "http://%s%s" % (self._url, api['oneshot_token']['url']),
|
||||
# headers={"x-api-key":api_key}
|
||||
#)
|
||||
#if r.status_code != 200:
|
||||
# logger.info("Failed to retrieve oneshot token")
|
||||
# return
|
||||
|
||||
token = json.loads(r.content)['result']
|
||||
self.ws_url = "ws://%s/websocket?token=%s" % (self._url, token)
|
||||
#token = json.loads(r.content)['result']
|
||||
#self.ws_url = "ws://%s/websocket?token=%s" % (self._url, token)
|
||||
self.ws_url = "ws://%s/websocket" % (self._url)
|
||||
self.ws = websocket.WebSocketApp(self.ws_url,
|
||||
on_message = lambda ws,msg: self.on_message(ws, msg),
|
||||
on_error = lambda ws,msg: self.on_error(ws, msg),
|
||||
@@ -66,7 +67,10 @@ class KlippyWebsocket(threading.Thread):
|
||||
|
||||
self._wst = threading.Thread(target=self.ws.run_forever)
|
||||
self._wst.daemon = True
|
||||
self._wst.start()
|
||||
try:
|
||||
self._wst.start()
|
||||
except Exception:
|
||||
logger.debug("Error starting web socket")
|
||||
|
||||
def is_connected(self):
|
||||
return self.connected
|
||||
@@ -86,16 +90,19 @@ class KlippyWebsocket(threading.Thread):
|
||||
self.callback_table.pop(response['id'])
|
||||
return
|
||||
|
||||
if "method" in response:
|
||||
if "method" in response and "on_message" in self._callback:
|
||||
Gdk.threads_add_idle(
|
||||
GLib.PRIORITY_HIGH_IDLE,
|
||||
self._callback,
|
||||
self._callback['on_message'],
|
||||
response['method'],
|
||||
response['params'][0] if "params" in response else {}
|
||||
)
|
||||
return
|
||||
|
||||
def send_method(self, method, params={}, callback=None, *args):
|
||||
if self.is_connected() == False:
|
||||
return False
|
||||
|
||||
self._req_id += 1
|
||||
if callback != None:
|
||||
self.callback_table[self._req_id] = [callback, method, params, [*args]]
|
||||
@@ -107,38 +114,44 @@ class KlippyWebsocket(threading.Thread):
|
||||
"id": self._req_id
|
||||
}
|
||||
self.ws.send(json.dumps(data))
|
||||
return True
|
||||
|
||||
def on_open(self, ws):
|
||||
logger.info("### ws open ###")
|
||||
logger.info("Moonraker Websocket Open")
|
||||
logger.info("Self.connected = %s" % self.is_connected())
|
||||
self.connected = True
|
||||
self.timeout = None
|
||||
if "on_connect" in self._callback:
|
||||
Gdk.threads_add_idle(
|
||||
GLib.PRIORITY_HIGH_IDLE,
|
||||
self._callback['on_connect']
|
||||
)
|
||||
|
||||
def on_close(self, ws):
|
||||
logger.info("### ws closed ###")
|
||||
if self.is_connected() == False:
|
||||
logger.debug("Connection already closed")
|
||||
return
|
||||
|
||||
logger.info("Moonraker Websocket Closed")
|
||||
self.connected = False
|
||||
if self.timeout == None:
|
||||
self.timeout = GLib.timeout_add(500, self.reconnect)
|
||||
|
||||
# TODO: Make non-blocking
|
||||
Gdk.threads_add_idle(
|
||||
GLib.PRIORITY_HIGH_IDLE,
|
||||
self._screen.printer_initializing,
|
||||
"Connecting to Moonraker..."
|
||||
)
|
||||
if "on_close" in self._callback:
|
||||
Gdk.threads_add_idle(
|
||||
GLib.PRIORITY_HIGH_IDLE,
|
||||
self._callback['on_close'],
|
||||
"Lost Connection to Moonraker"
|
||||
)
|
||||
|
||||
while (True == True):
|
||||
try:
|
||||
info = self._screen.apiclient.get_info()
|
||||
except Exception:
|
||||
continue
|
||||
if info != False:
|
||||
self.connect()
|
||||
if self.is_connected():
|
||||
break
|
||||
logger.info("### Waiting for websocket")
|
||||
time.sleep(.5)
|
||||
def reconnect(self):
|
||||
logger.debug("Attempting to reconnect")
|
||||
if self.is_connected():
|
||||
logger.debug("Reconnected")
|
||||
return False
|
||||
|
||||
Gdk.threads_add_idle(
|
||||
GLib.PRIORITY_HIGH_IDLE,
|
||||
self._screen.printer_ready
|
||||
)
|
||||
self.connect()
|
||||
return True
|
||||
|
||||
|
||||
def on_error(self, ws, error):
|
||||
@@ -150,13 +163,13 @@ class MoonrakerApi:
|
||||
|
||||
def emergency_stop(self):
|
||||
logger.info("Sending printer.emergency_stop")
|
||||
self._ws.send_method(
|
||||
return self._ws.send_method(
|
||||
"printer.emergency_stop"
|
||||
)
|
||||
|
||||
def gcode_script(self, script, callback=None, *args):
|
||||
logger.debug("Sending printer.gcode.script: %s", script)
|
||||
self._ws.send_method(
|
||||
return self._ws.send_method(
|
||||
"printer.gcode.script",
|
||||
{"script": script},
|
||||
callback,
|
||||
@@ -166,7 +179,7 @@ class MoonrakerApi:
|
||||
def get_file_list(self, callback=None, *args):
|
||||
#Commenting this log for being too noisy
|
||||
#logger.debug("Sending server.files.list")
|
||||
self._ws.send_method(
|
||||
return self._ws.send_method(
|
||||
"server.files.list",
|
||||
{},
|
||||
callback,
|
||||
@@ -175,7 +188,7 @@ class MoonrakerApi:
|
||||
|
||||
def get_file_metadata(self, filename, callback=None, *args):
|
||||
logger.debug("Sending server.files.metadata: %s", filename)
|
||||
self._ws.send_method(
|
||||
return self._ws.send_method(
|
||||
"server.files.metadata",
|
||||
{"filename": filename},
|
||||
callback,
|
||||
@@ -184,14 +197,32 @@ class MoonrakerApi:
|
||||
|
||||
def object_subscription(self, updates):
|
||||
logger.debug("Sending printer.objects.subscribe: %s", str(updates))
|
||||
self._ws.send_method(
|
||||
return self._ws.send_method(
|
||||
"printer.objects.subscribe",
|
||||
updates
|
||||
)
|
||||
|
||||
def power_device_off(self, device, callback=None, *args):
|
||||
logger.debug("Sending machine.device_power.off: %s" % device)
|
||||
return self._ws.send_method(
|
||||
"machine.device_power.off",
|
||||
{device: False},
|
||||
callback,
|
||||
*args
|
||||
)
|
||||
|
||||
def power_device_on(self, device, callback=None, *args):
|
||||
logger.debug("Sending machine.device_power.on %s" % device)
|
||||
return self._ws.send_method(
|
||||
"machine.device_power.on",
|
||||
{device: False},
|
||||
callback,
|
||||
*args
|
||||
)
|
||||
|
||||
def print_cancel(self, callback=None, *args):
|
||||
logger.debug("Sending printer.print.cancel")
|
||||
self._ws.send_method(
|
||||
return self._ws.send_method(
|
||||
"printer.print.cancel",
|
||||
{},
|
||||
callback,
|
||||
@@ -200,7 +231,7 @@ class MoonrakerApi:
|
||||
|
||||
def print_pause(self, callback=None, *args):
|
||||
logger.debug("Sending printer.print.pause")
|
||||
self._ws.send_method(
|
||||
return self._ws.send_method(
|
||||
"printer.print.pause",
|
||||
{},
|
||||
callback,
|
||||
@@ -209,7 +240,7 @@ class MoonrakerApi:
|
||||
|
||||
def print_resume(self, callback=None, *args):
|
||||
logger.debug("Sending printer.print.resume")
|
||||
self._ws.send_method(
|
||||
return self._ws.send_method(
|
||||
"printer.print.resume",
|
||||
{},
|
||||
callback,
|
||||
@@ -218,7 +249,7 @@ class MoonrakerApi:
|
||||
|
||||
def print_start(self, filename, callback=None, *args):
|
||||
logger.debug("Sending printer.print.start")
|
||||
self._ws.send_method(
|
||||
return self._ws.send_method(
|
||||
"printer.print.start",
|
||||
{
|
||||
"filename": filename
|
||||
@@ -230,7 +261,7 @@ class MoonrakerApi:
|
||||
def temperature_set(self, heater, target, callback=None, *args):
|
||||
if heater == "heater_bed":
|
||||
logger.debug("Sending printer.gcode.script: %s", KlippyGcodes.set_bed_temp(target))
|
||||
self._ws.send_method(
|
||||
return self._ws.send_method(
|
||||
"printer.gcode.script",
|
||||
{
|
||||
"script": KlippyGcodes.set_bed_temp(target)
|
||||
@@ -242,7 +273,7 @@ class MoonrakerApi:
|
||||
logger.debug("Sending printer.gcode.script: %s",
|
||||
KlippyGcodes.set_ext_temp(target, heater.replace("tool","")))
|
||||
#TODO: Add max/min limits
|
||||
self._ws.send_method(
|
||||
return self._ws.send_method(
|
||||
"printer.gcode.script",
|
||||
{
|
||||
"script": KlippyGcodes.set_ext_temp(target, heater.replace("tool",""))
|
||||
@@ -253,7 +284,7 @@ class MoonrakerApi:
|
||||
|
||||
def set_bed_temp(self, target, callback=None, *args):
|
||||
logger.debug("Sending set_bed_temp: %s", KlippyGcodes.set_bed_temp(target))
|
||||
self._ws.send_method(
|
||||
return self._ws.send_method(
|
||||
"printer.gcode.script",
|
||||
{
|
||||
"script": KlippyGcodes.set_bed_temp(target)
|
||||
@@ -264,7 +295,7 @@ class MoonrakerApi:
|
||||
|
||||
def set_tool_temp(self, tool, target, callback=None, *args):
|
||||
logger.debug("Sending set_tool_temp: %s", KlippyGcodes.set_ext_temp(target, tool))
|
||||
self._ws.send_method(
|
||||
return self._ws.send_method(
|
||||
"printer.gcode.script",
|
||||
{
|
||||
"script": KlippyGcodes.set_ext_temp(target, tool)
|
||||
@@ -275,12 +306,12 @@ class MoonrakerApi:
|
||||
|
||||
def restart(self):
|
||||
logger.debug("Sending printer.restart")
|
||||
self._ws.send_method(
|
||||
return self._ws.send_method(
|
||||
"printer.restart"
|
||||
)
|
||||
|
||||
def restart_firmware(self):
|
||||
logger.debug("Sending printer.firmware_restart")
|
||||
self._ws.send_method(
|
||||
return self._ws.send_method(
|
||||
"printer.firmware_restart"
|
||||
)
|
||||
@@ -0,0 +1,128 @@
|
||||
import configparser
|
||||
import os
|
||||
import logging
|
||||
import json
|
||||
|
||||
from io import StringIO
|
||||
|
||||
from os import path
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.config")
|
||||
|
||||
class ConfigError(Exception):
|
||||
pass
|
||||
|
||||
class KlipperScreenConfig:
|
||||
config = None
|
||||
|
||||
def __init__(self):
|
||||
self.config = configparser.ConfigParser()
|
||||
self.config_path = self.get_config_file_location()
|
||||
|
||||
try:
|
||||
self.config.read(self.config_path)
|
||||
except KeyError:
|
||||
raise ConfigError(f"Error reading config: {self.config_path}")
|
||||
|
||||
self.log_config(self.config)
|
||||
|
||||
self.get_menu_items("__main")
|
||||
#self.build_main_menu(self.config)
|
||||
|
||||
|
||||
def get_config_file_location(self):
|
||||
conf_name = "KlipperScreen.conf"
|
||||
|
||||
file = "%s/%s" % (os.getenv("HOME"), conf_name)
|
||||
if not path.exists(file):
|
||||
file = "%s/%s" % (os.getcwd(), conf_name)
|
||||
if not path.exists(file):
|
||||
file = "%s/ks_includes/%s" % (os.getcwd(), conf_name)
|
||||
|
||||
logger.info("Found configuration file at: %s" % file)
|
||||
return file
|
||||
|
||||
def get_menu_items(self, menu="__main", subsection=""):
|
||||
if subsection != "":
|
||||
subsection = subsection + " "
|
||||
index = "menu %s %s" % (menu, subsection)
|
||||
logger.debug("Getting menu items for: %s" % index)
|
||||
items = [i[len(index):] for i in self.config.sections() if i.startswith(index)]
|
||||
menu_items = []
|
||||
for item in items:
|
||||
split = item.split()
|
||||
if len(split) == 1:
|
||||
menu_items.append(self._build_menu_item(menu, index + item))
|
||||
|
||||
return menu_items
|
||||
|
||||
def get_menu_name(self, menu="__main", subsection=""):
|
||||
name = ("menu %s %s" % (menu, subsection)) if subsection != "" else ("menu %s" % menu)
|
||||
logger.debug("Menu name: %s" % name)
|
||||
if name not in self.config:
|
||||
return False
|
||||
return self.config[name].get('name')
|
||||
|
||||
|
||||
def get_preheat_options(self):
|
||||
index = "preheat "
|
||||
items = [i[len(index):] for i in self.config.sections() if i.startswith(index)]
|
||||
logger.debug("Items: %s" % items)
|
||||
|
||||
preheat_options = {}
|
||||
for item in items:
|
||||
preheat_options[item] = self._build_preheat_item(index + item)
|
||||
|
||||
return preheat_options
|
||||
|
||||
def get_printer_power_name(self):
|
||||
return self.config['settings'].get("printer_power_name", "printer")
|
||||
|
||||
|
||||
def log_config(self, config):
|
||||
lines = [
|
||||
" "
|
||||
"===== Config File =====",
|
||||
self._build_config_string(config),
|
||||
"======================="
|
||||
]
|
||||
logger.info("\n".join(lines))
|
||||
|
||||
def _build_config_string(self, config):
|
||||
sfile = StringIO()
|
||||
config.write(sfile)
|
||||
sfile.seek(0)
|
||||
return sfile.read().strip()
|
||||
|
||||
|
||||
|
||||
def _build_menu_item(self, menu, name):
|
||||
if name not in self.config:
|
||||
return False
|
||||
cfg = self.config[name]
|
||||
item = {
|
||||
"name": cfg.get("name"),
|
||||
"icon": cfg.get("icon"),
|
||||
"panel": cfg.get("panel", False),
|
||||
"method": cfg.get("method", False),
|
||||
"confirm": cfg.get("confirm", False),
|
||||
"enable": cfg.get("enable", True)
|
||||
}
|
||||
|
||||
try:
|
||||
item["params"] = json.loads(cfg.get("params", "{}"))
|
||||
except:
|
||||
logger.debug("Unable to parse parameters for [%s]" % name)
|
||||
item["params"] = {}
|
||||
|
||||
return {name[(len(menu) + 6):]: item}
|
||||
|
||||
def _build_preheat_item(self, name):
|
||||
if name not in self.config:
|
||||
return False
|
||||
cfg = self.config[name]
|
||||
item = {
|
||||
"extruder": cfg.getint("extruder", 0),
|
||||
"bed": cfg.getint("bed", 0)
|
||||
}
|
||||
return item
|
||||
@@ -18,7 +18,7 @@ class KlippyFiles:
|
||||
|
||||
def __init__(self, screen):
|
||||
self._screen = screen
|
||||
self.timeout = GLib.timeout_add(2000, self.ret_files)
|
||||
self.add_timeout()
|
||||
|
||||
if not os.path.exists('/tmp/.KS-thumbnails'):
|
||||
os.makedirs('/tmp/.KS-thumbnails')
|
||||
@@ -62,7 +62,7 @@ class KlippyFiles:
|
||||
elif method == "server.files.metadata":
|
||||
if "error" in result.keys():
|
||||
logger.debug("Error in getting metadata for %s" %(params['filename']))
|
||||
GLib.timeout_add(2000, self._screen._ws.klippy.get_file_metadata, params['filename'], self._callback)
|
||||
self.request_metadata(params['filename'])
|
||||
return
|
||||
|
||||
logger.debug("Got metadata for %s" % (result['result']['filename']))
|
||||
@@ -81,8 +81,22 @@ class KlippyFiles:
|
||||
def add_file_callback(self, callback):
|
||||
self.callbacks.append(callback)
|
||||
|
||||
def add_timeout(self):
|
||||
if self.timeout == None:
|
||||
self.timeout = GLib.timeout_add(4000, self.ret_files)
|
||||
|
||||
def remove_timeout(self):
|
||||
if self.timeout != None:
|
||||
self.timeout = None
|
||||
|
||||
def request_metadata(self, filename):
|
||||
GLib.timeout_add(2000, self._screen._ws.klippy.get_file_metadata, filename, self._callback)
|
||||
return False
|
||||
|
||||
def ret_files(self, retval=True):
|
||||
self._screen._ws.klippy.get_file_list(self._callback)
|
||||
if not self._screen._ws.klippy.get_file_list(self._callback):
|
||||
self.timeout = None
|
||||
return False
|
||||
return retval
|
||||
|
||||
def ret_file_data (self, filename):
|
||||
@@ -0,0 +1,288 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-11-18 12:37+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: panels/print.py:229
|
||||
msgid "?"
|
||||
msgstr ""
|
||||
|
||||
#: panels/zcalibrate.py:65
|
||||
msgid "Abort"
|
||||
msgstr ""
|
||||
|
||||
#: panels/zcalibrate.py:61
|
||||
msgid "Accept"
|
||||
msgstr ""
|
||||
|
||||
#: panels/print.py:229
|
||||
msgid "Are you sure you want to print"
|
||||
msgstr ""
|
||||
|
||||
#: panels/job_status.py:108
|
||||
msgid "Are you sure you wish to cancel this print?"
|
||||
msgstr ""
|
||||
|
||||
#: panels/bed_level.py:89 panels/fan.py:52 panels/fine_tune.py:119
|
||||
#: panels/menu.py:18 panels/move.py:96 panels/network.py:34
|
||||
#: panels/preheat.py:54 panels/temperature.py:78
|
||||
msgid "Back"
|
||||
msgstr ""
|
||||
|
||||
#: panels/job_status.py:79 panels/print.py:225
|
||||
msgid "Cancel"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fan.py:42
|
||||
msgid "Cancel Change"
|
||||
msgstr ""
|
||||
|
||||
#: panels/job_status.py:111
|
||||
msgid "Cancel Print"
|
||||
msgstr ""
|
||||
|
||||
#: panels/temperature.py:146
|
||||
msgid "Close"
|
||||
msgstr ""
|
||||
|
||||
#: panels/job_status.py:85
|
||||
msgid "Control"
|
||||
msgstr ""
|
||||
|
||||
#: panels/preheat.py:51
|
||||
msgid "Cooldown"
|
||||
msgstr ""
|
||||
|
||||
#: panels/temperature.py:49
|
||||
msgid "Decrease"
|
||||
msgstr ""
|
||||
|
||||
#: panels/bed_level.py:79
|
||||
msgid "Disable XY"
|
||||
msgstr ""
|
||||
|
||||
#: panels/zcalibrate.py:57
|
||||
msgid "Distance (mm)"
|
||||
msgstr ""
|
||||
|
||||
#: panels/bed_level.py:85 panels/job_status.py:82
|
||||
msgid "Emergency Stop"
|
||||
msgstr ""
|
||||
|
||||
#: panels/extrude.py:32
|
||||
msgid "Extrude"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:66 panels/fine_tune.py:134
|
||||
msgid "Extrusion"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:64
|
||||
msgid "Extrusion +"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:68
|
||||
msgid "Extrusion -"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:46 panels/fine_tune.py:141
|
||||
msgid "Fan"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:44
|
||||
msgid "Fan +"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:48
|
||||
msgid "Fan -"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fan.py:32
|
||||
msgid "Fan Off"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fan.py:35
|
||||
msgid "Fan On"
|
||||
msgstr ""
|
||||
|
||||
#: panels/extrude.py:21 panels/extrude.py:25
|
||||
msgid "Fast"
|
||||
msgstr ""
|
||||
|
||||
#: panels/system.py:22 panels/splash_screen.py:59
|
||||
msgid "Firmware Restart"
|
||||
msgstr ""
|
||||
|
||||
#: panels/job_status.py:115
|
||||
msgid "Go Back"
|
||||
msgstr ""
|
||||
|
||||
#: panels/bed_level.py:76 panels/move.py:38
|
||||
msgid "Home All"
|
||||
msgstr ""
|
||||
|
||||
#: panels/zcalibrate.py:25
|
||||
msgid "Homing"
|
||||
msgstr ""
|
||||
|
||||
#: panels/temperature.py:47
|
||||
msgid "Increase"
|
||||
msgstr ""
|
||||
|
||||
#: panels/splash_screen.py:23
|
||||
msgid "Initializing printer..."
|
||||
msgstr ""
|
||||
|
||||
#: panels/system.py:20
|
||||
msgid "Klipper Restart"
|
||||
msgstr ""
|
||||
|
||||
#: panels/system.py:43 panels/system.py:42
|
||||
msgid "KlipperScreen Version"
|
||||
msgstr ""
|
||||
|
||||
#: panels/system.py:62
|
||||
msgid "Load Average"
|
||||
msgstr ""
|
||||
|
||||
#: panels/zcalibrate.py:34
|
||||
msgid "Lower Nozzle"
|
||||
msgstr ""
|
||||
|
||||
#: panels/extrude.py:20 panels/extrude.py:21 panels/extrude.py:24
|
||||
msgid "Medium"
|
||||
msgstr ""
|
||||
|
||||
#: panels/move.py:87
|
||||
msgid "Move Distance (mm)"
|
||||
msgstr ""
|
||||
|
||||
#: panels/network.py:28
|
||||
msgid "Network Info"
|
||||
msgstr ""
|
||||
|
||||
#: panels/temperature.py:51
|
||||
msgid "Number Pad"
|
||||
msgstr ""
|
||||
|
||||
#: panels/job_status.py:70
|
||||
msgid "Pause"
|
||||
msgstr ""
|
||||
|
||||
#: panels/print.py:224
|
||||
msgid "Print"
|
||||
msgstr ""
|
||||
|
||||
#: panels/print.py:154
|
||||
msgid "Print Time"
|
||||
msgstr ""
|
||||
|
||||
#: panels/zcalibrate.py:32
|
||||
msgid "Raise Nozzle"
|
||||
msgstr ""
|
||||
|
||||
#: panels/splash_screen.py:57
|
||||
msgid "Restart"
|
||||
msgstr ""
|
||||
|
||||
#: panels/job_status.py:68
|
||||
msgid "Resume"
|
||||
msgstr ""
|
||||
|
||||
#: panels/extrude.py:34
|
||||
msgid "Retract"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fan.py:39
|
||||
msgid "Set Speed"
|
||||
msgstr ""
|
||||
|
||||
#: panels/print.py:152
|
||||
msgid "Size"
|
||||
msgstr ""
|
||||
|
||||
#: panels/extrude.py:21 panels/extrude.py:23
|
||||
msgid "Slow"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:56 panels/fine_tune.py:137
|
||||
msgid "Speed"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:54
|
||||
msgid "Speed +"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:58
|
||||
msgid "Speed -"
|
||||
msgstr ""
|
||||
|
||||
#: panels/system.py:31 panels/system.py:30
|
||||
msgid "System Information"
|
||||
msgstr ""
|
||||
|
||||
#: panels/extrude.py:36
|
||||
msgid "Temperature"
|
||||
msgstr ""
|
||||
|
||||
#: panels/job_status.py:33 panels/job_status.py:34
|
||||
msgid "Time Elapsed"
|
||||
msgstr ""
|
||||
|
||||
#: panels/job_status.py:35 panels/job_status.py:36
|
||||
msgid "Time Left"
|
||||
msgstr ""
|
||||
|
||||
#: panels/extrude.py:30
|
||||
msgid "Tool 1"
|
||||
msgstr ""
|
||||
|
||||
#: panels/print.py:150
|
||||
msgid "Uploaded"
|
||||
msgstr ""
|
||||
|
||||
#: panels/move.py:23
|
||||
msgid "X+"
|
||||
msgstr ""
|
||||
|
||||
#: panels/move.py:25
|
||||
msgid "X-"
|
||||
msgstr ""
|
||||
|
||||
#: panels/move.py:28
|
||||
msgid "Y+"
|
||||
msgstr ""
|
||||
|
||||
#: panels/move.py:30
|
||||
msgid "Y-"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:35 panels/fine_tune.py:131 panels/zcalibrate.py:23
|
||||
msgid "Z Offset"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:33 panels/move.py:33
|
||||
msgid "Z+"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:37 panels/move.py:35
|
||||
msgid "Z-"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:35
|
||||
msgid "mm"
|
||||
msgstr ""
|
||||
@@ -0,0 +1,269 @@
|
||||
#: panels/print.py:229
|
||||
msgid "?"
|
||||
msgstr ""
|
||||
|
||||
#: panels/zcalibrate.py:65
|
||||
msgid "Abort"
|
||||
msgstr "Abort"
|
||||
|
||||
#: panels/zcalibrate.py:61
|
||||
msgid "Accept"
|
||||
msgstr ""
|
||||
|
||||
#: panels/print.py:229
|
||||
msgid "Are you sure you want to print"
|
||||
msgstr ""
|
||||
|
||||
#: panels/job_status.py:108
|
||||
msgid "Are you sure you wish to cancel this print?"
|
||||
msgstr ""
|
||||
|
||||
#: panels/bed_level.py:89 panels/fan.py:52 panels/fine_tune.py:119
|
||||
#: panels/menu.py:18 panels/move.py:96 panels/network.py:34
|
||||
#: panels/preheat.py:54 panels/temperature.py:78
|
||||
msgid "Back"
|
||||
msgstr ""
|
||||
|
||||
#: panels/job_status.py:79 panels/print.py:225
|
||||
msgid "Cancel"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fan.py:42
|
||||
msgid "Cancel Change"
|
||||
msgstr ""
|
||||
|
||||
#: panels/job_status.py:111
|
||||
msgid "Cancel Print"
|
||||
msgstr ""
|
||||
|
||||
#: panels/temperature.py:146
|
||||
msgid "Close"
|
||||
msgstr ""
|
||||
|
||||
#: panels/job_status.py:85
|
||||
msgid "Control"
|
||||
msgstr ""
|
||||
|
||||
#: panels/preheat.py:51
|
||||
msgid "Cooldown"
|
||||
msgstr ""
|
||||
|
||||
#: panels/temperature.py:49
|
||||
msgid "Decrease"
|
||||
msgstr ""
|
||||
|
||||
#: panels/bed_level.py:79
|
||||
msgid "Disable XY"
|
||||
msgstr ""
|
||||
|
||||
#: panels/zcalibrate.py:57
|
||||
msgid "Distance (mm)"
|
||||
msgstr ""
|
||||
|
||||
#: panels/bed_level.py:85 panels/job_status.py:82
|
||||
msgid "Emergency Stop"
|
||||
msgstr ""
|
||||
|
||||
#: panels/extrude.py:32
|
||||
msgid "Extrude"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:66 panels/fine_tune.py:134
|
||||
msgid "Extrusion"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:64
|
||||
msgid "Extrusion +"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:68
|
||||
msgid "Extrusion -"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:46 panels/fine_tune.py:141
|
||||
msgid "Fan"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:44
|
||||
msgid "Fan +"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:48
|
||||
msgid "Fan -"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fan.py:32
|
||||
msgid "Fan Off"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fan.py:35
|
||||
msgid "Fan On"
|
||||
msgstr ""
|
||||
|
||||
#: panels/extrude.py:21 panels/extrude.py:25
|
||||
msgid "Fast"
|
||||
msgstr ""
|
||||
|
||||
#: panels/system.py:22 panels/splash_screen.py:59
|
||||
msgid "Firmware Restart"
|
||||
msgstr ""
|
||||
|
||||
#: panels/job_status.py:115
|
||||
msgid "Go Back"
|
||||
msgstr ""
|
||||
|
||||
#: panels/bed_level.py:76 panels/move.py:38
|
||||
msgid "Home All"
|
||||
msgstr ""
|
||||
|
||||
#: panels/zcalibrate.py:25
|
||||
msgid "Homing"
|
||||
msgstr ""
|
||||
|
||||
#: panels/temperature.py:47
|
||||
msgid "Increase"
|
||||
msgstr ""
|
||||
|
||||
#: panels/splash_screen.py:23
|
||||
msgid "Initializing printer..."
|
||||
msgstr ""
|
||||
|
||||
#: panels/system.py:20
|
||||
msgid "Klipper Restart"
|
||||
msgstr ""
|
||||
|
||||
#: panels/system.py:43 panels/system.py:42
|
||||
msgid "KlipperScreen Version"
|
||||
msgstr ""
|
||||
|
||||
#: panels/system.py:62
|
||||
msgid "Load Average"
|
||||
msgstr ""
|
||||
|
||||
#: panels/zcalibrate.py:34
|
||||
msgid "Lower Nozzle"
|
||||
msgstr ""
|
||||
|
||||
#: panels/extrude.py:20 panels/extrude.py:21 panels/extrude.py:24
|
||||
msgid "Medium"
|
||||
msgstr ""
|
||||
|
||||
#: panels/move.py:87
|
||||
msgid "Move Distance (mm)"
|
||||
msgstr ""
|
||||
|
||||
#: panels/network.py:28
|
||||
msgid "Network Info"
|
||||
msgstr ""
|
||||
|
||||
#: panels/temperature.py:51
|
||||
msgid "Number Pad"
|
||||
msgstr ""
|
||||
|
||||
#: panels/job_status.py:70
|
||||
msgid "Pause"
|
||||
msgstr ""
|
||||
|
||||
#: panels/print.py:224
|
||||
msgid "Print"
|
||||
msgstr ""
|
||||
|
||||
#: panels/print.py:154
|
||||
msgid "Print Time"
|
||||
msgstr ""
|
||||
|
||||
#: panels/zcalibrate.py:32
|
||||
msgid "Raise Nozzle"
|
||||
msgstr ""
|
||||
|
||||
#: panels/splash_screen.py:57
|
||||
msgid "Restart"
|
||||
msgstr ""
|
||||
|
||||
#: panels/job_status.py:68
|
||||
msgid "Resume"
|
||||
msgstr ""
|
||||
|
||||
#: panels/extrude.py:34
|
||||
msgid "Retract"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fan.py:39
|
||||
msgid "Set Speed"
|
||||
msgstr ""
|
||||
|
||||
#: panels/print.py:152
|
||||
msgid "Size"
|
||||
msgstr ""
|
||||
|
||||
#: panels/extrude.py:21 panels/extrude.py:23
|
||||
msgid "Slow"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:56 panels/fine_tune.py:137
|
||||
msgid "Speed"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:54
|
||||
msgid "Speed +"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:58
|
||||
msgid "Speed -"
|
||||
msgstr ""
|
||||
|
||||
#: panels/system.py:31 panels/system.py:30
|
||||
msgid "System Information"
|
||||
msgstr ""
|
||||
|
||||
#: panels/extrude.py:36
|
||||
msgid "Temperature"
|
||||
msgstr ""
|
||||
|
||||
#: panels/job_status.py:33 panels/job_status.py:34
|
||||
msgid "Time Elapsed"
|
||||
msgstr ""
|
||||
|
||||
#: panels/job_status.py:35 panels/job_status.py:36
|
||||
msgid "Time Left"
|
||||
msgstr ""
|
||||
|
||||
#: panels/extrude.py:30
|
||||
msgid "Tool 1"
|
||||
msgstr ""
|
||||
|
||||
#: panels/print.py:150
|
||||
msgid "Uploaded"
|
||||
msgstr ""
|
||||
|
||||
#: panels/move.py:23
|
||||
msgid "X+"
|
||||
msgstr ""
|
||||
|
||||
#: panels/move.py:25
|
||||
msgid "X-"
|
||||
msgstr ""
|
||||
|
||||
#: panels/move.py:28
|
||||
msgid "Y+"
|
||||
msgstr ""
|
||||
|
||||
#: panels/move.py:30
|
||||
msgid "Y-"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:35 panels/fine_tune.py:131 panels/zcalibrate.py:23
|
||||
msgid "Z Offset"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:33 panels/move.py:33
|
||||
msgid "Z+"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:37 panels/move.py:35
|
||||
msgid "Z-"
|
||||
msgstr ""
|
||||
|
||||
#: panels/fine_tune.py:35
|
||||
msgid "mm"
|
||||
msgstr ""
|
||||
@@ -1,8 +1,10 @@
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.Printer")
|
||||
|
||||
class Printer:
|
||||
|
||||
def __init__(self, data):
|
||||
def __init__(self, printer_info, data):
|
||||
self.config = data['configfile']['config']
|
||||
|
||||
logging.info("### Reading printer config")
|
||||
@@ -12,6 +14,12 @@ class Printer:
|
||||
self.devices = {}
|
||||
self.state = data['print_stats']['state']
|
||||
self.data = data
|
||||
self.klipper = {}
|
||||
self.power_devices = {}
|
||||
|
||||
self.klipper = {
|
||||
"version": printer_info['software_version']
|
||||
}
|
||||
|
||||
for x in self.config.keys():
|
||||
if x.startswith('extruder'):
|
||||
@@ -32,14 +40,30 @@ class Printer:
|
||||
"temperature": 0,
|
||||
"target": 0
|
||||
}
|
||||
self.process_update(data)
|
||||
|
||||
logging.info("### Toolcount: " + str(self.toolcount) + " Heaters: " + str(self.extrudercount))
|
||||
logger.info("Klipper version: %s", self.klipper['version'])
|
||||
logger.info("### Toolcount: " + str(self.toolcount) + " Heaters: " + str(self.extrudercount))
|
||||
|
||||
def configure_power_devices(self, data):
|
||||
self.power_devices = {}
|
||||
|
||||
logger.debug("Processing power devices: %s" % data)
|
||||
for x in data['devices']:
|
||||
logger.debug(x)
|
||||
self.power_devices[x['device']] = {
|
||||
"status": "on" if x['status'] == "on" else "off"
|
||||
}
|
||||
logger.debug("Power devices: %s" % self.power_devices)
|
||||
|
||||
def process_update(self, data):
|
||||
keys = ['virtual_sdcard','pause_resume','idle_timeout','print_stats']
|
||||
keys = ['fan','gcode_move','idle_timeout','pause_resume','print_stats','toolhead','virtual_sdcard']
|
||||
for x in keys:
|
||||
if x in data:
|
||||
if x not in self.data:
|
||||
self.data[x] = {}
|
||||
|
||||
for y in data[x]:
|
||||
self.data[x][y] = data[x][y]
|
||||
|
||||
@@ -57,8 +81,12 @@ class Printer:
|
||||
if "temperature" in d:
|
||||
self.set_dev_stat(x, "temperature", d["temperature"])
|
||||
|
||||
def get_config_section_list(self):
|
||||
return list(self.config)
|
||||
def process_power_update(self, data):
|
||||
if data['device'] in self.power_devices:
|
||||
self.power_devices[data['device']]['status'] = data['status']
|
||||
|
||||
def get_config_section_list(self, search=""):
|
||||
return [i for i in list(self.config) if i.startswith(search)]
|
||||
|
||||
def get_config_section(self, section):
|
||||
if section not in self.config:
|
||||
@@ -68,6 +96,17 @@ class Printer:
|
||||
def get_data(self):
|
||||
return self.data
|
||||
|
||||
def get_klipper_version(self):
|
||||
return self.klipper['version']
|
||||
|
||||
def get_power_devices(self):
|
||||
return list(self.power_devices)
|
||||
|
||||
def get_power_device_status(self, device):
|
||||
if device not in self.power_devices:
|
||||
return
|
||||
return self.power_devices[device]['status']
|
||||
|
||||
def get_stat(self, stat, substat = None):
|
||||
if substat != None:
|
||||
return self.data[stat][substat]
|
||||
@@ -0,0 +1,86 @@
|
||||
import gi
|
||||
import logging
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
logger = logging.getLogger("KlipperScreen.ScreenPanel")
|
||||
|
||||
class ScreenPanel:
|
||||
title_spacing = 50
|
||||
|
||||
def __init__(self, screen, title, back=True):
|
||||
self._screen = screen
|
||||
self.lang = self._screen.lang
|
||||
self._printer = screen.printer
|
||||
self.labels = {}
|
||||
|
||||
self.layout = Gtk.Layout()
|
||||
self.layout.set_size(self._screen.width, self._screen.height)
|
||||
|
||||
if back == True:
|
||||
b = KlippyGtk.ButtonImage('back', None, None, 40, 40)
|
||||
b.connect("clicked", self._screen._menu_go_back)
|
||||
self.layout.put(b, 0, 0)
|
||||
|
||||
h = KlippyGtk.ButtonImage('home', None, None, 40, 40)
|
||||
h.connect("clicked", self.menu_return, True)
|
||||
self.layout.put(h, self._screen.width - 55, 0)
|
||||
|
||||
e = KlippyGtk.ButtonImage('emergency', None, None, 40, 40)
|
||||
e.connect("clicked", self.emergency_stop)
|
||||
self.layout.put(e, int(self._screen.width/4*3) - 20, 0)
|
||||
|
||||
self.title = Gtk.Label()
|
||||
self.title.set_size_request(self._screen.width, self.title_spacing)
|
||||
self.title.set_hexpand(True)
|
||||
self.title.set_halign(Gtk.Align.CENTER)
|
||||
self.title.set_valign(Gtk.Align.CENTER)
|
||||
self.set_title(title)
|
||||
self.layout.put(self.title, 0, 0)
|
||||
|
||||
self.content = Gtk.Box(spacing=0)
|
||||
self.content.set_size_request(self._screen.width, self._screen.height - self.title_spacing)
|
||||
self.layout.put(self.content, 0, self.title_spacing)
|
||||
|
||||
|
||||
def initialize(self, panel_name):
|
||||
# Create gtk items here
|
||||
return
|
||||
|
||||
def emergency_stop(self, widget):
|
||||
self._screen._ws.klippy.emergency_stop()
|
||||
|
||||
def get(self):
|
||||
return self.layout
|
||||
|
||||
def home(self, widget):
|
||||
self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
|
||||
|
||||
def menu_item_clicked(self, widget, panel, item):
|
||||
print("### Creating panel "+ item['panel'])
|
||||
if "items" in item:
|
||||
self._screen.show_panel(self._screen._cur_panels[-1] + '_' + item['name'], item['panel'], item['name'],
|
||||
1, False, items=item['items'])
|
||||
return
|
||||
self._screen.show_panel(self._screen._cur_panels[-1] + '_' + item['name'], item['panel'], item['name'],
|
||||
1, False)
|
||||
|
||||
def menu_return(self, widget, home=False):
|
||||
if home == False:
|
||||
self._screen._menu_go_back()
|
||||
return
|
||||
self._screen._menu_go_home()
|
||||
|
||||
def set_title(self, title):
|
||||
self.title.set_label(title)
|
||||
|
||||
def update_image_text(self, label, text):
|
||||
if label in self.labels and 'l' in self.labels[label]:
|
||||
self.labels[label]['l'].set_text(text)
|
||||
|
||||
def update_temp(self, dev, temp, target):
|
||||
if dev in self.labels:
|
||||
self.labels[dev].set_label(KlippyGtk.formatTemperatureString(temp, target))
|
||||
@@ -5,16 +5,17 @@ import re
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from KlippyGcodes import KlippyGcodes
|
||||
from KlippyGtk import KlippyGtk
|
||||
from panels.screen_panel import ScreenPanel
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.BedLevelPanel")
|
||||
|
||||
class BedLevelPanel(ScreenPanel):
|
||||
def initialize(self, menu):
|
||||
_ = self.lang.gettext
|
||||
self.screws = None
|
||||
self.panel = KlippyGtk.HomogeneousGrid()
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
self.disabled_motors = False
|
||||
|
||||
screws = []
|
||||
@@ -47,7 +48,7 @@ class BedLevelPanel(ScreenPanel):
|
||||
yconf = self._screen.printer.get_config_section("stepper_y")
|
||||
x = int(int(xconf['position_max'])/4)
|
||||
y = int(int(yconf['position_max'])/4)
|
||||
screws = [
|
||||
self.screws = [
|
||||
[x, y],
|
||||
[x*3, y],
|
||||
[x, y*3],
|
||||
@@ -67,27 +68,25 @@ class BedLevelPanel(ScreenPanel):
|
||||
self.labels['br'] = KlippyGtk.ButtonImage("bed-level-b-r")
|
||||
self.labels['br'].connect("clicked", self.go_to_position, self.screws[1])
|
||||
|
||||
self.panel.attach(self.labels['tl'], 1, 0, 1, 1)
|
||||
self.panel.attach(self.labels['tr'], 2, 0, 1, 1)
|
||||
self.panel.attach(self.labels['bl'], 1, 1, 1, 1)
|
||||
self.panel.attach(self.labels['br'], 2, 1, 1, 1)
|
||||
grid.attach(self.labels['tl'], 1, 0, 1, 1)
|
||||
grid.attach(self.labels['tr'], 2, 0, 1, 1)
|
||||
grid.attach(self.labels['bl'], 1, 1, 1, 1)
|
||||
grid.attach(self.labels['br'], 2, 1, 1, 1)
|
||||
|
||||
self.labels['home'] = KlippyGtk.ButtonImage("home","Home All","color2")
|
||||
self.labels['home'] = KlippyGtk.ButtonImage("home",_("Home All"),"color2")
|
||||
self.labels['home'].connect("clicked", self.home)
|
||||
|
||||
self.labels['dm'] = KlippyGtk.ButtonImage("motor-off", "Disable XY", "color3")
|
||||
self.labels['dm'] = KlippyGtk.ButtonImage("motor-off", _("Disable XY"), "color3")
|
||||
self.labels['dm'].connect("clicked", self.disable_motors)
|
||||
|
||||
self.panel.attach(self.labels['home'], 0, 0, 1, 1)
|
||||
self.panel.attach(self.labels['dm'], 0, 1, 1, 1)
|
||||
grid.attach(self.labels['home'], 0, 0, 1, 1)
|
||||
grid.attach(self.labels['dm'], 0, 1, 1, 1)
|
||||
|
||||
self.labels['estop'] = KlippyGtk.ButtonImage("decrease","Emergency Stop","color4")
|
||||
self.labels['estop'] = KlippyGtk.ButtonImage("decrease",_("Emergency Stop"),"color4")
|
||||
self.labels['estop'].connect("clicked", self.emergency_stop)
|
||||
self.panel.attach(self.labels['estop'], 3, 0, 1, 1)
|
||||
grid.attach(self.labels['estop'], 3, 0, 1, 1)
|
||||
|
||||
b = KlippyGtk.ButtonImage('back', 'Back')
|
||||
b.connect("clicked", self._screen._menu_go_back)
|
||||
self.panel.attach(b, 3, 1, 1, 1)
|
||||
self.content.add(grid)
|
||||
|
||||
def go_to_position(self, widget, position):
|
||||
logger.debug("Going to position: %s", position)
|
||||
@@ -111,10 +110,5 @@ class BedLevelPanel(ScreenPanel):
|
||||
"M18" # Disable motors
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#for screw in screws:
|
||||
# sorted(screws.items(), key=lambda x: (float(x[1].split(",")[0]), float(x[1].split(",")[1])))
|
||||
def create_panel(*args):
|
||||
return BedLevelPanel(*args)
|
||||
@@ -1,13 +1,21 @@
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from KlippyGtk import KlippyGtk
|
||||
from KlippyGcodes import KlippyGcodes
|
||||
from panels.screen_panel import ScreenPanel
|
||||
|
||||
class ExamplePanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
# Create gtk items here
|
||||
return
|
||||
import gi
|
||||
import logging
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.ExamplePanel")
|
||||
|
||||
def create_panel(*args):
|
||||
return ExamplePanel(*args)
|
||||
|
||||
class ExamplePanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
# Create gtk items here
|
||||
|
||||
self.content.add(Gtk.Box())
|
||||
@@ -4,38 +4,39 @@ import logging
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from KlippyGtk import KlippyGtk
|
||||
from KlippyGcodes import KlippyGcodes
|
||||
from panels.screen_panel import ScreenPanel
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.ExtrudePanel")
|
||||
|
||||
def create_panel(*args):
|
||||
return ExtrudePanel(*args)
|
||||
|
||||
class ExtrudePanel(ScreenPanel):
|
||||
distance = 1
|
||||
distances = ['1','5','10','25']
|
||||
speed = "Medium"
|
||||
speeds = ["Slow", "Medium", "Fast"]
|
||||
speed_trans = {
|
||||
"Slow": "300",
|
||||
"Medium": "800",
|
||||
"Fast": "1400"
|
||||
}
|
||||
|
||||
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
|
||||
self.speed = _("Medium")
|
||||
self.speeds = [_("Slow"), _("Medium"), _("Fast")]
|
||||
self.speed_trans = {
|
||||
_("Slow"): "300",
|
||||
_("Medium"): "800",
|
||||
_("Fast"): "1400"
|
||||
}
|
||||
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
|
||||
|
||||
|
||||
self.labels['tool0'] = KlippyGtk.ButtonImage("extruder-1","Tool 1","color1")
|
||||
self.labels['tool0'] = KlippyGtk.ButtonImage("extruder-1",_("Tool 1"),"color1")
|
||||
self.labels['tool0'].get_style_context().add_class("button_active")
|
||||
self.labels['extrude'] = KlippyGtk.ButtonImage("extrude","Extrude","color3")
|
||||
self.labels['extrude'] = KlippyGtk.ButtonImage("extrude",_("Extrude"),"color3")
|
||||
self.labels['extrude'].connect("clicked", self.extrude, "+")
|
||||
self.labels['retract'] = KlippyGtk.ButtonImage("extrude","Retract","color2")
|
||||
self.labels['retract'] = KlippyGtk.ButtonImage("retract",_("Retract"),"color2")
|
||||
self.labels['retract'].connect("clicked", self.extrude, "-")
|
||||
self.labels['temperature'] = KlippyGtk.ButtonImage("heat-up","Temperature","color4")
|
||||
self.labels['temperature'] = KlippyGtk.ButtonImage("heat-up",_("Temperature"),"color4")
|
||||
self.labels['temperature'].connect("clicked", self.menu_item_clicked, "temperature", {
|
||||
"name": "Temperature",
|
||||
"panel": "temperature"
|
||||
@@ -90,17 +91,10 @@ class ExtrudePanel(ScreenPanel):
|
||||
|
||||
grid.attach(box, 1, 2, 2, 1)
|
||||
|
||||
|
||||
b = KlippyGtk.ButtonImage("back", "Back")
|
||||
b.connect("clicked", self._screen._menu_go_back)
|
||||
grid.attach(b, 3, 2, 1, 1)
|
||||
|
||||
|
||||
|
||||
self.panel = grid
|
||||
self.content.add(grid)
|
||||
self._screen.add_subscription(panel_name)
|
||||
|
||||
def process_update(self, data):
|
||||
def process_update(self, action, data):
|
||||
for x in self._printer.get_tools():
|
||||
self.update_temp(x,
|
||||
self._printer.get_dev_stat(x,"temperature"),
|
||||
|
||||
@@ -4,17 +4,22 @@ import logging
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from KlippyGtk import KlippyGtk
|
||||
from KlippyGcodes import KlippyGcodes
|
||||
from panels.screen_panel import ScreenPanel
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.FanPanel")
|
||||
|
||||
def create_panel(*args):
|
||||
return FanPanel(*args)
|
||||
|
||||
class FanPanel(ScreenPanel):
|
||||
fan_speed = 0
|
||||
user_selecting = False
|
||||
|
||||
def initialize(self, panel_name):
|
||||
# Create gtk items here
|
||||
_ = self.lang.gettext
|
||||
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
||||
@@ -28,17 +33,17 @@ class FanPanel(ScreenPanel):
|
||||
self.labels["scale"].get_style_context().add_class("fan_slider")
|
||||
box.add(self.labels["scale"])
|
||||
|
||||
self.labels["fanoff"] = KlippyGtk.ButtonImage("fan-off", "Fan Off")
|
||||
self.labels["fanoff"] = KlippyGtk.ButtonImage("fan-off", _("Fan Off"))
|
||||
self.labels["fanoff"].get_style_context().add_class("color1")
|
||||
self.labels["fanoff"].connect("clicked", self.set_fan_on, False)
|
||||
self.labels["fanon"] = KlippyGtk.ButtonImage("fan", "Fan On")
|
||||
self.labels["fanon"] = KlippyGtk.ButtonImage("fan", _("Fan On"))
|
||||
self.labels["fanon"].get_style_context().add_class("color3")
|
||||
self.labels["fanon"].connect("clicked", self.set_fan_on, True)
|
||||
|
||||
self.labels["apply"] = KlippyGtk.ButtonImage("resume", "Set Speed")
|
||||
self.labels["apply"] = KlippyGtk.ButtonImage("resume", _("Set Speed"))
|
||||
self.labels["apply"].get_style_context().add_class("color2")
|
||||
self.labels["apply"].connect("clicked", self.set_fan_speed)
|
||||
self.labels["cancel"] = KlippyGtk.ButtonImage("stop", "Cancel Change")
|
||||
self.labels["cancel"] = KlippyGtk.ButtonImage("stop", _("Cancel Change"))
|
||||
self.labels["cancel"].get_style_context().add_class("color4")
|
||||
self.labels["cancel"].connect("clicked", self.cancel_select_fan_speed)
|
||||
self.labels["cancel"].hide()
|
||||
@@ -46,34 +51,35 @@ class FanPanel(ScreenPanel):
|
||||
grid.attach(Gtk.Label(), 0, 0, 1, 1)
|
||||
grid.attach(box, 0, 1, 4, 1)
|
||||
grid.attach(self.labels["fanoff"], 0, 2, 1, 1)
|
||||
grid.attach(self.labels["fanon"], 1, 2, 1, 1)
|
||||
grid.attach(self.labels["fanon"], 3, 2, 1, 1)
|
||||
|
||||
b = KlippyGtk.ButtonImage('back', 'Back')
|
||||
b.connect("clicked", self._screen._menu_go_back)
|
||||
grid.attach(b,3,2,1,1)
|
||||
|
||||
self.panel = grid
|
||||
self.grid = grid
|
||||
self.content.add(grid)
|
||||
self._screen.add_subscription(panel_name)
|
||||
|
||||
def process_update(self, data):
|
||||
if "fan" in data and "speed" in data["fan"] and self.user_selecting == False:
|
||||
def process_update(self, action, data):
|
||||
if (action == "notify_status_update" and "fan" in data and "speed" in data["fan"] and
|
||||
self.user_selecting == False):
|
||||
self.fan_speed = float(int(float(data["fan"]["speed"]) * 100))
|
||||
self.labels["scale"].disconnect_by_func(self.select_fan_speed)
|
||||
self.labels["scale"].set_value(float(int(float(data["fan"]["speed"]) * 100)))
|
||||
self.labels["scale"].set_value(self.fan_speed)
|
||||
self.labels["scale"].connect("value-changed", self.select_fan_speed)
|
||||
|
||||
|
||||
def select_fan_speed(self, widget):
|
||||
if self.user_selecting == True:
|
||||
return
|
||||
|
||||
self.user_selecting = True
|
||||
self.panel.attach(self.labels["apply"], 3, 0, 1, 1)
|
||||
self.panel.attach(self.labels["cancel"], 0, 0, 1, 1)
|
||||
self.grid.attach(self.labels["apply"], 3, 0, 1, 1)
|
||||
self.grid.attach(self.labels["cancel"], 0, 0, 1, 1)
|
||||
self._screen.show_all()
|
||||
|
||||
def cancel_select_fan_speed(self, widget):
|
||||
self.labels["scale"].set_value(self.fan_speed)
|
||||
self.user_selecting = False
|
||||
self.panel.remove(self.labels["apply"])
|
||||
self.panel.remove(self.labels["cancel"])
|
||||
self.grid.remove(self.labels["apply"])
|
||||
self.grid.remove(self.labels["cancel"])
|
||||
|
||||
|
||||
def set_fan_speed(self, widget):
|
||||
|
||||
@@ -4,13 +4,16 @@ import logging
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from KlippyGtk import KlippyGtk
|
||||
from KlippyGcodes import KlippyGcodes
|
||||
from panels.screen_panel import ScreenPanel
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.FineTunePanel")
|
||||
|
||||
class FineTune(ScreenPanel):
|
||||
def create_panel(*args):
|
||||
return FineTunePanel(*args)
|
||||
|
||||
class FineTunePanel(ScreenPanel):
|
||||
user_selecting = False
|
||||
|
||||
bs = 0
|
||||
@@ -18,52 +21,55 @@ class FineTune(ScreenPanel):
|
||||
bs_deltas = ["0.01","0.05"]
|
||||
percent_delta = 1
|
||||
percent_deltas = ['1','5','10','25']
|
||||
fan = 100
|
||||
|
||||
extrusion = 0
|
||||
speed = 0
|
||||
|
||||
def initialize(self, panel_name):
|
||||
# Create gtk items here
|
||||
_ = self.lang.gettext
|
||||
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
grid.set_row_homogeneous(False)
|
||||
logger.debug("FineTunePanel")
|
||||
|
||||
|
||||
self.labels['z+'] = KlippyGtk.ButtonImage("move-z-", "Z+", "color1")
|
||||
self.labels['z+'] = KlippyGtk.ButtonImage("move-z-", _("Z+"), "color1")
|
||||
self.labels['z+'].connect("clicked", self.change_babystepping, "+")
|
||||
self.labels['zoffset'] = Gtk.Label("Z Offset: 0.00mm")
|
||||
self.labels['zoffset'] = Gtk.Label("0.00" + _("mm"))
|
||||
self.labels['zoffset'].get_style_context().add_class('temperature_entry')
|
||||
self.labels['z-'] = KlippyGtk.ButtonImage("move-z+", "Z-", "color1")
|
||||
self.labels['z-'] = KlippyGtk.ButtonImage("move-z+", _("Z-"), "color1")
|
||||
self.labels['z-'].connect("clicked", self.change_babystepping, "-")
|
||||
|
||||
grid.attach(self.labels['z+'], 0, 0, 1, 1)
|
||||
grid.attach(self.labels['zoffset'], 0, 1, 1, 1)
|
||||
grid.attach(self.labels['z-'], 0, 2, 1, 1)
|
||||
|
||||
self.labels['fan+'] = KlippyGtk.ButtonImage("fan-on", "Increase Fan", "color2")
|
||||
self.labels['fan+'] = KlippyGtk.ButtonImage("fan-on", _("Fan +"), "color2")
|
||||
self.labels['fan+'].connect("clicked", self.change_fan, "+")
|
||||
self.labels['fanspeed'] = Gtk.Label("Fan: 100%")
|
||||
self.labels['fanspeed'] = Gtk.Label("100%")
|
||||
self.labels['fanspeed'].get_style_context().add_class('temperature_entry')
|
||||
self.labels['fan-'] = KlippyGtk.ButtonImage("fan-off", "Decrease Fan", "color2")
|
||||
self.labels['fan-'] = KlippyGtk.ButtonImage("fan-off", _("Fan -"), "color2")
|
||||
self.labels['fan-'].connect("clicked", self.change_fan, "-")
|
||||
grid.attach(self.labels['fan+'], 1, 0, 1, 1)
|
||||
grid.attach(self.labels['fanspeed'], 1, 1, 1, 1)
|
||||
grid.attach(self.labels['fan-'], 1, 2, 1, 1)
|
||||
|
||||
self.labels['speed+'] = KlippyGtk.ButtonImage("speed-step", "Increase Speed", "color3")
|
||||
self.labels['speed+'] = KlippyGtk.ButtonImage("speed-step", _("Speed +"), "color3")
|
||||
self.labels['speed+'].connect("clicked", self.change_speed, "+")
|
||||
self.labels['speedfactor'] = Gtk.Label("Speed: 100%")
|
||||
self.labels['speedfactor'] = Gtk.Label("100%")
|
||||
self.labels['speedfactor'].get_style_context().add_class('temperature_entry')
|
||||
self.labels['speed-'] = KlippyGtk.ButtonImage("speed-step", "Decrease Speed", "color3")
|
||||
self.labels['speed-'] = KlippyGtk.ButtonImage("speed-step", _("Speed -"), "color3")
|
||||
self.labels['speed-'].connect("clicked", self.change_speed, "-")
|
||||
grid.attach(self.labels['speed+'], 2, 0, 1, 1)
|
||||
grid.attach(self.labels['speedfactor'], 2, 1, 1, 1)
|
||||
grid.attach(self.labels['speed-'], 2, 2, 1, 1)
|
||||
|
||||
self.labels['extrude+'] = KlippyGtk.ButtonImage("extrude", "Increase Extrusion", "color4")
|
||||
self.labels['extrude+'] = KlippyGtk.ButtonImage("extrude", _("Extrusion +"), "color4")
|
||||
self.labels['extrude+'].connect("clicked", self.change_extrusion, "+")
|
||||
self.labels['extrudefactor'] = Gtk.Label("Extrusion: 100%")
|
||||
self.labels['extrudefactor'] = Gtk.Label("100%")
|
||||
self.labels['extrudefactor'].get_style_context().add_class('temperature_entry')
|
||||
self.labels['extrude-'] = KlippyGtk.ButtonImage("retract", "Decrease Extrusion", "color4")
|
||||
self.labels['extrude-'] = KlippyGtk.ButtonImage("retract", _("Extrusion -"), "color4")
|
||||
self.labels['extrude-'].connect("clicked", self.change_extrusion, "-")
|
||||
grid.attach(self.labels['extrude+'], 3, 0, 1, 1)
|
||||
grid.attach(self.labels['extrudefactor'], 3, 1, 1, 1)
|
||||
@@ -109,32 +115,31 @@ class FineTune(ScreenPanel):
|
||||
|
||||
self.labels["1"].set_active(True)
|
||||
|
||||
grid.attach(deltgrid, 1, 3, 2, 1)
|
||||
grid.attach(deltgrid, 1, 3, 3, 1)
|
||||
|
||||
|
||||
|
||||
|
||||
b = KlippyGtk.ButtonImage('back', 'Back')
|
||||
b.connect("clicked", self._screen._menu_go_back)
|
||||
grid.attach(b,3,3,1,1)
|
||||
|
||||
self.panel = grid
|
||||
#self.panel = grid
|
||||
self.content.add(grid)
|
||||
self._screen.add_subscription(panel_name)
|
||||
|
||||
def process_update(self, data):
|
||||
def process_update(self, action, data):
|
||||
_ = self.lang.gettext
|
||||
|
||||
if action != "notify_status_update":
|
||||
return
|
||||
|
||||
if "gcode_move" in data:
|
||||
if "homing_origin" in data["gcode_move"]:
|
||||
self.labels['zoffset'].set_text("Z Offset: %.2fmm" % data["gcode_move"]["homing_origin"][2])
|
||||
self.labels['zoffset'].set_text("%.2fmm" % data["gcode_move"]["homing_origin"][2])
|
||||
if "extrude_factor" in data["gcode_move"]:
|
||||
self.extrusion = int(data["gcode_move"]["extrude_factor"]*100)
|
||||
self.labels['extrudefactor'].set_text("Extrusion: %3d%%" % self.extrusion)
|
||||
self.labels['extrudefactor'].set_text("%3d%%" % self.extrusion)
|
||||
if "speed_factor" in data["gcode_move"]:
|
||||
self.speed = int(data["gcode_move"]["speed_factor"]*100)
|
||||
self.labels['speedfactor'].set_text("Speed: %3d%%" % self.speed)
|
||||
self.labels['speedfactor'].set_text("%3d%%" % self.speed)
|
||||
|
||||
if "fan" in data and "speed" in data['fan']:
|
||||
self.fan = int(round(data['fan']['speed'],2)*100)
|
||||
self.labels['fanspeed'].set_text("Fan: %3d%%" % self.fan)
|
||||
self.labels['fanspeed'].set_text("%3d%%" % self.fan)
|
||||
|
||||
def change_babystepping(self, widget, dir):
|
||||
if dir == "+":
|
||||
|
||||
@@ -1,201 +1,210 @@
|
||||
import gi
|
||||
import logging
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from KlippyGtk import KlippyGtk
|
||||
from panels.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.JobStatusPanel")
|
||||
|
||||
class JobStatusPanel(ScreenPanel):
|
||||
is_paused = False
|
||||
filename = None
|
||||
|
||||
def initialize(self, panel_name):
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
self.labels['progress'] = KlippyGtk.ProgressBar("printing-progress-bar")
|
||||
#self.labels['progress'].set_vexpand(True)
|
||||
#self.labels['progress'].set_valign(Gtk.Align.CENTER)
|
||||
self.labels['progress'].set_show_text(False)
|
||||
#self.labels['progress'].set_margin_top(10)
|
||||
self.labels['progress'].set_margin_end(20)
|
||||
self.labels['progress_text'] = Gtk.Label()
|
||||
self.labels['progress_text'].get_style_context().add_class("printing-progress-text")
|
||||
overlay = Gtk.Overlay()
|
||||
overlay.add(self.labels['progress'])
|
||||
overlay.add_overlay(self.labels['progress_text'])
|
||||
|
||||
self.labels['file'] = KlippyGtk.ImageLabel("file","",20,"printing-status-label")
|
||||
self.labels['time_label'] = KlippyGtk.ImageLabel("speed-step","Time Elapsed",20,"printing-status-label")
|
||||
self.labels['time'] = KlippyGtk.Label("Time Elapsed","printing-status-label")
|
||||
self.labels['time_left_label'] = KlippyGtk.ImageLabel("speed-step","Time Left",20,"printing-status-label")
|
||||
self.labels['time_left'] = KlippyGtk.Label("Time Left","printing-status-label")
|
||||
timegrid = Gtk.Grid()
|
||||
timegrid.attach(self.labels['time_label']['b'], 0, 0, 1, 1)
|
||||
timegrid.attach(self.labels['time'], 0, 1, 1, 1)
|
||||
timegrid.attach(self.labels['time_left_label']['b'], 1, 0, 1, 1)
|
||||
timegrid.attach(self.labels['time_left'], 1, 1, 1, 1)
|
||||
info = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
info.props.valign = Gtk.Align.CENTER
|
||||
info.set_hexpand(True)
|
||||
info.set_vexpand(True)
|
||||
#info.add(self.labels['file']['b'])
|
||||
#info.add(self.labels['time']['b'])
|
||||
#info.add(self.labels['time_left']['b'])
|
||||
|
||||
#grid.attach(info,2,0,2,1)
|
||||
|
||||
pbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
pbox.pack_start(self.labels['file']['b'], False, True, 0)
|
||||
pbox.pack_end(timegrid, False, False, 0)
|
||||
#pbox.pack_end(self.labels['progress'], False, False, 0)
|
||||
pbox.pack_end(overlay, False, False, 0)
|
||||
|
||||
grid.attach(pbox, 1, 0, 3, 2)
|
||||
|
||||
self.labels['extruder'] = KlippyGtk.ButtonImage("extruder-1", KlippyGtk.formatTemperatureString(0, 0))
|
||||
self.labels['extruder'].set_sensitive(False)
|
||||
grid.attach(self.labels['extruder'], 0, 0, 1, 1)
|
||||
|
||||
self.labels['heater_bed'] = KlippyGtk.ButtonImage("bed", KlippyGtk.formatTemperatureString(0, 0))
|
||||
self.labels['heater_bed'].set_sensitive(False)
|
||||
grid.attach(self.labels['heater_bed'], 0, 1, 1, 1)
|
||||
|
||||
self.labels['resume'] = KlippyGtk.ButtonImage("resume","Resume","color1")
|
||||
self.labels['resume'].connect("clicked",self.resume)
|
||||
self.labels['pause'] = KlippyGtk.ButtonImage("pause","Pause","color1" )
|
||||
self.labels['pause'].connect("clicked",self.pause)
|
||||
|
||||
if self._printer.get_stat('pause_resume','is_paused') == True:
|
||||
self.is_paused = True
|
||||
grid.attach(self.labels['resume'], 0, 2, 1, 1)
|
||||
else:
|
||||
grid.attach(self.labels['pause'], 0, 2, 1, 1)
|
||||
|
||||
self.labels['cancel'] = KlippyGtk.ButtonImage("stop","Cancel","color2")
|
||||
self.labels['cancel'].connect("clicked", self.cancel)
|
||||
grid.attach(self.labels['cancel'], 1, 2, 1, 1)
|
||||
self.labels['estop'] = KlippyGtk.ButtonImage("decrease","Emergency Stop","color4")
|
||||
self.labels['estop'].connect("clicked", self.emergency_stop)
|
||||
grid.attach(self.labels['estop'], 2, 2, 1, 1)
|
||||
self.labels['control'] = KlippyGtk.ButtonImage("control","Control","color3")
|
||||
self.labels['control'].connect("clicked", self._screen._go_to_submenu, "Control")
|
||||
grid.attach(self.labels['control'], 3, 2, 1, 1)
|
||||
|
||||
self.panel = grid
|
||||
|
||||
self._screen.add_subscription(panel_name)
|
||||
|
||||
def resume(self, widget):
|
||||
self.disable_button("pause","cancel")
|
||||
self._screen._ws.klippy.print_resume(self._response_callback, "enable_button", "pause", "cancel")
|
||||
self._screen.show_all()
|
||||
|
||||
def pause(self, widget):
|
||||
self.disable_button("resume","cancel")
|
||||
self._screen._ws.klippy.print_pause(self._response_callback, "enable_button", "resume", "cancel")
|
||||
self._screen.show_all()
|
||||
|
||||
def cancel(self, widget):
|
||||
dialog = KlippyGtk.ConfirmDialog(
|
||||
self._screen,
|
||||
"Are you sure you wish to cancel this print?",
|
||||
[
|
||||
{
|
||||
"name": "Cancel Print",
|
||||
"response": Gtk.ResponseType.OK
|
||||
},
|
||||
{
|
||||
"name": "Go Back",
|
||||
"response": Gtk.ResponseType.CANCEL
|
||||
}
|
||||
],
|
||||
self.cancel_confirm
|
||||
)
|
||||
self.disable_button("pause","cancel")
|
||||
|
||||
def cancel_confirm(self, widget, response_id):
|
||||
widget.destroy()
|
||||
|
||||
if response_id == Gtk.ResponseType.CANCEL:
|
||||
self.enable_button("pause","cancel")
|
||||
return
|
||||
|
||||
self._screen._ws.klippy.print_cancel(self._response_callback, "enable_button", "pause", "cancel")
|
||||
|
||||
def _response_callback(self, response, method, params, func, *args):
|
||||
if func == "enable_button":
|
||||
self.enable_button(*args)
|
||||
|
||||
def enable_button(self, *args):
|
||||
for arg in args:
|
||||
self.labels[arg].set_sensitive(True)
|
||||
|
||||
def disable_button(self, *args):
|
||||
for arg in args:
|
||||
self.labels[arg].set_sensitive(False)
|
||||
|
||||
|
||||
def process_update(self, data):
|
||||
self.update_temp("heater_bed",
|
||||
self._printer.get_dev_stat("heater_bed","temperature"),
|
||||
self._printer.get_dev_stat("heater_bed","target")
|
||||
)
|
||||
for x in self._printer.get_tools():
|
||||
self.update_temp(x,
|
||||
self._printer.get_dev_stat(x,"temperature"),
|
||||
self._printer.get_dev_stat(x,"target")
|
||||
)
|
||||
|
||||
vsd = self._printer.get_stat("print_stats")
|
||||
if "filename" in vsd and self.filename != vsd['filename']:
|
||||
if vsd['filename'] != "":
|
||||
self.filename = KlippyGtk.formatFileName(vsd['filename'])
|
||||
self.update_image_text("file", self.filename)
|
||||
else:
|
||||
file = "Unknown"
|
||||
self.update_image_text("file", "Unknown")
|
||||
|
||||
|
||||
progress = 0 if self._printer.get_stat('virtual_sdcard','progress') == 0 else (vsd['print_duration'] /
|
||||
self._printer.get_stat('virtual_sdcard','progress') - vsd['print_duration'])
|
||||
|
||||
self.update_text("time", str(KlippyGtk.formatTimeString(vsd['print_duration'])))
|
||||
self.update_text("time_left", str(KlippyGtk.formatTimeString(
|
||||
progress
|
||||
)))
|
||||
|
||||
self.update_progress(self._printer.get_stat('virtual_sdcard','progress'))
|
||||
|
||||
if "pause_resume" in data:
|
||||
if self.is_paused == True and data['pause_resume']['is_paused'] == False:
|
||||
self.is_paused = False
|
||||
self.panel.attach(self.labels['pause'], 0, 2, 1, 1)
|
||||
self.panel.remove(self.labels['resume'])
|
||||
self.panel.show_all()
|
||||
if self.is_paused == False and data['pause_resume']['is_paused'] == True:
|
||||
self.is_paused = True
|
||||
self.panel.attach(self.labels['resume'], 0, 2, 1, 1)
|
||||
self.panel.remove(self.labels['pause'])
|
||||
self.panel.show_all()
|
||||
|
||||
|
||||
|
||||
def update_image_text(self, label, text):
|
||||
if label in self.labels and 'l' in self.labels[label]:
|
||||
self.labels[label]['l'].set_text(text)
|
||||
|
||||
def update_text(self, label, text):
|
||||
if label in self.labels:
|
||||
self.labels[label].set_text(text)
|
||||
|
||||
def update_progress (self, progress):
|
||||
self.labels['progress'].set_fraction(progress)
|
||||
self.labels['progress_text'].set_text("%s%%" % (str(int(progress*100))))
|
||||
|
||||
def update_temp(self, dev, temp, target):
|
||||
if dev in self.labels:
|
||||
self.labels[dev].set_label(KlippyGtk.formatTemperatureString(temp, target))
|
||||
import gi
|
||||
import logging
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.JobStatusPanel")
|
||||
|
||||
def create_panel(*args):
|
||||
return JobStatusPanel(*args)
|
||||
|
||||
class JobStatusPanel(ScreenPanel):
|
||||
is_paused = False
|
||||
filename = None
|
||||
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
self.labels['progress'] = KlippyGtk.ProgressBar("printing-progress-bar")
|
||||
#self.labels['progress'].set_vexpand(True)
|
||||
#self.labels['progress'].set_valign(Gtk.Align.CENTER)
|
||||
self.labels['progress'].set_show_text(False)
|
||||
#self.labels['progress'].set_margin_top(10)
|
||||
self.labels['progress'].set_margin_end(20)
|
||||
self.labels['progress_text'] = Gtk.Label()
|
||||
self.labels['progress_text'].get_style_context().add_class("printing-progress-text")
|
||||
overlay = Gtk.Overlay()
|
||||
overlay.add(self.labels['progress'])
|
||||
overlay.add_overlay(self.labels['progress_text'])
|
||||
|
||||
self.labels['file'] = KlippyGtk.ImageLabel("file","",20,"printing-status-label")
|
||||
self.labels['time_label'] = KlippyGtk.ImageLabel("speed-step",_("Time Elapsed"),20,"printing-status-label")
|
||||
self.labels['time'] = KlippyGtk.Label(_("Time Elapsed"),"printing-status-label")
|
||||
self.labels['time_left_label'] = KlippyGtk.ImageLabel("speed-step",_("Time Left"),20,"printing-status-label")
|
||||
self.labels['time_left'] = KlippyGtk.Label(_("Time Left"),"printing-status-label")
|
||||
timegrid = Gtk.Grid()
|
||||
timegrid.attach(self.labels['time_label']['b'], 0, 0, 1, 1)
|
||||
timegrid.attach(self.labels['time'], 0, 1, 1, 1)
|
||||
timegrid.attach(self.labels['time_left_label']['b'], 1, 0, 1, 1)
|
||||
timegrid.attach(self.labels['time_left'], 1, 1, 1, 1)
|
||||
info = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
info.props.valign = Gtk.Align.CENTER
|
||||
info.set_hexpand(True)
|
||||
info.set_vexpand(True)
|
||||
#info.add(self.labels['file']['b'])
|
||||
#info.add(self.labels['time']['b'])
|
||||
#info.add(self.labels['time_left']['b'])
|
||||
|
||||
#grid.attach(info,2,0,2,1)
|
||||
|
||||
pbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
pbox.pack_start(self.labels['file']['b'], False, True, 0)
|
||||
pbox.pack_end(timegrid, False, False, 0)
|
||||
#pbox.pack_end(self.labels['progress'], False, False, 0)
|
||||
pbox.pack_end(overlay, False, False, 0)
|
||||
|
||||
grid.attach(pbox, 1, 0, 3, 2)
|
||||
|
||||
self.labels['extruder'] = KlippyGtk.ButtonImage("extruder-1", KlippyGtk.formatTemperatureString(0, 0))
|
||||
self.labels['extruder'].set_sensitive(False)
|
||||
grid.attach(self.labels['extruder'], 0, 0, 1, 1)
|
||||
|
||||
self.labels['heater_bed'] = KlippyGtk.ButtonImage("bed", KlippyGtk.formatTemperatureString(0, 0))
|
||||
self.labels['heater_bed'].set_sensitive(False)
|
||||
grid.attach(self.labels['heater_bed'], 0, 1, 1, 1)
|
||||
|
||||
self.labels['resume'] = KlippyGtk.ButtonImage("resume",_("Resume"),"color1")
|
||||
self.labels['resume'].connect("clicked",self.resume)
|
||||
self.labels['pause'] = KlippyGtk.ButtonImage("pause",_("Pause"),"color1" )
|
||||
self.labels['pause'].connect("clicked",self.pause)
|
||||
|
||||
if self._printer.get_stat('pause_resume','is_paused') == True:
|
||||
self.is_paused = True
|
||||
grid.attach(self.labels['resume'], 0, 2, 1, 1)
|
||||
else:
|
||||
grid.attach(self.labels['pause'], 0, 2, 1, 1)
|
||||
|
||||
self.labels['cancel'] = KlippyGtk.ButtonImage("stop",_("Cancel"),"color2")
|
||||
self.labels['cancel'].connect("clicked", self.cancel)
|
||||
grid.attach(self.labels['cancel'], 1, 2, 1, 1)
|
||||
self.labels['estop'] = KlippyGtk.ButtonImage("emergency",_("Emergency Stop"),"color4")
|
||||
self.labels['estop'].connect("clicked", self.emergency_stop)
|
||||
grid.attach(self.labels['estop'], 2, 2, 1, 1)
|
||||
self.labels['control'] = KlippyGtk.ButtonImage("control",_("Control"),"color3")
|
||||
self.labels['control'].connect("clicked", self._screen._go_to_submenu, "")
|
||||
grid.attach(self.labels['control'], 3, 2, 1, 1)
|
||||
|
||||
self.layout = grid
|
||||
|
||||
self._screen.add_subscription(panel_name)
|
||||
|
||||
def resume(self, widget):
|
||||
self.disable_button("pause","cancel")
|
||||
self._screen._ws.klippy.print_resume(self._response_callback, "enable_button", "pause", "cancel")
|
||||
self._screen.show_all()
|
||||
|
||||
def pause(self, widget):
|
||||
self.disable_button("resume","cancel")
|
||||
self._screen._ws.klippy.print_pause(self._response_callback, "enable_button", "resume", "cancel")
|
||||
self._screen.show_all()
|
||||
|
||||
def cancel(self, widget):
|
||||
_ = self.lang.gettext
|
||||
|
||||
dialog = KlippyGtk.ConfirmDialog(
|
||||
self._screen,
|
||||
_("Are you sure you wish to cancel this print?"),
|
||||
[
|
||||
{
|
||||
"name": _("Cancel Print"),
|
||||
"response": Gtk.ResponseType.OK
|
||||
},
|
||||
{
|
||||
"name": _("Go Back"),
|
||||
"response": Gtk.ResponseType.CANCEL
|
||||
}
|
||||
],
|
||||
self.cancel_confirm
|
||||
)
|
||||
self.disable_button("pause","cancel")
|
||||
|
||||
def cancel_confirm(self, widget, response_id):
|
||||
widget.destroy()
|
||||
|
||||
if response_id == Gtk.ResponseType.CANCEL:
|
||||
self.enable_button("pause","cancel")
|
||||
return
|
||||
|
||||
self._screen._ws.klippy.print_cancel(self._response_callback, "enable_button", "pause", "cancel")
|
||||
|
||||
def _response_callback(self, response, method, params, func, *args):
|
||||
if func == "enable_button":
|
||||
self.enable_button(*args)
|
||||
|
||||
def enable_button(self, *args):
|
||||
for arg in args:
|
||||
self.labels[arg].set_sensitive(True)
|
||||
|
||||
def disable_button(self, *args):
|
||||
for arg in args:
|
||||
self.labels[arg].set_sensitive(False)
|
||||
|
||||
|
||||
def process_update(self, action, data):
|
||||
if action != "notify_status_update":
|
||||
return
|
||||
|
||||
self.update_temp("heater_bed",
|
||||
self._printer.get_dev_stat("heater_bed","temperature"),
|
||||
self._printer.get_dev_stat("heater_bed","target")
|
||||
)
|
||||
for x in self._printer.get_tools():
|
||||
self.update_temp(x,
|
||||
self._printer.get_dev_stat(x,"temperature"),
|
||||
self._printer.get_dev_stat(x,"target")
|
||||
)
|
||||
|
||||
vsd = self._printer.get_stat("print_stats")
|
||||
if "filename" in vsd and self.filename != vsd['filename']:
|
||||
if vsd['filename'] != "":
|
||||
self.filename = KlippyGtk.formatFileName(vsd['filename'])
|
||||
self.update_image_text("file", self.filename)
|
||||
else:
|
||||
file = "Unknown"
|
||||
self.update_image_text("file", "Unknown")
|
||||
|
||||
|
||||
progress = 0 if self._printer.get_stat('virtual_sdcard','progress') == 0 else (vsd['print_duration'] /
|
||||
self._printer.get_stat('virtual_sdcard','progress') - vsd['print_duration'])
|
||||
|
||||
self.update_text("time", str(KlippyGtk.formatTimeString(vsd['print_duration'])))
|
||||
self.update_text("time_left", str(KlippyGtk.formatTimeString(
|
||||
progress
|
||||
)))
|
||||
|
||||
self.update_progress(self._printer.get_stat('virtual_sdcard','progress'))
|
||||
|
||||
if "pause_resume" in data:
|
||||
if self.is_paused == True and data['pause_resume']['is_paused'] == False:
|
||||
self.is_paused = False
|
||||
self.panel.attach(self.labels['pause'], 0, 2, 1, 1)
|
||||
self.panel.remove(self.labels['resume'])
|
||||
self.panel.show_all()
|
||||
if self.is_paused == False and data['pause_resume']['is_paused'] == True:
|
||||
self.is_paused = True
|
||||
self.panel.attach(self.labels['resume'], 0, 2, 1, 1)
|
||||
self.panel.remove(self.labels['pause'])
|
||||
self.panel.show_all()
|
||||
|
||||
|
||||
|
||||
def update_image_text(self, label, text):
|
||||
if label in self.labels and 'l' in self.labels[label]:
|
||||
self.labels[label]['l'].set_text(text)
|
||||
|
||||
def update_text(self, label, text):
|
||||
if label in self.labels:
|
||||
self.labels[label].set_text(text)
|
||||
|
||||
def update_progress (self, progress):
|
||||
self.labels['progress'].set_fraction(progress)
|
||||
self.labels['progress_text'].set_text("%s%%" % (str(int(progress*100))))
|
||||
|
||||
def update_temp(self, dev, temp, target):
|
||||
if dev in self.labels:
|
||||
self.labels[dev].set_label(KlippyGtk.formatTemperatureString(temp, target))
|
||||
@@ -1,63 +1,69 @@
|
||||
import gi
|
||||
import logging
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from KlippyGtk import KlippyGtk
|
||||
from panels.menu import MenuPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.MainMenu")
|
||||
|
||||
class MainPanel(MenuPanel):
|
||||
|
||||
def initialize(self, panel_name, items, extrudercount):
|
||||
print("### Making MainMenu")
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
# Create Extruders and bed icons
|
||||
eq_grid = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
|
||||
i = 0
|
||||
for x in self._printer.get_tools():
|
||||
if i > 3:
|
||||
break
|
||||
self.labels[x] = KlippyGtk.ButtonImage("extruder-"+str(i+1), KlippyGtk.formatTemperatureString(0, 0))
|
||||
eq_grid.attach(self.labels[x], i%2, i/2, 1, 1)
|
||||
i += 1
|
||||
|
||||
self.labels['heater_bed'] = KlippyGtk.ButtonImage("bed", KlippyGtk.formatTemperatureString(0, 0))
|
||||
|
||||
width = 2 if i > 1 else 1
|
||||
eq_grid.attach(self.labels['heater_bed'], 0, i/2+1, width, 1)
|
||||
|
||||
grid.attach(eq_grid, 0, 0, 1, 1)
|
||||
grid.attach(self.arrangeMenuItems(items, 2, True), 1, 0, 1, 1)
|
||||
self.grid = grid
|
||||
|
||||
self.target_temps = {
|
||||
"heater_bed": 0,
|
||||
"extruder": 0
|
||||
}
|
||||
|
||||
self._screen.add_subscription(panel_name)
|
||||
|
||||
def get(self):
|
||||
return self.grid
|
||||
|
||||
def update_temp(self, dev, temp, target):
|
||||
if dev in self.labels:
|
||||
self.labels[dev].set_label(KlippyGtk.formatTemperatureString(temp, target))
|
||||
|
||||
def process_update(self, data):
|
||||
self.update_temp("heater_bed",
|
||||
self._printer.get_dev_stat("heater_bed","temperature"),
|
||||
self._printer.get_dev_stat("heater_bed","target")
|
||||
)
|
||||
for x in self._printer.get_tools():
|
||||
self.update_temp(x,
|
||||
self._printer.get_dev_stat(x,"temperature"),
|
||||
self._printer.get_dev_stat(x,"target")
|
||||
)
|
||||
return
|
||||
import gi
|
||||
import logging
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from panels.menu import MenuPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.MainMenu")
|
||||
|
||||
def create_panel(*args):
|
||||
return MainPanel(*args)
|
||||
|
||||
class MainPanel(MenuPanel):
|
||||
|
||||
def initialize(self, panel_name, items, extrudercount):
|
||||
print("### Making MainMenu")
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
# Create Extruders and bed icons
|
||||
eq_grid = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
|
||||
i = 0
|
||||
for x in self._printer.get_tools():
|
||||
if i > 3:
|
||||
break
|
||||
self.labels[x] = KlippyGtk.ButtonImage("extruder-"+str(i+1), KlippyGtk.formatTemperatureString(0, 0))
|
||||
eq_grid.attach(self.labels[x], i%2, i/2, 1, 1)
|
||||
i += 1
|
||||
|
||||
self.labels['heater_bed'] = KlippyGtk.ButtonImage("bed", KlippyGtk.formatTemperatureString(0, 0))
|
||||
|
||||
width = 2 if i > 1 else 1
|
||||
eq_grid.attach(self.labels['heater_bed'], 0, i/2+1, width, 1)
|
||||
|
||||
grid.attach(eq_grid, 0, 0, 1, 1)
|
||||
grid.attach(self.arrangeMenuItems(items, 2, True), 1, 0, 1, 1)
|
||||
self.grid = grid
|
||||
|
||||
self.target_temps = {
|
||||
"heater_bed": 0,
|
||||
"extruder": 0
|
||||
}
|
||||
|
||||
self._screen.add_subscription(panel_name)
|
||||
|
||||
def get(self):
|
||||
return self.grid
|
||||
|
||||
def update_temp(self, dev, temp, target):
|
||||
if dev in self.labels:
|
||||
self.labels[dev].set_label(KlippyGtk.formatTemperatureString(temp, target))
|
||||
|
||||
def process_update(self, action, data):
|
||||
if action != "notify_status_update":
|
||||
return
|
||||
|
||||
self.update_temp("heater_bed",
|
||||
self._printer.get_dev_stat("heater_bed","temperature"),
|
||||
self._printer.get_dev_stat("heater_bed","target")
|
||||
)
|
||||
for x in self._printer.get_tools():
|
||||
self.update_temp(x,
|
||||
self._printer.get_dev_stat(x,"temperature"),
|
||||
self._printer.get_dev_stat(x,"target")
|
||||
)
|
||||
return
|
||||
@@ -1,53 +1,99 @@
|
||||
import gi
|
||||
import logging
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from KlippyGtk import KlippyGtk
|
||||
from panels.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.MenuPanel")
|
||||
|
||||
class MenuPanel(ScreenPanel):
|
||||
def initialize(self, panel_name, items):
|
||||
print("### Making a new menu")
|
||||
|
||||
grid = self.arrangeMenuItems(items, 4)
|
||||
|
||||
b = KlippyGtk.ButtonImage('back', 'Back')
|
||||
b.connect("clicked", self._screen._menu_go_back)
|
||||
grid.attach(b, 3, 1, 1, 1)
|
||||
|
||||
self.panel = grid
|
||||
|
||||
def arrangeMenuItems (self, items, columns, expandLast=False):
|
||||
grid = Gtk.Grid()
|
||||
grid.set_row_homogeneous(True)
|
||||
grid.set_column_homogeneous(True)
|
||||
|
||||
l = len(items)
|
||||
i = 0
|
||||
for i in range(l):
|
||||
col = i % columns
|
||||
row = int(i/columns)
|
||||
width = 1
|
||||
if expandLast == True and i+1 == l and l%2 == 1:
|
||||
width = 2
|
||||
b = KlippyGtk.ButtonImage(
|
||||
items[i]['icon'], items[i]['name'], "color"+str((i%4)+1)
|
||||
)
|
||||
|
||||
if "panel" in items[i]:
|
||||
b.connect("clicked", self.menu_item_clicked, items[i]['panel'], items[i])
|
||||
elif "items" in items[i]:
|
||||
b.connect("clicked", self._screen._go_to_submenu, items[i]['name'])
|
||||
elif "method" in items[i]:
|
||||
params = items[i]['params'] if "params" in items[i] else {}
|
||||
b.connect("clicked", self._screen._send_action, items[i]['method'], params)
|
||||
|
||||
grid.attach(b, col, row, width, 1)
|
||||
|
||||
i += 1
|
||||
|
||||
return grid
|
||||
import gi
|
||||
import logging
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
from jinja2 import Template
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.MenuPanel")
|
||||
|
||||
def create_panel(*args):
|
||||
return MenuPanel(*args)
|
||||
|
||||
class MenuPanel(ScreenPanel):
|
||||
def initialize(self, panel_name, display_name, items):
|
||||
_ = self.lang.gettext
|
||||
|
||||
self.activate()
|
||||
|
||||
grid = self.arrangeMenuItems(items, 4)
|
||||
grid.set_size_request(self._screen.width, self._screen.height-45)
|
||||
|
||||
self.content.add(grid)
|
||||
self.panel = self.layout
|
||||
|
||||
def activate(self):
|
||||
self.j2_data = {
|
||||
"printer": {
|
||||
"power_devices": {
|
||||
"count": len(self._screen.printer.get_power_devices())
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.debug("j2_data: %s" % self.j2_data)
|
||||
|
||||
def arrangeMenuItems (self, items, columns, expandLast=False):
|
||||
grid = Gtk.Grid()
|
||||
grid.set_row_homogeneous(True)
|
||||
grid.set_column_homogeneous(True)
|
||||
logger.debug(items)
|
||||
for item in items:
|
||||
key = list(item)[0]
|
||||
logger.debug(item)
|
||||
if not self.evaluate_enable(item[key]['enable']):
|
||||
items.remove(item)
|
||||
|
||||
l = len(items)
|
||||
i = 0
|
||||
for i in range(l):
|
||||
col = i % columns
|
||||
row = int(i/columns)
|
||||
width = 1
|
||||
|
||||
if expandLast == True and i+1 == l and l%2 == 1:
|
||||
width = 2
|
||||
|
||||
key = list(items[i])[0]
|
||||
item = items[i][key]
|
||||
b = KlippyGtk.ButtonImage(
|
||||
item['icon'], item['name'], "color"+str((i%4)+1)
|
||||
)
|
||||
if item['panel'] != False:
|
||||
b.connect("clicked", self.menu_item_clicked, item['panel'], item)
|
||||
elif item['method'] != False:
|
||||
params = item['params'] if item['params'] != False else {}
|
||||
if item['confirm'] != False:
|
||||
b.connect("clicked", self._screen._confirm_send_action, item['confirm'], item['method'], params)
|
||||
else:
|
||||
b.connect("clicked", self._screen._send_action, item['method'], params)
|
||||
else:
|
||||
b.connect("clicked", self._screen._go_to_submenu, key)
|
||||
|
||||
grid.attach(b, col, row, width, 1)
|
||||
|
||||
i += 1
|
||||
|
||||
return grid
|
||||
|
||||
def evaluate_enable(self, enable):
|
||||
if enable == True:
|
||||
return True
|
||||
if enable == False:
|
||||
return False
|
||||
|
||||
try:
|
||||
logger.debug("Template: '%s'" % enable)
|
||||
logger.debug("Date: %s" % self.j2_data)
|
||||
j2_temp = Template(enable)
|
||||
result = j2_temp.render(self.j2_data)
|
||||
logger.debug("Result: %s" % result)
|
||||
if result == 'True':
|
||||
return True
|
||||
return False
|
||||
except:
|
||||
logger.debug("Error evaluating enable statement: %s", enable)
|
||||
return False
|
||||
@@ -1,131 +1,132 @@
|
||||
import gi
|
||||
import logging
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from KlippyGtk import KlippyGtk
|
||||
from KlippyGcodes import KlippyGcodes
|
||||
from panels.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.MovePanel")
|
||||
|
||||
class MovePanel(ScreenPanel):
|
||||
distance = 1
|
||||
distances = ['.1','.5','1','5','10','25']
|
||||
|
||||
|
||||
def initialize(self, panel_name):
|
||||
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
self.labels['x+'] = KlippyGtk.ButtonImage("move-x+", "X+", "color1")
|
||||
self.labels['x+'].connect("clicked", self.move, "X", "+")
|
||||
self.labels['x-'] = KlippyGtk.ButtonImage("move-x-", "X-", "color1")
|
||||
self.labels['x-'].connect("clicked", self.move, "X", "-")
|
||||
|
||||
self.labels['y+'] = KlippyGtk.ButtonImage("move-y+", "Y+", "color2")
|
||||
self.labels['y+'].connect("clicked", self.move, "Y", "+")
|
||||
self.labels['y-'] = KlippyGtk.ButtonImage("move-y-", "Y-", "color2")
|
||||
self.labels['y-'].connect("clicked", self.move, "Y", "-")
|
||||
|
||||
self.labels['z+'] = KlippyGtk.ButtonImage("move-z-", "Z+", "color3")
|
||||
self.labels['z+'].connect("clicked", self.move, "Z", "+")
|
||||
self.labels['z-'] = KlippyGtk.ButtonImage("move-z+", "Z-", "color3")
|
||||
self.labels['z-'].connect("clicked", self.move, "Z", "-")
|
||||
|
||||
self.labels['home'] = KlippyGtk.ButtonImage("home", "Home All")
|
||||
self.labels['home'].connect("clicked", self.home)
|
||||
|
||||
|
||||
grid.attach(self.labels['x+'], 2, 1, 1, 1)
|
||||
grid.attach(self.labels['x-'], 0, 1, 1, 1)
|
||||
grid.attach(self.labels['y+'], 1, 0, 1, 1)
|
||||
grid.attach(self.labels['y-'], 1, 1, 1, 1)
|
||||
grid.attach(self.labels['z+'], 3, 0, 1, 1)
|
||||
grid.attach(self.labels['z-'], 3, 1, 1, 1)
|
||||
|
||||
grid.attach(self.labels['home'], 0, 0, 1, 1)
|
||||
|
||||
distgrid = Gtk.Grid()
|
||||
j = 0;
|
||||
for i in self.distances:
|
||||
self.labels[i] = KlippyGtk.ToggleButton(i)
|
||||
self.labels[i].connect("clicked", self.change_distance, i)
|
||||
ctx = self.labels[i].get_style_context()
|
||||
if j == 0:
|
||||
ctx.add_class("distbutton_top")
|
||||
elif j == len(self.distances)-1:
|
||||
ctx.add_class("distbutton_bottom")
|
||||
else:
|
||||
ctx.add_class("distbutton")
|
||||
if i == "1":
|
||||
ctx.add_class("distbutton_active")
|
||||
distgrid.attach(self.labels[i], j, 0, 1, 1)
|
||||
j += 1
|
||||
|
||||
self.labels["1"].set_active(True)
|
||||
|
||||
#space_grid = KlippyGtk.HomogeneousGrid()
|
||||
#space_grid.attach(Gtk.Label("Distance (mm):"),0,0,1,1)
|
||||
#space_grid.attach(distgrid,0,1,1,1)
|
||||
#space_grid.attach(Gtk.Label(" "),0,2,1,1)
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
|
||||
bottomgrid = KlippyGtk.HomogeneousGrid()
|
||||
self.labels['pos_x'] = Gtk.Label("X: 0")
|
||||
self.labels['pos_y'] = Gtk.Label("Y: 0")
|
||||
self.labels['pos_z'] = Gtk.Label("Z: 0")
|
||||
self.labels['pos_x'].get_style_context().add_class("text")
|
||||
self.labels['pos_y'].get_style_context().add_class("text")
|
||||
self.labels['pos_z'].get_style_context().add_class("text")
|
||||
bottomgrid.attach(self.labels['pos_x'], 0, 0, 1, 1)
|
||||
bottomgrid.attach(self.labels['pos_y'], 1, 0, 1, 1)
|
||||
bottomgrid.attach(self.labels['pos_z'], 2, 0, 1, 1)
|
||||
box.pack_start(bottomgrid, True, True, 0)
|
||||
self.labels['move_dist'] = Gtk.Label("Move Distance (mm)")
|
||||
self.labels['move_dist'].get_style_context().add_class("text")
|
||||
box.pack_start(self.labels['move_dist'], True, True, 0)
|
||||
box.pack_start(distgrid, True, True, 0)
|
||||
|
||||
grid.attach(box, 0, 2, 3, 1)
|
||||
|
||||
|
||||
|
||||
b = KlippyGtk.ButtonImage('back', 'Back')
|
||||
b.connect("clicked", self._screen._menu_go_back)
|
||||
grid.attach(b, 3, 2, 1, 1)
|
||||
|
||||
self.panel = grid
|
||||
self._screen.add_subscription(panel_name)
|
||||
|
||||
def process_update(self, data):
|
||||
if "toolhead" in data and "position" in data["toolhead"]:
|
||||
self.labels['pos_x'].set_text("X: %.2f" % (data["toolhead"]["position"][0]))
|
||||
self.labels['pos_y'].set_text("Y: %.2f" % (data["toolhead"]["position"][1]))
|
||||
self.labels['pos_z'].set_text("Z: %.2f" % (data["toolhead"]["position"][2]))
|
||||
|
||||
def change_distance(self, widget, distance):
|
||||
if self.distance == distance:
|
||||
return
|
||||
logging.info("### Distance " + str(distance))
|
||||
|
||||
ctx = self.labels[str(self.distance)].get_style_context()
|
||||
ctx.remove_class("distbutton_active")
|
||||
|
||||
self.distance = distance
|
||||
ctx = self.labels[self.distance].get_style_context()
|
||||
ctx.add_class("distbutton_active")
|
||||
for i in self.distances:
|
||||
if i == self.distance:
|
||||
continue
|
||||
self.labels[str(i)].set_active(False)
|
||||
|
||||
def move(self, widget, axis, dir):
|
||||
dist = str(self.distance) if dir == "+" else "-" + str(self.distance)
|
||||
logging.info("# Moving " + axis + " " + dist + "mm")
|
||||
|
||||
print("%s\n%s %s%s" % (KlippyGcodes.MOVE_RELATIVE, KlippyGcodes.MOVE, axis, dist))
|
||||
self._screen._ws.klippy.gcode_script(
|
||||
"%s\n%s %s%s" % (KlippyGcodes.MOVE_RELATIVE, KlippyGcodes.MOVE, axis, dist)
|
||||
)
|
||||
import gi
|
||||
import logging
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.MovePanel")
|
||||
|
||||
def create_panel(*args):
|
||||
return MovePanel(*args)
|
||||
|
||||
class MovePanel(ScreenPanel):
|
||||
distance = 1
|
||||
distances = ['.1','.5','1','5','10','25']
|
||||
|
||||
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
self.labels['x+'] = KlippyGtk.ButtonImage("move-x+", _("X+"), "color1")
|
||||
self.labels['x+'].connect("clicked", self.move, "X", "+")
|
||||
self.labels['x-'] = KlippyGtk.ButtonImage("move-x-", _("X-"), "color1")
|
||||
self.labels['x-'].connect("clicked", self.move, "X", "-")
|
||||
|
||||
self.labels['y+'] = KlippyGtk.ButtonImage("move-y+", _("Y+"), "color2")
|
||||
self.labels['y+'].connect("clicked", self.move, "Y", "+")
|
||||
self.labels['y-'] = KlippyGtk.ButtonImage("move-y-", _("Y-"), "color2")
|
||||
self.labels['y-'].connect("clicked", self.move, "Y", "-")
|
||||
|
||||
self.labels['z+'] = KlippyGtk.ButtonImage("move-z-", _("Z+"), "color3")
|
||||
self.labels['z+'].connect("clicked", self.move, "Z", "+")
|
||||
self.labels['z-'] = KlippyGtk.ButtonImage("move-z+", _("Z-"), "color3")
|
||||
self.labels['z-'].connect("clicked", self.move, "Z", "-")
|
||||
|
||||
self.labels['home'] = KlippyGtk.ButtonImage("home", _("Home All"))
|
||||
self.labels['home'].connect("clicked", self.home)
|
||||
|
||||
|
||||
grid.attach(self.labels['x+'], 2, 1, 1, 1)
|
||||
grid.attach(self.labels['x-'], 0, 1, 1, 1)
|
||||
grid.attach(self.labels['y+'], 1, 0, 1, 1)
|
||||
grid.attach(self.labels['y-'], 1, 1, 1, 1)
|
||||
grid.attach(self.labels['z+'], 3, 0, 1, 1)
|
||||
grid.attach(self.labels['z-'], 3, 1, 1, 1)
|
||||
|
||||
grid.attach(self.labels['home'], 0, 0, 1, 1)
|
||||
|
||||
distgrid = Gtk.Grid()
|
||||
j = 0;
|
||||
for i in self.distances:
|
||||
self.labels[i] = KlippyGtk.ToggleButton(i)
|
||||
self.labels[i].connect("clicked", self.change_distance, i)
|
||||
ctx = self.labels[i].get_style_context()
|
||||
if j == 0:
|
||||
ctx.add_class("distbutton_top")
|
||||
elif j == len(self.distances)-1:
|
||||
ctx.add_class("distbutton_bottom")
|
||||
else:
|
||||
ctx.add_class("distbutton")
|
||||
if i == "1":
|
||||
ctx.add_class("distbutton_active")
|
||||
distgrid.attach(self.labels[i], j, 0, 1, 1)
|
||||
j += 1
|
||||
|
||||
self.labels["1"].set_active(True)
|
||||
|
||||
#space_grid = KlippyGtk.HomogeneousGrid()
|
||||
#space_grid.attach(Gtk.Label("Distance (mm):"),0,0,1,1)
|
||||
#space_grid.attach(distgrid,0,1,1,1)
|
||||
#space_grid.attach(Gtk.Label(" "),0,2,1,1)
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
|
||||
bottomgrid = KlippyGtk.HomogeneousGrid()
|
||||
self.labels['pos_x'] = Gtk.Label("X: 0")
|
||||
self.labels['pos_y'] = Gtk.Label("Y: 0")
|
||||
self.labels['pos_z'] = Gtk.Label("Z: 0")
|
||||
self.labels['pos_x'].get_style_context().add_class("text")
|
||||
self.labels['pos_y'].get_style_context().add_class("text")
|
||||
self.labels['pos_z'].get_style_context().add_class("text")
|
||||
bottomgrid.attach(self.labels['pos_x'], 0, 0, 1, 1)
|
||||
bottomgrid.attach(self.labels['pos_y'], 1, 0, 1, 1)
|
||||
bottomgrid.attach(self.labels['pos_z'], 2, 0, 1, 1)
|
||||
box.pack_start(bottomgrid, True, True, 0)
|
||||
self.labels['move_dist'] = Gtk.Label(_("Move Distance (mm)"))
|
||||
self.labels['move_dist'].get_style_context().add_class("text")
|
||||
box.pack_start(self.labels['move_dist'], True, True, 0)
|
||||
box.pack_start(distgrid, True, True, 0)
|
||||
|
||||
grid.attach(box, 0, 2, 3, 1)
|
||||
|
||||
self.content.add(grid)
|
||||
self._screen.add_subscription(panel_name)
|
||||
|
||||
def process_update(self, action, data):
|
||||
if action != "notify_status_update":
|
||||
return
|
||||
|
||||
if "toolhead" in data and "position" in data["toolhead"]:
|
||||
self.labels['pos_x'].set_text("X: %.2f" % (data["toolhead"]["position"][0]))
|
||||
self.labels['pos_y'].set_text("Y: %.2f" % (data["toolhead"]["position"][1]))
|
||||
self.labels['pos_z'].set_text("Z: %.2f" % (data["toolhead"]["position"][2]))
|
||||
|
||||
def change_distance(self, widget, distance):
|
||||
if self.distance == distance:
|
||||
return
|
||||
logging.info("### Distance " + str(distance))
|
||||
|
||||
ctx = self.labels[str(self.distance)].get_style_context()
|
||||
ctx.remove_class("distbutton_active")
|
||||
|
||||
self.distance = distance
|
||||
ctx = self.labels[self.distance].get_style_context()
|
||||
ctx.add_class("distbutton_active")
|
||||
for i in self.distances:
|
||||
if i == self.distance:
|
||||
continue
|
||||
self.labels[str(i)].set_active(False)
|
||||
|
||||
def move(self, widget, axis, dir):
|
||||
dist = str(self.distance) if dir == "+" else "-" + str(self.distance)
|
||||
logging.info("# Moving " + axis + " " + dist + "mm")
|
||||
|
||||
print("%s\n%s %s%s" % (KlippyGcodes.MOVE_RELATIVE, KlippyGcodes.MOVE, axis, dist))
|
||||
self._screen._ws.klippy.gcode_script(
|
||||
"%s\n%s %s%s" % (KlippyGcodes.MOVE_RELATIVE, KlippyGcodes.MOVE, axis, dist)
|
||||
)
|
||||
@@ -5,15 +5,19 @@ import os
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from KlippyGtk import KlippyGtk
|
||||
from panels.screen_panel import ScreenPanel
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.NetworkPanel")
|
||||
|
||||
def create_panel(*args):
|
||||
return NetworkPanel(*args)
|
||||
|
||||
class NetworkPanel(ScreenPanel):
|
||||
def initialize(self, menu):
|
||||
# Create gtk items here
|
||||
self.panel = KlippyGtk.HomogeneousGrid()
|
||||
_ = self.lang.gettext
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
grid.set_hexpand(True)
|
||||
|
||||
# Get Hostname
|
||||
stream = os.popen('hostname -A')
|
||||
@@ -25,12 +29,9 @@ class NetworkPanel(ScreenPanel):
|
||||
|
||||
|
||||
self.labels['networkinfo'] = Gtk.Label(
|
||||
"Network Info\n\n%s%s" % (hostname, ip)
|
||||
_("Network Info") + "\n\n%s%s" % (hostname, ip)
|
||||
)
|
||||
self.labels['networkinfo'].get_style_context().add_class('temperature_entry')
|
||||
self.panel.attach(self.labels['networkinfo'], 1, 0, 1, 1)
|
||||
grid.attach(self.labels['networkinfo'], 1, 0, 1, 1)
|
||||
|
||||
|
||||
b = KlippyGtk.ButtonImage('back', 'Back')
|
||||
b.connect("clicked", self._screen._menu_go_back)
|
||||
self.panel.attach(b, 1, 1, 1, 1)
|
||||
self.content.add(grid)
|
||||
@@ -0,0 +1,108 @@
|
||||
import gi
|
||||
import logging
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib, Pango
|
||||
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.PowerPanel")
|
||||
|
||||
def create_panel(*args):
|
||||
return PowerPanel(*args)
|
||||
|
||||
class PowerPanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
self.devices = {}
|
||||
|
||||
# Create a scroll window for the power devices
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_vexpand(True)
|
||||
|
||||
# Create a grid for all devices
|
||||
self.labels['devices'] = Gtk.Grid()
|
||||
scroll.add(self.labels['devices'])
|
||||
|
||||
# Create a box to contain all of the above
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
|
||||
box.set_vexpand(True)
|
||||
box.pack_start(scroll, True, True, 0)
|
||||
|
||||
self.load_power_devices()
|
||||
|
||||
self.content.add(box)
|
||||
|
||||
self._screen.add_subscription(panel_name)
|
||||
|
||||
def add_device(self, device):
|
||||
|
||||
frame = Gtk.Frame()
|
||||
frame.set_property("shadow-type",Gtk.ShadowType.NONE)
|
||||
|
||||
name = Gtk.Label()
|
||||
name.set_markup("<big><b>%s</b></big>" % (device))
|
||||
name.set_hexpand(True)
|
||||
name.set_halign(Gtk.Align.START)
|
||||
name.set_line_wrap(True)
|
||||
name.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
|
||||
switch = Gtk.Switch()
|
||||
switch.set_hexpand(False)
|
||||
switch.set_active(True if self._screen.printer.get_power_device_status(device) == "on" else False)
|
||||
switch.connect("notify::active", self.on_switch, device)
|
||||
switch.set_property("width-request", 150)
|
||||
switch.set_property("height-request", 80)
|
||||
|
||||
labels = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
labels.add(name)
|
||||
|
||||
dev = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
|
||||
dev.set_margin_top(10)
|
||||
dev.set_margin_end(15)
|
||||
dev.set_margin_start(15)
|
||||
dev.set_margin_bottom(10)
|
||||
dev.set_hexpand(True)
|
||||
dev.set_vexpand(False)
|
||||
|
||||
dev.add(labels)
|
||||
dev.add(switch)
|
||||
frame.add(dev)
|
||||
|
||||
self.devices[device] = {
|
||||
"row": frame,
|
||||
"switch": switch
|
||||
}
|
||||
|
||||
devices = sorted(self.devices)
|
||||
pos = devices.index(device)
|
||||
|
||||
self.labels['devices'].insert_row(pos)
|
||||
self.labels['devices'].attach(self.devices[device]['row'], 0, pos, 1, 1)
|
||||
self.labels['devices'].show_all()
|
||||
|
||||
def load_power_devices(self):
|
||||
devices = self._screen.printer.get_power_devices()
|
||||
for x in devices:
|
||||
self.add_device(x)
|
||||
|
||||
def on_switch(self, switch, gparam, device):
|
||||
logger.debug("Power toggled %s" % device)
|
||||
if switch.get_active():
|
||||
self._screen._ws.klippy.power_device_on(device)
|
||||
else:
|
||||
self._screen._ws.klippy.power_device_off(device)
|
||||
|
||||
def process_update(self, action, data):
|
||||
if action != "notify_power_changed":
|
||||
return
|
||||
|
||||
if data['device'] not in self.devices:
|
||||
return
|
||||
device = data['device']
|
||||
self.devices[device]['switch'].disconnect_by_func(self.on_switch)
|
||||
self.devices[device]['switch'].set_active(True if data['status'] == "on" else False)
|
||||
self.devices[device]['switch'].connect("notify::active", self.on_switch, device)
|
||||
@@ -4,16 +4,21 @@ import logging
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from KlippyGtk import KlippyGtk
|
||||
from panels.screen_panel import ScreenPanel
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.PreheatPanel")
|
||||
|
||||
def create_panel(*args):
|
||||
return PreheatPanel(*args)
|
||||
|
||||
class PreheatPanel(ScreenPanel):
|
||||
active_heaters = []
|
||||
|
||||
def initialize(self, panel_name):
|
||||
self.preheat_options = self._screen._config['preheat_options']
|
||||
_ = self.lang.gettext
|
||||
self.preheat_options = self._screen._config.get_preheat_options()
|
||||
logger.debug("Preheat options: %s" % self.preheat_options)
|
||||
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
@@ -46,24 +51,28 @@ class PreheatPanel(ScreenPanel):
|
||||
i += 1
|
||||
|
||||
|
||||
cooldown = KlippyGtk.ButtonImage('cool-down', 'Cooldown')
|
||||
cooldown = KlippyGtk.ButtonImage('cool-down', _('Cooldown'))
|
||||
cooldown.connect("clicked", self.set_temperature, "cooldown")
|
||||
|
||||
b = KlippyGtk.ButtonImage('back', 'Back')
|
||||
b.connect("clicked", self._screen._menu_go_back)
|
||||
|
||||
row = int(i/2) if i%2 == 0 else int(i/2)+1
|
||||
self.labels["control_grid"].attach(cooldown, 0, row, 1, 1)
|
||||
self.labels["control_grid"].attach(b, 1, row, 1, 1)
|
||||
self.labels["control_grid"].attach(cooldown, i%2, int(i/2), 1, 1)
|
||||
|
||||
|
||||
grid.attach(eq_grid, 0, 0, 1, 1)
|
||||
grid.attach(self.labels["control_grid"], 1, 0, 1, 1)
|
||||
|
||||
self.panel = grid
|
||||
self.content.add(grid)
|
||||
|
||||
self._screen.add_subscription(panel_name)
|
||||
|
||||
def activate(self):
|
||||
for x in self._printer.get_tools():
|
||||
if x not in self.active_heaters:
|
||||
self.select_heater(None, x)
|
||||
|
||||
if "heater_bed" not in self.active_heaters:
|
||||
self.select_heater(None, "heater_bed")
|
||||
|
||||
def select_heater(self, widget, heater):
|
||||
if heater in self.active_heaters:
|
||||
self.active_heaters.pop(self.active_heaters.index(heater))
|
||||
@@ -91,11 +100,15 @@ class PreheatPanel(ScreenPanel):
|
||||
self._screen._ws.klippy.set_bed_temp(self.preheat_options[setting]["bed"])
|
||||
self._printer.set_dev_stat(heater,"target", int(self.preheat_options[setting]["bed"]))
|
||||
else:
|
||||
print ("Setting %s to %d" % (heater, self.preheat_options[setting]['tool']))
|
||||
self._screen._ws.klippy.set_tool_temp(heater, self.preheat_options[setting]["tool"])
|
||||
self._printer.set_dev_stat(heater,"target", int(self.preheat_options[setting]["tool"]))
|
||||
print ("Setting %s to %d" % (heater, self.preheat_options[setting]['extruder']))
|
||||
self._screen._ws.klippy.set_tool_temp(self._printer.get_tool_number(heater),
|
||||
self.preheat_options[setting]["extruder"])
|
||||
self._printer.set_dev_stat(heater,"target", int(self.preheat_options[setting]["extruder"]))
|
||||
|
||||
def process_update(self, action, data):
|
||||
if action != "notify_status_update":
|
||||
return
|
||||
|
||||
def process_update(self, data):
|
||||
self.update_temp("heater_bed",
|
||||
self._printer.get_dev_stat("heater_bed","temperature"),
|
||||
self._printer.get_dev_stat("heater_bed","target")
|
||||
|
||||
@@ -3,15 +3,18 @@ import humanize
|
||||
import logging
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
from gi.repository import Gtk, Gdk, GLib, Pango
|
||||
from datetime import datetime
|
||||
|
||||
from KlippyGtk import KlippyGtk
|
||||
from KlippyGcodes import KlippyGcodes
|
||||
from panels.screen_panel import ScreenPanel
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.PrintPanel")
|
||||
|
||||
def create_panel(*args):
|
||||
return PrintPanel(*args)
|
||||
|
||||
class PrintPanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
self.labels['files'] = {}
|
||||
@@ -24,24 +27,10 @@ class PrintPanel(ScreenPanel):
|
||||
box.set_vexpand(True)
|
||||
box.pack_start(scroll, True, True, 0)
|
||||
|
||||
|
||||
bar = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
||||
bar.set_hexpand(True)
|
||||
bar.set_vexpand(False)
|
||||
bar.set_halign(Gtk.Align.END)
|
||||
bar.set_margin_top(5)
|
||||
bar.set_margin_bottom(5)
|
||||
bar.set_margin_end(5)
|
||||
refresh = KlippyGtk.ButtonImage('refresh', None, None, 60, 60)
|
||||
refresh.connect("clicked", self.reload_files)
|
||||
#bar.add(refresh)
|
||||
|
||||
back = KlippyGtk.ButtonImage('back', None, None, 60, 60)
|
||||
back.connect("clicked", self._screen._menu_go_back)
|
||||
bar.add(back)
|
||||
|
||||
box.pack_end(bar, False, False, 0)
|
||||
|
||||
self.labels['filelist'] = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
self.labels['filelist'].set_vexpand(True)
|
||||
|
||||
@@ -54,8 +43,7 @@ class PrintPanel(ScreenPanel):
|
||||
|
||||
scroll.add(self.labels['filelist'])
|
||||
|
||||
|
||||
self.panel = box
|
||||
self.content.add(box)
|
||||
|
||||
self._screen.files.add_file_callback(self._callback)
|
||||
|
||||
@@ -74,9 +62,11 @@ class PrintPanel(ScreenPanel):
|
||||
name = Gtk.Label()
|
||||
#n = 50
|
||||
#name.set_markup("<big>%s</big>" % ("\n".join([filename[i:i+n] for i in range(0, len(filename), n)])))
|
||||
name.set_markup("<big>%s</big>" % (filename))
|
||||
name.set_markup("<big><b>%s</b></big>" % (filename))
|
||||
name.set_hexpand(True)
|
||||
name.set_halign(Gtk.Align.START)
|
||||
name.set_line_wrap(True)
|
||||
name.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
|
||||
info = Gtk.Label("Uploaded: blah - Size: blah")
|
||||
info.set_halign(Gtk.Align.START)
|
||||
@@ -138,13 +128,18 @@ class PrintPanel(ScreenPanel):
|
||||
|
||||
|
||||
def get_file_info_str(self, filename):
|
||||
_ = self.lang.gettext
|
||||
|
||||
fileinfo = self._screen.files.get_file_info(filename)
|
||||
if fileinfo == None:
|
||||
return
|
||||
|
||||
return "<small>Uploaded: <b>%s</b> - Size: <b>%s</b> - Print Time: <b>%s</b></small>" % (
|
||||
return "<small>%s: <b>%s</b> - %s: <b>%s</b>\n%s: <b>%s</b></small>" % (
|
||||
_("Uploaded"),
|
||||
datetime.fromtimestamp(fileinfo['modified']).strftime("%Y-%m-%d %H:%M"),
|
||||
_("Size"),
|
||||
humanize.naturalsize(fileinfo['size']),
|
||||
_("Print Time"),
|
||||
self.get_print_time(filename)
|
||||
)
|
||||
|
||||
@@ -212,47 +207,36 @@ class PrintPanel(ScreenPanel):
|
||||
self.update_file(file)
|
||||
|
||||
def confirm_print(self, widget, filename):
|
||||
dialog = Gtk.Dialog()
|
||||
#TODO: Factor other resolutions in
|
||||
dialog.set_default_size(984, 580)
|
||||
dialog.set_resizable(False)
|
||||
dialog.set_transient_for(self._screen)
|
||||
dialog.set_modal(True)
|
||||
|
||||
dialog.add_button(button_text="Print", response_id=Gtk.ResponseType.OK)
|
||||
dialog.add_button(button_text="Cancel", response_id=Gtk.ResponseType.CANCEL)
|
||||
|
||||
dialog.connect("response", self.confirm_print_response, filename)
|
||||
dialog.get_style_context().add_class("dialog")
|
||||
|
||||
content_area = dialog.get_content_area()
|
||||
content_area.set_margin_start(15)
|
||||
content_area.set_margin_end(15)
|
||||
content_area.set_margin_top(15)
|
||||
content_area.set_margin_bottom(15)
|
||||
_ = self.lang.gettext
|
||||
buttons = [
|
||||
{"name":_("Print"), "response": Gtk.ResponseType.OK},
|
||||
{"name":_("Cancel"),"response": Gtk.ResponseType.CANCEL}
|
||||
]
|
||||
|
||||
label = Gtk.Label()
|
||||
label.set_markup("%s <b>%s</b>%s" % (_("Are you sure you want to print"), filename, _("?")))
|
||||
label.set_hexpand(True)
|
||||
label.set_halign(Gtk.Align.CENTER)
|
||||
label.set_line_wrap(True)
|
||||
label.set_size_request(800, -1)
|
||||
label.set_markup("Are you sure you want to print <b>%s</b>?\n\n" % (filename))
|
||||
label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
label.get_style_context().add_class("text")
|
||||
|
||||
grid = Gtk.Grid()
|
||||
grid.add(label)
|
||||
grid.set_size_request(self._screen.width - 60, -1)
|
||||
|
||||
pixbuf = self.get_file_image(filename, 400, 350)
|
||||
pixbuf = self.get_file_image(filename, self._screen.width/2, self._screen.height/3)
|
||||
if pixbuf != None:
|
||||
image = Gtk.Image.new_from_pixbuf(pixbuf)
|
||||
|
||||
image.set_margin_top(20)
|
||||
grid.attach_next_to(image, label, Gtk.PositionType.BOTTOM, 1, 3)
|
||||
|
||||
#table.attach(label, 0, 1, 0, 1, Gtk.AttachOptions.SHRINK | Gtk.AttachOptions.FILL)
|
||||
grid.set_vexpand(True)
|
||||
grid.set_halign(Gtk.Align.CENTER)
|
||||
grid.set_valign(Gtk.Align.CENTER)
|
||||
content_area.add(grid)
|
||||
|
||||
dialog.show_all()
|
||||
dialog = KlippyGtk.Dialog(self._screen, buttons, grid, self.confirm_print_response, filename)
|
||||
|
||||
def confirm_print_response(self, widget, response_id, filename):
|
||||
widget.destroy()
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from KlippyGtk import KlippyGtk
|
||||
from KlippyGcodes import KlippyGcodes
|
||||
|
||||
class ScreenPanel:
|
||||
def __init__(self, screen):
|
||||
self._screen = screen
|
||||
self._printer = screen.printer
|
||||
self.labels = {}
|
||||
|
||||
|
||||
def initialize(self, panel_name):
|
||||
# Create gtk items here
|
||||
return
|
||||
|
||||
def emergency_stop(self, widget):
|
||||
self._screen._ws.klippy.emergency_stop()
|
||||
|
||||
def get(self):
|
||||
# Return gtk item
|
||||
return self.panel
|
||||
|
||||
def home(self, widget):
|
||||
self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
|
||||
|
||||
def menu_item_clicked(self, widget, panel, item):
|
||||
print("### Creating panel "+ item['panel'])
|
||||
if "items" in item:
|
||||
self._screen.show_panel(self._screen._cur_panels[-1] + '_' + item['name'], item['panel'], 1, False, items=item['items'])
|
||||
return
|
||||
self._screen.show_panel(self._screen._cur_panels[-1] + '_' + item['name'], item['panel'], 1, False)
|
||||
|
||||
def update_image_text(self, label, text):
|
||||
if label in self.labels and 'l' in self.labels[label]:
|
||||
self.labels[label]['l'].set_text(text)
|
||||
|
||||
def update_temp(self, dev, temp, target):
|
||||
if dev in self.labels:
|
||||
self.labels[dev].set_label(KlippyGtk.formatTemperatureString(temp, target))
|
||||
@@ -1,67 +1,89 @@
|
||||
import gi
|
||||
import logging
|
||||
import os
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from KlippyGtk import KlippyGtk
|
||||
from panels.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.SplashScreenPanel")
|
||||
|
||||
class SplashScreenPanel(ScreenPanel):
|
||||
box = None
|
||||
|
||||
def initialize(self, panel_name):
|
||||
image = Gtk.Image()
|
||||
#TODO: update file reference
|
||||
image.set_from_file(os.getcwd() + "/styles/z-bolt/images/klipper.png")
|
||||
|
||||
self.labels['text'] = Gtk.Label("Initializing printer...")
|
||||
self.labels['text'].get_style_context().add_class("text")
|
||||
|
||||
|
||||
self.labels['actions'] = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
||||
self.labels['actions'].set_hexpand(True)
|
||||
self.labels['actions'].set_vexpand(False)
|
||||
self.labels['actions'].set_halign(Gtk.Align.END)
|
||||
self.labels['actions'].set_margin_end(20)
|
||||
|
||||
|
||||
main = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=15)
|
||||
main.pack_start(image, True, True, 10)
|
||||
main.pack_end(self.labels['actions'], False, False, 10)
|
||||
main.pack_end(self.labels['text'], True, True, 10)
|
||||
|
||||
|
||||
box = Gtk.VBox()
|
||||
box.add(main)
|
||||
|
||||
self.panel = box
|
||||
|
||||
def update_text(self, text):
|
||||
self.labels['text'].set_text(text)
|
||||
self.clear_action_bar()
|
||||
|
||||
def clear_action_bar(self):
|
||||
for child in self.labels['actions'].get_children():
|
||||
self.labels['actions'].remove(child)
|
||||
|
||||
def show_restart_buttons(self):
|
||||
if "firmware_restart" not in self.labels:
|
||||
self.labels['restart'] = KlippyGtk.ButtonImage("reboot","Restart","color1")
|
||||
self.labels['restart'].connect("clicked", self.restart)
|
||||
self.labels['firmware_restart'] = KlippyGtk.ButtonImage("restart","Firmware Restart","color2")
|
||||
self.labels['firmware_restart'].connect("clicked", self.firmware_restart)
|
||||
|
||||
self.clear_action_bar()
|
||||
|
||||
self.labels['actions'].add(self.labels['restart'])
|
||||
self.labels['actions'].add(self.labels['firmware_restart'])
|
||||
|
||||
def firmware_restart(self, widget):
|
||||
self._screen._ws.klippy.restart_firmware()
|
||||
|
||||
def restart(self, widget):
|
||||
self._screen._ws.klippy.restart()
|
||||
import gi
|
||||
import logging
|
||||
import os
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib, Pango
|
||||
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.SplashScreenPanel")
|
||||
|
||||
def create_panel(*args):
|
||||
return SplashScreenPanel(*args)
|
||||
|
||||
class SplashScreenPanel(ScreenPanel):
|
||||
box = None
|
||||
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
|
||||
image = Gtk.Image()
|
||||
#TODO: update file reference
|
||||
image.set_from_file(os.getcwd() + "/styles/z-bolt/images/klipper.png")
|
||||
|
||||
self.labels['text'] = Gtk.Label(_("Initializing printer..."))
|
||||
self.labels['text'].get_style_context().add_class("text")
|
||||
self.labels['text'].set_line_wrap(True)
|
||||
self.labels['text'].set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
self.labels['text'].set_halign(Gtk.Align.CENTER)
|
||||
|
||||
|
||||
self.labels['actions'] = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
||||
self.labels['actions'].set_hexpand(True)
|
||||
self.labels['actions'].set_vexpand(False)
|
||||
self.labels['actions'].set_halign(Gtk.Align.END)
|
||||
self.labels['actions'].set_margin_end(20)
|
||||
|
||||
|
||||
main = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=15)
|
||||
main.pack_start(image, True, True, 10)
|
||||
main.pack_end(self.labels['actions'], False, False, 10)
|
||||
main.pack_end(self.labels['text'], True, True, 10)
|
||||
|
||||
|
||||
box = Gtk.VBox()
|
||||
box.add(main)
|
||||
|
||||
self.layout = box
|
||||
|
||||
def update_text(self, text):
|
||||
self.labels['text'].set_text(text)
|
||||
self.clear_action_bar()
|
||||
|
||||
def clear_action_bar(self):
|
||||
for child in self.labels['actions'].get_children():
|
||||
self.labels['actions'].remove(child)
|
||||
|
||||
def show_restart_buttons(self):
|
||||
_ = self.lang.gettext
|
||||
|
||||
if "firmware_restart" not in self.labels:
|
||||
self.labels['power'] = KlippyGtk.ButtonImage("reboot",_("Power On Printer"),"color3")
|
||||
self.labels['restart'] = KlippyGtk.ButtonImage("reboot",_("Restart"),"color1")
|
||||
self.labels['restart'].connect("clicked", self.restart)
|
||||
self.labels['firmware_restart'] = KlippyGtk.ButtonImage("restart",_("Firmware Restart"),"color2")
|
||||
self.labels['firmware_restart'].connect("clicked", self.firmware_restart)
|
||||
|
||||
self.clear_action_bar()
|
||||
|
||||
devices = [i for i in self._screen.printer.get_power_devices() if i.lower().startswith('printer')]
|
||||
logger.debug("Power devices: %s" % devices)
|
||||
if len(devices) > 0:
|
||||
logger.debug("Adding power button")
|
||||
self.labels['power'].connect("clicked", self.power_on, devices[0])
|
||||
self.labels['actions'].add(self.labels['power'])
|
||||
|
||||
self.labels['actions'].add(self.labels['power'])
|
||||
self.labels['actions'].add(self.labels['restart'])
|
||||
self.labels['actions'].add(self.labels['firmware_restart'])
|
||||
|
||||
def firmware_restart(self, widget):
|
||||
self._screen._ws.klippy.restart_firmware()
|
||||
|
||||
def power_on(self, widget, device):
|
||||
self._screen._ws.klippy.power_device_on(device)
|
||||
|
||||
def restart(self, widget):
|
||||
self._screen._ws.klippy.restart()
|
||||
@@ -5,61 +5,63 @@ import os
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from KlippyGtk import KlippyGtk
|
||||
from KlippyGcodes import KlippyGcodes
|
||||
from panels.screen_panel import ScreenPanel
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.SystemPanel")
|
||||
|
||||
def create_panel(*args):
|
||||
return SystemPanel(*args)
|
||||
|
||||
class SystemPanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
# Create gtk items here
|
||||
_ = self.lang.gettext
|
||||
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
restart = KlippyGtk.ButtonImage('reboot','Klipper Restart','color1')
|
||||
restart = KlippyGtk.ButtonImage('reboot',_('Klipper Restart'),'color1')
|
||||
restart.connect("clicked", self.restart_klippy)
|
||||
firmrestart = KlippyGtk.ButtonImage('restart','Firmware Restart','color2')
|
||||
firmrestart = KlippyGtk.ButtonImage('restart',_('Firmware Restart'),'color2')
|
||||
firmrestart.connect("clicked", self.restart_klippy, "firmware")
|
||||
back = KlippyGtk.ButtonImage('back', 'Back')
|
||||
back.connect("clicked", self._screen._menu_go_back)
|
||||
|
||||
info = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
info.set_vexpand(True)
|
||||
|
||||
title = Gtk.Label("System Information")
|
||||
title.set_margin_bottom(5)
|
||||
title.set_margin_top(15)
|
||||
|
||||
self.labels['loadavg'] = Gtk.Label("temp")
|
||||
self.update_system_load()
|
||||
|
||||
self.system_timeout = GLib.timeout_add(1000, self.update_system_load)
|
||||
|
||||
title.get_style_context().add_class('temperature_entry')
|
||||
self.labels['loadavg'].get_style_context().add_class('temperature_entry')
|
||||
self.labels['klipper_version'] = Gtk.Label(_("Klipper Version") +
|
||||
(": %s" % self._screen.printer.get_klipper_version()))
|
||||
self.labels['klipper_version'].set_margin_top(15)
|
||||
|
||||
self.labels['ks_version'] = Gtk.Label(_("KlipperScreen Version") + (": %s" % self._screen.version))
|
||||
self.labels['ks_version'].set_margin_top(15)
|
||||
|
||||
info.add(title)
|
||||
info.add(self.labels['loadavg'])
|
||||
info.add(self.labels['klipper_version'])
|
||||
info.add(self.labels['ks_version'])
|
||||
|
||||
|
||||
grid.attach(info, 0, 0, 4, 2)
|
||||
grid.attach(restart, 0, 2, 1, 1)
|
||||
grid.attach(firmrestart, 1, 2, 1, 1)
|
||||
grid.attach(back, 3, 2, 1, 1)
|
||||
|
||||
self.panel = grid
|
||||
self.content.add(grid)
|
||||
|
||||
def update_system_load(self):
|
||||
_ = self.lang.gettext
|
||||
lavg = os.getloadavg()
|
||||
self.labels['loadavg'].set_text(
|
||||
"Load Average: %.2f %.2f %.2f" % (lavg[0], lavg[1], lavg[2])
|
||||
_("Load Average") + (": %.2f %.2f %.2f" % (lavg[0], lavg[1], lavg[2]))
|
||||
)
|
||||
|
||||
#TODO: Shouldn't need this
|
||||
self.system_timeout = GLib.timeout_add(1000, self.update_system_load)
|
||||
|
||||
def restart_klippy(self, type=None):
|
||||
def restart_klippy(self, widget, type=None):
|
||||
if type == "firmware":
|
||||
self._screen._ws.klippy.restart_firmware()
|
||||
else:
|
||||
|
||||
@@ -1,236 +1,246 @@
|
||||
import gi
|
||||
import logging
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from KlippyGtk import KlippyGtk
|
||||
from KlippyGcodes import KlippyGcodes
|
||||
from panels.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.TemperaturePanel")
|
||||
|
||||
class TemperaturePanel(ScreenPanel):
|
||||
active_heater = "extruder"
|
||||
tempdeltas = ["1","5","10","25"]
|
||||
tempdelta = "10"
|
||||
|
||||
def initialize(self, panel_name):
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
eq_grid = KlippyGtk.HomogeneousGrid()
|
||||
i = 0
|
||||
for x in self._printer.get_tools():
|
||||
if i > 3:
|
||||
break
|
||||
elif i == 0:
|
||||
primary_tool = x
|
||||
self.labels[x] = KlippyGtk.ToggleButtonImage("extruder-"+str(i+1), KlippyGtk.formatTemperatureString(0, 0))
|
||||
self.labels[x].connect('clicked', self.select_heater, x)
|
||||
if i == 0:
|
||||
self.labels[x].set_active(True)
|
||||
eq_grid.attach(self.labels[x], i%2, i/2, 1, 1)
|
||||
i += 1
|
||||
|
||||
print ("Primary tool: " + primary_tool)
|
||||
self.labels[primary_tool].get_style_context().add_class('button_active')
|
||||
|
||||
self.labels["heater_bed"] = KlippyGtk.ToggleButtonImage("bed", KlippyGtk.formatTemperatureString(0, 0))
|
||||
self.labels["heater_bed"].connect('clicked', self.select_heater, "heater_bed")
|
||||
width = 2 if i > 1 else 1
|
||||
eq_grid.attach(self.labels["heater_bed"], 0, i/2+1, width, 1)
|
||||
|
||||
self.labels["control_grid"] = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
self.labels["increase"] = KlippyGtk.ButtonImage("increase", "Increase", "color1")
|
||||
self.labels["increase"].connect("clicked",self.change_target_temp, "+")
|
||||
self.labels["decrease"] = KlippyGtk.ButtonImage("decrease", "Decrease", "color3")
|
||||
self.labels["decrease"].connect("clicked",self.change_target_temp, "-")
|
||||
self.labels["npad"] = KlippyGtk.ButtonImage("settings", "Number Pad", "color2")
|
||||
self.labels["npad"].connect("clicked", self.show_numpad)
|
||||
|
||||
tempgrid = Gtk.Grid()
|
||||
j = 0;
|
||||
for i in self.tempdeltas:
|
||||
self.labels['deg'+ i] = KlippyGtk.ToggleButton(i)
|
||||
self.labels['deg'+ i].connect("clicked", self.change_temp_delta, i)
|
||||
ctx = self.labels['deg'+ i].get_style_context()
|
||||
if j == 0:
|
||||
ctx.add_class("tempbutton_top")
|
||||
elif j == len(self.tempdeltas)-1:
|
||||
ctx.add_class("tempbutton_bottom")
|
||||
else:
|
||||
ctx.add_class("tempbutton")
|
||||
if i == "10":
|
||||
ctx.add_class("distbutton_active")
|
||||
tempgrid.attach(self.labels['deg'+ i], 0, j, 1, 1)
|
||||
j += 1
|
||||
|
||||
self.labels["deg" + self.tempdelta].set_active(True)
|
||||
|
||||
self.labels["control_grid"].attach(tempgrid, 2, 0, 1, 2)
|
||||
self.labels["control_grid"].attach(self.labels["increase"], 3, 0, 1, 1)
|
||||
self.labels["control_grid"].attach(self.labels["decrease"], 3, 1, 1, 1)
|
||||
self.labels["control_grid"].attach(self.labels["npad"], 2, 2, 1, 1)
|
||||
|
||||
b = KlippyGtk.ButtonImage('back', 'Back')
|
||||
b.connect("clicked", self._screen._menu_go_back)
|
||||
self.labels["control_grid"].attach(b, 3, 2, 1, 1)
|
||||
|
||||
|
||||
grid.attach(eq_grid, 0, 0, 1, 1)
|
||||
grid.attach(self.labels["control_grid"], 1, 0, 1, 1)
|
||||
|
||||
self.panel = grid
|
||||
|
||||
self._screen.add_subscription(panel_name)
|
||||
|
||||
self.update_temp("heater_bed",35,40)
|
||||
|
||||
def change_temp_delta(self, widget, tempdelta):
|
||||
if self.tempdelta == tempdelta:
|
||||
return
|
||||
logging.info("### tempdelta " + str(tempdelta))
|
||||
|
||||
ctx = self.labels["deg" + str(self.tempdelta)].get_style_context()
|
||||
ctx.remove_class("distbutton_active")
|
||||
|
||||
self.tempdelta = tempdelta
|
||||
ctx = self.labels["deg" + self.tempdelta].get_style_context()
|
||||
ctx.add_class("distbutton_active")
|
||||
for i in self.tempdeltas:
|
||||
if i == self.tempdeltas:
|
||||
continue
|
||||
self.labels["deg" + str(i)].set_active(False)
|
||||
|
||||
def show_numpad(self, widget):
|
||||
numpad = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
keys = [
|
||||
['1','numpad_tleft'],
|
||||
['2','numpad_top'],
|
||||
['3','numpad_tright'],
|
||||
['4','numpad_left'],
|
||||
['5','numpad_button'],
|
||||
['6','numpad_right'],
|
||||
['7','numpad_left'],
|
||||
['8','numpad_button'],
|
||||
['9','numpad_right'],
|
||||
['B','numpad_bleft'],
|
||||
['0','numpad_bottom'],
|
||||
['E','numpad_bright']
|
||||
]
|
||||
for i in range(len(keys)):
|
||||
id = 'button_' + str(keys[i][0])
|
||||
if keys[i][0] == "B":
|
||||
self.labels[id] = KlippyGtk.ButtonImage("backspace")
|
||||
elif keys[i][0] == "E":
|
||||
self.labels[id] = KlippyGtk.ButtonImage("complete", None, None, 40, 40)
|
||||
else:
|
||||
self.labels[id] = Gtk.Button(keys[i][0])
|
||||
self.labels[id].connect('clicked', self.update_entry, keys[i][0])
|
||||
ctx=self.labels[id].get_style_context()
|
||||
ctx.add_class(keys[i][1])
|
||||
numpad.attach(self.labels[id], i%3, i/3, 1, 1)
|
||||
|
||||
self.labels["keypad"] = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=3)
|
||||
self.labels['entry'] = Gtk.Entry()
|
||||
self.labels['entry'].props.xalign = 0.5
|
||||
ctx = self.labels['entry'].get_style_context()
|
||||
ctx.add_class('temperature_entry')
|
||||
|
||||
b = KlippyGtk.ButtonImage('back', 'Close')
|
||||
b.connect("clicked", self.hide_numpad)
|
||||
|
||||
#numpad.attach(b, 0, 5, 3, 1)
|
||||
#numpad.attach(self.labels['entry'], 0, 0, 3, 1)
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
box.add(self.labels['entry'])
|
||||
box.add(numpad)
|
||||
box.add(b)
|
||||
|
||||
self.labels["keypad"] = numpad
|
||||
|
||||
self.panel.remove_column(1)
|
||||
#self.panel.attach(self.labels["keypad"], 1, 0, 1, 1)
|
||||
self.panel.attach(box, 1, 0, 1, 1)
|
||||
self.panel.show_all()
|
||||
|
||||
def hide_numpad(self, widget):
|
||||
self.panel.remove_column(1)
|
||||
self.panel.attach(self.labels["control_grid"], 1, 0, 1, 1)
|
||||
self.panel.show_all()
|
||||
|
||||
|
||||
def select_heater (self, widget, heater):
|
||||
if self.active_heater == heater:
|
||||
return
|
||||
|
||||
|
||||
self.labels[self.active_heater].get_style_context().remove_class('button_active')
|
||||
self.active_heater = heater
|
||||
self.labels[heater].get_style_context().add_class("button_active")
|
||||
|
||||
if "entry" in self.labels:
|
||||
self.labels['entry'].set_text("")
|
||||
logging.info("### Active heater " + self.active_heater)
|
||||
|
||||
def process_update(self, data):
|
||||
self.update_temp("heater_bed",
|
||||
self._printer.get_dev_stat("heater_bed","temperature"),
|
||||
self._printer.get_dev_stat("heater_bed","target")
|
||||
)
|
||||
for x in self._printer.get_tools():
|
||||
self.update_temp(x,
|
||||
self._printer.get_dev_stat(x,"temperature"),
|
||||
self._printer.get_dev_stat(x,"target")
|
||||
)
|
||||
return
|
||||
|
||||
def change_target_temp(self, widget, dir):
|
||||
target = self._printer.get_dev_stat(self.active_heater, "target")
|
||||
if dir == "+":
|
||||
target += int(self.tempdelta)
|
||||
if target > KlippyGcodes.MAX_EXT_TEMP:
|
||||
target = KlippyGcodes.MAX_EXT_TEMP
|
||||
else:
|
||||
target -= int(self.tempdelta)
|
||||
if target < 0:
|
||||
target = 0
|
||||
|
||||
self._printer.set_dev_stat(self.active_heater, "target", target)
|
||||
|
||||
if self.active_heater == "heater_bed":
|
||||
self._screen._ws.klippy.gcode_script( KlippyGcodes.set_bed_temp(
|
||||
target
|
||||
))
|
||||
else:
|
||||
self._screen._ws.klippy.gcode_script( KlippyGcodes.set_ext_temp(
|
||||
target,
|
||||
self._printer.get_tool_number(self.active_heater)
|
||||
))
|
||||
|
||||
def update_entry(self, widget, digit):
|
||||
text = self.labels['entry'].get_text()
|
||||
if digit == 'B':
|
||||
if len(text) < 1:
|
||||
return
|
||||
self.labels['entry'].set_text(text[0:-1])
|
||||
elif digit == 'E':
|
||||
if self.active_heater == "heater_bed":
|
||||
temp = int(text)
|
||||
temp = 0 if temp < 0 or temp > KlippyGcodes.MAX_BED_TEMP else temp
|
||||
self._screen._ws.klippy.gcode_script(KlippyGcodes.set_bed_temp(temp))
|
||||
else:
|
||||
temp = int(text)
|
||||
temp = 0 if temp < 0 or temp > KlippyGcodes.MAX_EXT_TEMP else temp
|
||||
self._screen._ws.klippy.gcode_script( KlippyGcodes.set_ext_temp(
|
||||
temp,
|
||||
self._printer.get_tool_number(self.active_heater)
|
||||
))
|
||||
self._printer.set_dev_stat(self.active_heater, "target", temp)
|
||||
self.labels['entry'].set_text("")
|
||||
else:
|
||||
if len(text) >= 3:
|
||||
return
|
||||
self.labels['entry'].set_text(text + digit)
|
||||
import gi
|
||||
import logging
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.TemperaturePanel")
|
||||
|
||||
def create_panel(*args):
|
||||
return TemperaturePanel(*args)
|
||||
|
||||
class TemperaturePanel(ScreenPanel):
|
||||
active_heater = "extruder"
|
||||
tempdeltas = ["1","5","10","25"]
|
||||
tempdelta = "10"
|
||||
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
eq_grid = KlippyGtk.HomogeneousGrid()
|
||||
i = 0
|
||||
for x in self._printer.get_tools():
|
||||
if i > 3:
|
||||
break
|
||||
elif i == 0:
|
||||
primary_tool = x
|
||||
self.labels[x] = KlippyGtk.ToggleButtonImage("extruder-"+str(i+1), KlippyGtk.formatTemperatureString(0, 0))
|
||||
self.labels[x].connect('clicked', self.select_heater, x)
|
||||
if i == 0:
|
||||
self.labels[x].set_active(True)
|
||||
eq_grid.attach(self.labels[x], i%2, i/2, 1, 1)
|
||||
i += 1
|
||||
|
||||
print ("Primary tool: " + primary_tool)
|
||||
self.labels[primary_tool].get_style_context().add_class('button_active')
|
||||
|
||||
self.labels["heater_bed"] = KlippyGtk.ToggleButtonImage("bed", KlippyGtk.formatTemperatureString(0, 0))
|
||||
self.labels["heater_bed"].connect('clicked', self.select_heater, "heater_bed")
|
||||
width = 2 if i > 1 else 1
|
||||
eq_grid.attach(self.labels["heater_bed"], 0, i/2+1, width, 1)
|
||||
|
||||
self.labels["control_grid"] = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
self.labels["increase"] = KlippyGtk.ButtonImage("increase", _("Increase"), "color1")
|
||||
self.labels["increase"].connect("clicked",self.change_target_temp, "+")
|
||||
self.labels["decrease"] = KlippyGtk.ButtonImage("decrease", _("Decrease"), "color3")
|
||||
self.labels["decrease"].connect("clicked",self.change_target_temp, "-")
|
||||
self.labels["npad"] = KlippyGtk.ButtonImage("settings", _("Number Pad"), "color2")
|
||||
self.labels["npad"].connect("clicked", self.show_numpad)
|
||||
|
||||
tempgrid = Gtk.Grid()
|
||||
j = 0;
|
||||
for i in self.tempdeltas:
|
||||
self.labels['deg'+ i] = KlippyGtk.ToggleButton(i)
|
||||
self.labels['deg'+ i].connect("clicked", self.change_temp_delta, i)
|
||||
ctx = self.labels['deg'+ i].get_style_context()
|
||||
if j == 0:
|
||||
ctx.add_class("tempbutton_top")
|
||||
elif j == len(self.tempdeltas)-1:
|
||||
ctx.add_class("tempbutton_bottom")
|
||||
else:
|
||||
ctx.add_class("tempbutton")
|
||||
if i == "10":
|
||||
ctx.add_class("distbutton_active")
|
||||
tempgrid.attach(self.labels['deg'+ i], 0, j, 1, 1)
|
||||
j += 1
|
||||
|
||||
self.labels["deg" + self.tempdelta].set_active(True)
|
||||
|
||||
vbox = Gtk.VBox()
|
||||
vbox.pack_start(Gtk.Label("Temp °C"), False, False, 4)
|
||||
vbox.pack_end(tempgrid, True, True, 0)
|
||||
|
||||
self.labels["control_grid"].attach(vbox, 2, 0, 1, 3)
|
||||
self.labels["control_grid"].attach(self.labels["increase"], 3, 0, 1, 1)
|
||||
self.labels["control_grid"].attach(self.labels["decrease"], 3, 1, 1, 1)
|
||||
self.labels["control_grid"].attach(self.labels["npad"], 3, 2, 1, 1)
|
||||
|
||||
grid.attach(eq_grid, 0, 0, 1, 1)
|
||||
grid.attach(self.labels["control_grid"], 1, 0, 1, 1)
|
||||
|
||||
self.grid = grid
|
||||
self.content.add(grid)
|
||||
|
||||
self._screen.add_subscription(panel_name)
|
||||
|
||||
self.update_temp("heater_bed",35,40)
|
||||
|
||||
def change_temp_delta(self, widget, tempdelta):
|
||||
if self.tempdelta == tempdelta:
|
||||
return
|
||||
logging.info("### tempdelta " + str(tempdelta))
|
||||
|
||||
ctx = self.labels["deg" + str(self.tempdelta)].get_style_context()
|
||||
ctx.remove_class("distbutton_active")
|
||||
|
||||
self.tempdelta = tempdelta
|
||||
ctx = self.labels["deg" + self.tempdelta].get_style_context()
|
||||
ctx.add_class("distbutton_active")
|
||||
for i in self.tempdeltas:
|
||||
if i == self.tempdeltas:
|
||||
continue
|
||||
self.labels["deg" + str(i)].set_active(False)
|
||||
|
||||
def show_numpad(self, widget):
|
||||
_ = self.lang.gettext
|
||||
|
||||
numpad = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
keys = [
|
||||
['1','numpad_tleft'],
|
||||
['2','numpad_top'],
|
||||
['3','numpad_tright'],
|
||||
['4','numpad_left'],
|
||||
['5','numpad_button'],
|
||||
['6','numpad_right'],
|
||||
['7','numpad_left'],
|
||||
['8','numpad_button'],
|
||||
['9','numpad_right'],
|
||||
['B','numpad_bleft'],
|
||||
['0','numpad_bottom'],
|
||||
['E','numpad_bright']
|
||||
]
|
||||
for i in range(len(keys)):
|
||||
id = 'button_' + str(keys[i][0])
|
||||
if keys[i][0] == "B":
|
||||
self.labels[id] = KlippyGtk.ButtonImage("backspace")
|
||||
elif keys[i][0] == "E":
|
||||
self.labels[id] = KlippyGtk.ButtonImage("complete", None, None, 40, 40)
|
||||
else:
|
||||
self.labels[id] = Gtk.Button(keys[i][0])
|
||||
self.labels[id].connect('clicked', self.update_entry, keys[i][0])
|
||||
ctx=self.labels[id].get_style_context()
|
||||
ctx.add_class(keys[i][1])
|
||||
numpad.attach(self.labels[id], i%3, i/3, 1, 1)
|
||||
|
||||
self.labels["keypad"] = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=3)
|
||||
self.labels['entry'] = Gtk.Entry()
|
||||
self.labels['entry'].props.xalign = 0.5
|
||||
ctx = self.labels['entry'].get_style_context()
|
||||
ctx.add_class('temperature_entry')
|
||||
|
||||
b = KlippyGtk.ButtonImage('back', _('Close'))
|
||||
b.connect("clicked", self.hide_numpad)
|
||||
|
||||
#numpad.attach(b, 0, 5, 3, 1)
|
||||
#numpad.attach(self.labels['entry'], 0, 0, 3, 1)
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
box.add(self.labels['entry'])
|
||||
box.add(numpad)
|
||||
box.add(b)
|
||||
|
||||
self.labels["keypad"] = numpad
|
||||
|
||||
self.grid.remove_column(1)
|
||||
#self.grid.attach(self.labels["keypad"], 1, 0, 1, 1)
|
||||
self.grid.attach(box, 1, 0, 1, 1)
|
||||
self.grid.show_all()
|
||||
|
||||
def hide_numpad(self, widget):
|
||||
self.grid.remove_column(1)
|
||||
self.grid.attach(self.labels["control_grid"], 1, 0, 1, 1)
|
||||
self.grid.show_all()
|
||||
|
||||
|
||||
def select_heater (self, widget, heater):
|
||||
if self.active_heater == heater:
|
||||
return
|
||||
|
||||
|
||||
self.labels[self.active_heater].get_style_context().remove_class('button_active')
|
||||
self.active_heater = heater
|
||||
self.labels[heater].get_style_context().add_class("button_active")
|
||||
|
||||
if "entry" in self.labels:
|
||||
self.labels['entry'].set_text("")
|
||||
logging.info("### Active heater " + self.active_heater)
|
||||
|
||||
def process_update(self, action, data):
|
||||
if action != "notify_status_update":
|
||||
return
|
||||
|
||||
self.update_temp("heater_bed",
|
||||
self._printer.get_dev_stat("heater_bed","temperature"),
|
||||
self._printer.get_dev_stat("heater_bed","target")
|
||||
)
|
||||
for x in self._printer.get_tools():
|
||||
self.update_temp(x,
|
||||
self._printer.get_dev_stat(x,"temperature"),
|
||||
self._printer.get_dev_stat(x,"target")
|
||||
)
|
||||
return
|
||||
|
||||
def change_target_temp(self, widget, dir):
|
||||
target = self._printer.get_dev_stat(self.active_heater, "target")
|
||||
if dir == "+":
|
||||
target += int(self.tempdelta)
|
||||
if target > KlippyGcodes.MAX_EXT_TEMP:
|
||||
target = KlippyGcodes.MAX_EXT_TEMP
|
||||
else:
|
||||
target -= int(self.tempdelta)
|
||||
if target < 0:
|
||||
target = 0
|
||||
|
||||
self._printer.set_dev_stat(self.active_heater, "target", target)
|
||||
|
||||
if self.active_heater == "heater_bed":
|
||||
self._screen._ws.klippy.gcode_script( KlippyGcodes.set_bed_temp(
|
||||
target
|
||||
))
|
||||
else:
|
||||
self._screen._ws.klippy.gcode_script( KlippyGcodes.set_ext_temp(
|
||||
target,
|
||||
self._printer.get_tool_number(self.active_heater)
|
||||
))
|
||||
|
||||
def update_entry(self, widget, digit):
|
||||
text = self.labels['entry'].get_text()
|
||||
if digit == 'B':
|
||||
if len(text) < 1:
|
||||
return
|
||||
self.labels['entry'].set_text(text[0:-1])
|
||||
elif digit == 'E':
|
||||
if self.active_heater == "heater_bed":
|
||||
temp = int(text)
|
||||
temp = 0 if temp < 0 or temp > KlippyGcodes.MAX_BED_TEMP else temp
|
||||
self._screen._ws.klippy.gcode_script(KlippyGcodes.set_bed_temp(temp))
|
||||
else:
|
||||
temp = int(text)
|
||||
temp = 0 if temp < 0 or temp > KlippyGcodes.MAX_EXT_TEMP else temp
|
||||
self._screen._ws.klippy.gcode_script( KlippyGcodes.set_ext_temp(
|
||||
temp,
|
||||
self._printer.get_tool_number(self.active_heater)
|
||||
))
|
||||
self._printer.set_dev_stat(self.active_heater, "target", temp)
|
||||
self.labels['entry'].set_text("")
|
||||
else:
|
||||
if len(text) >= 3:
|
||||
return
|
||||
self.labels['entry'].set_text(text + digit)
|
||||
@@ -3,36 +3,41 @@ import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from KlippyGtk import KlippyGtk
|
||||
from KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||
from ks_includes.screen_panel import ScreenPanel
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger("KlipperScreen.ZCalibratePanel")
|
||||
|
||||
class ZCalibratePanel:
|
||||
def create_panel(*args):
|
||||
return ZCalibratePanel(*args)
|
||||
|
||||
class ZCalibratePanel(ScreenPanel):
|
||||
_screen = None
|
||||
labels = {}
|
||||
distance = 1
|
||||
distances = ['.01','.05','.1','.5','1','5']
|
||||
|
||||
def __init__(self, screen):
|
||||
self._screen = screen
|
||||
def __init__(self, screen, title, back=True):
|
||||
super().__init__(screen, title, False)
|
||||
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
grid = KlippyGtk.HomogeneousGrid()
|
||||
|
||||
label = Gtk.Label("Z Offset: ")
|
||||
label.get_style_context().add_class('temperature_entry')
|
||||
self.labels['zpos'] = Gtk.Label("Homing")
|
||||
self.labels['zpos'].get_style_context().add_class('temperature_entry')
|
||||
box = Gtk.Box()
|
||||
label = Gtk.Label(_("Z Offset") + ": \n")
|
||||
self.labels['zposition'] = Gtk.Label(_("Homing"))
|
||||
box = Gtk.VBox()
|
||||
box.set_vexpand(False)
|
||||
box.set_valign(Gtk.Align.CENTER)
|
||||
|
||||
box.add(label)
|
||||
box.add(self.labels['zpos'])
|
||||
box.add(self.labels['zposition'])
|
||||
|
||||
zpos = KlippyGtk.ButtonImage('z-offset-decrease',"Raise Nozzle")
|
||||
zpos = KlippyGtk.ButtonImage('z-offset-decrease',_("Raise Nozzle"))
|
||||
zpos.connect("clicked", self.move, "+")
|
||||
zneg = KlippyGtk.ButtonImage('z-offset-increase',"Lower Nozzle")
|
||||
zneg = KlippyGtk.ButtonImage('z-offset-increase',_("Lower Nozzle"))
|
||||
zneg.connect("clicked", self.move, "-")
|
||||
|
||||
distgrid = Gtk.Grid()
|
||||
@@ -55,44 +60,49 @@ class ZCalibratePanel:
|
||||
self.labels["1"].set_active(True)
|
||||
|
||||
space_grid = KlippyGtk.HomogeneousGrid()
|
||||
space_grid.attach(Gtk.Label("Distance (mm):"),0,0,1,1)
|
||||
space_grid.set_row_homogeneous(False)
|
||||
space_grid.attach(Gtk.Label(_("Distance (mm)") + ":"),0,0,1,1)
|
||||
space_grid.attach(distgrid,0,1,1,1)
|
||||
space_grid.attach(Gtk.Label(" "),0,2,1,1)
|
||||
|
||||
complete = KlippyGtk.ButtonImage('complete','Accept','color2')
|
||||
complete = KlippyGtk.ButtonImage('complete',_('Accept'),'color2')
|
||||
complete.connect("clicked", self.accept)
|
||||
|
||||
|
||||
b = KlippyGtk.ButtonImage('back', 'Abort')
|
||||
b = KlippyGtk.ButtonImage('back', _('Abort'))
|
||||
b.connect("clicked", self.abort)
|
||||
|
||||
|
||||
grid.attach(zpos, 1, 0, 1, 1)
|
||||
grid.attach(box, 0, 1, 2, 1)
|
||||
grid.attach(zneg, 1, 1, 1, 1)
|
||||
grid.attach(complete, 3, 1, 1, 1)
|
||||
#grid.set_row_homogeneous(False)
|
||||
grid.attach(zpos, 0, 0, 1, 1)
|
||||
grid.attach(box, 1, 0, 2, 2)
|
||||
grid.attach(zneg, 0, 1, 1, 1)
|
||||
grid.attach(complete, 3, 0, 1, 1)
|
||||
grid.attach(space_grid, 0, 2, 3, 1)
|
||||
grid.attach(b, 3, 2, 1, 1)
|
||||
|
||||
|
||||
self.grid = grid
|
||||
self.content.add(grid)
|
||||
self._screen.add_subscription(panel_name)
|
||||
|
||||
def activate(self):
|
||||
self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
|
||||
self._screen._ws.klippy.gcode_script(KlippyGcodes.PROBE_CALIBRATE)
|
||||
#if self._screen.printer.get_stat("toolhead","homed_axes") != "xyz":
|
||||
# self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME)
|
||||
#self._screen._ws.klippy.gcode_script(KlippyGcodes.PROBE_CALIBRATE)
|
||||
print("nothing")
|
||||
|
||||
def process_update(self, action, data):
|
||||
if action != "notify_status_update":
|
||||
return
|
||||
|
||||
def process_update(self, data):
|
||||
if "toolhead" in data and "position" in data['toolhead']:
|
||||
self.updatePosition(data['toolhead']['position'])
|
||||
|
||||
def updatePosition(self, position):
|
||||
self.labels['zpos'].set_text(str(round(position[2],2)))
|
||||
self.labels['zposition'].set_text(str(round(position[2],2)))
|
||||
|
||||
def change_distance(self, widget, distance):
|
||||
if self.distance == distance:
|
||||
return
|
||||
print("### Distance " + str(distance))
|
||||
|
||||
ctx = self.labels[str(self.distance)].get_style_context()
|
||||
ctx.remove_class("distbutton_active")
|
||||
@@ -113,9 +123,9 @@ class ZCalibratePanel:
|
||||
def abort(self, widget):
|
||||
logger.info("Aborting Z calibrate")
|
||||
self._screen._ws.klippy.gcode_script(KlippyGcodes.PROBE_ABORT)
|
||||
self._screen._menu_go_back(widget)
|
||||
self.menu_return(widget)
|
||||
|
||||
def accept(self, widget):
|
||||
logger.info("Accepting Z calibrate")
|
||||
self._screen._ws.klippy.gcode_script(KlippyGcodes.PROBE_ACCEPT)
|
||||
self._screen._ws.klippy.gcode_script(KlippyGcodes.SAVE_CONFIG)
|
||||
self.menu_return(widget)
|
||||
@@ -1,43 +1,30 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import gi
|
||||
import gettext
|
||||
import time
|
||||
import threading
|
||||
|
||||
import json
|
||||
import requests
|
||||
import websocket
|
||||
import importlib
|
||||
import logging
|
||||
import os
|
||||
import asyncio
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
from gi.repository import Gtk, Gdk, GLib, Pango
|
||||
|
||||
from KlippyWebsocket import KlippyWebsocket
|
||||
from KlippyRest import KlippyRest
|
||||
from files import KlippyFiles
|
||||
from KlippyGtk import KlippyGtk
|
||||
from printer import Printer
|
||||
from ks_includes.KlippyWebsocket import KlippyWebsocket
|
||||
from ks_includes.KlippyRest import KlippyRest
|
||||
from ks_includes.files import KlippyFiles
|
||||
from ks_includes.KlippyGtk import KlippyGtk
|
||||
from ks_includes.printer import Printer
|
||||
|
||||
# Do this better in the future
|
||||
from panels.screen_panel import *
|
||||
from panels.bed_level import *
|
||||
from panels.extrude import *
|
||||
from panels.fan import *
|
||||
from panels.fine_tune import *
|
||||
from panels.job_status import *
|
||||
from panels.main_menu import *
|
||||
from panels.menu import *
|
||||
from panels.move import *
|
||||
from panels.network import *
|
||||
from panels.preheat import *
|
||||
from panels.print import *
|
||||
from panels.splash_screen import *
|
||||
from panels.system import *
|
||||
from panels.temperature import *
|
||||
from panels.zcalibrate import *
|
||||
from ks_includes.config import KlipperScreenConfig
|
||||
|
||||
# Create logging
|
||||
logger = logging.getLogger('KlipperScreen')
|
||||
@@ -66,7 +53,9 @@ class KlipperScreen(Gtk.Window):
|
||||
number_tools = 1
|
||||
|
||||
panels = {}
|
||||
load_panel = {}
|
||||
_cur_panels = []
|
||||
files = None
|
||||
filename = ""
|
||||
subscriptions = []
|
||||
last_update = {}
|
||||
@@ -74,9 +63,11 @@ class KlipperScreen(Gtk.Window):
|
||||
printer = None
|
||||
|
||||
def __init__(self):
|
||||
self.read_config()
|
||||
self._config = KlipperScreenConfig()
|
||||
self.init_style()
|
||||
self.printer = Printer({
|
||||
"software_version": "Unknown"
|
||||
}, {
|
||||
'configfile': {
|
||||
'config': {}
|
||||
},
|
||||
@@ -87,83 +78,38 @@ class KlipperScreen(Gtk.Window):
|
||||
'is_active': False
|
||||
}
|
||||
})
|
||||
self.lang = gettext.translation('KlipperScreen', localedir='ks_includes/locales')
|
||||
_ = self.lang.gettext
|
||||
|
||||
self.apiclient = KlippyRest("127.0.0.1",7125)
|
||||
Gtk.Window.__init__(self)
|
||||
|
||||
self.set_default_size(Gdk.Screen.get_width(Gdk.Screen.get_default()), Gdk.Screen.get_height(Gdk.Screen.get_default()))
|
||||
self.width = Gdk.Screen.get_width(Gdk.Screen.get_default())
|
||||
self.height = Gdk.Screen.get_height(Gdk.Screen.get_default())
|
||||
self.set_default_size(self.width, self.height)
|
||||
self.set_resizable(False)
|
||||
logger.info("Screen resolution: %s", str(Gdk.Screen.get_width(Gdk.Screen.get_default()))+"x"+str(Gdk.Screen.get_height(Gdk.Screen.get_default())))
|
||||
self.version = get_software_version()
|
||||
logger.info("KlipperScreen version: %s" % self.version)
|
||||
logger.info("Screen resolution: %sx%s" % (self.width, self.height))
|
||||
|
||||
self.printer_initializing("Connecting to Moonraker")
|
||||
#self._load_panels()
|
||||
|
||||
self.printer_initializing(_("Initializing"))
|
||||
|
||||
self._ws = KlippyWebsocket(self, {
|
||||
"on_connect": self.init_printer,
|
||||
"on_message": self._websocket_callback,
|
||||
"on_close": self.printer_initializing
|
||||
})
|
||||
self._ws.connect()
|
||||
|
||||
# Disable DPMS
|
||||
os.system("/usr/bin/xset -display :0 s off")
|
||||
os.system("/usr/bin/xset -display :0 -dpms")
|
||||
os.system("/usr/bin/xset -display :0 s noblank")
|
||||
|
||||
ready = False
|
||||
return
|
||||
|
||||
try:
|
||||
info = self.apiclient.get_info()
|
||||
except Exception:
|
||||
return
|
||||
|
||||
if info == False:
|
||||
return
|
||||
|
||||
if not hasattr(self, "_ws"):
|
||||
self.create_websocket()
|
||||
|
||||
print(info)
|
||||
if info['result']['klippy_state'] == "disconnected":
|
||||
self.printer_initializing("Klipper is not connected to moonraker")
|
||||
return
|
||||
if info['result']['klippy_state'] == "error":
|
||||
logger.warning("Printer is emergency stopped")
|
||||
self.printer_initializing("Shutdown due to Emergency Stop")
|
||||
return
|
||||
|
||||
status_objects = [
|
||||
'idle_timeout',
|
||||
'configfile',
|
||||
'gcode_move',
|
||||
'fan',
|
||||
'toolhead',
|
||||
'virtual_sdcard',
|
||||
'print_stats',
|
||||
'heater_bed',
|
||||
'extruder',
|
||||
'pause_resume'
|
||||
]
|
||||
r = requests.get("http://127.0.0.1:7125/printer/objects/query?" + "&".join(status_objects))
|
||||
|
||||
#TODO: Check that we get good data
|
||||
#print (r.content)
|
||||
try:
|
||||
data = json.loads(r.content)
|
||||
except:
|
||||
logger.info("Not able to load data. Klippy is most likely offline")
|
||||
return
|
||||
data = data['result']['status']
|
||||
for x in data:
|
||||
self.last_update[x] = data[x]
|
||||
|
||||
self.printer_config = data['configfile']['config']
|
||||
#logger.debug("Printer config: %s" % json.dumps(self.printer_config, indent=2))
|
||||
self.printer.__init__(data)
|
||||
|
||||
# Initialize target values. TODO: methodize this
|
||||
self.printer.set_dev_stat("heater_bed", "target", data['heater_bed']['target'])
|
||||
self.printer.set_dev_stat("extruder", "target", data['extruder']['target'])
|
||||
|
||||
print (info)
|
||||
if (data['print_stats']['state'] == "printing" or data['print_stats']['state'] == "paused"):
|
||||
self.printer_printing()
|
||||
elif info['result']['klippy_state'] == "ready":
|
||||
self.printer_ready()
|
||||
|
||||
self.files = KlippyFiles(self)
|
||||
|
||||
def ws_subscribe(self):
|
||||
requested_updates = {
|
||||
@@ -175,72 +121,88 @@ class KlipperScreen(Gtk.Window):
|
||||
"heater_bed": ["target","temperature"],
|
||||
"print_stats": ["print_duration","total_duration","filament_used","filename","state","message"],
|
||||
"toolhead": ["homed_axes","estimated_print_time","print_time","position","extruder"],
|
||||
"virtual_sdcard": ["file_position","is_active","progress"]
|
||||
"virtual_sdcard": ["file_position","is_active","progress"],
|
||||
"webhooks": ["state","state_message"]
|
||||
}
|
||||
}
|
||||
self._ws.klippy.object_subscription(requested_updates)
|
||||
|
||||
def show_panel(self, panel_name, type, remove=None, pop=True, **kwargs):
|
||||
def _load_panel(self, panel, *args):
|
||||
if not panel in self.load_panel:
|
||||
logger.debug("Loading panel: %s" % panel)
|
||||
panel_path = os.path.join(os.path.dirname(__file__), 'panels', "%s.py" % panel)
|
||||
logger.info("Panel path: %s" % panel_path)
|
||||
if not os.path.exists(panel_path):
|
||||
msg = f"Panel {panel} does not exist"
|
||||
logger.info(msg)
|
||||
raise Exception(msg)
|
||||
|
||||
module = importlib.import_module("panels.%s" % panel)
|
||||
if not hasattr(module, "create_panel"):
|
||||
msg = f"Cannot locate create_panel function for {panel}"
|
||||
logger.info(msg)
|
||||
raise Exception(msg)
|
||||
self.load_panel[panel] = getattr(module, "create_panel")
|
||||
|
||||
try:
|
||||
return self.load_panel[panel](*args)
|
||||
except Exception:
|
||||
msg = f"Unable to create panel {panel}"
|
||||
logger.exception(msg)
|
||||
raise Exception(msg)
|
||||
|
||||
|
||||
def show_panel(self, panel_name, type, title, remove=None, pop=True, **kwargs):
|
||||
if panel_name not in self.panels:
|
||||
self.panels[panel_name] = self._load_panel(type, self, title)
|
||||
|
||||
try:
|
||||
if kwargs != {}:
|
||||
self.panels[panel_name].initialize(panel_name, **kwargs)
|
||||
else:
|
||||
self.panels[panel_name].initialize(panel_name)
|
||||
except:
|
||||
del self.panels[panel_name]
|
||||
self.show_error_modal("Unable to load panel %s" % type)
|
||||
return
|
||||
|
||||
if hasattr(self.panels[panel_name],"process_update"):
|
||||
self.panels[panel_name].process_update("notify_status_update", self.printer.get_data())
|
||||
|
||||
if hasattr(self.panels[panel_name],"activate"):
|
||||
self.panels[panel_name].activate()
|
||||
|
||||
if remove == 2:
|
||||
self._remove_all_panels()
|
||||
elif remove == 1:
|
||||
self._remove_current_panel(pop)
|
||||
|
||||
if panel_name not in self.panels:
|
||||
if type == "SplashScreenPanel":
|
||||
self.panels[panel_name] = SplashScreenPanel(self)
|
||||
elif type == "MainPanel":
|
||||
self.panels[panel_name] = MainPanel(self)
|
||||
elif type == "menu":
|
||||
self.panels[panel_name] = MenuPanel(self)
|
||||
elif type == "bed_level":
|
||||
self.panels[panel_name] = BedLevelPanel(self)
|
||||
elif type == "extrude":
|
||||
self.panels[panel_name] = ExtrudePanel(self)
|
||||
elif type == "finetune":
|
||||
self.panels[panel_name] = FineTune(self)
|
||||
elif type == "JobStatusPanel":
|
||||
self.panels[panel_name] = JobStatusPanel(self)
|
||||
elif type == "move":
|
||||
self.panels[panel_name] = MovePanel(self)
|
||||
elif type == "network":
|
||||
self.panels[panel_name] = NetworkPanel(self)
|
||||
elif type == "preheat":
|
||||
self.panels[panel_name] = PreheatPanel(self)
|
||||
elif type == "print":
|
||||
self.panels[panel_name] = PrintPanel(self)
|
||||
elif type == "temperature":
|
||||
self.panels[panel_name] = TemperaturePanel(self)
|
||||
elif type == "fan":
|
||||
self.panels[panel_name] = FanPanel(self)
|
||||
elif type == "system":
|
||||
self.panels[panel_name] = SystemPanel(self)
|
||||
elif type == "zcalibrate":
|
||||
self.panels[panel_name] = ZCalibratePanel(self)
|
||||
#Temporary for development
|
||||
else:
|
||||
self.panels[panel_name] = MovePanel(self)
|
||||
|
||||
if kwargs != {}:
|
||||
self.panels[panel_name].initialize(panel_name, **kwargs)
|
||||
else:
|
||||
self.panels[panel_name].initialize(panel_name)
|
||||
|
||||
if hasattr(self.panels[panel_name],"process_update"):
|
||||
self.panels[panel_name].process_update(self.printer.get_data())
|
||||
|
||||
if hasattr(self.panels[panel_name],"activate"):
|
||||
self.panels[panel_name].activate()
|
||||
|
||||
self.add(self.panels[panel_name].get())
|
||||
self.show_all()
|
||||
self._cur_panels.append(panel_name)
|
||||
logger.debug("Current panel hierarchy: %s", str(self._cur_panels))
|
||||
|
||||
def show_error_modal(self, err):
|
||||
_ = self.lang.gettext
|
||||
logger.exception("Showing error modal: %s", err)
|
||||
|
||||
def read_config (self):
|
||||
with open(config) as config_file:
|
||||
self._config = json.load(config_file)
|
||||
buttons = [
|
||||
{"name":_("Go Back"),"response": Gtk.ResponseType.CANCEL}
|
||||
]
|
||||
|
||||
label = Gtk.Label()
|
||||
label.set_markup(("%s \n\n" % err) +
|
||||
_("Check /tmp/KlipperScreen.log for more information.\nPlease submit an issue on GitHub for help."))
|
||||
label.set_hexpand(True)
|
||||
label.set_halign(Gtk.Align.CENTER)
|
||||
label.set_line_wrap(True)
|
||||
label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
label.get_style_context().add_class("text")
|
||||
|
||||
dialog = KlippyGtk.Dialog(self, buttons, label, self.error_modal_response)
|
||||
|
||||
def error_modal_response(self, widget, response_id):
|
||||
widget.destroy()
|
||||
|
||||
|
||||
def init_style(self):
|
||||
@@ -253,12 +215,6 @@ class KlipperScreen(Gtk.Window):
|
||||
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
|
||||
)
|
||||
|
||||
def create_websocket(self):
|
||||
self._ws = KlippyWebsocket(self, self._websocket_callback)
|
||||
self._ws.connect()
|
||||
self._curr = 0
|
||||
|
||||
|
||||
def _go_to_submenu(self, widget, name):
|
||||
logger.info("#### Go to submenu " + str(name))
|
||||
#self._remove_current_panel(False)
|
||||
@@ -266,15 +222,19 @@ class KlipperScreen(Gtk.Window):
|
||||
# Find current menu item
|
||||
panels = list(self._cur_panels)
|
||||
if "job_status" not in self._cur_panels:
|
||||
cur_item = self._find_current_menu_item(name, self._config['mainmenu'], panels.pop(0))
|
||||
menu = cur_item['items']
|
||||
menu = "__main"
|
||||
else:
|
||||
menu = self._config['printmenu']
|
||||
menu = "__print"
|
||||
|
||||
logger.info("#### Menu " + str(menu))
|
||||
#self.show_panel("_".join(self._cur_panels) + '_' + name, "menu", 1, False, menu=menu)
|
||||
disname = self._config.get_menu_name(menu, name)
|
||||
menuitems = self._config.get_menu_items(menu, name)
|
||||
if len(menuitems) == 0:
|
||||
logger.info("No items in menu, returning.")
|
||||
return
|
||||
|
||||
self.show_panel(self._cur_panels[-1] + '_' + name, "menu", 1, False, items=menu)
|
||||
self.show_panel(self._cur_panels[-1] + '_' + name, "menu", disname, 1, False, display_name=disname,
|
||||
items=menuitems)
|
||||
return
|
||||
|
||||
grid = self.arrangeMenuItems(menu, 4)
|
||||
@@ -288,37 +248,29 @@ class KlipperScreen(Gtk.Window):
|
||||
self.add(self.panels[cur_item['name']])
|
||||
self.show_all()
|
||||
|
||||
|
||||
|
||||
def _find_current_menu_item(self, menu, items, names):
|
||||
for item in items:
|
||||
if item['name'] == menu:
|
||||
return item
|
||||
#TODO: Add error check
|
||||
|
||||
def _remove_all_panels(self):
|
||||
while len(self._cur_panels) > 0:
|
||||
self._remove_current_panel()
|
||||
self._remove_current_panel(True, False)
|
||||
self.show_all()
|
||||
|
||||
|
||||
|
||||
def _remove_current_panel(self, pop=True):
|
||||
def _remove_current_panel(self, pop=True, show=True):
|
||||
if len(self._cur_panels) > 0:
|
||||
self.remove(
|
||||
self.panels[
|
||||
self._cur_panels[-1]
|
||||
].get()
|
||||
)
|
||||
self.remove(self.panels[self._cur_panels[-1]].get())
|
||||
if pop == True:
|
||||
self._cur_panels.pop()
|
||||
if len(self._cur_panels) > 0:
|
||||
self.add(self.panels[self._cur_panels[-1]].get())
|
||||
self.show_all()
|
||||
if show == True:
|
||||
self.show_all()
|
||||
|
||||
def _menu_go_back (self, widget):
|
||||
def _menu_go_back (self, widget=None):
|
||||
logger.info("#### Menu go back")
|
||||
self._remove_current_panel()
|
||||
|
||||
def _menu_go_home(self):
|
||||
logger.info("#### Menu go home")
|
||||
while len(self._cur_panels) > 1:
|
||||
self._remove_current_panel()
|
||||
|
||||
def add_subscription (self, panel_name):
|
||||
add = True
|
||||
@@ -335,21 +287,27 @@ class KlipperScreen(Gtk.Window):
|
||||
return
|
||||
|
||||
def _websocket_callback(self, action, data):
|
||||
_ = self.lang.gettext
|
||||
#print(json.dumps([action, data], indent=2))
|
||||
|
||||
if action == "notify_klippy_disconnected":
|
||||
logger.info("### Going to disconnected state")
|
||||
self.printer_initializing("Klipper has shutdown")
|
||||
self.printer_initializing(_("Klipper has shutdown"))
|
||||
return
|
||||
elif action == "notify_klippy_ready":
|
||||
logger.info("### Going to ready state")
|
||||
self.printer_ready()
|
||||
elif action == "notify_status_update":
|
||||
self.init_printer()
|
||||
elif action == "notify_status_update" and self.shutdown == False:
|
||||
self.printer.process_update(data)
|
||||
if "webhooks" in data:
|
||||
print(json.dumps([action, data], indent=2))
|
||||
if "webhooks" in data and "state" in data['webhooks']:
|
||||
if data['webhooks']['state'] == "ready":
|
||||
logger.info("### Going to ready state")
|
||||
self.printer_ready()
|
||||
elif data['webhooks']['state'] == "shutdown":
|
||||
self.shutdown == True
|
||||
self.printer_initializing(_("Klipper has shutdown"))
|
||||
else:
|
||||
active = self.printer.get_stat('virtual_sdcard','is_active')
|
||||
paused = self.printer.get_stat('pause_resume','is_paused')
|
||||
@@ -364,29 +322,64 @@ class KlipperScreen(Gtk.Window):
|
||||
#self.files.add_file()
|
||||
elif action == "notify_metadata_update":
|
||||
self.files.update_metadata(data['filename'])
|
||||
else:
|
||||
logger.debug(json.dumps([action, data], indent=2))
|
||||
elif action == "notify_power_changed":
|
||||
logger.debug("Power status changed: %s", data)
|
||||
self.printer.process_power_update(data)
|
||||
elif self.shutdown == False and action == "notify_gcode_response":
|
||||
if "Klipper state: Shutdown" in data:
|
||||
self.shutdown == True
|
||||
self.printer_initializing(_("Klipper has shutdown"))
|
||||
|
||||
if not (data.startswith("B:") and
|
||||
re.search(r'B:[0-9\.]+\s/[0-9\.]+\sT[0-9]+:[0-9\.]+', data)):
|
||||
logger.debug(json.dumps([action, data], indent=2))
|
||||
|
||||
for sub in self.subscriptions:
|
||||
self.panels[sub].process_update(data)
|
||||
self.panels[sub].process_update(action, data)
|
||||
|
||||
def _confirm_send_action(self, widget, text, method, params):
|
||||
_ = self.lang.gettext
|
||||
|
||||
buttons = [
|
||||
{"name":_("Continue"), "response": Gtk.ResponseType.OK},
|
||||
{"name":_("Cancel"),"response": Gtk.ResponseType.CANCEL}
|
||||
]
|
||||
|
||||
label = Gtk.Label()
|
||||
label.set_markup(text)
|
||||
label.set_hexpand(True)
|
||||
label.set_halign(Gtk.Align.CENTER)
|
||||
label.set_line_wrap(True)
|
||||
label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
label.get_style_context().add_class("text")
|
||||
|
||||
dialog = KlippyGtk.Dialog(self, buttons, label, self._confirm_send_action_response, method, params)
|
||||
|
||||
def _confirm_send_action_response(self, widget, response_id, method, params):
|
||||
if response_id == Gtk.ResponseType.OK:
|
||||
self._send_action(widget, method, params)
|
||||
|
||||
widget.destroy()
|
||||
|
||||
def _send_action(self, widget, method, params):
|
||||
self._ws.send_method(method, params)
|
||||
|
||||
def printer_initializing(self, text=None):
|
||||
self.shutdown = True
|
||||
self.show_panel('splash_screen',"SplashScreenPanel", 2)
|
||||
self.show_panel('splash_screen',"splash_screen", "Splash Screen", 2)
|
||||
if text != None:
|
||||
self.panels['splash_screen'].update_text(text)
|
||||
self.panels['splash_screen'].show_restart_buttons()
|
||||
|
||||
def printer_ready(self):
|
||||
def init_printer(self):
|
||||
_ = self.lang.gettext
|
||||
self.shutdown = False
|
||||
|
||||
status_objects = [
|
||||
'idle_timeout',
|
||||
'configfile',
|
||||
'gcode_move',
|
||||
'fan',
|
||||
'toolhead',
|
||||
'virtual_sdcard',
|
||||
'print_stats',
|
||||
@@ -394,25 +387,71 @@ class KlipperScreen(Gtk.Window):
|
||||
'extruder',
|
||||
'pause_resume'
|
||||
]
|
||||
r = requests.get("http://127.0.0.1:7125/printer/objects/query?" + "&".join(status_objects))
|
||||
|
||||
#TODO: Check that we get good data
|
||||
data = json.loads(r.content)
|
||||
self.printer_config = data['result']['status']['configfile']['config']
|
||||
#logger.debug("Printer config: %s" % json.dumps(self.printer_config, indent=2))
|
||||
printer_info = self.apiclient.get_printer_info()
|
||||
data = self.apiclient.send_request("printer/objects/query?" + "&".join(status_objects))
|
||||
powerdevs = self.apiclient.send_request("machine/device_power/devices")
|
||||
if printer_info == False or data == False:
|
||||
self.printer_initializing(_("Moonraker error"))
|
||||
return
|
||||
data = data['result']['status']
|
||||
|
||||
# Reinitialize printer, in case the printer was shut down and anything has changed.
|
||||
self.printer.__init__(data['result']['status'])
|
||||
self.printer.__init__(printer_info['result'], data)
|
||||
self.ws_subscribe()
|
||||
|
||||
#logger.debug("Config sections: %s", self.printer.get_config_section_list())
|
||||
#logger.debug("Bed_screws: %s", self.printer.get_config_section("bed_screws"))
|
||||
if powerdevs != False:
|
||||
self.printer.configure_power_devices(powerdevs['result'])
|
||||
|
||||
self.show_panel('main_panel', "MainPanel", 2, items=self._config['mainmenu'], extrudercount=self.printer.get_extruder_count())
|
||||
if self.files == None:
|
||||
self.files = KlippyFiles(self)
|
||||
else:
|
||||
self.files.add_timeout()
|
||||
|
||||
if printer_info['result']['state'] == "shutdown":
|
||||
if "FIRMWARE_RESTART" in printer_info['result']['state_message']:
|
||||
self.printer_initializing(
|
||||
_("Klipper has encountered an error.\nIssue a FIRMWARE_RESTART to attempt fixing the issue.")
|
||||
)
|
||||
else:
|
||||
self.printer_initializing(_("Klipper has shutdown"))
|
||||
return
|
||||
if (data['print_stats']['state'] == "printing" or data['print_stats']['state'] == "paused"):
|
||||
self.printer_printing()
|
||||
return
|
||||
self.printer_ready()
|
||||
|
||||
def printer_ready(self):
|
||||
if self.shutdown == True:
|
||||
self.init_printer()
|
||||
return
|
||||
|
||||
self.files.add_timeout()
|
||||
self.show_panel('main_panel', "main_menu", "Main Menu", 2, items=self._config.get_menu_items("__main"),
|
||||
extrudercount=self.printer.get_extruder_count())
|
||||
|
||||
def printer_printing(self):
|
||||
self.ws_subscribe()
|
||||
self.show_panel('job_status',"JobStatusPanel", 2)
|
||||
self.files.remove_timeout()
|
||||
self.show_panel('job_status',"job_status", "Print Status", 2)
|
||||
|
||||
def get_software_version():
|
||||
prog = ('git', '-C', os.path.dirname(__file__), 'describe', '--always',
|
||||
'--tags', '--long', '--dirty')
|
||||
try:
|
||||
process = subprocess.Popen(prog, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
ver, err = process.communicate()
|
||||
retcode = process.wait()
|
||||
if retcode == 0:
|
||||
version = ver.strip()
|
||||
if isinstance(version, bytes):
|
||||
version = version.decode()
|
||||
return version
|
||||
else:
|
||||
logger.debug(f"Error getting git version: {err}")
|
||||
except OSError:
|
||||
logger.exception("Error runing git describe")
|
||||
return "?"
|
||||
|
||||
def main():
|
||||
|
||||
@@ -423,4 +462,7 @@ def main():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
try:
|
||||
main()
|
||||
except:
|
||||
logger.exception("Fatal error in main loop")
|
||||
@@ -41,6 +41,7 @@ install_systemd_service()
|
||||
KSPATH_ESC=$(sed "s/\//\\\\\//g" <<< $KSPATH)
|
||||
KSENV_ESC=$(sed "s/\//\\\\\//g" <<< $KSENV)
|
||||
|
||||
SERVICE=$(sed "s/KS_USER/$USER/g" <<< $SERVICE)
|
||||
SERVICE=$(sed "s/KS_ENV/$KSENV_ESC/g" <<< $SERVICE)
|
||||
SERVICE=$(sed "s/KS_DIR/$KSPATH_ESC/g" <<< $SERVICE)
|
||||
|
||||
@@ -58,7 +59,7 @@ start_KlipperScreen() {
|
||||
sudo systemctl start KlipperScreen
|
||||
}
|
||||
|
||||
#install_packages
|
||||
install_packages
|
||||
create_virtualenv
|
||||
install_systemd_service
|
||||
update_x11
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
websocket==0.2.1
|
||||
requests==2.24.0
|
||||
requests==2.25.0
|
||||
vext==0.7.4
|
||||
websocket-client==0.57.0
|
||||
humanize==2.5.0
|
||||
humanize==3.1.0
|
||||
jinja2==2.11.2
|
||||
@@ -7,10 +7,9 @@ StartLimitIntervalSec=0
|
||||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=1
|
||||
User=pi
|
||||
User=KS_USER
|
||||
WorkingDirectory=KS_DIR
|
||||
ExecStart=/usr/bin/xinit KS_ENV/bin/python KS_DIR/screen.py
|
||||
ExecStartPost=KS_DIR/scripts/disablescreenblank.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,47 +1,47 @@
|
||||
|
||||
#
|
||||
import re
|
||||
import base64
|
||||
|
||||
dir = "/home/pi/sdcard/"
|
||||
file = "square_tower_0.2mm_PLA_ENDER3_46m.gcode"
|
||||
#f = f.open(file, 'r')
|
||||
|
||||
thumbnails = []
|
||||
cur_thumbnail = {}
|
||||
state = 0
|
||||
with open(dir + file, 'r') as f:
|
||||
for line in f:
|
||||
if state == 0:
|
||||
match = re.match(r'^; thumbnail begin ([0-9]+)x([0-9]+) ([0-9]+)', line)
|
||||
if match:
|
||||
cur_thumbnail = {
|
||||
"width": match.group(1),
|
||||
"height": match.group(2),
|
||||
"size": match.group(3),
|
||||
"data": ""
|
||||
}
|
||||
state = 1
|
||||
continue
|
||||
elif state == 1:
|
||||
if re.match (r'^; thumbnail end', line):
|
||||
state = 0
|
||||
thumbnails.append(cur_thumbnail)
|
||||
continue
|
||||
match = re.match(r'^; (\S+)$', line)
|
||||
if match:
|
||||
cur_thumbnail['data'] += match.group(1)
|
||||
|
||||
if len(thumbnails) > 0:
|
||||
biggest = 0
|
||||
for i in range(len(thumbnails)):
|
||||
if i == 0:
|
||||
continue
|
||||
if thumbnails[i]['width'] > thumbnails[biggest]['width']:
|
||||
biggest = i
|
||||
|
||||
image = base64.decodestring(thumbnails[biggest]['data'])
|
||||
name = file.split('.gcod')[0] + ".png"
|
||||
f = open(dir + name, 'wb')
|
||||
f.write(image)
|
||||
f.close()
|
||||
|
||||
#
|
||||
import re
|
||||
import base64
|
||||
|
||||
dir = "/home/pi/sdcard/"
|
||||
file = "square_tower_0.2mm_PLA_ENDER3_46m.gcode"
|
||||
#f = f.open(file, 'r')
|
||||
|
||||
thumbnails = []
|
||||
cur_thumbnail = {}
|
||||
state = 0
|
||||
with open(dir + file, 'r') as f:
|
||||
for line in f:
|
||||
if state == 0:
|
||||
match = re.match(r'^; thumbnail begin ([0-9]+)x([0-9]+) ([0-9]+)', line)
|
||||
if match:
|
||||
cur_thumbnail = {
|
||||
"width": match.group(1),
|
||||
"height": match.group(2),
|
||||
"size": match.group(3),
|
||||
"data": ""
|
||||
}
|
||||
state = 1
|
||||
continue
|
||||
elif state == 1:
|
||||
if re.match (r'^; thumbnail end', line):
|
||||
state = 0
|
||||
thumbnails.append(cur_thumbnail)
|
||||
continue
|
||||
match = re.match(r'^; (\S+)$', line)
|
||||
if match:
|
||||
cur_thumbnail['data'] += match.group(1)
|
||||
|
||||
if len(thumbnails) > 0:
|
||||
biggest = 0
|
||||
for i in range(len(thumbnails)):
|
||||
if i == 0:
|
||||
continue
|
||||
if thumbnails[i]['width'] > thumbnails[biggest]['width']:
|
||||
biggest = i
|
||||
|
||||
image = base64.decodestring(thumbnails[biggest]['data'])
|
||||
name = file.split('.gcod')[0] + ".png"
|
||||
f = open(dir + name, 'wb')
|
||||
f.write(image)
|
||||
f.close()
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||
KSPATH=$(sed 's/\/scripts//g' <<< $SCRIPTPATH)
|
||||
KSENV="${HOME}/.KlipperScreen-env"
|
||||
|
||||
update_virtualenv()
|
||||
{
|
||||
echo "Creating virtual environment"
|
||||
[ ! -d ${KSENV} ] && virtualenv -p /usr/bin/python3 ${KSENV}
|
||||
|
||||
${KSENV}/bin/pip install -r ${KSPATH}/scripts/KlipperScreen-requirements.txt
|
||||
${KSENV}/bin/pip install --no-binary ":all" "vext.gi==0.7.4"
|
||||
${KSENV}/bin/vext -e
|
||||
}
|
||||
|
||||
update_virtualenv
|
||||
@@ -19,6 +19,10 @@ scrollbar slider {
|
||||
background-color: #404E57;
|
||||
}
|
||||
|
||||
label {
|
||||
color: white;
|
||||
}
|
||||
|
||||
frame {
|
||||
color: #fff;
|
||||
border-bottom: 1px solid #444;
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
sodipodi:docname="emergency.svg"
|
||||
inkscape:version="1.0 (4035a4fb49, 2020-05-01)"
|
||||
version="1.1"
|
||||
id="svg4160"
|
||||
viewBox="0 0 60.137677 60.776516"
|
||||
height="60.776516"
|
||||
width="60.13768">
|
||||
<defs
|
||||
id="defs4162">
|
||||
<rect
|
||||
id="rect35"
|
||||
height="75.089285"
|
||||
width="56.160714"
|
||||
y="3.7185006"
|
||||
x="-24.056441" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
inkscape:document-rotation="0"
|
||||
inkscape:snap-global="false"
|
||||
inkscape:snap-bbox="true"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:window-y="-11"
|
||||
inkscape:window-x="-11"
|
||||
inkscape:window-height="2066"
|
||||
inkscape:window-width="3840"
|
||||
showguides="false"
|
||||
units="in"
|
||||
showgrid="true"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:document-units="px"
|
||||
inkscape:cy="30.217279"
|
||||
inkscape:cx="2.3098192"
|
||||
inkscape:zoom="11.313709"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
borderopacity="1.0"
|
||||
bordercolor="#666666"
|
||||
pagecolor="#ffffff"
|
||||
id="base">
|
||||
<inkscape:grid
|
||||
originy="-29.820954"
|
||||
originx="-9.9771178"
|
||||
id="grid4712"
|
||||
type="xygrid" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata4165">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
transform="translate(-3.5328446,2.2636422)"
|
||||
style="display:inline"
|
||||
inkscape:label="Move"
|
||||
id="layer2"
|
||||
inkscape:groupmode="layer">
|
||||
<g
|
||||
id="g46"
|
||||
transform="translate(-6.0411758,-15.071814)">
|
||||
<path
|
||||
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 22.795553,16.619161 3.21242,-1.25 3.212421,1.25 v 47.687531 l -3.212421,0.892857 -3.21242,-0.892857 z"
|
||||
id="rect4760-8"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccccc" />
|
||||
<ellipse
|
||||
style="fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#d40000;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path4508"
|
||||
cx="39.64286"
|
||||
cy="43.19643"
|
||||
rx="29.040764"
|
||||
ry="29.130053" />
|
||||
</g>
|
||||
<text
|
||||
transform="translate(47.1875,-4.8214286)"
|
||||
style="font-style:normal;font-weight:normal;font-size:53px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect35);fill:#d40000;fill-opacity:1;stroke:none;"
|
||||
id="text33"
|
||||
xml:space="preserve"><tspan
|
||||
x="-26"
|
||||
y="52.376338"><tspan
|
||||
style="font-weight:bold;font-size:53px;fill:#d40000">!</tspan></tspan></text>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.3 KiB |