# HG changeset patch # User Michiel Broek # Date 1540237425 -7200 # Node ID e84200edc852b01516a886cda77a8d0c98cc1b05 # Parent 87b86d16b1d688bb2cbe78b055ed735424c575c6 Updated esp-ide. Removed VNC server corre encoding because no clients would use it. Enabled WiFi error logmessages. Write runtime record is now debug logging. Removed recipe.Record number, not usefull and was wrong too. Removed console print of json log data. diff -r 87b86d16b1d6 -r e84200edc852 components/vnc_server/vnc-server.c --- a/components/vnc_server/vnc-server.c Sun Oct 21 23:12:08 2018 +0200 +++ b/components/vnc_server/vnc-server.c Mon Oct 22 21:43:45 2018 +0200 @@ -574,12 +574,6 @@ break; } } - - if (encoding_type.corre) { - ESP_LOGI(TAG, "SetEncodings use CORRE"); - } else { - ESP_LOGI(TAG, "SetEncodings use RAW"); - } break; case FRAME_BUFFER_UPDATE_REQ: @@ -867,15 +861,6 @@ uint16_t x_pos, y_pos; int i, j; int tile_width, tile_height; - int packet_length; - static vnc_color_t tile_buffer[TILE_SIZE][TILE_SIZE]; /* Buffer to hold tile to be encoded */ - vnc_color_t pixel_colour; - vnc_color_t bg_colour; - int no_of_subrects, subrect_width, subrect_height; - int k, l; - - no_of_subrects = 0; /* Set to no sub-rectangles to start with */ - packet_length = 20-4+(Bits_Per_Pixel/8); /* Set to minimum packet length to start with */ /* Get the X and Y positions of this tile from the packet buffer */ x_pos = packet_buffer[0] * 256 + packet_buffer[1]; @@ -885,137 +870,6 @@ tile_width = packet_buffer[4] * 256 + packet_buffer[5]; tile_height = packet_buffer[6] * 256 + packet_buffer[7]; - /* Set the encoding type to RRE */ - if (!encoding_type.corre) { - /* CoRRE encoding is not supported - just use raw encoding */ - goto use_raw_encoding; - } - - /* Set encoding type to CoRRE encoding in packet buffer */ - packet_buffer[8+0] = 0; - packet_buffer[8+1] = 0; - packet_buffer[8+2] = 0; - packet_buffer[8+3] = 4; - - /* Copy tile from the main frame buffer to the local tile buffer */ - for (i = 0; i < tile_height; i++) { - for (j = 0; j < tile_width; j++) { - tile_buffer[i][j] = frame_buffer[y_pos + i][x_pos + j]; - } - } - - /* Find the background colour */ - /* We just assume the (0, 0) pixel in the tile is the bgcolour */ - /* Its quick!!! */ - bg_colour = frame_buffer[y_pos][x_pos]; - - /* Set the background colour in the packet buffer */ - if (Bits_Per_Pixel == 8) { - packet_buffer[16] = PixelConvert(bg_colour); /* (vnc_color_t) bg_colour; */ - } else { - packet_buffer[16] = COLOUR2BYTE0(bg_colour); - packet_buffer[16+1] = COLOUR2BYTE1(bg_colour); - } - -#ifdef CYGNUM_VNC_SERVER_CORRE_ENCODING_HACK - /* Add an initial sub-rectangle to paint the background the background colour */ - /* This is required because of a known bug in the VNC viewer (x86 version) */ -//#if BITS_PER_PIXEL == 8 - packet_buffer[packet_length] = (vnc_color_t) bg_colour; - packet_length++; -//#endif -//#if BITS_PER_PIXEL == 16 -// packet_buffer[packet_length] = packet_buffer[16]; -// packet_buffer[packet_length+1] = packet_buffer[16+1]; -// packet_length += 2; -//#endif - packet_buffer[packet_length] = (uint8_t) 0; /* Sub-rect x-pos */ - packet_buffer[packet_length+1] = (uint8_t) 0; /* Sub-rect y-pos*/ - packet_buffer[packet_length+2] = (uint8_t) tile_width; /* Sub-rect width*/ - packet_buffer[packet_length+3] = (uint8_t) tile_height; /* Sub-rect height*/ - packet_length += 4; - no_of_subrects++; /* Increment sub-rectangle count */ -#endif - - /* Scan trough tile and find sub-rectangles */ - for (i = 0; i < tile_height; i++) { - for (j = 0; j < tile_width; j++) { - if (tile_buffer[i][j] != bg_colour) { - /* This is a non-background pixel */ - subrect_width = 1; - pixel_colour = tile_buffer[i][j]; - - /* Extend the sub-rectangle to its maximum width */ - for (subrect_width = 1; subrect_width <= tile_width-j-1; subrect_width++) { - if (tile_buffer[i][j+subrect_width] != pixel_colour) { - goto got_subrect_width; - } - } - -got_subrect_width: - - /* Extend the sub-rectangle to its maximum height */ - for (subrect_height=1; subrect_height <= tile_height-i-1; subrect_height++) { - for (k = j; k < j+subrect_width; k++) { - if (tile_buffer[i+subrect_height][k] != pixel_colour) { - goto got_subrect_height; - } - } - } - -got_subrect_height: - - /* Delete the pixels for the sub-rectangle from the sub-rectangle */ - for (k = i; k < i+subrect_height; k++) { - for (l = j; l < j+subrect_width; l++) { - tile_buffer[k][l] = bg_colour; - } - } - - /* Append new sub-rectangle data to the packet buffer */ - if (Bits_Per_Pixel == 8) { - packet_buffer[packet_length] = PixelConvert(pixel_colour); // (vnc_color_t) pixel_colour; - packet_length++; - } else { - packet_buffer[packet_length] = COLOUR2BYTE0(pixel_colour); - packet_buffer[packet_length+1] = COLOUR2BYTE1(pixel_colour); - packet_length += 2; - } - - packet_buffer[packet_length] = (uint8_t) j; /* Sub-rect x-pos */ - packet_length++; - - packet_buffer[packet_length] = (uint8_t) i; /* Sub-rect y-pos*/ - packet_length++; - - packet_buffer[packet_length] = (uint8_t) subrect_width; /* Sub-rect width*/ - packet_length++; - - packet_buffer[packet_length] = (uint8_t) subrect_height; /* Sub-rect height*/ - packet_length++; - - no_of_subrects++; /* Increment sub-rectangle count */ - - if (packet_length >= 12 + tile_height*tile_width*(BITS_PER_PIXEL/8) - 6) { - /* The next sub-rectangle will make the packet size */ - /* larger than a rew encoded packet - so just use raw */ - goto use_raw_encoding; - } - } - } - } - - /* Fill in no_of_sub-rectangles field in packet buffer */ - packet_buffer[12+0] = 0; - packet_buffer[12+1] = 0; - packet_buffer[12+2] = no_of_subrects / 256; - packet_buffer[12+3] = no_of_subrects % 256; - - /* CoRRE data encoding for tile complete */ - return packet_length; - -use_raw_encoding: - /* Create packet data using RAW encoding */ for (i = 0; i < tile_height; i++) { for (j = 0; j < tile_width; j++) { diff -r 87b86d16b1d6 -r e84200edc852 main/brewboard.c --- a/main/brewboard.c Sun Oct 21 23:12:08 2018 +0200 +++ b/main/brewboard.c Mon Oct 22 21:43:45 2018 +0200 @@ -129,8 +129,8 @@ xTaskCreate(&task_driver, "task_driver", 2560, NULL, 8, &xTaskDriver); xTaskCreate(&task_sound, "task_sound", 3072, NULL,15, &xTaskSound); xTaskCreate(&task_sdcard, "task_sdcard", 8192, NULL,10, &xTaskSDcard); - /* disable the default wifi logging */ - esp_log_level_set("wifi", ESP_LOG_NONE); + /* lower the wifi logging level */ + esp_log_level_set("wifi", ESP_LOG_ERROR); xTaskCreate(&task_wifi, "task_wifi", 4096, NULL, 3, &xTaskWifi); // Task for MQTT TFT_print(" Ok\r\nConnecting ", LASTX, LASTY); diff -r 87b86d16b1d6 -r e84200edc852 main/config.c --- a/main/config.c Sun Oct 21 23:12:08 2018 +0200 +++ b/main/config.c Mon Oct 22 21:43:45 2018 +0200 @@ -267,7 +267,6 @@ if (strcmp(wifiStation.SSID, (char *)SSID) == 0) { // Fount it fclose(f); -// ESP_LOGI(TAG, "read_station %s record %d", (char *)SSID, rc); return rc; } rc++; @@ -336,7 +335,7 @@ size_t bytes = fwrite(dst, 1, sizeof(runtime), f); fclose(f); - ESP_LOGI(TAG, "/spiffs/etc/runtime.conf written %d bytes", bytes); + ESP_LOGD(TAG, "/spiffs/etc/runtime.conf written %d bytes", bytes); } @@ -420,11 +419,10 @@ FILE *f = fopen("/spiffs/etc/recipe.conf", "r"); if (f == NULL) { - // No runtime yet, create it. + // No recipe yet, create it. dst = (uint8_t*)&recipe; memset(dst, 0, sizeof(recipe)); recipe.Version = 1; - recipe.Record = 1; sprintf(recipe.Name, "Recipe 1"); sprintf(recipe.Code, "001"); sprintf(recipe.MashStep[0].Name, "Mash-in"); @@ -464,7 +462,7 @@ void delete_recipe(int RecNo) { - int RecNow = 1; + int RecRead = 1, RecWrite = 1; FILE *n, *o; uint8_t *dst; size_t bytes; @@ -487,20 +485,17 @@ if (bytes == 0) break; - if (recipe.Record == RecNo) { - // Record to delete, don't copy - printf("Ditch %d\n", RecNo); - } else { - if ((config.RecipeRec == recipe.Record) && (config.RecipeRec != RecNow)) { + if (RecRead != RecNo) { + // Record to copy + if ((config.RecipeRec == RecRead) && (config.RecipeRec != RecWrite)) { // We need to change the default record. - config.RecipeRec = RecNow; + config.RecipeRec = RecWrite; write_config(); } - printf("Copy %d to %d\n", recipe.Record, RecNow); - recipe.Record = RecNow; fwrite(dst, 1, sizeof(recipe), n); - RecNow++; + RecWrite++; } + RecRead++; } fclose(o); fclose(n); @@ -508,6 +503,7 @@ rename("/spiffs/etc/recipe.conf", "/spiffs/etc/recipe.old"); rename("/spiffs/etc/recipe.new", "/spiffs/etc/recipe.conf"); unlink("/spiffs/etc/recipe.old"); + ESP_LOGI(TAG, "Deleted recipe %d", RecNo); } diff -r 87b86d16b1d6 -r e84200edc852 main/config.h --- a/main/config.h Sun Oct 21 23:12:08 2018 +0200 +++ b/main/config.h Mon Oct 22 21:43:45 2018 +0200 @@ -362,7 +362,7 @@ */ struct strRecipe { uint8_t Version; ///< Record version number. - int Record; ///< Record number + int o_Record; ///< Record number, obsolete. char Name[128]; ///< Recipe name. char Code[32]; ///< Recipe code. mashstep_t MashStep[8]; ///< Mash steps. diff -r 87b86d16b1d6 -r e84200edc852 main/recipes.c --- a/main/recipes.c Sun Oct 21 23:12:08 2018 +0200 +++ b/main/recipes.c Mon Oct 22 21:43:45 2018 +0200 @@ -497,7 +497,7 @@ TFT_setFont(DEFAULT_FONT, NULL); ShowText(2, 28, "Naam", recipe.Name); ShowText(2, 44, "Code", recipe.Code); - ShowInteger(162, 44, "Record", NULL, recipe.Record); + ShowInteger(162, 44, "Record", NULL, r_CurrentRec); ShowInteger(2, 60, "Kooktijd", " min", recipe.BoilTime); ShowFloat(162, 60, "Koel tot", " C", recipe.CoolTemp, 2); ShowFloat(2, 76, "Maisch in", " C", recipe.MashStep[0].Temperature, 2); @@ -580,7 +580,6 @@ case 1: memset(&recipe, 0, sizeof(recipe)); recipe.Version = 1; - recipe.Record = r_Records + 1; sprintf(recipe.Name, "Recipe %d", r_Records + 1); sprintf(recipe.Code, "00%d", r_Records + 1); sprintf(recipe.MashStep[0].Name, "Mash-in"); @@ -610,7 +609,7 @@ r_Records++; r_CurrentRec = r_Records; r_UpdateRec = true; - ESP_LOGI(TAG, "New recipe record %d", recipe.Record); + ESP_LOGI(TAG, "New recipe record %d", r_CurrentRec); break; case 2: if ((r_CurrentRec != config.RecipeRec) && (r_Records > 1)) { @@ -719,7 +718,7 @@ crc2 = crc32_le(0, dst, sizeof(recipe)); if ((crc1 != crc2) && Confirm("Gewijzigd, opslaan?", "Ja", "Nee")) { - write_recipe(recipe.Record); + write_recipe(r_CurrentRec); } Main_Screen = MAIN_TOOLS_RECIPE; break; diff -r 87b86d16b1d6 -r e84200edc852 main/task_sdcard.c --- a/main/task_sdcard.c Sun Oct 21 23:12:08 2018 +0200 +++ b/main/task_sdcard.c Mon Oct 22 21:43:45 2018 +0200 @@ -130,12 +130,12 @@ fprintf(f, "\"HLT_sp\":\"%.3f\",\"HLT_pv\":\"%.3f\",\"HLT_pwm\":\"%d\",", json_log->hlt_sp, json_log->hlt_pv, json_log->hlt_power); } fprintf(f, "\"Label\":\"%s\"}", json_log->time); - printf("{\"MLT_sp\":\"%.3f\",\"MLT_pv\":\"%.3f\",\"MLT_pwm\":\"%d\",\"MLT_tr\":\"%d\",\"Pump\":\"%d\",", - json_log->mlt_sp, json_log->mlt_pv, json_log->mlt_power, json_log->mlt_tempreached, json_log->pump_run); - if (json_log->hlt_sp > 0.0) { - printf("\"HLT_sp\":\"%.3f\",\"HLT_pv\":\"%.3f\",\"HLT_pwm\":\"%d\",", json_log->hlt_sp, json_log->hlt_pv, json_log->hlt_power); - } - printf("\"Label\":\"%s\"}\n", json_log->time); +// printf("{\"MLT_sp\":\"%.3f\",\"MLT_pv\":\"%.3f\",\"MLT_pwm\":\"%d\",\"MLT_tr\":\"%d\",\"Pump\":\"%d\",", +// json_log->mlt_sp, json_log->mlt_pv, json_log->mlt_power, json_log->mlt_tempreached, json_log->pump_run); +// if (json_log->hlt_sp > 0.0) { +// printf("\"HLT_sp\":\"%.3f\",\"HLT_pv\":\"%.3f\",\"HLT_pwm\":\"%d\",", json_log->hlt_sp, json_log->hlt_pv, json_log->hlt_power); +// } +// printf("\"Label\":\"%s\"}\n", json_log->time); fclose(f); } } @@ -186,7 +186,6 @@ addcomma = true; fprintf(f, "{\"type\":\"line\",\"mode\":\"vertical\",\"scaleID\":\"x-axis-0\",\"value\":\"%s\",\"borderColor\":\"%s\",\"borderWidth\":2,\"label\":{\"backgroundColor\":\"%s\",\"content\":\"%s\",\"position\":\"%s\",\"enabled\":true}}", json_log->time, bordercolor, color, label, pos); fclose(f); - printf( "{\"type\":\"line\",\"mode\":\"vertical\",\"scaleID\":\"x-axis-0\",\"value\":\"%s\",\"borderColor\":\"%s\",\"borderWidth\":2,\"label\":{\"backgroundColor\":\"%s\",\"content\":\"%s\",\"position\":\"%s\",\"enabled\":true}}\n", json_log->time, bordercolor, color, label, pos); } } } diff -r 87b86d16b1d6 -r e84200edc852 sdkconfig --- a/sdkconfig Sun Oct 21 23:12:08 2018 +0200 +++ b/sdkconfig Mon Oct 22 21:43:45 2018 +0200 @@ -332,6 +332,25 @@ CONFIG_FATFS_PER_FILE_CACHE=y # +# Modbus configuration +# +CONFIG_MB_UART_RXD=22 +CONFIG_MB_UART_TXD=23 +CONFIG_MB_UART_RTS=18 +CONFIG_MB_QUEUE_LENGTH=20 +CONFIG_MB_SERIAL_TASK_STACK_SIZE=2048 +CONFIG_MB_SERIAL_BUF_SIZE=256 +CONFIG_MB_SERIAL_TASK_PRIO=10 +CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT= +CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT=20 +CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE=20 +CONFIG_MB_CONTROLLER_STACK_SIZE=4096 +CONFIG_MB_EVENT_QUEUE_TIMEOUT=20 +CONFIG_MB_TIMER_PORT_ENABLED=y +CONFIG_MB_TIMER_GROUP=0 +CONFIG_MB_TIMER_INDEX=0 + +# # FreeRTOS # CONFIG_FREERTOS_UNICORE=