RoboidControl-cpp/Things/TouchSensor.cpp

23 lines
647 B
C++

#include "TouchSensor.h"
namespace RoboidControl {
TouchSensor::TouchSensor() : Thing(Thing::Type::TouchSensor) {}
TouchSensor::TouchSensor(Participant* owner, unsigned char thingId)
: Thing(owner, Thing::Type::TouchSensor, thingId) {}
TouchSensor::TouchSensor(Thing* parent, unsigned char thingId) : Thing(parent->owner, Thing::Type::TouchSensor, thingId) {
this->SetParent(parent);
}
int TouchSensor::GenerateBinary(char* bytes, unsigned char* ix) {
bytes[(*ix)++] = touchedSomething ? 1 : 0;
return 1;
}
void TouchSensor::ProcessBinary(char* bytes) {
this->touchedSomething |= (bytes[0] == 1);
}
} // namespace RoboidControl