Browse Source

Followup to sprintf cleanup

vanilla_fb_2.0.x
Scott Lahteine 4 years ago
parent
commit
84c79d7531
  1. 2
      Marlin/src/lcd/extui/lib/mks_ui/draw_cloud_bind.cpp
  2. 2
      Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp
  3. 2
      Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp
  4. 54
      Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp
  5. 14
      Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h
  6. 4
      buildroot/share/PlatformIO/variants/megaextendedpins/pins_arduino.h

2
Marlin/src/lcd/extui/lib/mks_ui/draw_cloud_bind.cpp

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

2
Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp

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

2
Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp

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

54
Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp

@ -178,14 +178,14 @@ void changeFlashMode(const bool dmaMode) {
} }
} }
static bool longName2DosName(const char *longName, uint8_t *dosName) { static bool longName2DosName(const char *longName, char *dosName) {
uint8_t i; uint8_t i;
for (i = FILENAME_LENGTH; i--;) dosName[i] = '\0'; for (i = FILENAME_LENGTH; i--;) dosName[i] = '\0';
while (*longName) { while (*longName) {
uint8_t c = *longName++; uint8_t c = *longName++;
if (c == '.') { // For a dot... if (c == '.') { // For a dot...
if (i == 0) return false; if (i == 0) return false;
strcat_P((char *)dosName, PSTR(".GCO")); strcat_P(dosName, PSTR(".GCO"));
break; break;
} }
else { else {
@ -196,7 +196,7 @@ static bool longName2DosName(const char *longName, uint8_t *dosName) {
dosName[i++] = c + (WITHIN(c, 'a', 'z') ? 'A' - 'a' : 0); // Uppercase required for 8.3 name dosName[i++] = c + (WITHIN(c, 'a', 'z') ? 'A' - 'a' : 0); // Uppercase required for 8.3 name
} }
if (i >= 5) { if (i >= 5) {
strcat_P((char *)dosName, PSTR("~1.GCO")); strcat_P(dosName, PSTR("~1.GCO"));
break; break;
} }
} }
@ -478,7 +478,7 @@ char wait_ip_back_flag = 0;
typedef struct { typedef struct {
int write_index; int write_index;
char saveFileName[30]; uint8_t saveFileName[30];
uint8_t fileTransfer; uint8_t fileTransfer;
uint32_t fileLen; uint32_t fileLen;
uint32_t tick_begin; uint32_t tick_begin;
@ -593,7 +593,7 @@ uint8_t Explore_Disk(char *path , uint8_t recu_level) {
} }
static void wifi_gcode_exec(uint8_t *cmd_line) { static void wifi_gcode_exec(uint8_t *cmd_line) {
char tempBuf[100] = { 0 }; int8_t tempBuf[100] = { 0 };
uint8_t *tmpStr = 0; uint8_t *tmpStr = 0;
int cmd_value; int cmd_value;
volatile int print_rate; volatile int print_rate;
@ -631,7 +631,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
while (tmpStr[index] == ' ') index++; while (tmpStr[index] == ' ') index++;
if (gCfgItems.wifi_type == ESP_WIFI) { if (gCfgItems.wifi_type == ESP_WIFI) {
char *path = tempBuf; char *path = (char *)tempBuf;
if (strlen((char *)&tmpStr[index]) < 80) { if (strlen((char *)&tmpStr[index]) < 80) {
send_to_wifi((uint8_t *)"Begin file list\r\n", strlen("Begin file list\r\n")); 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) {
strcat_P((char *)list_file.file_name[sel_id], PSTR("/")); strcat_P((char *)list_file.file_name[sel_id], PSTR("/"));
if (file_writer.fileTransfer == 1) { if (file_writer.fileTransfer == 1) {
uint8_t dosName[FILENAME_LENGTH]; char dosName[FILENAME_LENGTH];
uint8_t fileName[sizeof(list_file.file_name[sel_id])]; uint8_t fileName[sizeof(list_file.file_name[sel_id])];
fileName[0] = '\0'; fileName[0] = '\0';
if (has_path_selected == 1) { if (has_path_selected == 1) {
@ -690,8 +690,8 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
else strcat((char *)fileName, (char *)&tmpStr[index]); else strcat((char *)fileName, (char *)&tmpStr[index]);
if (!longName2DosName((const char *)fileName, dosName)) if (!longName2DosName((const char *)fileName, dosName))
strcpy_P(list_file.file_name[sel_id], PSTR("notValid")); strcpy_P(list_file.file_name[sel_id], PSTR("notValid"));
strcat((char *)list_file.file_name[sel_id], (char *)dosName); strcat((char *)list_file.file_name[sel_id], dosName);
strcat((char *)list_file.long_name[sel_id], (char *)dosName); strcat((char *)list_file.long_name[sel_id], dosName);
} }
else { else {
strcat((char *)list_file.file_name[sel_id], (char *)&tmpStr[index]); strcat((char *)list_file.file_name[sel_id], (char *)&tmpStr[index]);
@ -828,8 +828,8 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)|| (uiCfg.print_state == REPRINTING)) { if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)|| (uiCfg.print_state == REPRINTING)) {
print_rate = uiCfg.totalSend; print_rate = uiCfg.totalSend;
ZERO(tempBuf); ZERO(tempBuf);
sprintf_P(tempBuf, PSTR("M27 %d\r\n"), print_rate); sprintf_P((char *)tempBuf, PSTR("M27 %d\r\n"), print_rate);
send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf)); send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf));
} }
break; break;
@ -841,15 +841,15 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
while (tmpStr[index] == ' ') index++; while (tmpStr[index] == ' ') index++;
if (strstr_P((char *)&tmpStr[index], PSTR(".g")) || strstr_P((char *)&tmpStr[index], PSTR(".G"))) { if (strstr_P((char *)&tmpStr[index], PSTR(".g")) || strstr_P((char *)&tmpStr[index], PSTR(".G"))) {
strcpy(file_writer.saveFileName, (char *)&tmpStr[index]); strcpy((char *)file_writer.saveFileName, (char *)&tmpStr[index]);
if (gCfgItems.fileSysType == FILE_SYS_SD) { if (gCfgItems.fileSysType == FILE_SYS_SD) {
ZERO(tempBuf); ZERO(tempBuf);
sprintf_P(tempBuf, PSTR("%s"), file_writer.saveFileName); sprintf_P((char *)tempBuf, PSTR("%s"), file_writer.saveFileName);
} }
else if (gCfgItems.fileSysType == FILE_SYS_USB) { else if (gCfgItems.fileSysType == FILE_SYS_USB) {
ZERO(tempBuf); ZERO(tempBuf);
sprintf_P(tempBuf, PSTR("%s"), file_writer.saveFileName); sprintf_P((char *)tempBuf, PSTR("%s"), (char *)file_writer.saveFileName);
} }
mount_file_sys(gCfgItems.fileSysType); mount_file_sys(gCfgItems.fileSysType);
@ -858,11 +858,11 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
card.openFileWrite(cur_name); card.openFileWrite(cur_name);
if (card.isFileOpen()) { if (card.isFileOpen()) {
ZERO(file_writer.saveFileName); ZERO(file_writer.saveFileName);
strcpy(file_writer.saveFileName, (char *)&tmpStr[index]); strcpy((char *)file_writer.saveFileName, (char *)&tmpStr[index]);
ZERO(tempBuf); ZERO(tempBuf);
sprintf_P(tempBuf, PSTR("Writing to file: %s\r\n"), file_writer.saveFileName); sprintf_P((char *)tempBuf, PSTR("Writing to file: %s\r\n"), (char *)file_writer.saveFileName);
wifi_ret_ack(); wifi_ret_ack();
send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf)); send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf));
wifi_link_state = WIFI_WAIT_TRANS_START; wifi_link_state = WIFI_WAIT_TRANS_START;
} }
else { else {
@ -882,7 +882,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
SEND_OK_TO_WIFI; SEND_OK_TO_WIFI;
char *outBuf = tempBuf; char *outBuf = (char *)tempBuf;
char tbuf[34]; char tbuf[34];
sprintf_P(tbuf, PSTR("%d /%d"), (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0)); 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) {
strcat_P(outBuf, PSTR(" @:0 B@:0\r\n")); strcat_P(outBuf, PSTR(" @:0 B@:0\r\n"));
} }
else { else {
sprintf_P(tempBuf, PSTR("T:%d /%d B:%d /%d T0:%d /%d T1:%d /%d @:0 B@:0\r\n"), sprintf_P((char *)tempBuf, PSTR("T:%d /%d B:%d /%d T0:%d /%d T1:%d /%d @:0 B@:0\r\n"),
thermalManager.degHotend(0), thermalManager.degTargetHotend(0), thermalManager.degHotend(0), thermalManager.degTargetHotend(0),
#if HAS_HEATED_BED #if HAS_HEATED_BED
thermalManager.degBed(), thermalManager.degTargetBed(), thermalManager.degBed(), thermalManager.degTargetBed(),
@ -933,16 +933,16 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
); );
} }
send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf)); send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf));
queue.enqueue_one_P(PSTR("M105")); queue.enqueue_one_P(PSTR("M105"));
break; break;
case 992: case 992:
if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)) { if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)) {
ZERO(tempBuf); ZERO(tempBuf);
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); 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);
wifi_ret_ack(); wifi_ret_ack();
send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf)); send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf));
} }
break; break;
@ -950,9 +950,9 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)) { if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)) {
ZERO(tempBuf); ZERO(tempBuf);
if (strlen((char *)list_file.file_name[sel_id]) > (100 - 1)) return; if (strlen((char *)list_file.file_name[sel_id]) > (100 - 1)) return;
sprintf_P(tempBuf, PSTR("M994 %s;%d\n"), list_file.file_name[sel_id], (int)gCfgItems.curFilesize); sprintf_P((char *)tempBuf, PSTR("M994 %s;%d\n"), list_file.file_name[sel_id], (int)gCfgItems.curFilesize);
wifi_ret_ack(); wifi_ret_ack();
send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf)); send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf));
} }
break; break;
@ -1279,7 +1279,7 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) {
ZERO(public_buf); ZERO(public_buf);
if (strlen(file_writer.saveFileName) > sizeof(saveFilePath)) if (strlen((const char *)file_writer.saveFileName) > sizeof(saveFilePath))
return; return;
ZERO(saveFilePath); ZERO(saveFilePath);
@ -1305,7 +1305,7 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) {
char dosName[FILENAME_LENGTH]; char dosName[FILENAME_LENGTH];
if (!longName2DosName(file_writer.saveFileName, dosName)) { if (!longName2DosName((const char *)file_writer.saveFileName, dosName)) {
clear_cur_ui(); clear_cur_ui();
upload_result = 2; upload_result = 2;
wifiTransError.flag = 1; wifiTransError.flag = 1;
@ -1313,7 +1313,7 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) {
lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE); lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE);
return; return;
} }
strcpy(saveFilePath, dosName); strcpy((char *)saveFilePath, dosName);
card.cdroot(); card.cdroot();
upload_file.close(); upload_file.close();

