Bump version 7.0.0.3

Initial support for I2C driver runtime control using command I2CDriver and document I2CDEVICES.md
This commit is contained in:
Theo Arends 2019-11-03 17:54:39 +01:00
parent 3d40121fed
commit 1e29593469
45 changed files with 650 additions and 59 deletions

View File

@ -7,53 +7,54 @@ Tasmota supports several I2C devices but to use them they mostly need to be enab
## Supported I2C devices
The following table lists the supported I2C devices
Define | Driver | Device | Address(es) | Description
--------------------|---------|----------|-------------|-----------------------------------------------
USE_PCA9685 | xdrv_15 | PCA9685 | 0x40 - 0x47 | 16-channel 12-bit pwm driver
USE_PCF8574 | xdrv_28 | PCF8574 | 0x20 - 0x27 | 8-bit I/O expander
USE_PCF8574 | xdrv_28 | PCF8574A | 0x38 - 0x3F | 8-bit I/O expander
USE_DISPLAY_LCD | xdsp_01 | | 0x27, 0x3F | LCD display
USE_DISPLAY_SSD1306 | xdsp_02 | SSD1306 | 0x3C - 0x3D | Oled display
USE_DISPLAY_MATRIX | xdsp_03 | HT16K33 | 0x70 - 0x77 | 8x8 led matrix
USE_DISPLAY_SH1106 | xdsp_07 | SH1106 | 0x3C - 0x3D | Oled display
USE_ADE7953 | xnrg_07 | ADE7953 | 0x38 | Energy monitor
USE_HTU | xsns_08 | HTU21 | 0x40 | Temperature and Humidity sensor
USE_HTU | xsns_08 | SI7013 | 0x40 | Temperature and Humidity sensor
USE_HTU | xsns_08 | SI7020 | 0x40 | Temperature and Humidity sensor
USE_HTU | xsns_08 | SI7021 | 0x40 | Temperature and Humidity sensor
USE_BMP | xsns_09 | BMP085 | 0x76 - 0x77 | Pressure and temperature sensor
USE_BMP | xsns_09 | BMP180 | 0x76 - 0x77 | Pressure and temperature sensor
USE_BMP | xsns_09 | BMP280 | 0x76 - 0x77 | Pressure and temperature sensor
USE_BMP | xsns_09 | BME280 | 0x76 - 0x77 | Pressure, temperature and humidity sensor
USE_BMP | xsns_09 | BME680 | 0x76 - 0x77 | Pressure, temperature, humidity and gas sensor
USE_BH1750 | xsns_10 | BH1750 | 0x23, 0x5C | Ambient light intensity sensor
USE_VEML6070 | xsns_11 | VEML6070 | 0x38 - 0x39 | Ultra violet light intensity sensor
USE_ADS1115_I2CDEV | xsns_12 | ADS1115 | 0x48 - 0x4B | 4-channel 16-bit A/D converter
USE_ADS1115 | xsns_12 | ADS1115 | 0x48 - 0x4B | 4-channel 16-bit A/D converter
USE_INA219 | xsns_13 | INA219 | 0x40 - 0x41, 0x44 - 0x45 | Low voltage current sensor
USE_SHT3X | xsns_14 | SHT3X | 0x44 - 0x45 | Temperature and Humidity sensor
USE_SHT3X | xsns_14 | SHTC3 | 0x70 | Temperature and Humidity sensor
USE_TSL2561 | xsns_16 | TSL2561 | 0x29, 0x39, 0x49 | Light intensity sensor
USE_MGS | xsns_19 | Grove | 0x04 | Multichannel gas sensor
USE_SGP30 | xsns_21 | SGP30 | 0x58 | Gas (TVOC) and air quality sensor
USE_SI1145 | xsns_24 | SI1145 | 0x60 | Ultra violet index and light sensor
USE_SI1145 | xsns_24 | SI1146 | 0x60 | Ultra violet index and light sensor
USE_SI1145 | xsns_24 | SI1147 | 0x60 | Ultra violet index and light sensor
USE_LM75AD | xsns_26 | LM75AD | 0x48 - 0x4F | Temperature sensor
USE_APDS9960 | xsns_27 | APDS9960 | 0x39 | Proximity ambient light RGB and gesture sensor
USE_MCP230xx | xsns_29 | MCP23008 | 0x20 - 0x27 | 16-bit I/O expander
USE_MCP230xx | xsns_29 | MCP23017 | 0x20 - 0x27 | 16-bit I/O expander
USE_MPR121 | xsns_30 | MPR121 | 0x5A - 0x5D | Proximity capacitive touch sensor
USE_CCS811 | xsns_31 | CCS811 | 0x5A | Gas (TVOC) and air quality sensor
USE_MPU6050 | xsns_32 | MPU6050 | 0x68 - 0x69 | 3-axis gyroscope and temperature sensor
USE_DS3231 | xsns_33 | DS3231 | 0x68 | Real time clock
USE_MGC3130 | xsns_36 | MGC3130 | 0x42 | Electric field sensor
USE_MAX44009 | xsns_41 | MAX44009 | 0x4A - 0x4B | Ambient light intensity sensor
USE_SCD30 | xsns_42 | SCD30 | 0x61 | CO2 sensor
USE_SPS30 | xsns_44 | SPS30 | 0x69 | Particle sensor
USE_VL53L0X | xsns_45 | VL53L0X | 0x29 | Time-of-flight (ToF) distance sensor
USE_MLX90614 | xsns_46 | MLX90614 | 0x5A | Infra red temperature sensor
USE_CHIRP | xsns_48 | CHIRP | 0x20 | Soil moisture sensor
USE_PAJ7620 | xsns_50 | PAJ7620 | 0x73 | Gesture sensor
USE_INA226 | xsns_54 | INA226 | 0x40 - 0x41, 0x44 - 0x45 | Low voltage current sensor
USE_HIH6 | xsns_55 | HIH6130 | 0x27 | Temperature and Humidity sensor
Index | Define | Driver | Device | Address(es) | Description
------|---------------------|---------|----------|-------------|-----------------------------------------------
1 | USE_PCA9685 | xdrv_15 | PCA9685 | 0x40 - 0x47 | 16-channel 12-bit pwm driver
2 | USE_PCF8574 | xdrv_28 | PCF8574 | 0x20 - 0x27 | 8-bit I/O expander
2 | USE_PCF8574 | xdrv_28 | PCF8574A | 0x38 - 0x3F | 8-bit I/O expander
3 | USE_DISPLAY_LCD | xdsp_01 | | 0x27, 0x3F | LCD display
4 | USE_DISPLAY_SSD1306 | xdsp_02 | SSD1306 | 0x3C - 0x3D | Oled display
5 | USE_DISPLAY_MATRIX | xdsp_03 | HT16K33 | 0x70 - 0x77 | 8x8 led matrix
6 | USE_DISPLAY_SH1106 | xdsp_07 | SH1106 | 0x3C - 0x3D | Oled display
7 | USE_ADE7953 | xnrg_07 | ADE7953 | 0x38 | Energy monitor
8 | USE_SHT | xsns_07 | SHT1X | Any | Temperature and Humidity sensor
9 | USE_HTU | xsns_08 | HTU21 | 0x40 | Temperature and Humidity sensor
9 | USE_HTU | xsns_08 | SI7013 | 0x40 | Temperature and Humidity sensor
9 | USE_HTU | xsns_08 | SI7020 | 0x40 | Temperature and Humidity sensor
9 | USE_HTU | xsns_08 | SI7021 | 0x40 | Temperature and Humidity sensor
10 | USE_BMP | xsns_09 | BMP085 | 0x76 - 0x77 | Pressure and temperature sensor
10 | USE_BMP | xsns_09 | BMP180 | 0x76 - 0x77 | Pressure and temperature sensor
10 | USE_BMP | xsns_09 | BMP280 | 0x76 - 0x77 | Pressure and temperature sensor
10 | USE_BMP | xsns_09 | BME280 | 0x76 - 0x77 | Pressure, temperature and humidity sensor
10 | USE_BMP | xsns_09 | BME680 | 0x76 - 0x77 | Pressure, temperature, humidity and gas sensor
11 | USE_BH1750 | xsns_10 | BH1750 | 0x23, 0x5C | Ambient light intensity sensor
12 | USE_VEML6070 | xsns_11 | VEML6070 | 0x38 - 0x39 | Ultra violet light intensity sensor
13 | USE_ADS1115_I2CDEV | xsns_12 | ADS1115 | 0x48 - 0x4B | 4-channel 16-bit A/D converter
13 | USE_ADS1115 | xsns_12 | ADS1115 | 0x48 - 0x4B | 4-channel 16-bit A/D converter
14 | USE_INA219 | xsns_13 | INA219 | 0x40 - 0x41, 0x44 - 0x45 | Low voltage current sensor
15 | USE_SHT3X | xsns_14 | SHT3X | 0x44 - 0x45 | Temperature and Humidity sensor
15 | USE_SHT3X | xsns_14 | SHTC3 | 0x70 | Temperature and Humidity sensor
16 | USE_TSL2561 | xsns_16 | TSL2561 | 0x29, 0x39, 0x49 | Light intensity sensor
17 | USE_MGS | xsns_19 | Grove | 0x04 | Multichannel gas sensor
18 | USE_SGP30 | xsns_21 | SGP30 | 0x58 | Gas (TVOC) and air quality sensor
19 | USE_SI1145 | xsns_24 | SI1145 | 0x60 | Ultra violet index and light sensor
19 | USE_SI1145 | xsns_24 | SI1146 | 0x60 | Ultra violet index and light sensor
19 | USE_SI1145 | xsns_24 | SI1147 | 0x60 | Ultra violet index and light sensor
20 | USE_LM75AD | xsns_26 | LM75AD | 0x48 - 0x4F | Temperature sensor
21 | USE_APDS9960 | xsns_27 | APDS9960 | 0x39 | Proximity ambient light RGB and gesture sensor
22 | USE_MCP230xx | xsns_29 | MCP23008 | 0x20 - 0x27 | 16-bit I/O expander
22 | USE_MCP230xx | xsns_29 | MCP23017 | 0x20 - 0x27 | 16-bit I/O expander
23 | USE_MPR121 | xsns_30 | MPR121 | 0x5A - 0x5D | Proximity capacitive touch sensor
24 | USE_CCS811 | xsns_31 | CCS811 | 0x5A | Gas (TVOC) and air quality sensor
25 | USE_MPU6050 | xsns_32 | MPU6050 | 0x68 - 0x69 | 3-axis gyroscope and temperature sensor
26 | USE_DS3231 | xsns_33 | DS3231 | 0x68 | Real time clock
27 | USE_MGC3130 | xsns_36 | MGC3130 | 0x42 | Electric field sensor
28 | USE_MAX44009 | xsns_41 | MAX44009 | 0x4A - 0x4B | Ambient light intensity sensor
29 | USE_SCD30 | xsns_42 | SCD30 | 0x61 | CO2 sensor
30 | USE_SPS30 | xsns_44 | SPS30 | 0x69 | Particle sensor
31 | USE_VL53L0X | xsns_45 | VL53L0X | 0x29 | Time-of-flight (ToF) distance sensor
32 | USE_MLX90614 | xsns_46 | MLX90614 | 0x5A | Infra red temperature sensor
33 | USE_CHIRP | xsns_48 | CHIRP | 0x20 | Soil moisture sensor
34 | USE_PAJ7620 | xsns_50 | PAJ7620 | 0x73 | Gesture sensor
35 | USE_INA226 | xsns_54 | INA226 | 0x40 - 0x41, 0x44 - 0x45 | Low voltage current sensor
36 | USE_HIH6 | xsns_55 | HIH6130 | 0x27 | Temperature and Humidity sensor

