Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4android > Additional libraries and official updates
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Additional libraries and official updates Users contributed libraries and official updates. This forum is open for licensed users only.

IOIO board library

Reply
 
LinkBack Thread Tools Display Modes
  #41 (permalink)  
Old 08-28-2011, 07:08 AM
Knows the basics
 
Join Date: Apr 2009
Posts: 52
Default

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!
Reply With Quote
  #42 (permalink)  
Old 08-29-2011, 04:36 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

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.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #43 (permalink)  
Old 08-30-2011, 12:41 AM
Junior Member
 
Join Date: Jul 2011
Posts: 20
Default 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=yoyo.OpenDigitalOutput(5,clk.OP_NORMAL,True)
slaveselect(0)=yoyo.OpenDigitalOutput(6,slaveselec t(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=yoyo.OpenSpiMaster(miso,mosi,clk,slaveselect,s pi.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=yoyo.OpenSpiMaster(miso,mosi,clk,slaveselect,s pi.RATE_125K,False,False)
javac 1.6.0_26
src\sweetek\ioio\experiment\main.java:344: inconvertible types
found : anywheresoftware.b4a.agraham.ioio.B4AIOIO.B4ADigit alOutputWrapper[]
required: ioio.lib.api.DigitalOutput.Spec[][]
mostCurrent._spi.setObject((ioio.lib.api.SpiMaster )(mostCurrent._yoyo.OpenSpiMaster((ioio.lib.api.Di gitalInput.Spec)(_miso.getObject()),(ioio.lib.api. DigitalOutput.Spec)(_mosi.getObject()),(ioio.lib.a pi.DigitalOutput.Spec)(_clk.getObject()),(ioio.lib .api.DigitalOutput.Spec[][])(_slaveselect),mostCurrent._spi.RATE_125K,anywher esoftware.b4a.keywords.Common.False,anywheresoftwa re.b4a.keywords.Common.False)));
^
1 error

so, the question is: "how to define a valid digitaloutput array?
Reply With Quote
  #44 (permalink)  
Old 08-30-2011, 08:21 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by eric010101 View Post
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!
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #45 (permalink)  
Old 08-30-2011, 11:45 AM
Junior Member
 
Join Date: Jul 2011
Posts: 20
Default thanks!

Quote:
Originally Posted by agraham View Post
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!
after serveral hours searching and trying, I found the question is beyong my knoweledge.

let me know if I can help in anything.
Reply With Quote
  #46 (permalink)  
Old 08-30-2011, 12:06 PM
Basic4ppc Expert
 
Join Date: Jan 2011
Location: Wales
Posts: 612
Default

Quote:
Originally Posted by eric010101 View Post
after serveral hours searching and trying, I found the question is beyong my knoweledge.

let me know if I can help in anything.
You could always help with the shopping
Reply With Quote
  #47 (permalink)  
Old 08-30-2011, 01:16 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

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

Quote:
Dim spi As SpiMaster
Dim slavepins() As Int
slavepins = Array As Int(4, 5, 6)
Dim slavemodes() As Object
slavemodes = Array As Object( spi.OP_NORMAL, spi.OP_NORMAL, spi.OP_NORMAL)
spi=YOYO.OpenSpiMaster(1, spi.IP_PULL_UP, 2, spi.OP_NORMAL, 3, spi.OP_NORMAL, slavepins, slavemodes, spi.RATE_125K, False, False)
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #48 (permalink)  
Old 08-30-2011, 04:07 PM
Junior Member
 
Join Date: Jul 2011
Posts: 20
Default SPI Tested and is good but not perfect

Quote:
Originally Posted by agraham View Post
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?
Attached Images
File Type: jpg SPI_IOIO_B4A.JPG (15.8 KB, 49 views)

Last edited by eric010101 : 08-30-2011 at 04:19 PM.
Reply With Quote
  #49 (permalink)  
Old 08-30-2011, 04:26 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by eric010101 View Post
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.
Code:
    Dim unsignedi As Int
Dim signedb As Byte
signedb = 
0x8c
unsignedi = 
Bit.And(0xff, signedb)
Msgbox(unsignedi, signedb)
Quote:
did you buy apple?
Sorry!
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #50 (permalink)  
Old 08-30-2011, 04:50 PM
Junior Member
 
Join Date: Jul 2011
Posts: 20
Default 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.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wish:IOIO support meirmark Bugs & wishlist 15 03-31-2012 09:14 AM
Door library (Beta) - Special library Erel Official Updates 60 01-13-2011 11:23 AM
Merging Outlook library and Phone library Erel Official Updates 11 09-15-2010 09:22 AM
Back to the drawing board ...... taximania Chit Chat 13 06-17-2008 10:55 AM
simulation of a Galton board Stellaferox Share Your Creations 4 05-13-2007 07:21 PM


All times are GMT. The time now is 10:04 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0