addedd disable usb and broadcasting during charging/usb option
This commit is contained in:
+2
-1
@@ -13,4 +13,5 @@
|
|||||||
4. [battery usage Xiao C3](https://wiki.seeedstudio.com/XIAO_ESP32C3_Getting_Started/#battery-usage)
|
4. [battery usage Xiao C3](https://wiki.seeedstudio.com/XIAO_ESP32C3_Getting_Started/#battery-usage)
|
||||||
* max usable interval 4000ms seems like
|
* max usable interval 4000ms seems like
|
||||||
* 2000ms seems moar stable? idk
|
* 2000ms seems moar stable? idk
|
||||||
# Scratch
|
# Scratch
|
||||||
|
normal-10.230-10ms-nousb-ant-
|
||||||
@@ -21,6 +21,13 @@ menu "PrincessPiTracker Config"
|
|||||||
help
|
help
|
||||||
Your advertisement key, see https://github.com/leonboe1/GoogleFindMyTools
|
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
|
config DEVICE_NAME
|
||||||
string "BLE Device Name"
|
string "BLE Device Name"
|
||||||
default "PrincesiPiTracker"
|
default "PrincesiPiTracker"
|
||||||
|
|||||||
@@ -6,7 +6,11 @@
|
|||||||
#include "esp_log.h" // For ESP_LOGI and other logging functions
|
#include "esp_log.h" // For ESP_LOGI and other logging functions
|
||||||
#include "nvs_flash.h" // For NVS functions like nvs_flash_init
|
#include "nvs_flash.h" // For NVS functions like nvs_flash_init
|
||||||
#include "esp_err.h" // For error handling
|
#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()
|
#include "driver/usb_serial_jtag.h" // dis is da heacder fopr usb_serial_jtag_is_connected()
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CONFIG_DEEP_SLEEP_BURST_MODE
|
#if CONFIG_DEEP_SLEEP_BURST_MODE
|
||||||
#include "soc/soc_caps.h" // malloc and shit if lmao
|
#include "soc/soc_caps.h" // malloc and shit if lmao
|
||||||
#include "esp_sleep.h" // For deep sleep functions
|
#include "esp_sleep.h" // For deep sleep functions
|
||||||
@@ -262,15 +266,18 @@ void app_main() {
|
|||||||
// esp32c3, esp32c6, and esp32s3
|
// esp32c3, esp32c6, and esp32s3
|
||||||
#if defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32S3)
|
#if defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||||
#if CONFIG_DEEP_SLEEP_BURST_MODE
|
#if CONFIG_DEEP_SLEEP_BURST_MODE
|
||||||
// check if usb is connectedddd
|
|
||||||
bool usb_connected = usb_serial_jtag_is_connected();
|
#if CONFIG_DISABLE_USB_WHILE_CHARGING
|
||||||
if (usb_connected) {
|
// check if usb is connectedddd
|
||||||
ESP_LOGI(TAG, "USB Serial JTAG is connected\nDefaulting to Charging and Flashing Mode");
|
bool usb_connected = usb_serial_jtag_is_connected();
|
||||||
return; // exit app_main to prevent BLE initialization
|
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
|
// 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);
|
xTaskCreate(deep_sleep_wait_to_sleep, "deep_sleep_wait_to_sleep", 4096, NULL, 6, NULL);
|
||||||
|
|
||||||
// INIt timer wakeup
|
// INIt timer wakeup
|
||||||
|
|||||||
Reference in New Issue
Block a user