| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

My_mp3_player_interface_code

Page history last edited by David Boinagrov 11 years, 8 months ago

 

 

void vol_plus()         //pressing the volume_plus switch button

{

  if ((millis()-timee) > 200 and mp3_vol<250) 

    {

      if (mp3_vol >189) mp3_vol+=5;

      if (mp3_vol == 180) mp3_vol=190;

      if (mp3_vol == 170) mp3_vol=180;

      if (mp3_vol == 160) mp3_vol=170;

      if (mp3_vol == 0) mp3_vol=160;

      Mp3.volume(mp3_vol);

      timee=millis();     

      lcd_onn=1;

      draw_screen();

    }    

}

 

 

void vol_minus()         //pressing the volume_minus switch button

{

  if ((millis()-timee) > 200 and mp3_vol>0) 

    {

      if (mp3_vol == 160) mp3_vol=0;

      if (mp3_vol == 170) mp3_vol=160;

      if (mp3_vol == 180) mp3_vol=170;

      if (mp3_vol == 190) mp3_vol=180;

      if (mp3_vol > 190) mp3_vol-=5;

      Mp3.volume(mp3_vol);

      timee=millis();      

      lcd_onn=1;

      draw_screen();

 

    }       

}

 

 

 

void pause_pressed()         //pressing the pause/play button

{

  if (current_state == PAUSED and (millis()-timee) > 300) 

    {

      lcd_onn=1;

      current_state = DIR_PLAY;

      timee=millis();

      draw_screen();

    }

 

 

  if (current_state == DIR_PLAY and (millis()-timee) > 300) 

    {

      lcd_onn=1;

      current_state = PAUSED;  

      timee=millis();

      draw_screen();

    }

}

 

 

 

void skip_forward()         //pressing the skip_forward button

{

 

  if ((millis()-timee) > 300) 

    {

      Mp3.cancel_playback();

      sd_file.close();

 

      if (current_song < num_songs - 1) 

        current_song++;

      else

        current_song=0;

      sd_file_open();        

 

      draw_screen();

      timee=millis();

      lcd_onn=1;

    }

}

 

 

 

void skip_backward()         //pressing the skip_backward button

{

  if ((millis()-timee) > 300) 

    {

 

      Mp3.cancel_playback();

      sd_file.close();

 

      if (current_song > 0) 

         current_song--;

      else

         current_song = num_songs - 1;

      sd_file_open();

 

      draw_screen();

      timee=millis();

      lcd_onn=1;

    }

}

 

 

void write_song_names()   //write song names on the LCD, when playing

 {

   for (j=0; j<num_songs; j++) 

   {

      if (j!=current_song) lcd.writeString(0, j, cc[j], MODE_NORMAL);

      else lcd.writeString(0, j, cc[j], MODE_INVERSE);

   }

 }

 

void write_playing_status()   //write playin/paused status on LCS

 {

    if (current_state == DIR_PLAY) lcd.writeString(21, 6, "playing", MODE_NORMAL);

    if (current_state == PAUSED) lcd.writeString(24, 6, "paused", MODE_NORMAL);

 } 

 

 

void draw_volume_bar()         //draw volume bar

  {

    if (mp3_vol==0) vol2=0;

    if (mp3_vol==160) vol2=1;

    if (mp3_vol==170) vol2=2;

    if (mp3_vol==180) vol2=3;

    if (mp3_vol>189) vol2=mp3_vol/5-34;

    for (i=0; i<3*vol2; i++)

    {

      lcd.setPixel(82, 47-i, PIXEL_ON);

      lcd.setPixel(83, 47-i, PIXEL_ON);    

    }

  }

 

void draw_screen()             //draw all the components on the LCD screen  

  {

      lcd.clear();

      write_song_names();

      write_playing_status();

      draw_volume_bar();   

  }

 

 

void lcd_br()

  {

    delta=millis()-timee;

    if (delta<10000) br=255; 

    if (delta>10000 and delta<13000) br = 1083 - delta/12;

    if (delta>13000) br = 0;

    if (br>255) br=255;

    if (br<0) br=0;

      if (millis()>200)  analogWrite(15, br);

 

/*    if (delta>18000 and lcd_onn==1) 

      {

        lcd.clear();

        lcd_onn=0;

      }

*/

 

  }

 

 

Comments (0)

You don't have permission to comment on this page.