Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Is it possible to have code running in the backround?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
rss14




PostPosted: Thu Jun 05, 2008 3:49 pm   Post subject: 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?
Sponsor
Sponsor
Sponsor
sponsor
SNIPERDUDE




PostPosted: Thu Jun 05, 2008 3:57 pm   Post subject: RE:Is it possible to have code running in the backround?

look it up in the Turing Walkthrough about procedures
rss14




PostPosted: Thu Jun 05, 2008 4:00 pm   Post subject: RE:Is it possible to have code running in the backround?

Thank you for the link.
rss14




PostPosted: Thu Jun 05, 2008 5:08 pm   Post subject: 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




PostPosted: Thu Jun 05, 2008 5:51 pm   Post subject: 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




PostPosted: Thu Jun 05, 2008 7:56 pm   Post subject: 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




PostPosted: Thu Jun 05, 2008 8:22 pm   Post subject: Re: RE:Is it possible to have code running in the backround?

rss14 @ Thu Jun 05, 2008 7:56 pm wrote:
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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Insectoid




PostPosted: Thu Jun 05, 2008 8:35 pm   Post subject: RE:Is it possible to have code running in the backround?

Just so I can learn, what does parallelput do?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Jun 05, 2008 8:52 pm   Post subject: Re: RE:Is it possible to have code running in the backround?

insectoid @ Thu Jun 05, 2008 8:35 pm wrote:
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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Insectoid




PostPosted: Fri Jun 06, 2008 9:22 am   Post subject: 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...
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: