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@6:9eb153e1d472, 2015-08-15 (annotated)
- Committer:
- overkiller
- Date:
- Sat Aug 15 11:47:53 2015 +0000
- Revision:
- 6:9eb153e1d472
- Parent:
- 5:1afe17a20a5b
- Child:
- 7:baec885e57db
bugfix
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 | 6:9eb153e1d472 | 19 | enableAllButton.mode(PullDown); |
| overkiller | 2:09cc6b203fe4 | 20 | return 0; |
| overkiller | 2:09cc6b203fe4 | 21 | } |
| overkiller | 1:90d75436758b | 22 | int main() |
| overkiller | 1:90d75436758b | 23 | { |
| overkiller | 5:1afe17a20a5b | 24 | if(initDrivingUnit(1) == 0) |
| overkiller | 5:1afe17a20a5b | 25 | { |
| overkiller | 5:1afe17a20a5b | 26 | pc.printf("Ready to accept commands.\n\r Netrunner will start moving in 1 second"); |
| overkiller | 5:1afe17a20a5b | 27 | displayPrompt(&pc); |
| overkiller | 5:1afe17a20a5b | 28 | } |
| overkiller | 5:1afe17a20a5b | 29 | wait(1); |
| overkiller | 1:90d75436758b | 30 | while (true) |
| overkiller | 1:90d75436758b | 31 | { |
| overkiller | 6:9eb153e1d472 | 32 | checkEnableButtonState(); |
| overkiller | 6:9eb153e1d472 | 33 | // displayMessage("clicks: %f", &pc, buttonClicks); |
| overkiller | 4:cc391b3f3e57 | 34 | int action = getMenuInput(&pc); |
| overkiller | 6:9eb153e1d472 | 35 | actualDistance = getDistance(0); |
| overkiller | 6:9eb153e1d472 | 36 | if(actualDistance <= 10) |
| overkiller | 5:1afe17a20a5b | 37 | { |
| overkiller | 5:1afe17a20a5b | 38 | resetEngines(); |
| overkiller | 5:1afe17a20a5b | 39 | }else |
| overkiller | 5:1afe17a20a5b | 40 | { |
| overkiller | 5:1afe17a20a5b | 41 | forward(); |
| overkiller | 5:1afe17a20a5b | 42 | } |
| overkiller | 5:1afe17a20a5b | 43 | applyStates(); |
| overkiller | 0:5cf38d7bbdd5 | 44 | } |
| overkiller | 0:5cf38d7bbdd5 | 45 | } |