35 lines
606 B
C++
35 lines
606 B
C++
#include "DistanceSensor.h"
|
|
|
|
DistanceSensor::DistanceSensor()
|
|
{
|
|
isDistanceSensor = true;
|
|
}
|
|
|
|
DistanceSensor::DistanceSensor(float triggerDistance)
|
|
{
|
|
isDistanceSensor = true;
|
|
this->triggerDistance = triggerDistance;
|
|
}
|
|
|
|
float DistanceSensor::GetDistance()
|
|
{
|
|
return distance;
|
|
};
|
|
|
|
void DistanceSensor::SetDistance(float distance)
|
|
{
|
|
this->distance = distance;
|
|
}; // for simulation purposes
|
|
|
|
bool DistanceSensor::IsOn()
|
|
{
|
|
bool isOn = GetDistance() <= triggerDistance;
|
|
return isOn;
|
|
}
|
|
|
|
bool DistanceSensor::isOff()
|
|
{
|
|
bool isOff = GetDistance() > triggerDistance;
|
|
return isOff;
|
|
}
|