B4A Library IOIO board library

pinoy_ako

Member
Licensed User
Longtime User
Sir Agraham,
thanks for the continuous update on ioio. please continue doing so. once i get my diy ioio hardware working, i'll share it here. so others can enjoy your library with a cheaper hardware.


thank you sir Agraham! :sign0098:
 

agraham

Expert
Licensed User
Longtime User
Archive 1.3a now posted includes the unchanged Basic4android IOIO library version 1.3 together with the IOIOlib library version 3.2 which is the latest version on the Downloads page link here https://github.com/ytai/ioio/wiki

To use it you may have to upgrade your IOIO firmware to the App-IOIO0300.ioioapp Application Image Bundle found on the Downloads page by clicking the QR code image on the version 3.2 line and using the IOIO Manager Application available on the Market.
 

eric010101

Member
Licensed User
Longtime User
SPI Question

I tested the IOIO1.3, it worked fine with TwiMaster, but can't get through OpenSpiMaster, Here is my code:
Dim slaveselect(1) As DigitalOutput
Dim mosi As DigitalOutput
Dim miso As DigitalInput
Dim clk As DigitalOutput
mosi= YOYO.OpenDigitalOutput(3,mosi.OP_NORMAL ,True)
miso= YOYO.OpenDigitalInput(4,miso.IP_FLOATING)
clk=yoypenDigitalOutput(5,clk.OP_NORMAL,True)
slaveselect(0)=yoypenDigitalOutput(6,slaveselect(0).OP_NORMAL,True)
'OpenSpiMaster (miso As IOIO.lib.api.DigitalInput.Spec, mosi As IOIO.lib.api.DigitalOutput.Spec,
'clk As IOIO.lib.api.DigitalOutput.Spec, slaveSelect() As IOIO.lib.api.DigitalOutput.Spec[],
'rate As IOIO.lib.api.SpiMaster.Rate, invertClk As Boolean, sampleOnTrailing As Boolean) As IOIO.lib.api.SpiMaster

spi=yoypenSpiMaster(miso,mosi,clk,slaveselect,spi.RATE_125K,False,False)

and the error message,

Compiling code. 0.09
Generating R file. 0.00
Compiling generated Java code. Error
B4A line: 118
spi=yoypenSpiMaster(miso,mosi,clk,slaveselect,spi.RATE_125K,False,False)
javac 1.6.0_26
src\sweetek\ioio\experiment\main.java:344: inconvertible types
found : anywheresoftware.b4a.agraham.ioio.B4AIOIO.B4ADigitalOutputWrapper[]
required: ioio.lib.api.DigitalOutput.Spec[][]
mostCurrent._spi.setObject((ioio.lib.api.SpiMaster)(mostCurrent._yoypenSpiMaster((ioio.lib.api.DigitalInput.Spec)(_miso.getObject()),(ioio.lib.api.DigitalOutput.Spec)(_mosi.getObject()),(ioio.lib.api.DigitalOutput.Spec)(_clk.getObject()),(ioio.lib.api.DigitalOutput.Spec[][])(_slaveselect),mostCurrent._spi.RATE_125K,anywheresoftware.b4a.keywords.Common.False,anywheresoftware.b4a.keywords.Common.False)));
^
1 error

so, the question is: "how to define a valid digitaloutput array?
 

agraham

Expert
Licensed User
Longtime User
the question is: "how to define a valid digitaloutput array?
Indeed I overlooked the ramifications of it being an array of an IOIOlib type. I need to convert the Basic4android DigitalOutput wrapper types to unwrapped IOIO DigitalOutput types and copy them to an array of that type. I'll do it later today after I've done the weekly shopping!
 

eric010101

Member
Licensed User
Longtime User
thanks!


after serveral hours searching and trying, I found the question is beyong my knoweledge.

let me know if I can help in anything.
 

agraham

Expert
Licensed User
Longtime User
Version 1.4 now posted corrects the method signature for OpenSpiMaster which I totally screwed up originally by being careless.

 

eric010101

Member
Licensed User
Longtime User
SPI Tested and is good but not perfect

Version 1.4 now posted corrects the method signature for OpenSpiMaster which I totally screwed up originally by being careless.
hello agraham,
I tested the SPI with an EEPROM - AT25AA320. and the code:

If FirstTime=True Then
activity.AddMenuItem("UART","aUART")
activity.AddMenuItem("I2C","aI2C")
activity.AddMenuItem("SPI","aSPI")
activity.AddMenuItem("IO","aIO")
activity.AddMenuItem("ADC","aADC")
activity.AddMenuItem("WiFi","aWiFi")


SetSpinner
'default mode0,DA=4, CL=5, rate=100KH)
spn_Twimode.SelectedIndex=2
spn_TWIRate.SelectedIndex=0
spn_Period.SelectedIndex=4
spn_Addbit.SelectedIndex=0
txt_WriteByteLength.text=1
txt_ReadByteLength.text=7
txtAddress.Text="104"
TimerLoop.Initialize("TimerLoop",1000)

