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@24:6c2fec64f890, 2017-03-04 (annotated)
- Committer:
- cittecla
- Date:
- Sat Mar 04 15:04:14 2017 +0000
- Revision:
- 24:6c2fec64f890
- Parent:
- 23:4ddc4216f335
- Child:
- 25:08ee4525155b
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 | 24:6c2fec64f890 | 17 | //InterruptIn EncoderLeftA(PB_6); |
| cittecla | 24:6c2fec64f890 | 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 | 24:6c2fec64f890 | 22 | DigitalIn encoder(PB_6); |
| cittecla | 24:6c2fec64f890 | 23 | |
| cittecla | 21:cb40c0533bc2 | 24 | //DigitalOut led(LED1); // Board LED |
| cittecla | 18:a82994e67297 | 25 | |
| cittecla | 18:a82994e67297 | 26 | //Perophery for distance sensors |
| cittecla | 18:a82994e67297 | 27 | AnalogIn distance(PB_1); |
| cittecla | 18:a82994e67297 | 28 | DigitalOut enable(PC_1); |
| cittecla | 18:a82994e67297 | 29 | DigitalOut bit0(PH_1); |
| cittecla | 18:a82994e67297 | 30 | DigitalOut bit1(PC_2); |
| cittecla | 18:a82994e67297 | 31 | DigitalOut bit2(PC_3); |
| cittecla | 18:a82994e67297 | 32 | IRSensor sensors[6]; |
| cittecla | 18:a82994e67297 | 33 | |
| cittecla | 18:a82994e67297 | 34 | //indicator leds arround robot |
| cittecla | 18:a82994e67297 | 35 | DigitalOut leds[] = { PC_8, PC_6, PB_12, PA_7, PC_0, PC_9 }; |
| cittecla | 24:6c2fec64f890 | 36 | DigitalOut led(LED1); // Board LED |
| cittecla | 19:baa8371d55b4 | 37 | |
| cittecla | 18:a82994e67297 | 38 | |
| cittecla | 18:a82994e67297 | 39 | |
| cittecla | 18:a82994e67297 | 40 | static double time_counter = 0.0f; |
| cittecla | 18:a82994e67297 | 41 | static double timer0 = 0.0f; |
| cittecla | 18:a82994e67297 | 42 | bool status = 0; |
| cittecla | 18:a82994e67297 | 43 | |
| cittecla | 18:a82994e67297 | 44 | int main() |
| cittecla | 18:a82994e67297 | 45 | { |
| cittecla | 24:6c2fec64f890 | 46 | __enable_irq(); |
| cittecla | 22:c8e187b9d949 | 47 | |
| cittecla | 24:6c2fec64f890 | 48 | // EncoderLeftA.rise(&highPulseDetectedL); |
| cittecla | 24:6c2fec64f890 | 49 | //EncoderLeftB.rise(&highPulseDetectedL); |
| cittecla | 23:4ddc4216f335 | 50 | //EncoderRightA.rise(&highPulseDetectedR); // wird erkannt |
| cittecla | 23:4ddc4216f335 | 51 | //EncoderRightB.rise(&highPulseDetectedR); // wird erkannt |
| cittecla | 22:c8e187b9d949 | 52 | |
| cittecla | 19:baa8371d55b4 | 53 | move_init(); |
| cittecla | 24:6c2fec64f890 | 54 | while(1) { |
| cittecla | 24:6c2fec64f890 | 55 | //sync_movement(false,true); |
| cittecla | 24:6c2fec64f890 | 56 | if(encoder) { |
| cittecla | 24:6c2fec64f890 | 57 | led = 1; |
| cittecla | 24:6c2fec64f890 | 58 | } else { |
| cittecla | 18:a82994e67297 | 59 | led = 0; |
| cittecla | 18:a82994e67297 | 60 | } |
| cittecla | 24:6c2fec64f890 | 61 | } |
| cittecla | 24:6c2fec64f890 | 62 | |
| cittecla | 24:6c2fec64f890 | 63 | |
| cittecla | 24:6c2fec64f890 | 64 | /* while(1){ |
| cittecla | 24:6c2fec64f890 | 65 | if(status == 1){ |
| cittecla | 24:6c2fec64f890 | 66 | led = 0; |
| cittecla | 24:6c2fec64f890 | 67 | wait(0.5); |
| cittecla | 24:6c2fec64f890 | 68 | status = 0; |
| cittecla | 24:6c2fec64f890 | 69 | }else{ |
| cittecla | 24:6c2fec64f890 | 70 | led = 1; |
| cittecla | 24:6c2fec64f890 | 71 | timer0 = 0.0f; |
| cittecla | 24:6c2fec64f890 | 72 | pathfinding(); |
| cittecla | 24:6c2fec64f890 | 73 | status = 1; |
| cittecla | 24:6c2fec64f890 | 74 | } |
| cittecla | 24:6c2fec64f890 | 75 | }*/ |
| cittecla | 18:a82994e67297 | 76 | } |
| cittecla | 18:a82994e67297 | 77 | |
| cittecla | 21:cb40c0533bc2 | 78 | |
| cittecla | 22:c8e187b9d949 | 79 |
