Cleanup code
This commit is contained in:
parent
def0ecee5c
commit
2981b6b975
2 changed files with 9 additions and 5 deletions
|
@ -9,19 +9,23 @@ use std::time::Duration;
|
|||
/// For a given GCode buffer size on the machine, we can assume
|
||||
/// a maximum delay of `TIME_PER_MOVEMENT * BUFFER_COUNT`
|
||||
const TIME_PER_MOVEMENT: Duration = Duration::from_millis(30);
|
||||
|
||||
/// Movement speed of gantry when going full throttle in x/y-direction
|
||||
/// in units/min (mm/min)
|
||||
const FULL_SCALE_SPEED_XY: f64 = 2000.0;
|
||||
|
||||
/// Movement speed of gantry when going full throttle in z-direction
|
||||
/// in units/min (mm/min)
|
||||
const FULL_SCALE_SPEED_Z: f64 = 100.0;
|
||||
|
||||
/// Amount of GCODE buffers that should be filled for optimal jogging performance.
|
||||
/// More buffers increase the controller delay. Less buffers make it more difficult
|
||||
/// More buffers increase the controller delay. Fewer buffers make it more difficult
|
||||
/// for the motion planner on the printer to plan ahead.
|
||||
const TARGET_BUFER_FILL_LEVEL: usize = 4;
|
||||
const TARGET_BUFFER_FILL_LEVEL: usize = 4;
|
||||
|
||||
/// Time to wait before sending new commands if the GCODE buffer is overfull
|
||||
const LONG_COMMAND_DELAY: Duration = TIME_PER_MOVEMENT;
|
||||
|
||||
/// Divider for `LONG_COMMAND_DELAY` for waiting if we've reached `TARGET_BUFER_FILL_LEVEL`
|
||||
const SHORT_COMMAND_DELAY_DIVIDER: u32 = 2;
|
||||
|
||||
|
@ -76,7 +80,7 @@ pub fn jog(gamepad: &mut Gamepad, mut printer: Printer) -> Result<()> {
|
|||
let fill_level = printer.maximum_capacity() - printer.remaining_capacity();
|
||||
println!("remaining capacity: {}", printer.remaining_capacity());
|
||||
println!("fill level: {}", fill_level);
|
||||
match fill_level.cmp(&TARGET_BUFER_FILL_LEVEL) {
|
||||
match fill_level.cmp(&TARGET_BUFFER_FILL_LEVEL) {
|
||||
std::cmp::Ordering::Equal => {
|
||||
std::thread::sleep(LONG_COMMAND_DELAY / SHORT_COMMAND_DELAY_DIVIDER)
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use red::printer::{AutoReportSetting, Printer};
|
|||
use std::path::Path;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
jog()
|
||||
jog()
|
||||
}
|
||||
|
||||
fn find_printer_port() -> Result<String> {
|
||||
|
@ -36,7 +36,7 @@ fn jog() -> Result<()> {
|
|||
let printer_tty_path = find_printer_port()?;
|
||||
let mut printer = Printer::connect_to_path(&printer_tty_path)
|
||||
.with_context(|| anyhow!("Initializing printer connection"))?;
|
||||
|
||||
|
||||
printer.set_position_auto_report(AutoReportSetting::EverySeconds(1))?;
|
||||
printer.set_temperature_auto_report(AutoReportSetting::EverySeconds(1))?;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue