diff --git a/software/src/AudioAppletSubapp.h b/software/src/AudioAppletSubapp.h index 5cd4f21eb..bbf2da11d 100644 --- a/software/src/AudioAppletSubapp.h +++ b/software/src/AudioAppletSubapp.h @@ -101,6 +101,7 @@ class AudioAppletSubapp { for (size_t i = 0; i < Slots; i++) { print_applet_line(i); } + if (edit_state == EDIT_LEFT) { HemisphereAudioApplet& applet = IsStereo(left_cursor) ? get_stereo_applet(left_cursor) @@ -108,7 +109,9 @@ class AudioAppletSubapp { applet.BaseView(); gfxFrame(64, 0, 64, 64); } else { - gfxPrint(65, 2, "R Channel"); + // gfxPrint(65, 2, "R Channel"); + gfxPos(65, 2); + graphics.printf("MEM%3d%%) R", mem_percent); gfxDottedLine(64, 10, 126, 10); } if (edit_state == EDIT_RIGHT) { @@ -118,9 +121,23 @@ class AudioAppletSubapp { applet.BaseView(); gfxFrame(0, 0, 64, 64); } else { - gfxPrint(1, 2, "L Channel"); + // gfxPrint(1, 2, "L Channel"); + gfxPos(1, 2); + graphics.printf("L (CPU%3d%%", cpu_percent); gfxDottedLine(0, 10, 62, 10); } + + // Recall that unsigned substraction rolls over correclty, so when millis() + // rolls over, this will still work. + if (millis() - last_stats_update > 250) { + last_stats_update = millis(); + mem_percent = static_cast( + 100 * static_cast(AudioMemoryUsageMax()) / OC::AudioIO::AUDIO_MEMORY + ); + cpu_percent = static_cast(AudioProcessorUsageMax()); + AudioProcessorUsageMaxReset(); + AudioMemoryUsageMaxReset(); + } } void HandleEncoderButtonEvent(const UI::Event& event) { @@ -320,6 +337,10 @@ class AudioAppletSubapp { uint32_t last_update = 0; + int16_t mem_percent = 0; + int16_t cpu_percent = 0; + uint32_t last_stats_update = 0; + enum EditState { EDIT_NONE, EDIT_LEFT, diff --git a/software/src/AudioIO.cpp b/software/src/AudioIO.cpp index 6cfd2b239..f9b7793ad 100644 --- a/software/src/AudioIO.cpp +++ b/software/src/AudioIO.cpp @@ -19,7 +19,7 @@ namespace OC { } void Init() { - AudioMemory(128); + AudioMemory(AUDIO_MEMORY); } } } diff --git a/software/src/AudioIO.h b/software/src/AudioIO.h index 849e6e096..1ab89fab8 100644 --- a/software/src/AudioIO.h +++ b/software/src/AudioIO.h @@ -4,6 +4,7 @@ namespace OC { namespace AudioIO { + const int AUDIO_MEMORY = 128; AudioInputI2S2& InputStream(); AudioOutputI2S2& OutputStream(); void Init();