Starting point for the student buggy project
Fork of microbit-hello-world by
Buggy.h@4:2d939ef2b09c, 2017-08-06 (annotated)
- Committer:
- OyaideA
- Date:
- Sun Aug 06 20:13:33 2017 +0000
- Revision:
- 4:2d939ef2b09c
- Parent:
- 3:c3a42966b47c
- Child:
- 5:a33f016d5962
Now includes motor characterisation code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
OyaideA | 2:47b7a55b0805 | 1 | /* |
OyaideA | 2:47b7a55b0805 | 2 | This file contains the main function prototypes for the Buggy project |
OyaideA | 2:47b7a55b0805 | 3 | */ |
OyaideA | 2:47b7a55b0805 | 4 | #ifndef _BUGGY_H_ |
OyaideA | 2:47b7a55b0805 | 5 | #define _BUGGY_H_ |
OyaideA | 2:47b7a55b0805 | 6 | |
OyaideA | 2:47b7a55b0805 | 7 | #include "MicroBit.h" |
OyaideA | 2:47b7a55b0805 | 8 | |
OyaideA | 2:47b7a55b0805 | 9 | /******************************************************************* |
OyaideA | 2:47b7a55b0805 | 10 | Definition of global constants to control how to move the buggy |
OyaideA | 2:47b7a55b0805 | 11 | *******************************************************************/ |
OyaideA | 2:47b7a55b0805 | 12 | #define MOVE_FORWARD 0 |
OyaideA | 2:47b7a55b0805 | 13 | #define MOVE_BACKWARD 1 |
OyaideA | 2:47b7a55b0805 | 14 | #define ROTATE_CLOCKWISE 2 |
OyaideA | 2:47b7a55b0805 | 15 | #define ROTATE_ANTICLOCKWISE 3 |
OyaideA | 2:47b7a55b0805 | 16 | |
OyaideA | 2:47b7a55b0805 | 17 | |
OyaideA | 2:47b7a55b0805 | 18 | |
OyaideA | 2:47b7a55b0805 | 19 | void PauseLastCommand(); |
OyaideA | 2:47b7a55b0805 | 20 | void ContinueLastCommand(); |
OyaideA | 2:47b7a55b0805 | 21 | bool hasLastCommandCompleted(); |
OyaideA | 2:47b7a55b0805 | 22 | void InitialiseBuggy(); |
OyaideA | 2:47b7a55b0805 | 23 | unsigned int GetSonarTime_us(); |
OyaideA | 2:47b7a55b0805 | 24 | |
OyaideA | 2:47b7a55b0805 | 25 | /****************************************************************************** |
OyaideA | 2:47b7a55b0805 | 26 | Function to run a basic test of the buggy's motors. The buggy will perform the |
OyaideA | 2:47b7a55b0805 | 27 | following moves: move backwards, move forwards, rotate clockwise, rotate |
OyaideA | 2:47b7a55b0805 | 28 | anticlockwise. Each movement will continue for a user-defined time period. There |
OyaideA | 2:47b7a55b0805 | 29 | will be a pause period between each movement. |
OyaideA | 2:47b7a55b0805 | 30 | The function inputs are: |
OyaideA | 2:47b7a55b0805 | 31 | Voltage: the voltage you want to run the motor at. 0(off) to 1024(fast) |
OyaideA | 2:47b7a55b0805 | 32 | Time_ms: the length of time you want each movement to occur for |
OyaideA | 2:47b7a55b0805 | 33 | Pause_ms: the pause period between each motor move |
OyaideA | 2:47b7a55b0805 | 34 | *******************************************************************************/ |
OyaideA | 2:47b7a55b0805 | 35 | void RunBasicBuggyMotorTest(unsigned int Voltage, unsigned int Time_ms, unsigned int Pause_ms); |
OyaideA | 2:47b7a55b0805 | 36 | |
OyaideA | 2:47b7a55b0805 | 37 | void TestSonar(); |
OyaideA | 2:47b7a55b0805 | 38 | |
OyaideA | 2:47b7a55b0805 | 39 | void PrintSonarTiming(void); |
OyaideA | 2:47b7a55b0805 | 40 | |
OyaideA | 3:c3a42966b47c | 41 | void TestAntiCollision(unsigned int Voltage, unsigned int Time_ms, unsigned int SonarTime_us); |
OyaideA | 3:c3a42966b47c | 42 | |
OyaideA | 4:2d939ef2b09c | 43 | void MotorSpeedCharacterisation(void); |
OyaideA | 4:2d939ef2b09c | 44 | |
OyaideA | 2:47b7a55b0805 | 45 | extern MicroBit uBit; |
OyaideA | 2:47b7a55b0805 | 46 | |
OyaideA | 2:47b7a55b0805 | 47 | |
OyaideA | 2:47b7a55b0805 | 48 | |
OyaideA | 2:47b7a55b0805 | 49 | #endif |
OyaideA | 3:c3a42966b47c | 50 |