WiiLi Wiki frontpage Include your post in the News Get links Hoteles Quito
WiiLi.org Forum Index WiiLi.org
a new revolution
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

simple PingPong leds script with speed control
Goto page 1, 2  Next
 
Post new topic   Reply to topic    WiiLi.org Forum Index -> GlovePie
View previous topic :: View next topic  
Author Message
TiagoTiago



Joined: 20 Jan 2007
Posts: 710
Location: Brasil

Digg It
PostPosted: Tue Jan 23, 2007 12:54 pm    Post subject: simple PingPong leds script with speed control

shoudl I post this here or somewhere else?


Code:

//use the + and - buttoms to control the speed

if (var.rate<= 0)
var.rate=40
elseif (var.rate    <2)
var.rate= 1
endif


if (Wiimote1.Plus)

var.rate = var.rate +1
endif
if (Wiimote1.Minus)
var.rate= var.rate -1
endif
debug = var.rate
if(true)

Wiimote1.leds= 1
Wait var.rate ms
Wiimote1.Leds= 1+2
Wait var.rate ms
Wiimote1.leds= 2
Wait var.rate ms
Wiimote1.Leds= 2+4
Wait var.rate ms
Wiimote1.leds= 4
Wait var.rate ms
Wiimote1.Leds= 4+8
Wait var.rate ms
Wiimote1.leds= 8
Wait var.rate ms

Wiimote1.Leds= 4+8
Wait var.rate ms
Wiimote1.leds= 4
Wait var.rate ms
Wiimote1.Leds= 2+4
Wait var.rate ms
Wiimote1.leds= 2
Wait var.rate ms
Wiimote1.Leds= 1+2
Wait var.rate ms
endif



btw, if desired I authorize the inclçusion of this script on the next glovepie release Smile


Last edited by TiagoTiago on Thu Jan 25, 2007 6:22 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
Hizzeh



Joined: 23 Jan 2007
Posts: 12

Digg It
PostPosted: Tue Jan 23, 2007 6:54 pm    Post subject:

What does
Code:
if (var.rate<= 0)
var.rate=40
elseif (var.rate    <2)
var.rate= 1
endif


Do? Any idea how to have something last for X seconds?
Back to top
View user's profile Send private message
TiagoTiago



Joined: 20 Jan 2007
Posts: 710
Location: Brasil

Digg It
PostPosted: Tue Jan 23, 2007 8:26 pm    Post subject:

that part is to initally set it to 40 and keep it above zero afterwards

as for allowing it to end after N seconds I woudl have to research, I don't know enough currently to be able to say if that is possible
Back to top
View user's profile Send private message Send e-mail
TylerK



Joined: 18 Dec 2006
Posts: 384
Location: Springfield, IL

Digg It
PostPosted: Tue Jan 23, 2007 9:40 pm    Post subject:

Seems obvious to me. It looks like in that script the rate varies from 1 to 40 ms. So if you want something to last for a second, set the rate to 1000 ms?
Back to top
View user's profile Send private message
TiagoTiago



Joined: 20 Jan 2007
Posts: 710
Location: Brasil

Digg It
PostPosted: Tue Jan 23, 2007 10:03 pm    Post subject:

TylerK wrote:
Seems obvious to me. It looks like in that script the rate varies from 1 to 40 ms. So if you want something to last for a second, set the rate to 1000 ms?


actually the rate variable defines the delay between each step and not how long the effect last, and it varaites from 1 to infinity, 40 is just the initial value
Back to top
View user's profile Send private message Send e-mail
TylerK



Joined: 18 Dec 2006
Posts: 384
Location: Springfield, IL

Digg It
PostPosted: Tue Jan 23, 2007 10:17 pm    Post subject:

Ah, I see. So it's a matter of determining the rate based on how long you want the overall effect to last. Looks like there are 12 wait commands used. You should be able to set another variable to hold the total duration. Then divide the total duration by 12 to get the rate for each step.
Back to top
View user's profile Send private message
TiagoTiago



Joined: 20 Jan 2007
Posts: 710
Location: Brasil

Digg It
PostPosted: Wed Jan 24, 2007 12:16 am    Post subject:

that woudl definbe the length of the loop, and not how long the effect would take (I read "defining the how long it last" as emaning how long it sill be , and not how long til it repats itself. I read thart as meaning settign it to last only N seconds, instead fo running indefinetly)
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    WiiLi.org Forum Index -> GlovePie All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group