Machsupport Forum

Mach Discussion => Brains Development => Topic started by: Rademacher on November 24, 2010, 07:24:45 PM

Title: Execute Button Script - how do you use it?
Post by: Rademacher on November 24, 2010, 07:24:45 PM
I have been attempting to write a brain that will trigger my auto Z script when a Pokey55 button is pushed.  Can't seem to find a way to make scripts run from brains. 

Does any one know how to implement the Execute Button Script?  I am thinking this maybe the solution to my problem.

thanks,
Wayne
Title: Re: Execute Button Script - how do you use it?
Post by: poppabear on November 24, 2010, 07:58:31 PM
Set Trigger Macro using “Push User Button” in Brians:

First, you dont put the code in a button, you put it in a macro file. For
example file: m600.m1s
SetMessage( "This is a macro call..")

Then , you have to set that macro to be the default macro call with a call to
SetTriggerMacro( 600 ) at some point in the program, an init string could do
that if the SetTriggerMacro call were in another macro file that is called on
startup.  Then the brain will execute m600 whenever that brain termination code is
called.
Title: Re: Execute Button Script - how do you use it?
Post by: BR549 on November 24, 2010, 08:40:08 PM
HIYA SCOT, I must have fallen off the pumpkin wagon and bumped my head. Could you explain that again???

(;-) TP
Title: Re: Execute Button Script - how do you use it?
Post by: poppabear on November 25, 2010, 10:23:11 AM
Sure....
Quote
Set Trigger Macro using “Push User Button” in Brians:
First, you dont put the code in a button, you put it in a macro file. For
example file: m600.m1s
SetMessage( "This is a macro call..")
Then , you have to set that macro to be the default macro call with a call to
SetTriggerMacro( 600 ) at some point in the program, an init string could do
that if the SetTriggerMacro call were in another macro file that is called on
startup.  Then the brain will execute m600 whenever that brain termination code is
called.

hehehehe.......... sorry couldn't resist...

Ok Make the "Macro" that you want to be triggered, for instance M600 as above this macro does what ever....
then if you want it to auto trigger you have to set it using the set macro call. this will be a SEPERATE macro call.

So under General cfg, in the Init Put your set trigger macro in the init line, call it M1000.m1s
in that macro put the set trigger macro call:

'M1000.m1s (in the init line)
SetTriggerMacro( 600 )

//////////////////////////

When Mach starts up, it runs the "Init" line, which in turn runs the SetTriggerMacro call and sets which macro number will trigger
i.e. M600.m1s

So, in Brains.....  you have your even that triggers your "Trigger Macro button" termination.......
for aurguments sake, lets say you use ULED 2000 to trigger that function.

so your rung would look like: NOTE!! You may, or may not have to make an invert OP call after the ULED
depending on where it is coming from.

ULED 2000->Invert OP->Trigger Macro Button

so when ULED 2000 turns on, it will run the function that runs the macro you have set in the trigger.....

see!!!! Simple as PIE!!!!!!!!  hehehhehehehe  (  NOT!!!!! )

scott
Title: Re: Execute Button Script - how do you use it?
Post by: BR549 on November 25, 2010, 11:04:19 AM
oK so it was NOT the bump on the head, maybe just blind but I don't see ANY button push in Brians that will terminate with a macro call. Can you give me the button number(;-)

Up to now I had to set a user led and then monitor the led from the macropump to make it work(Not a good way as it eats up resources)

(;-) TP
Title: Re: Execute Button Script - how do you use it?
Post by: poppabear on November 25, 2010, 07:28:34 PM
???? in brains 1034

s.
Title: Re: Execute Button Script - how do you use it?
Post by: BR549 on November 25, 2010, 09:51:05 PM
BOY someone needs to rename that button(;-)

So  does that mean you can only have one button and call one macro??

(;-) TP



