Updated Sensor API (markdown)

Andre Thomas 2019-02-03 13:35:56 +02:00
parent fd853ce00d
commit 0d9d206caf
1 changed files with 3 additions and 2 deletions

@ -2,7 +2,6 @@ This wiki page is an attempt to document the Tasmota sensor API for sensor drive
# Important things to consider
* There are several I2C sensor examples you can take from the development codebase when writing your own and you are encouraged to do this as it is a quick and easy way to see how things fit together.
* There are currently no SPI drivers as examples in the development codebase. To see a SPI example look in the development_display codebase.
* The Tasmota firmware is essentially intended for Sonoff devices and commits to the main development branch will be subject to review based on whether or not what you intend to develop or add to the existing code is relevant to the general Sonoff device users.
* That being said, there is a lot of development going into the firmware which extends the functionality of standard off the shelf Sonoff devices, the firmware in itself is also useful to other ESP8266 based boards such as the WeMos ESP8266 boards and more technically inclined individuals who use generic ESP8266 modules in their own circuits which provides more access to pins and the ability to add more sensors and hardware external to the Sonoff device or the generic ESP8266 module circuits.
* The resources on the ESP8266 are finite. Most of the Sonoff devices ship with 1Mbyte SPI flash chips which means for the generic Sonoff device users the code generally needs to be less than 502Kbytes to ensure that OTA (Over The Air) flash functionality (which is the main reason why people use this firmware) remains available. RAM is also limited to an absolute maximum of 80Kbytes. This memory is divided into heap (used by global variables and Strings) and stack (used by local variables) where stack space is just 4Kbytes.
@ -18,9 +17,11 @@ This wiki page is an attempt to document the Tasmota sensor API for sensor drive
# Directory/file structure
Sensor libraries are located in the `lib/` directory. Sensor drivers are located in the `sonoff/` directory. The filename of the sensor driver is `xsns_<driver_ID>_<driver_name>.ino`, e.g. `xsns_05_ds18b20.ino` where `<driver_ID>` is a _unique_ number between 01 and 90 and `<driver_name>` is a human-readable name of the driver.
Using generic libraries from external sources for sensors should be avoided as far as possible as they usually include code for other platforms and are not always written in an optimised way.
# 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 `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 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>`.
## Callback function