### menu main ###
[menu __main]
type: list
name: Main

### menu tune ###
[menu __main __tune]
type: list
enable: {printer.idle_timeout.state == "Printing"}
name: Afstellen

[menu __main __tune __speed]
type: input
name: Snelheid: {'%3d' % (menu.input*100)}%
input: {printer.gcode_move.speed_factor}
input_min: 0.01
input_max: 5
input_step: 0.01
realtime: True
gcode:
    M220 S{'%d' % (menu.input*100)}

[menu __main __tune __flow]
type: input
name: Flow: {'%3d' % (menu.input*100)}%
input: {printer.gcode_move.extrude_factor}
input_min: 0.01
input_max: 2
input_step: 0.01
realtime: True
gcode:
    M221 S{'%d' % (menu.input*100)}

[menu __main __tune __offsetz]
type: input
name: Offset Z:{'%05.3f' % menu.input}
input: {printer.gcode_move.homing_origin.z}
input_min: -5
input_max: 5
input_step: 0.005
realtime: True
gcode:
    SET_GCODE_OFFSET Z={'%.3f' % menu.input} MOVE=1

### menu virtual sdcard ###
[menu __main __sdcard]
type: vsdlist
enable: {('virtual_sdcard' in printer)}
name: SD Kaart

[menu __main __sdcard __start]
type: command
enable: {('virtual_sdcard' in printer) and printer.virtual_sdcard.file_path and not printer.virtual_sdcard.is_active}
name: Start printen
gcode: M24

[menu __main __sdcard __resume]
type: command
enable: {('virtual_sdcard' in printer) and printer.print_stats.state == "paused"}
name: Herstart printen
gcode:
    {% if "pause_resume" in printer %}
        RESUME
    {% else %}
        M24
    {% endif %}

[menu __main __sdcard __pause]
type: command
enable: {('virtual_sdcard' in printer) and printer.print_stats.state == "printing"}
name: Pauseer printen
gcode:
    {% if "pause_resume" in printer %}
        PAUSE
    {% else %}
        M25
    {% endif %}

[menu __main __sdcard __cancel]
type: command
enable: {('virtual_sdcard' in printer) and (printer.print_stats.state == "printing" or printer.print_stats.state == "paused")}
name: Annuleer printen
gcode:
    {% if 'pause_resume' in printer %}
        CANCEL_PRINT
    {% else %}
        M25
        M27
        M26 S0
        TURN_OFF_HEATERS
        {% if printer.toolhead.position.z <= printer.toolhead.axis_maximum.z - 5 %}
            G91
            G0 Z5 F1000
            G90
        {% endif %}
    {% endif %}

### menu control ###
[menu __main __control]
type: list
name: Control

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

[menu __main __control __homez]
type: command
enable: {not printer.idle_timeout.state == "Printing"}
name: Home Z
gcode: G28 Z

[menu __main __control __homexy]
type: command
enable: {not printer.idle_timeout.state == "Printing"}
name: Home X/Y
gcode: G28 X Y

[menu __main __control __disable]
type: command
name: Steppers uit
gcode:
    M84
    M18

[menu __main __control __fanonoff]
type: input
enable: {'fan' in printer}
name: Koeling: {'ON ' if menu.input else 'OFF'}
input: {printer.fan.speed}
input_min: 0
input_max: 1
input_step: 1
gcode:
    M106 S{255 if menu.input else 0}

[menu __main __control __fanspeed]
type: input
enable: {'fan' in printer}
name: Snelheid koeler: {'%3d' % (menu.input*100)}%
input: {printer.fan.speed}
input_min: 0
input_max: 1
input_step: 0.01
gcode:
    M106 S{'%d' % (menu.input*255)}

[menu __main __control __caselightonoff]
type: input
enable: {'output_pin caselight' in printer}
name: Verlichting: {'ON ' if menu.input else 'OFF'}
input: {printer['output_pin caselight'].value}
input_min: 0
input_max: 1
input_step: 1
gcode:
    SET_PIN PIN=caselight VALUE={1 if menu.input else 0}

[menu __main __control __caselightpwm]
type: input
enable: {'output_pin caselight' in printer}
name: Verlichting: {'%3d' % (menu.input*100)}%
input: {printer['output_pin caselight'].value}
input_min: 0.0
input_max: 1.0
input_step: 0.01
gcode:
    SET_PIN PIN=caselight VALUE={menu.input}

