B4A Library IOIO board library

The request in this thread here introduced me to a product called IOIO that seems to have been designed by some Google engineers in the 20% of time that Google gives them to pursue their own interests,

The blog of the main mover of the project is at Microcontrollers, Electronics & Robotics: Meet IOIO - I/O for Android

The board will be available soon from here IOIO for Android - SparkFun Electronics

As the software has just been released I took a look at it and wrapped it in a couple of libraries for use with Basic4android. I obviously cannot test it as I have no board but the Basic4android library is a very thin veneer on top of the normal Android library so, typos and idiot errors aside, it should work with no problems and the software documentation should be pretty much applicable. I have copied a lot of the library help from the software documention so a B4A help viewer should give you a good grounding in how to use it.

I don't yet know if the board will be available this side of the pond - if anyone wants to ship me one for testing .... :)

EDIT :- Version 1.1 posted with INTERNET permission. See post #11 for details.

EDIT :- Version 1.2 posted with PulseInput. See post #37 for details.

EDIT :- Version 1.2 reposted with XML error fixed. See post #39 for details.

EDIT :- Version 1.3 posted with SPI and I2C support. See post #40 for details.

EDIT :- Version 1.3a posted with IOIOlib 3.2 included. See post #42 for details.

EDIT :- Version 1.4 posted. See post #47 for details.

EDIT :- IOIOlibBT 3.10 posted. See post#58 for details.

EDIT:- IOIOBT1.4 posted See post #63 for details

EDIT:- IOIOBT1.5 posted See post #77 for details.

THESE ATTACHMENTS ARE NOW OBSOLETE. SEE POST #105 FOR THE LATEST VERSIONS BY KOLBE: http://www.b4x.com/android/forum/threads/ioio-board-library.8942/page-6#post-90731
 

Attachments

  • IOIOBT1.5.zip
    102.3 KB · Views: 2,317
  • IOIO1.4.zip
    100.5 KB · Views: 1,750
Last edited by a moderator:

kolbe

Active Member
Licensed User
Longtime User
Is it related to this bug fixed in 3.26?

I think the fix is in the Firmware and not the IOIOlib but I could be wrong. This is my only guess. I've used SPI but never TWI so I have nothing to test your code with.
 

headingwest

Member
Licensed User
Longtime User
More IOIO TWI issues

I got the IOIO talking I2C / TWI with my picaxe. When I put it into a loop to get continuous readings (5 per second) the application froze after a short while, maybe 4 or 5 seconds.

Resetting the Picaxe chip didn't fix the problem, so I suspected the IOIO.

I changed my function call from TWI.WriteRead to TWI.WriteReadAsync but now I get a strange error when I test the return value. I get "Java.Lang.NoSuchFieldException: ready_" on the line that reads if TWI.Status(0) = true.

See code:

B4X:
Sub ControlLoop_Tick
   NotificationTool
   
   If TWI.IsInitialized Then
      If  bTWIstatus = 1 Then
         If TWI.Status(0) = True Then      'HERE IS THE CRASH - Java.Lang.NoSuchFieldException: ready_
            If TWI.Status(1) = True Then
               lblLeft.Text = grd1(0) & " R " & grd1(1)
               lblright.Text = grd1(2) & " L " & grd1(3)
               GetDistanceAsync
            End If
         End If      
      Else
         GetDistanceAsync
      End If
   End If
End Sub

HELP!
 

kolbe

Active Member
Licensed User
Longtime User
I don't see anything obviously lacking in the library code. I suspect some kind of a race condition. Try less samples per second and see if the exception goes away. There is a wait involved with the twi.status call, it should wait for the writereadasync to finish. Because this is all running on the main thread maybe there are gui events that are keeping the twi code from completing. Are you updating things on the activity? You could also try writing the data to an array and periodically refreshing the screen, as apposed to updating the screen 5 times a second.

Could I get a traceback from the logs? Are you using firmware 3.26?


I got the IOIO talking I2C / TWI with my picaxe. When I put it into a loop to get continuous readings (5 per second) the application froze after a short while, maybe 4 or 5 seconds.

Resetting the Picaxe chip didn't fix the problem, so I suspected the IOIO.

