main/brewboard.c

branch
idf 5.1
changeset 129
31f9d3e4a85f
parent 119
1cef3c25426b
equal deleted inserted replaced
128:64886971967b 129:31f9d3e4a85f
17 extern SemaphoreHandle_t xSemaphoreDS18B20; 17 extern SemaphoreHandle_t xSemaphoreDS18B20;
18 extern SemaphoreHandle_t xSemaphoreDriver; 18 extern SemaphoreHandle_t xSemaphoreDriver;
19 extern SemaphoreHandle_t xSemaphoreWiFi; 19 extern SemaphoreHandle_t xSemaphoreWiFi;
20 extern WIFI_State *wifi_state; 20 extern WIFI_State *wifi_state;
21 21
22 extern my_config_t config;
23
24
22 int Main_Screen = MAIN_MODE_UNKNOWN; ///< Screen number 25 int Main_Screen = MAIN_MODE_UNKNOWN; ///< Screen number
23 int Old_Screen = MAIN_MODE_UNKNOWN; ///< Previous screen number 26 int Old_Screen = MAIN_MODE_UNKNOWN; ///< Previous screen number
24 int Sub_Screen = 0; ///< Subscreen during mash 27 int Sub_Screen = 0; ///< Subscreen during mash
25 bool System_TimeOk = false; ///< System time status 28 bool System_TimeOk = false; ///< System time status
26 const esp_app_desc_t *app_desc = NULL; 29 const esp_app_desc_t *app_desc = NULL;
28 31
29 void app_main() 32 void app_main()
30 { 33 {
31 int tempy; 34 int tempy;
32 char temp[64]; 35 char temp[64];
36 esp_err_t ret;
33 37
34 ESP_LOGI(TAG, "Starting"); 38 ESP_LOGI(TAG, "Starting");
35 init_tft_display(); 39 init_tft_display();
36 40
37 TFT_setFont(DEJAVU24_FONT, NULL); 41 TFT_setFont(DEJAVU24_FONT, NULL);
38 _fg = TFT_YELLOW; 42 _fg = TFT_YELLOW;
39 tempy = TFT_getfontheight() + 4; 43 tempy = TFT_getfontheight() + 4;
40 app_desc = esp_ota_get_app_description(); 44 app_desc = esp_app_get_description();
41 sprintf(temp, "BrewBoard %s", app_desc->version); 45 sprintf(temp, "BrewBoard %s", app_desc->version);
42 TFT_print(temp, CENTER, 4); 46 TFT_print(temp, CENTER, 4);
47
48 /*
49 * Initialize NVS
50 */
51 ret = nvs_flash_init();
52 if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
53 ESP_ERROR_CHECK(nvs_flash_erase());
54 ret = nvs_flash_init();
55 }
56 ESP_ERROR_CHECK(ret);
43 57
44 TFT_setFont(DEJAVU18_FONT, NULL); 58 TFT_setFont(DEJAVU18_FONT, NULL);
45 _fg = TFT_CYAN; 59 _fg = TFT_CYAN;
46 TFT_print((char *)"Mount /spiffs ", 0, LASTY+tempy); 60 TFT_print((char *)"Mount /spiffs ", 0, LASTY+tempy);
47 ESP_LOGD(TAG, "Initializing SPIFFS"); 61 ESP_LOGD(TAG, "Initializing SPIFFS");
50 .base_path = "/spiffs", 64 .base_path = "/spiffs",
51 .partition_label = NULL, 65 .partition_label = NULL,
52 .max_files = 5, 66 .max_files = 5,
53 .format_if_mount_failed = true 67 .format_if_mount_failed = true
54 }; 68 };
55 69
56 // Use settings defined above to initialize and mount SPIFFS filesystem. 70 /*
57 // Note: esp_vfs_spiffs_register is an all-in-one convenience function. 71 * Use settings defined above to initialize and mount SPIFFS filesystem.
58 esp_err_t ret = esp_vfs_spiffs_register(&conf); 72 * Note: esp_vfs_spiffs_register is an all-in-one convenience function.
73 */
74 ret = esp_vfs_spiffs_register(&conf);
59 75
60 if (ret != ESP_OK) { 76 if (ret != ESP_OK) {
61 if (ret == ESP_FAIL) { 77 if (ret == ESP_FAIL) {
62 ESP_LOGE(TAG, "Failed to mount or format filesystem"); 78 ESP_LOGE(TAG, "Failed to mount or format filesystem");
63 } else if (ret == ESP_ERR_NOT_FOUND) { 79 } else if (ret == ESP_ERR_NOT_FOUND) {

mercurial