From 97e8aa45177c953a7e8137e926c77a9a7813fde0 Mon Sep 17 00:00:00 2001 From: Sergey Date: Wed, 1 Apr 2020 20:16:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=8B=D0=B2=D0=BE=D0=B4=20=D1=81=D0=BF?= =?UTF-8?q?=D0=B8=D1=81=D0=BA=D0=B0=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2?= =?UTF-8?q?=20=D0=B2=20=D0=BA=D1=83=D1=80=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 2 +- Marlin/Configuration_adv.h | 2 +- Marlin/src/gcode/gcode.cpp | 38 ++++++++++- Marlin/src/gcode/temp/M105.cpp | 5 -- Marlin/src/module/mks_wifi/mks_wifi.cpp | 4 ++ .../src/module/mks_wifi/mks_wifi_gcodes.cpp | 63 +++++++++++++++---- Marlin/src/module/mks_wifi/mks_wifi_gcodes.h | 3 + Marlin/src/module/temperature.cpp | 6 +- Marlin/src/sd/cardreader.cpp | 15 ++--- 9 files changed, 102 insertions(+), 36 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 5acdfe53a3..5d86ae092e 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1065,7 +1065,7 @@ // @section extruder // For direct drive extruder v9 set to true, for geared extruder set to false. -#define INVERT_E0_DIR true +#define INVERT_E0_DIR false //for std driver #define INVERT_E1_DIR false #define INVERT_E2_DIR false #define INVERT_E3_DIR false diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index e1434c798d..493489fc25 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2750,7 +2750,7 @@ /** * Include capabilities in M115 output */ -//#define EXTENDED_CAPABILITIES_REPORT +#define EXTENDED_CAPABILITIES_REPORT /** * Expected Printer Check diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 108b581bc2..acd4518058 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -408,7 +408,18 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 24: M24(); break; // M24: Start SD print case 25: M25(); break; // M25: Pause SD print case 26: M26(); break; // M26: Set SD index - case 27: M27(); break; // M27: Get SD status + case 27: + #if ENABLED(MKS_WIFI) + if(!serial_port_index){ + M27(); + }else{ + mks_m27(); + return; + } + #else + M27(); + #endif + break; // M27: Get SD status case 28: M28(); break; // M28: Start SD write case 29: M29(); break; // M29: Stop SD write case 30: M30(); break; // M30 Delete File @@ -457,7 +468,17 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 109: M109(); break; // M109: Wait for hotend temperature to reach target #endif - case 105: M105(); return; // M105: Report Temperatures (and say "ok") + case 105: + #if ENABLED(MKS_WIFI) + if(serial_port_index){ + mks_m105(); + }else{ + M105(); + } + #else + M105(); + #endif + return; // M105: Report Temperatures (and say "ok") #if FAN_COUNT > 0 case 106: M106(); break; // M106: Fan On @@ -529,7 +550,18 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 85: M85(); break; // M85: Set inactivity stepper shutdown timeout case 92: M92(); break; // M92: Set the steps-per-unit for one or more axes case 114: M114(); break; // M114: Report current position - case 115: M115(); break; // M115: Report capabilities + case 115: + #if ENABLED(MKS_WIFI) + if(serial_port_index){ + mks_m115(); + return; + }else{ + M115(); + } + #else + M115(); + #endif + break; // M115: Report capabilities case 117: M117(); break; // M117: Set LCD message text, if possible case 118: M118(); break; // M118: Display a message in the host console case 119: M119(); break; // M119: Report endstop states diff --git a/Marlin/src/gcode/temp/M105.cpp b/Marlin/src/gcode/temp/M105.cpp index 21990d54d0..e1554cd73d 100644 --- a/Marlin/src/gcode/temp/M105.cpp +++ b/Marlin/src/gcode/temp/M105.cpp @@ -33,11 +33,6 @@ void GcodeSuite::M105() { SERIAL_ECHOPGM(STR_OK); - #if ENABLED(MKS_WIFI) - if ( serial_port_index){ - SERIAL_EOL(); - }; - #endif #if HAS_TEMP_SENSOR diff --git a/Marlin/src/module/mks_wifi/mks_wifi.cpp b/Marlin/src/module/mks_wifi/mks_wifi.cpp index 68c9c52f29..b80c087da0 100644 --- a/Marlin/src/module/mks_wifi/mks_wifi.cpp +++ b/Marlin/src/module/mks_wifi/mks_wifi.cpp @@ -1,5 +1,7 @@ #include "mks_wifi.h" + + uint8_t mks_in_buffer[ESP_PACKET_DATA_MAX_SIZE]; uint8_t mks_out_buffer[ESP_PACKET_DATA_MAX_SIZE]; uint32_t line_index=0; @@ -77,6 +79,7 @@ void mks_wifi_out_add(uint8_t *data, uint32_t size){ esp_frame.data=mks_out_buffer; packet_size=mks_wifi_build_packet(esp_packet,&esp_frame); + //DEBUG("Send %s",mks_out_buffer); //выпихнуть в uart mks_wifi_send(esp_packet, packet_size); //очистить буфер @@ -254,6 +257,7 @@ uint16_t mks_wifi_build_packet(uint8_t *packet, ESP_PROTOC_FRAME *esp_frame){ void mks_wifi_send(uint8_t *packet, uint16_t size){ + safe_delay(10); for( uint32_t i=0; i < (uint32_t)(size+1); i++){ while(MYSERIAL1.availableForWrite()==0){ safe_delay(10); diff --git a/Marlin/src/module/mks_wifi/mks_wifi_gcodes.cpp b/Marlin/src/module/mks_wifi/mks_wifi_gcodes.cpp index e6633653c1..8f016220e5 100644 --- a/Marlin/src/module/mks_wifi/mks_wifi_gcodes.cpp +++ b/Marlin/src/module/mks_wifi/mks_wifi_gcodes.cpp @@ -1,33 +1,50 @@ #include "mks_wifi_gcodes.h" +const uint8_t pak[5]={0xA5,0x07,0x00,0x00,0xFC}; + const char m997_idle[]="M997 IDLE\n"; const char m997_printing[]="M997 PRINTING\n"; const char m997_pause[]="M997 PAUSE\n"; -void mks_m991(void){ +const char m115_firmware[]="FIRMWARE_NAME:TFT24\n"; +void mks_m991(void){ + char tempBuf[100]; const int8_t target_extruder = GcodeSuite::get_target_extruder_from_command(); if (target_extruder < 0) return; - #if HAS_TEMP_SENSOR + memset(tempBuf,0,100); + + sprintf((char *)tempBuf,"T:%d /%d B:%d /%d T0:%d /%d T1:0 /0 @:0 B@:0\n", + (int)Temperature::degHotend(target_extruder),Temperature::degTargetHotend(target_extruder), + (int)Temperature::degBed(),Temperature::degTargetBed(), + (int)Temperature::degHotend(target_extruder),Temperature::degTargetHotend(target_extruder)); + + mks_wifi_out_add((uint8_t *)tempBuf,strlen(tempBuf)); +} - thermalManager.print_heater_states(target_extruder - #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - , parser.boolval('R') - #endif - ); +void mks_m105(void){ + char tempBuf[100]; + const int8_t target_extruder = GcodeSuite::get_target_extruder_from_command(); + if (target_extruder < 0) return; - SERIAL_EOL(); + memset(tempBuf,0,100); - #else + SERIAL_ECHOPGM(STR_OK); + SERIAL_EOL(); - SERIAL_ECHOLNPGM(" T:0"); // Some hosts send M105 to test the serial connection + sprintf((char *)tempBuf,"T:%.1f /%.1f B:%.1f /%.1f T0:%.1f /%.1f T1:0.0 /0.0 @:0 B@:0\n", + Temperature::degHotend(target_extruder),(float)Temperature::degTargetHotend(target_extruder), + Temperature::degBed(),(float)Temperature::degTargetBed(), + Temperature::degHotend(target_extruder),(float)Temperature::degTargetHotend(target_extruder)); - #endif + mks_wifi_out_add((uint8_t *)tempBuf,strlen(tempBuf)); } + void mks_m997(void){ + static uint8_t call_cnt=0; if(CardReader::isPrinting()){ mks_wifi_out_add((uint8_t *)m997_printing,strlen(m997_printing)); @@ -37,4 +54,26 @@ void mks_m997(void){ mks_wifi_out_add((uint8_t *)m997_idle,strlen(m997_idle)); } -} \ No newline at end of file + if(call_cnt == 0){ + call_cnt=1; + mks_wifi_send((uint8_t *)pak, 4); //Внутри +1 + } + +} + + +void mks_m115(void){ + SERIAL_ECHOPGM(STR_OK); + SERIAL_EOL(); + mks_wifi_out_add((uint8_t *)m115_firmware,strlen(m115_firmware)); +} + +void mks_m27(void){ + + if (CardReader::isPrinting()) { + SERIAL_ECHOPGM(STR_SD_PRINTING_BYTE); + SERIAL_ECHO(0); + SERIAL_CHAR('/'); + SERIAL_ECHOLN(100); + } +} diff --git a/Marlin/src/module/mks_wifi/mks_wifi_gcodes.h b/Marlin/src/module/mks_wifi/mks_wifi_gcodes.h index c4ec14fb5b..60200b1748 100644 --- a/Marlin/src/module/mks_wifi/mks_wifi_gcodes.h +++ b/Marlin/src/module/mks_wifi/mks_wifi_gcodes.h @@ -8,5 +8,8 @@ void mks_m991(void); void mks_m997(void); +void mks_m115(void); +void mks_m105(void); +void mks_m27(void); #endif \ No newline at end of file diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index ecce18a7e9..f16a3af046 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -3002,11 +3002,7 @@ void Temperature::tick() { default: k = 'B'; break; #endif } - #if ENABLED(MKS_WIFI) - if (!serial_port_index){ - SERIAL_CHAR(' '); - } - #endif + SERIAL_CHAR(' '); SERIAL_CHAR(k); #if HOTENDS > 1 if (e >= 0) SERIAL_CHAR('0' + e); diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 48dc9892ae..8eb99603c2 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -261,13 +261,16 @@ void CardReader::printListing(SdFile parent, const char * const prepend/*=nullpt if (serial_port_index){ printLongPath(filename); }else{ - SERIAL_ECHO(filename); + SERIAL_ECHOLN(filename); + SERIAL_CHAR(' '); + SERIAL_ECHOLN(p.fileSize); } #else - SERIAL_ECHO(filename); - #endif + SERIAL_ECHO(filename); SERIAL_CHAR(' '); SERIAL_ECHOLN(p.fileSize); + #endif + } } } @@ -349,13 +352,7 @@ void CardReader::ls() { } // while i