JM9 XRCU Board 0.1.1
Libraries API Reference
Loading...
Searching...
No Matches
Uts_general Class Reference

Ultrasonic Sensor Driver (Generic) for XRCU. More...

#include <Uts_general.h>

Inheritance diagram for Uts_general:
Supported_sensor Supported_module Uts_togglable Uts_us016 Uts_gpio Uts_i2c Uts_uart Vl53l0x Uts_gpio_int Uts_tic

Public Member Functions

virtual bool begin ()
 Activates this ultrasonic sensor.
 
virtual void end ()
 Deactivates this ultrasonic sensor.
 
virtual uint16_t read_dist_mm ()
 Reads the distance between this ultrasonic sensor and the obstacle in front of it.
 
uint16_t read_dist_cm ()
 Reads the distance between this ultrasonic sensor and the obstacle in front of it.
 

Protected Member Functions

virtual void set_beginned (bool is_beginned)
 Sets whether this ultrasonic sensor is activated.
 
bool is_beginned ()
 Checks if this ultrasonic sensor is already activated.
 
void store_prev_dist_mm (uint16_t dist_mm)
 Stores the previous measured distance.
 
uint16_t get_prev_dist_mm ()
 Gets the previous measured distance.
 
 Uts_general ()
 Constructor for a generic ultrasonic sensor driver.
 
- Protected Member Functions inherited from Supported_sensor
 Supported_sensor ()
 Creates an object of a supported sensor.
 
- Protected Member Functions inherited from Supported_module
 Supported_module ()
 Creates an object of a supported module.
 

Static Protected Attributes

static const uint16_t ERROR_DIST_MM = 8888
 The distance representing a measurement error (in millimeters).
 

Detailed Description

Ultrasonic Sensor Driver (Generic) for XRCU.

Generic Ultrasonic Sensor Driver. This class defines the Greatest Common Denominator GCD (or Highest Common Factor HCF) of API for all ultrasonic sensor drivers.

Author
YH Choi @ JM9

Constructor & Destructor Documentation

◆ Uts_general()

Uts_general::Uts_general ( )
protected

Constructor for a generic ultrasonic sensor driver.

Uts_general.cpp - Generic Ultrasonic Sensor Driver for XRCU. Copyright (c) 2024 - 2025 YH Choi @ JM9. All right reserved.

Member Function Documentation

◆ begin()

bool Uts_general::begin ( )
virtual

Activates this ultrasonic sensor.

YOU MUST CALL ME IN void setup () FUNCTION TO USE THIS OBJECT PROPERLY. Configures the settings of the pin mode(s), possible communication bus(es) and this ultrasonic sensor.

Returns
true if sensor is successfully activated, false otherwise

Reimplemented in Uts_gpio, Uts_gpio_int, Uts_i2c, Uts_tic, Uts_togglable, Uts_uart, and Vl53l0x.

◆ end()

void Uts_general::end ( )
virtual

Deactivates this ultrasonic sensor.

Releases the communication pins and ports and clears the memory used for this ultrasonic sensor.

Reimplemented in Uts_gpio, Uts_gpio_int, Uts_i2c, Uts_tic, Uts_togglable, and Uts_uart.

◆ get_prev_dist_mm()

uint16_t Uts_general::get_prev_dist_mm ( )
inlineprotected

Gets the previous measured distance.

Returns
the previous measured distance (in millimeters)

◆ is_beginned()

bool Uts_general::is_beginned ( )
inlineprotected

Checks if this ultrasonic sensor is already activated.

Returns
true if this ultrasonic sensor is already activated, false otherwise

◆ read_dist_cm()

uint16_t Uts_general::read_dist_cm ( )
inline

Reads the distance between this ultrasonic sensor and the obstacle in front of it.

Returns
the distance between this ultrasonic sensor and the obstacle in front of it (in centimeters)

◆ read_dist_mm()

uint16_t Uts_general::read_dist_mm ( )
virtual

Reads the distance between this ultrasonic sensor and the obstacle in front of it.

Returns
the distance between this ultrasonic sensor and the obstacle in front of it (in millimeters)

Reimplemented in Uts_gpio, Uts_gpio_int, Uts_tic, Uts_us016, and Vl53l0x.

◆ set_beginned()

void Uts_general::set_beginned ( bool is_beginned)
protectedvirtual

Sets whether this ultrasonic sensor is activated.

Parameters
is_beginnedtrue to set the beginned flag, false to clear the beginned flag

Reimplemented in Uts_togglable.

◆ store_prev_dist_mm()

void Uts_general::store_prev_dist_mm ( uint16_t dist_mm)
inlineprotected

Stores the previous measured distance.

Parameters
dist_mmthe previous measured distance (in millimeters)

The documentation for this class was generated from the following files: