wow dude you rock !! ... worked like a charm... here are the changes if 
anyone wants to know!

i implemented both suggestions but it seems like the beginBatch/endBatch 
actually did the trick! 

thanks again!

  spi_ = ioio_.openSpiMaster(39, 4, 5, 6, SpiMaster.Rate.RATE_50K);


public void green(int start, int end) throws ConnectionLostException {

try {
for (int i = start; i < end; i++) {
color.clear();
color.r = (byte) 0;
color.g = (byte) 255;
color.b = (byte) 0;
setLed(i, color);
}
ioio_.beginBatch();
try {
spi_.writeReadAsync(0, buffer1_, buffer1_.length,
buffer1_.length, null, 0);
spi_.writeReadAsync(0, buffer2_, buffer2_.length,
buffer2_.length, null, 0);
Thread.sleep(50);
} finally {
  ioio_.endBatch();
}
} catch (InterruptedException e1) {
}


}

       On Monday, January 13, 2014 12:09:57 AM UTC-7, Ytai wrote:
>
> Hi,
> A few things to check:
>
>    - How come you can use the same pin for MISO and MOSI? It shouldn't be 
>    valid... Use something else for MISO.
>    - Try changing the second writeRead to writeReadAsync and wrap both 
>    calls between a ioio_.beginBatch() / ioio_.endBatch() block. 
>
>
>
> On Sun, Jan 12, 2014 at 9:18 PM, dakman05 <[email protected] <javascript:>
> > wrote:
>
>> Hey Ytai and IOIO Community!
>>  
>> Hope all is well. Having a problem with my IOIO-OTG ( Hardware ID: 
>> SPRK0020 Bootloader ID: IOIO0400 Firmware ID: IOIO0330) ... 
>>
>> So I have a WS2801 LED strip and I am using SPI to creating a unique 
>> green animation lighting effect...
>>
>> Essentially I played around with HolidayIOIO and was able to figure out 
>> how to control the LED strip ..
>>
>> It works like a charm via bluetooth but the following functions are 
>> flickering when directly connected via ADB... Same set of code is working 
>> completely different on BT vs ADB... In bluetooth it works great no 
>> flickering.. with ADB its as if the clock / timing is off... I tried 
>> adjusting the SPI Rate and still no cigar... 
>> See below
>>
>> Any help / suggestions is much appreciated!
>>
>> -Dave
>>
>> In setup:
>>
>>
>> * spi_ = ioio_.openSpiMaster(4, 4, 5, 6, SpiMaster.Rate.RATE_50K);*
>>
>>
>>> *public void greenAnimation() throws ConnectionLostException, 
>>> *InterruptedException 
>>> {
>>> new Thread(new Runnable() {
>>> public void run() {
>>> int i = 0;
>>> try {
>>> clear(0, 31);
>>>
>>> while (i < 25) {
>>>
>>> Thread.sleep(25);
>>>
>>>
>>>
>>>
>>> *if ( i >= 0 && i < 24) {green(0, i);}*
>>> Thread.sleep(25);
>>> i++;
>>> }
>>>
>>> Thread.sleep(20000);
>>> run();
>>> } catch (InterruptedException e) {
>>> // TODO Auto-generated catch block
>>> e.printStackTrace();
>>> } catch (ConnectionLostException e) {
>>> // TODO Auto-generated catch block
>>> e.printStackTrace();
>>> }
>>> }
>>> }).start();
>>> }
>>
>>                                                                          
>>
>> *private void setLed(int num, RGB rgb) {*
>>
>> // Find the right buffer to write to (first or second half).
>>
>> byte[] buffer;
>>
>> if (num >= 16) {
>>
>> buffer = buffer2_;
>>
>> num -= 16;
>>
>> } else {
>>
>> buffer = buffer1_;
>>
>> }
>>
>> num *= 3;
>>
>> if (rgb.r == 0 && rgb.g == 0 && rgb.b == 0) {
>>
>> fadeOut(buffer, num++);
>>
>> fadeOut(buffer, num++);
>>
>> fadeOut(buffer, num++);
>>
>> } else {
>>
>> // Poor-man's white balanace :)
>>
>> buffer[num++] = rgb.r;
>>
>> buffer[num++] = rgb.g;
>>
>> buffer[num++] = rgb.b;
>>
>> }
>>
>> }
>>
>>
>> *public void green(int start, int end)*
>>
>> throws ConnectionLostException {
>>
>> try {
>>
>> for (int i = start; i < end; i++) {
>>
>> color.clear();
>>
>> color.r = (byte) 0;
>>
>> color.g = (byte) 255;
>>
>> color.b = (byte) 0;
>>
>> setLed(i, color);
>>
>> }
>>
>> spi_.writeReadAsync(0, buffer1_, buffer1_.length,
>>
>> buffer1_.length, null, 0);
>>
>> spi_.writeRead(buffer2_, buffer2_.length, buffer2_.length,
>>
>> null, 0);
>>
>> Thread.sleep(50);
>>
>> } catch (InterruptedException e1) {
>>
>> }
>> }
>>
>>         -- 
>> You received this message because you are subscribed to the Google Groups 
>> "ioio-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/ioio-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to