Wait for an input?

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

Wait for an input?

Postby ger21 » Mon Sep 04, 2017 11:33 am

I don't see a GetInputPin function. Is the proper way to wait for an input something like this?


Code: Select all
while(!AS3.GetLED(##));
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2663
Joined: Sat Sep 03, 2016 2:17 am

Re: Wait for an input?

Postby cncdrive » Mon Sep 04, 2017 11:45 am

Hi Gerry,

Yes, there is no GetInputPin function, because all inputs are mapped to virtual LED codes, so all inputs states can be queried via the LEDs.
Don't get confused that LEDs might be slower, because they have to be drawn on the screen, they are not, the digital states of the LEDs are read and updated in a 20msec loop.

You have to insert some sleep into the wait loop, because the GetLED function does not contains any sleep, so while your loop runs, while the statement is true can oveload your PC, because the code will run without taking any naps.
You can do it something like:

Code: Select all
while(!AS3.GetLED(...))
{
   Thread.Sleep(1);
}
cncdrive
Site Admin
 
Posts: 4695
Joined: Tue Aug 12, 2014 11:17 pm


Return to Macros

Who is online

Users browsing this forum: No registered users and 14 guests