1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-08-30 09:39:49 +02:00

Simple speedup for spindle PWM

This commit is contained in:
Mitch Bradley
2020-02-19 13:30:40 -10:00
parent 096d765f75
commit f7a3d03734
2 changed files with 8 additions and 2 deletions

View File

@@ -20,7 +20,7 @@
// Grbl versioning system // Grbl versioning system
#define GRBL_VERSION "1.1f" #define GRBL_VERSION "1.1f"
#define GRBL_VERSION_BUILD "20200218" #define GRBL_VERSION_BUILD "20200219"
//#include <sdkconfig.h> //#include <sdkconfig.h>
#include <Arduino.h> #include <Arduino.h>

View File

@@ -205,8 +205,14 @@ void spindle_sync(uint8_t state, float rpm)
void grbl_analogWrite(uint8_t chan, uint32_t duty) 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); ledcWrite(chan, duty);
} }
} }