limit fps

Hi!
If I run the following program, there will be a 1 second lag in servo startup after receiving data.
So I would like to lack the limit on the fps output to the screen. please tell me. Thank you.

import time,pyb,sensor,image,micropython
from pyb import Pin,UART,Timer,Servo
from servo import Servos
from machine import I2C
sensor.reset()                      
sensor.set_pixformat(sensor.RGB565) 
sensor.set_framesize(sensor.QVGA)  
sensor.skip_frames(time=4000)    
clock = time.clock()                
####################################################################################################
MotorA=Pin('P1',Pin.OUT_PP,Pin.PULL_NONE)
MotorB=Pin('P2',Pin.OUT_PP,Pin.PULL_NONE)
i2c = I2C(sda=Pin('P5'), scl=Pin('P4'))
servo = Servos(i2c, address=0x40, freq=50, min_us=250, max_us=2800, degrees=180)
uart = UART(1, 115200, timeout=5)
####################################################################################################
#tim = Timer(1, freq=50)
#ch1 = tim.channel(1,Timer.PWM,pin=Pin("P7"),pulse_width_percent=1)
####################################################################################################
x=90
y=90


while(True):
    img =  sensor.snapshot()
    print(clock.fps())
    servo.position(7,x)
    servo.position(6,y)
    Data=0;
    Data=uart.readchar()
    if(Data!=0):
      if(Data==1):
        x+=1
      elif(Data==2):
        x-=1
      elif(Data==3):
        y+=1
      elif(Data==4):
        y-=1
      elif(Data==5):
        x=90
        y=90
        MotorA.value(True)
        MotorB.value(False)
      elif(Data==6):
        x=90
        y=90
        MotorA.value(False)
        MotorB.value(True)
    else:
      x=75
      y=90

servo_1.py (1.16 KB)
pca9685_1.py (1.91 KB)
camera_main.py (1.91 KB)

I don’t understand “lack the limit on the fps output to the screen”. Can you elaborate?

Well.
I want to receive data from Arduino and control the servo motor with that data while outputting video on my PC.
However, with the current program, there is a 1 second lag when moving the servo motor after receiving data from Arduino.
So,I want to Reduce processing to CPU.

Sorry for the poor English.I am Japanese and don’t understand English well…

Okay, i don’t see anything that would create the lag in the code. Anyway, what do you mean by reduce processing to the CPU? You can add delay methods that make it run slower.

I would like to limit the video fps displayed on my computer as a way to reduce the processing to the CPU.
I want to move the servo as soon as communication from Arduino comes.

I see, um, there’s no way to lower the IDE poll rate except to disable the frame buffer such that it doesn’t display anything.

You can redo your code loop such that you call snapshot() not each time through the loop. This will reduce the processing on your PC. So, just only call snapshot every 4 times through the loop.

OK! Thanks!