Revision 1461
updated all the library code to have sensible _init behavior.
Almost all of the library components have a global variable which gets set after init and the functions inside will fail with an error code if init has not been called. Also, the init functions themselves check this variable and will bail out without doing any damage if that init has already been called
motor.h | ||
---|---|---|
38 | 38 |
#ifndef _MOTOR_H |
39 | 39 |
#define _MOTOR_H |
40 | 40 |
|
41 |
#include <dragonfly_lib.h> |
|
41 | 42 |
#include <avr/io.h> |
42 | 43 |
/** |
43 | 44 |
* @addtogroup motors |
... | ... | |
50 | 51 |
#define BACKWARD 0 |
51 | 52 |
|
52 | 53 |
/** @brief Initialize the motors **/ |
53 |
void motors_init(void);
|
|
54 |
int motors_init(void);
|
|
54 | 55 |
/** @brief Set speed and direction of motor1 |
55 | 56 |
* @deprecated use the left motor function instead. it's more intuitive and easier to read.**/ |
56 |
void motor1_set(int direction, int speed);
|
|
57 |
int motor1_set(int direction, int speed);
|
|
57 | 58 |
/** @brief Set speed and direction of motor2 |
58 | 59 |
* @deprecated use the right motor function instead. it's more intuitive and easier to read.**/ |
59 |
void motor2_set(int direction, int speed);
|
|
60 |
int motor2_set(int direction, int speed);
|
|
60 | 61 |
/** @brief Set speed and direction of left motor **/ |
61 |
void motor_l_set(int direction, int speed);
|
|
62 |
int motor_l_set(int direction, int speed);
|
|
62 | 63 |
/** @brief Set speed and direction of right motor **/ |
63 |
void motor_r_set(int direction, int speed);
|
|
64 |
int motor_r_set(int direction, int speed);
|
|
64 | 65 |
/** @brief Turn the motors off **/ |
65 |
void motors_off(void);
|
|
66 |
int motors_off(void);
|
|
66 | 67 |
|
67 | 68 |
/**@}**/ // end addtogroup |
68 | 69 |
|
Also available in: Unified diff