go=False
looped=False
rbtn_Single.Checked=True

YOYO.Initialize
YOYO.WaitForConnect()



led = YOYO.OpenDigitalOutput(0,led.OP_NORMAL ,True) ' Enable LED_PIN for output
getSetUPValue
Dim spi As SpiMaster
Dim slavepins() As Int
slavepins = Array As Int(6, 7, 10)
Dim slavemodes() As Object
slavemodes = Array As Object( spi.OP_NORMAL, spi.OP_NORMAL, spi.OP_NORMAL)
spi=YOYO.OpenSpiMaster(3, spi.IP_PULL_UP, 4, spi.OP_NORMAL, 5, spi.OP_NORMAL, slavepins, slavemodes, spi.RATE_125K, False, False)
Dim i As Int
Dim wBuffer(2) As Byte
Dim rBuffer(7) As Byte
Dim Rs() As Boolean
Dim suc As Boolean
Dim tmp As String
suc=True
Do While (suc=True)
wBuffer(0)=0x05
If Spi.IsInitialized=True Then

spi.WriteRead(0,wBuffer,1,2,rBuffer,1)
lbStatus.Text="Read " & 1 & " bytes. @ " & DateTime.Time(DateTime.Now)
txtRX.Text=rbuffer(0)' Bit.ToHexString(rbuffer(0))
Else
Msgbox("NOT ready","")
End If
waitms(1000)
Loop

End If

*****************
the results were:
1. compilier was good with no error.
2. connected to IOIO with pins: 3,4,5,6, MISO,MOSI,CLK,CS. and data read.
3. send 0x05 to read eeprom's register byte and return should be 0x8C, but it showed "-116", negative? so strange.
4. confirmed the signal with LogicPort and is OK.see attached file
5. need to know how to convert -116 to 0x8C = 140 (256+(-116))=140, but how does it happen with a byte array?

thank you for your quick fix on lib. did you buy apple?
 

Attachments

  • SPI_IOIO_B4A.JPG
    15.8 KB · Views: 253
Last edited:

agraham

Expert
Licensed User
Longtime User
return should be 0x8C, but it showed "-116", negative? so strange
In Java bytes are treated as signed numbers -128 to 127. You can convert using an Int to get the unsigned value.
B4X:
   Dim unsignedi As Int
   Dim signedb As Byte
   signedb = 0x8c
   unsignedi = Bit.And(0xff, signedb)
   Msgbox(unsignedi, signedb)
did you buy apple?
Sorry!
 

eric010101

Member
Licensed User
Longtime User
know no java but basic

I started Anroid programming with Java, but after 2 weeks reading sample project, and eclipse, my face turned grey.
until I found B4A, my life turn color again. Thanks for your answer.

now I am ready to test different sensors.

I need to get some sleep now, I'll let you know if SPI works all night.

BTW, I don't do shopping, I eat only Apple.
 

bluedude

Well-Known Member
Licensed User
Longtime User
ADK Tinkerkit

Hi,

I know you have created the IOIO stuff but have you ever taken a look at the ADK stuff?

More and more hardware suppliers release an ADK en for example the ADK Tinkerkit is pretty amazing: Arduino ADK TinkerKit

Any plans to do something for the ADK stuff? I think it is broader supported compared to IOIO.

Cheers,
 

jboavida

Member
Licensed User
Longtime User
Sorry for the begginners question, but this library works on a tablet with Android 2.2 or needs 3.x?

I read somewhere that only honeycomb as hardware access...

Thanks
 

Nizze

Active Member
Licensed User
Longtime User
Dont work ??

Hi
Today i recived my IOIO module.
I hav edownloade the example and libs.
But nothing happands .
The red Led lights up but nothing more.

Have i forgotten something ??

Tested on Samsung S2 and Motorola XOOM

// Nizze
 

agraham

Expert
Licensed User
Longtime User
IOIOlibBT version 3.10 now posted. I have no idea if it will work but it compiles OK in Basic4android against IOIO.jar version 1.4.

This version of the IOIOlib is supposed to be able to connect with a IOIO board across a Bluetooth connection. It should be completely interchangeable with the original IOIOlib as far as IOIO.jar is concerned. Reference either IOIOlib or IOIOlibBT in your project but not both. It may not work on all versions of Android before API 10 - you can but try!

IOIOlibBT requires the the IOIO board be loaded with updated firmware that can recognise both an Android phone and a Bluetooth dongle and communicate appropriately.
 

pinoy_ako

Member
Licensed User
Longtime User
IOIOlibBT version 3.10 now posted. I have no idea if it will work but it compiles OK in Basic4android against IOIO.jar version 1.4.
hi sir agraham. i tried compiling a working ioio b4a sample with IOIOlibBT. it compiled ok. but when i tried to connect the app to a bt ioio board, the app hunged up. it seems it can't detect the bt ioio board.

is there something we can do with it? thanks
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…