Attempt to stabilize Shelly Pro 4PM values

This commit is contained in:
Theo Arends 2023-02-20 11:31:12 +01:00
parent 2d83c335bc
commit 692e9090c8
2 changed files with 12 additions and 0 deletions

View File

@ -272,6 +272,10 @@ void ShellyProUpdateIsr(void) {
/*
The goal if this function is to minimize SPI and SetVirtualPinState calls
*/
noInterrupts();
detachInterrupt(SPro.pin_mcp23s17_int);
interrupts();
uint32_t input_state = SP4Mcp23S17Read16(SP4_MCP23S17_INTCAPA); // Read intcap and clear interrupt
input_state &= 0x806F; // Only test input bits
@ -298,6 +302,8 @@ void ShellyProUpdateIsr(void) {
mask <<= 1;
}
SPro.input_state = input_state;
attachInterrupt(SPro.pin_mcp23s17_int, ShellyProUpdateIsr, CHANGE);
}
bool ShellyProButton(void) {

View File

@ -836,6 +836,7 @@ bool Xnrg07(uint32_t function) {
bool result = false;
switch (function) {
/*
case FUNC_ENERGY_EVERY_SECOND: // Use energy interrupt timer (fails on SPI)
if (!Ade7953.use_spi) { // No SPI
Ade7953EnergyEverySecond();
@ -846,6 +847,11 @@ bool Xnrg07(uint32_t function) {
Ade7953EnergyEverySecond();
}
break;
*/
case FUNC_ENERGY_EVERY_SECOND: // Use energy interrupt timer (fails on SPI)
Ade7953EnergyEverySecond();
break;
case FUNC_COMMAND:
result = Ade7953Command();
break;