mirror of
https://github.com/rzajac/esp-drv.git
synced 2025-07-26 14:11:05 +03:00
Update documentation and fix small issues.
This commit is contained in:
@ -18,7 +18,7 @@ anymore.
|
||||
Most of the operations with the DS18B20 library is based on passing pointers
|
||||
to the `esp_ow_device` structure which has pointer to `esp_ds18b20_st`
|
||||
status structure. The `esp_ds18b20_st` keeps track of last scratch pad read
|
||||
the last temperature conversion.
|
||||
and last temperature conversion.
|
||||
|
||||
```
|
||||
esp_ow_device *device;
|
||||
@ -34,12 +34,11 @@ esp_ow_dev *device = esp_ds18b20_new_dev(rom);
|
||||
|
||||
```
|
||||
|
||||
With DS18B20 temperature measurement takes between 94 and 750ms depending
|
||||
on resolution. You don't want to block the CPU for that long waiting for
|
||||
example using some kind of delay. That's why library is using event bus
|
||||
(esp_eb) to emmit events when the temperature conversion is ready to read.
|
||||
Check [example program](../../examples/ds18b20_temp) to see how it should be
|
||||
done.
|
||||
Temperature measurement with DS18B20 takes between 94 and 750ms depending
|
||||
on resolution. You don't want to block the CPU for that long using some kind
|
||||
of delay. That's why library is using event bus (esp_eb) to emmit events when
|
||||
the temperature conversion is ready.
|
||||
|
||||
See driver documentation in [esp_ds18b20.h](include/esp_ds18b20.h) header file
|
||||
for more details.
|
||||
Check [example program](../../examples/ds18b20_temp) to see how it should be
|
||||
done and driver documentation in [esp_ds18b20.h](include/esp_ds18b20.h)
|
||||
header file for more details.
|
||||
|
@ -217,10 +217,15 @@ esp_ds18b20_search(uint8_t gpio_num, bool in_alert, esp_ow_device **list)
|
||||
esp_ow_device *ICACHE_FLASH_ATTR
|
||||
esp_ds18b20_new_dev(uint8_t *rom)
|
||||
{
|
||||
esp_ow_device *device = os_zalloc(sizeof(esp_ow_device));
|
||||
esp_ds18b20_st *st = os_zalloc(sizeof(esp_ds18b20_st));
|
||||
esp_ow_device *device = esp_ow_new_dev(rom);
|
||||
if (device == NULL) return NULL;
|
||||
|
||||
esp_ds18b20_st *st = os_zalloc(sizeof(esp_ds18b20_st));
|
||||
if (st == NULL) {
|
||||
os_free(device);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
os_memcpy(device->rom, rom, 8);
|
||||
st->last_temp = ESP_DS18B20_TEMP_ERR;
|
||||
st->retries = -1;
|
||||
device->custom = st;
|
||||
@ -228,7 +233,6 @@ esp_ds18b20_new_dev(uint8_t *rom)
|
||||
return device;
|
||||
}
|
||||
|
||||
|
||||
esp_ow_device *ICACHE_FLASH_ATTR
|
||||
esp_ds18b20_get(uint8_t gpio_num)
|
||||
{
|
||||
|
@ -95,7 +95,7 @@ esp_ds18b20_search(uint8_t gpio_num, bool in_alert, esp_ow_device **list);
|
||||
*
|
||||
* @param rom The pointer to 8 byte ROM address
|
||||
*
|
||||
* @return The device.
|
||||
* @return The device or NULL on error.
|
||||
*/
|
||||
esp_ow_device *ICACHE_FLASH_ATTR
|
||||
esp_ds18b20_new_dev(uint8_t *rom);
|
||||
|
Reference in New Issue
Block a user