Skip to content

Commit

Permalink
use millis_t
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Mar 10, 2023
1 parent 0b81333 commit d148b83
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
17 changes: 8 additions & 9 deletions Marlin/src/lcd/extui/mks_ui/wifi_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,20 @@ extern CLOUD_PARA cloud_para;
extern bool once_flag, flash_preview_begin, default_preview_flg, gcode_preview_over;
extern bool flash_dma_mode;

uint32_t getWifiTick() { return millis(); }
millis_t getWifiTick() { return millis(); }

uint32_t getWifiTickDiff(const int32_t lastTick, const int32_t curTick) {
return (TICK_CYCLE) * (lastTick <= curTick ? curTick - lastTick : 0xFFFFFFFF - lastTick + curTick);
millis_t getWifiTickDiff(const millis_t lastTick, const millis_t curTick) {
return (TICK_CYCLE) * (lastTick <= curTick ? curTick - lastTick : 0xFFFFFFFFUL - lastTick + curTick);
}

void wifi_delay(int n) {
const uint32_t start = getWifiTick();
while (getWifiTickDiff(start, getWifiTick()) < (uint32_t)n)
void wifi_delay(const uint16_t n) {
const millis_t start = getWifiTick();
while (getWifiTickDiff(start, getWifiTick()) < millis_t(n))
hal.watchdog_refresh();
}

void wifi_reset() {
uint32_t start = getWifiTick();
const millis_t start = getWifiTick();
WIFI_RESET();
while (getWifiTickDiff(start, getWifiTick()) < 500) { /* nada */ }
WIFI_SET();
Expand Down Expand Up @@ -833,9 +833,8 @@ uint8_t Explore_Disk(const char * const path, const uint8_t recu_level, const bo
ZERO(Fstream);
strcpy(Fstream, card.filename);

if (card.flag.filenameIsDir && recu_level <= 10) {
if (card.flag.filenameIsDir && recu_level <= 10)
strcat_P(Fstream, PSTR(".DIR"));
}

strcat_P(Fstream, PSTR(" 0")); // report 0 file size

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/extui/mks_ui/wifi_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ extern CLOUD_PARA cloud_para;

extern WIFI_GCODE_BUFFER espGcodeFifo;

uint32_t getWifiTick();
uint32_t getWifiTickDiff(const int32_t lastTick, const int32_t curTick);
millis_t getWifiTick();
millis_t getWifiTickDiff(const millis_t lastTick, const millis_t curTick);

void mks_esp_wifi_init();
extern int cfg_cloud_flag;
Expand Down
6 changes: 2 additions & 4 deletions Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@

extern SZ_USART_FIFO WifiRxFifo;

extern int readUsartFifo(SZ_USART_FIFO *fifo, int8_t *buf, int32_t len);
extern int writeUsartFifo(SZ_USART_FIFO * fifo, int8_t * buf, int32_t len);
void esp_port_begin(uint8_t interrupt);
void wifi_delay(int n);
void wifi_delay(const uint16_t n);

#define ARRAY_SIZE(a) sizeof(a) / sizeof((a)[0])

Expand Down Expand Up @@ -246,7 +244,7 @@ EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t

const size_t headerLength = 8;

uint32_t startTime = getWifiTick();
const millis_t startTime = getWifiTick();
uint8_t hdr[headerLength];
uint16_t hdrIdx = 0;

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/extui/mks_ui/wifi_upload.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ typedef struct {
UploadState state;
uint32_t retriesPerBaudRate;
uint32_t connectAttemptNumber;
uint32_t lastAttemptTime;
uint32_t lastResetTime;
millis_t lastAttemptTime;
millis_t lastResetTime;
uint32_t uploadBlockNumber;
uint32_t uploadNextPercentToReport;
EspUploadResult uploadResult;
Expand Down

0 comments on commit d148b83

Please sign in to comment.