Edzelf / ESP32Radio-V2

New version of the well known ESP32 Radio. Now optional I2S output!
Apache License 2.0
182 stars 45 forks source link

displayvolume for LCD1602 #94

Open h1aji opened 1 year ago

h1aji commented 1 year ago

Hi Ed,

Would you be able to add intermittent volume status appearance into second line for LCD1602. Lets say show it for 3 seconds when changed. Something like this:

void LCD1602_displayvolume ( uint8_t vol )
{
  static uint8_t   oldvol = 0 ;                       // Previous volume
  uint16_t         pos ;                              // Positon of volume indicator

  dline[1].str = "";

  if ( vol != oldvol )                                // Volume changed?
  {
    dbgprint ( "Update volume to %d", vol ) ;
    oldvol = vol ;                                    // Remember for next compare
    pos = map ( vol, 0, 100, 0, dsp_getwidth() ) ;    // Compute end position on TFT
    for ( int i = 0 ; i < dsp_getwidth() ; i++ )      // Set oldstr to dots
    {
      if ( i <= pos )
      {
        dline[1].str += '\xFF' ;                     // Add block character
      }
      else
      {
        dline[1].str += ' ' ;                         // Or blank sign
      }
    }
    LCD1602_dsp_update_line(1) ;
    delay(3000);
  }
}