View File

@ -1,4 +1,7 @@
/*********************************************************************************************\
* 7.0.0.3 20191103
* Initial support for I2C driver runtime control using command I2CDriver and document I2CDEVICES.md
*
* 7.0.0.2 20191102
* Add command WebColor19 to control color of Module and Name (#6811)
* Add support for Honeywell I2C HIH series Humidity and Temperetaure sensor (#6808)

View File

@ -280,6 +280,7 @@
#define D_CMND_LEDSTATE "LedState"
#define D_CMND_LEDMASK "LedMask"
#define D_CMND_I2CSCAN "I2CScan"
#define D_CMND_I2CDRIVER "I2CDriver"
#define D_CMND_SERIALSEND "SerialSend"
#define D_CMND_SERIALDELIMITER "SerialDelimiter"
#define D_CMND_BAUDRATE "Baudrate"

View File

@ -436,10 +436,11 @@ struct SYSCFG {
uint8_t free_e9e[2]; // E9E
uint8_t web_color2[2][3]; // EA0 - Needs to be on integer distance / 3 from web_color
uint8_t web_color2[2][3]; // EA0 - Needs to be on integer / 3 distance from web_color
uint8_t free_ea4[338]; // EA6
uint8_t free_ea4[326]; // EA6
uint32_t i2c_drivers[3]; // FEC I2cDriver
uint32_t cfg_timestamp; // FF8
uint32_t cfg_crc32; // FFC
} Settings;

View File

@ -897,6 +897,7 @@ void SettingsDefaultSet2(void)
SettingsDefaultWebColor();
memset(&Settings.monitors, 0xFF, 20); // Enable all possible monitors, displays and sensors
SettingsEnableAllI2cDrivers();
}
/********************************************************************************************/
@ -929,6 +930,13 @@ void SettingsDefaultWebColor(void)
}
}
void SettingsEnableAllI2cDrivers(void)
{
Settings.i2c_drivers[0] = 0xFFFFFFFF;
Settings.i2c_drivers[1] = 0xFFFFFFFF;
Settings.i2c_drivers[2] = 0xFFFFFFFF;
}
/********************************************************************************************/
void SettingsDelta(void)
@ -1120,6 +1128,9 @@ void SettingsDelta(void)
Settings.web_color2[0][1] = Settings.web_color[0][1];
Settings.web_color2[0][2] = Settings.web_color[0][2];
}
if (Settings.version < 0x07000003) {
SettingsEnableAllI2cDrivers();
}
Settings.version = VERSION;
SettingsSave(1);
}

