36 lines
852 B
C++
36 lines
852 B
C++
#include "TouchSensor.h"
|
|
|
|
namespace RoboidControl {
|
|
|
|
TouchSensor::TouchSensor(Thing* parent) : Thing(parent) {
|
|
this->type = Type::TouchSensor;
|
|
this->name = "Touch sensor";
|
|
}
|
|
|
|
bool TouchSensor::IsTouching() {
|
|
return this->internalTouch || this->externalTouch;
|
|
}
|
|
|
|
void TouchSensor::PrepareForUpdate() {
|
|
//this->internalTouch = this->externalTouch;
|
|
}
|
|
|
|
void TouchSensor::Update(bool recursive) {
|
|
Thing::Update(recursive);
|
|
}
|
|
|
|
int TouchSensor::GenerateBinary(char* bytes, unsigned char* ix) {
|
|
std::cout << "BinaryMsg Touch " << this->internalTouch << std::endl;
|
|
bytes[(*ix)++] = this->internalTouch ? 1 : 0;
|
|
return 1;
|
|
}
|
|
|
|
void TouchSensor::ProcessBinary(char* bytes) {
|
|
this->externalTouch = (bytes[0] == 1);
|
|
if (this->externalTouch)
|
|
std::cout << "touching!\n";
|
|
else
|
|
std::cout << "not touching\n";
|
|
}
|
|
|
|
} // namespace RoboidControl
|