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.
Diff: UserInput.cpp
- Revision:
- 0:efdae9d24ee1
- Child:
- 1:b8f9693ae04f
- Child:
- 2:4dd54b3934a5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UserInput.cpp Wed Jul 22 13:12:14 2015 +0000 @@ -0,0 +1,83 @@ +#include "mbed.h" +#include "stdio.h" +#include <string> + +extern Serial pc; +extern Serial mbed2; + +LocalFileSystem local("local"); + +char company [100], pipe [100]; +//noOfSensor: is the number of sensors of the former +//distance: is the distance between the sensors in 'mm' +//S: straiting +//B: bending +int noOfSensorS, distanceS, noOfSensorB; + + +void inputNoOfPins(){ + FILE *pFile = fopen ("/local/details.txt" , "r"); + if (pFile == NULL){ + pc.printf("Error opening file"); + }else { + if ( fgets (company, 100 , pFile) != NULL ){ + pc.printf ("%s\n", company); + } + if ( fgets (pipe, 100 , pFile) != NULL ){ + pc.printf ("%s\n", pipe); + fclose (pFile); + } + } +} + +int UI_NumberOfSensorsB(){ + + FILE *p1File = fopen ("/local/details.txt" , "r"); + if (p1File == NULL){ + pc.printf("Error opening file"); + }else { + pc.printf ("%d\n", noOfSensorB = fgetc (p1File)); + fclose (p1File); + } +} + +int UI_DistanceB(){ + + int distanceB; + + pc.printf("UI_DistanceB"); + FILE *p2File = fopen ("/local/details.txt" , "r"); + if (p2File == NULL){ + pc.printf("Error opening file"); + }else { + for(int i = 0; i < 3; i++){ + pc.printf("inside"); + distanceB = atoi (fgets (p2File).c_str()); + } + distanceB = atoi (fgets (p2File)); + pc.printf ("%i\n", distanceB); + fclose (p2File); + } +} + +int UI_NumberOfSensorsS(){ + + FILE *p3File = fopen ("/local/details.txt" , "r"); + if (p3File == NULL){ + pc.printf("Error opening file"); + }else { + pc.printf ("%d\n", noOfSensorB = fgetc (p3File)); + fclose (p3File); + } +} + +int UI_DistanceS(){ + + FILE *p4File = fopen ("/local/details.txt" , "r"); + if (p4File == NULL){ + pc.printf("Error opening file"); + }else { + pc.printf ("%d\n", distanceS= fgetc (p4File)); + fclose (p4File); + } +} \ No newline at end of file