RepRapDiscount Full Graphic LCD reset button code July 20, 2015 06:22AM |
Registered: 8 years ago Posts: 126 |
Re: RepRapDiscount Full Graphic LCD reset button code July 21, 2015 04:44AM |
Admin Registered: 13 years ago Posts: 7,012 |
Re: RepRapDiscount Full Graphic LCD reset button code July 21, 2015 09:12AM |
Registered: 8 years ago Posts: 126 |
Quote
Dust
The circuit shows it just grounds the cpu reset line. Ie hardware reset. Wich on power on will turn off heated bed and hotend etc.
Ie I dont think it works how you think it does.
Re: RepRapDiscount Full Graphic LCD reset button code July 21, 2015 01:17PM |
Registered: 9 years ago Posts: 606 |
Re: RepRapDiscount Full Graphic LCD reset button code July 21, 2015 02:42PM |
Registered: 8 years ago Posts: 126 |
Quote
tadawson
That's not actually correct. It grounds the line errantly labelled as reset on the LCD schematic, but that line is wired to pin 41 on RAMPS, which is mapped in pins.h to whatever you want (default is KILL_PIN, IIRC), or can be disabled outright. It is *NOT* a dedicated reset line . . .
- Tim
Marlin_main.cpp void manage_inactivity()
#if defined(KILL_PIN) && KILL_PIN > -1 if( 0 == READ(KILL_PIN) ) kill(); #endif
void kill() { cli(); // Stop interrupts disable_heater(); disable_x(); disable_y(); disable_z(); disable_e0(); disable_e1(); disable_e2(); #if defined(PS_ON_PIN) && PS_ON_PIN > -1 pinMode(PS_ON_PIN,INPUT); #endif SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_ERR_KILLED); LCD_ALERTMESSAGEPGM(MSG_KILLED); suicide(); while(1) { /* Intentionally left empty */ } // Wait for reset }
#if defined(KILL_PIN) && KILL_PIN > -1 if( 0 == READ(KILL_PIN) ) ParkPause(); #endif void ParkPause() { float target[4]; float lastpos[4]; target[X_AXIS]=current_position[X_AXIS]; target[Y_AXIS]=current_position[Y_AXIS]; target[Z_AXIS]=current_position[Z_AXIS]; target[E_AXIS]=current_position[E_AXIS]; lastpos[X_AXIS]=current_position[X_AXIS]; lastpos[Y_AXIS]=current_position[Y_AXIS]; lastpos[Z_AXIS]=current_position[Z_AXIS]; lastpos[E_AXIS]=current_position[E_AXIS]; target[X_AXIS]= 0; target[Y_AXIS]= 225; plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); //finish moves st_synchronize(); uint8_t cnt=0; while(!lcd_clicked()){ cnt++; manage_heater(); manage_inactivity(); lcd_update(); } //return to normal plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); //should do nothing plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); //move xy back plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); //move z back plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], lastpos[E_AXIS], feedrate/60, active_extruder); //final untretract }
Re: RepRapDiscount Full Graphic LCD reset button code July 21, 2015 03:33PM |
Registered: 9 years ago Posts: 606 |
Re: RepRapDiscount Full Graphic LCD reset button code July 21, 2015 03:41PM |
Registered: 8 years ago Posts: 126 |
Quote
tadawson
Were it me, I would define a new pinning and function - IE FILSWAP_PIN or some such, map that to pin 41 in pins.h, and then clone and rename the kill function, and then could do either, were I to decide to add another switch . . . The connection between the switch and the function is soft, so why bugger up good existing code?
IE:
pins.h:
#if defined(REPRAP_DISCOUNT_SMART_CONTROLLER) || defined(G3D_PANEL)
// #define KILL_PIN 41
#define KILL_PIN -1
#define FILSWAP_PIN 41
#else
#define KILL_PIN -1
#endif
*and*
#if defined(FILSWAP_PIN) && FILSWAP_PIN > -1
if( 0 == READ(FILSWAP_PIN) )
ParkPause();
#endif
.
. Your function . . .
.
- Tim
if( 0 == READ(KILL_PIN) ) kill();
if( 0 == READ(KILL_PIN) ) ParkPause();
Re: RepRapDiscount Full Graphic LCD reset button code July 23, 2015 05:35AM |
Admin Registered: 13 years ago Posts: 7,012 |
Re: RepRapDiscount Full Graphic LCD reset button code July 23, 2015 02:29PM |
Registered: 9 years ago Posts: 606 |
Quote
DaveOB
Quote
tadawson
Were it me, I would define a new pinning and function - IE FILSWAP_PIN or some such, map that to pin 41 in pins.h, and then clone and rename the kill function, and then could do either, were I to decide to add another switch . . . The connection between the switch and the function is soft, so why bugger up good existing code?
IE:
pins.h:
#if defined(REPRAP_DISCOUNT_SMART_CONTROLLER) || defined(G3D_PANEL)
// #define KILL_PIN 41
#define KILL_PIN -1
#define FILSWAP_PIN 41
#else
#define KILL_PIN -1
#endif
*and*
#if defined(FILSWAP_PIN) && FILSWAP_PIN > -1
if( 0 == READ(FILSWAP_PIN) )
ParkPause();
#endif
.
. Your function . . .
.
- Tim
Thanks again Tim
Sorry, but with my limited coding, I don't see the difference between ( IF I understand your suggestion correct ) :
A. changing the pin mapping in pins.h from KILL_PIN to FILSWAP_PIN
or
B changing the function that gets called from
if( 0 == READ(KILL_PIN) ) kill();
to
if( 0 == READ(KILL_PIN) ) ParkPause();
In either case, there is a need for a new function ( ParkPause ).
Re: RepRapDiscount Full Graphic LCD reset button code July 24, 2015 04:19PM |
Registered: 9 years ago Posts: 109 |
Re: RepRapDiscount Full Graphic LCD reset button code July 24, 2015 05:12PM |
Registered: 8 years ago Posts: 126 |
Re: RepRapDiscount Full Graphic LCD reset button code July 24, 2015 08:49PM |
Registered: 9 years ago Posts: 606 |
Re: RepRapDiscount Full Graphic LCD reset button code July 25, 2015 04:41AM |
Registered: 8 years ago Posts: 126 |
Quote
tadawson
I don't know about you guys, but I find that an emergency stop is a lot of things, but useless isn't one of them . . . And I'd rather have it that some other function that could more easily implemented as a macro in Pronterface . . . such as filament load and unload . . .
- Tim
Re: RepRapDiscount Full Graphic LCD reset button code July 25, 2015 06:23AM |
Registered: 8 years ago Posts: 126 |
uint8_t cnt=0; while(!lcd_clicked()){ // wait for the LCD button to be pressed again cnt++; manage_heater(); manage_inactivity(); lcd_update(); } // go back to Home positions for X and Y in case they were moved from 0,225 //return to normal plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); //should do nothing plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); //move xy back plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); //move z back plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], lastpos[E_AXIS], feedrate/60, active_extruder); //final untretract
Re: RepRapDiscount Full Graphic LCD reset button code July 27, 2015 05:25AM |
Registered: 8 years ago Posts: 126 |
card.pauseSDPrint(); plan_buffer_line(ParkPausetarget[X_AXIS], ParkPausetarget[Y_AXIS], ParkPausetarget[Z_AXIS], ParkPauselastpos[E_AXIS], 150, active_extruder); st_synchronize();
MYSERIAL.println("Resume Normal Operation"); plan_buffer_line(ParkPauselastpos[X_AXIS], ParkPauselastpos[Y_AXIS], ParkPauselastpos[Z_AXIS], ParkPauselastpos[E_AXIS], 150, active_extruder); //final untretract st_synchronize(); card.startFileprint();
SOLVED :RepRapDiscount Full Graphic LCD reset button code July 28, 2015 07:37AM |
Registered: 8 years ago Posts: 126 |
// ==> ParkPause : uncomment this line to change the graphical LCD button funtion from 'kill' to 'ParkPause' #define EnableParkPause
void kill();to
void kill(); // add this line for ParkPause void ParkPause();
float homing_feedrate[] = HOMING_FEEDRATE;add
long ParkPauseMillis = -1; // prevents ParkPause from running unless printing has started
case 1: // G1add
if(ParkPauseMillis == -1) ParkPauseMillis = 0; // enables the ParkPause option after printing has started
#ifdef DUAL_X_CARRIAGE case 605: // Set dual x-carriage movement mode:
case 6001: //custom ParkPause // called from ParkPause function using : enquecommand_P(PSTR("M6001")); { LCD_MESSAGEPGM("ParkPause Init"); float target[4]; float lastpos[4]; target[X_AXIS]=current_position[X_AXIS]; target[Y_AXIS]=current_position[Y_AXIS]; target[Z_AXIS]=current_position[Z_AXIS]; target[E_AXIS]=current_position[E_AXIS]; lastpos[X_AXIS]=current_position[X_AXIS]; lastpos[Y_AXIS]=current_position[Y_AXIS]; lastpos[Z_AXIS]=current_position[Z_AXIS]; lastpos[E_AXIS]=current_position[E_AXIS]; plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); target[Z_AXIS]+= 5; //lift Z by 5mm plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); st_synchronize(); target[X_AXIS]= 5; target[Y_AXIS]= 225; plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); st_synchronize(); LCD_MESSAGEPGM("ParkPause Done"); delay(100); while(!lcd_clicked()){ manage_heater(); manage_inactivity(); lcd_update(); } LCD_MESSAGEPGM("ParkPause Reset"); lcd_update(); ParkPauseMillis = 0; plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); //should do nothing plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); //move xy back plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); //move z back LCD_MESSAGEPGM("Resumed"); } break;
void kill() { cli(); // Stop interrupts disable_heater(); disable_x(); disable_y(); disable_z(); disable_e0(); disable_e1(); disable_e2(); #if defined(PS_ON_PIN) && PS_ON_PIN > -1 pinMode(PS_ON_PIN,INPUT); #endif SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_ERR_KILLED); LCD_ALERTMESSAGEPGM(MSG_KILLED); suicide(); while(1) { /* Intentionally left empty */ } // Wait for reset }
void kill() { #ifdef EnableParkPause // check if the config option for ParkPause is enabled ParkPause(); #else // otherwise do the normal kill sequence cli(); // Stop interrupts disable_heater(); disable_x(); disable_y(); disable_z(); disable_e0(); disable_e1(); disable_e2(); #if defined(PS_ON_PIN) && PS_ON_PIN > -1 pinMode(PS_ON_PIN,INPUT); #endif SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_ERR_KILLED); LCD_ALERTMESSAGEPGM(MSG_KILLED); suicide(); while(1) { /* Intentionally left empty */ } // Wait for reset #endif }
void Stop()
// ParkPause - add this function for the ParkPause void ParkPause() { // if the button was pressed sometime in the last 5 seconds, ignore this button press as it is likely to be part of the first button press. if(ParkPauseMillis > 1){ if(millis() <= (ParkPauseMillis + 3000)){ MYSERIAL.println("------------------------------------------------- ParkPause Aborted - less than 10 seconds since last press"); return; // exit out of tis function and ignore the rest of the code in the function } } // otherwise if the button has not been pressed before, then ParkPause the printer if(ParkPauseMillis == 0){ ParkPauseMillis = millis(); enquecommand_P(PSTR("M6001")); return; // exit out of tis function and ignore the rest of the code in the function } }
Re: SOLVED :RepRapDiscount Full Graphic LCD reset button code August 22, 2015 09:21PM |
Registered: 10 years ago Posts: 444 |
Re: SOLVED :RepRapDiscount Full Graphic LCD reset button code August 23, 2015 12:06AM |
Registered: 9 years ago Posts: 606 |
Re: SOLVED :RepRapDiscount Full Graphic LCD reset button code August 23, 2015 02:10AM |
Registered: 8 years ago Posts: 126 |
Quote
RRuser
Is this pause/resume function working for everyone? Seems a perfect use for that button.
case 6001: //custom ParkPause // called from ParkPause function using : enquecommand_P(PSTR("M6001")); { LCD_MESSAGEPGM("ParkPause Init"); float target[4]; float lastpos[4]; target[X_AXIS]=current_position[X_AXIS]; target[Y_AXIS]=current_position[Y_AXIS]; target[Z_AXIS]=current_position[Z_AXIS]; target[E_AXIS]=current_position[E_AXIS]; lastpos[X_AXIS]=current_position[X_AXIS]; lastpos[Y_AXIS]=current_position[Y_AXIS]; lastpos[Z_AXIS]=current_position[Z_AXIS]; lastpos[E_AXIS]=current_position[E_AXIS]; plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); target[X_AXIS]= 5; target[Y_AXIS]= 225; plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); st_synchronize(); target[Z_AXIS]+= 5; //lift Z by 5mm plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); st_synchronize(); LCD_MESSAGEPGM("ParkPause Done"); delay(100); while(!lcd_clicked()){ manage_heater(); manage_inactivity(); lcd_update(); } LCD_MESSAGEPGM("ParkPause Reset"); lcd_update(); ParkPauseMillis = 0; plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); //should do nothing plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); //move xy back plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); //move z back LCD_MESSAGEPGM("Resumed"); } break;
Re: RepRapDiscount Full Graphic LCD reset button code September 07, 2015 03:58PM |
Registered: 9 years ago Posts: 17 |
Re: RepRapDiscount Full Graphic LCD reset button code September 07, 2015 04:14PM |
Registered: 8 years ago Posts: 126 |
Quote
atunguyd
Hi Dave, have you considered submitting these code changes to the Marlin GitHUB? I think it would be a good idea to pass it on to them.