Skip to content
Merged
2 changes: 1 addition & 1 deletion include/effects/matrix/spectrumeffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class VUMeter

virtual void DrawVUPixels(std::vector<std::shared_ptr<GFXBase>> & GFX, int i, int yVU, int fadeBy = 0, const CRGBPalette16 * pPalette = nullptr)
{
if (g_Analyzer.MicMode() == PeakData::PCREMOTE)
if (g_Analyzer.IsRemoteAudioActive())
pPalette = &vuPaletteBlue;

int xHalf = GFX[0]->width()/2;
Expand Down
2 changes: 1 addition & 1 deletion include/effects/strip/musiceffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class BeatEffectBase

// Access peaks via const reference to avoid copying
const PeakData & peaks = g_Analyzer.Peaks();
auto basslevel = peaks._Level[0] * 2; // Scale to historical 0-2 range
auto basslevel = peaks[0] * 2; // Scale to historical 0-2 range

debugV("basslevel: %0.2f", basslevel);
_samples.push_back(basslevel);
Expand Down
21 changes: 21 additions & 0 deletions include/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,7 @@ inline String str_sprintf(const char *fmt, ...)

#include <random>
#include <type_traits>
#include <iterator>

template <typename T>
inline static T random_range(T lower, T upper)
Expand Down Expand Up @@ -893,6 +894,20 @@ constexpr std::array<T, N> to_array(const T (&arr)[N]) {
return result;
}

// Provide a single-parameter std::accumulate overload for ranges/containers
// This allows: auto total = std::accumulate(container);
namespace std {

Copilot AI Aug 17, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding functions to the std namespace is undefined behavior according to the C++ standard. Consider using a custom namespace like 'nds' or 'nightdriver' instead.

Suggested change
namespace std {
// Note: Adding to namespace std is undefined behavior. Use a custom namespace instead.
namespace nightdriver {

Copilot uses AI. Check for mistakes.

This comment was marked as resolved.

template <typename Range>
inline auto accumulate(const Range& r)
-> std::remove_cv_t<std::remove_reference_t<decltype(*std::begin(r))>>
Comment thread
rbergen marked this conversation as resolved.
{
using T = std::remove_cv_t<std::remove_reference_t<decltype(*std::begin(r))>>;
Comment on lines +900 to +904

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::remove_cv_t<std::remove_reference_t<decltype(*std::begin(r))>> can be replaced by the more concise std::decay_t<decltype(*std::begin(r))>.

You may have to #include <type_traits> to make it compile.

T total{};
for (const auto& v : r) total += v;
return total;
}
}

// 16-bit (5:6:5) color definitions for common colors

#define BLACK16 0x0000
Expand All @@ -917,6 +932,12 @@ constexpr std::array<T, N> to_array(const T (&arr)[N]) {

#if USE_TFTSPI
#define DISABLE_ALL_LIBRARY_WARNINGS 1
// If the project provides its own TFT_eSPI setup via USER_SETUP_LOADED
// and build_flags, do not include the TTGO default user setup to avoid
// macro redefinition warnings.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please keep this stuff out of globals? Plop it into screen.cc or something of smaller scope.

#if TTGO && !defined(USER_SETUP_LOADED)
#include <User_Setups/Setup25_TTGO_T_Display.h>
#endif
#include <TFT_eSPI.h>
#include <SPI.h>
#endif
4 changes: 4 additions & 0 deletions include/screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,12 @@ class Screen : public GFXBase
#endif

#if USE_TFTSPI
#if TTGO

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same file, different scope, different manifest. Bleeah.

#include <User_Setups/Setup25_TTGO_T_Display.h>
#endif
#include <TFT_eSPI.h>
#include <SPI.h>


// TFTScreen
//
Expand Down
Loading