mirror of https://github.com/arendst/Tasmota.git
Merge branch 'development' of github.com:arendst/Tasmota into pr_tm1638
This commit is contained in:
commit
fb70d80923
|
@ -104,26 +104,6 @@ jobs:
|
||||||
name: firmware
|
name: firmware
|
||||||
path: ./build_output
|
path: ./build_output
|
||||||
|
|
||||||
tasmota32-lite:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v1
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v1
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install -U platformio
|
|
||||||
platformio upgrade --dev
|
|
||||||
platformio update
|
|
||||||
- name: Run PlatformIO
|
|
||||||
run: |
|
|
||||||
platformio run -e tasmota32-lite
|
|
||||||
- uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: firmware
|
|
||||||
path: ./build_output
|
|
||||||
|
|
||||||
tasmota32-knx:
|
tasmota32-knx:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
|
@ -724,26 +724,6 @@ jobs:
|
||||||
path: ./build_output
|
path: ./build_output
|
||||||
|
|
||||||
|
|
||||||
tasmota32-lite:
|
|
||||||
needs: tasmota_pull
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
continue-on-error: true
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v1
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v1
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
pip install -U platformio
|
|
||||||
- name: Run PlatformIO
|
|
||||||
run: |
|
|
||||||
platformio run -e tasmota32-lite
|
|
||||||
- uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: firmware
|
|
||||||
path: ./build_output
|
|
||||||
|
|
||||||
|
|
||||||
tasmota32-webcam:
|
tasmota32-webcam:
|
||||||
needs: tasmota_pull
|
needs: tasmota_pull
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -1455,7 +1435,6 @@ jobs:
|
||||||
[ ! -f ./mv_firmware/firmware/tasmota-zbbridge.* ] || mv ./mv_firmware/firmware/tasmota-zbbridge.* ./firmware/tasmota/
|
[ ! -f ./mv_firmware/firmware/tasmota-zbbridge.* ] || mv ./mv_firmware/firmware/tasmota-zbbridge.* ./firmware/tasmota/
|
||||||
[ ! -f ./mv_firmware/firmware/tasmota32.* ] || mv ./mv_firmware/firmware/tasmota32.* ./firmware/tasmota32/
|
[ ! -f ./mv_firmware/firmware/tasmota32.* ] || mv ./mv_firmware/firmware/tasmota32.* ./firmware/tasmota32/
|
||||||
[ ! -f ./mv_firmware/firmware/tasmota32-sensors.* ] || mv ./mv_firmware/firmware/tasmota32-sensors.* ./firmware/tasmota32/
|
[ ! -f ./mv_firmware/firmware/tasmota32-sensors.* ] || mv ./mv_firmware/firmware/tasmota32-sensors.* ./firmware/tasmota32/
|
||||||
[ ! -f ./mv_firmware/firmware/tasmota32-lite.* ] || mv ./mv_firmware/firmware/tasmota32-lite.* ./firmware/tasmota32/
|
|
||||||
[ ! -f ./mv_firmware/firmware/tasmota32-ir*.* ] || mv ./mv_firmware/firmware/tasmota32-ir*.* ./firmware/tasmota32/
|
[ ! -f ./mv_firmware/firmware/tasmota32-ir*.* ] || mv ./mv_firmware/firmware/tasmota32-ir*.* ./firmware/tasmota32/
|
||||||
[ ! -f ./mv_firmware/firmware/tasmota32-display.* ] || mv ./mv_firmware/firmware/tasmota32-display.* ./firmware/tasmota32/
|
[ ! -f ./mv_firmware/firmware/tasmota32-display.* ] || mv ./mv_firmware/firmware/tasmota32-display.* ./firmware/tasmota32/
|
||||||
[ ! -f ./mv_firmware/firmware/tasmota32-web*.* ] || mv ./mv_firmware/firmware/tasmota32-web*.* ./firmware/tasmota32/
|
[ ! -f ./mv_firmware/firmware/tasmota32-web*.* ] || mv ./mv_firmware/firmware/tasmota32-web*.* ./firmware/tasmota32/
|
||||||
|
|
|
@ -724,26 +724,6 @@ jobs:
|
||||||
path: ./build_output
|
path: ./build_output
|
||||||
|
|
||||||
|
|
||||||
tasmota32-lite:
|
|
||||||
needs: tasmota_pull
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
continue-on-error: true
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v1
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v1
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
pip install -U platformio
|
|
||||||
- name: Run PlatformIO
|
|
||||||
run: |
|
|
||||||
platformio run -e tasmota32-lite
|
|
||||||
- uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: firmware
|
|
||||||
path: ./build_output
|
|
||||||
|
|
||||||
|
|
||||||
tasmota32-webcam:
|
tasmota32-webcam:
|
||||||
needs: tasmota_pull
|
needs: tasmota_pull
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -1455,7 +1435,6 @@ jobs:
|
||||||
[ ! -f ./mv_firmware/firmware/tasmota-zbbridge.* ] || mv ./mv_firmware/firmware/tasmota-zbbridge.* ./firmware/tasmota/
|
[ ! -f ./mv_firmware/firmware/tasmota-zbbridge.* ] || mv ./mv_firmware/firmware/tasmota-zbbridge.* ./firmware/tasmota/
|
||||||
[ ! -f ./mv_firmware/firmware/tasmota32.* ] || mv ./mv_firmware/firmware/tasmota32.* ./firmware/tasmota32/
|
[ ! -f ./mv_firmware/firmware/tasmota32.* ] || mv ./mv_firmware/firmware/tasmota32.* ./firmware/tasmota32/
|
||||||
[ ! -f ./mv_firmware/firmware/tasmota32-sensors.* ] || mv ./mv_firmware/firmware/tasmota32-sensors.* ./firmware/tasmota32/
|
[ ! -f ./mv_firmware/firmware/tasmota32-sensors.* ] || mv ./mv_firmware/firmware/tasmota32-sensors.* ./firmware/tasmota32/
|
||||||
[ ! -f ./mv_firmware/firmware/tasmota32-lite.* ] || mv ./mv_firmware/firmware/tasmota32-lite.* ./firmware/tasmota32/
|
|
||||||
[ ! -f ./mv_firmware/firmware/tasmota32-ir*.* ] || mv ./mv_firmware/firmware/tasmota32-ir*.* ./firmware/tasmota32/
|
[ ! -f ./mv_firmware/firmware/tasmota32-ir*.* ] || mv ./mv_firmware/firmware/tasmota32-ir*.* ./firmware/tasmota32/
|
||||||
[ ! -f ./mv_firmware/firmware/tasmota32-display.* ] || mv ./mv_firmware/firmware/tasmota32-display.* ./firmware/tasmota32/
|
[ ! -f ./mv_firmware/firmware/tasmota32-display.* ] || mv ./mv_firmware/firmware/tasmota32-display.* ./firmware/tasmota32/
|
||||||
[ ! -f ./mv_firmware/firmware/tasmota32-web*.* ] || mv ./mv_firmware/firmware/tasmota32-web*.* ./firmware/tasmota32/
|
[ ! -f ./mv_firmware/firmware/tasmota32-web*.* ] || mv ./mv_firmware/firmware/tasmota32-web*.* ./firmware/tasmota32/
|
||||||
|
|
|
@ -29,7 +29,6 @@ default_envs =
|
||||||
; tasmota32
|
; tasmota32
|
||||||
; tasmota32-bluetooth
|
; tasmota32-bluetooth
|
||||||
; tasmota32-webcam
|
; tasmota32-webcam
|
||||||
; tasmota32-lite
|
|
||||||
; tasmota32-knx
|
; tasmota32-knx
|
||||||
; tasmota32-sensors
|
; tasmota32-sensors
|
||||||
; tasmota32-display
|
; tasmota32-display
|
||||||
|
|
|
@ -11,7 +11,6 @@ default_envs = ${build_envs.default_envs}
|
||||||
; tasmota32-webcam
|
; tasmota32-webcam
|
||||||
; tasmota32-odroidgo
|
; tasmota32-odroidgo
|
||||||
; tasmota32-core2
|
; tasmota32-core2
|
||||||
; tasmota32-lite
|
|
||||||
; tasmota32-knx
|
; tasmota32-knx
|
||||||
; tasmota32-sensors
|
; tasmota32-sensors
|
||||||
; tasmota32-display
|
; tasmota32-display
|
||||||
|
|
|
@ -66,11 +66,6 @@ extends = env:tasmota32
|
||||||
build_flags = ${common32.build_flags} -DFIRMWARE_BLUETOOTH
|
build_flags = ${common32.build_flags} -DFIRMWARE_BLUETOOTH
|
||||||
lib_extra_dirs = lib/libesp32, lib/libesp32_div, lib/lib_basic, lib/lib_i2c, lib/lib_ssl
|
lib_extra_dirs = lib/libesp32, lib/libesp32_div, lib/lib_basic, lib/lib_i2c, lib/lib_ssl
|
||||||
|
|
||||||
[env:tasmota32-lite]
|
|
||||||
extends = env:tasmota32
|
|
||||||
build_flags = ${common32.build_flags} -DFIRMWARE_LITE
|
|
||||||
lib_extra_dirs = lib/libesp32
|
|
||||||
|
|
||||||
[env:tasmota32-knx]
|
[env:tasmota32-knx]
|
||||||
extends = env:tasmota32
|
extends = env:tasmota32
|
||||||
build_flags = ${common32.build_flags} -DFIRMWARE_KNX_NO_EMULATION
|
build_flags = ${common32.build_flags} -DFIRMWARE_KNX_NO_EMULATION
|
||||||
|
|
|
@ -575,11 +575,14 @@
|
||||||
// #define USE_CHIRP // [I2cDriver33] Enable CHIRP soil moisture sensor (variable I2C address, default 0x20)
|
// #define USE_CHIRP // [I2cDriver33] Enable CHIRP soil moisture sensor (variable I2C address, default 0x20)
|
||||||
// #define USE_PAJ7620 // [I2cDriver34] Enable PAJ7620 gesture sensor (I2C address 0x73) (+2.5k code)
|
// #define USE_PAJ7620 // [I2cDriver34] Enable PAJ7620 gesture sensor (I2C address 0x73) (+2.5k code)
|
||||||
// #define USE_PCF8574 // [I2cDriver2] Enable PCF8574 I/O Expander (I2C addresses 0x20 - 0x26 and 0x39 - 0x3F) (+1k9 code)
|
// #define USE_PCF8574 // [I2cDriver2] Enable PCF8574 I/O Expander (I2C addresses 0x20 - 0x26 and 0x39 - 0x3F) (+1k9 code)
|
||||||
|
// #define USE_PCF8574_SENSOR // enable PCF8574 inputs and outputs in SENSOR message
|
||||||
|
// #define USE_PCF8574_DISPLAYINPUT // enable PCF8574 inputs display in Web page
|
||||||
|
// #define USE_PCF8574_MQTTINPUT // enable MQTT message & rule process on input change detection : stat/%topic%/PCF8574_INP = {"Time":"2021-03-07T16:19:23+01:00","PCF8574-1_INP":{"D1":1}}
|
||||||
// #define USE_HIH6 // [I2cDriver36] Enable Honeywell HIH Humidity and Temperature sensor (I2C address 0x27) (+0k6)
|
// #define USE_HIH6 // [I2cDriver36] Enable Honeywell HIH Humidity and Temperature sensor (I2C address 0x27) (+0k6)
|
||||||
// #define USE_DHT12 // [I2cDriver41] Enable DHT12 humidity and temperature sensor (I2C address 0x5C) (+0k7 code)
|
// #define USE_DHT12 // [I2cDriver41] Enable DHT12 humidity and temperature sensor (I2C address 0x5C) (+0k7 code)
|
||||||
// #define USE_DS1624 // [I2cDriver42] Enable DS1624, DS1621 temperature sensor (I2C addresses 0x48 - 0x4F) (+1k2 code)
|
// #define USE_DS1624 // [I2cDriver42] Enable DS1624, DS1621 temperature sensor (I2C addresses 0x48 - 0x4F) (+1k2 code)
|
||||||
// #define USE_AHT1x // [I2cDriver43] Enable AHT10/15 humidity and temperature sensor (I2C address 0x38, 0x39) (+0k8 code)
|
// #define USE_AHT1x // [I2cDriver43] Enable AHT10/15 humidity and temperature sensor (I2C address 0x38, 0x39) (+0k8 code)
|
||||||
// #define USE_AHT2x // [I2cDriver43] Enable AHT20 instead of AHT1x humidity and temperature sensor (I2C address 0x38) (+0k8 code)
|
// #define USE_AHT2x // [I2cDriver43] Enable AHT20 instead of AHT1x humidity and temperature sensor (I2C address 0x38) (+0k8 code)
|
||||||
// #define USE_WEMOS_MOTOR_V1 // [I2cDriver44] Enable Wemos motor driver V1 (I2C addresses 0x2D - 0x30) (+0k7 code)
|
// #define USE_WEMOS_MOTOR_V1 // [I2cDriver44] Enable Wemos motor driver V1 (I2C addresses 0x2D - 0x30) (+0k7 code)
|
||||||
// #define WEMOS_MOTOR_V1_ADDR 0x30 // Default I2C address 0x30
|
// #define WEMOS_MOTOR_V1_ADDR 0x30 // Default I2C address 0x30
|
||||||
// #define WEMOS_MOTOR_V1_FREQ 1000 // Default frequency
|
// #define WEMOS_MOTOR_V1_FREQ 1000 // Default frequency
|
||||||
|
|
|
@ -183,7 +183,11 @@ void MqttInit(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Mqtt.mqtt_tls) {
|
if (Mqtt.mqtt_tls) {
|
||||||
|
#ifdef ESP32
|
||||||
|
tlsClient = new BearSSL::WiFiClientSecure_light(2048,2048);
|
||||||
|
#else // ESP32 - ESP8266
|
||||||
tlsClient = new BearSSL::WiFiClientSecure_light(1024,1024);
|
tlsClient = new BearSSL::WiFiClientSecure_light(1024,1024);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_MQTT_AWS_IOT
|
#ifdef USE_MQTT_AWS_IOT
|
||||||
loadTlsDir(); // load key and certificate data from Flash
|
loadTlsDir(); // load key and certificate data from Flash
|
||||||
|
|
|
@ -37,37 +37,45 @@ struct PCF8574 {
|
||||||
uint8_t pin[64];
|
uint8_t pin[64];
|
||||||
uint8_t address[MAX_PCF8574];
|
uint8_t address[MAX_PCF8574];
|
||||||
uint8_t pin_mask[MAX_PCF8574] = { 0 };
|
uint8_t pin_mask[MAX_PCF8574] = { 0 };
|
||||||
|
#ifdef USE_PCF8574_MQTTINPUT
|
||||||
|
uint8_t last_input[MAX_PCF8574] = { 0 };
|
||||||
|
#endif
|
||||||
uint8_t max_connected_ports = 0; // Max numbers of devices comming from PCF8574 modules
|
uint8_t max_connected_ports = 0; // Max numbers of devices comming from PCF8574 modules
|
||||||
uint8_t max_devices = 0; // Max numbers of PCF8574 modules
|
uint8_t max_devices = 0; // Max numbers of PCF8574 modules
|
||||||
char stype[9];
|
char stype[9];
|
||||||
bool type = false;
|
bool type = false;
|
||||||
} Pcf8574;
|
} Pcf8574;
|
||||||
|
|
||||||
|
uint8_t Pcf8574Read(uint8_t idx)
|
||||||
|
{
|
||||||
|
Wire.requestFrom(Pcf8574.address[idx],(uint8_t)1);
|
||||||
|
return Wire.read();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t Pcf8574Write(uint8_t idx)
|
||||||
|
{
|
||||||
|
Wire.beginTransmission(Pcf8574.address[idx]);
|
||||||
|
Wire.write(Pcf8574.pin_mask[idx]);
|
||||||
|
return Wire.endTransmission();
|
||||||
|
}
|
||||||
|
|
||||||
void Pcf8574SwitchRelay(void)
|
void Pcf8574SwitchRelay(void)
|
||||||
{
|
{
|
||||||
for (uint32_t i = 0; i < TasmotaGlobal.devices_present; i++) {
|
for (uint32_t i = 0; i < TasmotaGlobal.devices_present; i++) {
|
||||||
uint8_t relay_state = bitRead(XdrvMailbox.index, i);
|
uint8_t relay_state = bitRead(XdrvMailbox.index, i);
|
||||||
|
|
||||||
//AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: Pcf8574.max_devices %d requested pin %d"), Pcf8574.max_devices,Pcf8574.pin[i]);
|
|
||||||
|
|
||||||
if (Pcf8574.max_devices > 0 && Pcf8574.pin[i] < 99) {
|
if (Pcf8574.max_devices > 0 && Pcf8574.pin[i] < 99) {
|
||||||
uint8_t board = Pcf8574.pin[i]>>3;
|
uint8_t board = Pcf8574.pin[i]>>3;
|
||||||
|
uint8_t pin = Pcf8574.pin[i]&0x7;
|
||||||
uint8_t oldpinmask = Pcf8574.pin_mask[board];
|
uint8_t oldpinmask = Pcf8574.pin_mask[board];
|
||||||
uint8_t _val = bitRead(TasmotaGlobal.rel_inverted, i) ? !relay_state : relay_state;
|
uint8_t _val = bitRead(TasmotaGlobal.rel_inverted, i) ? !relay_state : relay_state;
|
||||||
|
|
||||||
//AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: Pcf8574SwitchRelay %d on pin %d"), i,state);
|
//AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: SwitchRelay %d=%d => PCF-%d.D%d=%d"), i, relay_state, board +1, pin, _val);
|
||||||
|
bitWrite(Pcf8574.pin_mask[board], pin, _val);
|
||||||
if (_val) {
|
|
||||||
Pcf8574.pin_mask[board] |= _val << (Pcf8574.pin[i]&0x7);
|
|
||||||
} else {
|
|
||||||
Pcf8574.pin_mask[board] &= ~(1 << (Pcf8574.pin[i]&0x7));
|
|
||||||
}
|
|
||||||
if (oldpinmask != Pcf8574.pin_mask[board]) {
|
if (oldpinmask != Pcf8574.pin_mask[board]) {
|
||||||
Wire.beginTransmission(Pcf8574.address[board]);
|
Pcf8574.error = Pcf8574Write(board);
|
||||||
Wire.write(Pcf8574.pin_mask[board]);
|
|
||||||
Pcf8574.error = Wire.endTransmission();
|
|
||||||
}
|
}
|
||||||
//pcf8574.write(Pcf8574.pin[i]&0x7, TasmotaGlobal.rel_inverted[i] ? !state : state);
|
//else AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: SwitchRelay skipped"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,20 +122,32 @@ void Pcf8574Init(void)
|
||||||
TasmotaGlobal.devices_present = TasmotaGlobal.devices_present - Pcf8574.max_connected_ports; // reset no of devices to avoid duplicate ports on duplicate init.
|
TasmotaGlobal.devices_present = TasmotaGlobal.devices_present - Pcf8574.max_connected_ports; // reset no of devices to avoid duplicate ports on duplicate init.
|
||||||
Pcf8574.max_connected_ports = 0; // reset no of devices to avoid duplicate ports on duplicate init.
|
Pcf8574.max_connected_ports = 0; // reset no of devices to avoid duplicate ports on duplicate init.
|
||||||
for (uint32_t idx = 0; idx < Pcf8574.max_devices; idx++) { // suport up to 8 boards PCF8574
|
for (uint32_t idx = 0; idx < Pcf8574.max_devices; idx++) { // suport up to 8 boards PCF8574
|
||||||
|
uint8_t gpio = Pcf8574Read(idx);
|
||||||
|
Pcf8574.pin_mask[idx] = gpio;
|
||||||
|
#ifdef USE_PCF8574_MQTTINPUT
|
||||||
|
Pcf8574.last_input[idx] = gpio & ~Settings.pcf8574_config[idx];
|
||||||
|
#endif // #ifdef USE_PCF8574_MQTTINPUT
|
||||||
|
//AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: PCF-%d config=0x%02x, gpio=0x%02X"), idx +1, Settings.pcf8574_config[idx], gpio);
|
||||||
|
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: Device %d config 0x%02x"), idx +1, Settings.pcf8574_config[idx]);
|
for (uint32_t i = 0; i < 8; i++, gpio>>=1) {
|
||||||
|
|
||||||
for (uint32_t i = 0; i < 8; i++) {
|
|
||||||
uint8_t _result = Settings.pcf8574_config[idx] >> i &1;
|
uint8_t _result = Settings.pcf8574_config[idx] >> i &1;
|
||||||
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("PCF: I2C shift i %d: %d. Powerstate: %d, TasmotaGlobal.devices_present: %d"), i,_result, Settings.power>>i&1, TasmotaGlobal.devices_present);
|
//AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: I2C shift i %d: %d. Powerstate: %d, TasmotaGlobal.devices_present: %d"), i,_result, Settings.power>>i&1, TasmotaGlobal.devices_present);
|
||||||
if (_result > 0) {
|
if (_result > 0) {
|
||||||
Pcf8574.pin[TasmotaGlobal.devices_present] = i + 8 * idx;
|
Pcf8574.pin[TasmotaGlobal.devices_present] = i + 8 * idx;
|
||||||
bitWrite(TasmotaGlobal.rel_inverted, TasmotaGlobal.devices_present, Settings.flag3.pcf8574_ports_inverted); // SetOption81 - Invert all ports on PCF8574 devices
|
bitWrite(TasmotaGlobal.rel_inverted, TasmotaGlobal.devices_present, Settings.flag3.pcf8574_ports_inverted); // SetOption81 - Invert all ports on PCF8574 devices
|
||||||
|
if (!Settings.flag.save_state && !Settings.flag3.no_power_feedback) { // SetOption63 - Don't scan relay power state at restart - #5594 and #5663
|
||||||
|
//AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: Set power from from chip state"));
|
||||||
|
uint8_t power_state = Settings.flag3.pcf8574_ports_inverted ? 1 & ~gpio : 1 & gpio;
|
||||||
|
bitWrite(TasmotaGlobal.power, TasmotaGlobal.devices_present, power_state);
|
||||||
|
bitWrite(Settings.power, TasmotaGlobal.devices_present, power_state);
|
||||||
|
}
|
||||||
|
//else AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: DON'T set power from chip state"));
|
||||||
TasmotaGlobal.devices_present++;
|
TasmotaGlobal.devices_present++;
|
||||||
Pcf8574.max_connected_ports++;
|
Pcf8574.max_connected_ports++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: Settings.power=0x%08X, TasmotaGlobal.power=0x%08X"), Settings.power, TasmotaGlobal.power);
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("PCF: Total devices %d, PCF8574 output ports %d"), Pcf8574.max_devices, Pcf8574.max_connected_ports);
|
AddLog(LOG_LEVEL_INFO, PSTR("PCF: Total devices %d, PCF8574 output ports %d"), Pcf8574.max_devices, Pcf8574.max_connected_ports);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,6 +174,9 @@ const char HTTP_FORM_I2C_PCF8574_2[] PROGMEM =
|
||||||
"<option%s value='1'>" D_DEVICE_OUTPUT "</option>"
|
"<option%s value='1'>" D_DEVICE_OUTPUT "</option>"
|
||||||
"</select></td></tr>";
|
"</select></td></tr>";
|
||||||
|
|
||||||
|
const char HTTP_SNS_PCF8574_GPIO[] PROGMEM = "{s}PCF8574%c%d D%d{m}%d{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||||
|
|
||||||
|
|
||||||
void HandlePcf8574(void)
|
void HandlePcf8574(void)
|
||||||
{
|
{
|
||||||
if (!HttpCheckPriviledgedAccess()) { return; }
|
if (!HttpCheckPriviledgedAccess()) { return; }
|
||||||
|
@ -188,6 +211,63 @@ void HandlePcf8574(void)
|
||||||
WSContentStop();
|
WSContentStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(USE_PCF8574_SENSOR) || defined(USE_PCF8574_DISPLAYINPUT)
|
||||||
|
void Pcf8574Show(bool json)
|
||||||
|
{
|
||||||
|
#ifdef USE_PCF8574_SENSOR
|
||||||
|
if (json) {
|
||||||
|
for (int idx = 0 ; idx < Pcf8574.max_devices ; idx++)
|
||||||
|
{
|
||||||
|
uint8_t gpio = Pcf8574Read(idx);
|
||||||
|
ResponseAppend_P(PSTR(",\"PCF8574%c%d\":{\"D0\":%i,\"D1\":%i,\"D2\":%i,\"D3\":%i,\"D4\":%i,\"D5\":%i,\"D6\":%i,\"D7\":%i"),
|
||||||
|
IndexSeparator(), idx +1,
|
||||||
|
(gpio>>0)&1,(gpio>>1)&1,(gpio>>2)&1,(gpio>>3)&1,(gpio>>4)&1,(gpio>>5)&1,(gpio>>6)&1,(gpio>>7)&1);
|
||||||
|
}
|
||||||
|
ResponseJsonEnd();
|
||||||
|
}
|
||||||
|
#endif // #ifdef USE_PCF8574_SENSOR
|
||||||
|
#if defined(USE_WEBSERVER) && defined(USE_PCF8574_DISPLAYINPUT)
|
||||||
|
if(!json) {
|
||||||
|
for (int idx = 0 ; idx < Pcf8574.max_devices ; idx++)
|
||||||
|
{
|
||||||
|
uint8_t input_mask = ~Settings.pcf8574_config[idx]; //invert to 1 = input
|
||||||
|
uint8_t gpio = Pcf8574Read(idx);
|
||||||
|
for (int pin = 0 ; pin < 8 ; ++pin, input_mask>>=1, gpio>>=1)
|
||||||
|
{
|
||||||
|
if (input_mask & 1)
|
||||||
|
WSContentSend_P(HTTP_SNS_PCF8574_GPIO, IndexSeparator(), idx +1, pin, gpio & 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // defined(USE_WEBSERVER) && defined(USE_PCF8574_DISPLAYINPUT)
|
||||||
|
}
|
||||||
|
#endif // #if defined(USE_PCF8574_SENSOR) || defined(USE_PCF8574_DISPLAYINPUT)
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_PCF8574_MQTTINPUT
|
||||||
|
void Pcf8574CheckForInputChange(void)
|
||||||
|
{
|
||||||
|
for (int idx = 0 ; idx < Pcf8574.max_devices ; idx++)
|
||||||
|
{
|
||||||
|
uint8_t input_mask = ~Settings.pcf8574_config[idx]; //invert to 1 = input
|
||||||
|
uint8_t input = Pcf8574Read(idx) & input_mask;
|
||||||
|
uint8_t last_input = Pcf8574.last_input[idx];
|
||||||
|
if (input != last_input) { // don't scan bits if no change (EVERY_50_MS !)
|
||||||
|
for (uint8_t pin = 0 ; pin < 8 ; ++pin) {
|
||||||
|
if (bitRead(input_mask,pin) && bitRead(input,pin) != bitRead(last_input,pin)) {
|
||||||
|
ResponseTime_P(PSTR(",\"PCF8574%c%d_INP\":{\"D%i\":%i}}"), IndexSeparator(), idx +1, pin, bitRead(input,pin));
|
||||||
|
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, PSTR("PCF8574_INP"));
|
||||||
|
if (Settings.flag3.hass_tele_on_power) { // SetOption59 - Send tele/%topic%/SENSOR in addition to stat/%topic%/RESULT
|
||||||
|
MqttPublishSensor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Pcf8574.last_input[idx] = input;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif //#ifdef USE_PCF8574_MQTTINPUT
|
||||||
|
|
||||||
void Pcf8574SaveSettings(void)
|
void Pcf8574SaveSettings(void)
|
||||||
{
|
{
|
||||||
char stemp[7];
|
char stemp[7];
|
||||||
|
@ -243,6 +323,16 @@ bool Xdrv28(uint8_t function)
|
||||||
case FUNC_SET_POWER:
|
case FUNC_SET_POWER:
|
||||||
Pcf8574SwitchRelay();
|
Pcf8574SwitchRelay();
|
||||||
break;
|
break;
|
||||||
|
#ifdef USE_PCF8574_MQTTINPUT
|
||||||
|
case FUNC_EVERY_50_MSECOND:
|
||||||
|
Pcf8574CheckForInputChange();
|
||||||
|
break;
|
||||||
|
#endif // #ifdef USE_PCF8574_MQTTINPUT
|
||||||
|
#ifdef USE_PCF8574_SENSOR
|
||||||
|
case FUNC_JSON_APPEND:
|
||||||
|
Pcf8574Show(1);
|
||||||
|
break;
|
||||||
|
#endif // #ifdef USE_PCF8574_SENSOR
|
||||||
#ifdef USE_WEBSERVER
|
#ifdef USE_WEBSERVER
|
||||||
case FUNC_WEB_ADD_BUTTON:
|
case FUNC_WEB_ADD_BUTTON:
|
||||||
WSContentSend_P(HTTP_BTN_MENU_PCF8574);
|
WSContentSend_P(HTTP_BTN_MENU_PCF8574);
|
||||||
|
@ -250,6 +340,11 @@ bool Xdrv28(uint8_t function)
|
||||||
case FUNC_WEB_ADD_HANDLER:
|
case FUNC_WEB_ADD_HANDLER:
|
||||||
WebServer_on(PSTR("/" WEB_HANDLE_PCF8574), HandlePcf8574);
|
WebServer_on(PSTR("/" WEB_HANDLE_PCF8574), HandlePcf8574);
|
||||||
break;
|
break;
|
||||||
|
#ifdef USE_PCF8574_DISPLAYINPUT
|
||||||
|
case FUNC_WEB_SENSOR:
|
||||||
|
Pcf8574Show(0);
|
||||||
|
break;
|
||||||
|
#endif // #ifdef USE_PCF8574_DISPLAYINPUT
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,8 +56,8 @@ bool Dht12Read(void)
|
||||||
uint8_t tempTenth = Wire.read();
|
uint8_t tempTenth = Wire.read();
|
||||||
uint8_t checksum = Wire.read();
|
uint8_t checksum = Wire.read();
|
||||||
|
|
||||||
Dht12.humidity = ConvertHumidity( (float) humidity + (float) humidityTenth/(float) 10.0 );
|
Dht12.humidity = ConvertHumidity( humidity + ((float) humidityTenth) /10 );
|
||||||
Dht12.temperature = ConvertTemp( ((float)temp + (float)(tempTenth & 0x7F) / (float) 10.0) * (tempTenth & 0x80) ? -1.0 : 1.0 );
|
Dht12.temperature = ConvertTemp( (temp + (tempTenth & 0x7F) / 10.0f) * ((tempTenth & 0x80) ? -1 : 1) );
|
||||||
|
|
||||||
if (isnan(Dht12.temperature) || isnan(Dht12.humidity)) { return false; }
|
if (isnan(Dht12.temperature) || isnan(Dht12.humidity)) { return false; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue