B4A Library IOIO board library

Jiemde

Member
Licensed User
Longtime 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

Jiemde
 

Kevin L. Johnson

Member
Licensed User
Longtime User
In preparation for Dual Servos (Az & El) ...

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

http://www.b4x.com/android/forum/threads/ioio-board-library.8942/page-16#post-270678

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.

UPDATE:

It appears that the following line of code ...
B4X:
yoyo.OpenPwmOutput("pwmoutaz",5,Azservo.OP_NORMAL,50)
can NOT handle uppercase letters in the event name therefore ...

pwmout is OK
pwmoutaz is OK
but
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:

Jiemde

Member
Licensed User
Longtime User
Hi,

Is somebody can help me about the BMP180 sensor ?

Best regards
Jiemde
 

kolbe

Active Member
Licensed User
Longtime 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:

kolbe

Active Member
Licensed User
Longtime 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:

kolbe

Active Member
Licensed User
Longtime 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
 

kolbe

Active Member
Licensed User
Longtime 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.
 

kolbe

Active Member
Licensed User
Longtime 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.
 

Jiemde

Member
Licensed User
Longtime 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.


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
Jiemde
 

kolbe

Active Member
Licensed User
Longtime User

Try this
B4X:
Dim ut  As Long
msb=readbyte(0)
lsb=readbyte(1)
       
ut=Bit.ShiftLeft(Bit.AND(msb,0xff),8)+Bit.AND(lsb,0xff)
 

Jiemde

Member
Licensed User
Longtime User
Try this
B4X:
Dim ut  As Long
msb=readbyte(0)
lsb=readbyte(1)
      
ut=Bit.ShiftLeft(Bit.AND(msb,0xff),8)+Bit.AND(lsb,0xff)


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

jiemde
 

kolbe

Active Member
Licensed User
Longtime 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

jiemde

Use this for signed two byte value

B4X:
Bit.ShiftLeft(readbyte(0),8)+Bit.AND(readbyte(1),0xff)

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.
 

azhar28

New Member
Licensed User
Longtime 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
 

kolbe

Active Member
Licensed User
Longtime 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.
 

James Costello

Member
Licensed User
Longtime User
Kolbe,

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.

James


 

kolbe

Active Member
Licensed User
Longtime 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.

 

James Costello

Member
Licensed User
Longtime User
Kolbe,

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?


James
 

kolbe

Active Member
Licensed User
Longtime 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".


Kolbe,

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?


James
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…