#pragma once

#include "GenericSensor.h"
#include <NewPing.h>


class SonarSensor : public GenericSensor {
private:
	NewPing sonar{ TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE };
public:
	SonarSensor(short id) : GenericSensor(id) {}

	void setup() {
		pinMode(VCC_PIN, OUTPUT);
		turnOff();
	}

	unsigned int scan() {
		return sonar.convert_cm(sonar.ping_median());
	}

	void turnOn() {
		digitalWrite(VCC_PIN, HIGH);
	}

	void turnOff() {
		digitalWrite(VCC_PIN, LOW);
	}
};
