reading Pokeys pins

C Scripting questions and answers
Post Reply
ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: reading Pokeys pins

Post by ArtF »

Hi Gary:

Check the AuggieProgrammersGuide.chm file in your folder. It shows erxamples of all the script calls and hwo they are
used in general.

Art
ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

  That help file is only complete through the direct Engine commands, its parameters are not entered forthe other groupings. IF you see one of interest
that isnt complete, yell and Ill fill it in. Im looking at completeing that list and removing obsolete groups such as the contour drawing groups and such.
Too much was added into auggie that it didnt need, so much is being removed.

Art
ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

  One final thought, make sure you read the code contained in the default libraries, they are the best example of how
to use the various calls. Most of them are used in one way or another in the examples shown. You get a pretty good
idea how to script from those scripts. You can see some of them instantiate functions and also call them to run at startup
by simply calling the declared function in the library file.

 
Art
gburk
Site Admin
Posts: 324
Joined: Mon Nov 26, 2018 2:57 am

Re: reading Pokeys pins

Post by gburk »

Ok did a button to call this script

The Word help prints to the screen but the led doesn't turn on.

I created a led with the var name to XhomeTest

global Main_BUT_20 = function( current )
{
print("Help");
led = Led("XhomeTest");
  led.SetStateMask(1);
  //sleep(30);
  //led.SetStateMask(0);  //this makes the LED turn off, then on again in 3 seconds.

return;
};

So doing something wrong sorry for all the questions once I wrap my head around this stuff I should be good to go..
I didn't see anything like this in the scripts in the script folder...

Thanks gary
I 
ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: reading Pokeys pins

Post by ArtF »

Hi Gary:

    Your problem is the name of the led, your using the led variable name , not the actual led id name.
Start the scripter with the scripter checkbox in config dropdown. Turn on the scripter with its power button.

  At this point you can right click any LED and its identifier will be shown. In the case of your XhomeTest youll see
a name like LED_USERPANEL_6 or some such thing. Thats the identifier needed for getting an LED hook.

The variable name can be used with variable manipulation routines. As you type the right LED identifier it will
autocorrect in the window your typing it in.

Art


gburk
Site Admin
Posts: 324
Joined: Mon Nov 26, 2018 2:57 am

Re: reading Pokeys pins

Post by gburk »

I guess I'm to old for this but any way I started the script edit and when I right clicked the led I got
Main_LED_0:XhomeTest
I got the same type of name on all the led's, but the buttons did look like I was getting the right names back

Thanks gary
ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

  SO to connect to that LED youd use
the name Main_LED_0 ,

led = Led("Main_LED_0");
led.SetStateMask(1);

the variable name is XHomeTest. Not all items have a variable name.
I think the statement XHomeTest = 1 shoud turn it on as well without
having to get an LED hook for it. Generally a variable named object can
be refered to in script by its variable name instead of getting a hook and
using that. Ill have to test thats true in the case of LED's, its been awhile
since Ive done screen edits.

Art

ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: reading Pokeys pins

Post by ArtF »

Hi Gary:

I went back and edited to refresh myslf on how it works.

To set or get and LED's value, if it has a variable name, you can use

x = GlobalGet("MotionConnected");
print("Led = " + x);
GlobalSet("MotionConnected",1);


This will show you the motionconnected LED and set it to on if your in sim, replace
its varaible name with any you use and the globalGet / GlobalSet should work for you
for getting and settign any variable.


Art
gburk
Site Admin
Posts: 324
Joined: Mon Nov 26, 2018 2:57 am

Re: reading Pokeys pins

Post by gburk »

Ill try it I was confused as to how it knows which led  is ("Main_LED_0"); all the leds on the main screen had the same name except the :XhomeText The Estop led had Main_LED_ 0:Estop

Thanks gary
ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

While normally all LEDs will have names that are different, when the system see's they have a variable name,
it doesnt try to rename them to different primary names. this has to do with the rather complex system of naming
which is necessary as various modules could share a led name internally. At startup various id's are checkled in
order and apparently it ignores the naming once it see's it has a variable name instead.  (Its been awhile since
Ive been in there..).
  I tested the script I posted, should work OK.. Still dont know why the block didnt work, more testing req

Art
Post Reply