Changeset 785

Show
Ignore:
Timestamp:
08/06/08 13:09:34 (3 months ago)
Author:
liamstask
Message:

- update dip switch doc
- move autosend functions into OSC #ifdef

Files:
1 modified

Legend:

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

    r775 r785  
    4646* The DIP Switch subsystem reads values in from the 8 position DIP Switch (0 - 255) on the Application Board. 
    4747  Mask off the appropriate bits in the value returned from the DIP switch to determine whether a particular channel is on or off. 
     48   
     49  See the <a href="http://www.makingthings.com/documentation/tutorial/application-board-overview/user-interface"> 
     50  Application Board overview</a> for details. 
    4851* \ingroup Libraries 
    4952* @{ 
     
    5457  @param state An integer specifying the state of the DIP Switch - 1 (on) or 0 (off). 
    5558  @return Zero on success. 
     59   
     60  \b Example 
     61  \code 
     62  // enable the DIP switch 
     63  DipSwitch_SetActive(1); 
     64  \endcode 
    5665*/ 
    5766int DipSwitch_SetActive( int state ) 
     
    8089  Returns the active state of the DIP Switch. 
    8190  @return The active state of the DIP Switch - 1 (active) or 0 (inactive). 
     91   
     92  \b Example 
     93  \code 
     94  if( DipSwitch_GetActive() ) 
     95  { 
     96    // DIP switch is active 
     97  } 
     98  else 
     99  { 
     100    // DIP switch is not active 
     101  } 
     102  \endcode 
    82103*/ 
    83104int DipSwitch_GetActive( ) 
     
    89110  Read the current configuration of the on-board DIP switch. 
    90111  @return An integer from 0-255 indicating the current configuration of the DIP switch. 
     112   
     113  \b Example 
     114  \code 
     115  int dip_switch = DipSwitch_GetValue(); 
     116  // now dip_switch has a bitmask of all 8 channels of the DIP switch 
     117  \endcode 
    91118*/ 
    92119int DipSwitch_GetValue( ) 
     
    120147/** 
    121148  Read a single channel's value. 
     149  This is a convenience function that relies on DipSwitch_GetValue() 
     150  internally, but extracts the value for a given channel. 
    122151  @param channel The channel (0-7) you'd like to read. 
    123152  return true if the channel is on, false if it's off. 
    124153  @see DipSwitch_GetValue( ) 
     154   
     155  \b Example 
     156  \code 
     157  if(DipSwitch_GetValueChannel(4) ) 
     158  { 
     159    // DIP switch channel 4 is on 
     160  } 
     161  else 
     162  { 
     163    // DIP switch channel 4 is off 
     164  } 
     165  // now dip_switch has a bitmask of all 8 channels of the DIP switch 
     166  \endcode 
    125167*/ 
    126168bool DipSwitch_GetValueChannel( int channel ) 
     
    134176  else 
    135177    return ((val << channel) & 0x1); 
    136 } 
    137  
    138 bool DipSwitch_GetAutoSend( bool init ) 
    139 { 
    140   DipSwitch_SetActive( 1 ); 
    141   if( init ) 
    142   { 
    143     int autosend; 
    144     Eeprom_Read( EEPROM_DIPSWITCH_AUTOSEND, (uchar*)&autosend, 4 ); 
    145     DipSwitch->autosend = (autosend == 1 ) ? 1 : 0; 
    146   } 
    147   return DipSwitch->autosend; 
    148 } 
    149  
    150 void DipSwitch_SetAutoSend( int onoff ) 
    151 { 
    152   DipSwitch_SetActive( 1 ); 
    153   if( DipSwitch->autosend != onoff ) 
    154   { 
    155     DipSwitch->autosend = onoff; 
    156     Eeprom_Write( EEPROM_DIPSWITCH_AUTOSEND, (uchar*)&onoff, 4 ); 
    157   } 
    158178} 
    159179 
     
    256276#include "osc.h" 
    257277 
     278bool DipSwitch_GetAutoSend( bool init ) 
     279{ 
     280  DipSwitch_SetActive( 1 ); 
     281  if( init ) 
     282  { 
     283    int autosend; 
     284    Eeprom_Read( EEPROM_DIPSWITCH_AUTOSEND, (uchar*)&autosend, 4 ); 
     285    DipSwitch->autosend = (autosend == 1 ) ? 1 : 0; 
     286  } 
     287  return DipSwitch->autosend; 
     288} 
     289 
     290void DipSwitch_SetAutoSend( int onoff ) 
     291{ 
     292  DipSwitch_SetActive( 1 ); 
     293  if( DipSwitch->autosend != onoff ) 
     294  { 
     295    DipSwitch->autosend = onoff; 
     296    Eeprom_Write( EEPROM_DIPSWITCH_AUTOSEND, (uchar*)&onoff, 4 ); 
     297  } 
     298} 
     299 
    258300static char* DipSwitchOsc_Name = "dipswitch"; 
    259301static char* DipSwitchOsc_PropertyNames[] = { "active", "value", "autosend",  0 }; // must have a trailing 0