modbus_tcp
Move duplicate common code outside of the image draw part
This commit is contained in:
@@ -96,7 +96,6 @@ static err_t modbus_incoming_data(void* arg, struct tcp_pcb* pcb, struct pbuf* p
|
||||
llfs_file_t file_list[number_of_files];
|
||||
number_of_files = llfs_file_list(file_list, number_of_files, NULL);
|
||||
|
||||
if (number_of_files < registers[REG_IMAGE_NR]) {
|
||||
lcd_clear_text();
|
||||
lcd_clear_images();
|
||||
lcd_stop_all_gifs();
|
||||
@@ -104,6 +103,7 @@ static err_t modbus_incoming_data(void* arg, struct tcp_pcb* pcb, struct pbuf* p
|
||||
lcd_display_text(text, 10, 10, text_foreground_color, result_background,
|
||||
LCD_FONT24);
|
||||
|
||||
if (number_of_files < registers[REG_IMAGE_NR]) {
|
||||
lcd_display_text("FILE NOT IN FILESYSTEM", 10, 75, LCD_RED, LCD_BLACK, LCD_FONT24);
|
||||
} else {
|
||||
const char* ext = strrchr(file_list[registers[REG_IMAGE_NR] - 1].name, '.');
|
||||
@@ -111,17 +111,8 @@ static err_t modbus_incoming_data(void* arg, struct tcp_pcb* pcb, struct pbuf* p
|
||||
// No valid extension found
|
||||
}
|
||||
if (strcmp(ext, ".gif") == 0) {
|
||||
lcd_clear_text();
|
||||
lcd_clear_images();
|
||||
lcd_stop_all_gifs();
|
||||
|
||||
lcd_display_text(text, 10, 10, text_foreground_color, result_background, LCD_FONT24);
|
||||
lcd_gif_t* gif = lcd_draw_gif_from_fs(file_list[registers[REG_IMAGE_NR] - 1].name, 0, 75); // GIF on screen
|
||||
} else if (strcmp(ext, ".bmp") == 0) {
|
||||
lcd_clear_text();
|
||||
lcd_clear_images();
|
||||
lcd_stop_all_gifs();
|
||||
lcd_display_text(text, 10, 10, text_foreground_color, result_background, LCD_FONT24);
|
||||
lcd_draw_img_from_fs(file_list[registers[REG_IMAGE_NR] - 1].name, 0, 75); // BMP on screen
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user