24 lines
602 B
C++
24 lines
602 B
C++
#include "RelativeEncoder.h"
|
|
|
|
namespace RoboidControl {
|
|
|
|
RelativeEncoder::RelativeEncoder(Participant* owner)
|
|
: Thing(owner, Type::IncrementalEncoder) {}
|
|
RelativeEncoder::RelativeEncoder(Thing* parent)
|
|
: Thing(parent, Type::IncrementalEncoder) {}
|
|
|
|
float RelativeEncoder::GetRotationSpeed() {
|
|
return rotationSpeed;
|
|
}
|
|
|
|
int RelativeEncoder::GenerateBinary(char* data, unsigned char* ix) {
|
|
data[(*ix)++] = (unsigned char)(this->rotationSpeed * 127);
|
|
return 1;
|
|
}
|
|
|
|
void RelativeEncoder::ProcessBinary(char* data) {
|
|
this->rotationSpeed = (float)data[0] / 127;
|
|
}
|
|
|
|
} // namespace RoboidControl
|