14
Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h

@ -178,18 +178,18 @@ extern CLOUD_PARA cloud_para;
extern WIFI_GCODE_BUFFER espGcodeFifo; extern WIFI_GCODE_BUFFER espGcodeFifo;
extern uint32_t getWifiTick(); uint32_t getWifiTick();
extern uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick); uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick);
void mks_esp_wifi_init(); void mks_esp_wifi_init();
extern int cfg_cloud_flag; extern int cfg_cloud_flag;
extern int send_to_wifi(uint8_t *buf, int len); int send_to_wifi(uint8_t *buf, int len);
void wifi_looping(); void wifi_looping();
extern int raw_send_to_wifi(uint8_t *buf, int len); int raw_send_to_wifi(uint8_t *buf, int len);
extern int package_to_wifi(WIFI_RET_TYPE type, uint8_t *buf, int len); int package_to_wifi(WIFI_RET_TYPE type, uint8_t *buf, int len);
void get_wifi_list_command_send(); void get_wifi_list_command_send();
void get_wifi_commands(); void get_wifi_commands();
extern int readWifiBuf(int8_t *buf, int32_t len); int readWifiBuf(int8_t *buf, int32_t len);
void mks_wifi_firmware_update(); void mks_wifi_firmware_update();
#ifdef __cplusplus #ifdef __cplusplus

