lecteur mp3

Dependencies:   MPR121 SDFileSystem TextLCD VS1053lib mbed

Fork of MP3_test by PROJETS GEII-1 Cachan

Files at this revision

API Documentation at this revision

Comitter:
gr66
Date:
Wed Sep 28 18:10:24 2016 +0000
Child:
1:d1ed30ba5ca9
Commit message:
test

Changed in this revision

SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
VS1053lib.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
mp3.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Wed Sep 28 18:10:24 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/mbed_official/code/SDFileSystem/#8db0d3b02cec
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Wed Sep 28 18:10:24 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/GEII-1-Cachan/code/TextLCD/#2d87b5ec1470
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/VS1053lib.lib	Wed Sep 28 18:10:24 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/ollie8/code/VS1053lib/#ce980c240ae1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Sep 28 18:10:24 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mp3.cpp	Wed Sep 28 18:10:24 2016 +0000
@@ -0,0 +1,79 @@
+//********************************
+// version 27/09/16
+// G.Raynaud
+//********************************
+#include "mbed.h"
+#include "TextLCD.h"
+#include "SDFileSystem.h"
+#include <VLSIcodec.h>
+
+#define BUFFER_SIZE 2048
+
+Serial com(USBTX, USBRX); //Initiallize the Serial Port 0 (9600 bits/sec)
+unsigned char buff[BUFFER_SIZE];
+// codec
+VS1053Codec codec(p11, p12, p13, p14, p16, p15, p17); // mosi, miso, sck, cs,  dreq, rst, bsync
+// I2C Communication
+I2C i2c_lcd(p28, p27 ); // SCL, SDA
+// LCD
+TextLCD_I2C lcd(&i2c_lcd, 0x40, TextLCD::LCD16x2);  // I2C bus, PCF8574 Slaveaddress, LCD Type
+// SD card
+SDFileSystem sd(p5, p6, p7, p8, "sd"); //  mosi, miso, sclk, cs   the pinout on the mbed Cool Components workshop board
+
+int main()
+{
+    char ligne[17];
+    lcd.cls();
+    lcd.setBacklight(TextLCD::LightOff);
+    wait(1);
+    lcd.printf("     ");
+    lcd.cls();
+    lcd.setBacklight(TextLCD::LightOn);
+    lcd.setCursor(TextLCD::CurOff_BlkOff);
+    mkdir("/sd/mydir", 0777);
+    FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
+    if(fp == NULL) {
+        error("Could not open file for write\n");
+    }
+    fprintf(fp, "IUT---MP3");
+    fclose(fp);
+    fp = fopen("/sd/mydir/sdtest.txt", "r");
+    fscanf(fp,"%s",ligne);
+    lcd.printf(ligne);
+    fclose(fp);
+    
+    
+    wait(1);
+    //
+    codec.init();                      // initialise le codec
+    codec.loadpatch();                 // charge le patch (rev 1.5)
+    codec.setbassboost( 15, 150);      // basse
+    codec.settrebleboost( 7, 15000);   // aigue
+    codec.setvolume( 0x10, 0x10);      // volume
+
+
+    FILE *song  = fopen("/sd/music/1.mp3", "r");  // ouverture fichier MP3
+    codec.resetplaytime();
+    int aff=0;
+    
+    while(1) {
+
+        while(!feof(song)) {    // tant que fichier non termine
+
+            fread(buff, 1, BUFFER_SIZE, song);  // lecture buffer 
+            aff++;
+            if(aff%1==0){
+            codec.getplaytime(ligne);
+            ligne[5]=NULL;
+            lcd.locate(2,1);
+            lcd.puts(ligne);}
+            int iSize=0;
+            while( iSize < BUFFER_SIZE) {
+                codec.testdreq();
+                codec.writedata( buff[ iSize++]);
+                //if ( iSize > BUFFER_SIZE)
+                    //break;
+            }
+        }
+    }
+}
\ No newline at end of file