From d25c833f3c8971a43a830f921f629e4236097449 Mon Sep 17 00:00:00 2001 From: Obe Van Lierde Date: Mon, 20 Nov 2023 15:11:39 +0100 Subject: [PATCH] gif + bmp on screen, checking the extension --- project/Core/Src/modbus-tcp.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/project/Core/Src/modbus-tcp.c b/project/Core/Src/modbus-tcp.c index 08717c4..7c06df4 100644 --- a/project/Core/Src/modbus-tcp.c +++ b/project/Core/Src/modbus-tcp.c @@ -10,6 +10,8 @@ static err_t modbus_incomming_data(void *arg, struct tcp_pcb *pcb, struct pbuf * int i; int j; int len; + int lenght; + char extention[4]; char *pc; char *textstring; char text[200]; @@ -90,7 +92,17 @@ 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 - lcd_draw_img_from_fs(file_list[nr_img - 1].name, 10, 30); //BMP on screen + 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_gif_t* gif = lcd_draw_gif_from_fs(file_list[nr_img - 1].name, 10, 30); //GIF on screen + } + if(strcmp(extention,"bmp") == 0){ + lcd_draw_img_from_fs(file_list[nr_img - 1].name, 10, 30); //BMP on screen + } } else if (err == ERR_OK){ tcp_close(pcb); // when everithing was ok close the tcpconnection