Merge branch 'SAV-MkI_merge' into Development

Tested for SAV MKI and SAV 3D LCD on lewihe.
This commit is contained in:
fmalpartida
2014-12-28 19:54:06 +01:00
parent a5ed3e96f2
commit ec33df0554
6 changed files with 106 additions and 17 deletions

View File

@@ -463,11 +463,21 @@ void enquecommand_P(const char *cmd)
void setup_killpin()
{
#if defined(KILL_PIN) && KILL_PIN > -1
pinMode(KILL_PIN,INPUT);
SET_INPUT(KILL_PIN);
WRITE(KILL_PIN,HIGH);
#endif
}
// Set home pin
void setup_homepin(void)
{
#if defined(HOME_PIN) && HOME_PIN > -1
SET_INPUT(HOME_PIN);
WRITE(HOME_PIN,HIGH);
#endif
}
void setup_photpin()
{
#if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
@@ -600,6 +610,7 @@ void setup()
pinMode(SERVO0_PIN, OUTPUT);
digitalWrite(SERVO0_PIN, LOW); // turn it off
#endif // Z_PROBE_SLED
setup_homepin();
}
@@ -4303,6 +4314,18 @@ void handle_status_leds(void) {
void manage_inactivity()
{
#if defined(KILL_PIN) && KILL_PIN > -1
static int killCount = 0; // make the inactivity button a bit less responsive
const int KILL_DELAY = 10000;
#endif
#if defined(HOME_PIN) && HOME_PIN > -1
static int homeDebounceCount = 0; // poor man's debouncing count
const int HOME_DEBOUNCE_DELAY = 10000;
#endif
if(buflen < (BUFSIZE-1))
get_command();
@@ -4332,9 +4355,49 @@ void manage_inactivity()
#endif
#if defined(KILL_PIN) && KILL_PIN > -1
// Check if the kill button was pressed and wait just in case it was an accidental
// key kill key press
// -------------------------------------------------------------------------------
if( 0 == READ(KILL_PIN) )
kill();
{
killCount++;
}
else if (killCount > 0)
{
killCount--;
}
// Exceeded threshold and we can confirm that it was not accidental
// KILL the machine
// ----------------------------------------------------------------
if ( killCount >= KILL_DELAY)
{
kill();
}
#endif
#if defined(HOME_PIN) && HOME_PIN > -1
// Check to see if we have to home, use poor man's debouncer
// ---------------------------------------------------------
if ( 0 == READ(HOME_PIN) )
{
if (homeDebounceCount == 0)
{
enquecommand_P((PSTR("G28")));
homeDebounceCount++;
LCD_ALERTMESSAGEPGM(MSG_AUTO_HOME);
}
else if (homeDebounceCount < HOME_DEBOUNCE_DELAY)
{
homeDebounceCount++;
}
else
{
homeDebounceCount = 0;
}
}
#endif
#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
controllerFan(); //Check if fan should be turned on to cool stepper drivers down
#endif
@@ -4391,6 +4454,14 @@ void kill()
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM(MSG_ERR_KILLED);
LCD_ALERTMESSAGEPGM(MSG_KILLED);
// FMC small patch to update the LCD before ending
sei(); // enable interrupts
for ( int i=5; i--; lcd_update())
{
delay(200);
}
cli(); // disable interrupts
suicide();
while(1) { /* Intentionally left empty */ } // Wait for reset
}