|
@@ -463,11 +463,21 @@ void enquecommand_P(const char *cmd)
|
463
|
463
|
void setup_killpin()
|
464
|
464
|
{
|
465
|
465
|
#if defined(KILL_PIN) && KILL_PIN > -1
|
466
|
|
- pinMode(KILL_PIN,INPUT);
|
|
466
|
+ SET_INPUT(KILL_PIN);
|
467
|
467
|
WRITE(KILL_PIN,HIGH);
|
468
|
468
|
#endif
|
469
|
469
|
}
|
470
|
470
|
|
|
471
|
+// Set home pin
|
|
472
|
+void setup_homepin(void)
|
|
473
|
+{
|
|
474
|
+#if defined(HOME_PIN) && HOME_PIN > -1
|
|
475
|
+ SET_INPUT(HOME_PIN);
|
|
476
|
+ WRITE(HOME_PIN,HIGH);
|
|
477
|
+#endif
|
|
478
|
+}
|
|
479
|
+
|
|
480
|
+
|
471
|
481
|
void setup_photpin()
|
472
|
482
|
{
|
473
|
483
|
#if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
|
|
@@ -600,6 +610,7 @@ void setup()
|
600
|
610
|
pinMode(SERVO0_PIN, OUTPUT);
|
601
|
611
|
digitalWrite(SERVO0_PIN, LOW); // turn it off
|
602
|
612
|
#endif // Z_PROBE_SLED
|
|
613
|
+ setup_homepin();
|
603
|
614
|
}
|
604
|
615
|
|
605
|
616
|
|
|
@@ -4303,6 +4314,18 @@ void handle_status_leds(void) {
|
4303
|
4314
|
|
4304
|
4315
|
void manage_inactivity()
|
4305
|
4316
|
{
|
|
4317
|
+
|
|
4318
|
+#if defined(KILL_PIN) && KILL_PIN > -1
|
|
4319
|
+ static int killCount = 0; // make the inactivity button a bit less responsive
|
|
4320
|
+ const int KILL_DELAY = 10000;
|
|
4321
|
+#endif
|
|
4322
|
+
|
|
4323
|
+#if defined(HOME_PIN) && HOME_PIN > -1
|
|
4324
|
+ static int homeDebounceCount = 0; // poor man's debouncing count
|
|
4325
|
+ const int HOME_DEBOUNCE_DELAY = 10000;
|
|
4326
|
+#endif
|
|
4327
|
+
|
|
4328
|
+
|
4306
|
4329
|
if(buflen < (BUFSIZE-1))
|
4307
|
4330
|
get_command();
|
4308
|
4331
|
|
|
@@ -4332,9 +4355,49 @@ void manage_inactivity()
|
4332
|
4355
|
#endif
|
4333
|
4356
|
|
4334
|
4357
|
#if defined(KILL_PIN) && KILL_PIN > -1
|
|
4358
|
+
|
|
4359
|
+ // Check if the kill button was pressed and wait just in case it was an accidental
|
|
4360
|
+ // key kill key press
|
|
4361
|
+ // -------------------------------------------------------------------------------
|
4335
|
4362
|
if( 0 == READ(KILL_PIN) )
|
4336
|
|
- kill();
|
|
4363
|
+ {
|
|
4364
|
+ killCount++;
|
|
4365
|
+ }
|
|
4366
|
+ else if (killCount > 0)
|
|
4367
|
+ {
|
|
4368
|
+ killCount--;
|
|
4369
|
+ }
|
|
4370
|
+ // Exceeded threshold and we can confirm that it was not accidental
|
|
4371
|
+ // KILL the machine
|
|
4372
|
+ // ----------------------------------------------------------------
|
|
4373
|
+ if ( killCount >= KILL_DELAY)
|
|
4374
|
+ {
|
|
4375
|
+ kill();
|
|
4376
|
+ }
|
4337
|
4377
|
#endif
|
|
4378
|
+
|
|
4379
|
+#if defined(HOME_PIN) && HOME_PIN > -1
|
|
4380
|
+ // Check to see if we have to home, use poor man's debouncer
|
|
4381
|
+ // ---------------------------------------------------------
|
|
4382
|
+ if ( 0 == READ(HOME_PIN) )
|
|
4383
|
+ {
|
|
4384
|
+ if (homeDebounceCount == 0)
|
|
4385
|
+ {
|
|
4386
|
+ enquecommand_P((PSTR("G28")));
|
|
4387
|
+ homeDebounceCount++;
|
|
4388
|
+ LCD_ALERTMESSAGEPGM(MSG_AUTO_HOME);
|
|
4389
|
+ }
|
|
4390
|
+ else if (homeDebounceCount < HOME_DEBOUNCE_DELAY)
|
|
4391
|
+ {
|
|
4392
|
+ homeDebounceCount++;
|
|
4393
|
+ }
|
|
4394
|
+ else
|
|
4395
|
+ {
|
|
4396
|
+ homeDebounceCount = 0;
|
|
4397
|
+ }
|
|
4398
|
+ }
|
|
4399
|
+#endif
|
|
4400
|
+
|
4338
|
4401
|
#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
|
4339
|
4402
|
controllerFan(); //Check if fan should be turned on to cool stepper drivers down
|
4340
|
4403
|
#endif
|
|
@@ -4391,6 +4454,14 @@ void kill()
|
4391
|
4454
|
SERIAL_ERROR_START;
|
4392
|
4455
|
SERIAL_ERRORLNPGM(MSG_ERR_KILLED);
|
4393
|
4456
|
LCD_ALERTMESSAGEPGM(MSG_KILLED);
|
|
4457
|
+
|
|
4458
|
+ // FMC small patch to update the LCD before ending
|
|
4459
|
+ sei(); // enable interrupts
|
|
4460
|
+ for ( int i=5; i--; lcd_update())
|
|
4461
|
+ {
|
|
4462
|
+ delay(200);
|
|
4463
|
+ }
|
|
4464
|
+ cli(); // disable interrupts
|
4394
|
4465
|
suicide();
|
4395
|
4466
|
while(1) { /* Intentionally left empty */ } // Wait for reset
|
4396
|
4467
|
}
|