modified: firmware/main/include/leds.h
modified: firmware/main/include/wifi.h modified: firmware/main/src/leds.c modified: firmware/main/src/main.c modified: firmware/main/src/wifi.c modified: firmware/sdkconfig Enhance power management and disable wifi temporarily for temp testing
This commit is contained in:
1 parent
6ceb9ed7af
commit
2f48a98556
6 files changed
+66
-27
No files matched your search
+24
-18
@@ -19,14 +19,14 @@ void led_blink_task(void *pvParameter)
|
||||
// Blink the LEDs
|
||||
gpio_set_level(LED1, 0);
|
||||
gpio_set_level(LED2, 0);
|
||||
gpio_set_level(LED_INT, 1);
|
||||
//gpio_set_level(LED_INT, 1);
|
||||
vTaskDelay(800 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(LED1, 1);
|
||||
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(LED2, 1);
|
||||
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(LED1, 0);
|
||||
gpio_set_level(LED_INT, 0);
|
||||
//gpio_set_level(LED_INT, 0);
|
||||
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(LED2, 0);
|
||||
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||
@@ -40,39 +40,45 @@ esp_err_t led_init() {
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void led0_toggle() {
|
||||
gpio_set_level(LED_INT, gpio_get_level(LED_INT));
|
||||
//ESP_LOGI(TAG, "LED 3 turned on");
|
||||
}
|
||||
|
||||
void led0_on() {
|
||||
gpio_set_level(LED_INT, 0);
|
||||
//ESP_LOGI(TAG, "LED 3 turned on");
|
||||
}
|
||||
|
||||
void led1_on() {
|
||||
gpio_set_level(LED1, 1);
|
||||
ESP_LOGI(TAG, "LED 1 turned on");
|
||||
//ESP_LOGI(TAG, "LED 1 turned on");
|
||||
}
|
||||
|
||||
void led2_on() {
|
||||
gpio_set_level(LED2, 1);
|
||||
ESP_LOGI(TAG, "LED 2 turned on");
|
||||
}
|
||||
|
||||
void led3_on() {
|
||||
gpio_set_level(LED_INT, 0);
|
||||
ESP_LOGI(TAG, "LED 3 turned on");
|
||||
//ESP_LOGI(TAG, "LED 2 turned on");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void led0_off()
|
||||
{
|
||||
gpio_set_level(LED_INT, 1);
|
||||
//ESP_LOGI(TAG, "LED 3 turned off");
|
||||
}
|
||||
|
||||
void led1_off()
|
||||
{
|
||||
gpio_set_level(LED1, 0);
|
||||
ESP_LOGI(TAG, "LED 1 turned off");
|
||||
//ESP_LOGI(TAG, "LED 1 turned off");
|
||||
}
|
||||
|
||||
void led2_off()
|
||||
{
|
||||
gpio_set_level(LED2, 0);
|
||||
ESP_LOGI(TAG, "LED 2 turned off");
|
||||
//ESP_LOGI(TAG, "LED 2 turned off");
|
||||
}
|
||||
|
||||
void led3_off()
|
||||
{
|
||||
gpio_set_level(LED_INT, 1);
|
||||
ESP_LOGI(TAG, "LED 3 turned off");
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <freertos/task.h>
|
||||
#include <nvs_flash.h>
|
||||
#include <esp_system.h>
|
||||
#include <esp_sleep.h>
|
||||
//#include <esp_log.h>
|
||||
//#include <esp_event_loop.h>
|
||||
#include <esp_err.h>
|
||||
@@ -16,16 +17,27 @@
|
||||
|
||||
static const char * TAG = "main.c";
|
||||
|
||||
void vApplicationIdleHook(void) {
|
||||
//led0_toggle();
|
||||
led0_off();
|
||||
esp_light_sleep_start();
|
||||
//wifi_sleep();
|
||||
led0_on();
|
||||
}
|
||||
|
||||
void app_main()
|
||||
{
|
||||
ESP_ERROR_CHECK(nvs_flash_init());
|
||||
ESP_ERROR_CHECK(led_init());
|
||||
ESP_ERROR_CHECK(wifi_init());
|
||||
ESP_ERROR_CHECK(uart_init());
|
||||
//ESP_ERROR_CHECK(wifi_init());
|
||||
//ESP_ERROR_CHECK(uart_init());
|
||||
ESP_ERROR_CHECK(controller_init());
|
||||
|
||||
led0_on();
|
||||
|
||||
xTaskCreate(led_blink_task, "led_blink_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
|
||||
xTaskCreate(uart_read_task, "uart_read_task", 2048, NULL, 10, NULL);
|
||||
//xTaskCreate(uart_read_task, "uart_read_task", 2048, NULL, 10, NULL);
|
||||
xTaskCreate(sht31_sensor_test_task, "sht31_sensor_test_task", 2048, NULL, 10, NULL);
|
||||
|
||||
//vTaskStartScheduler();
|
||||
}
|
||||
@@ -9,20 +9,36 @@
|
||||
esp_err_t wifi_init(void) {
|
||||
tcpip_adapter_init();
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
|
||||
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
|
||||
|
||||
wifi_config_t sta_config = {
|
||||
.sta = {
|
||||
.ssid = CONFIG_ESP_WIFI_SSID,
|
||||
.password = CONFIG_ESP_WIFI_PASSWORD,
|
||||
},
|
||||
};
|
||||
|
||||
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &sta_config));
|
||||
ESP_ERROR_CHECK(esp_wifi_start());
|
||||
ESP_ERROR_CHECK(esp_wifi_connect());
|
||||
|
||||
// Enable power saving
|
||||
ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_MIN_MODEM));
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
esp_err_t wifi_sleep() {
|
||||
/*
|
||||
// Enter light sleep mode
|
||||
wifi_fpm_open(); // Enable modem sleep
|
||||
wifi_fpm_do_sleep(0xFFFFFFF); // Enter sleep mode indefinitely
|
||||
// The system will wake up when an interrupt occurs
|
||||
wifi_fpm_close(); // Close modem sleep mode after waking up
|
||||
*/
|
||||
return ESP_OK;
|
||||
}
|
||||
Reference in new issue
Block a user