I build photo slider based on ESP32 and I use PWM + sleep_ms to define distance which has to be reached by stepper motor.
The case is to show user actual distance which dolly moved, so I need to know how long actually motor works.
I use something like that (pseudo code):
[code]
freq = # calculate correct frequency for PWM
time = # time how long motor should work with frequency above
PWM.freq(freq)
PWM.init()
start_time = utime.ticks_us()
await asyncio.sleep_ms(time)
PWM.deinit()
[/code]
And there is second task which should display on oled current status:
[code]
time_elapsed = utime.ticks_diff(utime.ticks_us(), self.motor.start_time)
[/code]
The problem is that maximum value for utime.ticks_us() is 536870911 (about 13.5 minutes) and after that value has been reached, ticks_us return value -536870911...
I want to be able set slider to work about 3hrs, any idea how can I achieve that? Using simple timestamp can be not enough accurate
