Merge branch 'MK3' into MK3

This commit is contained in:
XPila 2017-07-12 17:54:41 +02:00 committed by GitHub
commit a41a836ef0
4 changed files with 97 additions and 79 deletions

View File

@ -911,14 +911,14 @@ static void lcd_language_menu();
#ifdef HAVE_PAT9125_SENSOR #ifdef HAVE_PAT9125_SENSOR
bool fsensor_enabled = true; bool fsensor_enabled = false;
bool fsensor_ignore_error = true; bool fsensor_ignore_error = true;
bool fsensor_M600 = false; bool fsensor_M600 = false;
long prev_pos_e = 0; long prev_pos_e = 0;
long err_cnt = 0; long err_cnt = 0;
#define FSENS_ESTEPS 140 //extruder resolution [steps/mm] #define FSENS_ESTEPS 280 //extruder resolution [steps/mm]
#define FSENS_MINDEL 280 //filament sensor min delta [steps] (3mm) #define FSENS_MINDEL 560 //filament sensor min delta [steps] (3mm)
#define FSENS_MINFAC 3 //filament sensor minimum factor [count/mm] #define FSENS_MINFAC 3 //filament sensor minimum factor [count/mm]
#define FSENS_MAXFAC 50 //filament sensor maximum factor [count/mm] #define FSENS_MAXFAC 50 //filament sensor maximum factor [count/mm]
#define FSENS_MAXERR 2 //filament sensor max error count #define FSENS_MAXERR 2 //filament sensor max error count
@ -5982,11 +5982,15 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
break; break;
case 3: case 3:
MYSERIAL.print("fsensor_enable()"); MYSERIAL.print("fsensor_enable()");
#ifdef HAVE_PAT9125_SENSOR
fsensor_enable(); fsensor_enable();
#endif
break; break;
case 4: case 4:
MYSERIAL.print("fsensor_disable()"); MYSERIAL.print("fsensor_disable()");
#ifdef HAVE_PAT9125_SENSOR
fsensor_disable(); fsensor_disable();
#endif
break; break;
case 5: case 5:
{ {

View File

@ -1,55 +1,60 @@
#ifndef SWSPI_H #ifndef SWSPI_H
#define SWSPI_H #define SWSPI_H
//#define SWSPI_RPI //#define SWSPI_RPI
#define SWSPI_AVR #define SWSPI_AVR
#ifdef SWSPI_RPI #ifdef SWSPI_RPI
//#define SWSPI_MISO 9 //#define SWSPI_MISO 9
#define SWSPI_MISO 10 #define SWSPI_MISO 10
#define SWSPI_MOSI 10 #define SWSPI_MOSI 10
#define SWSPI_SCK 11 #define SWSPI_SCK 11
#define SWSPI_CS 7 #define SWSPI_CS 7
#endif //SWSPI_RPI #endif //SWSPI_RPI
#ifdef SWSPI_AVR #ifdef SWSPI_AVR
//#if MOTHERBOARD == BOARD_EINY_0_3a //#if MOTHERBOARD == BOARD_EINY_0_3a
#define SWSPI_MISO 16 //RX2 #define SWSPI_MISO 16 //RX2
#define SWSPI_MOSI 16 //RX2 #define SWSPI_MOSI 16 //RX2
#define SWSPI_SCK 17 //TX2 #define SWSPI_SCK 17 //TX2
#define SWSPI_CS 20 //SDA #define SWSPI_CS 20 //SDA
//#endif //(MOTHERBOARD == 299) //#endif //(MOTHERBOARD == 299)
/*#if MOTHERBOARD == BOARD_EINY_0_4a /*#if MOTHERBOARD == BOARD_EINY_0_4a
#define SWSPI_MISO 62 //PK0 #define SWSPI_MISO 62 //PK0
#define SWSPI_MOSI 62 //PK0 #define SWSPI_MOSI 62 //PK0
#define SWSPI_SCK 21 //SCL #define SWSPI_SCK 21 //SCL
#define SWSPI_CS 20 //SDA #endif //(MOTHERBOARD == BOARD_EINY_0_3a)
#endif //(MOTHERBOARD == BOARD_EINY_0_4a)*/ #if (MOTHERBOARD == BOARD_EINY_0_4a)
#endif //SWSPI_AVR #define SWSPI_MISO 21 //PK0
#define SWSPI_MOSI 21 //PK0
#define SWSPI_POL 1 //polarity #define SWSPI_SCK 62 //SCL
#define SWSPI_PHA 0 //phase #define SWSPI_CS 20 //SDA
#define SWSPI_DOR 0 //data order #endif //(MOTHERBOARD == BOARD_EINY_0_4a)*/
#define SWSPI_DEL 2 //delay #endif //SWSPI_AVR
#define SWSPI_POL 1 //polarity
void swspi_init(); #define SWSPI_PHA 0 //phase
#define SWSPI_DOR 0 //data order
#if (SWSPI_MOSI == SWSPI_MISO) #define SWSPI_DEL 2 //delay
void swspi_tx(unsigned char tx);
unsigned char swspi_rx(); void swspi_init();
#else //(SWSPI_MOSI == SWSPI_MISO) #if (SWSPI_MOSI == SWSPI_MISO)
#define swspi_tx swspi_txrx void swspi_tx(unsigned char tx);
#define swspi_rx swspi_txrx unsigned char swspi_rx();
unsigned char swspi_txrx(unsigned char tx);
#else //(SWSPI_MOSI == SWSPI_MISO)
#endif //(SWSPI_MOSI == SWSPI_MISO)
#define swspi_tx swspi_txrx
void swspi_start(); #define swspi_rx swspi_txrx
void swspi_stop(); unsigned char swspi_txrx(unsigned char tx);
#endif //(SWSPI_MOSI == SWSPI_MISO)
#endif //SWSPI_H
void swspi_start();
void swspi_stop();
#endif //SWSPI_H

View File

@ -102,6 +102,8 @@ int8_t SDscrool = 0;
int8_t SilentModeMenu = 0; int8_t SilentModeMenu = 0;
int8_t FSensorStateMenu = 0; int8_t FSensorStateMenu = 0;
extern void fsensor_enable();
extern void fsensor_disable();
#ifdef SNMM #ifdef SNMM
@ -2472,8 +2474,14 @@ void EEPROM_read(int pos, uint8_t* value, uint8_t size)
static void lcd_fsensor_state_set() static void lcd_fsensor_state_set()
{ {
if (!FSensorStateMenu==0) {
fsensor_disable();
}else{
fsensor_enable();
}
FSensorStateMenu = !FSensorStateMenu; FSensorStateMenu = !FSensorStateMenu;
lcd_goto_menu(lcd_settings_menu, 7); lcd_goto_menu(lcd_settings_menu, 7);
} }
static void lcd_silent_mode_set() { static void lcd_silent_mode_set() {
@ -4365,10 +4373,10 @@ static void lcd_selftest()
if (_result) if (_result)
{ {
//current_position[X_AXIS] = current_position[X_AXIS] + 14;
//current_position[Y_AXIS] = current_position[Y_AXIS] + 12;
#ifdef HAVE_TMC2130_DRIVERS #ifdef HAVE_TMC2130_DRIVERS
tmc2130_home_exit(); tmc2130_home_exit();
sg_homing_delay = 0;
enable_endstops(false);
#endif #endif
current_position[X_AXIS] = current_position[X_AXIS] + 14; current_position[X_AXIS] = current_position[X_AXIS] + 14;
current_position[Y_AXIS] = current_position[Y_AXIS] + 12; current_position[Y_AXIS] = current_position[Y_AXIS] + 12;
@ -4429,33 +4437,31 @@ static bool lcd_selfcheck_axis_sg(char axis) {
current_position[axis] = 0; current_position[axis] = 0;
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
#ifdef HAVE_TMC2130_DRIVERS
tmc2130_home_exit();
sg_homing_delay = 0;
tmc2130_axis_stalled[axis] = false;
enable_endstops(true);
#endif
for (char i = 0; i < 2; i++) { for (char i = 0; i < 2; i++) {
/*SERIAL_ECHOPGM("i = "); /*SERIAL_ECHOPGM("i = ");
MYSERIAL.println(int(i)); MYSERIAL.println(int(i));
SERIAL_ECHOPGM("Current position 2:"); SERIAL_ECHOPGM("Current position 2:");
MYSERIAL.println(current_position[axis]);*/ MYSERIAL.println(current_position[axis]);*/
if (i == 0) {
current_position[axis] -= (axis_length + margin);
/*SERIAL_ECHOPGM("Current position 3:");
MYSERIAL.println(current_position[axis]);*/
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
}
else {
current_position[axis] -= margin;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
st_synchronize();
current_position[axis] -= axis_length;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
}
#ifdef HAVE_TMC2130_DRIVERS #ifdef HAVE_TMC2130_DRIVERS
tmc2130_home_enter(axis); tmc2130_home_enter(X_AXIS_MASK << axis);
#endif #endif
current_position[axis] -= (axis_length + margin);
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
st_synchronize(); st_synchronize();
#ifdef HAVE_TMC2130_DRIVERS #ifdef HAVE_TMC2130_DRIVERS
sg_homing_delay = 0;
tmc2130_home_exit(); tmc2130_home_exit();
#endif #endif
//current_position[axis] = st_get_position_mm(axis); //current_position[axis] = st_get_position_mm(axis);
@ -4463,17 +4469,18 @@ static bool lcd_selfcheck_axis_sg(char axis) {
current_position_init = st_get_position_mm(axis); current_position_init = st_get_position_mm(axis);
if (i == 0) { if (i < 1) {
current_position[axis] += margin; current_position[axis] += margin;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
st_synchronize(); st_synchronize();
current_position[axis] += axis_length; current_position[axis] += axis_length;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
#ifdef HAVE_TMC2130_DRIVERS #ifdef HAVE_TMC2130_DRIVERS
tmc2130_home_enter(axis); tmc2130_home_enter(X_AXIS_MASK << axis);
#endif #endif
st_synchronize(); st_synchronize();
#ifdef HAVE_TMC2130_DRIVERS #ifdef HAVE_TMC2130_DRIVERS
sg_homing_delay = 0;
tmc2130_home_exit(); tmc2130_home_exit();
#endif #endif
//current_position[axis] = st_get_position_mm(axis); //current_position[axis] = st_get_position_mm(axis);
@ -4489,7 +4496,9 @@ static bool lcd_selfcheck_axis_sg(char axis) {
if (abs(measured_axis_length[i] - axis_length) > max_error_mm) { if (abs(measured_axis_length[i] - axis_length) > max_error_mm) {
//axis length //axis length
#ifdef HAVE_TMC2130_DRIVERS #ifdef HAVE_TMC2130_DRIVERS
sg_homing_delay = 0;
tmc2130_home_exit(); tmc2130_home_exit();
enable_endstops(false);
#endif #endif
const char *_error_1; const char *_error_1;
const char *_error_2; const char *_error_2;

View File

@ -139,7 +139,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
//#define TMC2130_DEBUG //#define TMC2130_DEBUG
//#define TMC2130_DEBUG_WR //#define TMC2130_DEBUG_WR
//#define TMC2130_DEBUG_RD #define TMC2130_DEBUG_RD
/*------------------------------------ /*------------------------------------