Hi,
I'm seeing VarSpeedServo library for Arduino. This may be a silly question.
In the following code, the array name, sequenceIn is called. What number is assigned to this variable?
I'm seeing VarSpeedServo library for Arduino. This may be a silly question.
In the following code, the array name, sequenceIn is called. What number is assigned to this variable?
C++:
uint8_t VarSpeedServo::sequencePlay(servoSequencePoint sequenceIn[], uint8_t numPositions, bool loop, uint8_t startPos) {
uint8_t oldSeqPosition = this->curSeqPosition;
if( this->curSequence != sequenceIn) {
//Serial.println("newSeq");
this->curSequence = sequenceIn;
this->curSeqPosition = startPos;
oldSeqPosition = 255;
}
if (read() == sequenceIn[this->curSeqPosition].position && this->curSeqPosition != CURRENT_SEQUENCE_STOP) {
this->curSeqPosition++;
if (this->curSeqPosition >= numPositions) { // at the end of the loop
if (loop) { // reset to the beginning of the loop
this->curSeqPosition = 0;
} else { // stop the loop
this->curSeqPosition = CURRENT_SEQUENCE_STOP;
}
}
}
if (this->curSeqPosition != oldSeqPosition && this->curSeqPosition != CURRENT_SEQUENCE_STOP) {
// CURRENT_SEQUENCE_STOP position means the animation has ended, and should no longer be played
// otherwise move to the next position
write(sequenceIn[this->curSeqPosition].position, sequenceIn[this->curSeqPosition].speed);
//Serial.println(this->seqCurPosition);
}
return this->curSeqPosition;
}
C++:
typedef struct {
uint8_t position;
uint8_t speed;
} servoSequencePoint;
C++:
servoSequencePoint slow[] = {{100,20},{20,20},{60,50}};