Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
0xD34D committed Jan 1, 2024
2 parents 43f014d + 25bc649 commit a3be024
Show file tree
Hide file tree
Showing 29 changed files with 674 additions and 657 deletions.
6 changes: 6 additions & 0 deletions docs/Config_Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ All dates in this document are approximate.

## Changes

20231216: The `[hall_filament_width_sensor]` is changed to trigger filament runout
when the thickness of the filament exceeds `max_diameter`. The maximum diameter
defaults to `default_nominal_filament_diameter + max_difference`. See
[[hall_filament_width_sensor] configuration
reference](./Config_Reference.md#hall_filament_width_sensor) for more details.

20231207: Several undocumented config parameters in the `[printer]`
config section have been removed (the buffer_time_low,
buffer_time_high, buffer_time_start, and move_flush_time parameters).
Expand Down
6 changes: 5 additions & 1 deletion docs/Config_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2559,7 +2559,7 @@ sensor_type: LM75

### Builtin micro-controller temperature sensor

The atsam, atsamd, and stm32 micro-controllers contain an internal
The atsam, atsamd, stm32 and rp2040 micro-controllers contain an internal
temperature sensor. One can use the "temperature_mcu" sensor to
monitor these temperatures.

Expand Down Expand Up @@ -3149,6 +3149,7 @@ pin:
# The pin to configure as an output. This parameter must be provided.
#value:
#shutdown_value:
#maximum_mcu_duration:
#cycle_time: 0.100
#hardware_pwm: False
#scale:
Expand Down Expand Up @@ -4428,6 +4429,9 @@ adc2:
# command.
#min_diameter: 1.0
# Minimal diameter for trigger virtual filament_switch_sensor.
#max_diameter:
# Maximum diameter for triggering virtual filament_switch_sensor.
# The default is default_nominal_filament_diameter + max_difference.
#use_current_dia_while_delay: False
# Use the current diameter instead of the nominal diameter while
# the measurement delay has not run through.
Expand Down
6 changes: 6 additions & 0 deletions docs/Status_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ The following information is available in the
module. These settings may differ from the config file if a
`SET_RETRACTION` command alters them.

## gcode

The following information is available in the `gcode` object:
- `commands`: Returns a list of all currently available commands. For each
command, if a help string is defined it will also be provided.

## gcode_button

The following information is available in
Expand Down
6 changes: 4 additions & 2 deletions klippy/chelper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
void steppersync_free(struct steppersync *ss);
void steppersync_set_time(struct steppersync *ss
, double time_offset, double mcu_freq);
int steppersync_flush(struct steppersync *ss, uint64_t move_clock);
int steppersync_flush(struct steppersync *ss, uint64_t move_clock
, uint64_t clear_history_clock);
"""

defs_itersolve = """
Expand Down Expand Up @@ -94,7 +95,8 @@
, double start_pos_x, double start_pos_y, double start_pos_z
, double axes_r_x, double axes_r_y, double axes_r_z
, double start_v, double cruise_v, double accel);
void trapq_finalize_moves(struct trapq *tq, double print_time);
void trapq_finalize_moves(struct trapq *tq, double print_time
, double clear_history_time);
void trapq_set_position(struct trapq *tq, double print_time
, double pos_x, double pos_y, double pos_z);
int trapq_extract_old(struct trapq *tq, struct pull_move *p, int max
Expand Down
7 changes: 3 additions & 4 deletions klippy/chelper/serialqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,11 @@ handle_message(struct serialqueue *sq, double eventtime, int len)
pthread_mutex_lock(&sq->lock);

// Calculate receive sequence number
uint64_t rseq = ((sq->receive_seq & ~MESSAGE_SEQ_MASK)
| (sq->input_buf[MESSAGE_POS_SEQ] & MESSAGE_SEQ_MASK));
uint32_t rseq_delta = ((sq->input_buf[MESSAGE_POS_SEQ] - sq->receive_seq)
& MESSAGE_SEQ_MASK);
uint64_t rseq = sq->receive_seq + rseq_delta;
if (rseq != sq->receive_seq) {
// New sequence number
if (rseq < sq->receive_seq)
rseq += MESSAGE_SEQ_MASK+1;
if (rseq > sq->send_seq && sq->receive_seq != 1) {
// An ack for a message not sent? Out of order message?
sq->bytes_invalid += len;
Expand Down
29 changes: 23 additions & 6 deletions klippy/chelper/stepcompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ struct step_move {
int16_t add;
};

#define HISTORY_EXPIRE (30.0)

struct history_steps {
struct list_node node;
uint64_t first_clock, last_clock;
Expand Down Expand Up @@ -292,6 +290,13 @@ free_history(struct stepcompress *sc, uint64_t end_clock)
}
}

// Expire the stepcompress history older than the given clock
static void
stepcompress_history_expire(struct stepcompress *sc, uint64_t end_clock)
{
free_history(sc, end_clock);
}

// Free memory associated with a 'stepcompress' object
void __visible
stepcompress_free(struct stepcompress *sc)
Expand Down Expand Up @@ -322,9 +327,6 @@ calc_last_step_print_time(struct stepcompress *sc)
{
double lsc = sc->last_step_clock;
sc->last_step_print_time = sc->mcu_time_offset + (lsc - .5) / sc->mcu_freq;

if (lsc > sc->mcu_freq * HISTORY_EXPIRE)
free_history(sc, lsc - sc->mcu_freq * HISTORY_EXPIRE);
}

// Set the conversion rate of 'print_time' to mcu clock
Expand Down Expand Up @@ -731,6 +733,18 @@ steppersync_set_time(struct steppersync *ss, double time_offset
}
}

// Expire the stepcompress history before the given clock time
static void
steppersync_history_expire(struct steppersync *ss, uint64_t end_clock)
{
int i;
for (i = 0; i < ss->sc_num; i++)
{
struct stepcompress *sc = ss->sc_list[i];
stepcompress_history_expire(sc, end_clock);
}
}

// Implement a binary heap algorithm to track when the next available
// 'struct move' in the mcu will be available
static void
Expand Down Expand Up @@ -758,7 +772,8 @@ heap_replace(struct steppersync *ss, uint64_t req_clock)

// Find and transmit any scheduled steps prior to the given 'move_clock'
int __visible
steppersync_flush(struct steppersync *ss, uint64_t move_clock)
steppersync_flush(struct steppersync *ss, uint64_t move_clock
, uint64_t clear_history_clock)
{
// Flush each stepcompress to the specified move_clock
int i;
Expand Down Expand Up @@ -806,5 +821,7 @@ steppersync_flush(struct steppersync *ss, uint64_t move_clock)
// Transmit commands
if (!list_empty(&msgs))
serialqueue_send_batch(ss->sq, ss->cq, &msgs);

steppersync_history_expire(ss, clear_history_clock);
return 0;
}
3 changes: 2 additions & 1 deletion klippy/chelper/stepcompress.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct steppersync *steppersync_alloc(
void steppersync_free(struct steppersync *ss);
void steppersync_set_time(struct steppersync *ss, double time_offset
, double mcu_freq);
int steppersync_flush(struct steppersync *ss, uint64_t move_clock);
int steppersync_flush(struct steppersync *ss, uint64_t move_clock
, uint64_t clear_history_clock);

#endif // stepcompress.h
10 changes: 4 additions & 6 deletions klippy/chelper/trapq.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,10 @@ trapq_append(struct trapq *tq, double print_time
}
}

#define HISTORY_EXPIRE (30.0)

// Expire any moves older than `print_time` from the trapezoid velocity queue
void __visible
trapq_finalize_moves(struct trapq *tq, double print_time)
trapq_finalize_moves(struct trapq *tq, double print_time
, double clear_history_time)
{
struct move *head_sentinel = list_first_entry(&tq->moves, struct move,node);
struct move *tail_sentinel = list_last_entry(&tq->moves, struct move, node);
Expand All @@ -190,10 +189,9 @@ trapq_finalize_moves(struct trapq *tq, double print_time)
if (list_empty(&tq->history))
return;
struct move *latest = list_first_entry(&tq->history, struct move, node);
double expire_time = latest->print_time + latest->move_t - HISTORY_EXPIRE;
for (;;) {
struct move *m = list_last_entry(&tq->history, struct move, node);
if (m == latest || m->print_time + m->move_t > expire_time)
if (m == latest || m->print_time + m->move_t > clear_history_time)
break;
list_del(&m->node);
free(m);
Expand All @@ -206,7 +204,7 @@ trapq_set_position(struct trapq *tq, double print_time
, double pos_x, double pos_y, double pos_z)
{
// Flush all moves from trapq
trapq_finalize_moves(tq, NEVER_TIME);
trapq_finalize_moves(tq, NEVER_TIME, 0);

// Prune any moves in the trapq history that were interrupted
while (!list_empty(&tq->history)) {
Expand Down
3 changes: 2 additions & 1 deletion klippy/chelper/trapq.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ void trapq_append(struct trapq *tq, double print_time
, double start_pos_x, double start_pos_y, double start_pos_z
, double axes_r_x, double axes_r_y, double axes_r_z
, double start_v, double cruise_v, double accel);
void trapq_finalize_moves(struct trapq *tq, double print_time);
void trapq_finalize_moves(struct trapq *tq, double print_time
, double clear_history_time);
void trapq_set_position(struct trapq *tq, double print_time
, double pos_x, double pos_y, double pos_z);
int trapq_extract_old(struct trapq *tq, struct pull_move *p, int max
Expand Down
13 changes: 5 additions & 8 deletions klippy/clocksync.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ def _handle_clock(self, params):
self.queries_pending = 0
# Extend clock to 64bit
last_clock = self.last_clock
clock = (last_clock & ~0xffffffff) | params['clock']
if clock < last_clock:
clock += 0x100000000
self.last_clock = clock
clock_delta = (params['clock'] - last_clock) & 0xffffffff
self.last_clock = clock = last_clock + clock_delta
# Check if this is the best round-trip-time seen so far
sent_time = params['#sent_time']
if not sent_time:
Expand Down Expand Up @@ -138,10 +136,9 @@ def estimated_print_time(self, eventtime):
# misc commands
def clock32_to_clock64(self, clock32):
last_clock = self.last_clock
clock_diff = (last_clock - clock32) & 0xffffffff
if clock_diff & 0x80000000:
return last_clock + 0x100000000 - clock_diff
return last_clock - clock_diff
clock_diff = (clock32 - last_clock) & 0xffffffff
clock_diff -= (clock_diff & 0x80000000) << 1
return last_clock + clock_diff
def is_active(self):
return self.queries_pending <= 4
def dump_debug(self):
Expand Down
Loading

0 comments on commit a3be024

Please sign in to comment.