BOM (Bearing and Orientation Module)

Functions for dealing with the BOM. More...

Defines

#define BOM_ALL   0xFFFF
 Include all elements in the 16-bit bitfield.
#define BOM10   0
 Original BOM - No Range, No Individual LED control.
#define BOM15   1
 BOM 1.5 - No Range, Individual LED control.
#define RBOM   2
 RBOM - Range, Individual LED control.

Functions

void bom_init (char type)
 Initialize the bom according to bom type.
void bom_refresh (int bit_field)
 Refresh bom_val[] with new values from analog8. analog_init and bom_init must be called for this to work.
int bom_get (int which)
 Gets the bom reading from bom_val[which]. Call bom_refresh beforehand to read new bom values.
int bom_get_max (void)
 Compares all the values in bom_val[] and returns the index to the highest value element.
void bom_set_leds (int bit_field)
 Enables the selected bom leds on a BOM1.5.
int get_max_bom (void)
 (DEPRECATED) Gets and compares all bom values. Returns the index to the highest value element.
void bom_on (void)
 Turns on all BOM leds, or turns on enabled leds on a BOM1.5.
void bom_off (void)
 Turns off all bom leds.

Detailed Description

Functions for dealing with the BOM.

The Bearing and Orientation Module / Barrel of Monkeys / BOM is a custom sensor designed and built by the Colony Project. It consists of a ring of 16 IR emitters and 16 IR detectors. The BOM is most often use to determine the direction of other robots. This module contains functions for controlling the BOM.

Include bom.h to access these functions.


Function Documentation

int bom_get ( int  which  ) 

Gets the bom reading from bom_val[which]. Call bom_refresh beforehand to read new bom values.

Gets the bom reading from bom_val[which]. Call bom_refresh beforehand to read new bom values.

Parameters:
which which bom value to return
Returns:
the bom value
see bom_refresh

int bom_get_max ( void   ) 

Compares all the values in bom_val[] and returns the index to the highest value element.

Compares all the values in bom_val[] and returns the index to the lowest (max) value element.

Returns:
index to the lowest (max) bom value element. -1 if no value is lower than BOM_VALUE_THRESHOLD

Referenced by get_max_bom().

void bom_init ( char  type  ) 

Initialize the bom according to bom type.

Initializes the BOM. Call bom_init before reading bom values or turning bom leds.

INCOMPLETE - No utilization of BOM1.5 RSSI capability. Probably leave this out until Cornell and Pras return

See also:
bom_refresh, bom_leds_on, bom_leds_off

References BOM10, BOM15, BOM_ALL, bom_set_leds(), digital_output(), and RBOM.

Referenced by dragonfly_init().

void bom_off ( void   ) 

Turns off all bom leds.

Turns off all bom leds.

See also:
bom_on

References BOM10, BOM15, digital_output(), and RBOM.

void bom_on ( void   ) 

Turns on all BOM leds, or turns on enabled leds on a BOM1.5.

Flashes the BOM. If using a BOM1.5, only the emitters that have been enabled using bom_set_leds will turn on.

See also:
bom_off, bom_set_leds

References BOM10, BOM15, digital_output(), and RBOM.

void bom_refresh ( int  bit_field  ) 

Refresh bom_val[] with new values from analog8. analog_init and bom_init must be called for this to work.

Iterates through each bit in the bit_field. For each set bit, sets the corresponding bom select bits and updates the corresponding bom value with an analog_get8 reading. analog_init and bom_init must be called for this to work.

Parameters:
bit_field specifies which elements in bom_val[] should be updated. Use BOM_ALL to refresh all values. Ex. if 0x0003 is passed, bom_val[0] and bom_val[1] will be updated.
See also:
bom_get

References analog_get8(), analog_start_loop(), and analog_stop_loop().

Referenced by get_max_bom().

void bom_set_leds ( int  bit_field  ) 

Enables the selected bom leds on a BOM1.5.

Iterates through each bit in the bit_field. If the bit is set, the corresponding emitter will be enabled to turn on when bom_on() is called. bom_init must be called for this to work. Does nothing if a BOM1.0 is installed

Parameters:
bit_field specifies which leds should be turned on when bom_on is called. Use BOM_ALL to turn on all bom leds. Ex. if 0x0005 is passed, leds 0 and 2 will be turned on.

References BOM10, BOM15, digital_output(), and RBOM.

Referenced by bom_init().

int get_max_bom ( void   ) 

(DEPRECATED) Gets and compares all bom values. Returns the index to the highest value element.

(DEPRECATED) Returns the direction of the maximum BOM reading, as an integer in the range 0-15. 0 indicates to the robot's right, while the rest of the sensors are numbered counterclockwise. This is useful for determining the direction of a robot flashing its BOM, of only one robot is currently doing so. analog_init must be called before this function can be used.

Returns:
the direction of the maximum BOM reading
See also:
analog_init

References BOM_ALL, bom_get_max(), and bom_refresh().


Generated on Thu Apr 16 18:33:23 2009 for libdragonfly by  doxygen 1.5.5