diff --git a/components/esp32-ds18b20 b/components/esp32-ds18b20 index db5b263..0926cf3 160000 --- a/components/esp32-ds18b20 +++ b/components/esp32-ds18b20 @@ -1 +1 @@ -Subproject commit db5b2630824e445b735725cfb99d634c50219100 +Subproject commit 0926cf30719c8e214f1fba3f8c12ff6ba5a54c3f diff --git a/main/app_main.c b/main/app_main.c index cc4d9b0..593fcec 100644 --- a/main/app_main.c +++ b/main/app_main.c @@ -33,6 +33,7 @@ //#define USE_STATIC 1 #include "owb.h" +#include "owb_rmt.h" #include "ds18b20.h" @@ -46,17 +47,20 @@ void app_main() esp_log_level_set("*", ESP_LOG_INFO); // Stable readings require a brief period before communication - vTaskDelay(1000.0 / portTICK_PERIOD_MS); + vTaskDelay(2000.0 / portTICK_PERIOD_MS); // Create a 1-Wire bus -#ifdef USE_STATIC - OneWireBus owb_static; // static allocation - OneWireBus * owb = &owb_static; -#else - OneWireBus * owb = owb_malloc(); // heap allocation -#endif - - owb_init(owb, GPIO_DS18B20_0); +//#ifdef USE_STATIC +// OneWireBus owb_static; // static allocation +// OneWireBus * owb = &owb_static; +//#else +// OneWireBus * owb = owb_malloc(); // heap allocation +//#endif + OneWireBus * owb; + owb_rmt_driver_info rmt_driver_info; + owb = owb_rmt_initialize(&rmt_driver_info, GPIO_DS18B20_0, RMT_CHANNEL_1, RMT_CHANNEL_0); + +// owb_init(owb, GPIO_DS18B20_0); owb_use_crc(owb, true); // enable CRC check for ROM code // Find all connected devices @@ -64,7 +68,8 @@ void app_main() OneWireBus_ROMCode device_rom_codes[MAX_DEVICES] = {0}; int num_devices = 0; OneWireBus_SearchState search_state = {0}; - bool found = owb_search_first(owb, &search_state); + bool found = false; + owb_search_first(owb, &search_state, &found); while (found) { char rom_code_s[17]; @@ -72,7 +77,7 @@ void app_main() printf(" %d : %s\n", num_devices, rom_code_s); device_rom_codes[num_devices] = search_state.rom_code; ++num_devices; - found = owb_search_next(owb, &search_state); + owb_search_next(owb, &search_state, &found); } printf("Found %d devices\n", num_devices); @@ -90,7 +95,9 @@ void app_main() }; char rom_code_s[17]; owb_string_from_rom_code(known_device, rom_code_s, sizeof(rom_code_s)); - printf("Device %s is %s\n", rom_code_s, owb_verify_rom(owb, known_device) ? "present" : "not present"); + bool is_present = false; + owb_verify_rom(owb, known_device, &is_present); + printf("Device %s is %s\n", rom_code_s, is_present ? "present" : "not present"); // Create a DS18B20 device on the 1-Wire bus #ifdef USE_STATIC @@ -186,7 +193,7 @@ void app_main() { ds18b20_free(&devices[i]); } - owb_free(&owb); +// owb_free(&owb); #endif printf("Restarting now.\n");