Skip to content

Commit

Permalink
Update (#1)
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
DmitriyAD committed Aug 11, 2022
1 parent f2aa4bc commit 460c915
Show file tree
Hide file tree
Showing 487 changed files with 34,178 additions and 24,781 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.idea/
KlipperScreen.conf
__pycache__/
*.py[cod]
*$py.class
dist/
build/
venv/
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# KlipperScreen
## Z-BoltUI
KlipperScreen is touchscreen GUI for Klipper based 3D printers. KlipperScreen interfaces with [Klipper](https://github.com/kevinOConnor/klipper) via [Moonraker](https://github.com/arksine/moonraker).

KlipperScreen is a touchscreen GUI that interfaces with [Klipper](https://github.com/kevinOConnor/klipper) via [Moonraker](https://github.com/arksine/moonraker). It can switch between multiple printers to access them from a single location, and it doesn't even need to run on the same host, you can install it on another device and configure the IP address to access the printer.

### Documentation [![Documentation Status](https://readthedocs.org/projects/klipperscreen/badge/?version=latest)](https://klipperscreen.readthedocs.io/en/latest/?badge=latest)

[Click here to access the documentation.](https://klipperscreen.readthedocs.io/en/latest/)

### Inspiration
KlipperScreen was inspired by [OctoScreen](https://github.com/Z-Bolt/OctoScreen/) and the need for a touchscreen GUI that
will natively work with [Klipper](https://github.com/kevinOConnor/klipper) and [Moonraker](https://github.com/arksine/moonraker).

[![Main Menu](docs/img/panels/main_panel.png)](https://klipperscreen.readthedocs.io/en/latest/Panels/)

[More Screenshots](https://klipperscreen.readthedocs.io/en/latest/Panels/)
27 changes: 27 additions & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Changelog

Breaking changes will be listed here.

#### [2022 03 21](https://github.com/jordanruthe/KlipperScreen/commit/bc34b3c8d6761c27a0b0c62fc4dfa11442b417f6)
* Default configuration is now merged again.
Fixing [2021 05 20](https://github.com/jordanruthe/KlipperScreen/commit/eb801486928bf02709033dcbc5f0a45ca43b23c1)

#### [2022 03 10](https://github.com/jordanruthe/KlipperScreen/commit/490dc929bd11e3c4200b999ce7204d84fa0bc184)
* The "Power On Printer" button now requires power_devices under the printer section in KlipperScreen.conf
the power_devices allowed are those defined in the config of moonraker of the printer
The "Power" panel will be in the Menu if there are power devices found

#### [2022 03 01](https://github.com/jordanruthe/KlipperScreen/commit/49ab84e8d51535d3469d97fdee53099cca6abc39)
* The "Power On Printer" button now requires that the printer name in KlipperScreen.conf
and the power device in moonraker.conf to have the same name.
The "Power" panel will be in the Menu if there are power devices found

#### [2022 01 11](https://github.com/jordanruthe/KlipperScreen/commit/8a8c6c064cc6d097b1b34a5c42b4001367e545a6)
* The Preheat panel has been deprecated in favor of an all in one Temperature panel

Remove preheat panel from your Klipperscreen.conf or replace the occurrences of preheat with temperature

#### [2021 05 20](https://github.com/jordanruthe/KlipperScreen/commit/eb801486928bf02709033dcbc5f0a45ca43b23c1)
* Default configuration is not merged if a user configuration is set for a specific option

For instance, if `menu __main` is user defined, the main menu will not have any defaults.
124 changes: 96 additions & 28 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,30 @@
# Configuration

The configuration options are outlined below:
Usually you don't need to create a configuration file, but if you need to change something that is not changeable in the UI
create a blank file in `~/klipper_config/KlipperScreen.conf`, if the file already exist then just edit it.

KlipperScreen will search for a configuration file in the following order:

1. _~/KlipperScreen.conf_
2. _${KlipperScreen_Directory}/KlipperScreen.conf_
3. _~/klipper_config/KlipperScreen.conf_

If one of those files are found, it will be used over the default configuration. The default configuration will be
merged with the custom configuration, so if you do not define any menus the default menus will be used.

The default config is included here: (do not edit use as reference)
_${KlipperScreen_Directory}/ks_includes/default.conf_

If no config file is found then a new configuration file will be created in:
_~/klipper_config/KlipperScreen.conf_ Or _~/KlipperScreen.conf_
Write in the file only the options that need to be changed, and restart KlipperScreen.

## Include files
```
```py
[include conf.d/*.conf]
# Include another configuration file. Wildcards (*) will expand to match anything.
```


## Main Options
```
```py
[main]
# Invert axis in move panel. Default is False. Change to true to invert
invert_x: False
invert_y: False
invert_z: False

# Time (seconds) before the Job Status page reverts to main menu after a successful job
job_complete_timeout: 30
# Time in seconds before the Job Status page closes itself after a successful job/print
# 0 means disabled
job_complete_timeout: 0

# Time (seconds) before the Job Status page reverts to main menu after a successful job.
# If this option is 0, the user must click on a button to go back to the main menu.
# Time in seconds before the Job Status closes itself if an error is encountered
job_error_timeout: 0

# Specify the language
Expand All @@ -45,11 +33,22 @@ language: en

# Allows the cursor to be displayed on the screen
show_cursor: False

# Allows to define custom systemctl command for restart like xrdp
service: KlipperScreen

# If multiple printers are defined, this can be set the name of the one to show at startup.
default_printer: Ender 3 Pro

# To define a full set of custom menues (instead of merging user entries with default entries)
# set this to False. See Menu section below.
use_default_menu: True

```

## Printer Options
Multiple printers can be defined
```
```py
# Define printer and name. Name is anything after the first printer word
[printer Ender 3 Pro]
# Define the moonraker host/port if different from 127.0.0.1 and 7125
Expand All @@ -60,30 +59,77 @@ moonraker_api_key: False

# Define the z_babystep intervals in a CSV list. Currently only 2 are supported
z_babystep_values: 0.01, 0.05
```

# Override the movement speed and set a specific for this printer.
# These setting overrides the settings configured in the UI. If specified,
# the values configured in the UI will not be used.
move_speed_xy: 500
move_speed_z: 300

# Define one or more moonraker power devices that turn on this printer (CSV list)
# Default is the printer name
power_devices: example1, example2

# Define what items should be shown in titlebar besides the extruder and bed
# the name must be the same as defined in the klipper config
# valid options are temperature_sensors or temperature_fans, or heater_generic
titlebar_items: chamber, MCU, Pi

# The style of the user defined items in the titlebar
# Can be 'full' indicating that the full name is shown, 'short' for the first letter, or None (default) for no name
titlebar_name_type: None

# Z probe calibrate position
# By default is the middle of the bed
calibrate_x_position: 100
calibrate_y_position: 100

# Screen DPMS
# By default DPMS is used to turn off the screen, this should prevent burn-in and save power.
# However if you find that your screen doesn't turn off because it doesn't support it
# Setting this to false will just turn the screen black.
use_dpms: True
```

## Preheat Options
```
```py
[preheat my_temp_setting]
# Temperature for the heated bed
bed: 40
# Temperature for the tools
extruder: 195
# Temperature for generic heaters
heater_generic: 40
# Temperature controlled fans (temperature_fan in klipper config)
temperature_fan: 40
# optional GCode to run when the option is selected
gcode: MY_HEATSOAK_MACRO
```

There is a special preheat setting named cooldown to do additional things when the _cooldown_ button is pressed
for example:

```py
[preheat cooldown]
gcode: M107
```

## Bed Screws
```py
[bed_screws]
# Rotation is useful if the screen is not directly in front of the machine.
# Valid values are 0 90 180 270
rotation: 0
```

## 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. 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:
```
```py
[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
Expand All @@ -99,10 +145,10 @@ params: {"script":"G28 X"}
# Available variables are listed below.
enable: {{ printer.power_devices.count > 0 }}
```
Available panels are listed here: [docs/panels.md](panels.md)
Available panels are listed here: [docs/panels.md](Panels.md)

Certain variables are available for conditional testing of the enable statement:
```
```py
printer.bltouch # Available if bltouch section defined in config
printer.gcode_macros.count # Number of gcode macros
printer.idle_timeout # Idle timeout section
Expand All @@ -113,7 +159,7 @@ printer.power_devices.count # Number of power devices configured in Moonraker


A sample configuration of a main menu would be as follows:
```
```py
[menu __main homing]
name: Homing
icon: home
Expand All @@ -134,3 +180,25 @@ icon: home
method: printer.gcode.script
params: {"script":"G28"}
```

## KlipperScreen behaviour towards configuration

KlipperScreen will search for a configuration file in the following order:

1. _~/KlipperScreen.conf_
2. _${KlipperScreen_Directory}/KlipperScreen.conf_
3. _~/klipper_config/KlipperScreen.conf_

If you need a custom location for the configuration file, you can add -c or --configfile to the systemd file and specify
the location of your configuration file.

If one of those files are found, it will be merged with the default configuration.
Default Preheat options will be discarded if a custom preheat is found.
If include files are defined then, they will be merged first.

The default config is included here: (do not edit use as reference)
_${KlipperScreen_Directory}/ks_includes/default.conf_

Preferably *do not* copy the entire default.conf file, just configure the settings needed.

If no config file is found, then when a setting is changed in the settings panel, a new configuration file will be created automatically.
4 changes: 1 addition & 3 deletions docs/Contact.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ You may submit a GitHub issue request for any problems you are having.

## Klipper Community Discord

The invite link: https://discord.klipper3d.org/

Look for the channel `#klipper-screen`
[Look for the channel `#klipper-screen`](https://discord.klipper3d.org/)
81 changes: 37 additions & 44 deletions docs/Hardware.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Hardware

There are no recommended screens, but here are some guidelines:

* There is no support for vertical/portrait mode, only widescreen
* Minimum resolution of 480x320
There are no recommended screens, but the minimum supported resolution is 480x320

#### Hardware known to work

Expand All @@ -14,68 +11,64 @@ There are no recommended screens, but here are some guidelines:
* [3.5" RPi Display](http://www.lcdwiki.com/3.5inch_RPi_Display)
* [5" HDMI Display-B](http://lcdwiki.com/5inch_HDMI_Display-B)
* [VoCore](https://klipper.discourse.group/t/hardware-known-to-work-with-klipperscreen/35/7)
* [Android Phone](https://klipper.discourse.group/t/hardware-known-to-work-with-klipperscreen/35/8)
* [Android Phone](https://klipper.discourse.group/t/how-to-klipperscreen-on-android-smart-phones/1196)
* [WAVESHARE 4.3 inch DSI LCD](https://www.waveshare.com/4.3inch-dsi-lcd.htm)
* [DFrobot DFR0550](https://wiki.dfrobot.com/5%27%27TFT-Display_with_Touchscreen_V1.0_SKU_DFR0550)

* [More known hardware in the klipper discourse](https://klipper.discourse.group/t/hardware-known-to-work-with-klipperscreen/35)

#### Configuration
### Configuration

Follow the manufacturer instructions on how to install your screen. In general if you see a white screen, then it's not properly installed, ensure that you at least see a console, Then ![install](Installation.md) KlipperScreen, if you are having troubles refer to the ![troubleshooting page](Troubleshooting.md) for further information.

#### Touchscreen Calibration
Most people don't need to calibrate, but if you do need to calibrate your touchscreen, follow the below steps.

Run this command:
```
DISPLAY=:0 xinput_calibrator --list
```
It will output something such as:
```
Device "wch.cn USB2IIC_CTP_CONTROL" id=6
## Touchscreen touch rotation
If your touchscreen isn't registering touches properly after the screen has been rotated, you will need to apply a
transformation matrix.

First you will need your device name, on a terminal run:

```sh
DISPLAY=:0 xinput
```

Find the ID of your display and put it in the following command:
Output:
```sh
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ ADS7846 Touchscreen id=6 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
```
DISPLAY=:0 xinput_calibrator -v --device <id from last command>
In this case the device is the ADS7846 Touchscreen, yours may be different

You can test a change by running:

```sh
DISPLAY=:0 xinput set-prop "<device name>" 'Coordinate Transformation Matrix' <matrix>
```

#### Touchscreen touch rotation
If your touchscreen isn't registering touches properly after the screen has been rotated, you will need to apply a
transformation matrix. You can have the matrix be one of the following:
Where the matrix can be one of the following options:

* 0°: `1 0 0 0 1 0 0 0 1`
* 90° Clockwise: `0 -1 1 1 0 0 0 0 1`
* 90° Counter-Clockwise: `0 1 0 -1 0 1 0 0 1`
* 180°: `-1 0 1 0 -1 1 0 0 1`
* 180° (Inverts X and Y): `-1 0 1 0 -1 1 0 0 1`
* invert Y: `-1 0 1 1 1 0 0 0 1`
* invert X: `-1 0 1 0 1 0 0 0 1`

To check the current matrix, you will need your `<screen name>`
(which can be found via the last section, ex: "wch.cn USB2IIC_CTP_CONTROL").
Run the following command: `xinput list-props "wch.cn USB2IIC_CTP_CONTROL"`
For example:

It will output something such as:
```sh
DISPLAY=:0 xinput set-prop "ADS7846 Touchscreen" 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1
```
Device '<screen name>':
Device Enabled (115): 1
Coordinate Transformation Matrix (116): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
libinput Calibration Matrix (247): -1.000000, 0.000000, 1.000000, 0.000000, -1.000000, 1.000000, 0.000000, 0.000000, 1.000000
libinput Calibration Matrix Default (248): -1.000000, 0.000000, 1.000000, 0.000000, -1.000000, 1.000000, 0.000000, 0.000000, 1.000000
libinput Send Events Modes Available (249): 1, 0
libinput Send Events Mode Enabled (250): 0, 0
libinput Send Events Mode Enabled Default (251): 0, 0
Device Node (252): "/dev/input/event0"
Device Product ID (253): 6790, 58083
```

You can verify by checking that the 'Coordinate Transformation Matrix' or 'libinput Calibration Matrix'.

You can test a change by running: `xinput set-prop "<screen name>" 'Coordinate Transformation Matrix' <matrix>`

Replace matrix with one of the options above, such as: `1 0 0 0 1 0 0 0 1`

To make this permanent, modify the file `/etc/udev/rules.d/51-touchscreen.rules` and add following line:

```sh
ACTION=="add", ATTRS{name}=="<device name>", ENV{LIBINPUT_CALIBRATION_MATRIX}="<matrix>"
```
ACTION=="add", ATTRS{name}=="<screen name>", ENV{LIBINPUT_CALIBRATION_MATRIX}="<matrix>"
```
More info about input transformation can be found in:

* [Ubuntu wiki InputCoordinateTransformation](https://wiki.ubuntu.com/X/InputCoordinateTransformation)
* [Libinput docs](https://wayland.freedesktop.org/libinput/doc/1.9.0/absolute_axes.html)
Loading

0 comments on commit 460c915

Please sign in to comment.