Squirrels have fuzzy tails.
0 Members and 1 Guest are viewing this topic.
#include "hardware.h"#include "armbotbuild.h" //#include "scheduler.h"#include <Gait/GaitRunner.h>#define SCHEDULER_MAX_JOBS 8int anim1AlreadyPlayed = 0;int anim2AlreadyPlayed = 0;int anim3AlreadyPlayed = 0;int anim4AlreadyPlayed = 0;int zeroAlreadyPressed = 0;int oneAlreadyPressed = 0;int twoAlreadyPressed = 0;int distance = 0;int speed = 0;int lastTime = 0;int data = 0;ACTUATOR_LIST PROGMEM all[] = {&GripperGrabber.actuator,&GripperRotate.actuator,&GripperSideways.actuator,&GripperUpDown.actuator,&ElbowUpDown.actuator,&ShoulderUpDown.actuator,&ShoulderRotate.actuator };G8_RUNNER gait = MAKE_G8_RUNNER(all, animations);void appInitHardware(void) { initHardware(); gaitRunnerInit(&gait);}TICK_COUNT appInitSoftware(TICK_COUNT loopStart){ rprintf("Robot Started\r\n"); //servosDisconnect(&gait); gaitRunnerPlay(&gait, 2, 5000, 10, 1); return 500000;}void checkSonar(void * data, TICK_COUNT lasttime, TICK_COUNT overflow){ // lasttime is the microsecond time of when I should have been called // overflow is the number of microseconds of error between lasttime // and when actually called distanceRead(sonar); rprintf("Distance=%u\r\n",sonar.distance.cm); scheduleJob(&checkSonar,data,clockGetus(),1000000); //scheduleJob(&marqueeUpdate,data,lastTime,delay);}TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) { scheduleJob(&checkSonar,null,clockGetus(), 0); //servosConnect(&gait); gaitRunnerProcess(&gait); if(SWITCH_pressed(&button0)){ gaitRunnerPlay(&gait, 0, 5000, 30, 2); gaitRunnerProcess(&gait); } if(SWITCH_released(&button0)){ zeroAlreadyPressed = 0; } if(SWITCH_pressed(&button1)){ gaitRunnerPlay(&gait, 1, 5000, 75, 1); gaitRunnerProcess(&gait); } if(SWITCH_released(&button1)){ oneAlreadyPressed = 0; } if(SWITCH_pressed(&button2)){ gaitRunnerPlay(&gait, 3, 5000, 22, 10); gaitRunnerProcess(&gait); } if(SWITCH_released(&button2)){ twoAlreadyPressed = 0; } return 0;}
#include "scheduler.h"
#include <scheduler.h>
TICK_COUNT lastSonarRead = 0;TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) { if (loopStart - lastSonarRead >= 1000000){ lastSonarRead = loopStart; ---read the sonar --- }}
#include "hardware.h"#include "armbotbuild.h"#include <Gait/GaitRunner.h> int zeroAlreadyPressed = 0;int oneAlreadyPressed = 0;int twoAlreadyPressed = 0; //int lasttime = 0;//int * data = 0;//int i = 0; ACTUATOR_LIST PROGMEM all[] = {&GripperGrabber.actuator,&GripperRotate.actuator,&GripperSideways.actuator,&GripperUpDown.actuator,&ElbowUpDown.actuator,&ShoulderUpDown.actuator,&ShoulderRotate.actuator }; G8_RUNNER gait = MAKE_G8_RUNNER(all, animations); void appInitHardware(void) { initHardware(); gaitRunnerInit(&gait);}//void checkSonar(void * data, TICK_COUNT lasttime, TICK_COUNT overflow){// rprintf("about to check sonar\r\n");// distanceRead(sonar);// rprintf("about to display sonar\r\n");// rprintf("Distance=%u\r\n",sonar.distance.cm);// scheduleJob(&checkSonar,data,lasttime,1000000);// rprintf("sonar rescheduled for 1 second\r\n");//}TICK_COUNT lastSonarRead = 0;TICK_COUNT appInitSoftware(TICK_COUNT loopStart){ rprintf("Robot Started\r\n"); gaitRunnerPlay(&gait, 2, 5000, 10, 1); //scheduleJob(&checkSonar,&data,lasttime, 0); return 0;} TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) { if (loopStart - lastSonarRead >= 1000000){ lastSonarRead = loopStart; distanceRead(sonar); rprintf("Distance=%u\r\n",sonar.distance.cm); } // if( i >=10000) {// distanceRead(sonar);// rprintf("Distance=%u\r\n",sonar.distance.cm);// i = 0;// }// i++; if(SWITCH_pressed(&button0)){ if (zeroAlreadyPressed == 0) { rprintf("Button 0 Pressed\r\n"); distanceRead(sonar); rprintf("Distance=%u\r\n",sonar.distance.cm); gaitRunnerPlay(&gait, 0, 5000, 30, 2); gaitRunnerProcess(&gait); zeroAlreadyPressed = 1; } } if(SWITCH_released(&button0)){ zeroAlreadyPressed = 0; } if(SWITCH_pressed(&button1)){ if (oneAlreadyPressed == 0) { rprintf("Button 1 Pressed\r\n"); distanceRead(sonar); rprintf("Distance=%u\r\n",sonar.distance.cm); gaitRunnerPlay(&gait, 1, 5000, 75, 1); gaitRunnerProcess(&gait); oneAlreadyPressed = 1; } } if(SWITCH_released(&button1)){ oneAlreadyPressed = 0; } if(SWITCH_pressed(&button2)){ if (twoAlreadyPressed == 0) { rprintf("Button 2 Pressed\r\n"); distanceRead(sonar); rprintf("Distance=%u\r\n",sonar.distance.cm); gaitRunnerPlay(&gait, 3, 5000, 22, 10); gaitRunnerProcess(&gait); twoAlreadyPressed = 1; } } if(SWITCH_released(&button2)){ twoAlreadyPressed = 0; } return 0;}