JM9 XRCU Board 0.1.4
Libraries API Reference
Loading...
Searching...
No Matches
CompoI Class Reference

Compound Eye Driver for XRCU. More...

#include <CompoI.h>

Inheritance diagram for CompoI:
Supported_sensor Supported_module

Public Member Functions

 CompoI (const uint32_t init_port)
 Creates a CompoI object.
void begin (const uint8_t init_i2c_address=DEFAULT_I2C_ADDRESS)
 Activates this compound eye module.
bool test_comm ()
 Checks whether communication is established.
uint16_t get_product_code ()
 Gets the JM9 product number of the connected module.
uint8_t get_channel_val (const uint8_t channel)
 Reads the IR intensity of a specific channel.
uint8_t get_max_idx ()
 Gets the channel number that reads the strongest IR intensity.
uint8_t get_max_val ()
 Gets the strongest IR intensity reading among all channels.
uint8_t get_min_idx ()
 Gets the channel number that reads the weakest IR intensity.
uint8_t get_min_val ()
 Gets the weakest IR intensity reading among all channels.
uint8_t get_avg_val ()
 Gets the mean average IR intensity reading of all channels.
void set_filter_on ()
 Turns on the signal filter to see IR balls only.
void set_filter_off ()
 Turns off the signal filter to see fire flames and sunlight only.
bool is_filter_on ()
 Checks whether the signal filter is turned on or not.
void calibrate ()
 Initializes the hardware.
void set_addr_0x01 ()
 Sets I2C address of the module to 0x01.
void set_addr_0x02 ()
 Sets I2C address of the module to 0x02.
void disable_vectors ()
 Disables the vector algorithm.
void enable_vectors ()
 Enables the vector algorithm.
void turn_off_leds ()
 Turns off LEDs.
void turn_on_leds ()
 Turns on LEDs.
bool are_leds_on ()
 Checks whether the LEDs are turned on or not.
uint8_t get_ball_angle ()
 Gets the ball angle.
uint32_t read_eeprom ()
 Gets the EEPROM values.
void reset ()
 Software resets the module.
int16_t get_ball_angle_360 ()
 Gets the ball angle from the entire circle.
int16_t get_ball_vector_mag ()
 Gets the ball strength calculated from vector algorithm.
int16_t get_max_val_360 ()
 Gets the strongest IR intensity reading among all channels.
int16_t get_avg_val_360 ()
 Gets the mean average IR intensity reading of all channels.
void set_resistance (const int16_t r)
 Sets the resistance in series to photodiode.
int16_t get_resistance ()
 Gets the resistance in series to photodiode.
int16_t get_channel_val_360 (const uint8_t channel)
 Reads the IR intensity of a specific channel.

Additional Inherited Members

Protected Member Functions inherited from Supported_sensor
 Supported_sensor ()
 Creates an object of a supported sensor.
Protected Member Functions inherited from Supported_module
 Supported_module ()
 Creates an object of a supported module.

Detailed Description

Compound Eye Driver for XRCU.

Author
YH Choi @ JM9

Constructor & Destructor Documentation

◆ CompoI()

CompoI::CompoI ( const uint32_t init_port)

Creates a CompoI object.

Parameters
init_portthe I2C port connected to this compound eye module

Member Function Documentation

◆ are_leds_on()

bool CompoI::are_leds_on ( )

Checks whether the LEDs are turned on or not.

Returns
true if the LEDs are turned on, false otherwise.
See also
turn_on_leds()
turn_off_leds()

◆ begin()

void CompoI::begin ( const uint8_t init_i2c_address = DEFAULT_I2C_ADDRESS)

Activates this compound eye module.

YOU MUST CALL ME IN void setup () FUNCTION TO USE THIS OBJECT PROPERLY. Configures the settings of the I2C bus and the chip.

Parameters
init_i2c_addressthe 7-bit I2C address of this compound eye module

◆ calibrate()

void CompoI::calibrate ( )

Initializes the hardware.

This is already completed at the factory. There is no need for the user to call this method.

◆ disable_vectors()

void CompoI::disable_vectors ( )

Disables the vector algorithm.

The ball angle and strength calculations could be either HSL-like or vector-sum. Only one algorithm is used at a time to do the calculations.

