-#ifndef EXTURDER_MODULE_H
-#define EXTRUDER_MODULE_H
+#pragma once
#include "Tool.h"
#include "Pin.h"
+#include <tuple>
+
class StepperMotor;
-class Block;
// NOTE Tool is also a module, no need for multiple inheritance here
class Extruder : public Tool {
public:
- Extruder(uint16_t config_identifier, bool single= false);
- virtual ~Extruder() {}
+ Extruder(uint16_t config_identifier);
+ virtual ~Extruder();
void on_module_loaded();
- void on_config_reload(void* argument);
void on_gcode_received(void*);
- void on_gcode_execute(void* argument);
- void on_block_begin(void* argument);
- void on_block_end(void* argument);
- void on_play(void* argument);
- void on_pause(void* argument);
- void on_halt(void* argument);
- void on_speed_change(void* argument);
- uint32_t acceleration_tick(uint32_t dummy);
- uint32_t stepper_motor_finished_move(uint32_t dummy);
- Block* append_empty_block();
+
+ void select();
+ void deselect();
private:
+ void config_load();
void on_get_public_data(void* argument);
+ void on_set_public_data(void* argument);
+ float check_max_speeds(float target, float isecs);
- StepperMotor* stepper_motor;
- Pin step_pin; // Step pin for the stepper driver
- Pin dir_pin; // Dir pin for the stepper driver
- Pin en_pin;
-
- float target_position; // End point ( in mm ) for the current move
- float current_position; // Current point ( in mm ) for the current move, incremented every time a move is executed
- float unstepped_distance; // overflow buffer for requested moves that are less than 1 step
- Block* current_block; // Current block we are stepping, same as Stepper's one
+ StepperMotor *stepper_motor;
// kept together so they can be passed as public data
struct {
- float steps_per_millimeter; // Steps to travel one millimeter
float filament_diameter; // filament diameter
float extruder_multiplier; // flow rate 1.0 == 100%
- float acceleration; // extruder accleration SOLO setting
float retract_length; // firmware retract length
};
- float volumetric_multiplier;
- float feed_rate; //
- float max_speed;
-
- float travel_ratio;
- float travel_distance;
+ float volumetric_multiplier;
+ float max_volumetric_rate; // used for calculating volumetric rate in mm³/sec
// for firmware retract
- float retract_feedrate;
- float retract_recover_feedrate;
- float retract_recover_length;
- float retract_zlift_length;
- float retract_zlift_feedrate;
+ float retract_feedrate;
+ float retract_recover_feedrate;
+ float retract_recover_length;
+ float retract_zlift_length;
+ float retract_zlift_feedrate;
+
+ // for saving and restoring extruder position
+ std::tuple<float, float, int32_t> saved_position;
- char mode; // extruder motion mode, OFF, SOLO, or FOLLOW
struct {
- bool absolute_mode:1; // absolute/relative coordinate mode switch
- bool paused:1;
- bool single_config:1;
+ uint8_t motor_id:8;
bool retracted:1;
bool cancel_zlift_restore:1; // hack to stop a G11 zlift restore from overring an absolute Z setting
+ bool selected:1;
+ bool saved_selected:1;
};
-
-
};
-
-#endif