Roll back 1 day to avoid babystepping changes
This commit is contained in:
@@ -153,8 +153,8 @@ void stepperTask(void* parameter) {
|
||||
remaining--;
|
||||
}
|
||||
else {
|
||||
Stepper::pulse_phase_isr();
|
||||
remaining = Stepper::block_phase_isr();
|
||||
Stepper::stepper_pulse_phase_isr();
|
||||
remaining = Stepper::stepper_block_phase_isr();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
typedef uint32_t hal_timer_t;
|
||||
#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
|
||||
|
||||
#define HAL_TIMER_RATE F_CPU // frequency of timers peripherals
|
||||
#define HAL_TIMER_RATE SystemCoreClock // frequency of timers peripherals
|
||||
|
||||
#define STEP_TIMER_NUM 0 // index of timer to use for stepper (also +1 for 32bits counter)
|
||||
#define PULSE_TIMER_NUM STEP_TIMER_NUM
|
||||
|
||||
@@ -345,7 +345,7 @@ void disable_all_steppers() {
|
||||
|
||||
void event_probe_recover() {
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
host_prompt_do(PROMPT_INFO, PSTR("G29 Retrying"), DISMISS_STR);
|
||||
host_prompt_do(PROMPT_INFO, PSTR("G29 Retrying"), PSTR("Dismiss"));
|
||||
#endif
|
||||
#ifdef ACTION_ON_G29_RECOVER
|
||||
host_action(PSTR(ACTION_ON_G29_RECOVER));
|
||||
|
||||
@@ -295,6 +295,7 @@
|
||||
#define BOARD_GTM32_MINI_A30 4022 // STM32F103VET6 controller
|
||||
#define BOARD_GTM32_REV_B 4023 // STM32F103VET6 controller
|
||||
|
||||
|
||||
//
|
||||
// ARM Cortex-M4F
|
||||
//
|
||||
@@ -339,11 +340,6 @@
|
||||
#define BOARD_MRR_ESPE 6002
|
||||
#define BOARD_E4D_BOX 6003 // E4d@BOX
|
||||
|
||||
//
|
||||
// SAMD51 ARM Cortex M4
|
||||
//
|
||||
#define BOARD_AGCM4_RAMPS_144 6100 // RAMPS 1.4.4
|
||||
|
||||
//
|
||||
// Simulations
|
||||
//
|
||||
|
||||
@@ -49,6 +49,14 @@ void Babystep::step_axis(const AxisEnum axis) {
|
||||
}
|
||||
}
|
||||
|
||||
void Babystep::task() {
|
||||
#if EITHER(BABYSTEP_XY, I2C_POSITION_ENCODERS)
|
||||
LOOP_XYZ(axis) step_axis((AxisEnum)axis);
|
||||
#else
|
||||
step_axis(Z_AXIS);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Babystep::add_mm(const AxisEnum axis, const float &mm) {
|
||||
add_steps(axis, mm * planner.settings.axis_steps_per_mm[axis]);
|
||||
}
|
||||
|
||||
@@ -55,15 +55,7 @@ public:
|
||||
|
||||
static void add_steps(const AxisEnum axis, const int16_t distance);
|
||||
static void add_mm(const AxisEnum axis, const float &mm);
|
||||
|
||||
//
|
||||
// Called by the Temperature ISR to
|
||||
// apply accumulated babysteps to the axes.
|
||||
//
|
||||
static inline void task() {
|
||||
LOOP_L_N(axis, BS_TODO_AXIS(Z_AXIS)) step_axis((AxisEnum)axis);
|
||||
}
|
||||
|
||||
static void task();
|
||||
private:
|
||||
static void step_axis(const AxisEnum axis);
|
||||
};
|
||||
|
||||
@@ -64,8 +64,7 @@ void host_action(const char * const pstr, const bool eol) {
|
||||
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
|
||||
const char CONTINUE_STR[] PROGMEM = "Continue",
|
||||
DISMISS_STR[] PROGMEM = "Dismiss";
|
||||
const char CONTINUE_STR[] PROGMEM = "Continue";
|
||||
|
||||
#if HAS_RESUME_CONTINUE
|
||||
extern bool wait_for_user;
|
||||
@@ -85,78 +84,70 @@ void host_action(const char * const pstr, const bool eol) {
|
||||
if (eol) SERIAL_EOL();
|
||||
}
|
||||
|
||||
void host_action_prompt_plus(const char * const ptype, const char * const pstr, const char extra_char='\0') {
|
||||
void host_action_prompt_plus(const char * const ptype, const char * const pstr, const bool eol=true) {
|
||||
host_action_prompt(ptype, false);
|
||||
SERIAL_CHAR(' ');
|
||||
serialprintPGM(pstr);
|
||||
if (extra_char != '\0') SERIAL_CHAR(extra_char);
|
||||
SERIAL_EOL();
|
||||
}
|
||||
void host_action_prompt_begin(const PromptReason reason, const char * const pstr, const char extra_char/*='\0'*/) {
|
||||
host_action_prompt_end();
|
||||
host_prompt_reason = reason;
|
||||
host_action_prompt_plus(PSTR("begin"), pstr, extra_char);
|
||||
if (eol) SERIAL_EOL();
|
||||
}
|
||||
void host_action_prompt_begin(const char * const pstr, const bool eol/*=true*/) { host_action_prompt_plus(PSTR("begin"), pstr, eol); }
|
||||
void host_action_prompt_button(const char * const pstr) { host_action_prompt_plus(PSTR("button"), pstr); }
|
||||
void host_action_prompt_end() { host_action_prompt(PSTR("end")); }
|
||||
void host_action_prompt_show() { host_action_prompt(PSTR("show")); }
|
||||
void host_prompt_do(const PromptReason reason, const char * const pstr, const char * const btn1/*=nullptr*/, const char * const btn2/*=nullptr*/) {
|
||||
host_action_prompt_begin(reason, pstr);
|
||||
if (btn1) host_action_prompt_button(btn1);
|
||||
if (btn2) host_action_prompt_button(btn2);
|
||||
void host_prompt_do(const PromptReason reason, const char * const pstr, const char * const pbtn/*=nullptr*/) {
|
||||
host_prompt_reason = reason;
|
||||
host_action_prompt_end();
|
||||
host_action_prompt_begin(pstr);
|
||||
if (pbtn) host_action_prompt_button(pbtn);
|
||||
host_action_prompt_show();
|
||||
}
|
||||
|
||||
void filament_load_host_prompt() {
|
||||
const bool disable_to_continue = (false
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
|| runout.filament_ran_out
|
||||
#endif
|
||||
);
|
||||
host_prompt_do(PROMPT_FILAMENT_RUNOUT, PSTR("Paused"), PSTR("PurgeMore"),
|
||||
disable_to_continue ? PSTR("DisableRunout") : CONTINUE_STR
|
||||
);
|
||||
inline void say_m876_response(const char * const pstr) {
|
||||
SERIAL_ECHOPGM("M876 Responding PROMPT_");
|
||||
serialprintPGM(pstr);
|
||||
SERIAL_EOL();
|
||||
}
|
||||
|
||||
//
|
||||
// Handle responses from the host, such as:
|
||||
// - Filament runout responses: Purge More, Continue
|
||||
// - General "Continue" response
|
||||
// - Resume Print response
|
||||
// - Dismissal of info
|
||||
//
|
||||
void host_response_handler(const uint8_t response) {
|
||||
#ifdef DEBUG_HOST_ACTIONS
|
||||
static const char m876_prefix[] PROGMEM = "M876 Handle Re";
|
||||
serialprintPGM(m876_prefix); SERIAL_ECHOLNPAIR("ason: ", host_prompt_reason);
|
||||
serialprintPGM(m876_prefix); SERIAL_ECHOLNPAIR("sponse: ", response);
|
||||
SERIAL_ECHOLNPAIR("M876 Handle Reason: ", host_prompt_reason);
|
||||
SERIAL_ECHOLNPAIR("M876 Handle Response: ", response);
|
||||
#endif
|
||||
const char *msg = PSTR("UNKNOWN STATE");
|
||||
const PromptReason hpr = host_prompt_reason;
|
||||
host_prompt_reason = PROMPT_NOT_DEFINED; // Reset now ahead of logic
|
||||
host_prompt_reason = PROMPT_NOT_DEFINED;
|
||||
switch (hpr) {
|
||||
case PROMPT_FILAMENT_RUNOUT:
|
||||
msg = PSTR("FILAMENT_RUNOUT");
|
||||
switch (response) {
|
||||
|
||||
case 0: // "Purge More" button
|
||||
#if HAS_LCD_MENU && ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; // Simulate menu selection (menu exits, doesn't extrude more)
|
||||
#endif
|
||||
filament_load_host_prompt(); // Initiate another host prompt. (NOTE: The loop in load_filament may also do this!)
|
||||
break;
|
||||
|
||||
case 1: // "Continue" / "Disable Runout" button
|
||||
#if HAS_LCD_MENU && ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; // Simulate menu selection
|
||||
#endif
|
||||
if (response == 0) {
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE;
|
||||
#endif
|
||||
host_action_prompt_end(); // Close current prompt
|
||||
host_action_prompt_begin(PSTR("Paused"));
|
||||
host_action_prompt_button(PSTR("Purge More"));
|
||||
if (false
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
if (runout.filament_ran_out) { // Disable a triggered sensor
|
||||
runout.enabled = false;
|
||||
runout.reset();
|
||||
}
|
||||
|| runout.filament_ran_out
|
||||
#endif
|
||||
break;
|
||||
)
|
||||
host_action_prompt_button(PSTR("DisableRunout"));
|
||||
else {
|
||||
host_prompt_reason = PROMPT_FILAMENT_RUNOUT;
|
||||
host_action_prompt_button(CONTINUE_STR);
|
||||
}
|
||||
host_action_prompt_show();
|
||||
}
|
||||
else if (response == 1) {
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
if (runout.filament_ran_out) {
|
||||
runout.enabled = false;
|
||||
runout.reset();
|
||||
}
|
||||
#endif
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case PROMPT_USER_CONTINUE:
|
||||
@@ -177,9 +168,7 @@ void host_action(const char * const pstr, const bool eol) {
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
SERIAL_ECHOPGM("M876 Responding PROMPT_");
|
||||
serialprintPGM(msg);
|
||||
SERIAL_EOL();
|
||||
say_m876_response(msg);
|
||||
}
|
||||
|
||||
#endif // HOST_PROMPT_SUPPORT
|
||||
|
||||
@@ -46,7 +46,7 @@ void host_action(const char * const pstr, const bool eol=true);
|
||||
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
|
||||
extern const char CONTINUE_STR[], DISMISS_STR[];
|
||||
extern const char CONTINUE_STR[];
|
||||
|
||||
enum PromptReason : uint8_t {
|
||||
PROMPT_NOT_DEFINED,
|
||||
@@ -61,15 +61,13 @@ void host_action(const char * const pstr, const bool eol=true);
|
||||
|
||||
void host_response_handler(const uint8_t response);
|
||||
void host_action_notify(const char * const message);
|
||||
void host_action_prompt_begin(const PromptReason reason, const char * const pstr, const char extra_char='\0');
|
||||
void host_action_prompt_begin(const char * const pstr, const bool eol=true);
|
||||
void host_action_prompt_button(const char * const pstr);
|
||||
void host_action_prompt_end();
|
||||
void host_action_prompt_show();
|
||||
void host_prompt_do(const PromptReason reason, const char * const pstr, const char * const btn1=nullptr, const char * const btn2=nullptr);
|
||||
inline void host_prompt_open(const PromptReason reason, const char * const pstr, const char * const btn1=nullptr, const char * const btn2=nullptr) {
|
||||
if (host_prompt_reason == PROMPT_NOT_DEFINED) host_prompt_do(reason, pstr, btn1, btn2);
|
||||
void host_prompt_do(const PromptReason type, const char * const pstr, const char * const pbtn=nullptr);
|
||||
inline void host_prompt_open(const PromptReason reason, const char * const pstr, const char * const pbtn=nullptr) {
|
||||
if (host_prompt_reason == PROMPT_NOT_DEFINED) host_prompt_do(reason, pstr, pbtn);
|
||||
}
|
||||
|
||||
void filament_load_host_prompt();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -67,10 +67,9 @@
|
||||
|
||||
static xyze_pos_t resume_position;
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
PauseMenuResponse pause_menu_response;
|
||||
PauseMode pause_mode = PAUSE_MODE_PAUSE_PRINT;
|
||||
#endif
|
||||
PauseMode pause_mode = PAUSE_MODE_PAUSE_PRINT;
|
||||
|
||||
PauseMenuResponse pause_menu_response;
|
||||
|
||||
fil_change_settings_t fc_settings[EXTRUDERS];
|
||||
|
||||
@@ -86,11 +85,7 @@ fil_change_settings_t fc_settings[EXTRUDERS];
|
||||
|
||||
#if HAS_BUZZER
|
||||
static void filament_change_beep(const int8_t max_beep_count, const bool init=false) {
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
if (pause_mode == PAUSE_MODE_PAUSE_PRINT) return;
|
||||
#endif
|
||||
|
||||
if (pause_mode == PAUSE_MODE_PAUSE_PRINT) return;
|
||||
static millis_t next_buzz = 0;
|
||||
static int8_t runout_beep = 0;
|
||||
|
||||
@@ -191,7 +186,11 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
|
||||
+ active_extruder
|
||||
#endif
|
||||
;
|
||||
host_action_prompt_begin(PROMPT_USER_CONTINUE, PSTR("Load Filament T"), tool);
|
||||
host_prompt_reason = PROMPT_USER_CONTINUE;
|
||||
host_action_prompt_end();
|
||||
host_action_prompt_begin(PSTR("Load Filament T"), false);
|
||||
SERIAL_CHAR(tool);
|
||||
SERIAL_EOL();
|
||||
host_action_prompt_button(CONTINUE_STR);
|
||||
host_action_prompt_show();
|
||||
#endif
|
||||
@@ -248,10 +247,10 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
|
||||
|
||||
wait_for_user = true;
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Filament Purging..."), CONTINUE_STR);
|
||||
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Filament Purge Running..."), CONTINUE_STR);
|
||||
#endif
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onUserConfirmRequired_P(PSTR("Filament Purging..."));
|
||||
ExtUI::onUserConfirmRequired_P(PSTR("Filament Purge Running..."));
|
||||
#endif
|
||||
for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count)
|
||||
do_pause_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE);
|
||||
@@ -270,13 +269,27 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
|
||||
do_pause_e_move(purge_length, ADVANCED_PAUSE_PURGE_FEEDRATE);
|
||||
}
|
||||
|
||||
// Show "Purge More" / "Resume" menu and wait for reply
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
filament_load_host_prompt(); // Initiate another host prompt. (NOTE: host_response_handler may also do this!)
|
||||
host_prompt_reason = PROMPT_FILAMENT_RUNOUT;
|
||||
host_action_prompt_end(); // Close current prompt
|
||||
host_action_prompt_begin(PSTR("Paused"));
|
||||
host_action_prompt_button(PSTR("PurgeMore"));
|
||||
if (false
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
|| runout.filament_ran_out
|
||||
#endif
|
||||
)
|
||||
host_action_prompt_button(PSTR("DisableRunout"));
|
||||
else {
|
||||
host_prompt_reason = PROMPT_FILAMENT_RUNOUT;
|
||||
host_action_prompt_button(CONTINUE_STR);
|
||||
}
|
||||
host_action_prompt_show();
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
if (show_lcd) {
|
||||
// Show "Purge More" / "Resume" menu and wait for reply
|
||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||
wait_for_user = false;
|
||||
lcd_pause_show_message(PAUSE_MESSAGE_OPTION);
|
||||
@@ -396,7 +409,7 @@ bool pause_print(const float &retract, const xyz_pos_t &park_point, const float
|
||||
#endif
|
||||
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
host_prompt_open(PROMPT_INFO, PSTR("Pause"), DISMISS_STR);
|
||||
host_prompt_open(PROMPT_INFO, PSTR("Pause"), PSTR("Dismiss"));
|
||||
#endif
|
||||
|
||||
if (!DEBUGGING(DRYRUN) && unload_length && thermalManager.targetTooColdToExtrude(active_extruder)) {
|
||||
@@ -667,7 +680,7 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
|
||||
--did_pause_print;
|
||||
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
host_prompt_open(PROMPT_INFO, PSTR("Resuming"), DISMISS_STR);
|
||||
host_prompt_open(PROMPT_INFO, PSTR("Resuming"), PSTR("Dismiss"));
|
||||
#endif
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
|
||||
@@ -59,15 +59,14 @@ enum PauseMessage : char {
|
||||
PAUSE_MESSAGE_HEATING
|
||||
};
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
enum PauseMenuResponse : char {
|
||||
PAUSE_RESPONSE_WAIT_FOR,
|
||||
PAUSE_RESPONSE_EXTRUDE_MORE,
|
||||
PAUSE_RESPONSE_RESUME_PRINT
|
||||
};
|
||||
extern PauseMenuResponse pause_menu_response;
|
||||
extern PauseMode pause_mode;
|
||||
#endif
|
||||
enum PauseMenuResponse : char {
|
||||
PAUSE_RESPONSE_WAIT_FOR,
|
||||
PAUSE_RESPONSE_EXTRUDE_MORE,
|
||||
PAUSE_RESPONSE_RESUME_PRINT
|
||||
};
|
||||
|
||||
extern PauseMode pause_mode;
|
||||
extern PauseMenuResponse pause_menu_response;
|
||||
|
||||
extern fil_change_settings_t fc_settings[EXTRUDERS];
|
||||
|
||||
|
||||
@@ -92,7 +92,11 @@ void event_filament_runout() {
|
||||
|
||||
//action:out_of_filament
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
host_action_prompt_begin(PROMPT_FILAMENT_RUNOUT, PSTR("FilamentRunout T"), tool);
|
||||
host_prompt_reason = PROMPT_FILAMENT_RUNOUT;
|
||||
host_action_prompt_end();
|
||||
host_action_prompt_begin(PSTR("FilamentRunout T"), false);
|
||||
SERIAL_CHAR(tool);
|
||||
SERIAL_EOL();
|
||||
host_action_prompt_show();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -31,9 +31,7 @@
|
||||
* M876: Handle Prompt Response
|
||||
*/
|
||||
void GcodeSuite::M876() {
|
||||
|
||||
if (parser.seenval('S')) host_response_handler((uint8_t)parser.value_int());
|
||||
|
||||
}
|
||||
|
||||
#endif // HOST_PROMPT_SUPPORT && !EMERGENCY_PARSER
|
||||
|
||||
@@ -74,7 +74,7 @@ void GcodeSuite::M24() {
|
||||
host_action_resume();
|
||||
#endif
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
host_prompt_open(PROMPT_INFO, PSTR("Resuming SD"), DISMISS_STR);
|
||||
host_prompt_open(PROMPT_INFO, PSTR("Resuming SD"), PSTR("Dismiss"));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -37,10 +37,6 @@
|
||||
#ifdef __MARLIN_FIRMWARE__
|
||||
// __MARLIN_FIRMWARE__ exists when compiled within Marlin.
|
||||
#include "pin_mappings.h"
|
||||
#undef max
|
||||
#define max(a,b) ((a)>(b)?(a):(b))
|
||||
#undef min
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
#else
|
||||
namespace UI {
|
||||
static inline uint32_t safe_millis() {return millis();};
|
||||
|
||||
@@ -27,15 +27,6 @@
|
||||
* without adding new pin definitions to the board.
|
||||
*/
|
||||
|
||||
#ifdef S6_TFT_PINMAP
|
||||
#ifndef __MARLIN_FIRMWARE__
|
||||
#error "This pin mapping requires Marlin."
|
||||
#endif
|
||||
|
||||
#define CLCD_SPI_CS PC7
|
||||
#define CLCD_MOD_RESET PC6
|
||||
#endif
|
||||
|
||||
#ifdef CR10_TFT_PINMAP
|
||||
#ifndef __MARLIN_FIRMWARE__
|
||||
#error "This pin mapping requires Marlin."
|
||||
|
||||
@@ -1504,7 +1504,7 @@ void MarlinUI::update() {
|
||||
host_action_cancel();
|
||||
#endif
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
host_prompt_open(PROMPT_INFO, PSTR("UI Aborted"), DISMISS_STR);
|
||||
host_prompt_open(PROMPT_INFO, PSTR("UI Aborted"), PSTR("Dismiss"));
|
||||
#endif
|
||||
print_job_timer.stop();
|
||||
set_status_P(GET_TEXT(MSG_PRINT_ABORTED));
|
||||
|
||||
@@ -709,59 +709,6 @@ void Planner::init() {
|
||||
|
||||
#define MINIMAL_STEP_RATE 120
|
||||
|
||||
/**
|
||||
* Get the current block for processing
|
||||
* and mark the block as busy.
|
||||
* Return nullptr if the buffer is empty
|
||||
* or if there is a first-block delay.
|
||||
*
|
||||
* WARNING: Called from Stepper ISR context!
|
||||
*/
|
||||
block_t* Planner::get_current_block() {
|
||||
// Get the number of moves in the planner queue so far
|
||||
const uint8_t nr_moves = movesplanned();
|
||||
|
||||
// If there are any moves queued ...
|
||||
if (nr_moves) {
|
||||
|
||||
// If there is still delay of delivery of blocks running, decrement it
|
||||
if (delay_before_delivering) {
|
||||
--delay_before_delivering;
|
||||
// If the number of movements queued is less than 3, and there is still time
|
||||
// to wait, do not deliver anything
|
||||
if (nr_moves < 3 && delay_before_delivering) return nullptr;
|
||||
delay_before_delivering = 0;
|
||||
}
|
||||
|
||||
// If we are here, there is no excuse to deliver the block
|
||||
block_t * const block = &block_buffer[block_buffer_tail];
|
||||
|
||||
// No trapezoid calculated? Don't execute yet.
|
||||
if (TEST(block->flag, BLOCK_BIT_RECALCULATE)) return nullptr;
|
||||
|
||||
#if HAS_SPI_LCD
|
||||
block_buffer_runtime_us -= block->segment_time_us; // We can't be sure how long an active block will take, so don't count it.
|
||||
#endif
|
||||
|
||||
// As this block is busy, advance the nonbusy block pointer
|
||||
block_buffer_nonbusy = next_block_index(block_buffer_tail);
|
||||
|
||||
// Push block_buffer_planned pointer, if encountered.
|
||||
if (block_buffer_tail == block_buffer_planned)
|
||||
block_buffer_planned = block_buffer_nonbusy;
|
||||
|
||||
// Return the block
|
||||
return block;
|
||||
}
|
||||
|
||||
// The queue became empty
|
||||
#if HAS_SPI_LCD
|
||||
clear_block_buffer_runtime(); // paranoia. Buffer is empty now - so reset accumulated time to zero.
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate trapezoid parameters, multiplying the entry- and exit-speeds
|
||||
* by the provided factors.
|
||||
@@ -1551,7 +1498,8 @@ void Planner::quick_stop() {
|
||||
// must be handled: The tail could change between the read and the assignment
|
||||
// so this must be enclosed in a critical section
|
||||
|
||||
const bool was_enabled = stepper.suspend();
|
||||
const bool was_enabled = STEPPER_ISR_ENABLED();
|
||||
if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
|
||||
// Drop all queue entries
|
||||
block_buffer_nonbusy = block_buffer_planned = block_buffer_head = block_buffer_tail;
|
||||
@@ -1569,7 +1517,7 @@ void Planner::quick_stop() {
|
||||
cleaning_buffer_counter = 1000;
|
||||
|
||||
// Reenable Stepper ISR
|
||||
if (was_enabled) stepper.wake_up();
|
||||
if (was_enabled) ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
|
||||
// And stop the stepper ISR
|
||||
stepper.quick_stop();
|
||||
@@ -1600,12 +1548,13 @@ float Planner::get_axis_position_mm(const AxisEnum axis) {
|
||||
if (axis == CORE_AXIS_1 || axis == CORE_AXIS_2) {
|
||||
|
||||
// Protect the access to the position.
|
||||
const bool was_enabled = stepper.suspend();
|
||||
const bool was_enabled = STEPPER_ISR_ENABLED();
|
||||
if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
|
||||
const int32_t p1 = stepper.position(CORE_AXIS_1),
|
||||
p2 = stepper.position(CORE_AXIS_2);
|
||||
|
||||
if (was_enabled) stepper.wake_up();
|
||||
if (was_enabled) ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
|
||||
// ((a1+a2)+(a1-a2))/2 -> (a1+a2+a1-a2)/2 -> (a1+a1)/2 -> a1
|
||||
// ((a1+a2)-(a1-a2))/2 -> (a1+a2-a1+a2)/2 -> (a2+a2)/2 -> a2
|
||||
@@ -2055,12 +2004,13 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||
|
||||
#if HAS_SPI_LCD
|
||||
// Protect the access to the position.
|
||||
const bool was_enabled = stepper.suspend();
|
||||
const bool was_enabled = STEPPER_ISR_ENABLED();
|
||||
if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
|
||||
block_buffer_runtime_us += segment_time_us;
|
||||
block->segment_time_us = segment_time_us;
|
||||
|
||||
if (was_enabled) stepper.wake_up();
|
||||
if (was_enabled) ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
#endif
|
||||
|
||||
block->nominal_speed_sqr = sq(block->millimeters * inverse_secs); // (mm/sec)^2 Always > 0
|
||||
@@ -2872,48 +2822,6 @@ void Planner::set_max_jerk(const AxisEnum axis, float targetValue) {
|
||||
#endif
|
||||
}
|
||||
|
||||
#if HAS_SPI_LCD
|
||||
|
||||
uint16_t Planner::block_buffer_runtime() {
|
||||
#ifdef __AVR__
|
||||
// Protect the access to the variable. Only required for AVR, as
|
||||
// any 32bit CPU offers atomic access to 32bit variables
|
||||
const bool was_enabled = stepper.suspend();
|
||||
#endif
|
||||
|
||||
millis_t bbru = block_buffer_runtime_us;
|
||||
|
||||
#ifdef __AVR__
|
||||
// Reenable Stepper ISR
|
||||
if (was_enabled) stepper.wake_up();
|
||||
#endif
|
||||
|
||||
// To translate µs to ms a division by 1000 would be required.
|
||||
// We introduce 2.4% error here by dividing by 1024.
|
||||
// Doesn't matter because block_buffer_runtime_us is already too small an estimation.
|
||||
bbru >>= 10;
|
||||
// limit to about a minute.
|
||||
NOMORE(bbru, 0xFFFFul);
|
||||
return bbru;
|
||||
}
|
||||
|
||||
void Planner::clear_block_buffer_runtime() {
|
||||
#ifdef __AVR__
|
||||
// Protect the access to the variable. Only required for AVR, as
|
||||
// any 32bit CPU offers atomic access to 32bit variables
|
||||
const bool was_enabled = stepper.suspend();
|
||||
#endif
|
||||
|
||||
block_buffer_runtime_us = 0;
|
||||
|
||||
#ifdef __AVR__
|
||||
// Reenable Stepper ISR
|
||||
if (was_enabled) stepper.wake_up();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(AUTOTEMP)
|
||||
|
||||
void Planner::autotemp_M104_M109() {
|
||||
|
||||
@@ -763,18 +763,60 @@ class Planner {
|
||||
FORCE_INLINE static bool has_blocks_queued() { return (block_buffer_head != block_buffer_tail); }
|
||||
|
||||
/**
|
||||
* Get the current block for processing
|
||||
* and mark the block as busy.
|
||||
* Return nullptr if the buffer is empty
|
||||
* or if there is a first-block delay.
|
||||
*
|
||||
* The current block. nullptr if the buffer is empty.
|
||||
* This also marks the block as busy.
|
||||
* WARNING: Called from Stepper ISR context!
|
||||
*/
|
||||
static block_t* get_current_block();
|
||||
static block_t* get_current_block() {
|
||||
|
||||
// Get the number of moves in the planner queue so far
|
||||
const uint8_t nr_moves = movesplanned();
|
||||
|
||||
// If there are any moves queued ...
|
||||
if (nr_moves) {
|
||||
|
||||
// If there is still delay of delivery of blocks running, decrement it
|
||||
if (delay_before_delivering) {
|
||||
--delay_before_delivering;
|
||||
// If the number of movements queued is less than 3, and there is still time
|
||||
// to wait, do not deliver anything
|
||||
if (nr_moves < 3 && delay_before_delivering) return nullptr;
|
||||
delay_before_delivering = 0;
|
||||
}
|
||||
|
||||
// If we are here, there is no excuse to deliver the block
|
||||
block_t * const block = &block_buffer[block_buffer_tail];
|
||||
|
||||
// No trapezoid calculated? Don't execute yet.
|
||||
if (TEST(block->flag, BLOCK_BIT_RECALCULATE)) return nullptr;
|
||||
|
||||
#if HAS_SPI_LCD
|
||||
block_buffer_runtime_us -= block->segment_time_us; // We can't be sure how long an active block will take, so don't count it.
|
||||
#endif
|
||||
|
||||
// As this block is busy, advance the nonbusy block pointer
|
||||
block_buffer_nonbusy = next_block_index(block_buffer_tail);
|
||||
|
||||
// Push block_buffer_planned pointer, if encountered.
|
||||
if (block_buffer_tail == block_buffer_planned)
|
||||
block_buffer_planned = block_buffer_nonbusy;
|
||||
|
||||
// Return the block
|
||||
return block;
|
||||
}
|
||||
|
||||
// The queue became empty
|
||||
#if HAS_SPI_LCD
|
||||
clear_block_buffer_runtime(); // paranoia. Buffer is empty now - so reset accumulated time to zero.
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* "Discard" the block and "release" the memory.
|
||||
* Called when the current block is no longer needed.
|
||||
* NB: There MUST be a current block to call this function!!
|
||||
*/
|
||||
FORCE_INLINE static void discard_current_block() {
|
||||
if (has_blocks_queued())
|
||||
@@ -782,8 +824,47 @@ class Planner {
|
||||
}
|
||||
|
||||
#if HAS_SPI_LCD
|
||||
static uint16_t block_buffer_runtime();
|
||||
static void clear_block_buffer_runtime();
|
||||
|
||||
static uint16_t block_buffer_runtime() {
|
||||
#ifdef __AVR__
|
||||
// Protect the access to the variable. Only required for AVR, as
|
||||
// any 32bit CPU offers atomic access to 32bit variables
|
||||
bool was_enabled = STEPPER_ISR_ENABLED();
|
||||
if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
#endif
|
||||
|
||||
millis_t bbru = block_buffer_runtime_us;
|
||||
|
||||
#ifdef __AVR__
|
||||
// Reenable Stepper ISR
|
||||
if (was_enabled) ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
#endif
|
||||
|
||||
// To translate µs to ms a division by 1000 would be required.
|
||||
// We introduce 2.4% error here by dividing by 1024.
|
||||
// Doesn't matter because block_buffer_runtime_us is already too small an estimation.
|
||||
bbru >>= 10;
|
||||
// limit to about a minute.
|
||||
NOMORE(bbru, 0xFFFFul);
|
||||
return bbru;
|
||||
}
|
||||
|
||||
static void clear_block_buffer_runtime() {
|
||||
#ifdef __AVR__
|
||||
// Protect the access to the variable. Only required for AVR, as
|
||||
// any 32bit CPU offers atomic access to 32bit variables
|
||||
bool was_enabled = STEPPER_ISR_ENABLED();
|
||||
if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
#endif
|
||||
|
||||
block_buffer_runtime_us = 0;
|
||||
|
||||
#ifdef __AVR__
|
||||
// Reenable Stepper ISR
|
||||
if (was_enabled) ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(AUTOTEMP)
|
||||
|
||||
@@ -203,8 +203,11 @@ uint32_t Stepper::advance_divisor = 0,
|
||||
bool Stepper::bezier_2nd_half; // =false If Bézier curve has been initialized or not
|
||||
#endif
|
||||
|
||||
uint32_t Stepper::nextMainISR = 0;
|
||||
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
|
||||
constexpr uint32_t LA_ADV_NEVER = 0xFFFFFFFF;
|
||||
uint32_t Stepper::nextAdvanceISR = LA_ADV_NEVER,
|
||||
Stepper::LA_isr_rate = LA_ADV_NEVER;
|
||||
uint16_t Stepper::LA_current_adv_steps = 0,
|
||||
@@ -399,13 +402,13 @@ constexpr uint32_t NS_TO_PULSE_TIMER_TICKS(uint32_t NS) { return (NS + (NS_PER_P
|
||||
#define PULSE_HIGH_TICK_COUNT hal_timer_t(NS_TO_PULSE_TIMER_TICKS(_MIN_PULSE_HIGH_NS - _MIN(_MIN_PULSE_HIGH_NS, TIMER_SETUP_NS)))
|
||||
#define PULSE_LOW_TICK_COUNT hal_timer_t(NS_TO_PULSE_TIMER_TICKS(_MIN_PULSE_LOW_NS - _MIN(_MIN_PULSE_LOW_NS, TIMER_SETUP_NS)))
|
||||
|
||||
#define USING_TIMED_PULSE() hal_timer_t start_pulse_count = 0
|
||||
#define START_TIMED_PULSE(DIR) (start_pulse_count = HAL_timer_get_count(PULSE_TIMER_NUM))
|
||||
#define AWAIT_TIMED_PULSE(DIR) while (PULSE_##DIR##_TICK_COUNT > HAL_timer_get_count(PULSE_TIMER_NUM) - start_pulse_count) { }
|
||||
#define USING_TIMED_PULSE() hal_timer_t end_tick_count = 0
|
||||
#define START_TIMED_PULSE(DIR) (end_tick_count = HAL_timer_get_count(PULSE_TIMER_NUM) + PULSE_##DIR##_TICK_COUNT)
|
||||
#define AWAIT_TIMED_PULSE() while (HAL_timer_get_count(PULSE_TIMER_NUM) < end_tick_count) { }
|
||||
#define START_HIGH_PULSE() START_TIMED_PULSE(HIGH)
|
||||
#define AWAIT_HIGH_PULSE() AWAIT_TIMED_PULSE(HIGH)
|
||||
#define START_LOW_PULSE() START_TIMED_PULSE(LOW)
|
||||
#define AWAIT_LOW_PULSE() AWAIT_TIMED_PULSE(LOW)
|
||||
#define AWAIT_HIGH_PULSE() AWAIT_TIMED_PULSE()
|
||||
#define AWAIT_LOW_PULSE() AWAIT_TIMED_PULSE()
|
||||
|
||||
#if MINIMUM_STEPPER_PRE_DIR_DELAY > 0
|
||||
#define DIR_WAIT_BEFORE() DELAY_NS(MINIMUM_STEPPER_PRE_DIR_DELAY)
|
||||
@@ -419,6 +422,11 @@ constexpr uint32_t NS_TO_PULSE_TIMER_TICKS(uint32_t NS) { return (NS + (NS_PER_P
|
||||
#define DIR_WAIT_AFTER()
|
||||
#endif
|
||||
|
||||
void Stepper::wake_up() {
|
||||
// TCNT1 = 0;
|
||||
ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the stepper direction of each axis
|
||||
*
|
||||
@@ -1326,9 +1334,6 @@ HAL_STEP_TIMER_ISR() {
|
||||
#endif
|
||||
|
||||
void Stepper::isr() {
|
||||
|
||||
static uint32_t nextMainISR = 0; // Interval until the next main Stepper Pulse phase (0 = Now)
|
||||
|
||||
#ifndef __AVR__
|
||||
// Disable interrupts, to avoid ISR preemption while we reprogram the period
|
||||
// (AVR enters the ISR with global interrupts disabled, so no need to do it here)
|
||||
@@ -1352,35 +1357,35 @@ void Stepper::isr() {
|
||||
// Enable ISRs to reduce USART processing latency
|
||||
ENABLE_ISRS();
|
||||
|
||||
if (!nextMainISR) pulse_phase_isr(); // 0 = Do coordinated axes Stepper pulses
|
||||
// Run main stepping pulse phase ISR if we have to
|
||||
if (!nextMainISR) Stepper::stepper_pulse_phase_isr();
|
||||
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
if (!nextAdvanceISR) nextAdvanceISR = advance_isr(); // 0 = Do Linear Advance E Stepper pulses
|
||||
// Run linear advance stepper ISR if we have to
|
||||
if (!nextAdvanceISR) nextAdvanceISR = Stepper::advance_isr();
|
||||
#endif
|
||||
|
||||
// ^== Time critical. NOTHING besides pulse generation should be above here!!!
|
||||
|
||||
if (!nextMainISR) nextMainISR = block_phase_isr(); // Manage acc/deceleration, get next block
|
||||
// Run main stepping block processing ISR if we have to
|
||||
if (!nextMainISR) nextMainISR = Stepper::stepper_block_phase_isr();
|
||||
|
||||
// Get the interval to the next ISR call
|
||||
const uint32_t interval = _MIN(
|
||||
nextMainISR // Time until the next Stepper ISR
|
||||
uint32_t interval =
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
, nextAdvanceISR // Come back early for Linear Advance?
|
||||
_MIN(nextAdvanceISR, nextMainISR) // Nearest time interval
|
||||
#else
|
||||
nextMainISR // Remaining stepper ISR time
|
||||
#endif
|
||||
, uint32_t(HAL_TIMER_TYPE_MAX) // Come back in a very long time
|
||||
);
|
||||
;
|
||||
|
||||
//
|
||||
// Compute remaining time for each ISR phase
|
||||
// NEVER : The phase is idle
|
||||
// Zero : The phase will occur on the next ISR call
|
||||
// Non-zero : The phase will occur on a future ISR call
|
||||
//
|
||||
// Limit the value to the maximum possible value of the timer
|
||||
NOMORE(interval, uint32_t(HAL_TIMER_TYPE_MAX));
|
||||
|
||||
// Compute the time remaining for the main isr
|
||||
nextMainISR -= interval;
|
||||
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
// Compute the time remaining for the advance isr
|
||||
if (nextAdvanceISR != LA_ADV_NEVER) nextAdvanceISR -= interval;
|
||||
#endif
|
||||
|
||||
@@ -1466,7 +1471,7 @@ void Stepper::isr() {
|
||||
* call to this method that might cause variation in the timing. The aim
|
||||
* is to keep pulse timing as regular as possible.
|
||||
*/
|
||||
void Stepper::pulse_phase_isr() {
|
||||
void Stepper::stepper_pulse_phase_isr() {
|
||||
|
||||
// If we must abort the current block, do so!
|
||||
if (abort_current_block) {
|
||||
@@ -1543,7 +1548,7 @@ void Stepper::pulse_phase_isr() {
|
||||
// Don't step E here - But remember the number of steps to perform
|
||||
motor_direction(E_AXIS) ? --LA_steps : ++LA_steps;
|
||||
#else
|
||||
step_needed.e = true;
|
||||
step_needed.e = delta_error.e >= 0;
|
||||
#endif
|
||||
}
|
||||
#elif HAS_E0_STEP
|
||||
@@ -1599,14 +1604,20 @@ void Stepper::pulse_phase_isr() {
|
||||
|
||||
#if DISABLED(LIN_ADVANCE)
|
||||
#if ENABLED(MIXING_EXTRUDER)
|
||||
|
||||
if (delta_error.e >= 0) {
|
||||
delta_error.e -= advance_divisor;
|
||||
E_STEP_WRITE(mixer.get_stepper(), INVERT_E_STEP_PIN);
|
||||
}
|
||||
#elif HAS_E0_STEP
|
||||
PULSE_STOP(E);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else // !MIXING_EXTRUDER
|
||||
|
||||
#if HAS_E0_STEP
|
||||
PULSE_STOP(E);
|
||||
#endif
|
||||
|
||||
#endif // !MIXING_EXTRUDER
|
||||
#endif // !LIN_ADVANCE
|
||||
|
||||
#if ISR_MULTI_STEPS
|
||||
if (events_to_do) START_LOW_PULSE();
|
||||
@@ -1619,10 +1630,10 @@ void Stepper::pulse_phase_isr() {
|
||||
// properly schedules blocks from the planner. This is executed after creating
|
||||
// the step pulses, so it is not time critical, as pulses are already done.
|
||||
|
||||
uint32_t Stepper::block_phase_isr() {
|
||||
uint32_t Stepper::stepper_block_phase_isr() {
|
||||
|
||||
// If no queued movements, just wait 1ms for the next block
|
||||
uint32_t interval = (STEPPER_TIMER_RATE) / 1000UL;
|
||||
// If no queued movements, just wait 1ms for the next move
|
||||
uint32_t interval = (STEPPER_TIMER_RATE) / 1000;
|
||||
|
||||
// If there is a current block
|
||||
if (current_block) {
|
||||
@@ -1656,14 +1667,16 @@ uint32_t Stepper::block_phase_isr() {
|
||||
// acc_step_rate is in steps/second
|
||||
|
||||
// step_rate to timer interval and steps per stepper isr
|
||||
interval = calc_timer_interval(acc_step_rate, &steps_per_isr);
|
||||
interval = calc_timer_interval(acc_step_rate, oversampling_factor, &steps_per_isr);
|
||||
acceleration_time += interval;
|
||||
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
// Fire ISR if final adv_rate is reached
|
||||
if (LA_steps && (!LA_use_advance_lead || LA_isr_rate != current_block->advance_speed))
|
||||
initiateLA();
|
||||
#endif
|
||||
if (LA_use_advance_lead) {
|
||||
// Fire ISR if final adv_rate is reached
|
||||
if (LA_steps && LA_isr_rate != current_block->advance_speed) nextAdvanceISR = 0;
|
||||
}
|
||||
else if (LA_steps) nextAdvanceISR = 0;
|
||||
#endif // LIN_ADVANCE
|
||||
}
|
||||
// Are we in Deceleration phase ?
|
||||
else if (step_events_completed > decelerate_after) {
|
||||
@@ -1699,32 +1712,32 @@ uint32_t Stepper::block_phase_isr() {
|
||||
// step_rate is in steps/second
|
||||
|
||||
// step_rate to timer interval and steps per stepper isr
|
||||
interval = calc_timer_interval(step_rate, &steps_per_isr);
|
||||
interval = calc_timer_interval(step_rate, oversampling_factor, &steps_per_isr);
|
||||
deceleration_time += interval;
|
||||
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
if (LA_use_advance_lead) {
|
||||
// Wake up eISR on first deceleration loop and fire ISR if final adv_rate is reached
|
||||
if (step_events_completed <= decelerate_after + steps_per_isr || (LA_steps && LA_isr_rate != current_block->advance_speed)) {
|
||||
initiateLA();
|
||||
nextAdvanceISR = 0;
|
||||
LA_isr_rate = current_block->advance_speed;
|
||||
}
|
||||
}
|
||||
else if (LA_steps) initiateLA();
|
||||
#endif
|
||||
else if (LA_steps) nextAdvanceISR = 0;
|
||||
#endif // LIN_ADVANCE
|
||||
}
|
||||
// We must be in cruise phase otherwise
|
||||
else {
|
||||
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
// If there are any esteps, fire the next advance_isr "now"
|
||||
if (LA_steps && LA_isr_rate != current_block->advance_speed) initiateLA();
|
||||
if (LA_steps && LA_isr_rate != current_block->advance_speed) nextAdvanceISR = 0;
|
||||
#endif
|
||||
|
||||
// Calculate the ticks_nominal for this nominal speed, if not done yet
|
||||
if (ticks_nominal < 0) {
|
||||
// step_rate to timer interval and loops for the nominal speed
|
||||
ticks_nominal = calc_timer_interval(current_block->nominal_rate, &steps_per_isr);
|
||||
ticks_nominal = calc_timer_interval(current_block->nominal_rate, oversampling_factor, &steps_per_isr);
|
||||
}
|
||||
|
||||
// The timer interval is just the nominal value for the nominal speed
|
||||
@@ -1833,17 +1846,17 @@ uint32_t Stepper::block_phase_isr() {
|
||||
// No acceleration / deceleration time elapsed so far
|
||||
acceleration_time = deceleration_time = 0;
|
||||
|
||||
uint8_t oversampling = 0; // Assume no axis smoothing (via oversampling)
|
||||
uint8_t oversampling = 0; // Assume we won't use it
|
||||
|
||||
#if ENABLED(ADAPTIVE_STEP_SMOOTHING)
|
||||
// Decide if axis smoothing is possible
|
||||
// At this point, we must decide if we can use Stepper movement axis smoothing.
|
||||
uint32_t max_rate = current_block->nominal_rate; // Get the maximum rate (maximum event speed)
|
||||
while (max_rate < MIN_STEP_ISR_FREQUENCY) { // As long as more ISRs are possible...
|
||||
max_rate <<= 1; // Try to double the rate
|
||||
if (max_rate >= MAX_STEP_ISR_FREQUENCY_1X) break; // Don't exceed the estimated ISR limit
|
||||
++oversampling; // Increase the oversampling (used for left-shift)
|
||||
while (max_rate < MIN_STEP_ISR_FREQUENCY) {
|
||||
max_rate <<= 1;
|
||||
if (max_rate >= MAX_STEP_ISR_FREQUENCY_1X) break;
|
||||
++oversampling;
|
||||
}
|
||||
oversampling_factor = oversampling; // For all timer interval calculations
|
||||
oversampling_factor = oversampling;
|
||||
#endif
|
||||
|
||||
// Based on the oversampling factor, do the calculations
|
||||
@@ -1881,7 +1894,8 @@ uint32_t Stepper::block_phase_isr() {
|
||||
if ((LA_use_advance_lead = current_block->use_advance_lead)) {
|
||||
LA_final_adv_steps = current_block->final_adv_steps;
|
||||
LA_max_adv_steps = current_block->max_adv_steps;
|
||||
initiateLA(); // Start the ISR
|
||||
//Start the ISR
|
||||
nextAdvanceISR = 0;
|
||||
LA_isr_rate = current_block->advance_speed;
|
||||
}
|
||||
else LA_isr_rate = LA_ADV_NEVER;
|
||||
@@ -1940,7 +1954,7 @@ uint32_t Stepper::block_phase_isr() {
|
||||
#endif
|
||||
|
||||
// Calculate the initial timer interval
|
||||
interval = calc_timer_interval(current_block->initial_rate, &steps_per_isr);
|
||||
interval = calc_timer_interval(current_block->initial_rate, oversampling_factor, &steps_per_isr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2040,7 +2054,6 @@ uint32_t Stepper::block_phase_isr() {
|
||||
|
||||
return interval;
|
||||
}
|
||||
|
||||
#endif // LIN_ADVANCE
|
||||
|
||||
// Check if the given block is busy or not - Must not be called from ISR contexts
|
||||
@@ -2080,7 +2093,7 @@ void Stepper::init() {
|
||||
digipot_motor = 255 * (motor_current[i] / 2.5);
|
||||
dac084s085::setValue(i, digipot_motor);
|
||||
}
|
||||
#endif
|
||||
#endif//MB(ALLIGATOR)
|
||||
|
||||
// Init Microstepping Pins
|
||||
#if HAS_MICROSTEPS
|
||||
@@ -2274,7 +2287,7 @@ void Stepper::init() {
|
||||
|
||||
#if DISABLED(I2S_STEPPER_STREAM)
|
||||
HAL_timer_start(STEP_TIMER_NUM, 122); // Init Stepper ISR to 122 Hz for quick starting
|
||||
wake_up();
|
||||
ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
sei();
|
||||
#endif
|
||||
|
||||
@@ -2328,43 +2341,19 @@ int32_t Stepper::position(const AxisEnum axis) {
|
||||
#ifdef __AVR__
|
||||
// Protect the access to the position. Only required for AVR, as
|
||||
// any 32bit CPU offers atomic access to 32bit variables
|
||||
const bool was_enabled = suspend();
|
||||
const bool was_enabled = STEPPER_ISR_ENABLED();
|
||||
if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
#endif
|
||||
|
||||
const int32_t v = count_position[axis];
|
||||
|
||||
#ifdef __AVR__
|
||||
// Reenable Stepper ISR
|
||||
if (was_enabled) wake_up();
|
||||
if (was_enabled) ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
#endif
|
||||
return v;
|
||||
}
|
||||
|
||||
// Set the current position in steps
|
||||
void Stepper::set_position(const int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e) {
|
||||
planner.synchronize();
|
||||
const bool was_enabled = suspend();
|
||||
_set_position(a, b, c, e);
|
||||
if (was_enabled) wake_up();
|
||||
}
|
||||
|
||||
void Stepper::set_axis_position(const AxisEnum a, const int32_t &v) {
|
||||
planner.synchronize();
|
||||
|
||||
#ifdef __AVR__
|
||||
// Protect the access to the position. Only required for AVR, as
|
||||
// any 32bit CPU offers atomic access to 32bit variables
|
||||
const bool was_enabled = suspend();
|
||||
#endif
|
||||
|
||||
count_position[a] = v;
|
||||
|
||||
#ifdef __AVR__
|
||||
// Reenable Stepper ISR
|
||||
if (was_enabled) wake_up();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Signal endstops were triggered - This function can be called from
|
||||
// an ISR context (Temperature, Stepper or limits ISR), so we must
|
||||
// be very careful here. If the interrupt being preempted was the
|
||||
@@ -2373,7 +2362,8 @@ void Stepper::set_axis_position(const AxisEnum a, const int32_t &v) {
|
||||
// is properly canceled
|
||||
void Stepper::endstop_triggered(const AxisEnum axis) {
|
||||
|
||||
const bool was_enabled = suspend();
|
||||
const bool was_enabled = STEPPER_ISR_ENABLED();
|
||||
if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
endstops_trigsteps[axis] = (
|
||||
#if IS_CORE
|
||||
(axis == CORE_AXIS_2
|
||||
@@ -2388,21 +2378,22 @@ void Stepper::endstop_triggered(const AxisEnum axis) {
|
||||
// Discard the rest of the move if there is a current block
|
||||
quick_stop();
|
||||
|
||||
if (was_enabled) wake_up();
|
||||
if (was_enabled) ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
}
|
||||
|
||||
int32_t Stepper::triggered_position(const AxisEnum axis) {
|
||||
#ifdef __AVR__
|
||||
// Protect the access to the position. Only required for AVR, as
|
||||
// any 32bit CPU offers atomic access to 32bit variables
|
||||
const bool was_enabled = suspend();
|
||||
const bool was_enabled = STEPPER_ISR_ENABLED();
|
||||
if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
#endif
|
||||
|
||||
const int32_t v = endstops_trigsteps[axis];
|
||||
|
||||
#ifdef __AVR__
|
||||
// Reenable Stepper ISR
|
||||
if (was_enabled) wake_up();
|
||||
if (was_enabled) ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
#endif
|
||||
|
||||
return v;
|
||||
@@ -2412,13 +2403,14 @@ void Stepper::report_positions() {
|
||||
|
||||
#ifdef __AVR__
|
||||
// Protect the access to the position.
|
||||
const bool was_enabled = suspend();
|
||||
const bool was_enabled = STEPPER_ISR_ENABLED();
|
||||
if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
#endif
|
||||
|
||||
const xyz_long_t pos = count_position;
|
||||
|
||||
#ifdef __AVR__
|
||||
if (was_enabled) wake_up();
|
||||
if (was_enabled) ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
#endif
|
||||
|
||||
#if CORE_IS_XY || CORE_IS_XZ || ENABLED(DELTA) || IS_SCARA
|
||||
@@ -2579,21 +2571,16 @@ void Stepper::report_positions() {
|
||||
Z_STEP_WRITE(INVERT_Z_STEP_PIN);
|
||||
|
||||
// Restore direction bits
|
||||
DIR_WAIT_BEFORE();
|
||||
|
||||
X_DIR_WRITE(old_dir.x);
|
||||
Y_DIR_WRITE(old_dir.y);
|
||||
Z_DIR_WRITE(old_dir.z);
|
||||
|
||||
DIR_WAIT_AFTER();
|
||||
|
||||
#endif
|
||||
|
||||
} break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
sei();
|
||||
}
|
||||
|
||||
|
||||
+47
-28
@@ -321,13 +321,13 @@ class Stepper {
|
||||
static bool bezier_2nd_half; // If Bézier curve has been initialized or not
|
||||
#endif
|
||||
|
||||
static uint32_t nextMainISR; // time remaining for the next Step ISR
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
static constexpr uint32_t LA_ADV_NEVER = 0xFFFFFFFF;
|
||||
static uint32_t nextAdvanceISR, LA_isr_rate;
|
||||
static uint16_t LA_current_adv_steps, LA_final_adv_steps, LA_max_adv_steps; // Copy from current executed block. Needed because current_block is set to NULL "too early".
|
||||
static int8_t LA_steps;
|
||||
static bool LA_use_advance_lead;
|
||||
#endif
|
||||
#endif // LIN_ADVANCE
|
||||
|
||||
static int32_t ticks_nominal;
|
||||
#if DISABLED(S_CURVE_ACCELERATION)
|
||||
@@ -351,36 +351,28 @@ class Stepper {
|
||||
|
||||
public:
|
||||
|
||||
//
|
||||
// Constructor / initializer
|
||||
//
|
||||
Stepper() {};
|
||||
|
||||
// Initialize stepper hardware
|
||||
static void init();
|
||||
|
||||
// Interrupt Service Routine and phases
|
||||
|
||||
// The stepper subsystem goes to sleep when it runs out of things to execute.
|
||||
// Call this to notify the subsystem that it is time to go to work.
|
||||
static inline void wake_up() { ENABLE_STEPPER_DRIVER_INTERRUPT(); }
|
||||
|
||||
static inline bool is_awake() { return STEPPER_ISR_ENABLED(); }
|
||||
|
||||
static inline bool suspend() {
|
||||
const bool awake = is_awake();
|
||||
if (awake) DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
return awake;
|
||||
}
|
||||
// Interrupt Service Routines
|
||||
|
||||
// The ISR scheduler
|
||||
static void isr();
|
||||
|
||||
// The stepper pulse ISR phase
|
||||
static void pulse_phase_isr();
|
||||
// The stepper pulse phase ISR
|
||||
static void stepper_pulse_phase_isr();
|
||||
|
||||
// The stepper block processing ISR phase
|
||||
static uint32_t block_phase_isr();
|
||||
// The stepper block processing phase ISR
|
||||
static uint32_t stepper_block_phase_isr();
|
||||
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
// The Linear advance ISR phase
|
||||
// The Linear advance stepper ISR
|
||||
static uint32_t advance_isr();
|
||||
FORCE_INLINE static void initiateLA() { nextAdvanceISR = 0; }
|
||||
#endif
|
||||
|
||||
// Check if the given block is busy or not - Must not be called from ISR contexts
|
||||
@@ -389,14 +381,13 @@ class Stepper {
|
||||
// Get the position of a stepper, in steps
|
||||
static int32_t position(const AxisEnum axis);
|
||||
|
||||
// Set the current position in steps
|
||||
static void set_position(const int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e);
|
||||
static inline void set_position(const xyze_long_t &abce) { set_position(abce.a, abce.b, abce.c, abce.e); }
|
||||
static void set_axis_position(const AxisEnum a, const int32_t &v);
|
||||
|
||||
// Report the positions of the steppers, in steps
|
||||
static void report_positions();
|
||||
|
||||
// The stepper subsystem goes to sleep when it runs out of things to execute. Call this
|
||||
// to notify the subsystem that it is time to go to work.
|
||||
static void wake_up();
|
||||
|
||||
// Quickly stop all steppers
|
||||
FORCE_INLINE static void quick_stop() { abort_current_block = true; }
|
||||
|
||||
@@ -462,6 +453,34 @@ class Stepper {
|
||||
static void refresh_motor_power();
|
||||
#endif
|
||||
|
||||
// Set the current position in steps
|
||||
static inline void set_position(const int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e) {
|
||||
planner.synchronize();
|
||||
const bool was_enabled = STEPPER_ISR_ENABLED();
|
||||
if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
_set_position(a, b, c, e);
|
||||
if (was_enabled) ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
}
|
||||
static inline void set_position(const xyze_long_t &abce) { set_position(abce.a, abce.b, abce.c, abce.e); }
|
||||
|
||||
static inline void set_axis_position(const AxisEnum a, const int32_t &v) {
|
||||
planner.synchronize();
|
||||
|
||||
#ifdef __AVR__
|
||||
// Protect the access to the position. Only required for AVR, as
|
||||
// any 32bit CPU offers atomic access to 32bit variables
|
||||
const bool was_enabled = STEPPER_ISR_ENABLED();
|
||||
if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
#endif
|
||||
|
||||
count_position[a] = v;
|
||||
|
||||
#ifdef __AVR__
|
||||
// Reenable Stepper ISR
|
||||
if (was_enabled) ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set direction bits for all steppers
|
||||
static void set_directions();
|
||||
|
||||
@@ -471,11 +490,11 @@ class Stepper {
|
||||
static void _set_position(const int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e);
|
||||
FORCE_INLINE static void _set_position(const abce_long_t &spos) { _set_position(spos.a, spos.b, spos.c, spos.e); }
|
||||
|
||||
FORCE_INLINE static uint32_t calc_timer_interval(uint32_t step_rate, uint8_t* loops) {
|
||||
FORCE_INLINE static uint32_t calc_timer_interval(uint32_t step_rate, uint8_t scale, uint8_t* loops) {
|
||||
uint32_t timer;
|
||||
|
||||
// Scale the frequency, as requested by the caller
|
||||
step_rate <<= oversampling_factor;
|
||||
step_rate <<= scale;
|
||||
|
||||
uint8_t multistep = 1;
|
||||
#if DISABLED(DISABLE_MULTI_STEPPING)
|
||||
|
||||
@@ -65,12 +65,15 @@
|
||||
#include "../libs/private_spi.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(PID_EXTRUSION_SCALING)
|
||||
#if EITHER(BABYSTEPPING, PID_EXTRUSION_SCALING)
|
||||
#include "stepper.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(BABYSTEPPING)
|
||||
#include "../feature/babystep.h"
|
||||
#if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
|
||||
#include "../gcode/gcode.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "printcounter.h"
|
||||
|
||||
@@ -578,13 +578,6 @@
|
||||
#elif MB(E4D_BOX)
|
||||
#include "esp32/pins_E4D.h" // ESP32 env:esp32
|
||||
|
||||
//
|
||||
// Adafruit Grand Central M4 (SAMD51 ARM Cortex-M4)
|
||||
//
|
||||
|
||||
#elif MB(AGCM4_RAMPS_144)
|
||||
#include "samd/pins_RAMPS_144.h" // SAMD51 env:SAMD51_grandcentral_m4
|
||||
|
||||
//
|
||||
// Linux Native Debug board
|
||||
//
|
||||
|
||||
@@ -1,611 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* AGCM4 with RAMPS v1.4.4 pin assignments
|
||||
*/
|
||||
|
||||
#ifndef ARDUINO_GRAND_CENTRAL_M4
|
||||
#error "Oops! Select 'Adafruit Grand Central M4' in 'Tools > Board.'"
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_INFO_NAME
|
||||
#define BOARD_INFO_NAME "AGCM4 RAMPS 1.4.4"
|
||||
#endif
|
||||
|
||||
//
|
||||
// Servos
|
||||
//
|
||||
#define SERVO0_PIN 11
|
||||
#define SERVO1_PIN 6
|
||||
#define SERVO2_PIN 5
|
||||
#define SERVO3_PIN 4
|
||||
|
||||
//
|
||||
// EEPROM
|
||||
//
|
||||
#define E2END 0x7FFF // 32Kb (24lc256)
|
||||
#define I2C_EEPROM // EEPROM on I2C-0
|
||||
|
||||
//
|
||||
// Limit Switches
|
||||
//
|
||||
#define X_MIN_PIN 3
|
||||
#define X_MAX_PIN 2
|
||||
#define Y_MIN_PIN 14
|
||||
#define Y_MAX_PIN 15
|
||||
#define Z_MIN_PIN 18
|
||||
#define Z_MAX_PIN 19
|
||||
|
||||
//
|
||||
// Z Probe (when not Z_MIN_PIN)
|
||||
//
|
||||
#ifndef Z_MIN_PROBE_PIN
|
||||
#define Z_MIN_PROBE_PIN 18
|
||||
#endif
|
||||
|
||||
//
|
||||
// Steppers
|
||||
//
|
||||
#define X_STEP_PIN 67 // Mega/Due:54 - AGCM4:67
|
||||
#define X_DIR_PIN 68 // Mega/Due:55 - AGCM4:68
|
||||
#define X_ENABLE_PIN 38
|
||||
#ifndef X_CS_PIN
|
||||
#define X_CS_PIN 47
|
||||
#endif
|
||||
|
||||
#define Y_STEP_PIN 73 // Mega/Due:60 - AGCM4:73
|
||||
#define Y_DIR_PIN 74 // Mega/Due:61 - AGCM4:74
|
||||
#define Y_ENABLE_PIN 69 // Mega/Due:56 - AGCM4:69
|
||||
#ifndef Y_CS_PIN
|
||||
#define Y_CS_PIN 45
|
||||
#endif
|
||||
|
||||
#define Z_STEP_PIN 46
|
||||
#define Z_DIR_PIN 48
|
||||
#define Z_ENABLE_PIN 54 // Mega/Due:62 - AGCM4:54
|
||||
#ifndef Z_CS_PIN
|
||||
#define Z_CS_PIN 32
|
||||
#endif
|
||||
|
||||
#define Z2_STEP_PIN 36
|
||||
#define Z2_DIR_PIN 34
|
||||
#define Z2_ENABLE_PIN 30
|
||||
#ifndef Z2_CS_PIN
|
||||
#define Z2_CS_PIN 22
|
||||
#endif
|
||||
|
||||
#define E0_STEP_PIN 26
|
||||
#define E0_DIR_PIN 28
|
||||
#define E0_ENABLE_PIN 24
|
||||
#ifndef E0_CS_PIN
|
||||
#define E0_CS_PIN 43
|
||||
#endif
|
||||
|
||||
//
|
||||
// Temperature Sensors
|
||||
//
|
||||
#define TEMP_0_PIN 13
|
||||
#define TEMP_BED_PIN 14
|
||||
#define TEMP_CHAMBER_PIN 15
|
||||
|
||||
//
|
||||
// Heaters / Fans
|
||||
//
|
||||
#define HEATER_0_PIN 10
|
||||
#define HEATER_BED_PIN 8
|
||||
#define FAN_PIN 9
|
||||
#define FAN1_PIN 7
|
||||
#define FAN2_PIN 12
|
||||
|
||||
//
|
||||
// Misc. Functions
|
||||
//
|
||||
#define SDSS 53
|
||||
#define LED_PIN 13
|
||||
|
||||
#ifndef FILWIDTH_PIN
|
||||
#define FILWIDTH_PIN 5 // Analog Input on AUX2
|
||||
#endif
|
||||
|
||||
// RAMPS 1.4 DIO 4 on the servos connector
|
||||
#ifndef FIL_RUNOUT_PIN
|
||||
#define FIL_RUNOUT_PIN 4
|
||||
#endif
|
||||
|
||||
#ifndef PS_ON_PIN
|
||||
#define PS_ON_PIN 39
|
||||
#endif
|
||||
|
||||
#if ENABLED(CASE_LIGHT_ENABLE) && !defined(CASE_LIGHT_PIN) && !defined(SPINDLE_LASER_ENA_PIN)
|
||||
#if NUM_SERVOS <= 1 // Prefer the servo connector
|
||||
#define CASE_LIGHT_PIN 6 // Hardware PWM
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// M3/M4/M5 - Spindle/Laser Control
|
||||
//
|
||||
#if HAS_CUTTER && !defined(SPINDLE_LASER_ENA_PIN)
|
||||
#if !NUM_SERVOS // Use servo connector if possible
|
||||
#define SPINDLE_LASER_ENA_PIN 4 // Pullup or pulldown!
|
||||
#define SPINDLE_LASER_PWM_PIN 6 // Hardware PWM
|
||||
#define SPINDLE_DIR_PIN 5
|
||||
#else
|
||||
#error "No auto-assignable Spindle/Laser pins available."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// TMC software SPI
|
||||
//
|
||||
#if ENABLED(TMC_USE_SW_SPI)
|
||||
#ifndef TMC_SW_MOSI
|
||||
#define TMC_SW_MOSI 58 // Mega/Due:66 - AGCM4:58
|
||||
#endif
|
||||
#ifndef TMC_SW_MISO
|
||||
#define TMC_SW_MISO 44
|
||||
#endif
|
||||
#ifndef TMC_SW_SCK
|
||||
#define TMC_SW_SCK 56 // Mega/Due:64 - AGCM4:56
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_TMC220x
|
||||
/**
|
||||
* TMC2208/TMC2209 stepper drivers
|
||||
*
|
||||
* Hardware serial communication ports.
|
||||
* If undefined software serial is used according to the pins below
|
||||
*/
|
||||
//#define X_HARDWARE_SERIAL Serial1
|
||||
//#define X2_HARDWARE_SERIAL Serial1
|
||||
//#define Y_HARDWARE_SERIAL Serial1
|
||||
//#define Y2_HARDWARE_SERIAL Serial1
|
||||
//#define Z_HARDWARE_SERIAL Serial1
|
||||
//#define Z2_HARDWARE_SERIAL Serial1
|
||||
//#define E0_HARDWARE_SERIAL Serial1
|
||||
//#define E1_HARDWARE_SERIAL Serial1
|
||||
//#define E2_HARDWARE_SERIAL Serial1
|
||||
//#define E3_HARDWARE_SERIAL Serial1
|
||||
//#define E4_HARDWARE_SERIAL Serial1
|
||||
|
||||
//
|
||||
// Software serial
|
||||
//
|
||||
|
||||
#ifndef X_SERIAL_TX_PIN
|
||||
#define X_SERIAL_TX_PIN 47
|
||||
#endif
|
||||
#ifndef X_SERIAL_RX_PIN
|
||||
#define X_SERIAL_RX_PIN 47
|
||||
#endif
|
||||
#ifndef X2_SERIAL_TX_PIN
|
||||
#define X2_SERIAL_TX_PIN -1
|
||||
#endif
|
||||
#ifndef X2_SERIAL_RX_PIN
|
||||
#define X2_SERIAL_RX_PIN -1
|
||||
#endif
|
||||
|
||||
#ifndef Y_SERIAL_TX_PIN
|
||||
#define Y_SERIAL_TX_PIN 45
|
||||
#endif
|
||||
#ifndef Y_SERIAL_RX_PIN
|
||||
#define Y_SERIAL_RX_PIN 45
|
||||
#endif
|
||||
#ifndef Y2_SERIAL_TX_PIN
|
||||
#define Y2_SERIAL_TX_PIN -1
|
||||
#endif
|
||||
#ifndef Y2_SERIAL_RX_PIN
|
||||
#define Y2_SERIAL_RX_PIN -1
|
||||
#endif
|
||||
|
||||
#ifndef Z_SERIAL_TX_PIN
|
||||
#define Z_SERIAL_TX_PIN 32
|
||||
#endif
|
||||
#ifndef Z_SERIAL_RX_PIN
|
||||
#define Z_SERIAL_RX_PIN 32
|
||||
#endif
|
||||
#ifndef Z2_SERIAL_TX_PIN
|
||||
#define Z2_SERIAL_TX_PIN 22
|
||||
#endif
|
||||
#ifndef Z2_SERIAL_RX_PIN
|
||||
#define Z2_SERIAL_RX_PIN 22
|
||||
#endif
|
||||
|
||||
#ifndef E0_SERIAL_TX_PIN
|
||||
#define E0_SERIAL_TX_PIN 43
|
||||
#endif
|
||||
#ifndef E0_SERIAL_RX_PIN
|
||||
#define E0_SERIAL_RX_PIN 43
|
||||
#endif
|
||||
#ifndef E1_SERIAL_TX_PIN
|
||||
#define E1_SERIAL_TX_PIN -1
|
||||
#endif
|
||||
#ifndef E1_SERIAL_RX_PIN
|
||||
#define E1_SERIAL_RX_PIN -1
|
||||
#endif
|
||||
#ifndef E2_SERIAL_TX_PIN
|
||||
#define E2_SERIAL_TX_PIN -1
|
||||
#endif
|
||||
#ifndef E2_SERIAL_RX_PIN
|
||||
#define E2_SERIAL_RX_PIN -1
|
||||
#endif
|
||||
#ifndef E3_SERIAL_TX_PIN
|
||||
#define E3_SERIAL_TX_PIN -1
|
||||
#endif
|
||||
#ifndef E3_SERIAL_RX_PIN
|
||||
#define E3_SERIAL_RX_PIN -1
|
||||
#endif
|
||||
#ifndef E4_SERIAL_TX_PIN
|
||||
#define E4_SERIAL_TX_PIN -1
|
||||
#endif
|
||||
#ifndef E4_SERIAL_RX_PIN
|
||||
#define E4_SERIAL_RX_PIN -1
|
||||
#endif
|
||||
#ifndef E5_SERIAL_TX_PIN
|
||||
#define E5_SERIAL_TX_PIN -1
|
||||
#endif
|
||||
#ifndef E5_SERIAL_RX_PIN
|
||||
#define E5_SERIAL_RX_PIN -1
|
||||
#endif
|
||||
#ifndef E6_SERIAL_TX_PIN
|
||||
#define E6_SERIAL_TX_PIN -1
|
||||
#endif
|
||||
#ifndef E6_SERIAL_RX_PIN
|
||||
#define E6_SERIAL_RX_PIN -1
|
||||
#endif
|
||||
#ifndef E7_SERIAL_TX_PIN
|
||||
#define E7_SERIAL_TX_PIN -1
|
||||
#endif
|
||||
#ifndef E7_SERIAL_RX_PIN
|
||||
#define E7_SERIAL_RX_PIN -1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//////////////////////////
|
||||
// LCDs and Controllers //
|
||||
//////////////////////////
|
||||
|
||||
#if HAS_SPI_LCD
|
||||
|
||||
//
|
||||
// LCD Display output pins
|
||||
//
|
||||
#if ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
|
||||
|
||||
// TO TEST
|
||||
// #define LCD_PINS_RS 49 // CS chip select /SS chip slave select
|
||||
// #define LCD_PINS_ENABLE 51 // SID (MOSI)
|
||||
// #define LCD_PINS_D4 52 // SCK (CLK) clock
|
||||
|
||||
#elif BOTH(NEWPANEL, PANEL_ONE)
|
||||
|
||||
// TO TEST
|
||||
// #define LCD_PINS_RS 40
|
||||
// #define LCD_PINS_ENABLE 42
|
||||
// #define LCD_PINS_D4 57 // Mega/Due:65 - AGCM4:57
|
||||
// #define LCD_PINS_D5 58 // Mega/Due:66 - AGCM4:58
|
||||
// #define LCD_PINS_D6 44
|
||||
// #define LCD_PINS_D7 56 // Mega/Due:64 - AGCM4:56
|
||||
|
||||
#else
|
||||
|
||||
#if ENABLED(CR10_STOCKDISPLAY)
|
||||
|
||||
// TO TEST
|
||||
// #define LCD_PINS_RS 27
|
||||
// #define LCD_PINS_ENABLE 29
|
||||
// #define LCD_PINS_D4 25
|
||||
|
||||
#if DISABLED(NEWPANEL)
|
||||
// TO TEST
|
||||
// #define BEEPER_PIN 37
|
||||
#endif
|
||||
|
||||
#elif ENABLED(ZONESTAR_LCD)
|
||||
|
||||
// TO TEST
|
||||
// #define LCD_PINS_RS 56 // Mega/Due:64 - AGCM4:56
|
||||
// #define LCD_PINS_ENABLE 44
|
||||
// #define LCD_PINS_D4 55 // Mega/Due:63 - AGCM4:55
|
||||
// #define LCD_PINS_D5 40
|
||||
// #define LCD_PINS_D6 42
|
||||
// #define LCD_PINS_D7 57 // Mega/Due:65 - AGCM4:57
|
||||
|
||||
#else
|
||||
|
||||
#if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306)
|
||||
// TO TEST
|
||||
// #define LCD_PINS_DC 25 // Set as output on init
|
||||
// #define LCD_PINS_RS 27 // Pull low for 1s to init
|
||||
// DOGM SPI LCD Support
|
||||
// #define DOGLCD_CS 16
|
||||
// #define DOGLCD_MOSI 17
|
||||
// #define DOGLCD_SCK 23
|
||||
// #define DOGLCD_A0 LCD_PINS_DC
|
||||
#else
|
||||
#define LCD_PINS_RS 16
|
||||
#define LCD_PINS_ENABLE 17
|
||||
#define LCD_PINS_D4 23
|
||||
#define LCD_PINS_D5 25
|
||||
#define LCD_PINS_D6 27
|
||||
#endif
|
||||
|
||||
#define LCD_PINS_D7 29
|
||||
|
||||
#if DISABLED(NEWPANEL)
|
||||
#define BEEPER_PIN 33
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if DISABLED(NEWPANEL)
|
||||
// Buttons attached to a shift register
|
||||
// Not wired yet
|
||||
//#define SHIFT_CLK 38
|
||||
//#define SHIFT_LD 42
|
||||
//#define SHIFT_OUT 40
|
||||
//#define SHIFT_EN 17
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// LCD Display input pins
|
||||
//
|
||||
#if ENABLED(NEWPANEL)
|
||||
|
||||
#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER)
|
||||
|
||||
#define BEEPER_PIN 37
|
||||
|
||||
#if ENABLED(CR10_STOCKDISPLAY)
|
||||
// TO TEST
|
||||
// #define BTN_EN1 17
|
||||
// #define BTN_EN2 23
|
||||
#else
|
||||
#define BTN_EN1 31
|
||||
#define BTN_EN2 33
|
||||
#endif
|
||||
|
||||
#define BTN_ENC 35
|
||||
#ifndef SD_DETECT_PIN
|
||||
#define SD_DETECT_PIN 49
|
||||
#endif
|
||||
#define KILL_PIN 41
|
||||
|
||||
#if ENABLED(BQ_LCD_SMART_CONTROLLER)
|
||||
// TO TEST
|
||||
// #define LCD_BACKLIGHT_PIN 39
|
||||
#endif
|
||||
|
||||
#elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
|
||||
|
||||
// TO TEST
|
||||
// #define BTN_EN1 56 // Mega/Due:64 - AGCM4:56
|
||||
// #define BTN_EN2 72 // Mega/Due:59 - AGCM4:72
|
||||
// #define BTN_ENC 55
|
||||
// #define SD_DETECT_PIN 42
|
||||
|
||||
#elif ENABLED(LCD_I2C_PANELOLU2)
|
||||
|
||||
// TO TEST
|
||||
// #define BTN_EN1 47
|
||||
// #define BTN_EN2 43
|
||||
// #define BTN_ENC 32
|
||||
// #define LCD_SDSS SDSS
|
||||
// #define KILL_PIN 41
|
||||
|
||||
#elif ENABLED(LCD_I2C_VIKI)
|
||||
|
||||
// TO TEST
|
||||
// #define BTN_EN1 40 // http://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42.
|
||||
// #define BTN_EN2 42
|
||||
// #define BTN_ENC -1
|
||||
|
||||
// #define LCD_SDSS SDSS
|
||||
// #define SD_DETECT_PIN 49
|
||||
|
||||
#elif ANY(VIKI2, miniVIKI)
|
||||
|
||||
// TO TEST
|
||||
// #define DOGLCD_CS 45
|
||||
// #define DOGLCD_A0 44
|
||||
// #define LCD_SCREEN_ROT_180
|
||||
|
||||
// #define BEEPER_PIN 33
|
||||
// #define STAT_LED_RED_PIN 32
|
||||
// #define STAT_LED_BLUE_PIN 35
|
||||
|
||||
// #define BTN_EN1 22
|
||||
// #define BTN_EN2 7
|
||||
// #define BTN_ENC 39
|
||||
|
||||
// #define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board
|
||||
// #define KILL_PIN 31
|
||||
|
||||
#elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
|
||||
|
||||
// TO TEST
|
||||
// #define DOGLCD_CS 29
|
||||
// #define DOGLCD_A0 27
|
||||
|
||||
// #define BEEPER_PIN 23
|
||||
// #define LCD_BACKLIGHT_PIN 33
|
||||
|
||||
// #define BTN_EN1 35
|
||||
// #define BTN_EN2 37
|
||||
// #define BTN_ENC 31
|
||||
|
||||
// #define LCD_SDSS SDSS
|
||||
// #define SD_DETECT_PIN 49
|
||||
// #define KILL_PIN 41
|
||||
|
||||
#elif EITHER(MKS_MINI_12864, FYSETC_MINI_12864)
|
||||
|
||||
// TO TEST
|
||||
//#define BEEPER_PIN 37
|
||||
//#define BTN_ENC 35
|
||||
//#define SD_DETECT_PIN 49
|
||||
|
||||
//#ifndef KILL_PIN
|
||||
// #define KILL_PIN 41
|
||||
//#endif
|
||||
|
||||
#if ENABLED(MKS_MINI_12864) // Added in Marlin 1.1.6
|
||||
|
||||
// TO TEST
|
||||
// #define DOGLCD_A0 27
|
||||
// #define DOGLCD_CS 25
|
||||
|
||||
// GLCD features
|
||||
// Uncomment screen orientation
|
||||
// #define LCD_SCREEN_ROT_90
|
||||
// #define LCD_SCREEN_ROT_180
|
||||
// #define LCD_SCREEN_ROT_270
|
||||
|
||||
// not connected to a pin
|
||||
// #define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57)
|
||||
|
||||
// #define BTN_EN1 31
|
||||
// #define BTN_EN2 33
|
||||
|
||||
#elif ENABLED(FYSETC_MINI_12864)
|
||||
|
||||
// From https://wiki.fysetc.com/Mini12864_Panel/?fbclid=IwAR1FyjuNdVOOy9_xzky3qqo_WeM5h-4gpRnnWhQr_O1Ef3h0AFnFXmCehK8
|
||||
|
||||
// TO TEST
|
||||
// #define DOGLCD_A0 16
|
||||
// #define DOGLCD_CS 17
|
||||
|
||||
// #define BTN_EN1 33
|
||||
// #define BTN_EN2 31
|
||||
|
||||
//#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems
|
||||
// results in LCD soft SPI mode 3, SD soft SPI mode 0
|
||||
|
||||
// #define LCD_RESET_PIN 23 // Must be high or open for LCD to operate normally.
|
||||
|
||||
#if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0)
|
||||
#ifndef RGB_LED_R_PIN
|
||||
// TO TEST
|
||||
// #define RGB_LED_R_PIN 25
|
||||
#endif
|
||||
#ifndef RGB_LED_G_PIN
|
||||
// TO TEST
|
||||
// #define RGB_LED_G_PIN 27
|
||||
#endif
|
||||
#ifndef RGB_LED_B_PIN
|
||||
// TO TEST
|
||||
// #define RGB_LED_B_PIN 29
|
||||
#endif
|
||||
#elif ENABLED(FYSETC_MINI_12864_2_1)
|
||||
// TO TEST
|
||||
// #define NEOPIXEL_PIN 25
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#elif ENABLED(MINIPANEL)
|
||||
|
||||
// TO TEST
|
||||
// #define BEEPER_PIN 42
|
||||
// not connected to a pin
|
||||
// #define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57)
|
||||
|
||||
// #define DOGLCD_A0 44
|
||||
// #define DOGLCD_CS 58 // Mega/Due:66 - AGCM4:58
|
||||
|
||||
// GLCD features
|
||||
// Uncomment screen orientation
|
||||
// #define LCD_SCREEN_ROT_90
|
||||
// #define LCD_SCREEN_ROT_180
|
||||
// #define LCD_SCREEN_ROT_270
|
||||
|
||||
// #define BTN_EN1 40
|
||||
// #define BTN_EN2 55 // Mega/Due:63 - AGCM4:55
|
||||
// #define BTN_ENC 72 // Mega/Due:59 - AGCM4:72
|
||||
|
||||
// #define SD_DETECT_PIN 49
|
||||
// #define KILL_PIN 56 // Mega/Due:64 - AGCM4:56
|
||||
|
||||
#elif ENABLED(ZONESTAR_LCD)
|
||||
|
||||
// TO TEST
|
||||
// #define ADC_KEYPAD_PIN 12
|
||||
|
||||
#elif ENABLED(AZSMZ_12864)
|
||||
|
||||
// TO TEST
|
||||
|
||||
#else
|
||||
|
||||
// Beeper on AUX-4
|
||||
// #define BEEPER_PIN 33
|
||||
|
||||
// Buttons are directly attached to AUX-2
|
||||
#if ENABLED(REPRAPWORLD_KEYPAD)
|
||||
// TO TEST
|
||||
// #define SHIFT_OUT 40
|
||||
// #define SHIFT_CLK 44
|
||||
// #define SHIFT_LD 42
|
||||
// #define BTN_EN1 56 // Mega/Due:64 - AGCM4:56
|
||||
// #define BTN_EN2 72 // Mega/Due:59 - AGCM4:72
|
||||
// #define BTN_ENC 55 // Mega/Due:63 - AGCM4:55
|
||||
#elif ENABLED(PANEL_ONE)
|
||||
// TO TEST
|
||||
// #define BTN_EN1 72 // AUX2 PIN 3 (Mega/Due:59 - AGCM4:72)
|
||||
// #define BTN_EN2 55 // AUX2 PIN 4 (Mega/Due:63 - AGCM4:55)
|
||||
// #define BTN_ENC 49 // AUX3 PIN 7
|
||||
#else
|
||||
// TO TEST
|
||||
// #define BTN_EN1 37
|
||||
// #define BTN_EN2 35
|
||||
// #define BTN_ENC 31
|
||||
#endif
|
||||
|
||||
#if ENABLED(G3D_PANEL)
|
||||
// TO TEST
|
||||
// #define SD_DETECT_PIN 49
|
||||
// #define KILL_PIN 41
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif // NEWPANEL
|
||||
|
||||
#endif // HAS_SPI_LCD
|
||||
|
||||
//
|
||||
// SD Support
|
||||
//
|
||||
#ifndef SDCARD_CONNECTION
|
||||
#define SDCARD_CONNECTION ONBOARD
|
||||
#endif
|
||||
|
||||
#if SD_CONNECTION_IS(ONBOARD)
|
||||
#undef SDSS
|
||||
#define SDSS 83
|
||||
#undef SD_DETECT_PIN
|
||||
#define SD_DETECT_PIN 95
|
||||
#endif
|
||||
@@ -48,11 +48,6 @@
|
||||
#define E2END 0xFFF // 4KB
|
||||
#endif
|
||||
|
||||
//
|
||||
// Servos
|
||||
//
|
||||
#define SERVO0_PIN PA3
|
||||
|
||||
//
|
||||
// Limit Switches
|
||||
//
|
||||
@@ -64,11 +59,10 @@
|
||||
#define Z_MAX_PIN PA3
|
||||
|
||||
//
|
||||
// Filament Sensor
|
||||
// Servos
|
||||
// share with Z_MAX_PIN
|
||||
//
|
||||
#ifndef FIL_RUNOUT_PIN
|
||||
#define FIL_RUNOUT_PIN PA1
|
||||
#endif
|
||||
#define SERVO0_PIN PA3
|
||||
|
||||
//
|
||||
// Steppers
|
||||
@@ -166,7 +160,6 @@
|
||||
//#define KILL_PIN PC5
|
||||
|
||||
#define SDSS PA4
|
||||
#define SD_DETECT_PIN PB10
|
||||
|
||||
//
|
||||
// LCD / Controller
|
||||
@@ -196,6 +189,7 @@
|
||||
|
||||
#define BTN_EN1 PC6
|
||||
#define BTN_EN2 PC7
|
||||
#define SD_DETECT_PIN PB10
|
||||
|
||||
#define LCD_SDSS PA4
|
||||
|
||||
|
||||
Reference in New Issue
Block a user