diff --git a/project/Core/Src/mug.c b/project/Core/Src/mug.c index 4e2bbf1..d6fa9f5 100644 --- a/project/Core/Src/mug.c +++ b/project/Core/Src/mug.c @@ -51,16 +51,32 @@ static void example_publish(mqtt_client_t *client, void *arg) { llfs_file_t file_list[max_files]; size_t num_files; - num_files = llfs_file_list(file_list, max_files, "*.png"); + num_files = llfs_file_list(file_list, max_files, "*.bmp"); if(num_files == 0) { strcpy(pub_payload, "No images found"); } else { + strcat(pub_payload, "Available images: "); for (size_t i = 0; i < num_files; i++) { // Concatenate file names into the payload string strcat(pub_payload, file_list[i].name); - strcat(pub_payload, ", "); // Add a space between file names + strcat(pub_payload, ", "); // Add a comma between file names } + strcat(pub_payload, "\0"); + } + + num_files = llfs_file_list(file_list, max_files, "*.gif"); + + if(num_files == 0) { + strcpy(pub_payload, "No gifs found"); + } else { + strcat(pub_payload, "Available gifs: "); + for (size_t i = 0; i < num_files; i++) { + // Concatenate file names into the payload string + strcat(pub_payload, file_list[i].name); + strcat(pub_payload, ", "); // Add a comma between file names + } + strcat(pub_payload, "\0"); } err = mqtt_publish(client, "getImageList", pub_payload, strlen(pub_payload), qos, retain, mqtt_pub_request_cb, arg); if(err != ERR_OK) { @@ -94,22 +110,22 @@ static void mqtt_incoming_data_cb(void *arg, const u8_t *data, u16_t len, u8_t f switch(inpub_id) { case 0: //lcd_display_text("teststring", xpos, ypos, color, bgcolor, font); - LOG_INFO(TAG, "incoming data on input/setText: %s.", data); + LOG_INFO(TAG, "incoming data on input/setText: %s.", data_buffer); lcd_display_text(data_buffer, xpos, ypos, color, bgcolor, font); break; case 1: //places an image on the lcd - LOG_INFO(TAG, "incoming data on input/setImage: %s.", data); - //call function here + LOG_INFO(TAG, "incoming data on input/setImage: %s.", data_buffer); + lcd_draw_img_from_fs((const char*)data_buffer, xpos, ypos); break; case 2: //changes the text color on the lcd - LOG_INFO(TAG, "incoming data on input/setTextColor: %s.", data); + LOG_INFO(TAG, "incoming data on input/setTextColor: %s.", data_buffer); color = color_picker(data_buffer); break; case 3: //changes the background color - LOG_INFO(TAG, "incoming data on input/setColor: %s.", data); + LOG_INFO(TAG, "incoming data on input/setColor: %s.", data_buffer); bgcolor = color_picker(data_buffer); break; default: