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

Motor Driver for XRCU. More...

#include <Motors.h>

Inheritance diagram for Mtr:
Supported_actuator Supported_module

Public Member Functions

 Mtr (const uint32_t pwm_ch, const uint32_t pwm_pin, const uint32_t dir_pin)
 Constructor for Mtr objects.
 
void begin ()
 Activates the motor.
 
void end ()
 Deactivates the motor and release the occupied resources.
 
bool get_reverse_flag ()
 Gets whether the motor spinning direction is reversed when driving to the motor.
 
void set_reverse_flag (bool reverse)
 Sets whether the motor spinning direction is reversed when driving to the motor.
 
int16_t set_spd (int16_t spd)
 Sets the motor to spin at a new speed, and return its motor speed after setting.
 
int16_t operator= (const int16_t spd)
 Sets the motor to spin at a new speed, and return its motor speed after setting.
 
int16_t operator+= (const int16_t spd_inc)
 Increases this motor speed by spd_inc.
 
int16_t operator-= (const int16_t spd_dec)
 Decreases this motor speed by spd_dec.
 
int16_t operator++ ()
 Increases this motor speed by 1.
 
int16_t operator-- ()
 Decreases this motor speed by 1.
 
int16_t get_spd ()
 Gets the motor speed.
 
 operator int16_t ()
 Gets the motor speed.
 

Additional Inherited Members

- Protected Member Functions inherited from Supported_actuator
 Supported_actuator ()
 Creates an object of a supported actuator.
 
- Protected Member Functions inherited from Supported_module
 Supported_module ()
 Creates an object of a supported module.
 

Detailed Description

Motor Driver for XRCU.

Author
YH Choi @ JM9

Constructor & Destructor Documentation

◆ Mtr()

Mtr::Mtr ( const uint32_t pwm_ch,
const uint32_t pwm_pin,
const uint32_t dir_pin )

Constructor for Mtr objects.

Parameters
pwm_chthe pwm channel
pwm_pinthe pwm pin (digital output w/ PWM feature)
dir_pinthe direction pin (digital output w/o PWM feature)

Member Function Documentation

◆ get_reverse_flag()

bool Mtr::get_reverse_flag ( )

Gets whether the motor spinning direction is reversed when driving to the motor.

Returns
true if the motor spinning direction is reversed, false otherwise

◆ get_spd()

int16_t Mtr::get_spd ( )

Gets the motor speed.

Returns
the motor speed

◆ operator int16_t()

Mtr::operator int16_t ( )

Gets the motor speed.

Returns
the motor speed

◆ operator++()

int16_t Mtr::operator++ ( )

Increases this motor speed by 1.

Returns
the final motor speed

◆ operator+=()

int16_t Mtr::operator+= ( const int16_t spd_inc)

Increases this motor speed by spd_inc.

Parameters
spd_incthe motor speed to be added to current motor speed
Returns
the final motor speed

◆ operator--()

int16_t Mtr::operator-- ( )

Decreases this motor speed by 1.

Returns
the final motor speed

◆ operator-=()

int16_t Mtr::operator-= ( const int16_t spd_dec)

Decreases this motor speed by spd_dec.

Parameters
spd_decthe motor speed to be subtracted from current motor speed
Returns
the final motor speed

◆ operator=()

int16_t Mtr::operator= ( const int16_t spd)

Sets the motor to spin at a new speed, and return its motor speed after setting.

Parameters
spdthe new motor speed
Returns
the actual motor speed set to the motor

◆ set_reverse_flag()

void Mtr::set_reverse_flag ( bool reverse)

Sets whether the motor spinning direction is reversed when driving to the motor.

Parameters
reversetrue if the motor spinning direction is reversed, false otherwise

◆ set_spd()

int16_t Mtr::set_spd ( int16_t spd)

Sets the motor to spin at a new speed, and return its motor speed after setting.

Parameters
spdthe new motor speed
Returns
the actual motor speed set to the motor

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