anchor.diff:      [
         {gpio_pin_phase_A, {0}}, %| int | 0 | 0..40 |
         {gpio_pin_phase_B, {0}}, %| int | 0 | 0..40 |
  -      {phase_int_edge, {both}}, %| enum | both | falling, rising, both |
  -      {gpio_pin_switch, {0}}, %| int | 0 | 0..40 |
  -      {switch_int_edge, {falling}} %| enum | falling | falling, rising, both |
  +      {phase_int_edge, {both}} %| enum | both | falling, rising, both |
       ]). 
   
   
  
positive.code:     
    % Get the GPIO interrupt edge directions used by this block
    {ok, PhaseIntEdge} = attrib_utils:get_value(Config, phase_int_edge),
    {ok, SwitchIntEdge} = attrib_utils:get_value(Config, switch_int_edge),
    
    % Initialize the GPIO pins
    case config_utils:init_gpio(Config, Private, gpio_pin_phase_A, input) of
      {ok, Private1, GpioPinA_Ref} ->
        gpio_utils:register_int(GpioPinA_Ref),
        gpio_utils:set_int(GpioPinA_Ref, PhaseIntEdge),
        LastA_Value = gpio_utils:read_bool(GpioPinA_Ref),
        Private2 = attrib_utils:add_attribute(Private1, {last_A_value, {LastA_Value}}),
  
        case config_utils:init_gpio(Config, Private2, gpio_pin_phase_B, input) of
          {ok, Private3, GpioPinB_Ref} ->
            gpio_utils:register_int(GpioPinB_Ref),
            gpio_utils:set_int(GpioPinB_Ref, PhaseIntEdge),
            LastB_Value = gpio_utils:read_bool(GpioPinB_Ref),
            Private4 = attrib_utils:add_attribute(Private3, {last_B_value, {LastB_Value}}),
        
            case config_utils:init_gpio(Config, Private4, gpio_pin_switch, input) of
              {ok, Private5, GpioPinSwRef} ->
                gpio_utils:register_int(GpioPinSwRef),
                gpio_utils:set_int(GpioPinSwRef, SwitchIntEdge),
                LastSwValue = gpio_utils:read_bool(GpioPinSwRef),
                Private6 = attrib_utils:add_attribute(Private5, {last_sw_value, {LastSwValue}}),
                Value = null,
                Status = initialed;
                
              {error, _Reason} ->
                Value = null, 
                Status = proc_err,
                Private6 = Private4
            end;
  
          {error, _Reason} ->
             Value = null, 
            Status = proc_err,
            Private6 = Private2
        end;
  
      {error, _Reason} ->
        Value = null, 
        Status = proc_err,
        Private6 = Private
    end,
    
    Outputs1 = output_utils:set_value_status(Outputs, Value, Status),
    
    % This is the block state
    {Config, Inputs, Outputs1, Private6}.
  
  %%
  %%  Execute the block specific functionality
  
negative.code:   PhaseB = gpio_utils:read_bool(GpioPinB_Ref),
    {ok, _LastB_Value} = attrib_utils:get_value(Private, last_B_value),
  
    case attrib_utils:get_value(Outputs, value) of
      {ok, null}  -> Count = 0;
      {ok, Count} -> Count
    end,
   
    if (LastA_Value) andalso (not PhaseA) ->
  