This setting is saved and re-applied immediately, no need to reset or power-off-power-on.

Since
Hardware Version 4: JM9-PSA-17074

◆ enable_vectors()

void CompoI::enable_vectors ( )

Enables the vector algorithm.

The ball angle and strength calculations could be either HSL-like or vector-sum. Only one algorithm is used at a time to do the calculations.

Vector algorithm treats each sensor reading as a vector pointing along the sensor direction, and finds the sum of all the available vectors. The direction of the sum vector is the direction of the ball, while the magnitude of the sum vector is (proportional to) the intensity of the ball.

This setting is saved and re-applied immediately, no need to reset or power-off-power-on.

Since
Hardware Version 4: JM9-PSA-17074

◆ get_avg_val()

uint8_t CompoI::get_avg_val ( )

Gets the mean average IR intensity reading of all channels.

Returns
the mean average IR intensity reading of all channels [0 : 255] (8-bit resolution)
Note
The actual maximum reading might vary under different lighting conditions.

◆ get_avg_val_360()

int16_t CompoI::get_avg_val_360 ( )

Gets the mean average IR intensity reading of all channels.

Connect 2 sensors to form a 360-degree detection circle. The detection range of [90 : 270] degrees requires stable connection with the paired sensor.

Returns
the mean average IR intensity reading of all channels [0 : 1023] (10-bit resolution)
Warning
This value has a different resolution than get_avg_val().
Since
Hardware Version 4: JM9-PSA-17074

◆ get_ball_angle()

uint8_t CompoI::get_ball_angle ( )

Gets the ball angle.

This value starts with 0 degrees at the West (i.e. leftmost sensor), and increases clockwise.

Returns
the ball angle [0 : 180] (in degrees)

◆ get_ball_angle_360()

int16_t CompoI::get_ball_angle_360 ( )

Gets the ball angle from the entire circle.

This value starts with 0 degrees at the North (i.e. front sensor) and increases clockwise. 0 degrees is defined as the North of the connected sensor.

Connect 2 sensors to form a 360-degree detection circle. The detection range of [90 : 270] degrees requires stable connection with the paired sensor.

Returns
the ball angle [0 : 360] (in degrees)
Note
The value is calculated from the chosen algorithm. See disable_vectors() and enable_vectors().
Warning
This value has a different zero-point from get_ball_angle().
Since
Hardware Version 4: JM9-PSA-17074

◆ get_ball_vector_mag()

int16_t CompoI::get_ball_vector_mag ( )

Gets the ball strength calculated from vector algorithm.

Connect 2 sensors to form a 360-degree detection circle. The detection range of [90 : 270] degrees requires stable connection with the paired sensor.

Note
The value is calculated from the chosen algorithm. See disable_vectors() and enable_vectors().
Returns
the magnitude of the ball vector [0 : ???]

◆ get_channel_val()

uint8_t CompoI::get_channel_val ( const uint8_t channel)

Reads the IR intensity of a specific channel.

Parameters
channelthe channel number of compound-eye to read its value [1 : 7]
Returns
the IR intensity read by the photodiodes of the selected channel [0 : 255] (8-bit resolution)
Note
The actual maximum reading might vary under different lighting conditions.

◆ get_channel_val_360()

int16_t CompoI::get_channel_val_360 ( const uint8_t channel)

Reads the IR intensity of a specific channel.

The channel starts with 0 at the North (i.e. front sensor) and increases clockwise. 0 degrees is defined as the North of the connected sensor.

Connect 2 sensors to form a 360-degree detection circle. The detection range of [90 : 270] degrees requires stable connection with the paired sensor.

Parameters
channelthe channel number of compound-eye to read its value [0 : 11]
Returns
the IR intensity read by the photodiodes of the selected channel [0 : 1023] (10-bit resolution)
Note
The actual maximum reading might vary under different lighting conditions.
Warning
This value has a different resolution than get_channel_val().
Since
Hardware Version 4: JM9-PSA-17074

◆ get_max_idx()

uint8_t CompoI::get_max_idx ( )

Gets the channel number that reads the strongest IR intensity.

Returns
the channel number that reads the strongest IR intensity [1 : 7]

◆ get_max_val()

