diff --git a/Grbl_Esp32/config.h b/Grbl_Esp32/config.h index 588a1ac4..9d6ca1c0 100644 --- a/Grbl_Esp32/config.h +++ b/Grbl_Esp32/config.h @@ -189,7 +189,7 @@ Some features should not be changed. See notes below. // immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until // the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the // previous tool path, as if nothing happened. -#define ENABLE_SAFETY_DOOR_INPUT_PIN // ESP32 Leave this enabled for now .. code for undefined not ready +//#define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable. // After the safety door switch has been toggled and restored, this setting sets the power-up delay // between restoring the spindle and coolant and resuming the cycle. @@ -211,6 +211,10 @@ Some features should not be changed. See notes below. // inverting only two control pins, the safety door and reset. See cpu_map.h for other bit definitions. //#define INVERT_CONTROL_PIN_MASK CONTROL_MASK // Default disabled. Uncomment to disable. +// This allows control pins to be ignored. +// Since these are typically used on the pins that don't have pullups, they will float and cause +// problems if not externally pulled up. Ignoring will always return not activated when read. +//#define IGNORE_CONTROL_PINS // Inverts select limit pin states based on the following mask. This effects all limit pin functions, // such as hard limits and homing. However, this is different from overall invert limits setting. @@ -579,7 +583,7 @@ Some features should not be changed. See notes below. // NOTE: Still a work-in-progress. Machine coordinates must be in all negative space and // does not work with HOMING_FORCE_SET_ORIGIN enabled. Parking motion also moves only in // positive direction. -// #define PARKING_ENABLE // Default disabled. Uncomment to enable +//#define PARKING_ENABLE // Default disabled. Uncomment to enable // Configure options for the parking motion, if enabled. #define PARKING_AXIS Z_AXIS // Define which axis that performs the parking motion diff --git a/Grbl_Esp32/defaults.h b/Grbl_Esp32/defaults.h index b6ec8afc..3ae0cb45 100644 --- a/Grbl_Esp32/defaults.h +++ b/Grbl_Esp32/defaults.h @@ -40,9 +40,9 @@ #define DEFAULT_DIRECTION_INVERT_MASK 0 // uint8_t #define DEFAULT_INVERT_ST_ENABLE 0 // boolean #define DEFAULT_INVERT_LIMIT_PINS 1 // boolean - #define DEFAULT_INVERT_PROBE_PIN 1 // boolean + #define DEFAULT_INVERT_PROBE_PIN 0 // boolean - #define DEFAULT_STATUS_REPORT_MASK 1 // MPos enabled + #define DEFAULT_STATUS_REPORT_MASK 2 // MPos enabled #define DEFAULT_JUNCTION_DEVIATION 0.01 // mm #define DEFAULT_ARC_TOLERANCE 0.002 // mm @@ -53,8 +53,8 @@ #define DEFAULT_HOMING_ENABLE 0 // false #define DEFAULT_HOMING_DIR_MASK 3 // move positive dir Z, negative X,Y - #define DEFAULT_HOMING_FEED_RATE 100.0 // mm/min - #define DEFAULT_HOMING_SEEK_RATE 500.0 // mm/min + #define DEFAULT_HOMING_FEED_RATE 200.0 // mm/min + #define DEFAULT_HOMING_SEEK_RATE 2000.0 // mm/min #define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k) #define DEFAULT_HOMING_PULLOFF 1.0 // mm @@ -63,17 +63,17 @@ #define DEFAULT_LASER_MODE 0 // false - #define DEFAULT_X_STEPS_PER_MM 250.0 - #define DEFAULT_Y_STEPS_PER_MM 250.0 - #define DEFAULT_Z_STEPS_PER_MM 250.0 + #define DEFAULT_X_STEPS_PER_MM 800.0 + #define DEFAULT_Y_STEPS_PER_MM 800.0 + #define DEFAULT_Z_STEPS_PER_MM 800.0 - #define DEFAULT_X_MAX_RATE 6000.0 // mm/min - #define DEFAULT_Y_MAX_RATE 6000.0 // mm/min - #define DEFAULT_Z_MAX_RATE 6000.0 // mm/min + #define DEFAULT_X_MAX_RATE 5000.0 // mm/min + #define DEFAULT_Y_MAX_RATE 4000.0 // mm/min + #define DEFAULT_Z_MAX_RATE 3000.0 // mm/min - #define DEFAULT_X_ACCELERATION (50.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 - #define DEFAULT_Y_ACCELERATION (50.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 - #define DEFAULT_Z_ACCELERATION (50.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 + #define DEFAULT_X_ACCELERATION (200.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 + #define DEFAULT_Y_ACCELERATION (200.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 + #define DEFAULT_Z_ACCELERATION (200.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 #define DEFAULT_X_MAX_TRAVEL 300.0 // mm NOTE: Must be a positive value. #define DEFAULT_Y_MAX_TRAVEL 300.0 // mm NOTE: Must be a positive value. @@ -84,4 +84,4 @@ -#endif +#endif \ No newline at end of file diff --git a/Grbl_Esp32/grbl.h b/Grbl_Esp32/grbl.h index 3564891b..1a815964 100644 --- a/Grbl_Esp32/grbl.h +++ b/Grbl_Esp32/grbl.h @@ -20,7 +20,7 @@ // Grbl versioning system #define GRBL_VERSION "1.1f" -#define GRBL_VERSION_BUILD "20180817" +#define GRBL_VERSION_BUILD "20180823" //#include #include @@ -44,7 +44,6 @@ #include "gcode.h" #include "limits.h" #include "motion_control.h" -#include "print.h" #include "probe.h" #include "protocol.h" #include "report.h" diff --git a/Grbl_Esp32/print.cpp b/Grbl_Esp32/print.cpp deleted file mode 100644 index 1a2885fb..00000000 --- a/Grbl_Esp32/print.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - print.c - Functions for formatting output strings - Part of Grbl - - Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC - Copyright (c) 2009-2011 Simen Svale Skogsrud - - 2018 - Bart Dring This file was modifed for use on the ESP32 - CPU. Do not use this with Grbl for atMega328P - - Grbl is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Grbl is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Grbl. If not, see . -*/ - -#include "grbl.h" - - - - -// void printIntegerInBase(unsigned long n, unsigned long base) -// { -// unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. -// unsigned long i = 0; -// -// if (n == 0) { -// serial_write('0'); -// return; -// } -// -// while (n > 0) { -// buf[i++] = n % base; -// n /= base; -// } -// -// for (; i > 0; i--) -// serial_write(buf[i - 1] < 10 ? -// '0' + buf[i - 1] : -// 'A' + buf[i - 1] - 10); -// } - - -// Prints an uint8 variable in base 10. -void print_uint8_base10(uint8_t n) -{ - uint8_t digit_a = 0; - uint8_t digit_b = 0; - if (n >= 100) { // 100-255 - digit_a = '0' + n % 10; - n /= 10; - } - if (n >= 10) { // 10-99 - digit_b = '0' + n % 10; - n /= 10; - } - serial_write('0' + n); - if (digit_b) { serial_write(digit_b); } - if (digit_a) { serial_write(digit_a); } -} - - -// Prints an uint8 variable in base 2 with desired number of desired digits. -void print_uint8_base2_ndigit(uint8_t n, uint8_t digits) { - unsigned char buf[digits]; - uint8_t i = 0; - - for (; i < digits; i++) { - buf[i] = n % 2 ; - n /= 2; - } - - for (; i > 0; i--) - Serial.print('0' + buf[i - 1]); -} - - -void print_uint32_base10(uint32_t n) -{ - if (n == 0) { - Serial.print('0'); - return; - } - - unsigned char buf[10]; - uint8_t i = 0; - - while (n > 0) { - buf[i++] = n % 10; - n /= 10; - } - - for (; i > 0; i--) - Serial.print('0' + buf[i-1]); -} - - -void printInteger(long n) -{ - if (n < 0) { - Serial.print('-'); - print_uint32_base10(-n); - } else { - print_uint32_base10(n); - } -} - - -// Convert float to string by immediately converting to a long integer, which contains -// more digits than a float. Number of decimal places, which are tracked by a counter, -// may be set by the user. The integer is then efficiently converted to a string. -// NOTE: AVR '%' and '/' integer operations are very efficient. Bitshifting speed-up -// techniques are actually just slightly slower. Found this out the hard way. -void printFloat(float n, uint8_t decimal_places) -{ - Serial.print(n, decimal_places); -} - - -// Floating value printing handlers for special variables types used in Grbl and are defined -// in the config.h. -// - CoordValue: Handles all position or coordinate values in inches or mm reporting. -// - RateValue: Handles feed rate and current velocity in inches or mm reporting. -void printFloat_CoordValue(float n) { - if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) { - printFloat(n*INCH_PER_MM,N_DECIMAL_COORDVALUE_INCH); - } else { - printFloat(n,N_DECIMAL_COORDVALUE_MM); - } -} - -void printFloat_RateValue(float n) { - if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) { - printFloat(n*INCH_PER_MM,N_DECIMAL_RATEVALUE_INCH); - } else { - printFloat(n,N_DECIMAL_RATEVALUE_MM); - } -} - -// Debug tool to print free memory in bytes at the called point. -// NOTE: Keep commented unless using. Part of this function always gets compiled in. -// void printFreeMemory() -// { -// extern int __heap_start, *__brkval; -// uint16_t free; // Up to 64k values. -// free = (int) &free - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); -// printInteger((int32_t)free); -// printString(" "); -// } diff --git a/Grbl_Esp32/print.h b/Grbl_Esp32/print.h deleted file mode 100644 index 9ee2559d..00000000 --- a/Grbl_Esp32/print.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - print.h - Functions for formatting output strings - Part of Grbl - - Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC - Copyright (c) 2009-2011 Simen Svale Skogsrud - - 2018 - Bart Dring This file was modifed for use on the ESP32 - CPU. Do not use this with Grbl for atMega328P - - Grbl is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Grbl is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Grbl. If not, see . -*/ - -#ifndef print_h -#define print_h - - -void printString(const char *s); - -void printPgmString(const char *s); - -void printInteger(long n); - -void print_uint32_base10(uint32_t n); - -// Prints an uint8 variable in base 10. -void print_uint8_base10(uint8_t n); - -// Prints an uint8 variable in base 2 with desired number of desired digits. -void print_uint8_base2_ndigit(uint8_t n, uint8_t digits); - -void printFloat(float n, uint8_t decimal_places); - -// Floating value printing handlers for special variables types used in Grbl. -// - CoordValue: Handles all position or coordinate values in inches or mm reporting. -// - RateValue: Handles feed rate and current velocity in inches or mm reporting. -void printFloat_CoordValue(float n); -void printFloat_RateValue(float n); - -// Debug tool to print free memory in bytes at the called point. Not used otherwise. -void printFreeMemory(); - -#endif diff --git a/Grbl_Esp32/report.cpp b/Grbl_Esp32/report.cpp index 0bab2f57..10cefd05 100644 --- a/Grbl_Esp32/report.cpp +++ b/Grbl_Esp32/report.cpp @@ -466,14 +466,38 @@ void report_build_info(char *line) strcat(build_info,"H"); #endif #ifdef LIMITS_TWO_SWITCHES_ON_AXES - strcat(build_info,"L"); + strcat(build_info,"T"); + #endif + #ifdef ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES + strcat(build_info,"A"); + #endif + #ifdef ENABLE_SAFETY_DOOR_INPUT_PIN + strcat(build_info,"+"); #endif #ifdef ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES - strcat(build_info,"A"); + strcat(build_info,"A"); + #endif + #ifdef USE_SPINDLE_DIR_AS_ENABLE_PIN + strcat(build_info,"D"); + #endif + #ifdef SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED + strcat(build_info,"0"); + #endif + #ifdef ENABLE_SOFTWARE_DEBOUNCE + strcat(build_info,"S"); + #endif + #ifdef ENABLE_PARKING_OVERRIDE_CONTROL + strcat(build_info,"R"); + #endif + #ifndef HOMING_INIT_LOCK + strcat(build_info,"L"); #endif #ifdef ENABLE_BLUETOOTH strcat(build_info,"B"); #endif + #ifdef ENABLE_SAFETY_DOOR_INPUT_PIN + strcat(build_info,"+"); + #endif #ifndef ENABLE_RESTORE_EEPROM_WIPE_ALL // NOTE: Shown when disabled. strcat(build_info,"*"); #endif diff --git a/Grbl_Esp32/report.h b/Grbl_Esp32/report.h index b518b6a0..e20abe9f 100644 --- a/Grbl_Esp32/report.h +++ b/Grbl_Esp32/report.h @@ -63,6 +63,16 @@ #define STATUS_GCODE_G43_DYNAMIC_AXIS_ERROR 37 #define STATUS_GCODE_MAX_VALUE_EXCEEDED 38 +#define STATUS_SD_FAILED_MOUNT 60 // SD Failed to mount +#define STATUS_SD_FAILED_READ 61 // SD Failed to read file +#define STATUS_SD_FAILED_OPEN_DIR 62 // SD card failed to open directory +#define STATUS_SD_DIR_NOT_FOUND 63 // SD Card directory not found +#define STATUS_SD_FILE_EMPTY 64 // SD Card directory not found + +#define STATUS_BT_FAIL_BEGIN 70 // Bluetooth failed to start + + + // Define Grbl alarm codes. Valid values (1-255). 0 is reserved. #define ALARM_HARD_LIMIT_ERROR EXEC_ALARM_HARD_LIMIT #define ALARM_SOFT_LIMIT_ERROR EXEC_ALARM_SOFT_LIMIT @@ -87,6 +97,8 @@ #define MESSAGE_SPINDLE_RESTORE 10 #define MESSAGE_SLEEP_MODE 11 +void grbl_send(char *text); + // Prints system status messages. void report_status_message(uint8_t status_code); void report_realtime_steps(); @@ -134,4 +146,4 @@ void report_build_info(char *line); void settings_help(); -#endif +#endif \ No newline at end of file diff --git a/Grbl_Esp32/stepper.cpp b/Grbl_Esp32/stepper.cpp index 2d8b495b..547f895a 100644 --- a/Grbl_Esp32/stepper.cpp +++ b/Grbl_Esp32/stepper.cpp @@ -496,6 +496,43 @@ void st_update_plan_block_parameters() } } +#ifdef PARKING_ENABLE + // Changes the run state of the step segment buffer to execute the special parking motion. + void st_parking_setup_buffer() + { + // Store step execution data of partially completed block, if necessary. + if (prep.recalculate_flag & PREP_FLAG_HOLD_PARTIAL_BLOCK) { + prep.last_st_block_index = prep.st_block_index; + prep.last_steps_remaining = prep.steps_remaining; + prep.last_dt_remainder = prep.dt_remainder; + prep.last_step_per_mm = prep.step_per_mm; + } + // Set flags to execute a parking motion + prep.recalculate_flag |= PREP_FLAG_PARKING; + prep.recalculate_flag &= ~(PREP_FLAG_RECALCULATE); + pl_block = NULL; // Always reset parking motion to reload new block. + } + + + // Restores the step segment buffer to the normal run state after a parking motion. + void st_parking_restore_buffer() + { + // Restore step execution data and flags of partially completed block, if necessary. + if (prep.recalculate_flag & PREP_FLAG_HOLD_PARTIAL_BLOCK) { + st_prep_block = &st_block_buffer[prep.last_st_block_index]; + prep.st_block_index = prep.last_st_block_index; + prep.steps_remaining = prep.last_steps_remaining; + prep.dt_remainder = prep.last_dt_remainder; + prep.step_per_mm = prep.last_step_per_mm; + prep.recalculate_flag = (PREP_FLAG_HOLD_PARTIAL_BLOCK | PREP_FLAG_RECALCULATE); + prep.req_mm_increment = REQ_MM_INCREMENT_SCALAR/prep.step_per_mm; // Recompute this value. + } else { + prep.recalculate_flag = false; + } + pl_block = NULL; // Set to reload next block. + } +#endif + // Generates the step and direction port invert masks used in the Stepper Interrupt Driver. void st_generate_step_dir_invert_masks() { diff --git a/Grbl_Esp32/system.cpp b/Grbl_Esp32/system.cpp index ef687961..c8cd9c6f 100644 --- a/Grbl_Esp32/system.cpp +++ b/Grbl_Esp32/system.cpp @@ -24,7 +24,9 @@ void system_ini() // Renamed from system_init() due to conflict with esp32 files { // setup control inputs - pinMode(CONTROL_SAFETY_DOOR_PIN, INPUT); + #ifdef ENABLE_SAFETY_DOOR_INPUT_PIN + pinMode(CONTROL_SAFETY_DOOR_PIN, INPUT); + #endif pinMode(CONTROL_RESET_PIN, INPUT); pinMode(CONTROL_FEED_HOLD_PIN, INPUT); pinMode(CONTROL_CYCLE_START_PIN, INPUT); @@ -378,8 +380,15 @@ uint8_t system_check_travel_limits(float *target) // defined by the CONTROL_PIN_INDEX in the header file. uint8_t system_control_get_state() { + #ifdef IGNORE_CONTROL_PINS + return 0; + #endif + + uint8_t control_state = 0; + #ifdef ENABLE_SAFETY_DOOR_INPUT_PIN if (digitalRead(CONTROL_SAFETY_DOOR_PIN)) { control_state |= CONTROL_PIN_INDEX_SAFETY_DOOR; } + #endif if (digitalRead(CONTROL_RESET_PIN)) { control_state |= CONTROL_PIN_INDEX_RESET; } if (digitalRead(CONTROL_FEED_HOLD_PIN)) { control_state |= CONTROL_PIN_INDEX_FEED_HOLD; } if (digitalRead(CONTROL_CYCLE_START_PIN)) { control_state |= CONTROL_PIN_INDEX_CYCLE_START; } diff --git a/doc/csv/build_option_codes_en_US.csv b/doc/csv/build_option_codes_en_US.csv index 9a6d0fb4..867b489c 100644 --- a/doc/csv/build_option_codes_en_US.csv +++ b/doc/csv/build_option_codes_en_US.csv @@ -19,4 +19,5 @@ $,Restore EEPROM `$` settings command,Disabled I,Build info write user string command,Disabled E,Force sync upon EEPROM write,Disabled W,Force sync upon work coordinate offset change,Disabled -L,Homing initialization auto-lock,Disabled \ No newline at end of file +L,Homing initialization auto-lock,Disabled +B,Bluetooth Enabled \ No newline at end of file