#####################################################################
# Display Menu definition
#####################################################################

# Removed items
[menu __main __octoprint]
type: disabled

##  PreHeat
[menu __main __temp __preheat_pla]
type: disabled

[menu __main __temp __preheat_abs]
type: disabled

##  use own load and unload macro
[menu __main __filament __loadf]
type: disabled

[menu __main __filament __loads]
type: disabled

[menu __main __filament __unloadf]
type: disabled

[menu __main __filament __unloads]
type: disabled

# Bed Probe
[menu __main __setup __calib __bedprobe]
type: disabled

##  Delta Calibration
[menu __main __setup __calib __delta_calib_auto]
type: disabled

[menu __main __setup __calib __delta_calib_man]
type: disabled


# Added Items to the Stock menu
[menu __main __filament __preheat_pla]
type: command
name: Preheat for PLA
gcode:
  PREHEAT EXTRUDER_TEMP=190

[menu __main __filament __preheat_abs]
type: command
name: Preheat for ABS
gcode:
  PREHEAT EXTRUDER_TEMP=210

[menu __main __filament __load]
type: command
name: Load Filament
gcode:
  FILAMENT_LOAD

[menu __main __filament __unload]
type: command
name: Unload Filament
gcode:
  FILAMENT_UNLOAD

[menu __main __filament __purge]
type: command
name: Purge Filament (10mm)
gcode:
  FILAMENT_PURGE

[menu __main __setup __calib __home]
type: command
enable: {not printer.idle_timeout.state == "Printing"}
name: Home
gcode:
  G28

[menu __main __setup __calib __center]
type: command
enable: {not printer.idle_timeout.state == "Printing"}
name: Center
gcode:
  CENTER

[menu __main __setup __calib __bedprobe]
type: command
enable: {not printer.idle_timeout.state == "Printing"}
name: Bed probe
gcode:
  PROBE

## Probe & Endstop Z-Offset calibration
[menu __main __setup __calib __Z_offset]
type: list
enable: {not printer.idle_timeout.state == "Printing"}
name: Z offset

[menu __main __setup __calib __Z_offset __start]
type: input
enable: {not printer.idle_timeout.state == "Printing"}
name: Do {['None','Home','Probe','Endstop'][menu.input|int]}
input: 0
input_min: 0
input_max: 3
input_step: 1
gcode:
  {%- if menu.event == 'long_click' -%}
    {menu.back()}
  {%- endif -%}
  {%- if menu.input|int == 1 -%}
    {action_respond_info("Start Homing")}
    G28
    CENTER
  {%- elif menu.input|int == 2 -%}
    {% if "xyz" in printer.toolhead.homed_axes %}
      {action_respond_info("Start Probe calibration")}
      CENTER
      PROBE_CALIBRATE
    {%- else -%}
      {action_respond_info("Printer not homed")}
    {%- endif -%}
  {%- elif menu.input|int == 3 -%}
    {% if "xyz" in printer.toolhead.homed_axes %}
      {action_respond_info(" Start Z-Endstop calibration")}
      CENTER
      Z_ENDSTOP_CALIBRATE
    {%- else -%}
      {action_respond_info("Printer not homed")}
    {%- endif -%}
  {%- endif -%}


[menu __main __setup __calib __Z_offset __move_z]
type: input
name: Move Z: {'%03.2f' % menu.input}
input: {printer.gcode_move.gcode_position.z}
input_step: 1
realtime: True
gcode:
  {%- if menu.event == 'change' -%}
    G1 Z{'%.2f' % menu.input}
  {%- elif menu.event == 'long_click' -%}
    G1 Z{'%.2f' % menu.input}
    SAVE_GCODE_STATE NAME=__move__axis
    G91
    G1 Z2
    G1 Z-2
    RESTORE_GCODE_STATE NAME=__move__axis
  {%- endif -%}

[menu __main __setup __calib __Z_offset __test_z]
type: input
name: Test Z: {['++','+','+.01','+.05','+.1','+.5','-.5','-.1','-.05','-.01','-','--'][menu.input|int]}
input: 5
input_min: 0
input_max: 11
input_step: 1
gcode:
  {%- if menu.event == 'long_click' -%}
    TESTZ Z={['++','+','+.01','+.05','+.1','+.5','-.5','-.1','-.05','-.01','-','--'][menu.input|int]}
  {%- endif -%}

[menu __main __setup __calib __Z_offset __test_z_live]
type: input
name: Test Z : {'%03.3f' % menu.input}
input: 0
input_min: -5.0
input_max: 5.0
input_step: 0.01
realtime: True
gcode:
  {%- if menu.event == 'long_click' -%}
    TESTZ Z={'%.3f' % menu.input}
  {%- endif -%}

[menu __main __setup __calib __Z_offset __accept]
type: command
name: Accept
gcode: ACCEPT

[menu __main __setup __calib __Z_offset __abort]
type: command
name: Abort
gcode: ABORT

[menu __main __setup __calib __Z_offset __saveconfig]
type: command
name: Save config
gcode: SAVE_CONFIG