main.c 1.6 KB

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