From 37d918ae905ea6267fc2bfb0ca208a0f070239a8 Mon Sep 17 00:00:00 2001 From: bdring Date: Sat, 22 Feb 2020 09:53:36 -0600 Subject: [PATCH 1/4] Updated the way RMT channels are assigned RMT channels are now dynamically assigned by init_RMT() by the #defined pins it sees. --- Grbl_Esp32/config.h | 8 +- Grbl_Esp32/cpu_map.h | 59 ++++++++- Grbl_Esp32/grbl.h | 2 +- Grbl_Esp32/stepper.cpp | 268 +++++++++++++++++++++++------------------ Grbl_Esp32/stepper.h | 8 -- Grbl_Esp32/system.cpp | 15 +++ Grbl_Esp32/system.h | 2 + 7 files changed, 228 insertions(+), 134 deletions(-) diff --git a/Grbl_Esp32/config.h b/Grbl_Esp32/config.h index d6be8eb6..b0057328 100644 --- a/Grbl_Esp32/config.h +++ b/Grbl_Esp32/config.h @@ -44,11 +44,11 @@ Some features should not be changed. See notes below. // The CPU map is the main definition of the machine/controller you want to use // These are typically found in the cpu_map.h file. // See Github repo wiki for more details -#define CPU_MAP_TEST_DRIVE // these are defined in cpu_map.h +#define CPU_MAP_ESP32 // these are defined in cpu_map.h // Number of axes defined (steppers, servos, etc) (valid range: 3 to 6) -// Even if your machine only uses less than the minimum of 3, you should select 3 -#define N_AXIS 3 +// Even if your machine only uses less than the minimum of 3, you should select 3 +#define N_AXIS 3 #define VERBOSE_HELP // Currently this doesn't do anything #define GRBL_MSG_LEVEL MSG_LEVEL_INFO // what level of [MSG:....] do you want to see 0=all off @@ -288,7 +288,7 @@ Some features should not be changed. See notes below. #define IGNORE_CONTROL_PINS #define ENABLE_CONTROL_SW_DEBOUNCE // Default disabled. Uncomment to enable. -#define CONTROL_SW_DEBOUNCE_PERIOD 32 // in milliseconds default 32 microseconds +#define CONTROL_SW_DEBOUNCE_PERIOD 32 // in milliseconds default 32 microseconds // Inverts select limit pin states based on the following mask. This effects all limit pin functions, diff --git a/Grbl_Esp32/cpu_map.h b/Grbl_Esp32/cpu_map.h index 3a188f60..7cc4fefe 100644 --- a/Grbl_Esp32/cpu_map.h +++ b/Grbl_Esp32/cpu_map.h @@ -585,19 +585,20 @@ #endif #define USE_GANGED_AXES // allow two motors on an axis + #define USE_RMT_STEPS #define X_STEP_PIN GPIO_NUM_12 - #define X_STEP_B_PIN GPIO_NUM_22 // ganged motor + #define X2_STEP_PIN GPIO_NUM_22 // ganged motor #define X_AXIS_SQUARING #define Y_STEP_PIN GPIO_NUM_14 - #define Y_STEP_B_PIN GPIO_NUM_21 // ganged motor + #define Y2_STEP_PIN GPIO_NUM_21 // ganged motor #define Y_AXIS_SQUARING #define Z_STEP_PIN GPIO_NUM_27 #define X_DIRECTION_PIN GPIO_NUM_26 - #define Y_DIRECTION_PIN GPIO_NUM_25 + #define Y_DIRECTION_PIN GPIO_NUM_25 #define Z_DIRECTION_PIN GPIO_NUM_33 // OK to comment out to use pin for other features @@ -736,14 +737,14 @@ #define X_DIRECTION_PIN GPIO_NUM_33 // use Z labeled connector #define Y_STEP_PIN GPIO_NUM_14 - #define Y_STEP_B_PIN GPIO_NUM_21 // ganged motor + #define Y2_STEP_PIN GPIO_NUM_21 // ganged motor #define Y_DIRECTION_PIN GPIO_NUM_25 #define Y_AXIS_SQUARING #define Z_STEP_PIN GPIO_NUM_12 // use X labeled connector - #define Z_STEP_B_PIN GPIO_NUM_22 // use X labeled connector + #define Z2_STEP_PIN GPIO_NUM_22 // use X labeled connector #define Z_DIRECTION_PIN GPIO_NUM_26 // use X labeled connector - #define Z_AXIS_SQUARING + #define Z_AXIS_SQUARING // OK to comment out to use pin for other features #define STEPPERS_DISABLE_PIN GPIO_NUM_13 @@ -1082,6 +1083,52 @@ #endif +#ifdef EXTERNAL_DRIVER_4X + #define CPU_MAP_NAME "External Driver Board V1.1" + + #ifdef N_AXIS + #undef N_AXIS + #endif + #define N_AXIS 4 + + #define USE_RMT_STEPS + #define X_STEP_PIN GPIO_NUM_0 + #define X_DIRECTION_PIN GPIO_NUM_2 + #define Y_STEP_PIN GPIO_NUM_26 + #define Y_DIRECTION_PIN GPIO_NUM_15 + #define Z_STEP_PIN GPIO_NUM_27 + #define Z_DIRECTION_PIN GPIO_NUM_33 + #define A_STEP_PIN GPIO_NUM_14 + #define A_DIRECTION_PIN GPIO_NUM_12 + #define STEPPERS_DISABLE_PIN GPIO_NUM_13 + + + #define SPINDLE_PWM_PIN GPIO_NUM_25 + #define SPINDLE_PWM_CHANNEL 0 + #define SPINDLE_PWM_BIT_PRECISION 8 + #define SPINDLE_ENABLE_PIN GPIO_NUM_22 + + #define MODBUS_TX GPIO_NUM_17 + #define MODBUS_RX GPIO_NUM_4 + #define MODBUS_CTRL GPIO_NUM_16 + + #define X_LIMIT_PIN GPIO_NUM_34 + #define Y_LIMIT_PIN GPIO_NUM_35 + #define Z_LIMIT_PIN GPIO_NUM_36 + + #if (N_AXIS == 3) + #define LIMIT_MASK B0111 + #else + #define A_LIMIT_PIN GPIO_NUM_39 + #define LIMIT_MASK B1111 + #endif + + #define PROBE_PIN GPIO_NUM_32 + #define COOLANT_MIST_PIN GPIO_NUM_21 + + +#endif + #ifdef CPU_MAP_ATARI_1020 #include "atari_1020.h" #endif diff --git a/Grbl_Esp32/grbl.h b/Grbl_Esp32/grbl.h index 1d23575c..519f469f 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 "20200219" +#define GRBL_VERSION_BUILD "20200221" //#include #include diff --git a/Grbl_Esp32/stepper.cpp b/Grbl_Esp32/stepper.cpp index 9c4ba830..29a1f718 100644 --- a/Grbl_Esp32/stepper.cpp +++ b/Grbl_Esp32/stepper.cpp @@ -152,6 +152,21 @@ typedef struct { } st_prep_t; static st_prep_t prep; +// RMT channel numbers. These are assigned dynamically as needed via the CPU MAP +// Only 8 are available (0-7) +// They are Initialized with an invalid number to prevent unitended consequences +uint8_t X_rmt_chan_num = 255; +uint8_t X2_rmt_chan_num = 255; // Ganged axes have the "2" +uint8_t Y_rmt_chan_num = 255; +uint8_t Y2_rmt_chan_num = 255; +uint8_t Z_rmt_chan_num = 255; +uint8_t Z2_rmt_chan_num = 255; +uint8_t A_rmt_chan_num = 255; +uint8_t A2_rmt_chan_num = 255; +uint8_t B_rmt_chan_num = 255; +uint8_t B2_rmt_chan_num = 255; +uint8_t C_rmt_chan_num = 255; +uint8_t C2_rmt_chan_num = 255; /* "The Stepper Driver Interrupt" - This timer interrupt is the workhorse of Grbl. Grbl employs the venerable Bresenham line algorithm to manage and exactly synchronize multi-axis moves. @@ -458,22 +473,22 @@ void stepper_init() #ifdef X_STEP_PIN pinMode(X_STEP_PIN, OUTPUT); #endif - #ifdef X_STEP_B_PIN // ganged motor - pinMode(X_STEP_B_PIN, OUTPUT); + #ifdef X2_STEP_PIN // ganged motor + pinMode(X2_STEP_PIN, OUTPUT); #endif #ifdef Y_STEP_PIN pinMode(Y_STEP_PIN, OUTPUT); #endif - #ifdef Y_STEP_B_PIN - pinMode(Y_STEP_B_PIN, OUTPUT); + #ifdef Y2_STEP_PIN + pinMode(Y2_STEP_PIN, OUTPUT); #endif #ifdef Z_STEP_PIN pinMode(Z_STEP_PIN, OUTPUT); #endif - #ifdef Z_STEP_B_PIN - pinMode(Z_STEP_B_PIN, OUTPUT); + #ifdef Z2_STEP_PIN + pinMode(Z2_STEP_PIN, OUTPUT); #endif #ifdef A_STEP_PIN @@ -536,8 +551,6 @@ void stepper_init() timer_set_counter_value(STEP_TIMER_GROUP, STEP_TIMER_INDEX, 0x00000000ULL); timer_enable_intr(STEP_TIMER_GROUP, STEP_TIMER_INDEX); timer_isr_register(STEP_TIMER_GROUP, STEP_TIMER_INDEX, onStepperDriverTimer, NULL, 0, NULL); - - } #ifdef USE_RMT_STEPS @@ -567,8 +580,9 @@ void initRMT() rmtItem[1].duration1 = 0; #ifdef X_STEP_PIN - rmt_set_source_clk( (rmt_channel_t)X_RMT_CHANNEL, RMT_BASECLK_APB); - rmtConfig.channel = (rmt_channel_t)X_RMT_CHANNEL; + X_rmt_chan_num = sys_get_next_RMT_chan_num(); + rmt_set_source_clk( (rmt_channel_t)X_rmt_chan_num, RMT_BASECLK_APB); + rmtConfig.channel = (rmt_channel_t)X_rmt_chan_num; rmtConfig.tx_config.idle_level = bit_istrue(settings.step_invert_mask, X_AXIS) ? RMT_IDLE_LEVEL_HIGH : RMT_IDLE_LEVEL_LOW; rmtConfig.gpio_num = X_STEP_PIN; rmtItem[0].level0 = rmtConfig.tx_config.idle_level; @@ -577,11 +591,12 @@ void initRMT() rmt_fill_tx_items(rmtConfig.channel, &rmtItem[0], rmtConfig.mem_block_num, 0); #endif -#ifdef X_STEP_B_PIN - rmt_set_source_clk( (rmt_channel_t)X_B_RMT_CHANNEL, RMT_BASECLK_APB); - rmtConfig.channel = (rmt_channel_t)X_B_RMT_CHANNEL; +#ifdef X2_STEP_PIN + X2_rmt_chan_num = sys_get_next_RMT_chan_num(); + rmt_set_source_clk( (rmt_channel_t)X2_rmt_chan_num, RMT_BASECLK_APB); + rmtConfig.channel = (rmt_channel_t)X2_rmt_chan_num; rmtConfig.tx_config.idle_level = bit_istrue(settings.step_invert_mask, X_AXIS) ? RMT_IDLE_LEVEL_HIGH : RMT_IDLE_LEVEL_LOW; - rmtConfig.gpio_num = X_STEP_B_PIN; + rmtConfig.gpio_num = X2_STEP_PIN; rmtItem[0].level0 = rmtConfig.tx_config.idle_level; rmtItem[0].level1 = !rmtConfig.tx_config.idle_level; rmt_config(&rmtConfig); @@ -589,8 +604,9 @@ void initRMT() #endif #ifdef Y_STEP_PIN - rmt_set_source_clk( (rmt_channel_t)Y_RMT_CHANNEL, RMT_BASECLK_APB); - rmtConfig.channel = (rmt_channel_t)Y_RMT_CHANNEL; + Y_rmt_chan_num = sys_get_next_RMT_chan_num(); + rmt_set_source_clk( (rmt_channel_t)Y_rmt_chan_num, RMT_BASECLK_APB); + rmtConfig.channel = (rmt_channel_t)Y_rmt_chan_num; rmtConfig.tx_config.idle_level = bit_istrue(settings.step_invert_mask, Y_AXIS) ? RMT_IDLE_LEVEL_HIGH : RMT_IDLE_LEVEL_LOW; rmtConfig.gpio_num = Y_STEP_PIN; rmtItem[0].level0 = rmtConfig.tx_config.idle_level; @@ -599,11 +615,12 @@ void initRMT() rmt_fill_tx_items(rmtConfig.channel, &rmtItem[0], rmtConfig.mem_block_num, 0); #endif -#ifdef Y_STEP_B_PIN - rmt_set_source_clk( (rmt_channel_t)Y_B_RMT_CHANNEL, RMT_BASECLK_APB); - rmtConfig.channel = (rmt_channel_t)Y_B_RMT_CHANNEL; +#ifdef Y2_STEP_PIN + Y2_rmt_chan_num = sys_get_next_RMT_chan_num(); + rmt_set_source_clk( (rmt_channel_t)Y2_rmt_chan_num, RMT_BASECLK_APB); + rmtConfig.channel = (rmt_channel_t)Y2_rmt_chan_num; rmtConfig.tx_config.idle_level = bit_istrue(settings.step_invert_mask, Y_AXIS) ? RMT_IDLE_LEVEL_HIGH : RMT_IDLE_LEVEL_LOW; - rmtConfig.gpio_num = Y_STEP_B_PIN; + rmtConfig.gpio_num = Y2_STEP_PIN; rmtItem[0].level0 = rmtConfig.tx_config.idle_level; rmtItem[0].level1 = !rmtConfig.tx_config.idle_level; rmt_config(&rmtConfig); @@ -611,8 +628,9 @@ void initRMT() #endif #ifdef Z_STEP_PIN - rmt_set_source_clk( (rmt_channel_t)Z_RMT_CHANNEL, RMT_BASECLK_APB); - rmtConfig.channel = (rmt_channel_t)Z_RMT_CHANNEL; + Z_rmt_chan_num = sys_get_next_RMT_chan_num(); + rmt_set_source_clk( (rmt_channel_t)Z_rmt_chan_num, RMT_BASECLK_APB); + rmtConfig.channel = (rmt_channel_t)Z_rmt_chan_num; rmtConfig.tx_config.idle_level = bit_istrue(settings.step_invert_mask, Z_AXIS) ? RMT_IDLE_LEVEL_HIGH : RMT_IDLE_LEVEL_LOW; rmtConfig.gpio_num = Z_STEP_PIN; rmtItem[0].level0 = rmtConfig.tx_config.idle_level; @@ -622,8 +640,9 @@ void initRMT() #endif #ifdef A_STEP_PIN - rmt_set_source_clk( (rmt_channel_t)A_RMT_CHANNEL, RMT_BASECLK_APB); - rmtConfig.channel = (rmt_channel_t)A_RMT_CHANNEL; + A_rmt_chan_num = sys_get_next_RMT_chan_num(); + rmt_set_source_clk( (rmt_channel_t)A_rmt_chan_num, RMT_BASECLK_APB); + rmtConfig.channel = (rmt_channel_t)A_rmt_chan_num; rmtConfig.tx_config.idle_level = bit_istrue(settings.step_invert_mask, A_AXIS) ? RMT_IDLE_LEVEL_HIGH : RMT_IDLE_LEVEL_LOW; rmtConfig.gpio_num = A_STEP_PIN; // TODO rmtItem[0].level0 = rmtConfig.tx_config.idle_level; @@ -633,8 +652,9 @@ void initRMT() #endif #ifdef B_STEP_PIN - rmt_set_source_clk( (rmt_channel_t)B_RMT_CHANNEL, RMT_BASECLK_APB); - rmtConfig.channel = (rmt_channel_t)B_RMT_CHANNEL; + B_rmt_chan_num = sys_get_next_RMT_chan_num(); + rmt_set_source_clk( (rmt_channel_t)B_rmt_chan_num, RMT_BASECLK_APB); + rmtConfig.channel = (rmt_channel_t)B_rmt_chan_num; rmtConfig.tx_config.idle_level = bit_istrue(settings.step_invert_mask, B_AXIS) ? RMT_IDLE_LEVEL_HIGH : RMT_IDLE_LEVEL_LOW; rmtConfig.gpio_num = B_STEP_PIN; // TODO rmtItem[0].level0 = rmtConfig.tx_config.idle_level; @@ -644,8 +664,9 @@ void initRMT() #endif #ifdef C_STEP_PIN - rmt_set_source_clk( (rmt_channel_t)C_RMT_CHANNEL, RMT_BASECLK_APB); - rmtConfig.channel = (rmt_channel_t)C_RMT_CHANNEL; + C_rmt_chan_num = sys_get_next_RMT_chan_num(); + rmt_set_source_clk( (rmt_channel_t)C_rmt_chan_num, RMT_BASECLK_APB); + rmtConfig.channel = (rmt_channel_t)C_rmt_chan_num; rmtConfig.tx_config.idle_level = bit_istrue(settings.step_invert_mask, C_AXIS) ? RMT_IDLE_LEVEL_HIGH : RMT_IDLE_LEVEL_LOW; rmtConfig.gpio_num = C_STEP_PIN; // TODO rmtItem[0].level0 = rmtConfig.tx_config.idle_level; @@ -725,97 +746,117 @@ void set_direction_pins_on(uint8_t onMask) #ifdef X_DIRECTION_PIN digitalWrite(X_DIRECTION_PIN, (onMask & (1< Date: Sat, 22 Feb 2020 13:41:47 -0600 Subject: [PATCH 2/4] Added setup of ganged steper direction pins --- Grbl_Esp32/config.h | 2 +- Grbl_Esp32/cpu_map.h | 11 +++++++++-- Grbl_Esp32/grbl.h | 2 +- Grbl_Esp32/grbl_trinamic.cpp | 2 -- Grbl_Esp32/stepper.cpp | 28 ++++++++++++++++++++++++---- 5 files changed, 35 insertions(+), 10 deletions(-) diff --git a/Grbl_Esp32/config.h b/Grbl_Esp32/config.h index b0057328..78b47bd9 100644 --- a/Grbl_Esp32/config.h +++ b/Grbl_Esp32/config.h @@ -44,7 +44,7 @@ Some features should not be changed. See notes below. // The CPU map is the main definition of the machine/controller you want to use // These are typically found in the cpu_map.h file. // See Github repo wiki for more details -#define CPU_MAP_ESP32 // these are defined in cpu_map.h +#define CPU_MAP_TEST_DRIVE // these are defined in cpu_map.h // Number of axes defined (steppers, servos, etc) (valid range: 3 to 6) // Even if your machine only uses less than the minimum of 3, you should select 3 diff --git a/Grbl_Esp32/cpu_map.h b/Grbl_Esp32/cpu_map.h index 7cc4fefe..255c83d8 100644 --- a/Grbl_Esp32/cpu_map.h +++ b/Grbl_Esp32/cpu_map.h @@ -1012,20 +1012,27 @@ #ifdef N_AXIS #undef N_AXIS #endif - #define N_AXIS 4 // can be 3 or 4. (if 3 install bypass jumper next to the A driver) + #define N_AXIS 3 // can be 3 or 4. (if 3 install bypass jumper next to the A driver) #define USE_TRINAMIC #define TRINAMIC_DAISY_CHAIN // Use SPI enable instead of the enable pin // The hardware enable pin is tied to ground - #define USE_TRINAMIC_ENABLE + #define USE_TRINAMIC_ENABLE + + // The ESP32 RMT feature will generate the step pulse timing #define USE_RMT_STEPS + // allow two motors on an axis + #define USE_GANGED_AXES + #define X_DRIVER_TMC2130 // Which Driver Type? #define X_RSENSE 0.11f // .11 Ohm...typical of 2130 type 0.075 typical for TMC5160 #define X_STEP_PIN GPIO_NUM_12 #define X_DIRECTION_PIN GPIO_NUM_14 + #define X2_STEP_PIN GPIO_NUM_33 + #define X2_DIRECTION_PIN GPIO_NUM_32 #define X_TRINAMIC // using SPI control #define X_CS_PIN GPIO_NUM_17 // Daisy Chain, all share same CS pin diff --git a/Grbl_Esp32/grbl.h b/Grbl_Esp32/grbl.h index 519f469f..7aaabba3 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 "20200221" +#define GRBL_VERSION_BUILD "20200222" //#include #include diff --git a/Grbl_Esp32/grbl_trinamic.cpp b/Grbl_Esp32/grbl_trinamic.cpp index 285cb88e..c9fde27f 100644 --- a/Grbl_Esp32/grbl_trinamic.cpp +++ b/Grbl_Esp32/grbl_trinamic.cpp @@ -271,8 +271,6 @@ void trinamic_stepper_enable(bool enable) { previous_state = enable; - grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_INFO, "Trinamic Enable: %d", enable); - if (enable) toff = TRINAMIC_DEFAULT_TOFF; else diff --git a/Grbl_Esp32/stepper.cpp b/Grbl_Esp32/stepper.cpp index 29a1f718..0093eb99 100644 --- a/Grbl_Esp32/stepper.cpp +++ b/Grbl_Esp32/stepper.cpp @@ -509,24 +509,44 @@ void stepper_init() #ifdef X_DIRECTION_PIN pinMode(X_DIRECTION_PIN, OUTPUT); #endif + #ifdef X2_DIRECTION_PIN + pinMode(X2_DIRECTION_PIN, OUTPUT); + #endif + #ifdef Y_DIRECTION_PIN pinMode(Y_DIRECTION_PIN, OUTPUT); #endif + #ifdef Y2_DIRECTION_PIN + pinMode(Y2_DIRECTION_PIN, OUTPUT); + #endif + #ifdef Z_DIRECTION_PIN pinMode(Z_DIRECTION_PIN, OUTPUT); #endif + #ifdef Z2_DIRECTION_PIN + pinMode(Z2_DIRECTION_PIN, OUTPUT); + #endif + #ifdef A_DIRECTION_PIN pinMode(A_DIRECTION_PIN, OUTPUT); #endif + #ifdef A2_DIRECTION_PIN + pinMode(A2_DIRECTION_PIN, OUTPUT); + #endif + #ifdef B_DIRECTION_PIN pinMode(B_DIRECTION_PIN, OUTPUT); #endif + #ifdef B2_DIRECTION_PIN + pinMode(B2_DIRECTION_PIN, OUTPUT); + #endif + #ifdef C_DIRECTION_PIN pinMode(C_DIRECTION_PIN, OUTPUT); #endif - - - + #ifdef C2_DIRECTION_PIN + pinMode(C2_DIRECTION_PIN, OUTPUT); + #endif // setup stepper timer interrupt @@ -747,7 +767,7 @@ void set_direction_pins_on(uint8_t onMask) digitalWrite(X_DIRECTION_PIN, (onMask & (1< Date: Tue, 25 Feb 2020 10:33:48 +0100 Subject: [PATCH 3/4] Add inline help for [ESPXXX] command --- Grbl_Esp32/commands.cpp | 52 +++++++++++++++++++++++++++++++++++++-- Grbl_Esp32/grbl.h | 2 +- Grbl_Esp32/web_server.cpp | 4 +-- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/Grbl_Esp32/commands.cpp b/Grbl_Esp32/commands.cpp index 45174d4b..9f669d46 100644 --- a/Grbl_Esp32/commands.cpp +++ b/Grbl_Esp32/commands.cpp @@ -85,6 +85,53 @@ bool COMMANDS::execute_internal_command (int cmd, String cmd_params, level_authe //manage parameters String parameter; switch (cmd) { + //help + //[ESP] or [ESP0] + case 0: + { + if (espresponse){ + espresponse->println ("[List of ESP3D commands]"); + espresponse->println ("[ESP] - display this help"); + espresponse->println ("[ESP100](SSID) - display/set STA SSID"); + espresponse->println ("[ESP101](Password) - set STA password"); + espresponse->println ("[ESP102](Mode) - display/set STA IP mode (DHCP/STATIC)"); + espresponse->println ("[ESP103](IP=xxxx MSK=xxxx GW=xxxx) - display/set STA IP/Mask/GW"); + espresponse->println ("[ESP105](SSID) - display/set AP SSID"); + espresponse->println ("[ESP106](Password) - set AP password"); + espresponse->println ("[ESP107](IP) - display/set AP IP"); + espresponse->println ("[ESP108](Chanel) - display/set AP chanel"); + espresponse->println ("[ESP110](State) - display/set radio state which can be STA, AP, BT, OFF"); + espresponse->println ("[ESP111]display current IP"); + espresponse->println ("[ESP112](Hostname) - display/set Hostname"); + espresponse->println ("[ESP115](State) - display/set immediate radio state which can be ON, OFF"); + espresponse->println ("[ESP120](State) - display/set HTTP state which can be ON, OFF"); + espresponse->println ("[ESP121](Port) - display/set HTTP port "); + espresponse->println ("[ESP130](State) - display/set Telnet state which can be ON, OFF"); + espresponse->println ("[ESP131](Port) - display/set Telnet port "); + espresponse->println ("[ESP140](Bluetooth name) - display/set Bluetooth name"); + espresponse->println ("[ESP200] - display SD Card Status"); + espresponse->println ("[ESP210] - display SD Card content"); + espresponse->println ("[ESP215](file/dir name) - delete SD Card file / directory"); + espresponse->println ("[ESP220](file name) - run file from SD"); + espresponse->println ("[ESP400] - display ESP3D settings in JSON"); + espresponse->println ("[ESP401]P=(position) T=(type) V=(value) - Set specific setting"); + espresponse->println ("[ESP410] - display available AP list (limited to 30) in JSON"); + espresponse->println ("[ESP420] - display ESP3D current status"); + espresponse->println ("[ESP444]RESTART - Restart ESP"); + #ifdef ENABLE_AUTHENTICATION + espresponse->println ("[ESP555](Password) - set user password"); + #endif //ENABLE_AUTHENTICATION + #ifdef ENABLE_NOTIFICATIONS + espresponse->println ("[ESP600](message) - send message"); + espresponse->println ("[ESP610]type=(NONE/PUSHOVER/EMAIL/LINE) T1=(token1) T2=(token2) TS=(Settings) - display/set Notification settings"); + #endif //ENABLE_NOTIFICATIONS + espresponse->println ("[ESP700](file name) - run macro file from ESP Filesystem"); + espresponse->println ("[ESP710]FORMAT - Format ESP Filesystem"); + espresponse->println ("[ESP720]display total size and used size of ESP Filesystem"); + espresponse->println ("[ESP800] - display FW Informations"); + } + } + break; #ifdef ENABLE_WIFI //STA SSID //[ESP100][pwd=] @@ -1757,6 +1804,7 @@ bool COMMANDS::execute_internal_command (int cmd, String cmd_params, level_authe } #endif #ifdef ENABLE_NOTIFICATIONS + //[ESP600] case 600: { //Send message #ifdef ENABLE_AUTHENTICATION @@ -1926,7 +1974,7 @@ bool COMMANDS::execute_internal_command (int cmd, String cmd_params, level_authe cmd_part2 = currentline.substring (ESPpos2 + 1); } //if command is a valid number then execute command - if(cmd_part1.toInt()!=0) { + if(cmd_part1.toInt()>=0) { if (!execute_internal_command(cmd_part1.toInt(),cmd_part2, auth_type, espresponse)) response = false; } //if not is not a valid [ESPXXX] command ignore it @@ -2188,7 +2236,7 @@ bool COMMANDS::check_command (const char * line, int * cmd, String & cmd_params) cmd_part2 = buffer.substring (ESPpos2 + 1); } //if command is a valid number then execute command - if (cmd_part1.toInt() != 0) { + if (cmd_part1.toInt() >= 0) { *cmd = cmd_part1.toInt(); cmd_params = cmd_part2; result = true; diff --git a/Grbl_Esp32/grbl.h b/Grbl_Esp32/grbl.h index 7aaabba3..37e6bbcd 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 "20200222" +#define GRBL_VERSION_BUILD "20200225" //#include #include diff --git a/Grbl_Esp32/web_server.cpp b/Grbl_Esp32/web_server.cpp index 6f636d10..c557d789 100644 --- a/Grbl_Esp32/web_server.cpp +++ b/Grbl_Esp32/web_server.cpp @@ -512,7 +512,7 @@ void Web_Server::handle_web_command () cmd_part2 = cmd.substring (ESPpos2 + 1); } //if command is a valid number then execute command - if (cmd_part1.toInt() != 0) { + if (cmd_part1.toInt() >= 0) { ESPResponseStream espresponse(_webserver); //commmand is web only COMMANDS::execute_internal_command (cmd_part1.toInt(), cmd_part2, auth_level, &espresponse); @@ -589,7 +589,7 @@ void Web_Server::handle_web_command_silent () cmd_part2 = cmd.substring (ESPpos2 + 1); } //if command is a valid number then execute command - if (cmd_part1.toInt() != 0) { + if (cmd_part1.toInt() >= 0) { //commmand is web only if(COMMANDS::execute_internal_command (cmd_part1.toInt(), cmd_part2, auth_level, NULL)) _webserver->send (200, "text/plain", "ok"); else _webserver->send (200, "text/plain", "error"); From 2649e0605426a1a637779c5489248a69a63f7c5b Mon Sep 17 00:00:00 2001 From: Luc <8822552+luc-github@users.noreply.github.com> Date: Tue, 25 Feb 2020 14:23:59 +0100 Subject: [PATCH 4/4] allows to set STA mode by default --- Grbl_Esp32/config.h | 10 +++++++++- Grbl_Esp32/wificonfig.h | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Grbl_Esp32/config.h b/Grbl_Esp32/config.h index 78b47bd9..18a8f37a 100644 --- a/Grbl_Esp32/config.h +++ b/Grbl_Esp32/config.h @@ -56,7 +56,11 @@ Some features should not be changed. See notes below. // Serial baud rate // OK to change, but the ESP32 boot text is 115200, so you will not see that is your // serial monitor, sender, etc uses a different value than 115200 -#define BAUD_RATE 115200 +#define BAUD_RATE 115200 + +//Connect to your local AP with these credentials +//#define CONNECT_TO_SSID "your SSID" +//#define SSID_PASSWORD "your SSID password" #define ENABLE_BLUETOOTH // enable bluetooth @@ -101,7 +105,11 @@ Some features should not be changed. See notes below. //Default mode #ifdef ENABLE_WIFI +#ifdef CONNECT_TO_SSID +#define DEFAULT_RADIO_MODE ESP_WIFI_STA +#else #define DEFAULT_RADIO_MODE ESP_WIFI_AP +#endif //CONNECT_TO_SSID #else #undef ENABLE_NOTIFICATIONS #ifdef ENABLE_BLUETOOTH diff --git a/Grbl_Esp32/wificonfig.h b/Grbl_Esp32/wificonfig.h index a4e82f7c..58437673 100644 --- a/Grbl_Esp32/wificonfig.h +++ b/Grbl_Esp32/wificonfig.h @@ -53,8 +53,13 @@ //defaults values #define DEFAULT_HOSTNAME "grblesp" +#ifdef CONNECT_TO_SSID +#define DEFAULT_STA_SSID CONNECT_TO_SSID +#define DEFAULT_STA_PWD SSID_PASSWORD +#else //!CONNECT_TO_SSID #define DEFAULT_STA_SSID "GRBL_ESP" #define DEFAULT_STA_PWD "12345678" +#endif //CONNECT_TO_SSID #define DEFAULT_STA_IP "0.0.0.0" #define DEFAULT_STA_GW "0.0.0.0" #define DEFAULT_STA_MK "0.0.0.0"