+ text_xprintf(bm, 1, 0, TEXT_CENTER, "Play wav file: %s", file_name);
+ text_xprintf(bm, 2, 0, TEXT_CENTER, "File: %ld", log_file.fat_file.fsize);
+ text_xprintf(bm, 3, 0, TEXT_CENTER, "Volume level %ld", ADC_RANGECONV(adc_read(1), 0, 100));
+ kprintf("Open file: %s\n", file_name);
+ wm8731_setVolume(&wm8731_ctx, WM8731_HEADPHONE, ADC_RANGECONV(adc_read(1), 0, 100));
+
+ lcd_hx8347_blitBitmap(bm);
+ if (wav_check(&log_file.fd) >= 0)
+ {
+ kputs("Wav file play..\n");
+ i2s_dmaStartTxStreaming(&i2s, tmp, sizeof(tmp), sizeof(tmp) / 4, codec_play);
+ }
+
+ wm8731_setVolume(&wm8731_ctx, WM8731_HEADPHONE, 0);
+
+ // Flush data and close the files.
+ kfile_flush(&log_file.fd);
+ kfile_close(&log_file.fd);
+ }
+ else
+ {
+ kprintf("Unable to open file: '%s' error[%d]\n", FILE_NAME, result);
+ }
+ }
+ f_mount(0, NULL);
+
+ lcd_hx8347_blitBitmap(bm);
+}
+
+
+INLINE FileItemNode *refresh_cursor(Bitmap *bm, List *file_list, int select_idx)
+{
+ FileItemNode *item;
+ FileItemNode *select_node;
+ int col = 0;
+ int row = 0;
+
+ gfx_bitmapClear(bm);
+ select_node = (FileItemNode *)LIST_HEAD(file_list);
+ FOREACH_NODE(item, file_list)
+ {
+ if (row > MAX_ITEMS_ROW)
+ {
+ row = 1;
+ col = NEXT_ITEM_COL;
+ }
+
+ text_style(bm, 0, STYLEF_MASK);
+ if (select_idx <= MAX_ITEMS_ROW)
+ {
+ if (row == select_idx && col == 0)
+ text_style(bm, STYLEF_INVERT, STYLEF_INVERT);
+ select_node = item;
+ }
+ else
+ {
+ if (row == (select_idx - MAX_ITEMS_ROW) && col == NEXT_ITEM_COL)
+ text_style(bm, STYLEF_INVERT, STYLEF_INVERT);
+ select_node = item;
+ }
+
+ text_xprintf(bm, row, col, TEXT_NORMAL, "%s", item->file_name);
+ row++;
+ }
+
+ lcd_hx8347_blitBitmap(bm);
+
+ return select_node;
+}
+
+static void sd_explorer(Bitmap *bm)
+{
+ List file_list;
+ LIST_INIT(&file_list);
+ int file_list_size = 0;
+ gfx_bitmapClear(bm);
+
+ memcpy (&item_nodes[0].file_name, "<- Return..", sizeof(item_nodes[0].file_name));
+ ADDTAIL(&file_list, &item_nodes[0].n);
+
+ if (SD_CARD_PRESENT())
+ {
+ timer_delay(10);
+
+ bool sd_ok = sd_init(&sd, NULL, 0);
+ FRESULT result;
+
+ if (sd_ok)
+ {
+ kprintf("Mount FAT filesystem.\n");
+
+ result = f_mount(0, &fs);
+ if (result != FR_OK)
+ {
+ kprintf("Mounting FAT volumes error[%d]\n", result);
+ sd_ok = false;
+ }