diff --git a/include/zh_pcf8574.h b/include/zh_pcf8574.h index 30e31f8..577b78d 100644 --- a/include/zh_pcf8574.h +++ b/include/zh_pcf8574.h @@ -73,6 +73,7 @@ extern "C" { uint8_t i2c_address; // The i2c address of PCF8574 expander that caused the interrupt. uint8_t gpio_number; // The GPIO that caused the interrupt. + bool gpio_level; // The GPIO level that caused the interrupt. } zh_pcf8574_event_on_isr_t; /** diff --git a/version.txt b/version.txt index 867e524..589268e 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.2.0 \ No newline at end of file +1.3.0 \ No newline at end of file diff --git a/zh_pcf8574.c b/zh_pcf8574.c index 69254cf..bbf38e3 100644 --- a/zh_pcf8574.c +++ b/zh_pcf8574.c @@ -223,6 +223,7 @@ static void IRAM_ATTR _zh_pcf8574_isr_processing_task(void *pvParameter) zh_pcf8574_event_on_isr_t event = {0}; event.i2c_address = handle->i2c_address; event.gpio_number = 0xFF; + uint8_t old_reg = handle->gpio_status; uint8_t reg_temp = 0; esp_err_t err = _zh_pcf8574_read_register(handle, ®_temp); if (err != ESP_OK) @@ -232,9 +233,13 @@ static void IRAM_ATTR _zh_pcf8574_isr_processing_task(void *pvParameter) } for (uint8_t j = 0; j <= 7; ++j) { - if (((handle->gpio_work_mode & _gpio_matrix[j]) != 0) && ((reg_temp & _gpio_matrix[j]) == 0)) + if ((handle->gpio_work_mode & _gpio_matrix[j]) != 0) { - event.gpio_number = j; + if ((old_reg & _gpio_matrix[j]) != (reg_temp & _gpio_matrix[j])) + { + event.gpio_number = j; + event.gpio_level = reg_temp & _gpio_matrix[j]; + } break; } }