JM9 XRCU Board 0.1.2
Libraries API Reference
Loading...
Searching...
No Matches
Uts_gpio Class Reference

Ultrasonic Sensor Driver (TRIG-ECHO Polling) for XRCU. More...

#include <Uts_gpio.h>

Inheritance diagram for Uts_gpio:
Uts_togglable Uts_general Supported_sensor Supported_module Uts_gpio_int Uts_tic

Public Member Functions

 Uts_gpio (const uint8_t init_port)
 Creates a new Uts_gpio object.
 
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.
 
- Public Member Functions inherited from Uts_togglable
virtual void disable ()
 Teporarily disables this ultrasonic sensor.
 
virtual void enable ()
 Re-enables this ultrasonic sensor.
 
- Public Member Functions inherited from Uts_general
uint16_t read_dist_cm ()
 Reads the distance between this ultrasonic sensor and the obstacle in front of it.
 

Protected Member Functions

bool send_trig (bool wait_min_separation)
 Triggers a new measurement if the previous measurement has ended.
 
uint8_t get_port ()
 Gets the port connected to this ultrasonic sensor.
 
uint32_t get_trig_pin ()
 Gets the trigger pin connected to this ultrasonic sensor.
 
uint32_t get_echo_pin ()
 Gets the echo pin connected to this ultrasonic sensor.
 
bool actual_begin ()
 Activates this ultrasonic sensor.
 
void actual_end ()
 Deactivates this ultrasonic sensor.
 
- Protected Member Functions inherited from Uts_togglable
void set_beginned (bool is_beginned)
 Sets whether this ultrasonic sensor is activated.
 
void set_enabled (bool is_enabled)
 Sets whether this ultrasonic sensor is enabled or not.
 
bool is_enabled ()
 Checks if this ultrasonic sensor is enabled or not.
 
 Uts_togglable ()
 Constructor for a togglable ultrasonic sensor driver.
 
- Protected Member Functions inherited from Uts_general
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.
 

Additional Inherited Members

- Static Protected Attributes inherited from Uts_general
static const uint16_t ERROR_DIST_MM = 8888
 The distance representing a measurement error (in millimeters).
 

Detailed Description

Ultrasonic Sensor Driver (TRIG-ECHO Polling) for XRCU.

Ultrasonic Sensor Driver. Mode: 2-GPIO-pin TRIG-ECHO mode Pulse Measurement: polling (by pulseIn(...))

Note
Implementation automatically switches to Timer Input-Capture (class Uts_tic) if the port supports this implementation.
Author
YH Choi @ JM9

Constructor & Destructor Documentation

◆ Uts_gpio()

Uts_gpio::Uts_gpio ( const uint8_t init_port)

Creates a new Uts_gpio object.

Parameters
init_portthe port connected to this ultrasonic sensor

Member Function Documentation

◆ actual_begin()

bool Uts_gpio::actual_begin ( )
protected

Activates this ultrasonic sensor.

The actual begin implementation for TRIG-ECHO polling. 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

◆ actual_end()

void Uts_gpio::actual_end ( )
protected

Deactivates this ultrasonic sensor.

The actual end implementation for TRIG-ECHO polling. Releases the communication pins and ports and clears the memory used for this ultrasonic sensor.

◆ begin()

bool Uts_gpio::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 from Uts_togglable.

Reimplemented in Uts_gpio_int, and Uts_tic.

◆ end()

void Uts_gpio::end ( )
virtual

Deactivates this ultrasonic sensor.

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

Reimplemented from Uts_togglable.

Reimplemented in Uts_gpio_int, and Uts_tic.

◆ get_echo_pin()

uint32_t Uts_gpio::get_echo_pin ( )
inlineprotected

Gets the echo pin connected to this ultrasonic sensor.

Returns
the echo pin connected to this ultrasonic sensor

◆ get_port()

uint8_t Uts_gpio::get_port ( )
inlineprotected

Gets the port connected to this ultrasonic sensor.

Returns
the port connected to this ultrasonic sensor

◆ get_trig_pin()

uint32_t Uts_gpio::get_trig_pin ( )
inlineprotected

Gets the trigger pin connected to this ultrasonic sensor.

Returns
the trigger pin connected to this ultrasonic sensor

◆ read_dist_mm()

uint16_t Uts_gpio::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 from Uts_general.

Reimplemented in Uts_gpio_int, and Uts_tic.

◆ send_trig()

bool Uts_gpio::send_trig ( bool wait_min_separation)
protected

Triggers a new measurement if the previous measurement has ended.

Parameters
wait_min_separationtrue to wait for minimum separation, false otherwise
Returns
true if a trigger is successfully sent; false indicate unsuccessful

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