# ecrobot::Motor Class Reference

NXT Motor class. More...

`#include <Motor.h>`

List of all members.

## Public Member Functions
| Motor (ePortM port, bool brake=true)
| Constructor (set brake by default).
| ~Motor (void)
| Destructor (stop the motor).
void | reset (void)
| Stop motor and set motor encoder count to 0.
S32 | getCount (void) const
| Get motor encoder count.
void | setCount (S32 count)
| Set motor encoder count.
void | setPWM (S8 pwm)
| Set motor PWM value.
void | setBrake (bool brake)
| Set brake.
## Static Public Attributes
static const S8 | PWM_MAX = 100
| Maximum PWM value.
static const S8 | PWM_MIN = -100
| Minimum PWM value.
## Protected Member Functions
ePortM | getPort (void) const
| Get motor connected port.
bool | getBrake (void) const
| Get brake status.
S8 | getPWM (void) const
| Get current PWM value.

## Detailed Description

NXT Motor class.

## Constructor & Destructor Documentation

ecrobot::Motor::Motor | ( | ePortM | port,
|  | bool | brake = `true` |
| ) |  |  | `[explicit]`

Constructor (set brake by default).

Note:
This class must be constructed as a global object. Otherwise, a device assertion will be displayed
in the LCD when the object is constructed as a non global object.

Parameters:

  | port | Motor connected port
  | brake | true:brake/false:float

Returns:
  -

ecrobot::Motor::~Motor | ( | void |  | ) |

Destructor (stop the motor).

Parameters:

  | - |

Returns:
  -

## Member Function Documentation

bool ecrobot::Motor::getBrake | ( | void |  | ) | const`[inline, protected]`

Get brake status.

Parameters:

  | - |

Returns:
  true:brake/false:float

S32 ecrobot::Motor::getCount | ( | void |  | ) | const`[inline]`

Get motor encoder count.

Parameters:

  | - |

Returns:
  Motor encoder count in degree.

ePortM ecrobot::Motor::getPort | ( | void |  | ) | const`[inline, protected]`

Get motor connected port.

Parameters:

  | - |

Returns:
  Motor connected port

S8 ecrobot::Motor::getPWM | ( | void |  | ) | const`[inline, protected]`

Get current PWM value.

Parameters:

  | - |

Returns:
  PWM set value

void ecrobot::Motor::reset | ( | void |  | ) | `[inline]`

Stop motor and set motor encoder count to 0.

Parameters:

  | - |

Returns:
  -

void ecrobot::Motor::setBrake | ( | bool | brake | ) |

Set brake.

Parameters:

  | brake | true:brake/false:float

Returns:
  -

void ecrobot::Motor::setCount | ( | S32 | count | ) | `[inline]`

Set motor encoder count.

Parameters:

  | count | Motor encoder count in degree.

Returns:
  -

void ecrobot::Motor::setPWM | ( | S8 | pwm | ) |

Set motor PWM value.

Parameters:

  | pwm | PWM_MAX to PWM_MIN

Returns:
  -

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

- device/Motor.h