main.c 1.6 KB

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