#include "ultrasound_sensor.hpp"

#include <cstddef>

extern "C" {
	void *ultrasonic_init(uint8_t trigger, uint8_t echo, uint8_t temperature);
	void ultrasonic_clean(void *ultrasonic);
	uint32_t ultrasonic_get_distance(void *ultrasonic);
}

ultrasound_sensor::ultrasound_sensor(uint8_t trigger, uint8_t echo, uint8_t temprature)
{
	ultrasonic = ultrasonic_init(trigger, echo, temprature);
}

ultrasound_sensor::~ultrasound_sensor()
{
    ultrasonic_clean(ultrasonic);
	ultrasonic = NULL;
}

uint32_t ultrasound_sensor::get_value() const
{
	return ultrasonic_get_distance(ultrasonic);
}