Home Forums Sparkfun MP3 Shield Library Support Forum problem arduino mega2560+sparkfun+ir remote

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1768
    Anonymous
    Inactive

    Good morning everyone.
    I’m Italian so sorry for my English!
    I connected Arduino Mega with SparkFun shield mp3 + sd and everything works perfectly with the keyboard and serial.
    I then inserted library <IRremote.h> to change songs by remote control and works, but if I get the songs end up going the wrong numbers on the remote control and the program does not work anymore. ‘-
    Someone can ‘help me?

    #1769

    I have been thinking about attempting just such. Noting that IRremote and SFEMP3Shield both use interrupts. Hence, I expected a conflict between them, resulting in corrupted received IR values, but not necessarily a lock up. The SFEMP3Shield’s default setup of using INT0 is not very real time efficient as it reads the SdCard while in the service of INT0. During which the IRremote’s Timer1 interrupt is blocked.

    As a possible work a round by changing the SFEMP3ShieldConfig.h of

    #define USE_MP3_REFILL_MEANS USE_MP3_INTx

    to

    #define USE_MP3_REFILL_MEANS USE_MP3_Polled

    along with placing

    MP3player.available();

    in the main loop. This would preclude the interrupt conflict and believe it should work. Where it may have the draw back of having short pauses of the playing audio, when receiving a IR command. If this happens leave off the IRremote DEBUG, to help and limit any blocking activities in the loop(). Serial Prints may also delay.

    Let us know how it works or has problems.

    #1789
    Anonymous
    Inactive

    Perfect work!
    You’re number one!
    thank you very much
    Gianluca

    #1790

    I believe that means it works perfectly.

    I am glad it does.

    Is there any observations. Or problems, such as skipping sound when IR data is being decoded?

    #1792
    Anonymous
    Inactive

    everything works and does not crash!

    there just a small detail that affects the function playTrack ();

    cause if I want to change the first song I Do:

    MP3player.stopTrack ();

    MP3player.playTrack (1);

    otherwise does not change the song. Pause and resume functions I still can not make it go.

    #1793

    Stopping before playing next track is normal.

    I can understand that the Pause and Resume can be tricky as my example is stateless, hence the two separate commands. Need to tie a state machine (aka Boolean flag) around them if you want the same IR key to toggle pause.

     

    #1797
    Anonymous
    Inactive

    I acquire the value from the remote control and I see that ‘correct.
    then run

    else if(results.value==play_pause){
    if(MP3player.isPlaying()){
    MP3player.pauseDataStream();
    }
    else{
    MP3player.resumeDataStream();
    }

    }

     

    all other commands are correct.
    I do not think it’s normal stop the song rather then change it ’cause if I send the serial command to change song I just need
    MP3player.playTrack (1);
    without first stopping the song.

    #1798

    Please note the isPlay() does not reflect the complete status. It only indicates if a file is supposed to be playing at the moment. It does not reflect if it is paused. Playing another file while paused, still indicates a positive for isPlaying(). Hence this can not be used for un-pausing, the way you want.

    I have added new function getState(), see the example ‘p’ command at My current GitHub Fork/Branch . I have changed the ‘p’ command to now toggle pause on and off. It shows how to use the getState() command. This should be representative of what your are attempting.

    Your observation that playTrack (1); called after pauseDataStream(), actually un-paused the play, was not the desired effect. This is corrected. It will now require a stop.

    Also please note that this version requires the Sd.Begin in the main INO and there are some typo corrections of Get vs get / Set vs set… of some function names. All are shown in the example.

    Have fun.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.