I changed my function call from TWI.WriteRead to TWI.WriteReadAsync but now I get a strange error when I test the return value. I get "Java.Lang.NoSuchFieldException: ready_" on the line that reads if TWI.Status(0) = true.

See code:

B4X:
Sub ControlLoop_Tick
   NotificationTool
   
   If TWI.IsInitialized Then
      If  bTWIstatus = 1 Then
         If TWI.Status(0) = True Then      'HERE IS THE CRASH - Java.Lang.NoSuchFieldException: ready_
            If TWI.Status(1) = True Then
               lblLeft.Text = grd1(0) & " R " & grd1(1)
               lblright.Text = grd1(2) & " L " & grd1(3)
               GetDistanceAsync
            End If
         End If      
      Else
         GetDistanceAsync
      End If
   End If
End Sub

HELP!
 

kolbe

Active Member
Licensed User
Longtime User
@headingwest

Another thought. With your TWI.WriteRead version, see how much time it takes on average to complete the call. Since it is a blocking call, get a time stamp before and after and subtract the difference. This will give you an idea of the max samples per second possible. It was probably freezing because one call wasn't done, blocked, meanwhile others are being scheduled, the app is then non responsive because all it is doing is dealing with all the backed up calls.

I checked this lag for a project I was doing and it averaged around 50ms for the simplest of calls, digitalout hardwired to a digitalin. With i2c I wouldn't be surprised if it was greater than the 200ms you are expecting.
 

kolbe

Active Member
Licensed User
Longtime User
Multiple IOIOs

I've done some testing with two IOIOs. It turns out that with the current library v1.7, you can already connect two, one by BT the other by USB. OK, so that isn't what you asked but its good news. Be sure to use the ioio.connect method to connect the IOIOs.

How can I connect the IOIO to a specific BlueTooth MAC address?

I have multiple IOIO's, and I can only connect to the last physically paired IOIO bluetooth dongle.
 

headingwest

Member
Licensed User
Longtime User
I2C crash

Hi Kolbe,

I was using a USB cable to connnect and had measured the response time from 8 to 15ms. So much faster than I expected.

This project is quite simple so no services and still testing basic stuff. So a crash with i2c at this stage makes me nervous.

I've ended up moving to UART which with the Async ability seems to use less of the Androids processing power as the data is waiting in the buffer. Also crash free so far!

Thanks again for your assistance. Btw I'm trying to keep the full source code available on my site.

Cheers,

JIm.
 

kolbe

Active Member
Licensed User
Longtime User
new IOIO library uploaded

I just uploaded the next version of the IOIO library.

Because most of the methods need to be threaded, many of the interfaces have changed.... most notably all the Open methods have changed. Remember that code modules cannot receive events.

The IOIO Workbench app pretty much shows you how to code everything.

Have fun.
 
Last edited:

headingwest

Member
Licensed User
Longtime User
Latest IOI

Thanks Kolbe!!!

Can't wait to get it installed and running. Can you confirm that this is for the IOIO V1 which uses 3.26 and not for IOIO-OTG which uses 3.3?

Thanks.
 

kolbe

Active Member
Licensed User
Longtime User
I only have a v1 at the moment so I can confirm v3.26. If I understand things correctly however, it should work with v2 as well.

I see we have a new application version now too, v4. I'll see about updating to that soon.
 
Last edited:

kolbe

Active Member
Licensed User
Longtime User
FYI, coslad in the Italian forum has reported that the IOIO library does indeed work with the IOIO-OTG.

I'm already working on v1.9 with CapSense. There is however a bug in Ytai's 4.00 library so I waiting for that to be fixed before releasing it.
 

coslad

Well-Known Member
Licensed User
Longtime User
Hi ,
i didn't undestand witch library i have to use with ioio otg and bluetooth adpter .
Your library 1.8 is only for usb ?

Thanks
 

kolbe

Active Member
Licensed User
Longtime User
Perhaps I didn't understand. Did you get the IOIO-OTG to work with v1.8?

v1.8 should work with all IOIOs.

The only problem is that with Android 4.1 and above USB-ADB will not work. Google has now made this connection secured and Ytai doesn't plan on implementing a secured USB-ADB.

Bluetooth will work with all versions.

