anchor.diff:  %% ====================================================================
   -export([groups/0, version/0]).
   -export([create/2, create/4, create/5, upgrade/1, initialize/1, execute/2, delete/1]).
  +-export([handle_info/2]).
   
   groups() -> [digital, input].
   
  -version() -> "0.1.0".
  +version() -> "0.2.0".
   
   
   %% Merge the block type specific, Config, Input, and Output attributes
  
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:       _DoNothingB -> ok
    end,
  
    {Config, Inputs, Outputs}.
  
  
  %% 
  %% GPIO Interupt message from Elixir ALE library, 
  %% Execute this block
  %% 
  -spec handle_info(Info :: term(), 
                    BlockState :: block_state()) -> {noreply, block_state()}.
  
  handle_info({gpio_interrupt, Pin, Condition}, BlockState) ->
    m_logger:debug("Rx interrupt: ~p from GPIO pin: ~p ~n", [Condition, Pin]),
    NewBlockState = block_common:execute(BlockState, hardware),
    {noreply, NewBlockState};
  
  %%
  %% Unknown Info message, just log a warning
  %% 
  handle_info(Info, BlockState) ->
    {BlockName, BlockModule} = config_utils:name_module(BlockState),
    m_logger:warning(block_type_name_unknown_info_msg, [BlockModule, BlockName, Info]),
    {noreply, BlockState}.  
  
  
  %% ====================================================================
  