23 lines
513 B
C++
23 lines
513 B
C++
#include "RelativeEncoder.h"
|
|
|
|
namespace RoboidControl {
|
|
|
|
RelativeEncoder::RelativeEncoder(Thing* parent) : Thing(parent) {
|
|
this->type = 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
|