addedd disable usb and broadcasting during charging/usb option

This commit is contained in:
2025-11-29 13:55:50 -07:00
parent b018bbd516
commit f68889e72e
3 changed files with 23 additions and 8 deletions
+7
View File
@@ -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"
+14 -7
View File
@@ -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