recuperator fan control with esp32
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
esp-recuperator/main/user_main.c

67 lines
1.8 KiB

#include <sdkconfig.h>
#include <console/console.h>
#include <console/console_ioimpl.h>
#include "esp_wifi.h"
#include "esp_event.h"
#include "esp_log.h"
#include "esp_system.h"
#include "nvs_flash.h"
#include "driver/adc.h"
#include "application.h"
#include "settings.h"
#include "console/console_server.h"
#include "wifi_conn.h"
#include "console/register_cmds.h"
#include "irblast.h"
#include "mbiface.h"
#include "actuators.h"
#include "fancontrol.h"
static const char *TAG = "main";
void app_main(void) {
ESP_ERROR_CHECK(nvs_flash_init());
ESP_ERROR_CHECK(esp_register_shutdown_handler(cspemu_run_shutdown_handlers));
ESP_ERROR_CHECK(esp_event_loop_create_default());
settings_init();
settings_load();
// Start IDF service for pin change interrupts
ESP_ERROR_CHECK(gpio_install_isr_service(0));
ESP_LOGD(TAG, "initing netif");
ESP_ERROR_CHECK(esp_netif_init());
if (gSettings.wifi_enabled && (gSettings.sta_enabled || gSettings.ap_enabled)) {
initialise_wifi();
g_State.wifi_inited = true;
} else {
// initialise the bare minimum so wifi config can be changed
ESP_LOGD(TAG, "initing wifi");
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_LOGD(TAG, "set storage, set sta");
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_FLASH));
g_State.wifi_inited = true;
}
console_init(NULL);
register_console_commands();
console_setup_uart_stdio();
ESP_ERROR_CHECK(console_start_stdio(NULL, NULL));
act_init();
mbiface_setup();
fancontrol_init();
telnetsrv_start(CONSOLE_TELNET_PORT);
ESP_LOGI(TAG, "Startup finished, free heap = %u, cmds %"PRIu32, esp_get_free_heap_size(), console_count_commands());
}