Program for the water play project for the course Software Testing Practical 2016 given at the VU University
Dependencies: mbed DRV88255 TextLCD Ping mbed-rtos
ProximityController.cpp@10:fd4670ec0806, 2016-06-10 (annotated)
- Committer:
- sbouber1
- Date:
- Fri Jun 10 22:21:04 2016 +0000
- Revision:
- 10:fd4670ec0806
- Parent:
- 5:44ce56378b65
- Child:
- 24:eeef4009640d
Optional threading
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
joran | 5:44ce56378b65 | 1 | #include "ProximityController.h" |
sbouber1 | 10:fd4670ec0806 | 2 | #include "rtos.h" |
joran | 5:44ce56378b65 | 3 | |
joran | 5:44ce56378b65 | 4 | Ping pinger(p30); |
joran | 5:44ce56378b65 | 5 | |
joran | 5:44ce56378b65 | 6 | |
sbouber1 | 10:fd4670ec0806 | 7 | void ProximityController::update() { |
joran | 5:44ce56378b65 | 8 | int range; |
joran | 5:44ce56378b65 | 9 | |
joran | 5:44ce56378b65 | 10 | pinger.Send(); |
sbouber1 | 10:fd4670ec0806 | 11 | Thread::wait(30); |
joran | 5:44ce56378b65 | 12 | range = pinger.Read_cm()/ 2; |
sbouber1 | 10:fd4670ec0806 | 13 | this->distance = (float)range; |
sbouber1 | 10:fd4670ec0806 | 14 | } |
sbouber1 | 10:fd4670ec0806 | 15 | |
sbouber1 | 10:fd4670ec0806 | 16 | |
sbouber1 | 10:fd4670ec0806 | 17 | float ProximityController::getValue() { |
sbouber1 | 10:fd4670ec0806 | 18 | return this->distance; |
sbouber1 | 10:fd4670ec0806 | 19 | } |
sbouber1 | 10:fd4670ec0806 | 20 | |
sbouber1 | 10:fd4670ec0806 | 21 | std::string ProximityController::get_name() { |
sbouber1 | 10:fd4670ec0806 | 22 | return "ProximityController"; |
sbouber1 | 10:fd4670ec0806 | 23 | } |