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

30 lines
915 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);
// }
TouchSensor::TouchSensor(Participant* owner)
: Thing(owner, Type::TouchSensor) {}
// TouchSensor::TouchSensor(Thing* parent) : Thing(parent, Type::TouchSensor) {}
TouchSensor::TouchSensor(Thing& parent) : Thing(Type::TouchSensor, 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