   onEnterIdle(1200);
 }
 
-void onHeadsetInserted(boolean plugged) {
-  headset = plugged;
-  enableAmplifier(!headset);
+void onHeadphoneInserted(boolean plugged) {
+  headphone = plugged;
+  if (plugged) {
+    volume = volume + HEADPHONE_VOLUME_MAX - SPEAKER_VOLUME_MAX;
+  } else {
+    volume = volume + SPEAKER_VOLUME_MAX - HEADPHONE_VOLUME_MAX;
+  }
+  enableAmplifier(!headphone);
 }
 
 // Set volume for left, right channels. lower numbers == louder volume!

    if (state == PLAY_SELECTED) stopPlaying();
    nextTimeoutTick = 0; // no timeout during playing
    enablePlayer(true);
    enableAmplifier(!headset);
    onStartFirstTrack(index);
  }
}

byte nextLED = 0;
byte playingAlbum;
File album;
int volume = 25;
boolean headphone = false;
boolean headphoneFirstMeasure = false;


/***************************************************
