Sponsored links

Go Back   MP3Car.com > Mp3Car Technical > General Hardware Discussion > Fusion Brain > FB Software


Reply
 
Share Thread Tools Display Modes
Old 12-21-2008, 09:55 PM   #1
JiC
Newbie
 
Join Date: Sep 2008
Posts: 25
JiC is an unknown quantity at this point
Incrementing variables

Here is a block of code I'm working with
Code:
<if fire_on="logic" minimum_delta_vote_time="150" id="CountUSB"> <boolean_operation type="and"> <parameter1> <boolean_operation type="greater than"> <parameter1> <variable do="get" name="usbstatus"></variable> </parameter1> <parameter2> <number>5</number> </parameter2> </boolean_operation> </parameter1> <parameter2> <boolean_operation type="less than or equal to"> <parameter1> <variable do="get" name="usbtime"></variable> </parameter1> <parameter2> <number>4</number> </parameter2> </boolean_operation> </parameter2> </boolean_operation> <then> <do function="Change Variable" functionTargetID="usbtime" vote_opinion="+1" vote_priority="Low"></do> </then> </if>

Basically what I'm doing here is trying to buy myself a half second or so before I flip an output back off. However, this code takes 'usbtime' from 0 to 1, then it never goes any higher. I'm not sure if it's only entering the <then> once, or if vote_opinion=+1 is not working properly. I'm not changing 'usbstatus' while I'm testing this block. Any ideas?
JiC is offline   Reply With Quote
Advertisement
 
Advertisement
Sponsored links

Old 12-21-2008, 11:02 PM   #2
JiC
Newbie
 
Join Date: Sep 2008
Posts: 25
JiC is an unknown quantity at this point
OK just did some more testing and found out <do function="Change Variable" functionTargetID="usbtime" vote_opinion="+1" vote_priority="Low"></do> sets the value to 1 regardless of its previous value. Is there any way to add a number to a variable?
JiC is offline   Reply With Quote
Old 12-21-2008, 11:17 PM   #3
JiC
Newbie
 
Join Date: Sep 2008
Posts: 25
JiC is an unknown quantity at this point
Ok so found a way to do it. Hopefully this will help some other people. This same idea can be used with steering wheel controls to create different actions if you hold down the buttons. Also it seems to me like since the COM update the MDX is much more accurate with the timer and delta_vote times. Before they seemed random, now they work as they should.

Now I have it set up so if you hold 'next track' for longer then one second it starts to send fast forwards every half second after that. If you hold next track for less then a second and let go it advances to the next track.

This timer in my code below allows me to use the fusion brain to trigger a relay for about a second then turn it back off. RR calls a function that turns on a digital output and sets usbstatus to 10 (high) and usbcount to 0. The relay is used to interrupt the +5V wire on the USB cable leading to my hub up front. This solves all pesky problems with my hub and touchscreen on resuming from hibernate (which the fusion brain always comes out of perfectly )

Code:
<if fire_on="logic" minimum_delta_vote_time="150" id="CountUSB"> <boolean_operation type="and"> <parameter1> <boolean_operation type="greater than"> <parameter1> <variable do="get" name="usbstatus"></variable> </parameter1> <parameter2> <number>5</number> </parameter2> </boolean_operation> </parameter1> <parameter2> <boolean_operation type="less than or equal to"> <parameter1> <variable do="set" name="usbtime"> <operation type="add"> <parameter1> <variable do="get" name="usbtime"></variable> </parameter1> <parameter2> <number>1</number> </parameter2> </operation> </variable> </parameter1> <parameter2> <number>10</number> </parameter2> </boolean_operation> </parameter2> </boolean_operation> </if> <if fire_on="logic" minimum_delta_vote_time="100" id="ResetUSB"> <boolean_operation type="and"> <parameter1> <boolean_operation type="greater than"> <parameter1> <variable do="get" name="usbstatus"></variable> </parameter1> <parameter2> <number>5</number> </parameter2> </boolean_operation> </parameter1> <parameter2> <boolean_operation type="greater than"> <parameter1> <variable do="get" name="usbtime"></variable> </parameter1> <parameter2> <number>10</number> </parameter2> </boolean_operation> </parameter2> </boolean_operation> <then> <do function="Change Variable" functionTargetID="usbstatus" vote_opinion="0" vote_priority="Low"></do> <do function="Change Variable" functionTargetID="usbtime" vote_opinion="0" vote_priority="Low"></do> <do function="Trigger Output" functionTargetID="Digital Output 0" vote_opinion="Off" vote_priority="Low"></do> </then> </if>

JiC is offline   Reply With Quote
Old 12-21-2008, 11:18 PM   #4
Newbie
 
Join Date: Dec 2008
Posts: 23
alejoal07 is an unknown quantity at this point
Quote: Originally Posted by JiC View Post
OK just did some more testing and found out <do function="Change Variable" functionTargetID="usbtime" vote_opinion="+1" vote_priority="Low"></do> sets the value to 1 regardless of its previous value. Is there any way to add a number to a variable?

Yup, try:

vote_opinion="d+1"

(That will add 1 to whatever the value is)
alejoal07 is offline   Reply With Quote
Old 12-21-2008, 11:32 PM   #5
JiC
Newbie
 
Join Date: Sep 2008
Posts: 25
JiC is an unknown quantity at this point
Thanks alejoal. I haven't tried it yet but the way you describe is much cleaner
JiC is offline   Reply With Quote
Old 12-22-2008, 12:11 AM   #6
Fusion Brain Creator
 
2k1Toaster's Avatar
 
Join Date: Mar 2006
Location: Colorado, but Canadian!
Posts: 8,862
2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future
Yes + and - are the signs

d is add the difference to what it is. Without the d it is make it so.

So "d1" is add 1, "+1" is make it equal to 1, "d-4" is subtract 4, and so on.
2k1Toaster is offline   Reply With Quote
Sponsored links
Advertisement
 
Advertisement
Reply

Bookmarks

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Increment numerical valued variables Tensai RR Skins 4 08-14-2007 01:54 AM
Dividing variables frangolfgt Road Runner 7 07-19-2007 08:30 PM
Any way to set persistent variables other than rr.ini? Sal R. RR Skins 10 02-06-2007 05:46 PM
Some clarity on variables being sent to flash objects... Sonicxtacy02 Road Runner 7 10-17-2006 01:44 PM
How do I use Variables on my Skin ? guino RR FAQ 0 06-07-2006 11:51 AM



All times are GMT -5. The time now is 07:34 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.2
Copyright © 1999 - 2008 Mp3Car.com Inc.Ad Management by RedTyger
Message Board Statistics