From 6fbc6983c45ecf2338f3288af60163d9f8dd1282 Mon Sep 17 00:00:00 2001 From: Obe Van Lierde Date: Mon, 20 Nov 2023 15:44:47 +0100 Subject: [PATCH] updatet clears --- project/Core/Src/modbus-tcp.c | 37 +++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/project/Core/Src/modbus-tcp.c b/project/Core/Src/modbus-tcp.c index 884901b..ada71af 100644 --- a/project/Core/Src/modbus-tcp.c +++ b/project/Core/Src/modbus-tcp.c @@ -85,23 +85,30 @@ static err_t modbus_incomming_data(void *arg, struct tcp_pcb *pcb, struct pbuf * number_of_files = llfs_file_list(file_list, number_of_files, NULL); // vrijgemaakt geheugen invullen met de lijst - - lenght = strlen(file_list[nr_img - 1].name); //lenght from filename - - strncpy(extention, file_list[nr_img - 1].name + lenght - 3, 3); //putting the last tree digits in string - extention[3] = '\0'; //adding the \0 - - if(strcmp(extention,"gif") == 0){ - lcd_clear(LCD_BLACK); - lcd_display_text(textstring, 10, 10, result_txt, result_bg, LCD_FONT24); - lcd_gif_t* gif = lcd_draw_gif_from_fs(file_list[nr_img - 1].name, 0, 75); //GIF on screen - } - if(strcmp(extention,"bmp") == 0){ - lcd_clear(LCD_BLACK); - lcd_display_text(textstring, 10, 10, result_txt, result_bg, LCD_FONT24); - lcd_draw_img_from_fs(file_list[nr_img - 1].name, 0, 75); //BMP on screen + if(number_of_files < nr_img){ + lcd_clear_txt(void); + lcd_clear_images(void); + lcd_display_text("FILE NOT IN FILESYSTEM", 10, 10, LCD_RED, LCD_BLACK, LCD_FONT24); } + else{ + lenght = strlen(file_list[nr_img - 1].name); //lenght from filename + strncpy(extention, file_list[nr_img - 1].name + lenght - 3, 3); //putting the last tree digits in string + extention[3] = '\0'; //adding the \0 + + if(strcmp(extention,"gif") == 0){ + lcd_clear_txt(void); + lcd_clear_images(void); + lcd_display_text(textstring, 10, 10, result_txt, result_bg, LCD_FONT24); + lcd_gif_t* gif = lcd_draw_gif_from_fs(file_list[nr_img - 1].name, 0, 75); //GIF on screen + } + if(strcmp(extention,"bmp") == 0){ + lcd_clear_txt(void); + lcd_clear_images(void); + lcd_display_text(textstring, 10, 10, result_txt, result_bg, LCD_FONT24); + lcd_draw_img_from_fs(file_list[nr_img - 1].name, 0, 75); //BMP on screen + } + } } else if (err == ERR_OK){ tcp_close(pcb); // when everithing was ok close the tcpconnection }