library/pid.py change millis to ticks_ms

change pyb.millis to time.tick_ms, for supporting imx.rt
This commit is contained in:
王开智 2024-03-13 13:15:27 +08:00 committed by GitHub
parent dbe5187558
commit e763300b8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,7 +8,7 @@ while(True):
#control value with output
"""
from pyb import millis
from time import ticks_ms
from math import pi, isnan
@ -25,7 +25,7 @@ class PID:
self._last_derivative = float("nan")
def get_pid(self, error, scaler):
tnow = millis()
tnow = ticks_ms()
dt = tnow - self._last_t
output = 0
if self._last_t == 0 or dt > 1000: