<< return to Pixycam.com

Pan and Tilt Coding of "class ServoLoop"?

Hello
I was wondering why the PanTilt sketch provided for the Pixy camera are declared as “class ServoLoop”? Couldn’t the code be written as a function (ie:

void ServoLoop(int32_t pgain, int32_t dgain)
{
//code here.
}

void ServoLoopupdate(int32_t error)
{
//code here.
}

Just wondering why it was written as a class and not a function. Thx, Scott

Hello Scott,
You don’t need to use a class or struct. The class or struct allows you to store the gains and the state without having to pass around. It’s a programming preference.

Edward