Explorar el Código

More MKS UI sprintf

Scott Lahteine hace 3 años
padre
commit
4e314ef6d4
Se han modificado 1 ficheros con 21 adiciones y 21 borrados
  1. 21
    21
      Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp

+ 21
- 21
Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp Ver fichero

@@ -478,7 +478,7 @@ char wait_ip_back_flag = 0;
478 478
 
479 479
 typedef struct {
480 480
   int write_index;
481
-  uint8_t saveFileName[30];
481
+  char saveFileName[30];
482 482
   uint8_t fileTransfer;
483 483
   uint32_t fileLen;
484 484
   uint32_t tick_begin;
@@ -593,7 +593,7 @@ uint8_t Explore_Disk(char *path , uint8_t recu_level) {
593 593
 }
594 594
 
595 595
 static void wifi_gcode_exec(uint8_t *cmd_line) {
596
-  int8_t tempBuf[100] = { 0 };
596
+  char tempBuf[100] = { 0 };
597 597
   uint8_t *tmpStr = 0;
598 598
   int  cmd_value;
599 599
   volatile int print_rate;
@@ -631,7 +631,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
631 631
             while (tmpStr[index] == ' ') index++;
632 632
 
633 633
             if (gCfgItems.wifi_type == ESP_WIFI) {
634
-              char *path = (char *)tempBuf;
634
+              char *path = tempBuf;
635 635
 
636 636
               if (strlen((char *)&tmpStr[index]) < 80) {
637 637
                 send_to_wifi((uint8_t *)"Begin file list\r\n", strlen("Begin file list\r\n"));
@@ -828,8 +828,8 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
828 828
           if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)|| (uiCfg.print_state == REPRINTING)) {
829 829
             print_rate = uiCfg.totalSend;
830 830
             ZERO(tempBuf);
831
-            sprintf_P((char *)tempBuf, PSTR("M27 %d\r\n"), print_rate);
832
-            send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf));
831
+            sprintf_P(tempBuf, PSTR("M27 %d\r\n"), print_rate);
832
+            send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf));
833 833
           }
834 834
           break;
835 835
 
@@ -841,15 +841,15 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
841 841
             while (tmpStr[index] == ' ') index++;
842 842
 
843 843
             if (strstr_P((char *)&tmpStr[index], PSTR(".g")) || strstr_P((char *)&tmpStr[index], PSTR(".G"))) {
844
-              strcpy((char *)file_writer.saveFileName, (char *)&tmpStr[index]);
844
+              strcpy(file_writer.saveFileName, (char *)&tmpStr[index]);
845 845
 
846 846
               if (gCfgItems.fileSysType == FILE_SYS_SD) {
847 847
                 ZERO(tempBuf);
848
-                sprintf_P((char *)tempBuf, PSTR("%s"), file_writer.saveFileName);
848
+                sprintf_P(tempBuf, PSTR("%s"), file_writer.saveFileName);
849 849
               }
850 850
               else if (gCfgItems.fileSysType == FILE_SYS_USB) {
851 851
                 ZERO(tempBuf);
852
-                sprintf_P((char *)tempBuf, PSTR("%s"), (char *)file_writer.saveFileName);
852
+                sprintf_P(tempBuf, PSTR("%s"), file_writer.saveFileName);
853 853
               }
854 854
               mount_file_sys(gCfgItems.fileSysType);
855 855
 
@@ -858,11 +858,11 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
858 858
                 card.openFileWrite(cur_name);
859 859
                 if (card.isFileOpen()) {
860 860
                   ZERO(file_writer.saveFileName);
861
-                  strcpy((char *)file_writer.saveFileName, (char *)&tmpStr[index]);
861
+                  strcpy(file_writer.saveFileName, (char *)&tmpStr[index]);
862 862
                   ZERO(tempBuf);
863
-                  sprintf_P((char *)tempBuf, PSTR("Writing to file: %s\r\n"), (char *)file_writer.saveFileName);
863
+                  sprintf_P(tempBuf, PSTR("Writing to file: %s\r\n"), file_writer.saveFileName);
864 864
                   wifi_ret_ack();
865
-                  send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf));
865
+                  send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf));
866 866
                   wifi_link_state = WIFI_WAIT_TRANS_START;
