JM9 XRCU Board 0.1.4
Libraries API Reference
Loading...
Searching...
No Matches
CompoI.h
Go to the documentation of this file.
1
8
9#ifndef COMPOI_H
10#define COMPOI_H
11
12#include <Arduino.h>
13#include <Wire.h>
14
15#include <Supported_sensor.h>
16
21class CompoI : public Supported_sensor {
22 private:
26 const uint32_t port;
27
31 uint8_t i2c_address;
32
36 uint8_t prev_data_list [21];
37
41 uint8_t prev_ball_angle;
42
46 int16_t prev_ball_angle_360;
47
51 int16_t prev_ball_vector_mag;
52
56 int16_t prev_max_val_360;
57
61 int16_t prev_avg_val_360;
62
66 int16_t prev_resistance;
67
71 int16_t prev_channel_vals [12];
72
76 static const uint8_t DEFAULT_I2C_ADDRESS;
77
81 static const uint32_t I2C_FREQ;
82
86 static const uint32_t MODULE_RESPONSE_TIMEOUT_US;
87
91 static const uint32_t INTERVAL_BETWEEN_RETRIES_US;
92
100 bool query (const uint8_t cmd, const uint8_t rx_len);
101
108 bool try_send_command (const uint8_t cmd, const uint8_t rx_len = 0);
109
118 uint8_t command (const uint8_t cmd);
119
120 public:
126 CompoI (const uint32_t init_port);
127
135 void begin (const uint8_t init_i2c_address = DEFAULT_I2C_ADDRESS);
136
141 bool test_comm ();
142
147 uint16_t get_product_code ();
148
155 uint8_t get_channel_val (const uint8_t channel);
156
161 uint8_t get_max_idx ();
162
168 uint8_t get_max_val ();
169
174 uint8_t get_min_idx ();
175
181 uint8_t get_min_val ();
182
188 uint8_t get_avg_val ();
189
198
207
215
222 void calibrate ();
223
231
239
252
270
278
286
293 bool are_leds_on ();
294
300 uint8_t get_ball_angle ();
301
310 uint32_t read_eeprom ();
311
315 void reset ();
316
335
347
362 int16_t get_max_val_360 ();
363
376 int16_t get_avg_val_360 ();
377
388 void set_resistance (const int16_t r);
389
396 int16_t get_resistance ();
397
416 int16_t get_channel_val_360 (const uint8_t channel);
417};
418
419#endif // #ifndef COMPOI_H
uint8_t get_max_idx()
Gets the channel number that reads the strongest IR intensity.
int16_t get_channel_val_360(const uint8_t channel)
Reads the IR intensity of a specific channel.
void set_resistance(const int16_t r)
Sets the resistance in series to photodiode.
int16_t get_avg_val_360()
Gets the mean average IR intensity reading of all channels.
uint16_t get_product_code()
Gets the JM9 product number of the connected module.
void set_filter_off()
Turns off the signal filter to see fire flames and sunlight only.
uint8_t get_max_val()
Gets the strongest IR intensity reading among all channels.
void begin(const uint8_t init_i2c_address=DEFAULT_I2C_ADDRESS)
Activates this compound eye module.
void set_addr_0x01()
Sets I2C address of the module to 0x01.
int16_t get_ball_angle_360()
Gets the ball angle from the entire circle.
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 calibrate()
Initializes the hardware.
uint32_t read_eeprom()
Gets the EEPROM values.
bool test_comm()
Checks whether communication is established.
int16_t get_ball_vector_mag()
Gets the ball strength calculated from vector algorithm.
void turn_off_leds()
Turns off LEDs.
int16_t get_max_val_360()
Gets the strongest IR intensity reading among all channels.
uint8_t get_ball_angle()
Gets the ball angle.
void reset()
Software resets the module.
uint8_t get_channel_val(const uint8_t channel)
Reads the IR intensity of a specific channel.
int16_t get_resistance()
Gets the resistance in series to photodiode.
bool are_leds_on()
Checks whether the LEDs are turned on or not.
CompoI(const uint32_t init_port)
Creates a CompoI object.
void enable_vectors()
Enables the vector algorithm.
void disable_vectors()
Disables the vector algorithm.
void set_addr_0x02()
Sets I2C address of the module to 0x02.
void set_filter_on()
Turns on the signal filter to see IR balls only.
uint8_t get_min_idx()
Gets the channel number that reads the weakest IR intensity.
void turn_on_leds()
Turns on LEDs.
bool is_filter_on()
Checks whether the signal filter is turned on or not.
Supported_sensor()
Creates an object of a supported sensor.
Definition Supported_sensor.h:23