uint8_t CompoI::get_max_val ( )

Gets the strongest IR intensity reading among all channels.

Returns
the strongest IR intensity reading among all channels [0 : 255] (8-bit resolution)
Note
The actual maximum reading might vary under different lighting conditions.

◆ get_max_val_360()

int16_t CompoI::get_max_val_360 ( )

Gets the strongest IR intensity reading among all channels.

Connect 2 sensors to form a 360-degree detection circle. The detection range of [90 : 270] degrees requires stable connection with the paired sensor.

Returns
the strongest IR intensity reading among all channels [0 : 1023] (10-bit resolution)
Note
The value is calculated from the chosen algorithm. See disable_vectors() and enable_vectors().
Warning
This value has a different resolution than get_max_val().
Since
Hardware Version 4: JM9-PSA-17074

◆ get_min_idx()

uint8_t CompoI::get_min_idx ( )

Gets the channel number that reads the weakest IR intensity.

Returns
the channel number that reads the weakest IR intensity [1 : 7]

◆ get_min_val()

uint8_t CompoI::get_min_val ( )

Gets the weakest IR intensity reading among all channels.

Returns
the weakest IR intensity reading among all channels [0 : 255] (8-bit resolution)
Note
The actual maximum reading might vary under different lighting conditions.

◆ get_product_code()

uint16_t CompoI::get_product_code ( )

Gets the JM9 product number of the connected module.

Returns
The JM9 product number of the connected module (e.g. 17074).

◆ get_resistance()

int16_t CompoI::get_resistance ( )

Gets the resistance in series to photodiode.

Returns
the resistance in ohms
Since
Hardware Version 4: JM9-PSA-17074

◆ is_filter_on()

bool CompoI::is_filter_on ( )

Checks whether the signal filter is turned on or not.

Returns
true if the signal filter is turned on, false otherwise.
See also
set_filter_on()
set_filter_off()

◆ read_eeprom()

uint32_t CompoI::read_eeprom ( )

Gets the EEPROM values.

This method is for internal use such as menu use only. The returned values do not provide a guaranteed meaning and are subject to change without notice.

Returns
EEPROM values [0x04, 0x03, 0x02, 0x01]

◆ set_addr_0x01()

void CompoI::set_addr_0x01 ( )

Sets I2C address of the module to 0x01.

This setting is saved and re-applied if the module is reset or power-off-power-on.

See also
set_addr_0x02()

◆ set_addr_0x02()

void CompoI::set_addr_0x02 ( )

Sets I2C address of the module to 0x02.

This setting is saved and re-applied if the module is reset or power-off-power-on.

See also
set_addr_0x01()

◆ set_filter_off()

void CompoI::set_filter_off ( )

Turns off the signal filter to see fire flames and sunlight only.

Only constant IR light sources are reflected in the readings. Signal ripples (such as IR balls) are removed from the readings.

Warning
Behaviour changed: This filter becomes a IR-ball / fire-flame filter since Hardware Version 4: JM9-PSA-17074.

◆ set_filter_on()

void CompoI::set_filter_on ( )

Turns on the signal filter to see IR balls only.

Only oscillating IR light sources are reflected in the readings. Background sunlight interference are removed from the readings.

Warning
Behaviour changed: This filter becomes a IR-ball / fire-flame filter since Hardware Version 4: JM9-PSA-17074.

◆ set_resistance()

void CompoI::set_resistance ( const int16_t r)

Sets the resistance in series to photodiode.

Adjusts the sensitivity of the photodiodes. This setting is saved and re-applied immediately, no need to reset or power-off-power-on.

Parameters
rthe resistance [2000 : 10470] in ohms
Since
Hardware Version 4: JM9-PSA-17074

◆ test_comm()

bool CompoI::test_comm ( )

Checks whether communication is established.

Returns
true if communication with the module is established, false otherwise

◆ turn_off_leds()

void CompoI::turn_off_leds ( )

Turns off LEDs.

This setting is saved and re-applied immediately, no need to reset or power-off-power-on.

◆ turn_on_leds()

void CompoI::turn_on_leds ( )

Turns on LEDs.

This setting is saved and re-applied immediately, no need to reset or power-off-power-on.


The documentation for this class was generated from the following file: