B4A Library IOIO board library

Discussion in 'Additional libraries, classes and official updates' started by agraham, Apr 30, 2011.

  1. Jiemde

    Jiemde Member Licensed User

    Hi All, in 1 month I've do more with B4A than with Java/androîd in 6 month! that's fantastic!
    But sometimes I don't know how to do something, example:
    I try to use the BMP180 from Bosch, I can open the I2C connection, read the E²Prom registers like 0xAA and OxAB but in the documentation it's necessary to "group" these 2 octets, but I do not find how ?
    Is someone can help me ?

    Best regards

  2. Kevin L. Johnson

    Kevin L. Johnson Member Licensed User

    In preparation for Dual Servos (Az & El) ...

    I thought that I'd simply take my single servo example app from ...


    and renamed the servo variable to first 'servoAz' and then tried 'Azservo'.

    It seems that when preparing the code (carefully renaming variables and events) for dual servos some of the fired event names are particular (almost as if they are hardcoded) and don't like to be changed to differentiate which servo (like 'pwmoutput_open' to 'Azpwmoutput_open' because the minute I change variable names to reflect not just a servo but the Azimuth (Panning) Servo it will not fire the renamed events and therefore objects don't get initialized and therefore the code will not work properly.


    It appears that the following line of code ...
    can NOT handle uppercase letters in the event name therefore ...

    pwmout is OK
    pwmoutaz is OK
    pwmoutAz or Azpwmout is NOT OK

    Kolbe is this behavior by design or is it a bug?
    AND before you answer that ... THANK YOU and Agraham both for all your previous hard work and current dedication to this library.
    Last edited: Sep 5, 2014
  3. Jiemde

    Jiemde Member Licensed User


    Is somebody can help me about the BMP180 sensor ?

    Best regards
  4. kolbe

    kolbe Active Member Licensed User

    Hello all, good to see the activity while I was gone. To answer the question below, because you are creating an event you can only use lower case. This is a b4a thing. I hope to answer some of the other questions today.

    Last edited: Sep 13, 2014
  5. kolbe

    kolbe Active Member Licensed User

    Spend some time reading this thread and you will figure it out. You are getting the error because you are missing the IOIO library. Good luck.

    P.S. Reading your other posts, it looks like you figured it out.

    Last edited: Sep 13, 2014
  6. kolbe

    kolbe Active Member Licensed User

    About connections. I generally use Bluetooth because I find it the most flexible. Connecting and reconnecting is the simplest out of all the options, just don't forget to init btadmin or it won't work. I use the TrendNet TBW 106UB. I like this one because it is Class 1.

    The only reason I find to use OpenAccessory is if you want the fastest transfer and lowest jitter possible. If you have a project that requires this, like a balancing robot, then this is essential.

    The Device option is cool because you can power the IOIO from the Android device.

    The ioio.ReceiverRegister should only be called once when the app process in created and then ioio.ReceiverUnregister when the app is closing, the process killed (activity_pause userclosed=true, or exitapplication). I don't think any harm is done when the app pauses to leave it registered and you might even lose functionality if you do. I'll explain, when an OpenAccessory device is plugged in the Android OS sends out a message to all the apps. Your app must register a receiver to be able to detect this message and be aware that the IOIO has been plugged in and consequently establish a data connection to it. If for example you have a service running in the background to reconnect if necessary, then unregistering while the app is in the background will not allow the IOIO to reconnect.

    As for app program architecture to deal with IOIO connections, I generally use a service that monitors the connections. Every five seconds a timer checks the state of the IOIO. Based on the state it will take appropriate actions. A global variable allows other parts of the program to know if the IOIO connection is valid. I surround all my IOIO calls with TRY / CATCH in order to catch any connections errors.

    Hope this helps
  7. kolbe

    kolbe Active Member Licensed User

    Have you seen these examples. Check out the I2C example, that is what you need for the BMP180.
  8. kolbe

    kolbe Active Member Licensed User

    I just tried both IOIO v1 and v2 with a S4 mini. BT and OpenAccessory worked just fine but ADB and Device did not. So if by usb you mean ADB usb that is correct if you mean OpenAccessory by usb in my case it works. I also noticed that when I connected the S3 to the IOIO with usb the IOIO started humming a tiny bit. I've haven't seen this with another device.
  9. kolbe

    kolbe Active Member Licensed User

    Just released v2.04 of the IOIO library. This is just a maintenance release. No real changes other than the bug fixes from Ytai's library. Look here to see the changes.
  10. Jiemde

    Jiemde Member Licensed User

    Hi Kolbe,
    I'm already stopped by ( I think! ) a basic thing, I can read the 2 bytes from the calibrations registrys of an BMP180 sensor, but don't know how to concat these 2 bytes into a single one of 16 bits?
    I've try the ByteConverter library without succes!
    Can you help me?

    Thanks in advance for your help
  11. kolbe

    kolbe Active Member Licensed User

    Try this
    Dim ut  As Long
    raphaelcno likes this.
  12. Jiemde

    Jiemde Member Licensed User

    Thank you very much Kolbe, it work for signed var but now I try to resolve the problem for unsigned var ! it's not easy to understand for me.

    Best regards

  13. kolbe

    kolbe Active Member Licensed User

    Use this for signed two byte value

    Accessing the byte directly uses 7th bit in a byte as a sign bit. Using Bit.AND uses all bits in the byte as value bits. So the example above gives you a 15 bit value and the 16 bit is a sign bit.
  14. azhar28

    azhar28 New Member Licensed User

    Anyone manage to read from one wire sensor such as MAX6675 using twimaster or spimaster.
    I try to use example for i2c and twimaster from kolbe and eric but the compiler give:

    Compiling generated Java code. Error
    javac 1.7.0_13
    src\b4a\trytry\main.java:231: error: cannot find symbol
    public static anywheresoftware.b4a.agraham.ioio.B4AIOIO.B4ATwiMaster _twi = null;
    symbol: class B4ATwiMaster
    location: class B4AIOIO
    1 error
  15. kolbe

    kolbe Active Member Licensed User

    Can't really help without seeing the code. However my guess is that you aren't getting a reference to a twi instance before calling a method.
  16. James Costello

    James Costello Member Licensed User


    I`m trying to get PWM to work so I can control the brightness of some LED`s, Bluetooth connection works fine, tried the demo and can turn on/off the yellow LED on the board. But having a problem getting any of the pins to behave and control an LED.


  17. kolbe

    kolbe Active Member Licensed User

    Have you tried the workbench app? In this app you have an example of how to use ioio.openPwmOutput. There are many other method examples as well in this app. You need however to adapt the layout to your device.

  18. James Costello

    James Costello Member Licensed User


    When I try to open the Workbench 2.32 I get an error "IOIO 20" library missing; but I`ve already downloaded the IOIO 2.04 library?

  19. kolbe

    kolbe Active Member Licensed User

    In the library tab of the IDE make sure you select the correct IOIO library. I named the library "ioio 20" and that is what the workbench app is looking for. Just select the right version (the version shows up in parenthesis once checked) in the tab or make sure the file name is "ioio 20.jar" and "ioio20.xml".

  20. James Costello

    James Costello Member Licensed User

    Ah...the file names in the 2.04 library are ioio.jar & ioio.xml.

    I`ll rename them...thanks.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice