docs: Add DGUS display documentation

This commit is contained in:
Desuuuu 2021-09-10 01:08:27 +02:00
parent 283ca4d3be
commit ea372e1d19
No known key found for this signature in database
GPG Key ID: 85943F4B2C2CE0DC
3 changed files with 406 additions and 0 deletions

View File

@ -305,6 +305,71 @@ The following actions are available in menu templates:
* When `<force>` is set True then it will also stop editing. Default
value is False.
## T5UID1 DGUSPrinterMenu templates
If a [dgus_display config section](Config_Reference.md#dgus-display-support) is
enabled with a [T5UID1 display](Config_Reference.md#t5uid1-display) and the
[DGUSPrinterMenu implementation](Config_Reference.md#t5uid1-display-dgusprintermenu),
then it is possible to customize the menus with
[dgus_menu](Config_Reference.md#dgus_menu) config sections.
The following read-only attributes are available:
* `params`: dict containing the parameters passed to the menu. Not available in
the `condition` template.
The following functions are available:
* `get_volume()`: returns the current display volume.
* `get_brightness()`: returns the current display brightness.
* `format_duration(seconds)`: formats the `<seconds>` duration to a
human-readable string and returns it.
* `wrap_text(text, len[, max])`: splits `<text>` into lines of less than
`<len>` characters and returns the resulting list.
* When `<max>` is provided, only the first `<max>` lines are returned.
* `map_range(value, imin, imax, omin, omax)`: maps the value `<value>`, ranging
from `<imin>` to `<imax>`, to a value ranging from `<omin>` to `<omax>` and
returns it.
* `parse_boolean(value)`: parses the string `<value>` as a boolean and
returns it.
* `sd_filename(path)`: removes the virtual sdcard path from the beginning of
`<path>` and returns the result.
* `get_field_value()`: returns the value of the input field. Only available for
`number_input` and `text_input` menus.
Additionally, for script templates, the following functions are available:
* `play_sound(start[, slen][, volume])`: plays the sound stored at index
`<start>` on the display.
* `<slen>` is the number of blocks occupied by the sound. Default to 1.
* `<volume>` ranges from 0 to 100 and defaults to the current volume if not
provided.
* `stop_sound()`: stops any currently playing sound.
* `set_volume(volume[, save])`: sets the volume to `<volume>` (ranging from
0 to 100).
* When `<save>` is True, the value is updated in the config. Defaults to
False.
* `set_brightness(brightness[, save])`: sets the brightness to `<brightness>`
(ranging from 0 to 100).
* When `<save>` is True, the value is updated in the config. Defaults to
False.
* `request_update()`: requests a display update.
* `set_menu(name[, silent], ...)`: switches to the menu named `<name>`.
* When `<silent>` is False, a sound is played when the menu is switched.
Defaults to False.
* `go_back([force][, silent])`: switches to the parent menu.
* When `<force>` is False, the switch only happens if the back button is
currently enabled. Defaults to False.
* When `<silent>` is False, a sound is played when the menu is switched.
Defaults to False.
* `set_message(message)`: sets the display status message to `<message>`.
* `set_title(title)`: sets the menu title to `<title>`.
* `set_back_enabled(state)`: sets the state of the menu back button to
`<state>`.
* `set_field_value(value)`: sets the value of the input field to `<value>`. Only
available for `number_input` menus.
* `set_field_value(text[, input_text])`: sets the value of the input field to
`<text>`. Only available for `text_input` menus.
* When `<input_text>` is provided, sets the value of the underlying input to
`<input_text>`.
## Save Variables to disk
<!-- {% raw %} -->

View File

@ -3629,6 +3629,287 @@ information on menu attributes available during template rendering.
# mode start or end.
```
## DGUS Display support
### [dgus_display]
Support for a DGUS display attached to the micro-controller via UART. One
may define any number of sections with a "dgus_display" prefix. If no
prefix is provided, the display's name is set to "default".
```
[dgus_display]
type:
# The type of DGUS display. Currently only "t5uid1" displays are
# supported. This parameter must be provided.
#uart_mcu:
# The name of the micro-controller that the chip is connected to.
# The default is "mcu".
#uart_bus:
# If the micro-controller supports multiple UART busses then one may
# specify the micro-controller bus name here. The default depends on
# the type of micro-controller.
#uart_baud:
# The baud rate to use when communicating with the device. The
# default is 115200.
#uart_rx_buffer:
# The size of the receive buffer (in bytes) used by the
# micro-controller. The default is 96.
#uart_tx_buffer:
# The size of the transmit buffer (in bytes) used by the
# micro-controller. The default is 192.
#uart_rx_interval:
# The interval (in milliseconds) at which the receive buffer will be
# flushed by the micro-controller. If this value is 0, the buffer is flushed
# only when it is close to full. The default is 25.
```
### T5UID1 Display
Information on configuring a T5UID1 display. Also see the
[command reference](G-Codes.md#dgus-display-commands).
```
[dgus_display]
type: t5uid1
implementation:
# The implementation to use for the display. This may be
# "dgus_printer_menu" or "debug" (see below). This parameter must be
# provided.
#volume:
# The volume for the display's speaker. The value may range from 0 to 100 and
# the default is 75.
#brightness:
# The display's brightness. The value may range from 0 to 100 and the default
# is 100.
...
```
## T5UID1 Display DGUSPrinterMenu
The DGUSPrinterMenu T5UID1 implementation supports dynamic menus. It is
designed to work with the
[DGUSPrinterMenu](https://github.com/Desuuuu/DGUSPrinterMenu) touchscreen
firmware. Also see the [command reference](G-Codes.md#dgus-display-commands).
```
[dgus_display]
type: t5uid1
implementation: dgus_printer_menu
#message_timeout:
# The timeout for status messages (in seconds). The default is 30.
#shutdown_text:
# The message to display on the shutdown page. The default is
# "Printer is shutdown!".
...
```
### [dgus_home]
Home menu customization. If this section is not provided, the home
configuration is loaded from the
[default menus](../klippy/extras/dgus_display/t5uid1/dpm/menu.cfg).
```
[dgus_home]
#display:
# The name of the display that this section targets. The default is
# "default".
#param_e1:
# The name of the config section for the first extruder. The default is
# "extruder".
#param_e2:
# The name of the config section for the second extruder. The default is
# "extruder1".
#param_bed:
# The name of the config section for the heated bed. The default is
# "heater_bed".
#param_fan:
# The name of the config section for the fan. The default is "fan".
...
```
### [dgus_menu]
Customizable display menus.
A [default set of menus](../klippy/extras/dgus_display/t5uid1/dpm/menu.cfg)
is loaded if no menu was defined in the main printer.cfg config file. If you
want to modify a menu, copy the default menus to your config file and make
your modifications there.
See the
[command template document](Command_Templates.md#t5uid1-dgusprintermenu-templates)
for information on attributes available during template rendering.
```
# Common parameters available for all dgus_menu config sections.
#[dgus_menu some_name]
#display:
# The name of the display that this section targets. The default is
# "default".
#type:
# One of "list", "vsdlist", "text", "number_input", "text_input", "command":
# list - displays its children as buttons in a scrollable list.
# A child menu is created by using its parent's name as
# a prefix, for example: [dgus_menu parent child].
# vsdlist - same as 'list' but will append files from virtual
# sdcard. Disabled if virtual sdcard is not configured.
# text - a page that displays some text.
# number_input - a page that allows inputing numerical values.
# text_input - a page that allows inputing text.
# command - special element that runs a script during its setup.
# Since it is not a page, its setup is always aborted.
title:
# The title of the menu. This is displayed in the upper left corner of the
# menu and on the menu's button in case it is the child of a list menu.
#back:
# When False, the back button in the upper left corner is disabled. The
# default is True.
#condition:
# Template that evaluates to True or False. This template is only evaluated
# after the printer enters the "ready" state. If it evaluates to False,
# the menu is considered disabled and cannot be entered. The 'params' dict
# is not available in this template.
#enable:
# Template that evaluates to True or False. This template is evaluated
# on every menu update. If it evaluates to False, the menu is considered
# disabled and cannot be entered. If it evaluates to False while the
# menu is active, the display will switch back to its parent menu.
#setup:
# Script to run when the menu is entered. Evaluated as a template. A special
# abort_setup([reason]) function is available to this template. When
# called, it will prevent the menu from being entered. If the reason
# parameter is provided, it will be set as the status message.
#update:
# Script to run on each menu update. Evaluated as a template.
#param_<name>:
# One may specify any number of options with a "param_" prefix. The
# given name will be assigned the given value (parsed as a Python
# literal) and will be available during all macro expansions for this menu
# as an entry in the 'params' dict. If the parameter is passed in the call
# to set_menu() then that value will be used during macro expansion.
# Parameter names may not use upper case characters.
# Text specific parameters.
#[dgus_menu some_text]
#type: text
#text:
# The text to display - evaluated as a template. Will be split into 4 lines
# of 32 characters each.
#line1:
#line2:
#line3:
#line4:
# One may use these parameters instead of the "text" parameter to define
# each line independently. Evaluated as templates. Lines cannot exceed 32
# characters.
#button:
# The text of the button at the bottom of the page. If not specified, no
# button is shown. Cannot exceed 16 characters.
#button_action:
# Script to run when the button is pressed. Evaluated as a template.
# Number input specific parameters.
#[dgus_menu some_number_input]
#type: number_input
#variation:
# Either unspecified or one of "step", "steps" or "slider":
# step - adds up/down arrows to step through values.
# steps - adds up/down arrows to step through values as well as buttons
# to select the active step.
# slider - adds a slider.
#field_title:
# The title of the input field. Cannot exceed 16 characters.
#field_unit:
# The unit of the input field. Cannot exceed 6 characters.
#decimals:
# The number of decimals (ranging from 0 to 5) for the input. The input will
# be treated as an integer if 0. The default is 0.
#min:
# The minimum value for the input - evaluated as a template. The absolute
# minimum value is -999999999999 for 0 decimals. For each extra decimal,
# divide this number by 10. The default is to use the absolute minimum.
# This parameter must be provided for the "slider" variation.
#max:
# The maximum value for the input - evaluated as a template. The absolute
# maximum value is 999999999999 for 0 decimals. For each extra decimal,
# divide this number by 10. The default is to use the absolute maximum.
# This parameter must be provided for the "slider" variation.
#default:
# The content of the input when the menu is entered - evaluated as a
# template. The default is 0.
#input_action:
# Script to run when the input's value is changed. Evaluated as a template.
#button:
# The text of the button at the bottom of the page. If not specified, no
# button is shown. Cannot exceed 16 characters.
#button_action:
# Script to run when the button is pressed. Evaluated as a template.
# Number input "step" variation specific parameters.
#[dgus_menu some_number_input]
#type: number_input
#variation: step
#step:
# The step applied when arrows are pressed. Must be a positive integer or
# float value.
# Number input "steps" variation specific parameters.
#[dgus_menu some_number_input]
#type: number_input
#variation: steps
#steps:
# A comma separated list of up to 3 steps. Each step must be a positive
# integer or float value.
#default_step:
# The active step when the menu is entered. Must be an integer between
# 1 and 3. The default is 1.
# Text input specific parameters.
#[dgus_menu some_text_input]
#type: text_input
#field_title:
# The title of the input field. Cannot exceed 16 characters.
#max_length:
# The maximum number of characters of the input - evaluated as a template.
# Must evaluate to an integer between 1 and 32. The default is 32.
#clear_input:
# When True, clears any previously entered text before editing. The default
# is False.
#default:
# The content of the input when the menu is entered - evaluated as a
# template. The default is an empty string.
#input_action:
# Script to run when the input's value is changed. Evaluated as a template.
#button:
# The text of the button at the bottom of the page. If not specified, no
# button is shown. Cannot exceed 16 characters.
#button_action:
# Script to run when the button is pressed. Evaluated as a template.
# Command specific parameters.
#[dgus_menu some_command]
#type: command
#action:
# Script to run when this command is executed. Evaluated as a template.
```
## T5UID1 Display Debug
The debug T5UID1 implementation provides low-level commands for interacting
with the display.
See the [command reference](G-Codes.md#dgus-display-commands) for more
information.
```
[dgus_display]
type: t5uid1
implementation: debug
...
```
## Filament sensors
### [filament_switch_sensor]

View File

@ -841,3 +841,63 @@ Palette prints work by embedding special OCodes (Omega Codes)
in the GCode file:
- `O1`...`O32`: These codes are read from the GCode stream and processed
by this module and passed to the Palette 2 device.
### DGUS Display Commands
The following commands are available when the
[dgus_display config section](Config_Reference.md#dgus-display-support)
is enabled with a [T5UID1 display](Config_Reference.md#t5uid1-display):
- `DGUS_PLAY_SOUND [DISPLAY=<config_name>] START=<start> [LEN=<len>]
[VOLUME=<volume>]`: Plays the sound stored at index `START` on the display.
`LEN` is the number of blocks occupied by the sound (the default is 1).
`VOLUME` ranges from 0 to 100 and defaults to the current volume if unset.
- `DGUS_STOP_SOUND [DISPLAY=<config_name>]`: Stops any currently playing sound.
- `DGUS_GET_VOLUME [DISPLAY=<config_name>]`: Prints the current volume.
- `DGUS_SET_VOLUME [DISPLAY=<config_name>] VOLUME=<volume> [SAVE=1]`: Sets the
volume (ranging from 0 to 100). If `SAVE` is enabled, the value is updated
in the config. The config can then be persisted by issuing a `SAVE_CONFIG`
command.
- `DGUS_GET_BRIGHTNESS [DISPLAY=<config_name>]`: Prints the current brightness.
- `DGUS_SET_BRIGHTNESS [DISPLAY=<config_name>] BRIGHTNESS=<brightness>
[SAVE=1]`: Sets the brightness (ranging from 0 to 100). If `SAVE` is enabled,
the value is updated in the config. The config can then be persisted by
issuing a `SAVE_CONFIG` command.
The following additional commands are available for the
[DGUSPrinterMenu implementation](Config_Reference.md#t5uid1-display-dgusprintermenu):
- `DGUS_REQUEST_UPDATE [DISPLAY=<config_name>]`: Requests a display update.
- `DGUS_SET_MENU [DISPLAY=<config_name>] MENU=<menu>
[PARAM_<name>=<value>]`: Switches to the menu named `MENU`. Additional
menu parameters can be passed using `PARAM_<name>` parameters.
- `DGUS_SET_MESSAGE [DISPLAY=<config_name>] MESSAGE=<message>`: Sets the
display status message to `MESSAGE`.
The following additional commands are available for the
[debug implementation](Config_Reference.md#t5uid1-display-debug):
- `DGUS_READ [DISPLAY=<config_name>] ADDR=<addr> WLEN=<wlen>`: Reads `WLEN`
words from the display RAM at address `ADDR`.
- `DGUS_WRITE [DISPLAY=<config_name>] ADDR=<addr> [DATA_STR=<data>]
[DATA=<data>]`: Writes data to the display RAM at address `ADDR`. Either
`DATA_STR` (string) or `DATA` (hex string) must be provided.
- `DGUS_SET_PAGE [DISPLAY=<config_name>] PAGE=<page>`: Switches to the page
with id `PAGE`.
- `DGUS_ENABLE_CONTROL [DISPLAY=<config_name>] PAGE=<page> TYPE=<type>
INDEX=<index>`: Enables a touch control. `PAGE` is control page id. `TYPE`
is the type of control. `INDEX` is the index of the control in the page.
- `DGUS_DISABLE_CONTROL [DISPLAY=<config_name>] PAGE=<page> TYPE=<type>
INDEX=<index>`: Disables a touch control. `PAGE` is control page id. `TYPE`
is the type of control. `INDEX` is the index of the control in the page.
- `DGUS_READ_CONTROL [DISPLAY=<config_name>] PAGE=<page> TYPE=<type>
INDEX=<index>`: Reads a touch control data to the display RAM. `PAGE` is
control page id. `TYPE` is the type of control. `INDEX` is the index of
the control in the page.
- `DGUS_WRITE_CONTROL [DISPLAY=<config_name>] PAGE=<page> TYPE=<type>
INDEX=<index> [DATA=<data>]`: Writes a control data from the display RAM.
`PAGE` is control page id. `TYPE` is the type of control. `INDEX` is the
index of the control in the page. If `DATA` (hex string) is specified,
it is written to the display RAM before the control is updated.
- `DGUS_READ_NOR [DISPLAY=<config_name>] NOR_ADDR=<nor_addr> ADDR=<addr>
WLEN=<wlen>`: Reads `WLEN` words from the display NOR at address `NOR_ADDR`,
writing them to the display RAM at address `ADDR`.
For all these commands, the `DISPLAY` parameter defaults to "default".