mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Reset the FPS clock every 2s.
This commit is contained in:
parent
0666d0a465
commit
f85540b716
@ -30,7 +30,13 @@ mp_obj_t py_clock_fps(mp_obj_t clock_obj)
|
||||
py_clock_obj_t *clock = (py_clock_obj_t*) clock_obj;
|
||||
clock->t_frame++;
|
||||
clock->t_ticks += (systick_current_millis()-clock->t_start);
|
||||
return mp_obj_new_float(1000.0f/(clock->t_ticks/(float)clock->t_frame));
|
||||
float fps = 1000.0f / (clock->t_ticks/(float)clock->t_frame);
|
||||
if (clock->t_ticks >= 2000) {
|
||||
// Reset the FPS clock every 2s
|
||||
clock->t_frame = 0;
|
||||
clock->t_ticks = 0;
|
||||
}
|
||||
return mp_obj_new_float(fps);
|
||||
}
|
||||
|
||||
mp_obj_t py_clock_avg(mp_obj_t clock_obj)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user