Merge pull request #10920 from thinkyhead/bf2_misc_cleanups_jun2

[2.0.x] Clean up ST7565, dual endstops homing
2.0.x
Scott Lahteine 7 years ago committed by GitHub
commit 85914423a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -65,6 +65,22 @@
#define HEIGHT 64
#define PAGE_HEIGHT 8
#define ST7565_ADC_REVERSE(N) (0xA0 | ((N) & 0x1))
#define ST7565_BIAS_MODE(N) (0xA2 | ((N) & 0x1))
#define ST7565_ALL_PIX(N) (0xA4 | ((N) & 0x1))
#define ST7565_INVERTED(N) (0xA6 | ((N) & 0x1))
#define ST7565_ON(N) (0xAE | ((N) & 0x1))
#define ST7565_OUT_MODE(N) (0xC0 | ((N) & 0x1) << 3)
#define ST7565_POWER_CONTROL(N) (0x28 | (N))
#define ST7565_V0_RATIO(N) (0x20 | ((N) & 0x7))
#define ST7565_CONTRAST(N) (0x81), (N)
#define ST7565_COLUMN_ADR(N) (0x10 | ((N) >> 4) & 0xF), (0x00 | ((N) & 0xF))
#define ST7565_PAGE_ADR(N) (0xB0 | (N))
#define ST7565_START_LINE(N) (0x40 | (N))
#define ST7565_SLEEP_MODE() (0xAC)
#define ST7565_NOOP() (0xE3)
/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
static const uint8_t u8g_dev_st7565_64128n_HAL_init_seq[] PROGMEM = {
U8G_ESC_CS(0), // disable chip
@ -72,36 +88,34 @@ static const uint8_t u8g_dev_st7565_64128n_HAL_init_seq[] PROGMEM = {
U8G_ESC_CS(1), // enable chip
U8G_ESC_RST(15), // do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
0x0A2, // 0x0A2: LCD bias 1/9 (according to Displaytech 64128N datasheet)
0x0A0, // Normal ADC Select (according to Displaytech 64128N datasheet)
ST7565_BIAS_MODE(0), // 0xA2: LCD bias 1/9 (according to Displaytech 64128N datasheet)
ST7565_ADC_REVERSE(0), // Normal ADC Select (according to Displaytech 64128N datasheet)
0x0C8, // common output mode: set scan direction normal operation/SHL Select, 0x0C0 --> SHL = 0, normal, 0x0C8 --> SHL = 1
0x040, // Display start line for Displaytech 64128N
ST7565_OUT_MODE(1), // common output mode: set scan direction normal operation/SHL Select, 0x0C0 --> SHL = 0, normal, 0x0C8 --> SHL = 1
ST7565_START_LINE(0), // Display start line for Displaytech 64128N
0x028 | 0x04, // power control: turn on voltage converter
U8G_ESC_DLY(50), // delay 50 ms
//0x028 | 0x04, // power control: turn on voltage converter
//U8G_ESC_DLY(50), // delay 50 ms
0x028 | 0x06, // power control: turn on voltage regulator
U8G_ESC_DLY(50), // delay 50 ms
//0x028 | 0x06, // power control: turn on voltage regulator
//U8G_ESC_DLY(50), // delay 50 ms
0x028 | 0x07, // power control: turn on voltage follower
ST7565_POWER_CONTROL(0x7), // power control: turn on voltage follower
U8G_ESC_DLY(50), // delay 50 ms
0x010, // Set V0 voltage resistor ratio. Setting for controlling brightness of Displaytech 64128N
0x0A6, // display normal, bit val 0: LCD pixel off.
ST7565_V0_RATIO(0), // Set V0 voltage resistor ratio. Setting for controlling brightness of Displaytech 64128N
0x081, // set contrast
0x01E, // Contrast value. Setting for controlling brightness of Displaytech 64128N
ST7565_INVERTED(0), // display normal, bit val 0: LCD pixel off.
ST7565_CONTRAST(0x1E), // Contrast value. Setting for controlling brightness of Displaytech 64128N
0x0AF, // display on
ST7565_ON(1), // display on
U8G_ESC_DLY(100), // delay 100 ms
0x0A5, // display all points, ST7565
ST7565_ALL_PIX(1), // display all points, ST7565
U8G_ESC_DLY(100), // delay 100 ms
U8G_ESC_DLY(100), // delay 100 ms
0x0A4, // normal display
ST7565_ALL_PIX(0), // normal display
U8G_ESC_CS(0), // disable chip
U8G_ESC_END // end of sequence
};
@ -109,18 +123,17 @@ static const uint8_t u8g_dev_st7565_64128n_HAL_init_seq[] PROGMEM = {
static const uint8_t u8g_dev_st7565_64128n_HAL_data_start[] PROGMEM = {
U8G_ESC_ADR(0), // instruction mode
U8G_ESC_CS(1), // enable chip
0x010, // set upper 4 bit of the col adr to 0x10
0x000, // set lower 4 bit of the col adr to 0x00. Changed for DisplayTech 64128N
ST7565_COLUMN_ADR(0x00), // high 4 bits to 0, low 4 bits to 0. Changed for DisplayTech 64128N
U8G_ESC_END // end of sequence
};
static const uint8_t u8g_dev_st7565_64128n_HAL_sleep_on[] PROGMEM = {
U8G_ESC_ADR(0), // instruction mode
U8G_ESC_CS(1), // enable chip
0x0AC, // static indicator off
0x000, // indicator register set (not sure if this is required)
0x0AE, // display off
0x0A5, // all points on
ST7565_SLEEP_MODE(), // static indicator off
//0x000, // indicator register set (not sure if this is required)
ST7565_ON(0), // display off
ST7565_ALL_PIX(1), // all points on
U8G_ESC_CS(0), // disable chip, bugfix 12 nov 2014
U8G_ESC_END // end of sequence
};
@ -128,14 +141,14 @@ static const uint8_t u8g_dev_st7565_64128n_HAL_sleep_on[] PROGMEM = {
static const uint8_t u8g_dev_st7565_64128n_HAL_sleep_off[] PROGMEM = {
U8G_ESC_ADR(0), // instruction mode
U8G_ESC_CS(1), // enable chip
0x0A4, // all points off
0x0AF, // display on
ST7565_ALL_PIX(0), // all points off
ST7565_ON(1), // display on
U8G_ESC_DLY(50), // delay 50 ms
U8G_ESC_CS(0), // disable chip, bugfix 12 nov 2014
U8G_ESC_END // end of sequence
};
uint8_t u8g_dev_st7565_64128n_HAL_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) {
uint8_t u8g_dev_st7565_64128n_HAL_fn(u8g_t *u8g, u8g_dev_t *dev, const uint8_t msg, void *arg) {
switch(msg) {
case U8G_DEV_MSG_INIT:
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
@ -146,10 +159,9 @@ uint8_t u8g_dev_st7565_64128n_HAL_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
case U8G_DEV_MSG_PAGE_NEXT: {
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_HAL_data_start);
u8g_WriteByte(u8g, dev, 0x0B0 | pb->p.page); /* select current page (ST7565R) */
u8g_WriteByte(u8g, dev, ST7565_PAGE_ADR(pb->p.page)); /* select current page (ST7565R) */
u8g_SetAddress(u8g, dev, 1); /* data mode */
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
return 0;
if (!u8g_pb_WriteBuffer(pb, u8g, dev)) return 0;
u8g_SetChipSelect(u8g, dev, 0);
}
break;
@ -170,7 +182,7 @@ uint8_t u8g_dev_st7565_64128n_HAL_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
}
uint8_t u8g_dev_st7565_64128n_HAL_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) {
uint8_t u8g_dev_st7565_64128n_HAL_2x_fn(u8g_t *u8g, u8g_dev_t *dev, const uint8_t msg, void *arg) {
switch(msg) {
case U8G_DEV_MSG_INIT:
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
@ -182,13 +194,13 @@ uint8_t u8g_dev_st7565_64128n_HAL_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg,
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_HAL_data_start);
u8g_WriteByte(u8g, dev, 0x0B0 | (2*pb->p.page)); /* select current page (ST7565R) */
u8g_WriteByte(u8g, dev, ST7565_PAGE_ADR(2 * pb->p.page)); /* select current page (ST7565R) */
u8g_SetAddress(u8g, dev, 1); /* data mode */
u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)pb->buf);
u8g_SetChipSelect(u8g, dev, 0);
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_HAL_data_start);
u8g_WriteByte(u8g, dev, 0x0B0 | (2*pb->p.page+1)); /* select current page (ST7565R) */
u8g_WriteByte(u8g, dev, ST7565_PAGE_ADR(2 * pb->p.page + 1)); /* select current page (ST7565R) */
u8g_SetAddress(u8g, dev, 1); /* data mode */
u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
u8g_SetChipSelect(u8g, dev, 0);

@ -148,8 +148,7 @@
#define MSG_UBL_STEP_BY_STEP_MENU _UxGT("UBL Postupně")
#define MSG_LED_CONTROL _UxGT("LED Nastavení")
#define MSG_LEDS_ON _UxGT("Světla Zap")
#define MSG_LEDS_OFF _UxGT("Světla Vyp")
#define MSG_LEDS _UxGT("Světla")
#define MSG_LED_PRESETS _UxGT("Světla Předvolby")
#define MSG_SET_LEDS_RED _UxGT("Červená")
#define MSG_SET_LEDS_ORANGE _UxGT("Oranžová")

@ -309,8 +309,7 @@
#define MSG_UBL_STEP_BY_STEP_MENU _UxGT("Schrittweises UBL")
#define MSG_LED_CONTROL _UxGT("LED Kontrolle")
#define MSG_LEDS_ON _UxGT("Licht an")
#define MSG_LEDS_OFF _UxGT("Licht aus")
#define MSG_LEDS _UxGT("Licht")
#define MSG_LED_PRESETS _UxGT("Licht Einstellungen")
#define MSG_SET_LEDS_RED _UxGT("Rot")
#define MSG_SET_LEDS_ORANGE _UxGT("Orange")

@ -371,11 +371,8 @@
#ifndef MSG_LED_CONTROL
#define MSG_LED_CONTROL _UxGT("LED Control")
#endif
#ifndef MSG_LEDS_ON
#define MSG_LEDS_ON _UxGT("Lights On")
#endif
#ifndef MSG_LEDS_OFF
#define MSG_LEDS_OFF _UxGT("Lights Off")
#ifndef MSG_LEDS
#define MSG_LEDS _UxGT("Lights")
#endif
#ifndef MSG_LED_PRESETS
#define MSG_LED_PRESETS _UxGT("Light Presets")

@ -142,8 +142,7 @@
//#define MSG_UBL_Z_OFFSET_STOPPED _UxGT("Z-Offset Stopped")
//#define MSG_UBL_STEP_BY_STEP_MENU _UxGT("Step-By-Step UBL")
#define MSG_LED_CONTROL _UxGT("LED ezarpenak")
#define MSG_LEDS_ON _UxGT("Argiak piztu")
#define MSG_LEDS_OFF _UxGT("Argiak itzali")
#define MSG_LEDS _UxGT("Argiak")
#define MSG_LED_PRESETS _UxGT("Argi aurrehautaketak")
#define MSG_SET_LEDS_RED _UxGT("Gorria")
#define MSG_SET_LEDS_ORANGE _UxGT("Laranja")

@ -144,8 +144,7 @@
#define MSG_UBL_STEP_BY_STEP_MENU _UxGT("UBL Pas à pas")
#define MSG_LED_CONTROL _UxGT("Contrôle LED")
#define MSG_LEDS_ON _UxGT("Lumière ON")
#define MSG_LEDS_OFF _UxGT("Lumière OFF")
#define MSG_LEDS _UxGT("Lumière")
#define MSG_LED_PRESETS _UxGT("Préregl. LED")
#define MSG_SET_LEDS_RED _UxGT("Rouge")
#define MSG_SET_LEDS_ORANGE _UxGT("Orange")

@ -143,8 +143,7 @@
#define MSG_UBL_STEP_BY_STEP_MENU _UxGT("UBL passo passo")
#define MSG_LED_CONTROL _UxGT("Controllo LED")
#define MSG_LEDS_ON _UxGT("Luci On")
#define MSG_LEDS_OFF _UxGT("Luci Off")
#define MSG_LEDS _UxGT("Luci")
#define MSG_LED_PRESETS _UxGT("Preset luci")
#define MSG_SET_LEDS_RED _UxGT("Rosso")
#define MSG_SET_LEDS_ORANGE _UxGT("Arancione")

@ -148,8 +148,7 @@
#define MSG_UBL_Z_OFFSET_STOPPED _UxGT("Compensação Z parou")
#define MSG_UBL_STEP_BY_STEP_MENU _UxGT("UBL passo a passo")
#define MSG_LED_CONTROL _UxGT("Controle do LED")
#define MSG_LEDS_ON _UxGT("Luz Acesa")
#define MSG_LEDS_OFF _UxGT("Luz Apagada")
#define MSG_LEDS _UxGT("Luz")
#define MSG_LED_PRESETS _UxGT("Configuração da Luz")
#define MSG_SET_LEDS_RED _UxGT("Luz Vermelha")
#define MSG_SET_LEDS_ORANGE _UxGT("Luz Laranja")

@ -144,8 +144,7 @@
#define MSG_UBL_STEP_BY_STEP_MENU _UxGT("Пошаговое UBL")
#define MSG_LED_CONTROL _UxGT("Настройки LED")
#define MSG_LEDS_ON _UxGT("Включить подсветку")
#define MSG_LEDS_OFF _UxGT("Выключить подсветку")
#define MSG_LEDS _UxGT("Подсветку")
#define MSG_LED_PRESETS _UxGT("Предустановки света")
#define MSG_SET_LEDS_RED _UxGT("Красный свет")
#define MSG_SET_LEDS_ORANGE _UxGT("Оранжевый свет")

@ -153,8 +153,7 @@
#define MSG_UBL_STEP_BY_STEP_MENU _UxGT("UBL Postupne")
#define MSG_LED_CONTROL _UxGT("Nastavenie LED")
#define MSG_LEDS_ON _UxGT("Zapnúť svetlo")
#define MSG_LEDS_OFF _UxGT("Vypnúť svetlo")
#define MSG_LEDS _UxGT("Svetlo")
#define MSG_LED_PRESETS _UxGT("Prednastavené farby")
#define MSG_SET_LEDS_RED _UxGT("Červená")
#define MSG_SET_LEDS_ORANGE _UxGT("Oranžová")

@ -143,8 +143,7 @@
#define MSG_UBL_STEP_BY_STEP_MENU _UxGT("一步步UBL") // "Step-By-Step UBL"
#define MSG_LED_CONTROL _UxGT("灯管控制") // "LED Control")
#define MSG_LEDS_ON _UxGT("灯亮") // "Lights On")
#define MSG_LEDS_OFF _UxGT("灯灭") // "Lights Off")
#define MSG_LEDS _UxGT("灯") // "Lights")
#define MSG_LED_PRESETS _UxGT("灯预置") // "Light Presets")
#define MSG_SET_LEDS_RED _UxGT("红") // "Red")
#define MSG_SET_LEDS_ORANGE _UxGT("橙") // "Orange")

@ -143,8 +143,7 @@
#define MSG_UBL_STEP_BY_STEP_MENU _UxGT("一步步UBL") // "Step-By-Step UBL"
#define MSG_LED_CONTROL _UxGT("灯管控制") // "LED Control")
#define MSG_LEDS_ON _UxGT("灯亮") // "Lights On")
#define MSG_LEDS_OFF _UxGT("灯灭") // "Lights Off")
#define MSG_LEDS _UxGT("灯") // "Lights")
#define MSG_LED_PRESETS _UxGT("灯预置") // "Light Presets")
#define MSG_SET_LEDS_RED _UxGT("红") // "Red")
#define MSG_SET_LEDS_ORANGE _UxGT("橙") // "Orange")

@ -4255,10 +4255,8 @@ void lcd_quick_feedback(const bool clear_buttons) {
void lcd_led_menu() {
START_MENU();
MENU_BACK(MSG_MAIN);
if (leds.lights_on)
MENU_ITEM(function, MSG_LEDS_OFF, leds.toggle);
else
MENU_ITEM(function, MSG_LEDS_ON, leds.toggle);
bool led_on = leds.lights_on;
MENU_ITEM_EDIT_CALLBACK(bool, MSG_LEDS, &led_on, leds.toggle);
MENU_ITEM(function, MSG_SET_LEDS_DEFAULT, leds.set_default);
#if ENABLED(LED_COLOR_PRESETS)
MENU_ITEM(submenu, MSG_LED_PRESETS, lcd_led_presets_menu);

@ -396,7 +396,6 @@ void Endstops::M119() {
// Check endstops - Could be called from ISR!
void Endstops::update() {
#define SET_BIT_TO(N,B,TF) do{ if (TF) SBI(N,B); else CBI(N,B); }while(0)
// UPDATE_ENDSTOP_BIT: set the current endstop bits for an endstop to its status
#define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT_TO(live_state, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)))
// COPY_BIT: copy the value of SRC_BIT to DST_BIT in DST
@ -590,7 +589,7 @@ void Endstops::update() {
if (dual_hit) { \
_ENDSTOP_HIT(AXIS1, MINMAX); \
/* if not performing home or if both endstops were trigged during homing... */ \
if (!stepper.performing_homing || dual_hit == 0x3) \
if (!stepper.homing_dual_axis || dual_hit == 0x3) \
planner.endstop_triggered(_AXIS(AXIS1)); \
} \
}while(0)

@ -1052,9 +1052,14 @@ static void do_homing_move(const AxisEnum axis, const float distance, const floa
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR(">>> do_homing_move(", axis_codes[axis]);
SERIAL_ECHOPAIR(", ", distance);
SERIAL_ECHOPAIR(", ", fr_mm_s);
SERIAL_ECHOPAIR(" [", fr_mm_s ? fr_mm_s : homing_feedrate(axis));
SERIAL_ECHOLNPGM("])");
SERIAL_ECHOPGM(", ");
if (fr_mm_s)
SERIAL_ECHO(fr_mm_s);
else {
SERIAL_ECHOPAIR("[", homing_feedrate(axis));
SERIAL_CHAR(']');
}
SERIAL_ECHOLNPGM(")");
}
#endif
@ -1262,11 +1267,12 @@ void homeaxis(const AxisEnum axis) {
}
#endif
const int axis_home_dir =
const int axis_home_dir = (
#if ENABLED(DUAL_X_CARRIAGE)
(axis == X_AXIS) ? x_home_dir(active_extruder) :
axis == X_AXIS ? x_home_dir(active_extruder) :
#endif
home_dir(axis);
home_dir(axis)
);
// Homing Z towards the bed? Deploy the Z probe or endstop.
#if HOMING_Z_WITH_PROBE
@ -1274,14 +1280,20 @@ void homeaxis(const AxisEnum axis) {
#endif
// Set flags for X, Y, Z motor locking
#if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
switch (axis) {
#if ENABLED(X_DUAL_ENDSTOPS)
if (axis == X_AXIS) stepper.set_homing_flag_x(true);
case X_AXIS:
#endif
#if ENABLED(Y_DUAL_ENDSTOPS)
if (axis == Y_AXIS) stepper.set_homing_flag_y(true);
case Y_AXIS:
#endif
#if ENABLED(Z_DUAL_ENDSTOPS)
if (axis == Z_AXIS) stepper.set_homing_flag_z(true);
case Z_AXIS:
#endif
stepper.set_homing_dual_axis(true);
default: break;
}
#endif
// Fast move towards endstop until triggered
@ -1321,37 +1333,32 @@ void homeaxis(const AxisEnum axis) {
const bool pos_dir = axis_home_dir > 0;
#if ENABLED(X_DUAL_ENDSTOPS)
if (axis == X_AXIS) {
const bool lock_x1 = pos_dir ? (endstops.x_endstop_adj > 0) : (endstops.x_endstop_adj < 0);
float adj = ABS(endstops.x_endstop_adj);
if (pos_dir) adj = -adj;
if (lock_x1) stepper.set_x_lock(true); else stepper.set_x2_lock(true);
do_homing_move(axis, adj);
if (lock_x1) stepper.set_x_lock(false); else stepper.set_x2_lock(false);
stepper.set_homing_flag_x(false);
const float adj = ABS(endstops.x_endstop_adj);
if (pos_dir ? (endstops.x_endstop_adj > 0) : (endstops.x_endstop_adj < 0)) stepper.set_x_lock(true); else stepper.set_x2_lock(true);
do_homing_move(axis, pos_dir ? adj : -adj);
stepper.set_x_lock(false);
stepper.set_x2_lock(false);
}
#endif
#if ENABLED(Y_DUAL_ENDSTOPS)
if (axis == Y_AXIS) {
const bool lock_y1 = pos_dir ? (endstops.y_endstop_adj > 0) : (endstops.y_endstop_adj < 0);
float adj = ABS(endstops.y_endstop_adj);
if (pos_dir) adj = -adj;
if (lock_y1) stepper.set_y_lock(true); else stepper.set_y2_lock(true);
do_homing_move(axis, adj);
if (lock_y1) stepper.set_y_lock(false); else stepper.set_y2_lock(false);
stepper.set_homing_flag_y(false);
const float adj = ABS(endstops.y_endstop_adj);
if (pos_dir ? (endstops.y_endstop_adj > 0) : (endstops.y_endstop_adj < 0)) stepper.set_y_lock(true); else stepper.set_y2_lock(true);
do_homing_move(axis, pos_dir ? adj : -adj);
stepper.set_y_lock(false);
stepper.set_y2_lock(false);
}
#endif
#if ENABLED(Z_DUAL_ENDSTOPS)
if (axis == Z_AXIS) {
const bool lock_z1 = pos_dir ? (endstops.z_endstop_adj > 0) : (endstops.z_endstop_adj < 0);
float adj = ABS(endstops.z_endstop_adj);
if (pos_dir) adj = -adj;
if (lock_z1) stepper.set_z_lock(true); else stepper.set_z2_lock(true);
do_homing_move(axis, adj);
if (lock_z1) stepper.set_z_lock(false); else stepper.set_z2_lock(false);
stepper.set_homing_flag_z(false);
const float adj = ABS(endstops.z_endstop_adj);
if (pos_dir ? (endstops.z_endstop_adj > 0) : (endstops.z_endstop_adj < 0)) stepper.set_z_lock(true); else stepper.set_z2_lock(true);
do_homing_move(axis, pos_dir ? adj : -adj);
stepper.set_z_lock(false);
stepper.set_z2_lock(false);
}
#endif
stepper.set_homing_dual_axis(false);
#endif
#if IS_SCARA
@ -1393,10 +1400,9 @@ void homeaxis(const AxisEnum axis) {
if (axis == Z_AXIS && STOW_PROBE()) return;
#endif
// Clear z_lift if homing the Z axis
// Clear retracted status if homing the Z axis
#if ENABLED(FWRETRACT)
if (axis == Z_AXIS)
fwretract.hop_amount = 0.0;
if (axis == Z_AXIS) fwretract.hop_amount = 0.0;
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
@ -1470,7 +1476,7 @@ void homeaxis(const AxisEnum axis) {
#endif
#if ENABLED(DELTA)
switch(axis) {
switch (axis) {
#if HAS_SOFTWARE_ENDSTOPS
case X_AXIS:
case Y_AXIS:

@ -87,7 +87,7 @@ Stepper stepper; // Singleton
block_t* Stepper::current_block = NULL; // A pointer to the block currently being traced
#if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
bool Stepper::performing_homing = false;
bool Stepper::homing_dual_axis = false;
#endif
#if HAS_MOTOR_CURRENT_PWM
@ -166,7 +166,7 @@ bool Stepper::all_steps_done = false;
uint32_t Stepper::acceleration_time, Stepper::deceleration_time;
volatile int32_t Stepper::count_position[NUM_AXIS] = { 0 };
volatile signed char Stepper::count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
int8_t Stepper::count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
#if ENABLED(MIXING_EXTRUDER)
int32_t Stepper::counter_m[MIXING_STEPPERS];
@ -183,7 +183,7 @@ volatile int32_t Stepper::endstops_trigsteps[XYZ];
#if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
#define DUAL_ENDSTOP_APPLY_STEP(A,V) \
if (performing_homing) { \
if (homing_dual_axis) { \
if (A##_HOME_DIR < 0) { \
if (!(TEST(endstops.state(), A##_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \
if (!(TEST(endstops.state(), A##2_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \
@ -1144,7 +1144,6 @@ void Stepper::set_directions() {
HAL_STEP_TIMER_ISR {
HAL_timer_isr_prologue(STEP_TIMER_NUM);
// Call the ISR
Stepper::isr();
HAL_timer_isr_epilogue(STEP_TIMER_NUM);
@ -1175,7 +1174,7 @@ void Stepper::isr() {
// We need this variable here to be able to use it in the following loop
hal_timer_t min_ticks;
do {
// Enable ISRs so the USART processing latency is reduced
// Enable ISRs to reduce USART processing latency
ENABLE_ISRS();
// Run main stepping pulse phase ISR if we have to
@ -1193,11 +1192,9 @@ void Stepper::isr() {
uint32_t interval =
#if ENABLED(LIN_ADVANCE)
// Select the closest interval in time
MIN(nextAdvanceISR, nextMainISR)
MIN(nextAdvanceISR, nextMainISR) // Nearest time interval
#else
// The interval is just the remaining time to the stepper ISR
nextMainISR
nextMainISR // Remaining stepper ISR time
#endif
;

@ -63,7 +63,7 @@ class Stepper {
static block_t* current_block; // A pointer to the block currently being traced
#if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
static bool performing_homing;
static bool homing_dual_axis;
#endif
#if HAS_MOTOR_CURRENT_PWM
@ -143,7 +143,7 @@ class Stepper {
//
// Current direction of stepper motors (+1 or -1)
//
static volatile signed char count_direction[NUM_AXIS];
static int8_t count_direction[NUM_AXIS];
//
// Mixing extruder mix counters
@ -220,18 +220,18 @@ class Stepper {
static void microstep_readings();
#endif
#if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
FORCE_INLINE static void set_homing_dual_axis(const bool state) { homing_dual_axis = state; }
#endif
#if ENABLED(X_DUAL_ENDSTOPS)
FORCE_INLINE static void set_homing_flag_x(const bool state) { performing_homing = state; }
FORCE_INLINE static void set_x_lock(const bool state) { locked_X_motor = state; }
FORCE_INLINE static void set_x2_lock(const bool state) { locked_X2_motor = state; }
#endif
#if ENABLED(Y_DUAL_ENDSTOPS)
FORCE_INLINE static void set_homing_flag_y(const bool state) { performing_homing = state; }
FORCE_INLINE static void set_y_lock(const bool state) { locked_Y_motor = state; }
FORCE_INLINE static void set_y2_lock(const bool state) { locked_Y2_motor = state; }
#endif
#if ENABLED(Z_DUAL_ENDSTOPS)
FORCE_INLINE static void set_homing_flag_z(const bool state) { performing_homing = state; }
FORCE_INLINE static void set_z_lock(const bool state) { locked_Z_motor = state; }
FORCE_INLINE static void set_z2_lock(const bool state) { locked_Z2_motor = state; }
#endif
@ -247,15 +247,9 @@ class Stepper {
// Set the current position in steps
inline static void set_position(const int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e) {
planner.synchronize();
// Disable stepper interrupts, to ensure atomic setting of all the position variables
const bool was_enabled = STEPPER_ISR_ENABLED();
if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
// Set position
_set_position(a, b, c, e);
// Reenable Stepper ISR
if (was_enabled) ENABLE_STEPPER_DRIVER_INTERRUPT();
}

Loading…
Cancel
Save