4
buildroot/share/PlatformIO/variants/megaextendedpins/pins_arduino.h

@ -89,7 +89,7 @@ static const uint8_t A15 = PIN_A15;
#define digitalPinToPCICR(p) ( (((p) >= 10) && ((p) <= 13)) || \ #define digitalPinToPCICR(p) ( (((p) >= 10) && ((p) <= 13)) || \
(((p) >= 50) && ((p) <= 53)) || \ (((p) >= 50) && ((p) <= 53)) || \
(((p) >= 62) && ((p) <= 69)) ? (&PCICR) : ((uint8_t *)0) ) (((p) >= 62) && ((p) <= 69)) ? (&PCICR) : nullptr )
#define digitalPinToPCICRbit(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? 0 : \ #define digitalPinToPCICRbit(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? 0 : \
( (((p) >= 62) && ((p) <= 69)) ? 2 : \ ( (((p) >= 62) && ((p) <= 69)) ? 2 : \
@ -97,7 +97,7 @@ static const uint8_t A15 = PIN_A15;
#define digitalPinToPCMSK(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? (&PCMSK0) : \ #define digitalPinToPCMSK(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? (&PCMSK0) : \
( (((p) >= 62) && ((p) <= 69)) ? (&PCMSK2) : \ ( (((p) >= 62) && ((p) <= 69)) ? (&PCMSK2) : \
((uint8_t *)0) ) ) nullptr ) )
#define digitalPinToPCMSKbit(p) ( (((p) >= 10) && ((p) <= 13)) ? ((p) - 6) : \ #define digitalPinToPCMSKbit(p) ( (((p) >= 10) && ((p) <= 13)) ? ((p) - 6) : \
( ((p) == 50) ? 3 : \ ( ((p) == 50) ? 3 : \

Loading…
Cancel
Save