|
1 | | -# Arduino Print |
| 1 | +# Device Setup |
2 | 2 |
|
3 | | -Methods used to support Arduino Print functionality. |
| 3 | +Methods used to setup and configure the device before taking data samples. |
4 | 4 |
|
5 | | -### setCursor() |
| 5 | +## Configuration |
6 | 6 |
|
7 | | -This method is called set the "cursor" position in the device. The library supports the Arduino `Print` interface, enabling the use of a `print()` and `println()` methods. The set cursor position defines where to start text output for this functionality. |
| 7 | +### getTMF882XConfig() |
| 8 | + |
| 9 | +The underlying TMF882X SDK uses a "configuration structure" to read and modify the configuration of the connected device. This method retrieves the current configuration of the device. |
| 10 | + |
| 11 | +When changing a value of the configuration, the following steps are taken: |
| 12 | +* Retrieve the current configuration using `getTMF882XConfig()` |
| 13 | +* Change the value in the configuration structure |
| 14 | +* Updating the device configuration using the method `setTMF882XConfig()` |
| 15 | + |
| 16 | +The configuration is transferred as a structure of type `struct tmf882x_mode_app_config`. This structure is defined by the TMF882X SDK, and contains the following fields: |
| 17 | + |
| 18 | +| Type | Struct Field | Description | |
| 19 | +| :--- | :--- | :--- | |
| 20 | +| uint16_t | report_period_ms | Result reporting period in milliseconds | |
| 21 | +| uint16_t | kilo_iterations | Iterations * 1024 for measurements | |
| 22 | +| uint16_t | low_threshold | Low distance threshold setting triggering interrupts | |
| 23 | +| uint16_t | high_threshold | High distance threshold setting triggering interrupts | |
| 24 | +| uint32_t | zone_mask | Zone mask for disabling interrupts for certain channels | |
| 25 | +| uint8_t | persistence | Persistence setting for generating interrupts | |
| 26 | +| uint8_t | confidence_threshold | Confidence threshold for generating interrupts | |
| 27 | +| uint8_t | gpio_0 | GPIO_0 config settings | |
| 28 | +| uint8_t | gpio_1 | GPIO_1 config settings | |
| 29 | +| uint8_t | power_cfg | Power configuration settings | |
| 30 | +| uint8_t | spad_map_id | Spad map identifier | |
| 31 | +| uint32_t | alg_setting | Algorithm setting configuration | |
| 32 | +| uint8_t | histogram_dump | Histogram dump configuration | |
| 33 | +| uint8_t | spread_spectrum | Spread Spectrum configuration | |
| 34 | +| uint8_t | i2c_slave_addr | I2C slave address configuration | |
| 35 | +| uint16_t | oscillator_trim | Sensor Oscillator trim value | |
| 36 | + |
| 37 | +The details and specific values for the above fields are detailed in the TMF882X datasheet. |
| 38 | + |
| 39 | +```c++ |
| 40 | + bool getTMF882XConfig(struct tmf882x_mode_app_config tofConfig) |
| 41 | +``` |
| 42 | +
|
| 43 | +| Parameter | Type | Description | |
| 44 | +| :--- | :--- | :--- | |
| 45 | +| tofConfig | `struct tmf882x_mode_app_config` | A configuration structure that the current configuration data is copied to| |
| 46 | +| return value| `bool` | `true` on success, `false` on an error | |
| 47 | +
|
| 48 | +
|
| 49 | +### setTMF882XConfig() |
| 50 | +
|
| 51 | +Call this method to set the current configuration page in the connected TMF882X device. A `tmf882x_mode_app_config` structure with the desired values is passed into this method. Details of the structure fields are listed in the description of the `getTMF882XConfig()` method. |
| 52 | +
|
| 53 | +When changing a value of the configuration, the following steps are taken: |
| 54 | +* Retrieve the current configuration using `getTMF882XConfig()` |
| 55 | +* Change the value in the configuration structure |
| 56 | +* Updating the device configuration using the method `setTMF882XConfig()` |
8 | 57 |
|
9 | 58 | ```c++ |
10 | | -void setCursor(uint8_t x, uint8_t y) |
| 59 | +bool setTMF882XConfig(struct tmf882x_mode_app_config tofConfig) |
11 | 60 | ``` |
12 | 61 |
|
13 | 62 | | Parameter | Type | Description | |
14 | 63 | | :--- | :--- | :--- | |
15 | | -| x | `uint8_t` | The X coordinate of the cursor| |
16 | | -| y | `uint8_t` | The Y coordinate of the cursor| |
| 64 | +| tofConfig | `struct tmf882x_mode_app_config` | A configuration structure that has the desired settings for the device| |
| 65 | +| return value| `bool` | `true` on success, `false` on an error | |
| 66 | + |
| 67 | +## SPAD Settings |
| 68 | + |
17 | 69 |
|
18 | | -### setColor() |
| 70 | +### getCurrentSPADMap() |
19 | 71 |
|
20 | | -This method is called to set the current color of the system. This is used by the Arduino `Print` interface functionality |
| 72 | +This method returns the ID of the current SPAD Map in use on the device. The TMF882X uses a _SPAD Map_ to control the viewing geometry of the sample data retrieved from the sensor. Consult the TMF882X datasheet for SPAD Map details as available ID values. |
| 73 | + |
| 74 | +```c++ |
| 75 | +uint8_t getCurrentSPADMap(void) |
| 76 | +``` |
| 77 | +
|
| 78 | +| Parameter | Type | Description | |
| 79 | +| :--- | :--- | :--- | |
| 80 | +| return value| `uint8_t` | `0` on error, otherwise the ID of the SPAD Map| |
| 81 | +
|
| 82 | +### setCurrentSPADMap() |
| 83 | +
|
| 84 | +This method sets the current SPAD map in the connected device. The SPAD Map is specified by its ID. Available SPAD Maps and their associated IDs are listed in the TMF882X datasheet. |
| 85 | +
|
| 86 | +```c++ |
| 87 | +bool setCurrentSPADMap(uint8_t idSPAD) |
| 88 | +``` |
| 89 | + |
| 90 | +| Parameter | Type | Description | |
| 91 | +| :--- | :--- | :--- | |
| 92 | +| idSPAD| `uint8_t` | The ID of the SPAD to make current on the device | |
| 93 | +| return value| `bool` | `true` on success, `false` on an error | |
| 94 | + |
| 95 | +### getSPADConfig() |
| 96 | + |
| 97 | +Retrieve the current SPAD configuration from the connected device. This configuration is returned as a `tmf882x_mode_app_spad_config` structure. |
| 98 | + |
| 99 | + |
| 100 | +The SPAD configuration structure is defined as follows: |
| 101 | +```C++ |
| 102 | +struct tmf882x_mode_app_spad_config { |
| 103 | + struct tmf882x_mode_app_single_spad_config { |
| 104 | + int8_t xoff_q1; |
| 105 | + int8_t yoff_q1; |
| 106 | + uint8_t xsize; |
| 107 | + uint8_t ysize; |
| 108 | + uint8_t spad_mask[TMF8X2X_COM_MAX_SPAD_SIZE]; |
| 109 | + uint8_t spad_map[TMF8X2X_COM_MAX_SPAD_SIZE]; |
| 110 | + } spad_configs[TMF8X2X_MAX_CONFIGURATIONS]; |
| 111 | + uint32_t num_spad_configs; |
| 112 | +}; |
| 113 | +``` |
| 114 | +The fields are defined as: |
| 115 | +
|
| 116 | +| Type | Struct Field | Description | |
| 117 | +| :--- | :--- | :--- | |
| 118 | +| int8_t | xoff_q1 | X-direction offset in Q1 format | |
| 119 | +| int8_t | yoff_q1 | Y-direction offset in Q1 format | |
| 120 | +| uint8_t | xsize | Size of spad map in X-direction | |
| 121 | +| uint8_t | ysize | Size of spad map in Y-direction | |
| 122 | +| uint8_t | spad_mask | Spad enable mask configuration (1 enable, 0 disable)| |
| 123 | +| uint8_t | spad_map | Spad channel mapping for measurement (channels 1 - 9) | |
| 124 | +| uint32_t | num_spad_configs | he number of spad configurations | |
21 | 125 |
|
| 126 | +The details and specific values for the above fields are detailed in the TMF882X datasheet. |
22 | 127 |
|
23 | 128 | ```c++ |
24 | | -void setColor(uint8_t clr) |
| 129 | +bool getSPADConfig(struct tmf882x_mode_app_spad_config tofSpad) |
25 | 130 | ``` |
26 | 131 |
|
27 | 132 | | Parameter | Type | Description | |
28 | 133 | | :--- | :--- | :--- | |
29 | | -| `clr` | `uint8_t` | The color to set. 0 = black, > 0 = white| |
| 134 | +| tofSpad| `struct tmf882x_mode_app_spad_config` | Struct to hold the current SPAD configuration values. | |
| 135 | +| return value| `bool` | `true` on success, `false` on an error | |
30 | 136 |
|
31 | | -### getColor() |
| 137 | +### setSPADConfig() |
32 | 138 |
|
33 | | -This method is called to get the current color of the system. This is used by the Arduino `Print` interface functionality |
| 139 | +Set the current SPAD configuration in the connected device. This configuration is set using a `tmf882x_mode_app_spad_config` structure. This method is used to set custom SPAD Maps in the TMF882X. |
34 | 140 |
|
| 141 | +See the descriptor of `getSPADConfig()` for details of the `tmf882x_mode_app_spad_config`. |
35 | 142 |
|
36 | 143 | ```c++ |
37 | | -uint8_t getColor(void) |
| 144 | +bool setSPADConfig(struct tmf882x_mode_app_spad_config tofSpad) |
38 | 145 | ``` |
39 | 146 |
|
40 | 147 | | Parameter | Type | Description | |
41 | 148 | | :--- | :--- | :--- | |
42 | | -| return value| `uint8_t` | The current color| |
| 149 | +| tofSpad| `struct tmf882x_mode_app_spad_config` | The config values for the on device SPAD settings. | |
| 150 | +| return value| `bool` | `true` on success, `false` on an error | |
0 commit comments