Skip to content

Commit

Permalink
Fixed PCF8574 mode 1
Browse files Browse the repository at this point in the history
- Fixed PCF8574 mode 1 with base relays exception 3/28 regression from v12.4.0.4 (#19408)
- Bump version v13.1.0.2
  • Loading branch information
arendst committed Aug 31, 2023
1 parent 2bae1f4 commit 48cf04d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
19 changes: 13 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@ All notable changes to this project will be documented in this file.

## [Unreleased] - Development

## [13.1.0.1]
## [13.1.0.2]
### Added

### Breaking Changed

### Changed

### Fixed
- PCF8574 mode 1 with base relays exception 3/28 regression from v12.4.0.4 (#19408)

### Removed

## [13.1.0.1] 20230831
### Added
- Commands to allow setting of timeprop parameters (#19310)
- Variables ``%power<1..28>%`` and ``%switch<1..28>%`` to rules (#19331)
- Experimental support for ESP32-C2 and ESP32-C6 using Arduino core v3.0

### Breaking Changed

### Changed
- Display invert setting after tasmota start in uDisplay driver (#19337)

Expand All @@ -19,9 +29,6 @@ All notable changes to this project will be documented in this file.
- Teleinfo power (#19381)
- Exception 3 in IRHVAC (#19389)

### Removed


## [Released] - Development

## [13.1.0] 20230815
Expand Down
3 changes: 2 additions & 1 deletion RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm

[Complete list](BUILDS.md) of available feature and sensors.

## Changelog v13.1.0.1
## Changelog v13.1.0.2
### Added
- Experimental support for ESP32-C2 and ESP32-C6 using Arduino core v3.0
- Commands to allow setting of timeprop parameters [#19310](https://github.com/arendst/Tasmota/issues/19310)
Expand All @@ -125,5 +125,6 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
- Shutter invert [#19341](https://github.com/arendst/Tasmota/issues/19341) and [#19374](https://github.com/arendst/Tasmota/issues/19374)
- Teleinfo power [#19381](https://github.com/arendst/Tasmota/issues/19381)
- Exception 3 in IRHVAC [#19389](https://github.com/arendst/Tasmota/issues/19389)
- PCF8574 mode 1 with base relays exception 3/28 regression from v12.4.0.4 [#19408](https://github.com/arendst/Tasmota/issues/19408)

### Removed
2 changes: 1 addition & 1 deletion tasmota/include/tasmota_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
#ifndef _TASMOTA_VERSION_H_
#define _TASMOTA_VERSION_H_

const uint32_t VERSION = 0x0D010001; // 13.1.0.1
const uint32_t VERSION = 0x0D010002; // 13.1.0.2

#endif // _TASMOTA_VERSION_H_
17 changes: 10 additions & 7 deletions tasmota/tasmota_xdrv_driver/xdrv_28_pcf8574_v2.ino
Original file line number Diff line number Diff line change
Expand Up @@ -425,14 +425,15 @@ bool Pcf8574AddSwitch(void) {
\*********************************************************************************************/

void Pcf8574SwitchRelay(void) {
for (uint32_t i = 0; i < TasmotaGlobal.devices_present; i++) {
uint8_t relay_state = bitRead(XdrvMailbox.index, i);
uint32_t devices_present = TasmotaGlobal.devices_present - Pcf8574.relay_offset;
for (uint32_t i = 0; i < devices_present; i++) {
uint8_t relay_state = bitRead(XdrvMailbox.index, Pcf8574.relay_offset + i);

if (Pcf8574.max_devices > 0 && Pcf8574_pin[i] < 99) {
uint8_t board = Pcf8574_pin[i]>>3;
uint8_t pin = Pcf8574_pin[i]&0x7;
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, Pcf8574.relay_offset + i) ? !relay_state : relay_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);
Expand Down Expand Up @@ -485,9 +486,10 @@ void Pcf8574ModuleInitMode1(void) {

for (uint32_t i = 0; i < 8; i++, gpio>>=1) {
uint8_t _result = Settings->pcf8574_config[idx] >> i &1;
//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);
uint32_t devices_present = TasmotaGlobal.devices_present - Pcf8574.relay_offset;
//AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: I2C shift i %d: %d. Powerstate: %d, devices_present: %d"), i,_result, Settings->power>>i&1, devices_present);
if (_result > 0) {
Pcf8574_pin[TasmotaGlobal.devices_present] = i + 8 * idx;
Pcf8574_pin[devices_present] = i + 8 * idx;
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"));
Expand Down Expand Up @@ -575,7 +577,8 @@ void Pcf8574SaveSettings(void) {
n = n&(n-1);
count++;
}
if (count <= TasmotaGlobal.devices_present) {
uint32_t devices_present = TasmotaGlobal.devices_present - Pcf8574.relay_offset;
if (count <= devices_present) {
UpdateDevicesPresent(-count);
}
for (byte i = 0; i < 8; i++) {
Expand Down Expand Up @@ -662,12 +665,12 @@ void Pcf8574ModuleInit(void) {
if (Pcf8574.mode) {
Pcf8574_pin = (uint16_t*)malloc(Pcf8574.max_connected_ports * sizeof(uint16_t));
if (Pcf8574_pin) {
Pcf8574.relay_offset = TasmotaGlobal.devices_present;
#ifdef USE_PCF8574_MODE2
if (Pcf8574LoadTemplate()) {
Pcf8574.mode = 2;
Pcf8574.button_offset = -1;
Pcf8574.switch_offset = -1;
Pcf8574.relay_offset = TasmotaGlobal.devices_present;
Pcf8574.relay_max -= UpdateDevicesPresent(Pcf8574.relay_max);
} else
#endif // USE_PCF8574_MODE2
Expand Down

0 comments on commit 48cf04d

Please sign in to comment.