### menu move 10mm ###
[menu __main __control __move_10mm]
type: list
enable: {not printer.idle_timeout.state == "Printing"}
name: Verplaats 10mm

[menu __main __control __move_10mm __axis_x]
type: input
name: Verplaats X:{'%05.1f' % menu.input}
input: {printer.gcode_move.gcode_position.x}
input_min: {printer.toolhead.axis_minimum.x}
input_max: {printer.toolhead.axis_maximum.x}
input_step: 10.0
gcode:
    SAVE_GCODE_STATE NAME=__move__axis
    G90
    G1 X{menu.input}
    RESTORE_GCODE_STATE NAME=__move__axis

[menu __main __control __move_10mm __axis_y]
type: input
name: Verplaats Y:{'%05.1f' % menu.input}
input: {printer.gcode_move.gcode_position.y}
input_min: {printer.toolhead.axis_minimum.y}
input_max: {printer.toolhead.axis_maximum.y}
input_step: 10.0
gcode:
    SAVE_GCODE_STATE NAME=__move__axis
    G90
    G1 Y{menu.input}
    RESTORE_GCODE_STATE NAME=__move__axis

[menu __main __control __move_10mm __axis_z]
type: input
enable: {not printer.idle_timeout.state == "Printing"}
name: Verplaats Z:{'%05.1f' % menu.input}
input: {printer.gcode_move.gcode_position.z}
input_min: 0
input_max: {printer.toolhead.axis_maximum.z}
input_step: 10.0
gcode:
    SAVE_GCODE_STATE NAME=__move__axis
    G90
    G1 Z{menu.input}
    RESTORE_GCODE_STATE NAME=__move__axis

[menu __main __control __move_10mm __axis_e]
type: input
enable: {not printer.idle_timeout.state == "Printing"}
name: Draai E:{'%+06.1f' % menu.input}
input: 0
input_min: -{printer.configfile.config.extruder.max_extrude_only_distance|default(50)}
input_max: {printer.configfile.config.extruder.max_extrude_only_distance|default(50)}
input_step: 10.0
gcode:
    SAVE_GCODE_STATE NAME=__move__axis
    M83
    G1 E{menu.input} F240
    RESTORE_GCODE_STATE NAME=__move__axis

### menu move 1mm ###
[menu __main __control __move_1mm]
type: list
enable: {not printer.idle_timeout.state == "Printing"}
name: Verplaats 1mm

[menu __main __control __move_1mm __axis_x]
type: input
name: Verplaats X:{'%05.1f' % menu.input}
input: {printer.gcode_move.gcode_position.x}
input_min: {printer.toolhead.axis_minimum.x}
input_max: {printer.toolhead.axis_maximum.x}
input_step: 1.0
gcode:
    SAVE_GCODE_STATE NAME=__move__axis
    G90
    G1 X{menu.input}
    RESTORE_GCODE_STATE NAME=__move__axis

[menu __main __control __move_1mm __axis_y]
type: input
name: Verplaats Y:{'%05.1f' % menu.input}
input: {printer.gcode_move.gcode_position.y}
input_min: {printer.toolhead.axis_minimum.y}
input_max: {printer.toolhead.axis_maximum.y}
input_step: 1.0
gcode:
    SAVE_GCODE_STATE NAME=__move__axis
    G90
    G1 Y{menu.input}
    RESTORE_GCODE_STATE NAME=__move__axis

[menu __main __control __move_1mm __axis_z]
type: input
enable: {not printer.idle_timeout.state == "Printing"}
name: Verplaats Z:{'%05.1f' % menu.input}
input: {printer.gcode_move.gcode_position.z}
input_min: 0
input_max: {printer.toolhead.axis_maximum.z}
input_step: 1.0
gcode:
    SAVE_GCODE_STATE NAME=__move__axis
    G90
    G1 Z{menu.input}
    RESTORE_GCODE_STATE NAME=__move__axis

[menu __main __control __move_1mm __axis_e]
type: input
enable: {not printer.idle_timeout.state == "Printing"}
name: Draai E:{'%+06.1f' % menu.input}
input: 0
input_min: -{printer.configfile.config.extruder.max_extrude_only_distance|default(50)}
input_max: {printer.configfile.config.extruder.max_extrude_only_distance|default(50)}
input_step: 1.0
gcode:
    SAVE_GCODE_STATE NAME=__move__axis
    M83
    G1 E{menu.input} F240
    RESTORE_GCODE_STATE NAME=__move__axis

### menu move 0.1mm ###
[menu __main __control __move_01mm]
type: list
enable: {not printer.idle_timeout.state == "Printing"}
name: Verplaats 0.1mm

