
-----------------------------------
rss14
Thu Jun 05, 2008 3:49 pm

Is it possible to have code running in the backround?
-----------------------------------
I need a loop to continuously be running in the background, while the program plays. Is that possible?

-----------------------------------
SNIPERDUDE
Thu Jun 05, 2008 3:57 pm

RE:Is it possible to have code running in the backround?
-----------------------------------
look it up in the turing walkthrough about procedures

-----------------------------------
rss14
Thu Jun 05, 2008 4:00 pm

RE:Is it possible to have code running in the backround?
-----------------------------------
Thank you for the link.

-----------------------------------
rss14
Thu Jun 05, 2008 5:08 pm

RE:Is it possible to have code running in the backround?
-----------------------------------
I read the tutorial, but I am a bit confused. 

My program uses parallelput to give output to LEDs in order to resemble a traffic intersection. 

However, I need to add a crossing light, and a switch. 

When parallelget(64) = 1, then I put that into a variable: 
loop
    switchpressed := parallelget
    if ((switchpressed div 128) mod 2) = 1 then
        switchstandby = true
    end if
end loop

However, the program just continues this loop, which i want running in the backround, and ignores the rest of the code (which parralelputs the LEDs (also a loop) )

-----------------------------------
rss14
Thu Jun 05, 2008 5:51 pm

RE:Is it possible to have code running in the backround?
-----------------------------------
procedure buttonpressed
    switchpressed := parallelget
    if ((switchpressed div 128) mod 2) = 1 then
        switchstandby := true
    end if
end buttonpressed


loop
    buttonpressed
    parallelput (33)
    cancross := false
    delay (5000)
    buttonpressed
    parallelput (9)
    cancross := false
    delay (2000)
    buttonpressed
    if switchstandby = true then
        parallelput (82)
    else
        parallelput (18)
    end if
    cancross := true
    delay (5000)
    buttonpressed
    parallelput (6)
    cancross := false
    delay (2000)
end loop

This is my revised code. . . however, the LED only turns on if I hold the button, so when buttonpressed runs, it find the button to be 1 . . . I can't find a way to have button pressed run for an infinite amount of time, without disturbing the loop of the traffic lights. . .

-----------------------------------
rss14
Thu Jun 05, 2008 7:56 pm

RE:Is it possible to have code running in the backround?
-----------------------------------
Nvm, i got help from a friend. 

I made a process so the thing will run in the background.

-----------------------------------
Tony
Thu Jun 05, 2008 8:22 pm

Re: RE:Is it possible to have code running in the backround?
-----------------------------------
Nvm, i got help from a friend.
Not much of "help" if it's the wrong solution.

A single frame of your loop takes 14 seconds to complete. So it all works, for the most part, correctly. Just very slowly. Take out the delays.

-----------------------------------
Insectoid
Thu Jun 05, 2008 8:35 pm

RE:Is it possible to have code running in the backround?
-----------------------------------
Just so I can learn, what does parallelput do?

-----------------------------------
Tony
Thu Jun 05, 2008 8:52 pm

Re: RE:Is it possible to have code running in the backround?
-----------------------------------
what does parallelput do?
the bit-pattern encoding the integer argument sets the high/low pins on the parallel port. It requires some pretty old hardware and some cut-up cables, but it's an easy way to hooked up to electronic components such as 5v motors and LEDs.

-----------------------------------
Insectoid
Fri Jun 06, 2008 9:22 am

RE:Is it possible to have code running in the backround?
-----------------------------------
Oh, so that's what I'm going to be using with my LED binary conversion project I guess...
