02/07/15
Dependencies: mbed
UserInput.cpp@59:2cbbd6fea55b, 2015-07-29 (annotated)
- Committer:
- aidanPJG
- Date:
- Wed Jul 29 15:27:15 2015 +0000
- Revision:
- 59:2cbbd6fea55b
- Parent:
- 56:bf08d9e50ccc
- Child:
- 70:168d67695a65
Working with GUItabbed to an extent. Need to get the read working
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aidanPJG | 48:e9578f56534a | 1 | #include "mbed.h" |
aidanPJG | 54:9322b1b76e13 | 2 | #include <utility> |
aidanPJG | 56:bf08d9e50ccc | 3 | #include <string> |
aidanPJG | 48:e9578f56534a | 4 | |
aidanPJG | 48:e9578f56534a | 5 | extern Serial pc; |
aidanPJG | 48:e9578f56534a | 6 | int sensorNumber; |
aidanPJG | 49:889751dd0395 | 7 | double sensorDistance; |
aidanPJG | 48:e9578f56534a | 8 | |
aidanPJG | 56:bf08d9e50ccc | 9 | int inputNoOfPins() |
aidanPJG | 56:bf08d9e50ccc | 10 | { |
aidanPJG | 59:2cbbd6fea55b | 11 | // pc.printf("Ready to Read.\n"); |
aidanPJG | 59:2cbbd6fea55b | 12 | // pc.printf("Enter the number of sensors\n"); |
aidanPJG | 48:e9578f56534a | 13 | while (1){ |
aidanPJG | 48:e9578f56534a | 14 | if (pc.readable()) |
aidanPJG | 48:e9578f56534a | 15 | { |
aidanPJG | 48:e9578f56534a | 16 | pc.scanf("%d", &sensorNumber); |
aidanPJG | 54:9322b1b76e13 | 17 | break; |
aidanPJG | 54:9322b1b76e13 | 18 | } |
aidanPJG | 56:bf08d9e50ccc | 19 | } |
aidanPJG | 59:2cbbd6fea55b | 20 | // pc.printf("sensorNumber : %d \t " ,sensorNumber ); |
aidanPJG | 54:9322b1b76e13 | 21 | return(sensorNumber); |
aidanPJG | 56:bf08d9e50ccc | 22 | } |
aidanPJG | 54:9322b1b76e13 | 23 | double inputDistance(){ |
aidanPJG | 59:2cbbd6fea55b | 24 | // pc.printf("Enter the distance between each sensor\n "); |
aidanPJG | 54:9322b1b76e13 | 25 | while (1){ |
aidanPJG | 54:9322b1b76e13 | 26 | if (pc.readable()) |
aidanPJG | 54:9322b1b76e13 | 27 | { |
aidanPJG | 49:889751dd0395 | 28 | pc.scanf("%lf", &sensorDistance); //has to &lf because must know the size of it before getting it in |
aidanPJG | 48:e9578f56534a | 29 | break; |
aidanPJG | 48:e9578f56534a | 30 | } |
aidanPJG | 48:e9578f56534a | 31 | } |
aidanPJG | 59:2cbbd6fea55b | 32 | // pc.printf( "SensorDistance : %f", sensorDistance ); |
aidanPJG | 54:9322b1b76e13 | 33 | return(sensorDistance); |
aidanPJG | 54:9322b1b76e13 | 34 | } |