diff --git a/NOTES-SCRATCH.md b/NOTES-SCRATCH.md index d2e7b2c..cdb0f9a 100644 --- a/NOTES-SCRATCH.md +++ b/NOTES-SCRATCH.md @@ -13,4 +13,5 @@ 4. [battery usage Xiao C3](https://wiki.seeedstudio.com/XIAO_ESP32C3_Getting_Started/#battery-usage) * max usable interval 4000ms seems like * 2000ms seems moar stable? idk -# Scratch \ No newline at end of file +# Scratch +normal-10.230-10ms-nousb-ant- \ No newline at end of file diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index 923e2df..7f2b352 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -21,6 +21,13 @@ menu "PrincessPiTracker Config" help Your advertisement key, see https://github.com/leonboe1/GoogleFindMyTools + config DISABLE_USB_WHILE_CHARGING + bool "Disable USB Serial and Broadcasting While Charging" + default y + help + Enable this option to disable USB Serial and Broadcasting while charging to save power. + + config DEVICE_NAME string "BLE Device Name" default "PrincesiPiTracker" diff --git a/main/PrincessPiTracker.c b/main/PrincessPiTracker.c index 5f2df7d..4c7cd75 100644 --- a/main/PrincessPiTracker.c +++ b/main/PrincessPiTracker.c @@ -6,7 +6,11 @@ #include "esp_log.h" // For ESP_LOGI and other logging functions #include "nvs_flash.h" // For NVS functions like nvs_flash_init #include "esp_err.h" // For error handling + +#if CONFIG_DISABLE_USB_WHILE_CHARGING #include "driver/usb_serial_jtag.h" // dis is da heacder fopr usb_serial_jtag_is_connected() +#endif + #if CONFIG_DEEP_SLEEP_BURST_MODE #include "soc/soc_caps.h" // malloc and shit if lmao #include "esp_sleep.h" // For deep sleep functions @@ -262,15 +266,18 @@ void app_main() { // esp32c3, esp32c6, and esp32s3 #if defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32S3) #if CONFIG_DEEP_SLEEP_BURST_MODE - // check if usb is connectedddd - bool usb_connected = usb_serial_jtag_is_connected(); - if (usb_connected) { - ESP_LOGI(TAG, "USB Serial JTAG is connected\nDefaulting to Charging and Flashing Mode"); - return; // exit app_main to prevent BLE initialization - } + + #if CONFIG_DISABLE_USB_WHILE_CHARGING + // check if usb is connectedddd + bool usb_connected = usb_serial_jtag_is_connected(); + if (usb_connected) { + ESP_LOGI(TAG, "USB Serial JTAG is connected\nDefaulting to Charging and Flashing Mode"); + return; // exit app_main to prevent BLE initialization + } + #endif // Initialize sleep wait task - ESP_LOGI(TAG, "Initializing slweep wait task"); + ESP_LOGI(TAG, "Initializing sleep wait task"); xTaskCreate(deep_sleep_wait_to_sleep, "deep_sleep_wait_to_sleep", 4096, NULL, 6, NULL); // INIt timer wakeup