867 867
                 }
868 868
                 else {
@@ -882,7 +882,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
882 882
 
883 883
             SEND_OK_TO_WIFI;
884 884
 
885
-            char *outBuf = (char *)tempBuf;
885
+            char *outBuf = tempBuf;
886 886
             char tbuf[34];
887 887
 
888 888
             sprintf_P(tbuf, PSTR("%d /%d"), (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0));
@@ -917,7 +917,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
917 917
             strcat_P(outBuf, PSTR(" @:0 B@:0\r\n"));
918 918
           }
919 919
           else {
920
-            sprintf_P((char *)tempBuf, PSTR("T:%d /%d B:%d /%d T0:%d /%d T1:%d /%d @:0 B@:0\r\n"),
920
+            sprintf_P(tempBuf, PSTR("T:%d /%d B:%d /%d T0:%d /%d T1:%d /%d @:0 B@:0\r\n"),
921 921
               thermalManager.degHotend(0), thermalManager.degTargetHotend(0),
922 922
               #if HAS_HEATED_BED
923 923
                 thermalManager.degBed(), thermalManager.degTargetBed(),
@@ -933,16 +933,16 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
933 933
             );
934 934
           }
935 935
 
936
-          send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf));
936
+          send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf));
937 937
           queue.enqueue_one_P(PSTR("M105"));
938 938
           break;
939 939
 
940 940
         case 992:
941 941
           if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)) {
942 942
             ZERO(tempBuf);
943
-            sprintf_P((char *)tempBuf, PSTR("M992 %d%d:%d%d:%d%d\r\n"), print_time.hours/10, print_time.hours%10, print_time.minutes/10, print_time.minutes%10, print_time.seconds/10, print_time.seconds%10);
943
+            sprintf_P(tempBuf, PSTR("M992 %d%d:%d%d:%d%d\r\n"), print_time.hours/10, print_time.hours%10, print_time.minutes/10, print_time.minutes%10, print_time.seconds/10, print_time.seconds%10);
944 944
             wifi_ret_ack();
945
-            send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf));
945
+            send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf));
946 946
           }
947 947
           break;
948 948
 
@@ -950,9 +950,9 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
950 950
           if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)) {
951 951
             ZERO(tempBuf);
952 952
             if (strlen((char *)list_file.file_name[sel_id]) > (100 - 1)) return;
953
-            sprintf_P((char *)tempBuf, PSTR("M994 %s;%d\n"), list_file.file_name[sel_id], (int)gCfgItems.curFilesize);
953
+            sprintf_P(tempBuf, PSTR("M994 %s;%d\n"), list_file.file_name[sel_id], (int)gCfgItems.curFilesize);
954 954
             wifi_ret_ack();
955
-            send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf));
955
+            send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf));
956 956
           }
957 957
           break;
958 958
 
@@ -1279,7 +1279,7 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) {
1279 1279
 
1280 1280
   ZERO(public_buf);
1281 1281
 
1282
-  if (strlen((const char *)file_writer.saveFileName) > sizeof(saveFilePath))
1282
+  if (strlen(file_writer.saveFileName) > sizeof(saveFilePath))
1283 1283
     return;
1284 1284
 
1285 1285
   ZERO(saveFilePath);
@@ -1303,9 +1303,9 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) {
1303 1303
 
1304 1304
   #if ENABLED(SDSUPPORT)
1305 1305
 
1306
-    uint8_t dosName[FILENAME_LENGTH];
1306
+    char dosName[FILENAME_LENGTH];
1307 1307
 
1308
-    if (!longName2DosName((const char *)file_writer.saveFileName,dosName)) {
1308
+    if (!longName2DosName(file_writer.saveFileName, dosName)) {
1309 1309
       clear_cur_ui();
1310 1310
       upload_result = 2;
1311 1311
       wifiTransError.flag = 1;

Loading…
Cancelar
Guardar