Last active
March 19, 2020 22:33
-
-
Save mikezter/162823d8f0c25b16b6d4a0d24b26de95 to your computer and use it in GitHub Desktop.
Custom menu for Klipper firmware on Creality Ender 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: @mikezter | |
# Date: 2020-03-18 | |
# Description: This plugin uses Cura TIME and TIME_ELAPSED estimations | |
# to calculate build percentage and time remaining. | |
# It can insert M73 P<percentage> and M117 <time remaining> gcodes. | |
from ..Script import Script | |
import re | |
class DisplayPercentageM73(Script): | |
def __init__(self): | |
self.totalTime = 1 | |
self.currentTime = 0 | |
super().__init__() | |
def getSettingDataString(self): | |
return """{ | |
"name": "Display Percentage on LCD using gcode M73", | |
"key": "DisplayPercentageM73", | |
"metadata": {}, | |
"version": 2, | |
"settings": | |
{ | |
"m117": | |
{ | |
"label": "Include time remaining message", | |
"description": "Inserts M117 along with M73", | |
"type": "bool", | |
"default_value": false | |
} | |
} | |
}""" | |
def getTotalTime(self, layer): | |
match = re.findall(";TIME:(\d+)", layer) | |
if match: | |
self.totalTime = int(match[0]) | |
return self.totalTime | |
def getCurrentTime(self, layer): | |
match = re.findall(";TIME_ELAPSED:(\d+\.?\d*)", layer) | |
if match: | |
self.currentTime = float(match[0]) | |
return self.currentTime | |
def percentage(self): | |
if self.currentTime > self.totalTime: | |
return 100 | |
return 100 * self.currentTime / self.totalTime | |
def remainingTimeToString(self): | |
remaining = self.totalTime - self.currentTime | |
if remaining < 0: | |
return "0:00" | |
m, s = divmod(remaining, 60) | |
h, m = divmod(m, 60) | |
return "{:d}:{:02d}".format(int(h), int(m)) | |
def m117(self): | |
if not self.getSettingValueByKey("m117"): | |
return "" | |
return "M117 {}h remaining.\n".format(self.remainingTimeToString()) | |
def execute(self, data): | |
self.totalTime = 1 | |
self.currentTime = 0 | |
for layer_number, layer in enumerate(data): | |
if self.totalTime == 1: | |
self.getTotalTime(layer) | |
self.getCurrentTime(layer) | |
m73 = "M73 P{} ; {} of {}\n".format(self.percentage(), self.currentTime, self.totalTime) | |
data[layer_number] = layer + m73 + self.m117() | |
return data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Send: MENU DO=dump | |
Recv: // heater.available_sensors = ['heater_bed', 'extruder'] | |
Recv: // heater.is_enabled = True | |
Recv: // heater.available_heaters = ['heater_bed', 'extruder'] | |
Recv: // spi_temperature.is_enabled = False | |
Recv: // force_move.is_enabled = True | |
Recv: // pause_resume.is_paused = False | |
Recv: // pause_resume.is_enabled = True | |
Recv: // verify_heater.heater_bed.is_enabled = True | |
Recv: // configfile.is_enabled = True | |
Recv: // query_endstops.is_enabled = True | |
Recv: // heater_bed.is_enabled = True | |
Recv: // heater_bed.temperature = 34.4655316977 | |
Recv: // heater_bed.target = 0.0 | |
Recv: // adc_temperature.is_enabled = False | |
Recv: // virtual_sdcard.is_enabled = True | |
Recv: // virtual_sdcard.progress = 0.0 | |
Recv: // statistics.is_enabled = True | |
Recv: // menu.is_enabled = True | |
Recv: // menu.eventtime = 137125.214698 | |
Recv: // menu.is16xx = True | |
Recv: // menu.isRunning = True | |
Recv: // menu.is20xx = False | |
Recv: // menu.is1604 = True | |
Recv: // menu.is1602 = False | |
Recv: // menu.timeout = 0 | |
Recv: // menu.autorun = False | |
Recv: // menu.is2002 = False | |
Recv: // menu.is2004 = False | |
Recv: // verify_heater.extruder.is_enabled = True | |
Recv: // stepper_enable.is_enabled = True | |
Recv: // buttons.is_enabled = True | |
Recv: // manual_probe.is_enabled = True | |
Recv: // gcode_macro.M600.is_enabled = True | |
Recv: // gcode_macro.is_enabled = True | |
Recv: // pins.is_enabled = True | |
Recv: // pid_calibrate.is_enabled = True | |
Recv: // query_adc.is_enabled = True | |
Recv: // gcode.speed_factor = 1.0 | |
Recv: // gcode.gcode_position = Coord(x=0.0, y=0.0, z=0.0, e=0.0) | |
Recv: // gcode.homing_ypos = 0.0 | |
Recv: // gcode.speed = 1500.0 | |
Recv: // gcode.busy = False | |
Recv: // gcode.homing_zpos = 0.0 | |
Recv: // gcode.action_emergency_stop = <bound method GCodeParser._action_emergency_stop of <gcode.GCodeParser instance at 0x7415c288>> | |
Recv: // gcode.last_ypos = 0.0 | |
Recv: // gcode.last_epos = 0.0 | |
Recv: // gcode.base_zpos = 0.0 | |
Recv: // gcode.action_respond_info = <bound method GCodeParser._action_respond_info of <gcode.GCodeParser instance at 0x7415c288>> | |
Recv: // gcode.abs_extrude = True | |
Recv: // gcode.move_epos = 0.0 | |
Recv: // gcode.last_xpos = 0.0 | |
Recv: // gcode.base_ypos = 0.0 | |
Recv: // gcode.base_epos = 0.0 | |
Recv: // gcode.action_respond_error = <bound method GCodeParser._action_respond_error of <gcode.GCodeParser instance at 0x7415c288>> | |
Recv: // gcode.extrude_factor = 1.0 | |
Recv: // gcode.move_zpos = 0.0 | |
Recv: // gcode.is_enabled = True | |
Recv: // gcode.base_xpos = 0.0 | |
Recv: // gcode.move_ypos = 0.0 | |
Recv: // gcode.move_xpos = 0.0 | |
Recv: // gcode.last_zpos = 0.0 | |
Recv: // gcode.homing_xpos = 0.0 | |
Recv: // idle_timeout.is_enabled = True | |
Recv: // idle_timeout.state = Idle | |
Recv: // idle_timeout.printing_time = 0.0 | |
Recv: // fan.is_enabled = True | |
Recv: // fan.speed = 0.0 | |
Recv: // mcu.is_enabled = True | |
Recv: // bed_screws.is_enabled = True | |
Recv: // tuning_tower.is_enabled = True | |
Recv: // thermistor.is_enabled = False | |
Recv: // toolhead.status = Ready | |
Recv: // toolhead.is_enabled = True | |
Recv: // toolhead.xpos = 0.0 | |
Recv: // toolhead.epos = 0.0 | |
Recv: // toolhead.zpos = 0.0 | |
Recv: // toolhead.homed_axes = | |
Recv: // toolhead.ypos = 0.0 | |
Recv: // toolhead.estimated_print_time = 477.046526875 | |
Recv: // toolhead.print_time = 0.0 | |
Recv: // toolhead.printing_time = 0.0 | |
Recv: // toolhead.is_idle = False | |
Recv: // toolhead.is_ready = True | |
Recv: // toolhead.position = Coord(x=0.0, y=0.0, z=0.0, e=0.0) | |
Recv: // toolhead.is_printing = False | |
Recv: // toolhead.extruder = extruder | |
Recv: // display.is_enabled = True | |
Recv: // display.progress = 0 | |
Recv: // display.message = | |
Recv: // extruder.is_enabled = True | |
Recv: // extruder.pressure_advance = 0.44 | |
Recv: // extruder.temperature = 199.941345405 | |
Recv: // extruder.smooth_time = 0.04 | |
Recv: // extruder.target = 200.0 | |
Recv: ok |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file contains common pin mappings for the 2018 Creality | |
# Ender 3. To use this config, the firmware should be compiled for the | |
# AVR atmega1284p. | |
# Note, a number of Melzi boards are shipped with a bootloader that | |
# requires the following command to flash the board: | |
# avrdude -p atmega1284p -c arduino -b 57600 -P /dev/ttyUSB0 -U out/klipper.elf.hex | |
# If the above command does not work and "make flash" does not work | |
# then one may need to flash a bootloader to the board - see the | |
# Klipper docs/Bootloaders.md file for more information. | |
# See the example.cfg file for a description of available parameters. | |
[virtual_sdcard] | |
path: /home/pi/.octoprint/uploads/ | |
[stepper_x] | |
step_pin: PD7 | |
dir_pin: !PC5 | |
enable_pin: !PD6 | |
step_distance: .0125 | |
endstop_pin: ^PC2 | |
position_endstop: 0 | |
position_max: 235 | |
homing_speed: 50 | |
homing_retract_dist: 0 | |
[stepper_y] | |
step_pin: PC6 | |
dir_pin: !PC7 | |
enable_pin: !PD6 | |
step_distance: .0125 | |
endstop_pin: ^PC3 | |
position_endstop: 0 | |
position_max: 235 | |
homing_speed: 50 | |
homing_retract_dist: 0 | |
[stepper_z] | |
step_pin: PB3 | |
dir_pin: PB2 | |
enable_pin: !PA5 | |
step_distance: .0025 | |
endstop_pin: ^PC4 | |
position_endstop: 0.0 | |
position_max: 250 | |
position_min: 0 | |
[extruder] | |
max_extrude_only_distance: 100.0 | |
step_pin: PB1 | |
dir_pin: !PB0 | |
enable_pin: !PD6 | |
step_distance: 0.010526 | |
nozzle_diameter: 0.500 | |
filament_diameter: 1.750 | |
pressure_advance: 0.44 | |
heater_pin: PD5 | |
sensor_type: EPCOS 100K B57560G104F | |
sensor_pin: PA7 | |
control: pid | |
# tuned for stock hardware with 200 degree Celsius target | |
pid_Kp: 21.527 | |
pid_Ki: 1.063 | |
pid_Kd: 108.982 | |
min_temp: 0 | |
max_temp: 250 | |
[heater_bed] | |
heater_pin: PD4 | |
sensor_type: EPCOS 100K B57560G104F | |
sensor_pin: PA6 | |
control: pid | |
# tuned for stock hardware with 50 degree Celsius target | |
pid_Kp: 54.027 | |
pid_Ki: 0.770 | |
pid_Kd: 948.182 | |
min_temp: 0 | |
max_temp: 130 | |
[fan] | |
pin: PB4 | |
[mcu] | |
serial: /dev/ttyUSB0 | |
[printer] | |
kinematics: cartesian | |
max_velocity: 300 | |
max_accel: 3000 | |
max_z_velocity: 5 | |
max_z_accel: 100 | |
[display] | |
lcd_type: st7920 | |
cs_pin: PA3 | |
sclk_pin: PA1 | |
sid_pin: PC1 | |
encoder_pins: ^PD2, ^PD3 | |
click_pin: ^!PC0 | |
[bed_screws] | |
screw1: 35,35 | |
screw2: 195,35 | |
screw3: 195,195 | |
screw4: 35,195 | |
screw5: 110,110 | |
###################################################################### | |
# Filament Change | |
###################################################################### | |
# M600: Filament Change. This macro will pause the printer, move the | |
# tool to the change position, and retract the filament 50mm. Adjust | |
# the retraction settings for your own extruder. After filament has | |
# been changed, the print can be resumed from its previous position | |
# with the "RESUME" gcode. | |
[pause_resume] | |
[gcode_macro M600] | |
default_parameter_X: 10 | |
default_parameter_Y: 10 | |
default_parameter_Z: 10 | |
gcode: | |
PAUSE | |
M117 Waiting for RESUME... | |
G91 | |
G1 E-5 F300 | |
G1 Z{Z} | |
G90 | |
G1 X{X} Y{Y} F3000 | |
M83 | |
G1 E-50 F1000 | |
G1 E-50 F1000 | |
G1 E-50 F1800 | |
G1 E-50 F1800 | |
G1 E-50 F1800 | |
G1 E-50 F1800 | |
G1 E-50 F1800 | |
G1 E-50 F1800 | |
M82 | |
################ | |
### MENU ### | |
################ | |
[menu __main] | |
type: list | |
name: Main Menu | |
items: | |
pause_resume | |
__tune | |
__octoprint | |
__sdcard | |
__control | |
__temp | |
__filament | |
__prepare | |
######################### | |
### menu pause/resume ### | |
######################### | |
[menu pause_resume] | |
type: list | |
enable: !toolhead.is_idle | |
name: Pause/Resume | |
items: | |
pause_resume pause | |
pause_resume resume | |
pause_resume clear | |
[menu pause_resume pause] | |
type: command | |
name: Pause | |
enable: !pause_resume.is_paused | |
action: exit | |
gcode: PAUSE | |
[menu pause_resume resume] | |
type: command | |
name: Resume | |
enable: pause_resume.is_paused | |
action: exit | |
gcode: RESUME | |
[menu pause_resume clear] | |
type: command | |
name: Clear Pause State | |
enable: pause_resume.is_paused | |
action: exit | |
gcode: CLEAR_PAUSE | |
######################## | |
### menu temperature ### | |
######################## | |
[menu __temp] | |
type: list | |
name: Temperature | |
items: | |
.__preheat_pla | |
.__hotend0_current, .__hotend0_target | |
.__hotbed_current, .__hotbed_target | |
.__preheat_abs | |
.__cooldown __all | |
.__cooldown | |
exit | |
[menu __temp __preheat_pla __all] | |
type: command | |
enable: extruder.is_enabled,heater_bed.is_enabled | |
name: Preheat all | |
action: exit | |
gcode: | |
M140 S70 | |
M104 S200 | |
[menu __temp __cooldown __all] | |
type: command | |
enable: extruder.is_enabled,heater_bed.is_enabled | |
name: Cooldown all | |
action: exit | |
gcode: | |
M104 S0 | |
M140 S0 | |
######################## | |
### menu filament ### | |
######################## | |
[menu __filament] | |
type: list | |
name: Filament | |
items: | |
__temp __hotend0_current, __temp __hotend0_target | |
__temp __preheat_pla __hotend | |
.__unload | |
.__load | |
pause_resume resume | |
.__feed | |
exit | |
[menu __filament __load] | |
type: command | |
name: Load Filament | |
gcode: | |
M83 | |
G1 E50 F1000 | |
G1 E50 F1800 | |
G1 E50 F1800 | |
G1 E50 F1800 | |
G1 E50 F1800 | |
G1 E50 F1000 | |
G1 E50 F700 | |
G1 E50 F300 | |
G1 E-2 F150 | |
M82 | |
[menu __filament __unload] | |
type: command | |
name: Unload Filament | |
gcode: | |
M83 | |
G1 E-50 F1000 | |
G1 E-50 F1000 | |
G1 E-50 F1800 | |
G1 E-50 F1800 | |
G1 E-50 F1800 | |
G1 E-50 F1800 | |
G1 E-50 F1800 | |
G1 E-50 F1800 | |
M18 E | |
M82 | |
################################## | |
### menu prepare bed screws ### | |
################################## | |
[menu __prepare] | |
type: list | |
enable: !toolhead.is_printing | |
name: Prepare | |
items: | |
.bed_screw_adjust | |
.__hotend_pid_tuning | |
.__hotbed_pid_tuning | |
.__host_restart | |
.__firmware_restart | |
[menu __prepare bed_screw_adjust] | |
type: list | |
name: Bed screw adjust | |
items: | |
.start | |
.adjusted | |
.accept | |
.abort | |
exit | |
[menu __prepare bed_screw_adjust start] | |
type: command | |
name: Start procedure | |
enable: !toolhead.is_printing | |
gcode: | |
G28 | |
BED_SCREWS_ADJUST | |
[menu __prepare bed_screw_adjust adjusted] | |
type: command | |
name: Adjusted | |
enable: !toolhead.is_printing | |
gcode: ADJUSTED | |
[menu __prepare bed_screw_adjust accept] | |
type: command | |
name: Accept | |
enable: !toolhead.is_printing | |
gcode: ACCEPT | |
[menu __prepare bed_screw_adjust abort] | |
type: command | |
name: Abort | |
enable: !toolhead.is_printing | |
gcode: ABORT | |
################################## | |
### action exit ### | |
################################## | |
[menu exit] | |
name: Exit | |
type: command | |
action: exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment