Sat, 06 Jun 2020 13:28:46 +0200
Changed the recipe database so that it is expandable, version 2. More mash fields and allow 16 steps. Allow 20 Additions. Removed separate mash steps from the state machine, the steps are moved to the runtime data. There is no fixed step number for mashout anymore. There is no fixed step for mash-in anymore, just use the first step and heat to the infusion temperature. After malt add, switch to the normal step temperature. Implemented decoction steps.
/* BrewVoard */ #include "config.h" static const char *TAG = "brewboard"; static TaskHandle_t xTaskTFT = NULL; static TaskHandle_t xTaskDS18B20 = NULL; static TaskHandle_t xTaskDriver = NULL; static TaskHandle_t xTaskSound = NULL; static TaskHandle_t xTaskSDcard = NULL; static TaskHandle_t xTaskWifi = NULL; extern SemaphoreHandle_t xSemaphoreDS18B20; extern SemaphoreHandle_t xSemaphoreDriver; extern SemaphoreHandle_t xSemaphoreWiFi; extern WIFI_State *wifi_state; int Main_Screen = MAIN_MODE_UNKNOWN; ///< Screen number int Old_Screen = MAIN_MODE_UNKNOWN; ///< Previous screen number int Sub_Screen = 0; ///< Subscreen during mash bool System_TimeOk = false; ///< System time status const esp_app_desc_t *app_desc = NULL; void app_main() { int tempy; char temp[64]; ESP_LOGI(TAG, "Starting"); init_tft_display(); TFT_setFont(DEJAVU24_FONT, NULL); _fg = TFT_YELLOW; tempy = TFT_getfontheight() + 4; app_desc = esp_ota_get_app_description(); sprintf(temp, "BrewBoard %s", app_desc->version); TFT_print(temp, CENTER, 4); TFT_setFont(DEJAVU18_FONT, NULL); _fg = TFT_CYAN; TFT_print((char *)"Mount /spiffs ", 0, LASTY+tempy); ESP_LOGI(TAG, "Initializing SPIFFS"); esp_vfs_spiffs_conf_t conf = { .base_path = "/spiffs", .partition_label = NULL, .max_files = 5, .format_if_mount_failed = true }; // Use settings defined above to initialize and mount SPIFFS filesystem. // Note: esp_vfs_spiffs_register is an all-in-one convenience function. esp_err_t ret = esp_vfs_spiffs_register(&conf); if (ret != ESP_OK) { if (ret == ESP_FAIL) { ESP_LOGE(TAG, "Failed to mount or format filesystem"); } else if (ret == ESP_ERR_NOT_FOUND) { ESP_LOGE(TAG, "Failed to find SPIFFS partition"); } else { ESP_LOGE(TAG, "Failed to initialize SPIFFS (%d)", ret); } _fg = TFT_RED; TFT_print((char *)"error\r\n", LASTX, LASTY); return; // Stop application. } size_t total = 0, used = 0; ret = esp_spiffs_info(NULL, &total, &used); if (ret != ESP_OK) { ESP_LOGE(TAG, "Failed to get SPIFFS partition information"); _fg = TFT_RED; TFT_print((char *)"error\r\n", LASTX, LASTY); return; // Stop application. } else { ESP_LOGI(TAG, "Partition size: %d, used: %d - %d%%", total, used, (used * 100) / total); } TFT_print((char *)"Ok\r\n", LASTX, LASTY); // Just to debug, list the /spiffs filesystem. #if 1 DIR *dir = opendir("/spiffs"); struct dirent* de = readdir(dir); while (de) { if (de->d_type == DT_REG) { printf("F "); } if (de->d_type == DT_DIR) { printf("D "); } printf("%s\n", de->d_name); de = readdir(dir); } closedir(dir); #endif /* * Read or create configuration */ TFT_print((char *)"Ophalen configuratie ", LASTX, LASTY); read_config(); read_equipment(config.EquipmentRec); read_runtime(); read_recipe(config.RecipeRec); TFT_print((char *)"Ok\r\n", LASTX, LASTY); // Set the Touchscreen calibration/ TS_set_calibration(config.ts_xleft, config.ts_xright, config.ts_ytop, config.ts_ybottom); /* * TZ names don't work, so set the TZ the hard way. * This is the setting for Europe/Amsterdam. */ setenv("TZ", "CET-01CEST-02,M3.4.0,M10.4.0", 1); tzset(); xSemaphoreDS18B20 = xSemaphoreCreateMutex(); xSemaphoreDriver = xSemaphoreCreateMutex(); TFT_print((char *)"Starten taken ", LASTX, LASTY); xTaskCreate(&task_tft, "task_tft", 6144, NULL, 4, &xTaskTFT); vTaskDelay(400 / portTICK_PERIOD_MS); xTaskCreate(&task_ds18b20, "task_ds18b20", 2560, NULL, 8, &xTaskDS18B20); xTaskCreate(&task_driver, "task_driver", 2560, NULL, 8, &xTaskDriver); xTaskCreate(&task_sound, "task_sound", 2048, NULL,15, &xTaskSound); xTaskCreate(&task_sdcard, "task_sdcard", 8192, NULL,10, &xTaskSDcard); /* lower the wifi logging level */ esp_log_level_set("wifi", ESP_LOG_ERROR); xTaskCreate(&task_wifi, "task_wifi", 4096, NULL, 3, &xTaskWifi); TFT_print((char *)" Ok\r\nConnecting ", LASTX, LASTY); int wait = 20; while (wait) { vTaskDelay(750 / portTICK_PERIOD_MS); TFT_print((char *)".", LASTX, LASTY); if (xSemaphoreTake(xSemaphoreWiFi, 25) == pdTRUE) { if (wifi_state->STA_connected == true) wait = 0; else wait--; xSemaphoreGive(xSemaphoreWiFi); } } TFT_print((char *)" Ok\r\n", LASTX, LASTY); SoundPlay(SOUND_StartUp); start_http_websocket(); vTaskDelay(1000 / portTICK_PERIOD_MS); Main_Screen = MAIN_MODE_FREE; // static char cBuffer[ 1024 ]; /* * Main application loop. */ while (1) { vTaskDelay(20000 / portTICK_PERIOD_MS); // vTaskList( cBuffer ); // printf("Name State Prio Stack Num\n"); // printf("--------------- ------- ------- ------- -------\n"); // printf("%s\n", cBuffer); } // Not reached. }