[menu __main __control __move_01mm __axis_x]
type: input
name: Verplaats X:{'%05.1f' % menu.input}
input: {printer.gcode_move.gcode_position.x}
input_min: {printer.toolhead.axis_minimum.x}
input_max: {printer.toolhead.axis_maximum.x}
input_step: 0.1
gcode:
    SAVE_GCODE_STATE NAME=__move__axis
    G90
    G1 X{menu.input}
    RESTORE_GCODE_STATE NAME=__move__axis

[menu __main __control __move_01mm __axis_y]
type: input
name: Verplaats Y:{'%05.1f' % menu.input}
input: {printer.gcode_move.gcode_position.y}
input_min: {printer.toolhead.axis_minimum.y}
input_max: {printer.toolhead.axis_maximum.y}
input_step: 0.1
gcode:
    SAVE_GCODE_STATE NAME=__move__axis
    G90
    G1 Y{menu.input}
    RESTORE_GCODE_STATE NAME=__move__axis

[menu __main __control __move_01mm __axis_z]
type: input
enable: {not printer.idle_timeout.state == "Printing"}
name: Verplaats Z:{'%05.1f' % menu.input}
input: {printer.gcode_move.gcode_position.z}
input_min: 0
input_max: {printer.toolhead.axis_maximum.z}
input_step: 0.1
gcode:
    SAVE_GCODE_STATE NAME=__move__axis
    G90
    G1 Z{menu.input}
    RESTORE_GCODE_STATE NAME=__move__axis

[menu __main __control __move_01mm __axis_e]
type: input
enable: {not printer.idle_timeout.state == "Printing"}
name: Draai E:{'%+06.1f' % menu.input}
input: 0
input_min: -{printer.configfile.config.extruder.max_extrude_only_distance|default(50)}
input_max: {printer.configfile.config.extruder.max_extrude_only_distance|default(50)}
input_step: 0.1
gcode:
    SAVE_GCODE_STATE NAME=__move__axis
    M83
    G1 E{menu.input} F240
    RESTORE_GCODE_STATE NAME=__move__axis

### menu temperature ###
[menu __main __temp]
type: list
name: Temperatuur

[menu __main __temp __hotend0_target]
type: input
enable: {('extruder' in printer) and ('extruder' in printer.heaters.available_heaters)}
name: {"Ex0:%3.0f (%4.0f)" % (menu.input, printer.extruder.temperature)}
input: {printer.extruder.target}
input_min: 0
input_max: {printer.configfile.config.extruder.max_temp}
input_step: 1
gcode: M104 T0 S{'%.0f' % menu.input}

[menu __main __temp __hotend1_target]
type: input
enable: {('extruder1' in printer) and ('extruder1' in printer.heaters.available_heaters)}
name: {"Ex1:%3.0f (%4.0f)" % (menu.input, printer.extruder1.temperature)}
input: {printer.extruder1.target}
input_min: 0
input_max: {printer.configfile.config.extruder1.max_temp}
input_step: 1
gcode: M104 T1 S{'%.0f' % menu.input}

[menu __main __temp __hotbed_target]
type: input
enable: {'heater_bed' in printer}
name: {"Bed:%3.0f (%4.0f)" % (menu.input, printer.heater_bed.temperature)}
input: {printer.heater_bed.target}
input_min: 0
input_max: {printer.configfile.config.heater_bed.max_temp}
input_step: 1
gcode: M140 S{'%.0f' % menu.input}

[menu __main __temp __preheat_pla]
type: list
name: Voorverwarmen PLA

[menu __main __temp __preheat_pla __all]
type: command
enable: {('extruder' in printer) and ('heater_bed' in printer)}
name: Alles voorverwarmen
gcode:
    M140 S60
    M104 S200

[menu __main __temp __preheat_pla __hotend]
type: command
enable: {'extruder' in printer}
name: Hotend voorverwarmen
gcode: M104 S200

[menu __main __temp __preheat_pla __hotbed]
type: command
enable: {'heater_bed' in printer}
name: Hotbed voorverwarmen
gcode: M140 S60

[menu __main __temp __preheat_abs]
type: list
name: Voorverwarmen ABS

[menu __main __temp __preheat_abs __all]
type: command
enable: {('extruder' in printer) and ('heater_bed' in printer)}
name: Alles voorverwarmen
gcode:
    M140 S110
    M104 S245

