TI RSLK Library 0.2.2
Loading...
Searching...
No Matches
SimpleRSLK.h
Go to the documentation of this file.
1
2#include "RSLK_Pins.h"
3#include "QTRSensors.h"
4#include "GP2Y0A21_Sensor.h"
5#include "Encoder.h"
6#include "Romi_Motor_Power.h"
7#include "Bump_Switch.h"
8
9#ifndef SimpleRSLK_h
10#define SimpleRSLK_h
11
19#define LS_NUM_SENSORS 8
20
24#define DST_NUM_SENSORS 3
25
29#define NUM_MOTORS 2
30
34#define LP_LEFT_BTN PUSH2
35
39#define LP_RIGHT_BTN PUSH1
40
44#define TOTAL_BP_SW 6
45
49#define LEFT_MOTOR 0
50
54#define RIGHT_MOTOR 1
55
59#define BOTH_MOTORS 2
60
64#define LEFT_SHRP_DIST 0
65
69#define CENTER_SHRP_DIST 1
70
74#define RIGHT_SHRP_DIST 2
75
79#define MOTOR_DIR_FORWARD 0
80
84#define MOTOR_DIR_BACKWARD 1
85
89#define DARK_LINE 0
90
94#define LIGHT_LINE 1
95
100void setupRSLK();
101
114uint16_t readSharpDist(uint8_t num);
115
128int16_t readSharpDistMM(uint8_t num);
129
142float readSharpDistIN(uint8_t num);
143
153bool isBumpSwitchPressed(uint8_t num);
154
163uint8_t getBumpSwitchPressed();
164
173void enableMotor(uint8_t motorNum);
174
183void disableMotor(uint8_t motorNum);
184
193void pauseMotor(uint8_t motorNum);
194
203void resumeMotor(uint8_t motorNum);
204
217void setMotorDirection(uint8_t motorNum, uint8_t direction);
218
233void setMotorSpeed(uint8_t motorNum, uint8_t speed);
234
241void setupWaitBtn(uint8_t btn);
242
248void setupLed(uint8_t ledPin);
249
257void waitBtnPressed(uint8_t btnPin, int8_t ledPin = 0);
258
269void calibrateLineSensor(uint8_t mode = DARK_LINE, uint32_t duration = 500);
270
286void readCalLineSensor(uint16_t *calVal);
287
302uint32_t getLinePosition();
303
315void readRawLineSensor(uint16_t *sensor);
316
317/*************************************************************************
318 * deprecated methods
319 *************************************************************************/
320
335#define readLineSensor readRawLineSensor
336
349void clearMinMax(uint16_t *sensorMin, uint16_t *sensorMax);
350
364void setSensorMinMax(uint16_t *sensor, uint16_t *sensorMin, uint16_t *sensorMax);
365
395void readCalLineSensor(uint16_t *sensor,
396 uint16_t *calVal,
397 uint16_t *sensorMin,
398 uint16_t *sensorMax,
399 uint8_t mode);
400
422uint32_t getLinePosition(uint16_t *calVal, uint8_t mode);
423
426#endif // SimpleRSLK_h
#define DARK_LINE
Used to specify that the robot is running on a floor lighter than the line.
Definition SimpleRSLK.h:89
uint32_t getLinePosition()
Get line position.
void enableMotor(uint8_t motorNum)
Enable motor (take it out of sleep)
float readSharpDistIN(uint8_t num)
Read distance sensor value in inches.
void setMotorSpeed(uint8_t motorNum, uint8_t speed)
Set the motor speed.
bool isBumpSwitchPressed(uint8_t num)
Return bump switch status.
void setupRSLK()
Performs a variety of initialization needed for the RSLK.
void clearMinMax(uint16_t *sensorMin, uint16_t *sensorMax)
Provide default values for the sensor's Min and Max arrays.
void disableMotor(uint8_t motorNum)
Disable motor (puts the motor to sleep)
void setMotorDirection(uint8_t motorNum, uint8_t direction)
Set direction the motor will turn.
uint16_t readSharpDist(uint8_t num)
Read distance sensor value.
void readRawLineSensor(uint16_t *sensor)
Read raw line sensor values.
uint8_t getBumpSwitchPressed()
Return mask of bump switch states.
void waitBtnPressed(uint8_t btnPin, int8_t ledPin=0)
Busy wait until user pushes and releases button.
void setupWaitBtn(uint8_t btn)
Configure pin as a wait to release button.
void pauseMotor(uint8_t motorNum)
Pause motor (put the motor to sleep while saving its speed)
void readCalLineSensor(uint16_t *calVal)
Read calibrated line sensor values. Assumes calibration completed.
void setupLed(uint8_t ledPin)
Configure pin that is connected to an led.
void calibrateLineSensor(uint8_t mode=DARK_LINE, uint32_t duration=500)
Calibrates line sensor.
void resumeMotor(uint8_t motorNum)
Resume motor (take the motor out of sleep and resumes its prior speed)
int16_t readSharpDistMM(uint8_t num)
Read distance sensor value in millimeters.
void setSensorMinMax(uint16_t *sensor, uint16_t *sensorMin, uint16_t *sensorMax)
Update line sensor's min and max values array based on current data.