diff -r 1625e565ca31 -r aaa095986ede main/task_tft.c --- a/main/task_tft.c Thu May 02 11:52:36 2019 +0200 +++ b/main/task_tft.c Wed May 08 15:46:50 2019 +0200 @@ -13,8 +13,9 @@ spi_lobo_device_handle_t tsspi = NULL; ///< Touchscreen SPI handler extern sButton Buttons[MAXBUTTONS]; ///< 40 buttons on a screen. time_t now; ///< Current time +time_t last = 0; ///< Last time struct tm timeinfo; ///< Current time structure -char s_timer[10]; ///< Timer sctring buffer +char s_timer[10]; ///< Timer string buffer char s_top_msg[64]; ///< Top message string buffer extern float stageTemp; @@ -30,12 +31,14 @@ extern bool _NewMinute; extern bool _UseHLT; extern bool System_TimeOk; +extern const esp_app_desc_t *app_desc; static const char *TAG = "task_tft"; #define SPI_BUS TFT_HSPI_HOST ///< SPI bus for the TFT, TFT_VSPI_HOST or TFT_HSPI_HOST extern int Main_Screen; +extern int Sub_Screen; extern int Old_Screen; extern int MLT_pin; extern int HLT_pin; @@ -470,10 +473,10 @@ hlt_sp[0] = '\0'; hlt_power[0] = '\0'; } - snprintf(msg, 1023, "{\"main\":\"%d\",\"mlt_led\":\"%d\",\"mlt_pv\":\"%7.3f\",\"mlt_sp\":\"%s\",\"mlt_power\":\"%s\"" \ + snprintf(msg, 1023, "{\"main\":\"%d\",\"sub\":\"%d\",\"mlt_led\":\"%d\",\"mlt_pv\":\"%7.3f\",\"mlt_sp\":\"%s\",\"mlt_power\":\"%s\"" \ ",\"pump_led\":\"%d\",\"hlt_led\":\"%d\",\"hlt_pv\":\"%7.3f\",\"hlt_sp\":\"%s\",\"hlt_power\":\"%s\"" \ ",\"timer\":\"%s\",\"top_msg\":\"%s\"}", - Main_Screen, (MLT_pin) ? 1:0, driver_state->mlt_pv, mlt_sp, mlt_power, + Main_Screen, Sub_Screen, (MLT_pin) ? 1:0, driver_state->mlt_pv, mlt_sp, mlt_power, (Pump_pin) ? 1:0, (HLT_pin) ? 1:0, driver_state->hlt_pv, hlt_sp, hlt_power, s_timer, s_top_msg); @@ -487,7 +490,7 @@ void task_tft(void *pvParameter) { - char msg[32]; + char msg[64]; ESP_LOGI(TAG, "Initialize TFT/Touch task"); @@ -528,7 +531,8 @@ /* * With each screenchange, remove the timer too. */ - snprintf(msg, 31, "{\"main\":\"%d\",\"timer\":\"\"}", Main_Screen); + Sub_Screen = 0; + snprintf(msg, 63, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"\"}", Main_Screen, Sub_Screen); ws_server_send_text_clients("/ws", msg, strlen(msg)); ESP_LOGI(TAG, "Change screen %d to %d", Old_Screen, Main_Screen); @@ -557,7 +561,7 @@ break; case MAIN_INFO: - sprintf(temp_buf, "BrewBoard %s", VERSION); + sprintf(temp_buf, "BrewBoard %s", app_desc->version); TopMessage(temp_buf); _fg = TFT_YELLOW; TFT_setFont(UBUNTU16_FONT, NULL); @@ -565,7 +569,7 @@ // ------------------------------------- _fg = TFT_ORANGE; TFT_print("Parts are written by Chris Morgan,\r\n", 0, LASTY); - TFT_print("Brett Beauregard, Chris Garry, LoBo,\r\n", 0, LASTY); + TFT_print("Brett Beauregard, Blake Felt, LoBo,\r\n", 0, LASTY); TFT_print("and David Antliff.\r\n", 0, LASTY); ShowInteger(1,140, "Free memory", " bytes", esp_get_free_heap_size()); ShowText(1,158, "IDF version", (char *)esp_get_idf_version()); @@ -618,7 +622,8 @@ Updates_Init(); break; - case MAIN_AUTO_INIT: + case MAIN_AUTO_INIT1: + case MAIN_AUTO_INIT2: case MAIN_AUTO_DELAYSTART: case MAIN_AUTO_HEATUP: case MAIN_AUTO_MASH_IN: @@ -666,17 +671,20 @@ } switch (Buttons_Scan()) { case 0: Main_Screen = MAIN_MANUAL_INIT; break; - case 1: Main_Screen = MAIN_AUTO_INIT; break; - case 2: Main_Screen = MAIN_INFO; break; - case 3: Main_Screen = MAIN_TOOLS; break; + case 1: Main_Screen = MAIN_AUTO_INIT1; break; + case 2: Main_Screen = MAIN_INFO; break; + case 3: Main_Screen = MAIN_TOOLS; break; default: break; } - if (System_TimeOk) { + if (System_TimeOk && (now != last)) { + last = now; strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo); TFT_setFont(DEJAVU18_FONT, NULL); _bg = TFT_BLACK; _fg = TFT_ORANGE; TFT_print(strftime_buf, CENTER, 125); + snprintf(msg, 63, "{\"timer\":\"%s\"}", strftime_buf); // Fix string termination and only send once/second. + ws_server_send_text_clients("/ws", msg, strlen(msg)); } break; @@ -735,7 +743,8 @@ } break; - case MAIN_AUTO_INIT: + case MAIN_AUTO_INIT1: + case MAIN_AUTO_INIT2: case MAIN_AUTO_DELAYSTART: case MAIN_AUTO_HEATUP: case MAIN_AUTO_MASH_IN: