Skip to content

Commit 374ebdd

Browse files
committed
Make Mic a template param, improve I2S audio
1 parent 6e29a3e commit 374ebdd

7 files changed

Lines changed: 175 additions & 91 deletions

File tree

include/globals.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,10 @@ constexpr std::array<T, N> to_array(const T (&arr)[N]) {
917917

918918
#if USE_TFTSPI
919919
#define DISABLE_ALL_LIBRARY_WARNINGS 1
920-
#if TTGO
920+
// If the project provides its own TFT_eSPI setup via USER_SETUP_LOADED
921+
// and build_flags, do not include the TTGO default user setup to avoid
922+
// macro redefinition warnings.
923+
#if TTGO && !defined(USER_SETUP_LOADED)
921924
#include <User_Setups/Setup25_TTGO_T_Display.h>
922925
#endif
923926
#include <TFT_eSPI.h>

include/soundanalyzer.h

Lines changed: 138 additions & 80 deletions
Large diffs are not rendered by default.

platformio.ini

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,8 @@ build_flags = -DM5DEMO=1
518518
-DLED_PIN0=32
519519
-DTOGGLE_BUTTON_1=37
520520
-DTOGGLE_BUTTON_2=39
521-
-DNUM_BANDS=160
521+
-DDEFAULT_INFO_PAGE=1
522+
-DNUM_BANDS=80
522523
${dev_m5stack.build_flags}
523524

524525
; Now for the Heltec, with WiFi and webserver enabled
@@ -1047,6 +1048,7 @@ board_build.flash_freq = 40m
10471048
build_flags = -DTTGO=1
10481049
-DEFFECTS_TTGO=1
10491050
-DUSE_SCREEN=1
1051+
-DDEFAULT_INFO_PAGE=1
10501052
-DUSE_TFTSPI=1
10511053
-DUSER_SETUP_LOADED=1
10521054
-DST7789_DRIVER
@@ -1062,8 +1064,6 @@ build_flags = -DTTGO=1
10621064
-DTFT_MISO=-1
10631065
-DTFT_BL=4
10641066
-DTFT_BACKLIGHT_ON=HIGH
1065-
-DLOAD_GLCD=1
1066-
-DLOAD_GFXFF=1
10671067
-DSPI_FREQUENCY=40000000
10681068
-DSPI_READ_FREQUENCY=6000000
10691069
-DPROJECT_NAME="\"TTGO\""
@@ -1076,7 +1076,8 @@ build_flags = -DTTGO=1
10761076
-DENABLE_OTA=0
10771077
-DENABLE_REMOTE=1
10781078
-DENABLE_AUDIO=1
1079-
-DNUM_BANDS=120
1079+
-DNUM_BANDS=48
1080+
-DMAX_SAMPLES=512
10801081
-DUSE_I2S_AUDIO=1
10811082
-DINPUT_PIN=33
10821083
-DI2S_BCLK_PIN=26
@@ -1085,8 +1086,6 @@ build_flags = -DTTGO=1
10851086
-DLED_PIN0=21
10861087
-DRING_SIZE_0=24
10871088
-DBONUS_PIXELS=0
1088-
-DMATRIX_WIDTH=48
1089-
-DMATRIX_HEIGHT=16
10901089
-DNUM_FANS=MATRIX_WIDTH
10911090
-DFAN_SIZE=MATRIX_HEIGHT
10921091
-DIR_REMOTE_PIN=22

src/audio.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ void IRAM_ATTR AudioSamplerTaskEntry(void *)
9191
debugV("VURatio: %f\n", g_Analyzer.VURatio());
9292
debugV("VURatioFade: %f\n", g_Analyzer.VURatioFade());
9393

94-
// Delay enough time to yield 45fps max
94+
// Delay enough time to yield 60fps max
9595
// We wait a minimum even if busy so we don't Bogart the CPU
9696

97-
constexpr auto kMaxFPS = 45;
97+
constexpr auto kMaxFPS = 60;
9898
const auto targetDelay = PERIOD_FROM_FREQ(kMaxFPS) * MILLIS_PER_SECOND / MICROS_PER_SECOND;
9999
delay(max(1.0, targetDelay - (millis() - lastFrame)));
100100

src/main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ void onReceiveESPNOW(const uint8_t *macAddr, const uint8_t *data, int dataLen);
180180

181181
std::unique_ptr<SystemContainer> g_ptrSystem;
182182
Values g_Values;
183-
SoundAnalyzer g_Analyzer;
184183
RemoteDebug Debug; // Instance of our telnet debug server
185184
std::mutex g_buffer_mutex;
186185

src/screen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void BasicInfoSummary(bool bRedraw)
109109
char chStatus = szStatus[c2];
110110
cStatus++;
111111

112-
if (display.width() > 240)
112+
if (display.width() > 320)
113113
display.setTextSize(3);
114114
else if (display.width() >= 160)
115115
display.setTextSize(2);

src/soundanalyzer.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//+--------------------------------------------------------------------------
2+
//
3+
// File: SoundAnalyzer.cpp
4+
//
5+
// NightDriverStrip - (c) 2018 Plummer's Software LLC. All Rights Reserved.
6+
//
7+
// Template instantiations for SoundAnalyzer class
8+
//
9+
//---------------------------------------------------------------------------
10+
11+
#include "soundanalyzer.h"
12+
13+
ProjectSoundAnalyzer g_Analyzer;
14+
15+
#if ENABLE_AUDIO
16+
17+
// Explicit template instantiations to ensure proper linkage
18+
template class SoundAnalyzer<kParamsMesmerizer>;
19+
template class SoundAnalyzer<kParamsPCRemote>;
20+
template class SoundAnalyzer<kParamsM5>;
21+
template class SoundAnalyzer<kParamsM5Plus2>;
22+
template class SoundAnalyzer<kParamsI2SExternal>;
23+
24+
#endif
25+

0 commit comments

Comments
 (0)