Defines | |
#define | BOM_ALL 0xFFFF |
Include all elements in the 16-bit bitfield. | |
#define | BOM 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_leds_on (int bit_field) |
Turns on the selected bom leds. Only works with BOM_ALL if using the original bom. | |
void | bom_leds_off (int bit_field) |
Turns off the selected bom leds. Only works with BOM_ALL if using the original bom. | |
int | get_max_bom (void) |
(DEPRECATED) Gets and compares all bom values. Returns the index to the highest value element. | |
void | bom_on (void) |
(DEPRECATED) Turns on all bom leds. | |
void | bom_off (void) |
(DEPRECATED) Turns off all bom leds. |
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.
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.
which | which bom value to return |
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.
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 - need to fill in init routine for BOM15
void bom_leds_off | ( | int | bit_field | ) |
Turns off the selected bom leds. Only works with BOM_ALL if using the original bom.
Iterates through each bit in the bit_field. For each set bit, turns off the corresponding bom led. bom_init must be called for this to work. Only works with BOM_ALL if using the original bom.
bit_field | specifies which leds should be turned off. Use BOM_ALL to turn off all bom leds. Ex. if 0x000B is passed, leds 0 and 3 will be turned off. |
void bom_leds_on | ( | int | bit_field | ) |
Turns on the selected bom leds. Only works with BOM_ALL if using the original bom.
Iterates through each bit in the bit_field. For each set bit, turns on the corresponding bom led. bom_init must be called for this to work. Only works with BOM_ALL if using the original bom.
bit_field | specifies which leds should be turned on. Use BOM_ALL to turn on all bom leds. Ex. if 0x0005 is passed, leds 0 and 2 will be turned on. |
void bom_off | ( | void | ) |
void bom_on | ( | void | ) |
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.
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. |
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.