Browse Source

m992 and m944 support

FB4S_WIFI
Sergey 3 years ago
parent
commit
739d1fede4
  1. 2
      Marlin/src/gcode/gcode.cpp
  2. 29
      Marlin/src/module/mks_wifi/mks_wifi_gcodes.cpp
  3. 2
      Marlin/src/module/mks_wifi/mks_wifi_gcodes.h
  4. 30
      Marlin/src/sd/cardreader.cpp
  5. 5
      Marlin/src/sd/cardreader.h

2
Marlin/src/gcode/gcode.cpp

@ -1070,6 +1070,8 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
#if ENABLED(MKS_WIFI) #if ENABLED(MKS_WIFI)
case 991: if(port.index == MKS_WIFI_SERIAL_NUM){mks_m991();}; return; case 991: if(port.index == MKS_WIFI_SERIAL_NUM){mks_m991();}; return;
case 992: if(port.index == MKS_WIFI_SERIAL_NUM){mks_m992();}; return;
case 994: if(port.index == MKS_WIFI_SERIAL_NUM){mks_m994();}; return;
#endif #endif
#if ENABLED(MKS_WIFI) #if ENABLED(MKS_WIFI)

29
Marlin/src/module/mks_wifi/mks_wifi_gcodes.cpp

@ -1,5 +1,9 @@
#include "mks_wifi_gcodes.h" #include "mks_wifi_gcodes.h"
#ifdef MKS_WIFI #ifdef MKS_WIFI
#include "../../module/printcounter.h"
#include "../../libs/duration_t.h"
const uint8_t pak[5]={0xA5,0x07,0x00,0x00,0xFC}; const uint8_t pak[5]={0xA5,0x07,0x00,0x00,0xFC};
@ -63,6 +67,31 @@ void mks_m115(void){
mks_wifi_out_add((uint8_t *)m115_firmware,strlen(m115_firmware)); mks_wifi_out_add((uint8_t *)m115_firmware,strlen(m115_firmware));
} }
void mks_m992(void){
char buffer[30];
uint32_t duration_sec = print_job_timer.duration();
uint16_t hours = duration_sec / 3600;
uint16_t minutes = (duration_sec - hours*3600) / 60;
uint16_t seconds = (duration_sec - hours*3600 - minutes*60);
sprintf((char *)buffer, "M992 %02d:%02d:%02d\r\n", hours, minutes, seconds);
mks_wifi_out_add((uint8_t *)buffer,strlen(buffer));
}
void mks_m994(void){
char buffer[150];
char filename[101];
if(CardReader::isPrinting()){
CardReader::GetSelectedFilename(filename);
sprintf((char *)buffer, ("M994 %s;%ld\n"), filename, CardReader::GetSelectedFilesize());
mks_wifi_out_add((uint8_t *)buffer,strlen(buffer));
}
}
void mks_m27(void){ void mks_m27(void){
// if (CardReader::isPrinting()) { // if (CardReader::isPrinting()) {

2
Marlin/src/module/mks_wifi/mks_wifi_gcodes.h

@ -10,6 +10,8 @@
#ifdef MKS_WIFI #ifdef MKS_WIFI
void mks_m991(void); void mks_m991(void);
void mks_m992(void);
void mks_m994(void);
void mks_m997(void); void mks_m997(void);
void mks_m115(void); void mks_m115(void);
void mks_m105(void); void mks_m105(void);

30
Marlin/src/sd/cardreader.cpp

@ -1375,4 +1375,34 @@ void CardReader::fileHasFinished() {
#endif // POWER_LOSS_RECOVERY #endif // POWER_LOSS_RECOVERY
#if ENABLED(MKS_WIFI)
void CardReader::GetSelectedFilename(char *filename) {
if (file.isOpen()) {
char dosFilename[FILENAME_LENGTH];
file.getDosName(dosFilename);
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
selectFileByName(dosFilename);
if (longFilename[0]) {
strncpy(filename,longFilename,100);
}else{
strncpy(filename,dosFilename,100);
}
#else
strncpy(filename,dosFilename,100);
#endif
}
else
SERIAL_ECHOPGM("(no file)");
SERIAL_EOL();
}
uint32_t CardReader::GetSelectedFilesize(void) {
return filesize;
}
#endif
#endif // SDSUPPORT #endif // SDSUPPORT

5
Marlin/src/sd/cardreader.h

@ -109,6 +109,11 @@ public:
CardReader(); CardReader();
#if ENABLED(MKS_WIFI)
static void GetSelectedFilename(char *filename);
static uint32_t GetSelectedFilesize(void);
#endif
static void changeMedia(DiskIODriver *_driver) { driver = _driver; } static void changeMedia(DiskIODriver *_driver) { driver = _driver; }
static SdFile getroot() { return root; } static SdFile getroot() { return root; }

Loading…
Cancel
Save