mirror of https://github.com/arendst/Tasmota.git
Updated Sensor API (markdown)
parent
49e4725b97
commit
8567bd1c5c
|
@ -21,7 +21,7 @@ Using generic libraries from external sources for sensors should be avoided as f
|
|||
|
||||
# API structure
|
||||
## Pre-processor directives
|
||||
Conditional compiling of a sensor driver is achieved by commenting/uncommenting a pre-processor directive of the scheme `USE_<driver_name>` in `my_user_config.h`. Accordingly the driver code has to be wrapped in `#ifdef USE_<driver_name> ... #endif // USE_<driver_name>`. Any Sensor driver must contain a pre-processor directive defining the driver ID by the scheme `#define XSNS_<driver_ID>`.
|
||||
Conditional compiling of a sensor driver is achieved by adding a pre-processor directive of the scheme `USE_<driver_name>` in `user_config_override.h`. Accordingly the driver code has to be wrapped in `#ifdef USE_<driver_name> ... #endif // USE_<driver_name>`. Any Sensor driver must contain a pre-processor directive defining the driver ID by the scheme `#define XSNS_<driver_ID>`.
|
||||
|
||||
## Callback function
|
||||
|
||||
|
@ -117,7 +117,7 @@ Setting a flag that the driver was successful in detecting the attached chip/boa
|
|||
|
||||
When writing your function responsible for detecting an externally connected I<sup>2</sup>C device try to create a method by which you read or write to specific registers that would be applicable to that specific I<sup>2</sup>C device only as to confirm a positive detect for the device. If this is not done extensively it will lead to some drivers getting false detects for a different device type simply because it shares the same I<sup>2</sup>C address.
|
||||
|
||||
Unless your driver is specifically going to use the entire array of addresses provisioned by the manufacturer please consider using a #define USE_MYCHIPNAME_ADDR in the user_config.h so that the user may specify the address on which to expect the device. This is of course only applicable to drivers that are not enabled by default in any of the pre-built binaries.
|
||||
Unless your driver is specifically going to use the entire array of addresses provisioned by the manufacturer please consider using a #define USE_MYCHIPNAME_ADDR in the `user_config_override.h` so that the user may specify the address on which to expect the device. This is of course only applicable to drivers that are not enabled by default in any of the pre-built binaries.
|
||||
|
||||
**I<sup>2</sup>C address auto-detection example**
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue