![](/media/cache/profiles/altb_JGUSAOG.jpg.50x50_q85.jpg)
SPI read Pixi Cam V1
Diff: Pixy.cpp
- Revision:
- 5:d109b094d4bb
- Parent:
- 4:478d4d9193a1
diff -r 478d4d9193a1 -r d109b094d4bb Pixy.cpp --- a/Pixy.cpp Mon Aug 23 11:26:37 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -#include "Pixy.h" - -ServoLoop::ServoLoop(int32_t pgain, int32_t dgain) -{ - m_pos = PIXY_RCS_CENTER_POS; - m_pgain = pgain; - m_dgain = dgain; - m_prevError = 0x80000000L; -} - -void ServoLoop::update(int32_t error) -{ - long int vel; - if (m_prevError != 0x80000000) { - vel = (error*m_pgain + (error - m_prevError)*m_dgain) >> 10; - m_pos += vel; - if (m_pos > PIXY_RCS_MAX_POS) { - m_pos = PIXY_RCS_MAX_POS; - } else if (m_pos < PIXY_RCS_MIN_POS) { - m_pos = PIXY_RCS_MIN_POS; - } - } - m_prevError = error; -} -