1- import { wsClient } from "../init/client" ;
2- import { Axis , AxisPositions , PrinterProfile , PrinterCommands } from "../types/printer" ;
3- import { eventBus } from "./eventbus" ;
4-
51/**
2+ * @file Printer.ts
63 * Class representing a 3D printer instance
74 * Handles printer control commands and state management
85 * Using the verifyConnection() decorator to verify the connection
96 */
7+
8+ import { wsClient } from "../init/client" ;
9+ import { Axis , AxisPositions , PrinterProfile , PrinterCommands } from "../types/printer" ;
10+ import { eventBus } from "./eventbus" ;
11+
1012export default class Printer implements PrinterCommands {
1113 /** Stores current printer configuration and state */
1214 printerInfo : PrinterProfile
@@ -87,9 +89,6 @@ export default class Printer implements PrinterCommands {
8789 message_type : 'GCommand' ,
8890 message : 'G29'
8991 } )
90-
91- // TODO: This is not really necessary, is it!?
92- this . autoHome ( )
9392 }
9493
9594 /**
@@ -112,19 +111,27 @@ export default class Printer implements PrinterCommands {
112111 const current_position = this . axisPositions [ axis ]
113112 let new_position = direction === '+' ? current_position + distance : current_position - distance
114113
115- // Check for printer limits to avoid crusing things
116- if ( new_position < 0 ) new_position = 0
117- else if ( axis !== 'e' && new_position > this . printerInfo . dimensions [ axis ] ) {
118- new_position = this . printerInfo . dimensions [ axis ]
114+ // Check for printer limits to avoid crusing things (only for X, Y, Z)
115+ if ( axis !== 'e0' && axis !== 'e1' ) {
116+ if ( new_position < 0 ) new_position = 0
117+ else if ( new_position > this . printerInfo . dimensions [ axis ] ) {
118+ new_position = this . printerInfo . dimensions [ axis ]
119+ }
119120 }
120121
121122 // Check for hotend temperature before moving
122- if ( axis === 'e ' && ( Math . abs ( this . printerInfo . temperatures . e0 - this . printerInfo . temperatures . e0_set ) > 3
123+ if ( axis === 'e0 ' && ( Math . abs ( this . printerInfo . temperatures . e0 - this . printerInfo . temperatures . e0_set ) > 3
123124 || this . printerInfo . temperatures . e0 < this . hotendMinTemp ) ) {
124125 console . error ( 'Extruder temp very different from target temp' )
125126 return
126127 }
127128
129+ if ( axis === 'e1' && ( Math . abs ( this . printerInfo . temperatures . e1 - this . printerInfo . temperatures . e1_set ) > 3
130+ || this . printerInfo . temperatures . e1 < this . hotendMinTemp ) ) {
131+ console . error ( 'Extruder temp very different from target temp' )
132+ return
133+ }
134+
128135 wsClient . sendCommand ( {
129136 message_type : 'GCommand' ,
130137 message : `G1 ${ axis } ${ new_position } ` . toUpperCase ( )
0 commit comments