[menu __main __temp __preheat_abs __hotend]
type: command
enable: {'extruder' in printer}
name: Hotend voorverwarmen
gcode: M104 S245

[menu __main __temp __preheat_abs __hotbed]
type: command
enable: {'heater_bed' in printer}
name: Hotbed voorverwarmen
gcode: M140 S110

[menu __main __temp __cooldown]
type: list
name: Afkoelen

[menu __main __temp __cooldown __all]
type: command
enable: {('extruder' in printer) and ('heater_bed' in printer)}
name: Alles afkoelen
gcode:
    M104 S0
    M140 S0

[menu __main __temp __cooldown __hotend]
type: command
enable: {'extruder' in printer}
name: Hotend afkoelen
gcode: M104 S0

[menu __main __temp __cooldown __hotbed]
type: command
enable: {'heater_bed' in printer}
name: Hotbed afkoelen
gcode: M140 S0

### menu filament ###

[menu __main __filament]
type: list
name: Filament

[menu __main __filament __hotend0_target]
type: input
enable: {'extruder' in printer}
name: {"Ex0:%3.0f (%4.0f)" % (menu.input, printer.extruder.temperature)}
input: {printer.extruder.target}
input_min: 0
input_max: {printer.configfile.config.extruder.max_temp}
input_step: 1
gcode: M104 T0 S{'%.0f' % menu.input}

[menu __main __filament __loadf]
type: command
name: Fil. snel laden
gcode:
    SAVE_GCODE_STATE NAME=__filament__load
    M83
    G1 E50 F960
    RESTORE_GCODE_STATE NAME=__filament__load

[menu __main __filament __loads]
type: command
name: Fil. langzaam laden
gcode:
    SAVE_GCODE_STATE NAME=__filament__load
    M83
    G1 E50 F240
    RESTORE_GCODE_STATE NAME=__filament__load

[menu __main __filament __unloadf]
type: command
name: Fil. snel uitwerpen
gcode:
    SAVE_GCODE_STATE NAME=__filament__load
    M83
    G1 E-50 F960
    RESTORE_GCODE_STATE NAME=__filament__load

[menu __main __filament __unloads]
type: command
name: Fil. langzaam uitwerpen
gcode:
    SAVE_GCODE_STATE NAME=__filament__load
    M83
    G1 E-50 F240
    RESTORE_GCODE_STATE NAME=__filament__load

[menu __main __filament __feed]
type: input
name: Snelheid: {'%.1f' % menu.input}
input: 5
input_step: 0.1
gcode:
    SAVE_GCODE_STATE NAME=__filament__load
    M83
    G1 E{'%.1f' % menu.input} F60
    RESTORE_GCODE_STATE NAME=__filament__load

### menu setup ###
[menu __main __setup]
type: list
enable: {not printer.idle_timeout.state == "Printing"}
name: Setup

[menu __main __setup __save_config]
type: command
name: Bewaar configuratie
gcode: SAVE_CONFIG

[menu __main __setup __restart]
type: list
name: Herstarten

[menu __main __setup __restart __host_restart]
type: command
enable: {not printer.idle_timeout.state == "Printing"}
name: Herstart host
gcode: RESTART

[menu __main __setup __restart __firmware_restart]
type: command
enable: {not printer.idle_timeout.state == "Printing"}
name: Herstart FW
gcode: FIRMWARE_RESTART

[menu __main __setup __tuning]
type: list
name: PID tuning

[menu __main __setup __tuning __hotend_pid_tuning]
type: command
enable: {(not printer.idle_timeout.state == "Printing") and ('extruder' in printer)}
name: Tune Hotend PID
gcode: PID_CALIBRATE HEATER=extruder TARGET=210 WRITE_FILE=1

[menu __main __setup __tuning __hotbed_pid_tuning]
type: command
enable: {(not printer.idle_timeout.state == "Printing") and ('heater_bed' in printer)}
name: Tune Hotbed PID
gcode: PID_CALIBRATE HEATER=heater_bed TARGET=60 WRITE_FILE=1

[menu __main __setup __calib]
type: list
name: Calibratie

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

[menu __main __setup __dump]
type: command
name: Dump parameters
gcode:
   {% for name1 in printer %}
      {% for name2 in printer[name1] %}
         { action_respond_info("printer['%s'].%s = %s"
                               % (name1, name2, printer[name1][name2])) }
      {% else %}
         { action_respond_info("printer['%s'] = %s" % (name1, printer[name1])) }
      {% endfor %}
   {% endfor %}
