File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,5 +30,8 @@ typedef uint32_t millis_t;
3030#define MS_TO_SEC (N ) millis_t((N)/1000UL)
3131#define MS_TO_SEC_PRECISE (N ) (float(N)/1000.0f)
3232
33- #define PENDING (NOW ,SOON ) ((int32_t)(NOW-(SOON))<0)
33+ #define FUTURE (START ,DURA ) (millis_t(millis()-(START))<(DURA))
34+ #define PAST (START ,DURA ) (!FUTURE(START,DURA))
35+
36+ #define PENDING (NOW ,SOON ) (int32_t((NOW)-(SOON))<0)
3437#define ELAPSED (NOW ,SOON ) (!PENDING(NOW,SOON))
Original file line number Diff line number Diff line change @@ -242,11 +242,11 @@ void GcodeSuite::get_destination_from_command() {
242242}
243243
244244/* *
245- * Dwell waits immediately. It does not synchronize. Use M400 instead of G4
245+ * Dwell waits immediately. It does not synchronize.
246246 */
247- void GcodeSuite::dwell (millis_t time) {
248- time + = millis ();
249- while (PENDING ( millis () , time)) idle ();
247+ void GcodeSuite::dwell (const millis_t time) {
248+ const millis_t startMillis = millis ();
249+ while (FUTURE (startMillis , time)) idle ();
250250}
251251
252252/* *
Original file line number Diff line number Diff line change @@ -503,7 +503,7 @@ class GcodeSuite {
503503 #define KEEPALIVE_STATE (N ) NOOP
504504 #endif
505505
506- static void dwell (millis_t time);
506+ static void dwell (const millis_t time);
507507
508508private:
509509
You can’t perform that action at this time.
0 commit comments