mpv 6050 over i2c to ioio. provides slow data. heres my code.

class Looper extends BaseIOIOLooper {
/** The on-board LED. */
private DigitalOutput led_;

    /**
     * Called every time a connection with IOIO has been established.
     * Typically used to open pins.
     * 
     * @throws ConnectionLostException
     *             When IOIO connection is lost.
     * @throws InterruptedException 
     * 
     * @see ioio.lib.util.AbstractIOIOActivity.IOIOThread#setup()
     */

    @Override
    public void setup() throws ConnectionLostException, InterruptedException {
        led_ = ioio_.openDigitalOutput(0, true);


        // Create the i2c port
        twi = ioio_.openTwiMaster(0, TwiMaster.Rate.RATE_1MHz, false);

        ///////////////////////
        //Get the whoamI register value to check if the sensor is connected

        byte[] request = new byte[] {0x75};
        byte[] response = new byte[1];
        //try {
        twi.writeRead(0x68, false, request, request.length, response, 
response.length);
        //} catch (InterruptedException e1) {
        //TODO Auto-generated catch block
        //e1.printStackTrace();
        //}
        /*
        //Make the power control bit high
        byte[] request1 = new byte[] {0x6B,0x00};
        //try {
        twi.writeRead(0x68, false, request1, request1.length, null,0);
        //} catch (InterruptedException e1) {
        //TODO Auto-generated catch block
        //e1.printStackTrace();
        //}
        //Set the range of accel
        request1[0] = 0x1C;
        request1[1] = 0x10;
        try {
        twi.writeRead(0x68, false, request1, request1.length, null,0);
        } catch (InterruptedException e1) {
        //TODO Auto-generated catch block
        e1.printStackTrace();
        }
        //////////////////////////////////////////////////////
     */         
    }

    /**
     * Called repetitively while the IOIO is connected.
     * 
     * @throws ConnectionLostException
     *             When IOIO connection is lost.
     * 
     * @see ioio.lib.util.AbstractIOIOActivity.IOIOThread#loop()
     */

    @Override
    public void loop() throws ConnectionLostException {

        //xhigh in request1 and response 1
        //int  tempxH=0;
        request[0] = 0x3B;
        try {
            twi.writeRead(0x68, false, request, request.length, response, 
response.length);
        } catch (InterruptedException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        tempxH=((int)(response[0]));
        //xlow in request1 and response 1
        request[0] = 0x3C;
        try {
            twi.writeRead(0x68, false, request, request.length, response, 
response.length);
        } catch (InterruptedException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        tempxH = (tempxH*255) + response[0];
        tempxH=tempxH*(0.00024);


        //yhigh in request 2

        //int  tempyH=0;
        request[0] = 0x3D;
        try {
            twi.writeRead(0x68, false, request, request.length, response, 
response.length);
        } catch (InterruptedException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        tempyH=((int)(response[0]));
        //ylow in request1 and response 1
        request[0] = 0x3E;
        try {
            twi.writeRead(0x68, false, request, request.length, response, 
response.length);
        } catch (InterruptedException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        tempyH = (tempyH*255) + response[0];
        tempyH=tempyH*(0.00024);

        //zhigh in request 2
        //int  tempzH=0;
        request[0] = 0x3F;
        try {
            twi.writeRead(0x68, false, request, request.length, response, 
response.length);
        } catch (InterruptedException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        tempzH=((int)(response[0]));
        //zlow in request1 and response 1
        request[0] = 0x40;
        try {
            twi.writeRead(0x68, false, request, request.length, response, 
response.length);
        } catch (InterruptedException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        tempzH = (tempzH*255) + response[0];
        tempzH=tempzH*(0.00024);

        str1 = Double.toString(tempxH);
        str2 =  Double.toString(tempyH);
        str3 =  Double.toString(tempzH);
        //xAxisText.setText("Hello");
        updateTextView(xAxisText,str1);
        updateTextView(yAxisText,str2);
        updateTextView(zAxisText,str3);
    }

}

 * A method to create our IOIO thread.

private void updateTextView(final TextView textView, final String text) {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            textView.setText(text);
        }
    });
}


protected IOIOLooper createIOIOLooper() {
    return new Looper();
}
}

i tried twimaster rate ie 400khz,100khz. but no use.
i tried running app on usb mode without using bluetooth dongle. im getting 
1000 values/ 3 sec which is slow for i2c connection when using usb mode.

-- 
You received this message because you are subscribed to the Google Groups 
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to