Skip to content

Commit

Permalink
添加函数,设定feeder step的脉冲频率
Browse files Browse the repository at this point in the history
  • Loading branch information
G authored and G committed Jun 26, 2024
1 parent 6c3ecf1 commit 3e57f40
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions klippy/extras/filafeeders.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ def _loginfo(self, msg):
def _cal_step_cycle_time(self, speed):
freq = speed * self.scale_speed2freq
return 1.0 / freq if freq > 0 else 0.1

def _set_step_cycle_time(self, cycle_time):
if self.cur_cycle_time == cycle_time: # no need to change.
return
self.cur_cycle_time = cycle_time # update the cycle time.
mcu = self.step.get_mcu()
cycle_ticks = mcu.seconds_to_clock(cycle_time)
self.step.get_mcu()._serial.send("set_digital_out_pwm_cycle oid=%c cycle_ticks=%u" % (self.step._oid, cycle_ticks)) # set the cycle time of step pin.

# feed filament len at speed
def feed_filament(self, print_time, speed, len): # set feed len with speed. value is the length to feed.
Expand Down Expand Up @@ -228,6 +236,7 @@ def enable_stepper(self, bOn):
def set_pulse(self, print_time, value, cycle_time):
print_time = max(print_time, self.last_pulsetime + MIN_DIRPULSE_TIME)
self.last_pulsetime = print_time
self._set_step_cycle_time(cycle_time)
self.step.set_pwm(print_time, value) #, cycle_time)
# toolhead = self.printer.lookup_object('toolhead')
# toolhead.register_lookahead_callback(
Expand Down

0 comments on commit 3e57f40

Please sign in to comment.