Edzelf / Esp-radio

Internet radio based on Esp8266 and VS1053.
MIT License
622 stars 200 forks source link

Play / Pause function on physical button #221

Closed dansity closed 6 months ago

dansity commented 6 months ago

I will leave this small modification here if anyone needs it. I wanted to make one of the button play / pause function instead of the preset. I have copied the functions from the web buttons to one of the physical button.

Button functions are starting at line 1174, replace button 1 or button 2

#if ( not ( defined ( USETFT ) ) )
    newval = digitalRead ( BUTTON1 ) ;            // Test if below certain level
    if ( newval != oldval1 )                      // Change?
    {
      oldval1 = newval ;                          // Yes, remember value
      if ( newval == LOW )                        // Button pushed?
      {
        if ( datamode & ( HEADER | DATA | METADATA | PLAYLISTINIT |
                      PLAYLISTHEADER | PLAYLISTDATA ) )
          {
            datamode = STOPREQD ;                           // Request STOP
          }
        else {
          hostreq = true ; // Yes, request restart
        }
      }
      return ;
    }