MRD Lab / SpindleBot_1_5b

Dependencies:   MX12 ServoRingBuffer mbed-src

Fork of SpindleBot by MRD Lab

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Old_Code.h Source File

Old_Code.h

00001 ///// Old serial code:
00002     //// Setup:
00003         //c.attach(&keyStroke,Serial::RxIrq); // setup keyStroke ISR
00004     
00005     //// ISR:
00006     
00007         /*/ Function keyStroke: Serial ISR for keystroke
00008         void keyStroke(){
00009             if(keyStrokeFlag){
00010                 //FREAK OUT!!!!
00011                 pc.printf("keyStroke Function had unexpected error!!!!\r\n");
00012             }
00013             keyStrokeVal = pc.getc();   // This stores the keystroke character into a variable called keyStrokeVal 
00014             keyStrokeFlag = true;       // This sets the keyStrokeFlag to true to show that data is ready
00015         }*/
00016 
00017     //// Main Loop:
00018             /*/ This section of code should run only if a key stroke has been input by the user
00019             if (keyStrokeFlag == true) {
00020                  switch(keyStrokeVal) {
00021                     case 'm':
00022                     case 'M':
00023                         pc.printf("%% *************  Manual Grasp Mode  **********************\r\n");
00024                         break;
00025                     case 'a':
00026                     case 'A':
00027                         pc.printf("%% *************  Auto Grasp Mode  ************************\r\n");
00028                         break;
00029                     case 'r':
00030                     case 'R':
00031                         collect_data=!collect_data;
00032                         //pc.printf("% New value=%d\n",collect_data);
00033                         if(collect_data==false){
00034                             //Let's just be done with our current file, by setting our count to the max
00035                             file_count=SAMPLES_PER_FILE;
00036                         }
00037                         pc.printf("%% *************  Toggled Data Collection  ****************\r\n");
00038                         break;
00039                     case '\r':
00040                     case '\n':
00041                         //Don't do anything
00042                         break;
00043                     default:
00044                         pc.printf("Please press a vaild key. The key you pressed was: %c\r\n", keyStrokeVal );
00045                  }
00046                 keyStrokeFlag = false;
00047             }*/
00048             
00049 ////////// Old SD file code
00050     
00051     /*
00052     int num_objects=0;
00053     
00054     // Read the number of files in the /sd/data directory, so we can name ours to be next
00055     mkdir("/sd/data", 0777);
00056     DIR *dp;
00057     dp = opendir("/sd/data");
00058     struct dirent *dirp;
00059     //read all directory and file names in current directory into filename vector
00060     while((dirp = readdir(dp)) != NULL) {
00061         dirp->d_name;
00062         num_objects++;
00063     }
00064     closedir(dp);
00065     num_objects++;
00066     */
00067         //// In while loop:
00068         /*char buf[0x100];
00069         file_num++;
00070         pc.printf( "New file: /sd/data/%04d%04d.csv\n", num_objects, file_num);
00071         fflush(pc);
00072         snprintf(buf, sizeof(buf), "/sd/data/%04d%04d.csv", num_objects, file_num);
00073         FILE *fp = fopen(buf, "w");
00074         //FILE *fp = fopen("/sd/data/sdtest.txt", "w");
00075         if(fp == NULL) {
00076             error("Could not open file for write\n");
00077         }
00078         fprintf(fp, "%%Position0,Force0,Position1,Force1,Time\n");
00079         */
00080         
00081