TargetManager manual test
Dependencies: TargetManager mbed
main.cpp@7:ca2863cba3ba, 2017-03-13 (annotated)
- Committer:
- dupm2216
- Date:
- Mon Mar 13 21:39:14 2017 +0000
- Revision:
- 7:ca2863cba3ba
- Parent:
- 6:07147a130219
- Child:
- 8:b9745dd296c2
Add instructions for manual testing of the NerfusTicker and the Bumper
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dupm2216 | 0:fc00abeafce9 | 1 | #include "mbed.h" |
dupm2216 | 3:0169a6a1ca10 | 2 | #include "Bumper.hpp" |
dupm2216 | 4:535d32238a43 | 3 | #include "TargetHitCallback.hpp" |
dupm2216 | 0:fc00abeafce9 | 4 | #include "TargetManager.hpp" |
dupm2216 | 5:e9c15bafd93f | 5 | #include "TargetMissedCallback.hpp" |
dupm2216 | 6:07147a130219 | 6 | #include "NerfusTicker.hpp" |
dupm2216 | 0:fc00abeafce9 | 7 | |
dupm2216 | 0:fc00abeafce9 | 8 | int main() |
dupm2216 | 0:fc00abeafce9 | 9 | { |
dupm2216 | 3:0169a6a1ca10 | 10 | printf("Start TargetManager manual test\r\n"); |
dupm2216 | 7:ca2863cba3ba | 11 | printf("Instruction:\r\n"); |
dupm2216 | 7:ca2863cba3ba | 12 | printf("\tNerfusTicker works if a target miss is printed every second\r\n"); |
dupm2216 | 7:ca2863cba3ba | 13 | printf("\tBumper works if a target hit is printed when you click the limit switch\r\n"); |
dupm2216 | 7:ca2863cba3ba | 14 | printf("\t\tLimit switch connections: C(p5), NO(VCC), NC(GND)\r\n"); |
dupm2216 | 3:0169a6a1ca10 | 15 | |
dupm2216 | 0:fc00abeafce9 | 16 | PinName bumper_pin = p5; |
dupm2216 | 0:fc00abeafce9 | 17 | |
dupm2216 | 6:07147a130219 | 18 | NerfusTicker target_timeout_ticker; |
dupm2216 | 6:07147a130219 | 19 | TargetManager target_manager(target_timeout_ticker); |
dupm2216 | 3:0169a6a1ca10 | 20 | |
dupm2216 | 4:535d32238a43 | 21 | TargetHitCallback target_hit_callback(target_manager, 42); |
dupm2216 | 5:e9c15bafd93f | 22 | TargetMissedCallback target_missed_callback(target_manager, 42); |
dupm2216 | 6:07147a130219 | 23 | target_timeout_ticker.init(&target_missed_callback); |
dupm2216 | 5:e9c15bafd93f | 24 | |
dupm2216 | 4:535d32238a43 | 25 | Bumper bumper(bumper_pin, target_hit_callback); |
dupm2216 | 4:535d32238a43 | 26 | |
dupm2216 | 0:fc00abeafce9 | 27 | while(true) |
dupm2216 | 0:fc00abeafce9 | 28 | { |
dupm2216 | 6:07147a130219 | 29 | target_timeout_ticker.start(500); |
dupm2216 | 3:0169a6a1ca10 | 30 | wait_ms(1000); |
dupm2216 | 0:fc00abeafce9 | 31 | } |
dupm2216 | 0:fc00abeafce9 | 32 | } |