View File

@ -28,7 +28,7 @@ const char kTasmotaCommands[] PROGMEM = "|" // No prefix
D_CMND_FRIENDLYNAME "|" D_CMND_SWITCHMODE "|" D_CMND_INTERLOCK "|" D_CMND_TELEPERIOD "|" D_CMND_RESET "|" D_CMND_TIME "|" D_CMND_TIMEZONE "|" D_CMND_TIMESTD "|"
D_CMND_TIMEDST "|" D_CMND_ALTITUDE "|" D_CMND_LEDPOWER "|" D_CMND_LEDSTATE "|" D_CMND_LEDMASK "|"
#ifdef USE_I2C
D_CMND_I2CSCAN "|"
D_CMND_I2CSCAN "|" D_CMND_I2CDRIVER "|"
#endif
D_CMND_SENSOR "|" D_CMND_DRIVER;
@ -43,7 +43,7 @@ void (* const TasmotaCommand[])(void) PROGMEM = {
&CmndFriendlyname, &CmndSwitchMode, &CmndInterlock, &CmndTeleperiod, &CmndReset, &CmndTime, &CmndTimezone, &CmndTimeStd,
&CmndTimeDst, &CmndAltitude, &CmndLedPower, &CmndLedState, &CmndLedMask,
#ifdef USE_I2C
&CmndI2cScan,
&CmndI2cScan, CmndI2cDriver,
#endif
&CmndSensor, &CmndDriver };
@ -1537,6 +1537,19 @@ void CmndI2cScan(void)
I2cScan(mqtt_data, sizeof(mqtt_data));
}
}
void CmndI2cDriver(void)
{
if (XdrvMailbox.index < MAX_I2C_DRIVERS) {
if (XdrvMailbox.payload >= 0) {
bitWrite(Settings.i2c_drivers[XdrvMailbox.index / 32], XdrvMailbox.index % 32, XdrvMailbox.payload &1);
}
restart_flag = 2;
}
Response_P(PSTR("{\"" D_CMND_I2CDRIVER "\":"));
XI2cDriverState();
ResponseJsonEnd();
}
#endif // USE_I2C
void CmndSensor(void)

