diff --git a/Grbl_Esp32/grbl.h b/Grbl_Esp32/grbl.h index d1c46d66..1d23575c 100644 --- a/Grbl_Esp32/grbl.h +++ b/Grbl_Esp32/grbl.h @@ -20,7 +20,7 @@ // Grbl versioning system #define GRBL_VERSION "1.1f" -#define GRBL_VERSION_BUILD "20200218" +#define GRBL_VERSION_BUILD "20200219" //#include #include diff --git a/Grbl_Esp32/spindle_control.cpp b/Grbl_Esp32/spindle_control.cpp index c350edb7..0ad8f1d8 100644 --- a/Grbl_Esp32/spindle_control.cpp +++ b/Grbl_Esp32/spindle_control.cpp @@ -205,8 +205,14 @@ void spindle_sync(uint8_t state, float rpm) void grbl_analogWrite(uint8_t chan, uint32_t duty) { - if (ledcRead(chan) != duty) // reduce unnecessary calls to ledcWrite() + // Remember the old duty cycle in memory instead of reading + // it from the I/O peripheral because I/O reads are quite + // a bit slower than memory reads. + static uint32_t old_duty = 0; + + if (old_duty != duty) // reduce unnecessary calls to ledcWrite() { + old_duty = duty; ledcWrite(chan, duty); } }