![](/media/cache/profiles/94bd3f4d79c60af8831740e58a68dd6e.jpg.50x50_q85.jpg)
use VS1033(MP3 decoder) and UL024TF(TFTLCD)
Dependencies: TFTLCDwithFastIO FastIO SDFileSystem TouchPanel VS1033 mbed
main.cpp
- Committer:
- nameless129
- Date:
- 2015-07-12
- Revision:
- 2:0090839c8276
- Parent:
- 0:5f0e931ae677
- Child:
- 3:67e97c846cec
File content as of revision 2:0090839c8276:
#include "ili9328.h" #include <stdio.h> #include "mbed.h" #include "SDFileSystem.h" #include "VS1053.h" // prepare the data bus for writing commands and pixel data BusOut dataBus( P1_28,P2_3,P1_18,P1_24,P1_19,P1_26,P1_27,P1_25 ); // 16 pins // create the lcd instance //(PinName CS, PinName RESET, PinName RS, PinName WR, BusOut *DATA_PORT, PinName BL=NC, PinName RD=NC, backlight_t blType=Constant, float defaultBackLightLevel=1.0) ILI9328_LCD lcd( P0_12, P0_11, P0_13, P0_14, &dataBus, NC, P1_9 ); // control pins and data bus SDFileSystem sd(/*MOSI*/ P0_9, /*MISO*/ P0_8, /*SCK*/ P1_29, /*CS*/ P0_2, /*Mountpoint*/ "sd"); VS1053 mp3(/*MOSI*/ P1_22 , /*MISO*/ P1_21, /*SCK*/ P1_20, /*CS*/ P1_23, /*BSYNC*/ P2_16, /*DREQ*/ P2_17, /*RST*/ P2_18, /*SPI freq.*/ 10000000); #define SD_READ_BLOCK_SIZE (1024) int main() { static FILE *fp = NULL; size_t sizeRead = 0; size_t totalSizeSent=0; size_t fileSize=0; uint8_t buf[SD_READ_BLOCK_SIZE]; printf("Power ON\r\n"); //LCD Init. lcd.Initialize(LANDSCAPE,RGB16); /* for sine test mode */ // mp3.sine_test_activate(SineWave_10k); // while(1); //MP3 decoder Init. mp3.hardwareReset(); mp3.sci_init(); mp3.sdi_init(); wait(0.1); printf("init CMPL.\r\n"); lcd.SetBackground(COLOR_BLUE); lcd.FillScreen(-1); lcd.SetFont( &TerminusFont ); lcd.Print( "STOP:XXXXXXXX", CENTER, 25 ); // align text to center horizontally and use starndard colors fp = fopen("/sd/2.mp3", "rb"); //Get file size fseek( fp, 0, SEEK_END ); fileSize = ftell( fp ); printf("file size:%d\r\n",fileSize); //move file pointer to top. rewind(fp); if (fp) { clearerr(fp); totalSizeSent = 0; } while(1) { if(totalSizeSent>=fileSize) { // Close when the track reaches the end mp3.stop(); fclose(fp); fp = NULL; printf("stop\r\n"); while(1) { } } else { sizeRead = fread(buf, sizeof(uint8_t), SD_READ_BLOCK_SIZE, fp); totalSizeSent += mp3.sendDataBlock(buf, sizeRead); //printf("total %d Send %d\r\n",totalSizeSent,sizeRead); } } }