Shop OBEX P1 Docs P2 Docs Learn Events
Question - How do I Temporarly stop one method while another one runs? — Parallax Forums

Question - How do I Temporarly stop one method while another one runs?

lockadoclockadoc Posts: 115
edited 2010-01-18 05:28 in Propeller 1
I'm working on an object that has one method to make some Leds light up when it's dark, which works fine.
I·also have another method in this object that upon an input will blink the Leds for 2 minutes, which works fine unless the first method sences
darkness which in turn prevents the Leds from blinking because of the over-riding turning on of the Leds.

How do I temporarly over-ride the first method and than return controll to the first one?

Bill S·

Comments

  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-01-18 00:16
    Within one cog you cannot stop a method in its tracks; you need to spawn your sub-processes out to another cog so that you main cog (overall program manager) can stop them at will. Within one cog it's like calling a subroutine; the area of the program that could exert control is not active.

    In your other thread (on this same project) I showed you how to do this.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon McPhalen
    Hollywood, CA
  • lockadoclockadoc Posts: 115
    edited 2010-01-18 01:29
    thanks thst what made me check out if it was a problem in my object.
    I did not catch that I needed to run the light sensor in a cog of its own

    thanks
    Bill S
  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-01-18 04:25
    The *problem* is your sequences. Even though you are treating them like objects, they're really just subroutines and running in the main program, not separate from it which would allow shut-down control as you want.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon McPhalen
    Hollywood, CA
  • W9GFOW9GFO Posts: 4,010
    edited 2010-01-18 05:28
    lockadoc said...
    I'm working on an object that has one method to make some Leds light up when it's dark, which works fine.
    I also have another method in this object that upon an input will blink the Leds for 2 minutes, which works fine unless the first method sences
    darkness which in turn prevents the Leds from blinking because of the over-riding turning on of the Leds.

    How do I temporarly over-ride the first method and than return controll to the first one?

    Bill S

    Here is my simplistic approach;
    PUB Leds
    
    repeat
       CheckSensors
       if dark
         outa[noparse][[/noparse]led]~~
       else
         outa[noparse][[/noparse]led]~
       if blink
         !outa[noparse][[/noparse]led]
         waitcnt(clkfreq/2 + cnt)
    



    Rich H

    edit: I noticed that the question is really about something else described in another thread, I'll leave this up as I think it gives an answer for what was asked in this thread.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Simple Servo Tester, a kit from Gadget Gangster.

    Post Edited (W9GFO) : 1/18/2010 5:48:49 AM GMT
Sign In or Register to comment.