From 53d2344a92b3348386bb8b6d17be78feedd0b432 Mon Sep 17 00:00:00 2001 From: dingpppp <117643419+dingpppp@users.noreply.github.com> Date: Wed, 3 Jan 2024 15:20:55 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=87=BD=E6=95=B0=E5=A3=B0=E6=98=8E?= =?UTF-8?q?=E5=8A=A0=E4=B8=8A=E5=88=86=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/xgzf4000.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/xgzf4000.h b/include/xgzf4000.h index 4ddc38a..1924772 100644 --- a/include/xgzf4000.h +++ b/include/xgzf4000.h @@ -39,7 +39,7 @@ typedef struct { } xgzf4000_i2c_config_t; -esp_err_t xgzf4000_new_sensor(i2c_port_t i2c_num, int sda_pin, int scl_pin) +esp_err_t xgzf4000_new_sensor(i2c_port_t i2c_num, int sda_pin, int scl_pin); /** * @brief Delete XGZF4000 device handle. From 8875e1f23d3ff0dd22e9d25bd82b1aaee8900ea9 Mon Sep 17 00:00:00 2001 From: dingpppp <117643419+dingpppp@users.noreply.github.com> Date: Wed, 3 Jan 2024 15:22:03 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E9=87=8D=E5=A4=8D=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E8=A6=81=E7=94=A8=E5=90=8C=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=90=8D=E5=AD=97=E5=AE=9A=E4=B9=89TAG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/default_example/main/xgzf4000-poll-data.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/default_example/main/xgzf4000-poll-data.c b/examples/default_example/main/xgzf4000-poll-data.c index 6e24cd2..f52bd6c 100644 --- a/examples/default_example/main/xgzf4000-poll-data.c +++ b/examples/default_example/main/xgzf4000-poll-data.c @@ -1,7 +1,7 @@ #include "esp_log.h" #include "xgzf4000.h" -static const char *TAG = "XGZF4000_APP"; +static const char *TAG_XGZF = "XGZF4000_APP"; #define I2C_XGZF4000_ADDR 0x50 // default I2C address of the XGZF4000 sensor #define I2C_MASTER_SCL_IO 19 // Assign the SCL pin number @@ -25,12 +25,12 @@ static void poll_air_flow_data(void) { // Log the flow rate in the selected unit #ifdef CONFIG_FLOW_RATE_UNIT_LMIN - ESP_LOGI(TAG, "Raw Flow Rate: %u, Flow Rate: %.2f L/min", flow_rate_raw, flow_rate); + ESP_LOGI(TAG_XGZF, "Raw Flow Rate: %u, Flow Rate: %.2f L/min", flow_rate_raw, flow_rate); #elif CONFIG_FLOW_RATE_UNIT_CMH - ESP_LOGI(TAG, "Raw Flow Rate: %u, Flow Rate: %.2f m³/h", flow_rate_raw, flow_rate); + ESP_LOGI(TAG_XGZF, "Raw Flow Rate: %u, Flow Rate: %.2f m³/h", flow_rate_raw, flow_rate); #endif } else { - ESP_LOGE(TAG, "Failed to read air flow data"); + ESP_LOGE(TAG_XGZF, "Failed to read air flow data"); } } From ddd59ac6784728108b32d1cc5ffa226920e279f7 Mon Sep 17 00:00:00 2001 From: dingpppp <117643419+dingpppp@users.noreply.github.com> Date: Wed, 3 Jan 2024 15:24:06 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=AE=9A=E4=B9=89=E4=B8=89=E4=B8=AA?= =?UTF-8?q?=E6=9C=AA=E5=AE=9A=E4=B9=89=E7=9A=84=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xgzf4000.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xgzf4000.c b/xgzf4000.c index 00ac927..15b4ba1 100644 --- a/xgzf4000.c +++ b/xgzf4000.c @@ -19,6 +19,10 @@ #include "xgzf4000.h" #include "xgzf4000_reg.h" +#define I2C_MASTER_FREQ_HZ 100000 // I2C master frequency +#define I2C_MASTER_RX_BUF_DISABLE 0 +#define I2C_MASTER_TX_BUF_DISABLE 0 + #define K_FACTOR 1000 // Proportionality factor for converting raw flow data to actual flow rate, either 1000 or 1000 static esp_err_t xgzf4000_read_flow_data(xgzf4000_dev_handle_t dev, uint8_t *data, size_t len) From cd2ac39833bc8cf6746b31362d59016c161bac44 Mon Sep 17 00:00:00 2001 From: dingpppp <117643419+dingpppp@users.noreply.github.com> Date: Wed, 3 Jan 2024 15:25:20 +0800 Subject: [PATCH 4/5] =?UTF-8?q?I2C=E8=84=9A=E6=94=B9=E6=88=90=E5=B7=B2?= =?UTF-8?q?=E6=9C=89=E7=9A=84=E5=AE=8F=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/default_example/main/xgzf4000-poll-data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/default_example/main/xgzf4000-poll-data.c b/examples/default_example/main/xgzf4000-poll-data.c index f52bd6c..c5743ce 100644 --- a/examples/default_example/main/xgzf4000-poll-data.c +++ b/examples/default_example/main/xgzf4000-poll-data.c @@ -42,7 +42,7 @@ void app_main(void) { .i2c_addr = I2C_XGZF4000_ADDR, }; - ESP_ERROR_CHECK(xgzf4000_new_sensor(I2C_MASTER_NUM, I2C_SDA_PIN, I2C_SCL_PIN)); + ESP_ERROR_CHECK(xgzf4000_new_sensor(I2C_MASTER_NUM, I2C_MASTER_SDA_IO, I2C_MASTER_SCL_IO)); if (init_xgzf4000_sensor() != ESP_OK) { From 1096a159b2328fd8819d660698b548a6d337e31b Mon Sep 17 00:00:00 2001 From: dingpppp <117643419+dingpppp@users.noreply.github.com> Date: Wed, 3 Jan 2024 15:28:52 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=89=BE=E4=B8=8D=E5=88=B0xgzf4000?= =?UTF-8?q?=E4=BC=A0=E6=84=9F=E5=99=A8=E5=88=9D=E5=A7=8B=E5=8C=96=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/default_example/main/xgzf4000-poll-data.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/default_example/main/xgzf4000-poll-data.c b/examples/default_example/main/xgzf4000-poll-data.c index c5743ce..54c8bb0 100644 --- a/examples/default_example/main/xgzf4000-poll-data.c +++ b/examples/default_example/main/xgzf4000-poll-data.c @@ -45,10 +45,10 @@ void app_main(void) { ESP_ERROR_CHECK(xgzf4000_new_sensor(I2C_MASTER_NUM, I2C_MASTER_SDA_IO, I2C_MASTER_SCL_IO)); - if (init_xgzf4000_sensor() != ESP_OK) { - ESP_LOGE(TAG, "Failed to initialize XGZF4000 sensor"); - return; - } + // if (init_xgzf4000_sensor() != ESP_OK) { + // ESP_LOGE(TAG_XGZF, "Failed to initialize XGZF4000 sensor"); + // return; + // } while (1) { poll_air_flow_data();