main.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include <stdio.h>
  2. #include <nvs_flash.h>
  3. #include <esp_netif.h>
  4. #include "freertos/FreeRTOS.h"
  5. #include "freertos/task.h"
  6. #include "esp_log.h"
  7. #include "lcd_st7701.h"
  8. #include "gui_guider.h"
  9. #include "beep.h"
  10. lv_ui guider_ui;
  11. void app_main()
  12. {
  13. // 初始化NVS
  14. esp_err_t err = nvs_flash_init(); //nvs初始化
  15. if (err == ESP_ERR_NVS_NO_FREE_PAGES) {
  16. ESP_ERROR_CHECK(nvs_flash_erase()); //擦除nvs
  17. nvs_flash_init(); //重新初始化
  18. }
  19. ESP_ERROR_CHECK(esp_netif_init());
  20. //read_system_setting(&system_setting); // 读取nvs中存储的系统设置
  21. // 空调逻辑控制器初始化
  22. //ac_controller_init(&system_setting);
  23. // iotx_event_regist_cb(&iot_event_monitor); // 注册网关事件
  24. beep_init(); // 蜂鸣器初始化
  25. ESP_ERROR_CHECK(lcd_st7701_init());
  26. // 如果上次为熄屏状态
  27. // uint8_t *s_on_off = nvs_get_uint8(NVS_SCREEN_ON_OFF);
  28. // if (s_on_off != NULL) {
  29. // if (*s_on_off == 1) {
  30. // ESP_ERROR_CHECK(lcd_st7701_backlight_off()); // 关闭背光
  31. // } else {
  32. ESP_ERROR_CHECK(lcd_st7701_backlight_on());
  33. // }
  34. // } else {
  35. // ESP_ERROR_CHECK(lcd_st7701_backlight_on());
  36. // }
  37. setup_ui(&guider_ui); // 初始化UI
  38. //app_wifi_init(on_wifi_connected);
  39. // sht30_init(); // 初始化温湿度传感器
  40. // 初始化OTA功能
  41. //ota_init();
  42. // 熄屏定时器初始化
  43. //screen_off_timer_init(&system_setting);
  44. for (;;) {
  45. vTaskDelay(10 / portTICK_PERIOD_MS);
  46. }
  47. }