WIP
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
.vscode
|
||||
.DS_Store
|
@ -24,8 +24,9 @@ extern "C"
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ZH_DHT11, ///< Sensor type DHT11.
|
||||
ZH_DHT22 ///< Sensor type DHT22 or AM2302.
|
||||
ZH_DHT11, ///< Sensor type DHT11.
|
||||
ZH_DHT22, ///< Sensor type DHT22 or AM2302.
|
||||
ZH_AM2320, ///< Sensor type AM2320.
|
||||
} zh_dht_sensor_type_t;
|
||||
|
||||
/**
|
||||
@ -34,7 +35,7 @@ extern "C"
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t sensor_pin; ///< Sensor GPIO connection. @note
|
||||
uint8_t sensor_pin; ///< Sensor GPIO connection. @note Can be NULL for AM2320 sensor with I2C connection.
|
||||
zh_dht_sensor_type_t sensor_type; ///< Sensor type. @note
|
||||
} zh_dht_handle_t;
|
||||
|
||||
@ -46,7 +47,7 @@ extern "C"
|
||||
*
|
||||
* @return Handle of the sensor
|
||||
*/
|
||||
zh_dht_handle_t zh_dht_init(const zh_dht_sensor_type_t sensor_type, const uint8_t sensor_pin);
|
||||
zh_dht_handle_t zh_dht_init(const zh_dht_sensor_type_t sensor_type, const uint8_t *sensor_pin);
|
||||
|
||||
/**
|
||||
* @brief Read DHT sensor.
|
||||
|
4
zh_dht.c
4
zh_dht.c
@ -25,7 +25,7 @@ static const char *TAG = "zh_dht";
|
||||
|
||||
static esp_err_t _read_bit(const zh_dht_handle_t *dht_handle, bool *bit);
|
||||
|
||||
zh_dht_handle_t zh_dht_init(const zh_dht_sensor_type_t sensor_type, const uint8_t sensor_pin)
|
||||
zh_dht_handle_t zh_dht_init(const zh_dht_sensor_type_t sensor_type, const uint8_t *sensor_pin)
|
||||
{
|
||||
ESP_LOGI(TAG, "DHT initialization begin.");
|
||||
zh_dht_handle_t zh_dht_handle = {
|
||||
@ -34,7 +34,7 @@ zh_dht_handle_t zh_dht_init(const zh_dht_sensor_type_t sensor_type, const uint8_
|
||||
gpio_config_t config = {0};
|
||||
config.intr_type = GPIO_INTR_DISABLE;
|
||||
config.mode = GPIO_MODE_INPUT;
|
||||
config.pin_bit_mask = (1ULL << sensor_pin);
|
||||
config.pin_bit_mask = (1ULL << *sensor_pin);
|
||||
config.pull_down_en = GPIO_PULLDOWN_DISABLE;
|
||||
config.pull_up_en = GPIO_PULLUP_ENABLE;
|
||||
if (gpio_config(&config) != ESP_OK)
|
||||
|
Reference in New Issue
Block a user