Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@5:1afe17a20a5b, 2015-08-13 (annotated)
- Committer:
- overkiller
- Date:
- Thu Aug 13 15:52:19 2015 +0000
- Revision:
- 5:1afe17a20a5b
- Parent:
- 4:cc391b3f3e57
- Child:
- 6:9eb153e1d472
sensor code
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| overkiller | 0:5cf38d7bbdd5 | 1 | #include "mbed.h" |
| overkiller | 1:90d75436758b | 2 | #include "include/EngineDriver.h" |
| overkiller | 3:def8a92db030 | 3 | #include "include/SerialPrompt.h" |
| overkiller | 5:1afe17a20a5b | 4 | #include "include/SR04.h" |
| overkiller | 4:cc391b3f3e57 | 5 | Serial pc(USBTX, USBRX); |
| overkiller | 4:cc391b3f3e57 | 6 | |
| overkiller | 2:09cc6b203fe4 | 7 | int initDrivingUnit(int testLoops) |
| overkiller | 2:09cc6b203fe4 | 8 | { |
| overkiller | 2:09cc6b203fe4 | 9 | pc.printf("Testing engines...\n\r"); |
| overkiller | 2:09cc6b203fe4 | 10 | enableAll(); |
| overkiller | 2:09cc6b203fe4 | 11 | int i = 0; |
| overkiller | 2:09cc6b203fe4 | 12 | while(i < testLoops) |
| overkiller | 2:09cc6b203fe4 | 13 | { |
| overkiller | 2:09cc6b203fe4 | 14 | testEngines(); |
| overkiller | 2:09cc6b203fe4 | 15 | applyStates(); |
| overkiller | 2:09cc6b203fe4 | 16 | i++; |
| overkiller | 2:09cc6b203fe4 | 17 | } |
| overkiller | 2:09cc6b203fe4 | 18 | resetEngines(); |
| overkiller | 2:09cc6b203fe4 | 19 | return 0; |
| overkiller | 2:09cc6b203fe4 | 20 | } |
| overkiller | 1:90d75436758b | 21 | int main() |
| overkiller | 1:90d75436758b | 22 | { |
| overkiller | 5:1afe17a20a5b | 23 | if(initDrivingUnit(1) == 0) |
| overkiller | 5:1afe17a20a5b | 24 | { |
| overkiller | 5:1afe17a20a5b | 25 | pc.printf("Ready to accept commands.\n\r Netrunner will start moving in 1 second"); |
| overkiller | 5:1afe17a20a5b | 26 | displayPrompt(&pc); |
| overkiller | 5:1afe17a20a5b | 27 | } |
| overkiller | 5:1afe17a20a5b | 28 | inState[0] = 0; |
| overkiller | 5:1afe17a20a5b | 29 | inState[1] = 1; |
| overkiller | 5:1afe17a20a5b | 30 | inState[2] = 1; |
| overkiller | 5:1afe17a20a5b | 31 | inState[3] = 0; |
| overkiller | 5:1afe17a20a5b | 32 | wait(1); |
| overkiller | 1:90d75436758b | 33 | while (true) |
| overkiller | 1:90d75436758b | 34 | { |
| overkiller | 4:cc391b3f3e57 | 35 | int action = getMenuInput(&pc); |
| overkiller | 5:1afe17a20a5b | 36 | float dist = getDistance(0); |
| overkiller | 5:1afe17a20a5b | 37 | displayMessage(distMsg, &pc, dist); |
| overkiller | 5:1afe17a20a5b | 38 | if(dist <= 10) |
| overkiller | 5:1afe17a20a5b | 39 | { |
| overkiller | 5:1afe17a20a5b | 40 | resetEngines(); |
| overkiller | 5:1afe17a20a5b | 41 | }else |
| overkiller | 5:1afe17a20a5b | 42 | { |
| overkiller | 5:1afe17a20a5b | 43 | forward(); |
| overkiller | 5:1afe17a20a5b | 44 | } |
| overkiller | 5:1afe17a20a5b | 45 | applyStates(); |
| overkiller | 0:5cf38d7bbdd5 | 46 | } |
| overkiller | 0:5cf38d7bbdd5 | 47 | } |