Browse Source

Followup to sprintf cleanup

Scott Lahteine 3 years ago
parent
commit
84c79d7531

+ 1
- 1
Marlin/src/lcd/extui/lib/mks_ui/draw_cloud_bind.cpp View File

@@ -190,7 +190,7 @@ void display_qrcode(uint8_t *qrcode_data) {
190 190
 }
191 191
 
192 192
 void cloud_unbind() {
193
-  package_to_wifi(WIFI_CLOUD_UNBIND, (uint8_t *)0, 0);
193
+  package_to_wifi(WIFI_CLOUD_UNBIND, nullptr, 0);
194 194
   unbinding_flag = 1;
195 195
 }
196 196
 

+ 1
- 1
Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp View File

@@ -137,7 +137,7 @@ static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) {
137 137
 
138 138
             gCfgItems.wifi_mode_sel = STA_MODEL;
139 139
 
140
-            package_to_wifi(WIFI_PARA_SET, (uint8_t *)0, 0);
140
+            package_to_wifi(WIFI_PARA_SET, nullptr, 0);
141 141
 
142 142
             public_buf_l[0] = 0xA5;
143 143
             public_buf_l[1] = 0x09;

+ 1
- 1
Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp View File

@@ -54,7 +54,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
54 54
           queue.inject_P(G28_STR);
55 55
         }
56 56
         const int ind = obj->mks_obj_id - ID_M_POINT1;
57
-        sprintf_P(public_buf_l, PSTR("G1 Z10\nG1 X%d Y%d\nG1 Z0"), gCfgItems.trammingPos[ind].x, gCfgItems.trammingPos[ind].y);
57
+        sprintf_P(public_buf_l, PSTR("G1Z10\nG1X%dY%d\nG1Z0"), gCfgItems.trammingPos[ind].x, gCfgItems.trammingPos[ind].y);
58 58
         queue.inject(public_buf_l);
59 59
       }
60 60
       break;

+ 27
- 27
Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp View File

@@ -178,14 +178,14 @@ void changeFlashMode(const bool dmaMode) {
178 178
   }
179 179
 }
180 180
 
