Skip to content

Commit

Permalink
Rename AHT20 variables and names to XGZF4000
Browse files Browse the repository at this point in the history
  • Loading branch information
hayschan committed Dec 25, 2023
1 parent 4d41626 commit d78a1da
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 30 deletions.
39 changes: 19 additions & 20 deletions include/xgzf4000.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,53 +15,53 @@ extern "C" {

#include "driver/i2c.h"

/* AHT20 address: CE pin low - 0x38, CE pin high - 0x39 */
#define AHT20_ADDRRES_0 (0x38<<1)
#define AHT20_ADDRESS_1 (0x39<<1)
/* XGZF4000 address: CE pin low - 0x38, CE pin high - 0x39 */
#define XGZF4000_ADDRRES_0 (0x38<<1)
#define XGZF4000_ADDRESS_1 (0x39<<1)

/**
* @brief Type of AHT20 device handle
* @brief Type of XGZF4000 device handle
*
*/
typedef void *aht20_dev_handle_t;
typedef void *xgzf4000_dev_handle_t;

/**
* @brief AHT20 I2C config struct
* @brief XGZF4000 I2C config struct
*
*/
typedef struct {
i2c_port_t i2c_port; /*!< I2C port used to connecte AHT20 device */
uint8_t i2c_addr; /*!< I2C address of AHT20 device, can be 0x38 or 0x39 according to A0 pin */
} aht20_i2c_config_t;
i2c_port_t i2c_port; /*!< I2C port used to connecte XGZF4000 device */
uint8_t i2c_addr; /*!< I2C address of XGZF4000 device, can be 0x38 or 0x39 according to A0 pin */
} xgzf4000_i2c_config_t;

/**
* @brief Create new AHT20 device handle.
* @brief Create new XGZF4000 device handle.
*
* @param[in] i2c_conf Config for I2C used by AHT20
* @param[out] handle_out New AHT20 device handle
* @param[in] i2c_conf Config for I2C used by XGZF4000
* @param[out] handle_out New XGZF4000 device handle
* @return
* - ESP_OK Device handle creation success.
* - ESP_ERR_INVALID_ARG Invalid device handle or argument.
* - ESP_ERR_NO_MEM Memory allocation failed.
*
*/
esp_err_t aht20_new_sensor(const aht20_i2c_config_t *i2c_conf, aht20_dev_handle_t *handle_out);
esp_err_t xgzf4000_new_sensor(const xgzf4000_i2c_config_t *i2c_conf, xgzf4000_dev_handle_t *handle_out);

/**
* @brief Delete AHT20 device handle.
* @brief Delete XGZF4000 device handle.
*
* @param[in] handle AHT20 device handle
* @param[in] handle XGZF4000 device handle
* @return
* - ESP_OK Device handle deletion success.
* - ESP_ERR_INVALID_ARG Invalid device handle or argument.
*
*/
esp_err_t aht20_del_sensor(aht20_dev_handle_t handle);
esp_err_t xgzf4000_del_sensor(xgzf4000_dev_handle_t handle);

/**
* @brief read the temperature and humidity data
*
* @param[in] *handle points to an aht20 handle structure
* @param[in] *handle points to an xgzf4000 handle structure
* @param[out] *temperature_raw points to a raw temperature buffer
* @param[out] *temperature points to a converted temperature buffer
* @param[out] *humidity_raw points to a raw humidity buffer
Expand All @@ -71,9 +71,8 @@ esp_err_t aht20_del_sensor(aht20_dev_handle_t handle);
* - ESP_OK Success
* - ESP_FAIL Fail
*/
esp_err_t aht20_read_temperature_humidity(aht20_dev_handle_t handle,
uint32_t *temperature_raw, float *temperature,
uint32_t *humidity_raw, float *humidity);
static esp_err_t xgzf4000_read_flow_data(xgzf4000_dev_handle_t dev, uint8_t *data, size_t len)

#ifdef __cplusplus
}
#endif
8 changes: 0 additions & 8 deletions priv_include/xgzf4000_reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,3 @@
#define TEMPERATURE_MIN (0.0f) /**< chip min working temperature */
#define TEMPERATURE_MAX (50.0f) /**< chip max working temperature */
#define PRESSURE_MAX (0.2f) /**< chip max working pressure */

#define AHT20_START_MEASURMENT_CMD 0xAC /* start measurment command */

#define AT581X_STATUS_CMP_INT (2) /* 1 --Out threshold range; 0 --In threshold range */
#define AT581X_STATUS_Calibration_Enable (3) /* 1 --Calibration enable; 0 --Calibration disable */
#define AT581X_STATUS_CRC_FLAG (4) /* 1 --CRC ok; 0 --CRC failed */
#define AT581X_STATUS_MODE_STATUS (5) /* 00 -NOR mode; 01 -CYC mode; 1x --CMD mode */
#define AT581X_STATUS_BUSY_INDICATION (7) /* 1 --Equipment is busy; 0 --Equipment is idle */
4 changes: 2 additions & 2 deletions xgzf4000.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ esp_err_t xgzf4000_read_air_flow(xgzf4000_dev_handle_t handle, uint32_t *flow_ra
esp_err_t xgzf4000_new_sensor(const xgzf4000_i2c_config_t *i2c_conf, xgzf4000_dev_handle_t *handle_out)
{
ESP_LOGI(TAG, "Initializing XGZF4000 Air Flow Sensor");
ESP_LOGI(TAG, "%-15s: %d.%d.%d", CHIP_NAME, AHT20_VER_MAJOR, AHT20_VER_MINOR, AHT20_VER_PATCH);
ESP_LOGI(TAG, "%-15s: %d.%d.%d", CHIP_NAME, XGZF4000_VER_MAJOR, XGZF4000_VER_MINOR, XGZF4000_VER_PATCH);
ESP_LOGI(TAG, "%-15s: %1.1f - %1.1fV", "SUPPLY_VOLTAGE", SUPPLY_VOLTAGE_MIN, SUPPLY_VOLTAGE_MAX);
ESP_LOGI(TAG, "%-15s: %.2f - %.2f℃", "TEMPERATURE", TEMPERATURE_MIN, TEMPERATURE_MAX);
ESP_LOGI(TAG, "%-15s: %.2fMPa", "PRESSURE", PRESSURE_MAX);
Expand All @@ -96,7 +96,7 @@ esp_err_t xgzf4000_new_sensor(const xgzf4000_i2c_config_t *i2c_conf, xgzf4000_de
}


esp_err_t xgzf4000_del_sensor(aht20_dev_handle_t handle)
esp_err_t xgzf4000_del_sensor(xgzf4000_dev_handle_t handle)
{
ESP_RETURN_ON_FALSE(handle, ESP_ERR_INVALID_ARG, TAG, "invalid device handle pointer");

Expand Down

0 comments on commit d78a1da

Please sign in to comment.