Title: Re: Execute Button Script - how do you use it?
Post by: poppabear on November 25, 2010, 10:09:24 PM
yeap
Title: Re: Execute Button Script - how do you use it?
Post by: Greolt on November 26, 2010, 01:13:31 AM
Thanks for that info Scott

I presume that button press is   "1034 - Execute Button Script"

Greg
Title: Re: Execute Button Script - how do you use it?
Post by: Rademacher on November 26, 2010, 09:16:16 AM
Wow, so intuitive....can't believe I missed it;)

Seriously, really appreciate the help, I was really stuck.

Wayne
Title: Re: Execute Button Script - how do you use it?
Post by: poppabear on November 26, 2010, 10:07:27 AM
Really........

    after all, "How Hard Could IT Be?"

scott :)
Title: Re: Execute Button Script - how do you use it?
Post by: Rademacher on November 28, 2010, 10:44:33 AM
Thanks to Poppabear.....I got the "Execute Button Script" working.    Since this topic was not real clear to me...I thought I would share the steps I used to make it work.   In fact, I was able to trigger (3) different functions by using If Then statements in my script.

#1 Create (2) VB scripts;
The first script (m666) simply has this statement "SetTriggerMacro (1000)"
The second script (m1000) is the process, or processes, you want to run.

If isActive (OEMtrig1) then
******************X do something *********XX
end if

If isActive (OEMtrig2) then
******************X do something *********XX
end if

If isActive (OEMtrig3) then
******************X do something *********XX
end if


#2 Setup your hotkeys.
ex. Trigger#1 301, Trigger#2 301, Trigger#3 301

#3 Set your ports and pins
ex. oemtrigger#1 port10 pin5, oemtrigger#2 port10 pin6, oemtrigger#3 port10 pin7

#4 Write your Brain using the "execute buttonscript"
ex. oemtrigger#1--->no op---->execute button script
oemtrigger#2---->no op---> execute button script
oemtrigger#3--->no op--->execute button script

hope this helps,
Wayne
Title: Re: Execute Button Script - how do you use it?
Post by: Rademacher on November 28, 2010, 11:05:19 AM
Here is my keypress brain and VB script

Wayne
Title: Re: Execute Button Script - how do you use it?
Post by: Rademacher on November 28, 2010, 07:01:55 PM
Finaly finished.....here's a photo of my finished pendant ;D
Title: Re: Execute Button Script - how do you use it?
Post by: budman68 on November 28, 2010, 07:16:51 PM
That is beautiful!  ;)

Dave
Title: Re: Execute Button Script - how do you use it?
Post by: Rademacher on November 28, 2010, 11:09:10 PM
Thanks, glad you like it.
Title: Re: Execute Button Script - how do you use it?
Post by: poppabear on November 29, 2010, 08:03:00 AM
Nice, did you use the PoPendant auto set up? on the config page? or "Roll your own".

scott
Title: Re: Execute Button Script - how do you use it?
Post by: Rademacher on November 29, 2010, 12:06:29 PM
Rolled my own, so I could connect the hardware to fit my needs.

I tried using the LCD and scan matrix keyboard configs but found the encoder become very jerky...appears the overhead of the keyboard scan and LCD was keeping the Pokey to busy for fluid encoder movements. 

To solve the encoder issue, I hacked the 16key keyboard so each button is a indepenent key press....no scan required.  I also disabled the LCD.  These two changes allows the Pokey to provide smooth encoder movements and yet allow the use of all the different key presses :) 

Wayne
Title: Re: Execute Button Script - how do you use it?
Post by: poppabear on November 30, 2010, 08:09:03 AM
fixed that, in version 10.6.2 of the pokeys install from boris site, (he also did a firmware upgrade 2.17 I think), that addressed some of those issues from his end as well.

scott
Title: Re: Execute Button Script - how do you use it?
Post by: Rademacher on November 30, 2010, 10:18:23 AM
This great news.....I really want to use the LCD.   

I had the latest pokey plugin, but the pokey firmware was out of date.  I will to the update and give it a try

thanks for the support Scott