Shop OBEX P1 Docs P2 Docs Learn Events
TRying to start a blinker in a new cog — Parallax Forums

TRying to start a blinker in a new cog

lockadoclockadoc Posts: 115
edited 2009-10-17 04:29 in Propeller 1
I'm trying to start a blinker in a new cog ,to be used to let me see there is still life in the prop, while it does other things,
which might not happen for hours.

I've built this method by following page 81 in the PROP Manual, but I must be making an error for it will not blink the led.
Can some-one tell me what·I have·copied wrong?

Thanks BillyS

Comments

  • John AbshierJohn Abshier Posts: 1,116
    edited 2009-10-16 18:31
    LifeCogId is initialized to 0. When you call stop you stop the cog that Spin is running in.

    John Abshier
  • lockadoclockadoc Posts: 115
    edited 2009-10-16 18:55
    How do I correct that,, I don't see that in the book.



    Thanks

    BillyS
  • John AbshierJohn Abshier Posts: 1,116
    edited 2009-10-16 18:56
    A specific fix, not a general one, would be to change -1 to 0 in the if statement.

    John Abshier
  • MagIO2MagIO2 Posts: 2,243
    edited 2009-10-16 19:47
    Have a look at different Objects. That's why they tend to use cognew() + 1.

    Pub Start                                                           'Starts the new cog method
      Stop                                                              'Prevents multiple starts of this method
      LifeCogId := cognew (Life, @LifeStack)[b][color=green] + 1[/color][/b]                           'Starts and gets a cog ID
      
    Pub Stop                                                            'Stops the cog that was started  
       if LifeCogId[s][color=red][b] > -1
    [/b][/color][/s]    cogstop (LifecogId [b][color=green]- 1[/color][/b])
     
    
    

    That's the general fix.
  • lockadoclockadoc Posts: 115
    edited 2009-10-17 04:29
    thanks thats what I needed.I knew it was something very easy,
    But when you don't catch it at first, it looks real hard and can drive you nuts.

    Thanks BillyS
Sign In or Register to comment.