181
-static bool longName2DosName(const char *longName, uint8_t *dosName) {
181
+static bool longName2DosName(const char *longName, char *dosName) {
182 182
   uint8_t i;
183 183
   for (i = FILENAME_LENGTH; i--;) dosName[i] = '\0';
184 184
   while (*longName) {
185 185
     uint8_t c = *longName++;
186 186
     if (c == '.') { // For a dot...
187 187
       if (i == 0) return false;
188
-      strcat_P((char *)dosName, PSTR(".GCO"));
188
+      strcat_P(dosName, PSTR(".GCO"));
189 189
       break;
190 190
     }
191 191
     else {
@@ -196,7 +196,7 @@ static bool longName2DosName(const char *longName, uint8_t *dosName) {
196 196
       dosName[i++] = c + (WITHIN(c, 'a', 'z') ? 'A' - 'a' : 0); // Uppercase required for 8.3 name
197 197
     }
198 198
     if (i >= 5) {
199
-      strcat_P((char *)dosName, PSTR("~1.GCO"));
199
+      strcat_P(dosName, PSTR("~1.GCO"));
200 200
       break;
201 201
     }
202 202
   }
@@ -478,7 +478,7 @@ char wait_ip_back_flag = 0;
478 478
 
479 479
 typedef struct {
480 480
   int write_index;
481
-  char saveFileName[30];
481
+  uint8_t 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
-  char tempBuf[100] = { 0 };
596
+  int8_t 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 = tempBuf;
634
+              char *path = (char *)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"));
@@ -680,7 +680,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
680 680
                     strcat_P((char *)list_file.file_name[sel_id], PSTR("/"));
681 681
 
682 682
                   if (file_writer.fileTransfer == 1) {
683
-                    uint8_t dosName[FILENAME_LENGTH];
683
+                    char dosName[FILENAME_LENGTH];
684 684
                     uint8_t fileName[sizeof(list_file.file_name[sel_id])];
685 685
                     fileName[0] = '\0';
686 686
                     if (has_path_selected == 1) {
@@ -690,8 +690,8 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
690 690
                     else strcat((char *)fileName, (char *)&tmpStr[index]);
691 691
                     if (!longName2DosName((const char *)fileName, dosName))
692 692
                       strcpy_P(list_file.file_name[sel_id], PSTR("notValid"));
693
-                    strcat((char *)list_file.file_name[sel_id], (char *)dosName);
694
-                    strcat((char *)list_file.long_name[sel_id], (char *)dosName);
693
+                    strcat((char *)list_file.file_name[sel_id], dosName);
694
+                    strcat((char *)list_file.long_name[sel_id], dosName);
695 695
                   }
696 696
                   else {
697 697
                     strcat((char *)list_file.file_name[sel_id], (char *)&tmpStr[index]);
@@ -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(tempBuf, PSTR("M27 %d\r\n"), print_rate);
832
-            send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf));
831
+            sprintf_P((char *)tempBuf, PSTR("M27 %d\r\n"), print_rate);
832
+            send_to_wifi((uint8_t *)tempBuf, strlen((char *)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(file_writer.saveFileName, (char *)&tmpStr[index]);
844
+              strcpy((char *)file_writer.saveFileName, (char *)&tmpStr[index]);
845 845
 
846 846
               if (gCfgItems.fileSysType == FILE_SYS_SD) {
847 847
                 ZERO(tempBuf);
848
-                sprintf_P(tempBuf, PSTR("%s"), file_writer.saveFileName);
848
+                sprintf_P((char *)tempBuf, PSTR("%s"), file_writer.saveFileName);
849 849
               }
850 850
               else if (gCfgItems.fileSysType == FILE_SYS_USB) {
851 851
                 ZERO(tempBuf);
852
-                sprintf_P(tempBuf, PSTR("%s"), file_writer.saveFileName);
852
+                sprintf_P((char *)tempBuf, PSTR("%s"), (char *)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(file_writer.saveFileName, (char *)&tmpStr[index]);
861
+                  strcpy((char *)file_writer.saveFileName, (char *)&tmpStr[index]);
862 862
                   ZERO(tempBuf);
863
-                  sprintf_P(tempBuf, PSTR("Writing to file: %s\r\n"), file_writer.saveFileName);
863
+                  sprintf_P((char *)tempBuf, PSTR("Writing to file: %s\r\n"), (char *)file_writer.saveFileName);
864 864
                   wifi_ret_ack();
865
-                  send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf));
865
+                  send_to_wifi((uint8_t *)tempBuf, strlen((char *)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 = tempBuf;
885
+            char *outBuf = (char *)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(tempBuf, PSTR("T:%d /%d B:%d /%d T0:%d /%d T1:%d /%d @:0 B@:0\r\n"),
920
+            sprintf_P((char *)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(tempBuf));
936
+          send_to_wifi((uint8_t *)tempBuf, strlen((char *)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(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((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);
944 944
             wifi_ret_ack();
945
-            send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf));
945
+            send_to_wifi((uint8_t *)tempBuf, strlen((char *)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(tempBuf, PSTR("M994 %s;%d\n"), list_file.file_name[sel_id], (int)gCfgItems.curFilesize);
953
+            sprintf_P((char *)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(tempBuf));
955
+            send_to_wifi((uint8_t *)tempBuf, strlen((char *)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(file_writer.saveFileName) > sizeof(saveFilePath))
1282
+  if (strlen((const char *)file_writer.saveFileName) > sizeof(saveFilePath))
1283 1283
     return;
1284 1284
 
1285 1285
   ZERO(saveFilePath);
@@ -1305,7 +1305,7 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) {
1305 1305
 
1306 1306
     char dosName[FILENAME_LENGTH];
1307 1307
 
1308
-    if (!longName2DosName(file_writer.saveFileName, dosName)) {
1308
+    if (!longName2DosName((const char *)file_writer.saveFileName, dosName)) {
1309 1309
       clear_cur_ui();
1310 1310
       upload_result = 2;
1311 1311
       wifiTransError.flag = 1;
@@ -1313,7 +1313,7 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) {
1313 1313
       lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE);
1314 1314
       return;
1315 1315
     }
1316
-    strcpy(saveFilePath, dosName);
1316
+    strcpy((char *)saveFilePath, dosName);
1317 1317
 
1318 1318
     card.cdroot();
1319 1319
     upload_file.close();

+ 7
- 7
Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h View File

@@ -178,18 +178,18 @@ extern CLOUD_PARA cloud_para;
178 178
 
179 179
 extern WIFI_GCODE_BUFFER espGcodeFifo;
180 180
 
181
-extern uint32_t  getWifiTick();
182
-extern uint32_t  getWifiTickDiff(int32_t lastTick, int32_t curTick);
181
+uint32_t getWifiTick();
182
+uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick);
183 183
 
184 184
 void mks_esp_wifi_init();
185
-extern int  cfg_cloud_flag;
186
-extern int  send_to_wifi(uint8_t *buf, int len);
185
+extern int cfg_cloud_flag;
186
+int send_to_wifi(uint8_t *buf, int len);
187 187
 void wifi_looping();
188
-extern int  raw_send_to_wifi(uint8_t *buf, int len);
189
-extern int  package_to_wifi(WIFI_RET_TYPE type, uint8_t *buf, int len);
188
+int raw_send_to_wifi(uint8_t *buf, int len);
189
+int package_to_wifi(WIFI_RET_TYPE type, uint8_t *buf, int len);
190 190
 void get_wifi_list_command_send();
191 191
 void get_wifi_commands();
192
-extern int  readWifiBuf(int8_t *buf, int32_t len);
192
+int readWifiBuf(int8_t *buf, int32_t len);
193 193
 void mks_wifi_firmware_update();
194 194
 
195 195
 #ifdef __cplusplus

+ 2
- 2
buildroot/share/PlatformIO/variants/megaextendedpins/pins_arduino.h View File

@@ -89,7 +89,7 @@ static const uint8_t A15 = PIN_A15;
89 89
 
90 90
 #define digitalPinToPCICR(p)    ( (((p) >= 10) && ((p) <= 13)) || \
91 91
                                   (((p) >= 50) && ((p) <= 53)) || \
92
-                                  (((p) >= 62) && ((p) <= 69)) ? (&PCICR) : ((uint8_t *)0) )
92
+                                  (((p) >= 62) && ((p) <= 69)) ? (&PCICR) : nullptr )
93 93
 
94 94
 #define digitalPinToPCICRbit(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? 0 : \
95 95
                                 ( (((p) >= 62) && ((p) <= 69)) ? 2 : \
@@ -97,7 +97,7 @@ static const uint8_t A15 = PIN_A15;
97 97
 
98 98
 #define digitalPinToPCMSK(p)    ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? (&PCMSK0) : \
99 99
                                 ( (((p) >= 62) && ((p) <= 69)) ? (&PCMSK2) : \
100
-                                ((uint8_t *)0) ) )
100
+                                nullptr ) )
101 101
 
102 102
 #define digitalPinToPCMSKbit(p) ( (((p) >= 10) && ((p) <= 13)) ? ((p) - 6) : \
103 103
                                 ( ((p) == 50) ? 3 : \

Loading…
Cancel
Save