RoboidControl-cpp/Things/RelativeEncoder.cpp
2025-05-18 17:34:52 +02:00

24 lines
608 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