Shop OBEX P1 Docs P2 Docs Learn Events
Test — Parallax Forums

Test

w4fejw4fej Posts: 264
edited 2014-10-10 02:56 in General Discussion
pub config(pin1, mode1, state1)  'pin, 0-single 1-dual, 0-manual 1-auto refresh, returns ID of refresh cog

  if (not state) and state1   'clears cog influence when transitioning from manual state to auto state
    dira[pin1]~
    outa[pin1]~
    
  pin  := pin1             'set internal
  mode := mode1            'configuration
  state := state1          'variables
  
  if not state         'get cog ready to pulse and kill any auto cog
    stop
    dira[pin]~~
    outa[pin]~

  if state                  'setup and launch refresh cog in auto mode
    if not motor1           'set motor1 pulsewidth if not set
      set_motor1(1500)
    if not motor2           'set motor2 pulsewidth if not set
      set_motor2(1500)
    if not cog              'launch refresh cog if not already running
      cog := cognew(refresh_cog, @hb_stack) + 1

  return cog - 1          'returns cog running refresh code, returns -1 if no refresh cog running

End of test

Comments

  • ganjaganja Posts: 1
    edited 2014-10-07 23:45
    test bold test quote
    quote
  • mklrobomklrobo Posts: 420
    edited 2014-10-10 02:56
    w4fej wrote: »
    pub config(pin1, mode1, state1)  'pin, 0-single 1-dual, 0-manual 1-auto refresh, returns ID of refresh cog
    
      if (not state) and state1   'clears cog influence when transitioning from manual state to auto state
        dira[pin1]~
        outa[pin1]~
        
      pin  := pin1             'set internal
      mode := mode1            'configuration
      state := state1          'variables
      
      if not state         'get cog ready to pulse and kill any auto cog
        stop
        dira[pin]~~
        outa[pin]~
    
      if state                  'setup and launch refresh cog in auto mode
        if not motor1           'set motor1 pulsewidth if not set
          set_motor1(1500)
        if not motor2           'set motor2 pulsewidth if not set
          set_motor2(1500)
        if not cog              'launch refresh cog if not already running
          cog := cognew(refresh_cog, @hb_stack) + 1
    
      return cog - 1          'returns cog running refresh code, returns -1 if no refresh cog running
    

    End of test
    It looks like the program gets a cog to pulse a motor, automatically. I am curious,what is the total flow chart of the
    whole program? Thanks.
Sign In or Register to comment.