Browse Source

tweaks

main
Hendrik Langer 7 years ago
parent
commit
7d68de58ca
  1. 15
      src/main.cpp
  2. 4
      src/mp3.cpp
  3. 2
      src/mp3.h

15
src/main.cpp

@ -1,3 +1,11 @@
/*
*
* Compile and flash:
* platformio run --target upload && platformio device monitor -b 115200
* Decode stack trace:
* addr2line -pfiaC -e .pioenvs/heltec_wifi_lora_32/firmware.elf 0x4013abed:0x3ffe35d0
*/
#include <Arduino.h> #include <Arduino.h>
//Include Basecamp in this sketch //Include Basecamp in this sketch
@ -38,7 +46,7 @@ BME280 bme280;
MP3 mp3; MP3 mp3;
Rotary rotary; Rotary rotary;
Screen* screen; Screen* screen;
Led led; //Led led;
menuType menuChange = eNone; menuType menuChange = eNone;
uint32_t lastButtonPress = 0; uint32_t lastButtonPress = 0;
@ -138,7 +146,7 @@ Serial.println(strftime_buf);
} }
mp3.begin(); mp3.begin();
led.setup(); // led.setup();
rotary.registerCallback(rotation); rotary.registerCallback(rotation);
rotary.begin(rotaryPinA, rotaryPinB, rotaryPinButton); rotary.begin(rotaryPinA, rotaryPinB, rotaryPinButton);
@ -244,6 +252,9 @@ void loop()
strftime(timeStr, sizeof(timeStr), "%H:%M:%S", &timeinfo); strftime(timeStr, sizeof(timeStr), "%H:%M:%S", &timeinfo);
sprintf(weatherStr, "%.1f°C %.1f%% %.0fhPa", bme280.readTemperature(), bme280.readHumidity(), bme280.readPressure()); sprintf(weatherStr, "%.1f°C %.1f%% %.0fhPa", bme280.readTemperature(), bme280.readHumidity(), bme280.readPressure());
Serial.print("Free Heap: ");
Serial.println(ESP.getFreeHeap());
} }
if(millis() - lastTransmit >= 60000) { if(millis() - lastTransmit >= 60000) {

4
src/mp3.cpp

@ -80,7 +80,7 @@ void MP3::setVolume(int volume) {
} }
uint32_t MP3::getBuffFill() { uint32_t MP3::getBuffFill() {
if (audiobuffer) return ((100U*audiobuffer->getFillLevel())/(8*1024)); if (audiobuffer) return ((100U*audiobuffer->getFillLevel())/preallocateBufferSize);
else return 0; else return 0;
} }
@ -115,7 +115,7 @@ void MP3::mp3_decoder_task(void *pvParameters) {
while(decoder->isRunning()) { while(decoder->isRunning()) {
if (volumeChanged) { if (volumeChanged) {
volumeChanged = false; volumeChanged = false;
out->SetGain(((float)volume)/100.0); out->SetGain(((float)volume)/(100.0/1.50)); // gain from 0.1 to 4.0
} }
if (!decoder->loop()) break; if (!decoder->loop()) break;
if (!playing) break; if (!playing) break;

2
src/mp3.h

@ -30,7 +30,7 @@ class MP3 {
void mp3_decoder_task(void*); void mp3_decoder_task(void*);
static void cTaskWrapper(void*); static void cTaskWrapper(void*);
static constexpr int preallocateBufferSize = 8*1024; static constexpr int preallocateBufferSize = 16*1024;
static constexpr int preallocateCodecSize = 29192; // MP3 codec max mem needed static constexpr int preallocateCodecSize = 29192; // MP3 codec max mem needed
void *preallocateBuffer = NULL; void *preallocateBuffer = NULL;
void *preallocateCodec = NULL; void *preallocateCodec = NULL;

Loading…
Cancel
Save