#[cfg(feature = "native")]
use core::fmt::Display;
use crate::math::Real;
#[cfg(feature = "native")]
use strum::Display;
use strum::{AsRefStr, EnumVariantNames};
use alloc::string::String;
pub(crate) mod processor;
pub(crate) mod planner;
pub(crate) mod parser;
pub(crate) mod task_control;
#[cfg(feature = "with-printjob")] pub(crate) mod task_printjob;
#[cfg(feature = "integration-test")] pub(crate) mod task_integration;
#[cfg(feature = "with-motion")]
pub(crate) mod task_deferr;
#[cfg(any(feature = "with-hotend", feature = "with-hotbed"))]
pub(crate) mod task_temperature;
#[cfg(feature = "with-motion")]
pub mod task_stepper;
#[cfg(feature = "with-motion")]
pub(crate) mod motion_timing;
#[allow(dead_code)]
#[derive(Clone, Default)]
#[cfg_attr(feature = "native", derive(Debug))]
pub struct S {
pub(crate) ln: Option<u32>,
pub(crate) s: Option<Real>,
}
#[allow(dead_code)]
#[derive(Clone, Default)]
#[cfg_attr(feature = "native", derive(Debug))]
pub struct XYZW {
pub(crate) ln: Option<u32>,
pub(crate) x: Option<Real>,
pub(crate) y: Option<Real>,
pub(crate) z: Option<Real>,
pub(crate) w: Option<Real>,
}
#[cfg(feature = "with-defmt")]
impl crate::hwa::defmt::Format for XYZW {
fn format(&self, fmt: crate::hwa::defmt::Formatter) {
crate::hwa::defmt::write!(fmt, "XYZW {:?}", self.ln)
}
}
#[allow(dead_code)]
#[derive(Clone, Default)]
#[cfg_attr(feature = "native", derive(Debug))]
pub struct XYZ {
pub(crate) ln: Option<u32>,
pub(crate) f: Option<Real>,
pub(crate) x: Option<Real>,
pub(crate) y: Option<Real>,
pub(crate) z: Option<Real>,
}
#[cfg(feature = "with-defmt")]
impl crate::hwa::defmt::Format for XYZ {
fn format(&self, fmt: crate::hwa::defmt::Formatter) {
crate::hwa::defmt::write!(fmt, "XYZ {:?}", self.ln)
}
}
#[cfg(feature = "native")]
impl Display for XYZ {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
core::write!(f,
"X {} Y {} Z {} F {}",
self.x.map_or_else(|| "NaN".to_string(), |v| v.to_string()),
self.y.map_or_else(|| "NaN".to_string(), |v| v.to_string()),
self.z.map_or_else(|| "NaN".to_string(), |v| v.to_string()),
self.f.map_or_else(|| "NaN".to_string(), |v| v.to_string()),
)
}
}
#[allow(dead_code)]
#[derive(Clone, Default)]
#[cfg_attr(feature = "native", derive(Debug))]
pub struct XYZEFS {
pub(crate) ln: Option<u32>,
pub(crate) e: Option<Real>,
pub(crate) f: Option<Real>,
pub(crate) s: Option<Real>,
pub(crate) x: Option<Real>,
pub(crate) y: Option<Real>,
pub(crate) z: Option<Real>,
}
impl XYZEFS {
#[allow(unused)]
pub fn with_x(&self, pos: i32) -> Self {
Self {
ln: self.ln,
e: self.e,
f: self.f,
s: self.s,
x: Some(Real::from_lit(pos as i64, 0)),
y: self.y,
z: self.z,
}
}
}
#[cfg(feature = "with-defmt")]
impl crate::hwa::defmt::Format for XYZEFS {
fn format(&self, fmt: crate::hwa::defmt::Formatter) {
crate::hwa::defmt::write!(fmt, "XYZEFS {:?}", self.ln)
}
}
#[allow(unused)]
#[derive(Clone, EnumVariantNames, AsRefStr, Default)]
#[cfg_attr(feature = "native", derive(Display))]
pub enum GCode {
#[default]
NOP,
#[cfg(feature = "grbl-compat")]
STATUS,
#[cfg(feature = "grbl-compat")]
GRBLCMD,
G,
G0(XYZ),
G1(XYZEFS),
G4,
G10, G11, G17, G18, G19, G21, G22, G23,
G28(XYZW),
G29,
#[strum(serialize = "G29.1")] G29_1,
#[strum(serialize = "G29.2")] G29_2,
G30,
G31,
G32,
#[strum(serialize = "G38.2")]
G38_2, #[strum(serialize = "G38.3")] G38_3, #[strum(serialize = "G38.4")] G38_4, #[strum(serialize = "G38.5")] G38_5, G80, G81, G82, G90,
G91,
G92,
#[strum(serialize = "G92.1")]
G92_1,
#[strum(serialize = "G92.2")]
G92_2, G93, G94,
M,
M0, M1, M2, M3, M4, M5, M6, M7, M8, M9, M10, M11, M13, M16, M17, M18, M20(Option<String>),
M21,
M22,
M23(Option<String>),
M24,
M25,
M26,
M27,
M30, M31, M32, M33, M37, M73,
M79,
M80,
M81,
M83,
M84, M92,
M100,
M104(S),
M105,
M106,
M107,
M109(S),
M110, M111,
M112,
M114,
M115,
M116,
M117,
M118,
M119,
M120, M121, M140(S),
M190,
M200,
M201, M202,
M203, M204,
M205, M206, M207, M208, M209, M210, M211, M212, M218, M220(S),
M221(S),
M290, M302, M305, M350, M360, M400,
M401, M402, M404, M407, M410, M422, M450, M451, M452, M453, M500, M501,
M502, M504, M505, M510, M511, M512, M513, M524,
M555, M563, M851,
#[strum(serialize = "M862.1")] M862_1,
#[strum(serialize = "M862.2")] M862_2,
#[strum(serialize = "M862.3")] M862_3,
M900,
M907,
M929 }
#[cfg(feature = "defmt")]
impl crate::hwa::defmt::Format for GCode {
fn format(&self, fmt: crate::hwa::defmt::Formatter) {
let gcode_name: &str = self.as_ref();
crate::hwa::defmt::write!(fmt, "{}", gcode_name)
}
}