Example #1
0
void loop(){
  // Send state
  int l = leftMotor->getNewTicks();
  int r = rightMotor->getNewTicks();
  sendState(l, r);
  updateMotors();
  delay(DELTA_TIME);
}
Example #2
0
/*
    motor1 : LT
    motor2 : LB
    motor3 : RT
    motor4 : RB
    motor5 : BACK
    motor6 : BACK

*/
int main() {

    OSCclass *c=new OSCclass;
    OSCmsg *recv;

    
    uint8_t channel = 7;
    // Set the Channel. 0 is the default, 15 is max
    //mrf.SetChannel(channel);
    char add[5];
    char *command;
    
    pc.printf("Start----- Haptic Vest!\r\n");
    
    
    while(1) {

        rxLen = rf_receive(rxBuffer, 128);
       // pc.printf("RxLen %d", rxLen);
        if(rxLen > 0) {
                    
            recv= c->getOSCmsg(rxBuffer);

            printf("Address is %s with type %c and msg %c \r\n",recv->getAddr(),recv->getType(),recv->getArgs());
            
            strncpy(add,recv->getAddr(),5);
           
            if(add[1] == 'B'){
            
                    
                        motorStatus = find_status(add);
        
                        pc.printf("motor status: %d\r\n", motorStatus);
        
                        motor6 = motorStatus%10;//BACK
                        //motor5 = motor6;
                        motor4 = (motorStatus / 10) % 10;//RB
                        motor3 = (motorStatus / 100) % 10;//RT
                        //solenoid2=motor3;
                        motor2 = (motorStatus / 1000) % 10;//LB
                        motor1 = (motorStatus / 10000) % 10;//LT
                        //solenoid1=motor1;
                        //printf("%d %d %d %d %d %d \r\n",motor1,motor2,motor3,motor4,motor5,motor6);
                        
                        updateMotors();

                }
        }

    }
}
Example #3
0
// Program begins here
int main() {
    CyGlobalIntEnable; /* Enable global interrupts. */
    
    hardware_init();
    
    for(;;){
        handleFrames();                         //deal with any relevant incoming frames
        
        updateMotors(); 
        
        read_current_and_encoder();             //read the adc values and the quadrature encoder values
        CyDelayUs(100);                         //this delay is just to prevent it form dropping too many frames
    }
}