Pan and Tilt Coding of "class ServoLoop"?

Added by scott monasee 21 days ago

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


Replies (1)

RE: Pan and Tilt Coding of "class ServoLoop"? - Added by Edward Getz 21 days ago

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

(1-1/1)