
Herr Ball
Don't really want the answer of how to do this, YET ... LOL.
Would like to pull my hair out a little first.
I just wish to know by anyone is it possible to have EZB call a subroutine inside a script?
Ex: Rich's BlinkM Script
Would it be possible to write several subroutines and then call anyone of them when needed?
Ex:
Subroutine
Red LED blink 3 times.
Subroutine
Blue LED blink 7 times.
Subroutine
Yellow LED blink 6 times.
Is this possible?
Thanks all for your thoughts on this.
P.S. I guess this might be a little confusing without the rest of what I wish to do ... LOL.
I plan on having another microcontroller (not EZB) that runs a program.
It is in that microcontroller that I need to call a subroutine through I2C from EZB.
Hope that makes sense?
Upgrade to ARC Pro
Get access to the latest features and updates with ARC Early Access edition. You'll have everything that's needed to unleash your robot's potential!
It uses a whole bunch of separate scripts for each section/module/routine such as the "Avoid" script or the "Roam" script, these are called using the ControlCommand() in the main script. All are neatly in their own Script Manager renamed Ping Roam, run the main script and you will see the other scripts starting and stopping to suit the main script.
The scripts are pretty well commented so you should be able to read them one by one and see what's going on and why. Hopefully it will guide you in the right direction. Your sub routines will be much simpler with the I2C commands only but the ping script will show an example of how to call the sub routine scripts up and get them starting and stopping.
http://www.ez-robot.com/Community/Forum/posts.aspx?threadId=3431 , @Richs example of I2C answered my question perfectly and perhaps @Herr Ball's. Just my guess ...if Herr Ball assigned a variable for each subroutine then he could call it up anytime! If....and a big IF, one can create a subroutines as a "variable" it might solve his issue .......I see that Rich has used letters in his command script like c and f etc , which tells me that DJ has included ThingM's, Blink_M funcs.h library ..hooray I would like to give Rich an informal " solved it"
Yes, I assume you could set variables, such as;
$sequence1 = "0,0x09,n,0xff,0x00,0x00"
$sequence2 = "0,0x09,n,0x00,0xff,0x00"
I'll have to read the datasheet again when I have chance and look in to the sequence programming (if it exists, it is possible I was dreaming). However, separate scripts called with a ControlCommand("blinkmscripts", "script2", ScriptStartWait) will also work.
I did have issues with my I2C LCD Display however that turned out to be due to the HD servos in melvins pan/tilt head bracket, as soon as I power the servos from their own 6V regulated source the problem went away.
In fact, I power my LCD (with backlight), 1 BlinkM (soon to be 3) and an accelerometer all from the I2C port with no issues. No pull up resistors installed or anything.
It may help if you added a power cap to the I2C Vcc and Ground to give a small reservoir for any power dips.
You are also able to write light scripts however it states that only ID 0 is writeable. It's not something I've tried yet but I've added it to my list.
If the light scripts on page 21 would do for your sequences this may be the way to go about it, otherwise it is simple to write your own scripts in ARC with the I2C commands and sleeps etc. then call them with a control command.
Hopefully it's enough to get you started @Herr Ball
You just got to love this forum and the people that use it ...