Skip to content

Commit

Permalink
Initial support for macros
Browse files Browse the repository at this point in the history
  • Loading branch information
hesiod committed Sep 5, 2022
1 parent b2eae78 commit bccbe1a
Show file tree
Hide file tree
Showing 9 changed files with 693 additions and 180 deletions.
34 changes: 34 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ glam = { version = "0.20", features = ["serde"] }
thiserror = "1"
regex = "1"
lazy_static = "1"
minijinja = { version = "^0.18", features = ["source"] }
serde_json = "^1"
2 changes: 1 addition & 1 deletion lib/src/firmware_retraction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct FirmwareRetractionOptions {
pub lift_z: f64,
}

#[derive(Debug)]
#[derive(Debug, Clone, Copy)]
pub enum FirmwareRetractionState {
Unretracted,
Retracted {
Expand Down
7 changes: 4 additions & 3 deletions lib/src/gcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::BTreeMap;
use std::fmt::Display;
use std::io::{self, BufRead};

use serde::Serialize;
use thiserror::Error;

#[derive(Debug, PartialEq, PartialOrd, Clone)]
Expand Down Expand Up @@ -121,7 +122,7 @@ impl Display for GCodeTraditionalParams {
}
}

#[derive(Debug, PartialEq, PartialOrd, Clone)]
#[derive(Debug, PartialEq, Eq, PartialOrd, Clone, Serialize)]
pub struct GCodeExtendedParams(BTreeMap<String, String>);

impl GCodeExtendedParams {
Expand Down Expand Up @@ -279,7 +280,7 @@ mod parser {
fn parse(s: &str) -> IResult<&str, GCodeCommand> {
let (s, _) = space0(s)?;

let (s, _line_no) = opt(line_number)(s)?;
// let (s, _line_no) = opt(line_number)(s)?;

let (s, (op, comment)) = alt((
complete(traditional_gcode),
Expand Down Expand Up @@ -314,7 +315,7 @@ mod parser {
}

fn traditional_gcode(s: &str) -> IResult<&str, (GCodeOperation, Option<&str>)> {
let (s, letter) = satisfy(|c| c.is_alphabetic())(s)?;
let (s, letter) = satisfy(|c| matches!(c.to_ascii_lowercase(), 'g' | 'm'))(s)?;
let (s, code) = match lexical_core::parse_partial::<u16>(s.as_bytes()) {
Ok((_, 0)) => return Err(Err::Error(Error::from_error_kind(s, ErrorKind::Digit))),
Ok((value, processed)) => (s.slice(processed..), value),
Expand Down
1 change: 1 addition & 0 deletions lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ extern crate lazy_static;
pub mod firmware_retraction;
pub mod gcode;
mod kind_tracker;
mod macros;
pub mod planner;
pub mod slicer;

Expand Down
Loading

0 comments on commit bccbe1a

Please sign in to comment.