A code for the spindling of bots.
Dependencies: MX12 ServoRingBuffer mbed-src
Fork of SpindleBot by
Diff: Old_Code.h
- Revision:
- 2:dfeadd6c651c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Old_Code.h Mon Jan 26 04:38:06 2015 +0000 @@ -0,0 +1,81 @@ +///// Old serial code: + //// Setup: + //c.attach(&keyStroke,Serial::RxIrq); // setup keyStroke ISR + + //// ISR: + + /*/ Function keyStroke: Serial ISR for keystroke + void keyStroke(){ + if(keyStrokeFlag){ + //FREAK OUT!!!! + pc.printf("keyStroke Function had unexpected error!!!!\r\n"); + } + keyStrokeVal = pc.getc(); // This stores the keystroke character into a variable called keyStrokeVal + keyStrokeFlag = true; // This sets the keyStrokeFlag to true to show that data is ready + }*/ + + //// Main Loop: + /*/ This section of code should run only if a key stroke has been input by the user + if (keyStrokeFlag == true) { + switch(keyStrokeVal) { + case 'm': + case 'M': + pc.printf("%% ************* Manual Grasp Mode **********************\r\n"); + break; + case 'a': + case 'A': + pc.printf("%% ************* Auto Grasp Mode ************************\r\n"); + break; + case 'r': + case 'R': + collect_data=!collect_data; + //pc.printf("% New value=%d\n",collect_data); + if(collect_data==false){ + //Let's just be done with our current file, by setting our count to the max + file_count=SAMPLES_PER_FILE; + } + pc.printf("%% ************* Toggled Data Collection ****************\r\n"); + break; + case '\r': + case '\n': + //Don't do anything + break; + default: + pc.printf("Please press a vaild key. The key you pressed was: %c\r\n", keyStrokeVal ); + } + keyStrokeFlag = false; + }*/ + +////////// Old SD file code + + /* + int num_objects=0; + + // Read the number of files in the /sd/data directory, so we can name ours to be next + mkdir("/sd/data", 0777); + DIR *dp; + dp = opendir("/sd/data"); + struct dirent *dirp; + //read all directory and file names in current directory into filename vector + while((dirp = readdir(dp)) != NULL) { + dirp->d_name; + num_objects++; + } + closedir(dp); + num_objects++; + */ + //// In while loop: + /*char buf[0x100]; + file_num++; + pc.printf( "New file: /sd/data/%04d%04d.csv\n", num_objects, file_num); + fflush(pc); + snprintf(buf, sizeof(buf), "/sd/data/%04d%04d.csv", num_objects, file_num); + FILE *fp = fopen(buf, "w"); + //FILE *fp = fopen("/sd/data/sdtest.txt", "w"); + if(fp == NULL) { + error("Could not open file for write\n"); + } + fprintf(fp, "%%Position0,Force0,Position1,Force1,Time\n"); + */ + + \ No newline at end of file