View File

@ -20,6 +20,6 @@
#ifndef _TASMOTA_VERSION_H_
#define _TASMOTA_VERSION_H_
const uint32_t VERSION = 0x07000002;
const uint32_t VERSION = 0x07000003;
#endif // _TASMOTA_VERSION_H_

View File

@ -21,6 +21,7 @@
#ifdef USE_PCA9685
#define XDRV_15 15
#define XI2C_01 1 // See I2CDEVICES.md
#define PCA9685_REG_MODE1 0x00
#define PCA9685_REG_LED0_ON_L 0x06
@ -178,6 +179,8 @@ void PCA9685_OutputTelemetry(bool telemetry) {
bool Xdrv15(uint8_t function)
{
if (!XI2cEnabled(XI2C_01)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -26,6 +26,7 @@
\*********************************************************************************************/
#define XDRV_28 28
#define XI2C_02 2 // See I2CDEVICES.md
#define PCF8574_ADDR1 0x20 // PCF8574
#define PCF8574_ADDR2 0x38 // PCF8574A
@ -222,6 +223,8 @@ void Pcf8574SaveSettings()
bool Xdrv28(uint8_t function)
{
if (!XI2cEnabled(XI2C_02)) { return false; }
bool result = false;
if (i2c_flg && Pcf8574.type) {

View File

@ -22,6 +22,7 @@
#ifdef USE_DISPLAY_LCD
#define XDSP_01 1
#define XI2C_03 3 // See I2CDEVICES.md
#define LCD_ADDRESS1 0x27 // LCD I2C address option 1
#define LCD_ADDRESS2 0x3F // LCD I2C address option 2
@ -189,6 +190,8 @@ void LcdRefresh(void) // Every second
bool Xdsp01(uint8_t function)
{
if (!XI2cEnabled(XI2C_03)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -22,6 +22,7 @@
#ifdef USE_DISPLAY_SSD1306
#define XDSP_02 2
#define XI2C_04 4 // See I2CDEVICES.md
#define OLED_RESET 4
@ -173,6 +174,8 @@ void Ssd1306Refresh(void) // Every second
bool Xdsp02(byte function)
{
if (!XI2cEnabled(XI2C_04)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -22,6 +22,7 @@
#ifdef USE_DISPLAY_MATRIX
#define XDSP_03 3
#define XI2C_05 5 // See I2CDEVICES.md
#define MTX_MAX_SCREEN_BUFFER 80
@ -330,6 +331,8 @@ void MatrixRefresh(void) // Every second
bool Xdsp03(uint8_t function)
{
if (!XI2cEnabled(XI2C_05)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -28,6 +28,7 @@
extern uint8_t *buffer;
#define XDSP_07 7
#define XI2C_06 6 // See I2CDEVICES.md
#define OLED_ADDRESS1 0x3C // Oled 128x32 I2C address
#define OLED_ADDRESS2 0x3D // Oled 128x64 I2C address
@ -167,6 +168,8 @@ void SH1106Refresh(void) // Every second
bool Xdsp07(uint8_t function)
{
if (!XI2cEnabled(XI2C_06)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -29,6 +29,7 @@
\*********************************************************************************************/
#define XNRG_07 7
#define XI2C_07 7 // See I2CDEVICES.md
#define ADE7953_PREF 1540
#define ADE7953_UREF 26000
@ -268,6 +269,8 @@ bool Ade7953Command(void)
bool Xnrg07(uint8_t function)
{
if (!XI2cEnabled(XI2C_07)) { return false; }
bool result = false;
switch (function) {

View File

@ -29,6 +29,7 @@
\*********************************************************************************************/
#define XSNS_07 7
#define XI2C_08 8 // See I2CDEVICES.md
enum {
SHT1X_CMD_MEASURE_TEMP = B00000011,
@ -220,6 +221,8 @@ void ShtShow(bool json)
bool Xsns07(uint8_t function)
{
if (!XI2cEnabled(XI2C_08)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -28,6 +28,7 @@
\*********************************************************************************************/
#define XSNS_08 8
#define XI2C_09 9 // See I2CDEVICES.md
#define HTU21_ADDR 0x40
@ -280,6 +281,8 @@ void HtuShow(bool json)
bool Xsns08(uint8_t function)
{
if (!XI2cEnabled(XI2C_09)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -28,6 +28,7 @@
\*********************************************************************************************/
#define XSNS_09 9
#define XI2C_10 10 // See I2CDEVICES.md
#define BMP_ADDR1 0x76
#define BMP_ADDR2 0x77
@ -623,6 +624,8 @@ void BmpShow(bool json)
bool Xsns09(uint8_t function)
{
if (!XI2cEnabled(XI2C_10)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -26,6 +26,7 @@
\*********************************************************************************************/
#define XSNS_10 10
#define XI2C_11 11 // See I2CDEVICES.md
#define BH1750_ADDR1 0x23
#define BH1750_ADDR2 0x5C
@ -112,6 +113,8 @@ void Bh1750Show(bool json)
bool Xsns10(uint8_t function)
{
if (!XI2cEnabled(XI2C_11)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -95,6 +95,7 @@
\*********************************************************************************************/
#define XSNS_11 11
#define XI2C_12 12 // See I2CDEVICES.md
#define VEML6070_ADDR_H 0x39 // on some PCB boards the address can be changed by a solder point,
#define VEML6070_ADDR_L 0x38 // to have no address conflicts with other I2C sensors and/or hardware
@ -304,6 +305,8 @@ void Veml6070Show(bool json)
bool Xsns11(uint8_t function)
{
if (!XI2cEnabled(XI2C_12)) { return false; }
bool result = false;
if (i2c_flg && !(pin[GPIO_ADE7953_IRQ] < 99)) { // The ADE7953 uses I2C address 0x38 too but needs priority

View File

@ -41,6 +41,7 @@
\*********************************************************************************************/
#define XSNS_12 12
#define XI2C_13 13 // See I2CDEVICES.md
#define ADS1115_ADDRESS_ADDR_GND 0x48 // address pin low (GND)
#define ADS1115_ADDRESS_ADDR_VDD 0x49 // address pin high (VCC)
@ -241,6 +242,8 @@ void Ads1115Show(bool json)
bool Xsns12(uint8_t function)
{
if (!XI2cEnabled(XI2C_13)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -41,6 +41,7 @@
\*********************************************************************************************/
#define XSNS_12 12
#define XI2C_13 13 // See I2CDEVICES.md
#include <ADS1115.h>
@ -130,6 +131,8 @@ void Ads1115Show(bool json)
bool Xsns12(uint8_t function)
{
if (!XI2cEnabled(XI2C_13)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -28,6 +28,7 @@
\*********************************************************************************************/
#define XSNS_13 13
#define XI2C_14 14 // See I2CDEVICES.md
#define INA219_ADDRESS1 (0x40) // 1000000 (A0+A1=GND)
#define INA219_ADDRESS2 (0x41) // 1000000 (A0=Vcc, A1=GND)
@ -275,6 +276,8 @@ void Ina219Show(bool json)
bool Xsns13(uint8_t function)
{
if (!XI2cEnabled(XI2C_14)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -26,6 +26,7 @@
\*********************************************************************************************/
#define XSNS_14 14
#define XI2C_15 15 // See I2CDEVICES.md
#define SHT3X_ADDR_GND 0x44 // address pin low (GND)
#define SHT3X_ADDR_VDD 0x45 // address pin high (VDD)
@ -138,6 +139,8 @@ void Sht3xShow(bool json)
bool Xsns14(uint8_t function)
{
if (!XI2cEnabled(XI2C_15)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -28,6 +28,7 @@
\*********************************************************************************************/
#define XSNS_16 16
#define XI2C_16 16 // See I2CDEVICES.md
#include <Tsl2561Util.h>
@ -121,6 +122,8 @@ void Tsl2561Show(bool json)
bool Xsns16(uint8_t function)
{
if (!XI2cEnabled(XI2C_16)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -27,6 +27,7 @@
\*********************************************************************************************/
#define XSNS_19 19
#define XI2C_17 17 // See I2CDEVICES.md
#ifndef MGS_SENSOR_ADDR
#define MGS_SENSOR_ADDR 0x04 // Default Mutichannel Gas sensor i2c address
@ -92,6 +93,8 @@ void MGSShow(bool json)
bool Xsns19(uint8_t function)
{
if (!XI2cEnabled(XI2C_17)) { return false; }
bool result = false;
static int detected = false;

View File

@ -28,6 +28,7 @@
\*********************************************************************************************/
#define XSNS_21 21
#define XI2C_18 18 // See I2CDEVICES.md
#include "Adafruit_SGP30.h"
Adafruit_SGP30 sgp;
@ -153,6 +154,8 @@ void Sgp30Show(bool json)
bool Xsns21(uint8_t function)
{
if (!XI2cEnabled(XI2C_18)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -28,6 +28,7 @@
\*********************************************************************************************/
#define XSNS_24 24
#define XI2C_19 19 // See I2CDEVICES.md
#define SI114X_ADDR 0X60
//
@ -350,6 +351,8 @@ void Si1145Show(bool json)
bool Xsns24(uint8_t function)
{
if (!XI2cEnabled(XI2C_19)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -29,6 +29,7 @@
\*********************************************************************************************/
#define XSNS_26 26
#define XI2C_20 20 // See I2CDEVICES.md
#define LM75AD_ADDRESS1 0x48
#define LM75AD_ADDRESS2 0x49
@ -103,6 +104,8 @@ void LM75ADShow(bool json)
bool Xsns26(uint8_t function)
{
if (!XI2cEnabled(XI2C_20)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -37,6 +37,7 @@
\*********************************************************************************************/
#define XSNS_27 27
#define XI2C_21 21 // See I2CDEVICES.md
#if defined(USE_SHT) || defined(USE_VEML6070) || defined(USE_TSL2561)
#warning **** Turned off conflicting drivers SHT and VEML6070 ****
@ -2026,6 +2027,8 @@ bool APDS9960CommandSensor(void)
bool Xsns27(uint8_t function)
{
if (!XI2cEnabled(XI2C_21)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -29,6 +29,7 @@
\*********************************************************************************************/
#define XSNS_29 29
#define XI2C_22 22 // See I2CDEVICES.md
/*
Default register locations for MCP23008 - They change for MCP23017 in default bank mode
@ -776,6 +777,8 @@ void MCP230xx_Interrupt_Retain_Report(void) {
bool Xsns29(uint8_t function)
{
if (!XI2cEnabled(XI2C_22)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -48,6 +48,7 @@
* Assign Tasmota sensor model ID
*/
#define XSNS_30 30
#define XI2C_23 23 // See I2CDEVICES.md
/** @defgroup group1 MPR121
* MPR121 preprocessor directives
@ -399,6 +400,8 @@ void Mpr121Show(struct mpr121 *pS, uint8_t function)
*/
bool Xsns30(uint8_t function)
{
if (!XI2cEnabled(XI2C_23)) { return false; }
// ???
bool result = false;

View File

@ -28,6 +28,7 @@
\*********************************************************************************************/
#define XSNS_31 31
#define XI2C_24 24 // See I2CDEVICES.md
#include "Adafruit_CCS811.h"
@ -103,6 +104,8 @@ void CCS811Show(bool json)
bool Xsns31(uint8_t function)
{
if (!XI2cEnabled(XI2C_24)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -28,6 +28,7 @@
\*********************************************************************************************/
#define XSNS_32 32
#define XI2C_25 25 // See I2CDEVICES.md
#define D_SENSOR_MPU6050 "MPU6050"
@ -225,6 +226,8 @@ void MPU_6050Show(bool json)
bool Xsns32(uint8_t function)
{
if (!XI2cEnabled(XI2C_25)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -33,6 +33,7 @@
\*********************************************************************************************/
#define XSNS_33 33
#define XI2C_26 26 // See I2CDEVICES.md
//DS3232 I2C Address
#ifndef USE_RTC_ADDR
@ -133,6 +134,8 @@ void SetDS3231Time (uint32_t epoch_time) {
bool Xsns33(uint8_t function)
{
if (!XI2cEnabled(XI2C_26)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -33,6 +33,7 @@
\*********************************************************************************************/
#define XSNS_36 36
#define XI2C_27 27 // See I2CDEVICES.md
#warning **** MGC3130: It is recommended to disable all unneeded I2C-drivers ****
@ -602,6 +603,8 @@ bool MGC3130CommandSensor()
bool Xsns36(uint8_t function)
{
if (!XI2cEnabled(XI2C_27)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -26,6 +26,7 @@
\*********************************************************************************************/
#define XSNS_41 41
#define XI2C_28 28 // See I2CDEVICES.md
#define MAX44009_ADDR1 0x4A
#define MAX44009_ADDR2 0x4B
@ -149,6 +150,8 @@ void Max4409Show(bool json)
bool Xsns41(uint8_t function)
{
if (!XI2cEnabled(XI2C_28)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -21,6 +21,7 @@
#ifdef USE_SCD30
#define XSNS_42 42
#define XI2C_29 29 // See I2CDEVICES.md
#define SCD30_MAX_MISSED_READS 3
#define SCD30_STATE_NO_ERROR 0
@ -472,6 +473,8 @@ void Scd30Show(bool json)
bool Xsns42(byte function)
{
if (!XI2cEnabled(XI2C_29)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -21,6 +21,7 @@
#ifdef USE_SPS30
#define XSNS_44 44
#define XI2C_30 30 // See I2CDEVICES.md
#define SPS30_ADDR 0x69
@ -283,6 +284,8 @@ bool SPS30_cmd(void) {
bool Xsns44(byte function)
{
if (!XI2cEnabled(XI2C_30)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -20,6 +20,9 @@
#ifdef USE_I2C
#ifdef USE_VL53L0X
#define XSNS_45 45
#define XI2C_31 31 // See I2CDEVICES.md
#include <Wire.h>
#include "VL53L0X.h"
VL53L0X sensor;
@ -131,10 +134,10 @@ void Vl53l0Show(boolean json)
* Interface
\*********************************************************************************************/
#define XSNS_45 45
bool Xsns45(byte function)
{
if (!XI2cEnabled(XI2C_31)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -20,7 +20,8 @@
#ifdef USE_I2C
#ifdef USE_MLX90614
#define XSNS_46 46
#define XSNS_46 46
#define XI2C_32 32 // See I2CDEVICES.md
#define I2_ADR_IRT 0x5a
@ -116,6 +117,8 @@ void MLX90614_Show(uint8_t json) {
bool Xsns46(byte function)
{
if (!XI2cEnabled(XI2C_32)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -43,6 +43,8 @@
\*********************************************************************************************/
#define XSNS_48 48
#define XI2C_33 33 // See I2CDEVICES.md
#define CHIRP_MAX_SENSOR_COUNT 3 // 127 is expectectd to be the max number
#define CHIRP_ADDR_STANDARD 0x20 // standard address
@ -521,6 +523,8 @@ bool ChirpCmd(void) {
bool Xsns48(uint8_t function)
{
if (!XI2cEnabled(XI2C_33)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -38,6 +38,7 @@
\*********************************************************************************************/
#define XSNS_50 50
#define XI2C_34 34 // See I2CDEVICES.md
#define PAJ7620_ADDR 0x73 // standard address
@ -536,6 +537,8 @@ bool PAJ7620Cmd(void) {
bool Xsns50(uint8_t function)
{
if (!XI2cEnabled(XI2C_34)) { return false; }
bool result = false;
if (i2c_flg) {

View File

@ -67,6 +67,7 @@
// Define driver ID
#define XSNS_54 54
#define XI2C_35 35 // See I2CDEVICES.md
#define INA226_MAX_ADDRESSES 4
#define INA226_ADDRESS1 (0x40) // 1000000 (A0+A1=GND)
@ -529,7 +530,9 @@ void Ina226Show(bool json)
* @post None.
*
*/
bool Xsns54(byte callback_id) {
bool Xsns54(byte callback_id)
{
if (!XI2cEnabled(XI2C_35)) { return false; }
// Set return value to `false`
bool result = false;

View File

@ -30,6 +30,7 @@
\*********************************************************************************************/
#define XSNS_55 55
#define XI2C_36 36 // See I2CDEVICES.md
#define HIH6_ADDR 0x27
@ -134,6 +135,8 @@ void Hih6Show(bool json)
bool Xsns55(uint8_t function)
{
if (!XI2cEnabled(XI2C_36)) { return false; }
bool result = false;
if (i2c_flg) {

449
tasmota/xx2c_interface.ino Normal file
View File

@ -0,0 +1,449 @@
/*
xx2c_interface.ino - I2c interface support for Tasmota
Copyright (C) 2019 Theo Arends
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef USE_I2C
#ifdef XFUNC_PTR_IN_ROM
const uint8_t kI2cList[] PROGMEM = {
#else
const uint8_t kI2cList[] = {
#endif
#ifdef XI2C_01
XI2C_01,
#endif
#ifdef XI2C_02
XI2C_02,
#endif
#ifdef XI2C_03
XI2C_03,
#endif
#ifdef XI2C_04
XI2C_04,
#endif
#ifdef XI2C_05
XI2C_05,
#endif
#ifdef XI2C_06
XI2C_06,
#endif
#ifdef XI2C_07
XI2C_07,
#endif
#ifdef XI2C_08
XI2C_08,
#endif
#ifdef XI2C_09
XI2C_09,
#endif
#ifdef XI2C_10
XI2C_10,
#endif
#ifdef XI2C_11
XI2C_11,
#endif
#ifdef XI2C_12
XI2C_12,
#endif
#ifdef XI2C_13
XI2C_13,
#endif
#ifdef XI2C_14
XI2C_14,
#endif
#ifdef XI2C_15
XI2C_15,
#endif
#ifdef XI2C_16
XI2C_16,
#endif
#ifdef XI2C_17
XI2C_17,
#endif
#ifdef XI2C_18
XI2C_18,
#endif
#ifdef XI2C_19
XI2C_19,
#endif
#ifdef XI2C_20
XI2C_20,
#endif
#ifdef XI2C_21
XI2C_21,
#endif
#ifdef XI2C_22
XI2C_22,
#endif
#ifdef XI2C_23
XI2C_23,
#endif
#ifdef XI2C_24
XI2C_24,
#endif
#ifdef XI2C_25
XI2C_25,
#endif
#ifdef XI2C_26
XI2C_26,
#endif
#ifdef XI2C_27
XI2C_27,
#endif
#ifdef XI2C_28
XI2C_28,
#endif
#ifdef XI2C_29
XI2C_29,
#endif
#ifdef XI2C_30
XI2C_30,
#endif
#ifdef XI2C_31
XI2C_31,
#endif
#ifdef XI2C_32
XI2C_32,
#endif
#ifdef XI2C_33
XI2C_33,
#endif
#ifdef XI2C_34
XI2C_34,
#endif
#ifdef XI2C_35
XI2C_35,
#endif
#ifdef XI2C_36
XI2C_36,
#endif
#ifdef XI2C_37
XI2C_37,
#endif
#ifdef XI2C_38
XI2C_38,
#endif
#ifdef XI2C_39
XI2C_39,
#endif
#ifdef XI2C_40
XI2C_40,
#endif
#ifdef XI2C_41
XI2C_41,
#endif
#ifdef XI2C_42
XI2C_42,
#endif
#ifdef XI2C_43
XI2C_43,
#endif
#ifdef XI2C_44
XI2C_44,
#endif
#ifdef XI2C_45
XI2C_45,
#endif
#ifdef XI2C_46
XI2C_46,
#endif
#ifdef XI2C_47
XI2C_47,
#endif
#ifdef XI2C_48
XI2C_48,
#endif
#ifdef XI2C_49
XI2C_49,
#endif
#ifdef XI2C_50
XI2C_50,
#endif
#ifdef XI2C_51
XI2C_51,
#endif
#ifdef XI2C_52
XI2C_52,
#endif
#ifdef XI2C_53
XI2C_53,
#endif
#ifdef XI2C_54
XI2C_54,
#endif
#ifdef XI2C_55
XI2C_55,
#endif
#ifdef XI2C_56
XI2C_56,
#endif
#ifdef XI2C_57
XI2C_57,
#endif
#ifdef XI2C_58
XI2C_58,
#endif
#ifdef XI2C_59
XI2C_59,
#endif
#ifdef XI2C_60
XI2C_60,
#endif
#ifdef XI2C_61
XI2C_61,
#endif
#ifdef XI2C_62
XI2C_62,
#endif
#ifdef XI2C_63
XI2C_63,
#endif
#ifdef XI2C_64
XI2C_64,
#endif
#ifdef XI2C_65
XI2C_65,
#endif
#ifdef XI2C_66
XI2C_66,
#endif
#ifdef XI2C_67
XI2C_67,
#endif
#ifdef XI2C_68
XI2C_68,
#endif
#ifdef XI2C_69
XI2C_69,
#endif
#ifdef XI2C_70
XI2C_70,
#endif
#ifdef XI2C_71
XI2C_71,
#endif
#ifdef XI2C_72
XI2C_72,
#endif
#ifdef XI2C_73
XI2C_73,
#endif
#ifdef XI2C_74
XI2C_74,
#endif
#ifdef XI2C_75
XI2C_75,
#endif
#ifdef XI2C_76
XI2C_76,
#endif
#ifdef XI2C_77
XI2C_77,
#endif
#ifdef XI2C_78
XI2C_78,
#endif
#ifdef XI2C_79
XI2C_79,
#endif
#ifdef XI2C_80
XI2C_80,
#endif
#ifdef XI2C_81
XI2C_81,
#endif
#ifdef XI2C_82
XI2C_82,
#endif
#ifdef XI2C_83
XI2C_83,
#endif
#ifdef XI2C_84
XI2C_84,
#endif
#ifdef XI2C_85
XI2C_85,
#endif
#ifdef XI2C_86
XI2C_86,
#endif
#ifdef XI2C_87
XI2C_87,
#endif
#ifdef XI2C_88
XI2C_88,
#endif
#ifdef XI2C_89
XI2C_89,
#endif
#ifdef XI2C_90
XI2C_90,
#endif
#ifdef XI2C_91
XI2C_91,
#endif
#ifdef XI2C_92
XI2C_92,
#endif
#ifdef XI2C_93
XI2C_93,
#endif
#ifdef XI2C_94
XI2C_94,
#endif
#ifdef XI2C_95
XI2C_95,
#endif
#ifdef XI2C_96
XI2C_96
#endif
};
/*********************************************************************************************/
bool XI2cEnabled(uint32_t i2c_index)
{
/*
if (i2c_index < sizeof(kI2cList)) {
#ifdef XFUNC_PTR_IN_ROM
uint32_t index = pgm_read_byte(kI2cList + i2c_index);
#else
uint32_t index = kI2cList[i2c_index];
#endif
return bitRead(Settings.i2c_drivers[index / 32], index % 32);
}
return true;
*/
return bitRead(Settings.i2c_drivers[i2c_index / 32], i2c_index % 32);
}
void XI2cDriverState(void)
{
ResponseAppend_P(PSTR("\"")); // Use string for enable/disable signal
for (uint32_t i = 0; i < sizeof(kI2cList); i++) {
#ifdef XFUNC_PTR_IN_ROM
uint32_t i2c_driver_id = pgm_read_byte(kI2cList + i);
#else
uint32_t i2c_driver_id = kI2cList[i];
#endif
bool disabled = false;
if (i2c_driver_id < MAX_I2C_DRIVERS) {
disabled = !bitRead(Settings.i2c_drivers[i2c_driver_id / 32], i2c_driver_id % 32);
}
ResponseAppend_P(PSTR("%s%s%d"), (i) ? "," : "", (disabled) ? "!" : "", i2c_driver_id);
}
ResponseAppend_P(PSTR("\""));
}
#endif // USE_I2C