Show
Ignore:
Timestamp:
07/31/08 13:20:15 (5 months ago)
Author:
liamstask
Message:

- add convenience routine for getting a single channel's value from the DIP switch, as per #45

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • firmware/trunk/libraries/dipswitch/dipswitch.c

    r704 r775  
    116116 
    117117  return r; 
     118} 
     119 
     120/** 
     121  Read a single channel's value. 
     122  @param channel The channel (0-7) you'd like to read. 
     123  return true if the channel is on, false if it's off. 
     124  @see DipSwitch_GetValue( ) 
     125*/ 
     126bool DipSwitch_GetValueChannel( int channel ) 
     127{ 
     128  if( channel < 0 || channel > 7 ) 
     129    return CONTROLLER_ERROR_ILLEGAL_INDEX; 
     130 
     131  int val = DipSwitch_GetValue(); 
     132  if( val < 0 ) 
     133    return false; 
     134  else 
     135    return ((val << channel) & 0x1); 
    118136} 
    119137