diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index b3bb3c54c2..abd9cdd6fb 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -36,6 +36,10 @@ GcodeSuite gcode; #include "queue.h" #include "../module/motion.h" +#if ENABLED(MKS_WIFI) +#include "../module/mks_wifi/mks_wifi_gcodes.h" +#endif + #if ENABLED(PRINTCOUNTER) #include "../module/printcounter.h" #endif @@ -852,8 +856,8 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { #endif #if ENABLED(MKS_WIFI) - case 991: M105(); return; - + case 991: mks_m991(); return; + case 997: mks_m997(); return; #endif #if ENABLED(PLATFORM_M997_SUPPORT) diff --git a/Marlin/src/gcode/temp/M105.cpp b/Marlin/src/gcode/temp/M105.cpp index d763b79760..9622ada86f 100644 --- a/Marlin/src/gcode/temp/M105.cpp +++ b/Marlin/src/gcode/temp/M105.cpp @@ -31,8 +31,10 @@ void GcodeSuite::M105() { const int8_t target_extruder = get_target_extruder_from_command(); if (target_extruder < 0) return; - #if DISABLED(MKS_WIFI) + SERIAL_ECHOPGM(STR_OK); + #if ENABLED(MKS_WIFI) + SERIAL_EOL(); #endif #if HAS_TEMP_SENSOR diff --git a/Marlin/src/module/mks_wifi/mks_wifi_gcodes.cpp b/Marlin/src/module/mks_wifi/mks_wifi_gcodes.cpp new file mode 100644 index 0000000000..e6633653c1 --- /dev/null +++ b/Marlin/src/module/mks_wifi/mks_wifi_gcodes.cpp @@ -0,0 +1,40 @@ +#include "mks_wifi_gcodes.h" + +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 int8_t target_extruder = GcodeSuite::get_target_extruder_from_command(); + if (target_extruder < 0) return; + + #if HAS_TEMP_SENSOR + + thermalManager.print_heater_states(target_extruder + #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) + , parser.boolval('R') + #endif + ); + + SERIAL_EOL(); + + #else + + SERIAL_ECHOLNPGM(" T:0"); // Some hosts send M105 to test the serial connection + + #endif +} + + +void mks_m997(void){ + + if(CardReader::isPrinting()){ + mks_wifi_out_add((uint8_t *)m997_printing,strlen(m997_printing)); + }else if(CardReader::isPaused()){ + mks_wifi_out_add((uint8_t *)m997_pause,strlen(m997_pause)); + }else{ + mks_wifi_out_add((uint8_t *)m997_idle,strlen(m997_idle)); + } + +} \ No newline at end of file diff --git a/Marlin/src/module/mks_wifi/mks_wifi_gcodes.h b/Marlin/src/module/mks_wifi/mks_wifi_gcodes.h new file mode 100644 index 0000000000..c4ec14fb5b --- /dev/null +++ b/Marlin/src/module/mks_wifi/mks_wifi_gcodes.h @@ -0,0 +1,12 @@ +#ifndef MKS_WIFI_GCODES_H +#define MKS_WIFI_GCODES_H + +#include "../../gcode/gcode.h" +#include "../temperature.h" +#include "../../sd/cardreader.h" +#include "mks_wifi.h" + +void mks_m991(void); +void mks_m997(void); + +#endif \ No newline at end of file