From 7d68de58ca0b57bceb74d4a8d37f6aa3c576cca3 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Tue, 6 Feb 2018 13:13:34 +0100 Subject: [PATCH] tweaks --- src/main.cpp | 15 +++++++++++++-- src/mp3.cpp | 4 ++-- src/mp3.h | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 5916ecc..01f4e99 100644 --- a/src/main.cpp +++ b/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 //Include Basecamp in this sketch @@ -38,7 +46,7 @@ BME280 bme280; MP3 mp3; Rotary rotary; Screen* screen; -Led led; +//Led led; menuType menuChange = eNone; uint32_t lastButtonPress = 0; @@ -138,7 +146,7 @@ Serial.println(strftime_buf); } mp3.begin(); - led.setup(); +// led.setup(); rotary.registerCallback(rotation); rotary.begin(rotaryPinA, rotaryPinB, rotaryPinButton); @@ -244,6 +252,9 @@ void loop() strftime(timeStr, sizeof(timeStr), "%H:%M:%S", &timeinfo); sprintf(weatherStr, "%.1f°C %.1f%% %.0fhPa", bme280.readTemperature(), bme280.readHumidity(), bme280.readPressure()); + Serial.print("Free Heap: "); + Serial.println(ESP.getFreeHeap()); + } if(millis() - lastTransmit >= 60000) { diff --git a/src/mp3.cpp b/src/mp3.cpp index 4665229..1e773d1 100644 --- a/src/mp3.cpp +++ b/src/mp3.cpp @@ -80,7 +80,7 @@ void MP3::setVolume(int volume) { } uint32_t MP3::getBuffFill() { - if (audiobuffer) return ((100U*audiobuffer->getFillLevel())/(8*1024)); + if (audiobuffer) return ((100U*audiobuffer->getFillLevel())/preallocateBufferSize); else return 0; } @@ -115,7 +115,7 @@ void MP3::mp3_decoder_task(void *pvParameters) { while(decoder->isRunning()) { if (volumeChanged) { 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 (!playing) break; diff --git a/src/mp3.h b/src/mp3.h index 547a33e..0f967f0 100644 --- a/src/mp3.h +++ b/src/mp3.h @@ -30,7 +30,7 @@ class MP3 { void mp3_decoder_task(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 void *preallocateBuffer = NULL; void *preallocateCodec = NULL;