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.
Dependencies: mbed
Fork of Robocode by
source/main.cpp@22:c8e187b9d949, 2017-03-03 (annotated)
- Committer:
- cittecla
- Date:
- Fri Mar 03 20:44:01 2017 +0000
- Revision:
- 22:c8e187b9d949
- Parent:
- 21:cb40c0533bc2
- Child:
- 23:4ddc4216f335
test
;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| cittecla | 18:a82994e67297 | 1 | /** |
| cittecla | 18:a82994e67297 | 2 | * Main File of Robocode |
| cittecla | 18:a82994e67297 | 3 | * Handels parallel processing and interupts |
| cittecla | 18:a82994e67297 | 4 | * Version 0.0.1 |
| cittecla | 18:a82994e67297 | 5 | * PES2 Gruppe 1 |
| cittecla | 18:a82994e67297 | 6 | **/ |
| cittecla | 18:a82994e67297 | 7 | |
| cittecla | 18:a82994e67297 | 8 | #include "mbed.h" |
| cittecla | 18:a82994e67297 | 9 | #include "pathfinding.h" |
| cittecla | 18:a82994e67297 | 10 | #include "time.h" |
| cittecla | 18:a82994e67297 | 11 | #include "IRsensor.h" |
| cittecla | 18:a82994e67297 | 12 | #include "move.h" |
| cittecla | 18:a82994e67297 | 13 | |
| cittecla | 18:a82994e67297 | 14 | //static double time_counter = 0.0f; |
| cittecla | 18:a82994e67297 | 15 | //static double deltatime = 0.0f; |
| cittecla | 18:a82994e67297 | 16 | |
| cittecla | 22:c8e187b9d949 | 17 | InterruptIn EncoderLeftA(PB_6); |
| cittecla | 22:c8e187b9d949 | 18 | InterruptIn EncoderLeftB(PB_7); |
| cittecla | 22:c8e187b9d949 | 19 | InterruptIn EncoderRightA(PA_6); |
| cittecla | 22:c8e187b9d949 | 20 | InterruptIn EncoderRightB(PC_7); |
| cittecla | 22:c8e187b9d949 | 21 | |
| cittecla | 21:cb40c0533bc2 | 22 | //DigitalOut led(LED1); // Board LED |
| cittecla | 18:a82994e67297 | 23 | |
| cittecla | 18:a82994e67297 | 24 | //Perophery for distance sensors |
| cittecla | 18:a82994e67297 | 25 | AnalogIn distance(PB_1); |
| cittecla | 18:a82994e67297 | 26 | DigitalOut enable(PC_1); |
| cittecla | 18:a82994e67297 | 27 | DigitalOut bit0(PH_1); |
| cittecla | 18:a82994e67297 | 28 | DigitalOut bit1(PC_2); |
| cittecla | 18:a82994e67297 | 29 | DigitalOut bit2(PC_3); |
| cittecla | 18:a82994e67297 | 30 | IRSensor sensors[6]; |
| cittecla | 18:a82994e67297 | 31 | |
| cittecla | 18:a82994e67297 | 32 | //indicator leds arround robot |
| cittecla | 18:a82994e67297 | 33 | DigitalOut leds[] = { PC_8, PC_6, PB_12, PA_7, PC_0, PC_9 }; |
| cittecla | 18:a82994e67297 | 34 | |
| cittecla | 19:baa8371d55b4 | 35 | |
| cittecla | 18:a82994e67297 | 36 | |
| cittecla | 18:a82994e67297 | 37 | |
| cittecla | 18:a82994e67297 | 38 | static double time_counter = 0.0f; |
| cittecla | 18:a82994e67297 | 39 | static double timer0 = 0.0f; |
| cittecla | 18:a82994e67297 | 40 | bool status = 0; |
| cittecla | 18:a82994e67297 | 41 | |
| cittecla | 18:a82994e67297 | 42 | int main() |
| cittecla | 18:a82994e67297 | 43 | { |
| cittecla | 22:c8e187b9d949 | 44 | __enable_irq(); |
| cittecla | 22:c8e187b9d949 | 45 | |
| cittecla | 22:c8e187b9d949 | 46 | EncoderLeftA.rise(&highPulseDetectedL); |
| cittecla | 22:c8e187b9d949 | 47 | EncoderLeftB.rise(&highPulseDetectedL); |
| cittecla | 22:c8e187b9d949 | 48 | EncoderRightA.rise(&highPulseDetectedR); |
| cittecla | 22:c8e187b9d949 | 49 | EncoderRightB.rise(&highPulseDetectedR); |
| cittecla | 22:c8e187b9d949 | 50 | |
| cittecla | 19:baa8371d55b4 | 51 | move_init(); |
| cittecla | 22:c8e187b9d949 | 52 | while(1){ |
| cittecla | 21:cb40c0533bc2 | 53 | sync_movement(false,true); |
| cittecla | 21:cb40c0533bc2 | 54 | } |
| cittecla | 22:c8e187b9d949 | 55 | |
| cittecla | 22:c8e187b9d949 | 56 | |
| cittecla | 18:a82994e67297 | 57 | /* while(1){ |
| cittecla | 18:a82994e67297 | 58 | if(status == 1){ |
| cittecla | 18:a82994e67297 | 59 | led = 0; |
| cittecla | 18:a82994e67297 | 60 | wait(0.5); |
| cittecla | 18:a82994e67297 | 61 | status = 0; |
| cittecla | 18:a82994e67297 | 62 | }else{ |
| cittecla | 18:a82994e67297 | 63 | led = 1; |
| cittecla | 18:a82994e67297 | 64 | timer0 = 0.0f; |
| cittecla | 18:a82994e67297 | 65 | pathfinding(); |
| cittecla | 18:a82994e67297 | 66 | status = 1; |
| cittecla | 18:a82994e67297 | 67 | } |
| cittecla | 18:a82994e67297 | 68 | }*/ |
| cittecla | 18:a82994e67297 | 69 | } |
| cittecla | 18:a82994e67297 | 70 | |
| cittecla | 21:cb40c0533bc2 | 71 | |
| cittecla | 22:c8e187b9d949 | 72 |