Unfortunately I haven't been able to get USB Open Accessory to work.

Hope this clears things up.


Hi ,
i didn't undestand witch library i have to use with ioio otg and bluetooth adpter .
Your library 1.8 is only for usb ?

Thanks
 

coslad

Well-Known Member
Licensed User
Longtime User
Hi,
Excuse my English, now I try to explain me better.

I have seen that there was for b4a the ioio lib and the ioiobt lib, now , can I use only the 1.8 version to connect both USB and Bluetooth ( not in the same time together ) changing only the parameter to true in the connect function?
Or I need two library, one to USB and other to Bluetooth?

Wish I explained well, thanks

Inviato dal mio H9500 con Tapatalk 2
 

coslad

Well-Known Member
Licensed User
Longtime User
Hi ,
I answer to myself , i tried your library with Bt and IOIO-OTG and works fine.

I tested on a Galaxy s without problem , but on a ZP900 a MTK6577 based phone (homepage ZOPO ZP900 ),a strange thing happens , afer this commad :

If btadmin.IsEnabled Then YOYO.connect("io",True,1,0)

the event Sub io_connected(noerror As Boolean ) doesn't recalled (never) .

If i disconnect the the ioioboard in the bluetooth device list of the phone , obviously the connect function return false .

I tried even with different millisec in the connection function , but never the _connected sub is called .

If i connect with usb ( YOYO.connect("io",false,1,0) ) it works fine

Maybe can help to know that in the list of bluetooth connected device on the phone , the ioio appear as headphone icon .


PS: To Erel , please update the IOIO wiki .

Thanks
 
Last edited:

kolbe

Active Member
Licensed User
Longtime User
As you figured out there since v1.7 there is only one library and it works with both USB and BT.

If it doesn't connect but doesn't throw any exceptions then most likely there is a problem with BT pairing. Check the logcat from your device that works with the one that doesn't. The IOIO works well with some BT dongles and not with others. Try the workbench app that I included to see if the library detects a properly paired IOIO. Ytai's gethub page has a list of dongles that users report work correctly.

Sorry about the IOIO wiki I'll update it soon.

Hi ,
I answer to myself , i tried your library with Bt and IOIO-OTG and works fine.

I tested on a Galaxy s without problem , but on a ZP900 a MTK6577 based phone (homepage ZOPO ZP900 ),a strange thing happens , afer this commad :

If btadmin.IsEnabled Then YOYO.connect("io",True,1,0)

the event Sub io_connected(noerror As Boolean ) doesn't recalled (never) .

If i disconnect the the ioioboard in the bluetooth device list of the phone , obviously the connect function return false .

I tried even with different millisec in the connection function , but never the _connected sub is called .

If i connect with usb ( YOYO.connect("io",false,1,0) ) it works fine

Maybe can help to know that in the list of bluetooth connected device on the phone , the ioio appear as headphone icon .


PS: To Erel , please update the IOIO wiki .

Thanks
 

markon

New Member
Licensed User
Longtime User
I am willing to work with Kolbe on this

My understanding is that all should still work with the v2 board. Don't have a v2 to test so anyone that does let me know. Ytai even said that the v3.3 app firmware should work on both boards. So until there is new functionality the current library is still serving me well.

I am willing to work on this with Kolbe. Let me know.
I would like to do the following
1. Upgrade to the 3.30 release of the IOIOlib, IOIOAccesory, IOIOBT
2. Make to work with OpenAcc.

Let me know and we can start.

William Mark Esser. :)
 

kolbe

Active Member
Licensed User
Longtime User
If you could get OpenAcc to work that would be great. Check your PM, I sent you a reply.

I have a v1.9 built on 4.00 already. I guess I can release it as a beta. I know there is a bug in the capsense functionality that is why I haven't released it.

I am willing to work on this with Kolbe. Let me know.
I would like to do the following
1. Upgrade to the 3.30 release of the IOIOlib, IOIOAccesory, IOIOBT
2. Make to work with OpenAcc.

Let me know and we can start.

William Mark Esser. :)
 

bluedude

Well-Known Member
Licensed User
Longtime User
B4A with the IOIO mint board and shield

Koble,

What I mean is if you think the B4A library can run this IOIO mint.

Cheers,
 
Top