Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add M5 Unified support (M5 Stick C Plus 2, M5 Stack Core 2) #642

Merged
merged 12 commits into from
Jul 16, 2024

Conversation

davepl
Copy link
Contributor

@davepl davepl commented Jul 8, 2024

Description

Moves all M5-based projects to the unified M5 stack

Fixes #582. Fixes #618.

  • I read the contribution guidelines in CONTRIBUTING.md.
  • I understand the BlinkenPerBit metric, and maximized it in this PR.
  • I selected main as the target branch.
  • All code herein is subjected to the license terms in COPYING.txt.

if (_bMirrored)
setPixelsOnAllChannels(_cLength-1-position, _cBallSize, Colors[i % ARRAYSIZE(ballColors)], true);
setPixelsOnAllChannels(_cLength-1-position, _cBallSize, Colors[i % std::size(ballColors)], true);
Copy link
Contributor

Choose a reason for hiding this comment

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

I had to consult the holy books (https://en.cppreference.com/w/cpp/iterator/size#Version_1) to convince myself they were the same, but I'd consider

ballColors.size() to be more in line with STL norms and would save you from having to make our own.

I don't feel strongly enough about this to tussle over it. If you hate it, don't even type the STFU.

include/effects/strip/faneffects.h Outdated Show resolved Hide resolved
@@ -503,6 +503,97 @@ class TwinkleEffect : public LEDStripEffect
}
};

// SilonEffect
Copy link
Contributor

Choose a reason for hiding this comment

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

I know you don't dig spelling corrections, but this effect (a.k.a. "larson scanner" or "larson lamps" as they were also used on K.I.T.T, also produced by Glen Larson) should probably at least publicly be called "Cylon"

https://galactica.fandom.com/wiki/Cylon

https://shop.evilmadscientist.com/productsmenu/152

If we want to have a REAL flamewar, let's take up plot holes in the sequel. In the early episodes, their spines glowed when they were aroused, yet nobody questioned why Professor Pinhead couldn't build an effective Cylon Detector! (I know... off topic. :-)

include/effects/strip/misceffects.h Show resolved Hide resolved
// BUGBUG: Once we have compiler support we shoud use the C++20 versions

template <typename T, std::size_t N>
constexpr std::array<T, N> to_array(const T (&arr)[N]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Odd. Is it still in std::experimental::to_array on yours? Have you run a pkg update lately?

I'm queasy rolling our own std::anything, but please wrap this inside an #if !defined(__cpp_lib_to_array) so we don't conflict with it when it shows up. (I've been using to_array and friends, but I'm living in the future.)

Citation for name (It's in the spec, too.):
https://en.cppreference.com/w/cpp/feature_test
Example usage:
https://gcc.gnu.org/pipermail/libstdc++-cvs/2024q1/040869.html

@@ -241,11 +241,23 @@ inline void * PreferPSRAMAlloc(size_t s)
if (psramInit())
{
debugV("PSRAM Array Request for %u bytes\n", s);
return ps_malloc(s);
auto p = ps_malloc(s);
Copy link
Contributor

Choose a reason for hiding this comment

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

It's out of scope for this PR, but since we make reasonable use of https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/external-ram.html#configuring-external-ram
and I'e (a) quit calling psram_init() on every malloc in my own trees after moving it out of a debug print in main (oof!) and have run various strips (not so many matrix builds) for weeks/months without depletion, what would be the bar to eliminate all this "too clever" code and let
heap_caps_malloc_extmem_enable() just handle all this for us?

I'm willing to do some heavy lifting on this. Just LMK the acceptance criteria for build configurations and test patterns.

debugV("ProcessIncomingData -- Channel: %u, Length: %u, Seconds: %llu, Micros: %llu ... ",
channel16,
length32,
seconds,
micros);

// The very old original implementation used channel numbers, not a mask, and only channel 0 was supported at that time, so if
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this was a yank and put, but can you please try to associate some kidn of absolute time with "very old"? Code grows older (we don't!) and it can be hard to reconstruct how hard this will be worth preserving in the year 2030 when there's a Mesmerizer in every home.

It doesn't need to be an exact date or a git hash or anything. Even "early 2018" will help our successors carbon-date this kind of code.

@@ -1067,8 +1067,8 @@ class FireFanEffect : public LEDStripEffect
{
for (int i = 0; i < CellCount(); i++)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the optimizer trivially prove that CellCount doesn't change as a result of anything we may be doing inside these loops? It might be worth pulling it into a local so it doesn't have to recompute/re-fetch it if not.

include/effects/strip/misceffects.h Outdated Show resolved Hide resolved
@@ -158,7 +158,7 @@ void BasicInfoSummary(bool bRedraw)
time(&t);
struct tm *tmp = localtime(&t);
char szTime[16];
strftime(szTime, ARRAYSIZE(szTime), "%H:%M:%S", tmp);
strftime(szTime, std::size(szTime), "%H:%M:%S", tmp);
Copy link
Contributor

Choose a reason for hiding this comment

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

Someone with access to hardware could earn valuable cleanup points replacing this V7-era ctime nonsense with something like (warning: freehanded code)
auto t = system_clock::now(); // should be a std::chrono::time_point
std::chrono::hh_mm_ss hms {t};
auto as_string = std::format("{}", hms);

I could be convinced to pair-program with someone that had appropriate hardware and wanted to do it together.

Those C-era time functions can't die from the planet soon enough for my taste.

@davepl
Copy link
Contributor Author

davepl commented Jul 9, 2024 via email

Copy link
Collaborator

@rbergen rbergen left a comment

Choose a reason for hiding this comment

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

Note: some of my comments are responses to @robertlipe's comments. I've been told by others that GitHub can make it difficult to follow these threads when consumed via email. So, it may be best (if not necessary?) to view the review on GitHub.

So I do have a few comments, but no deal-breakers as far as I'm concerned. I'll push an update to this PR to add an M5StickC Plus2 project to the web installer, and address some of my own (textual) comments in that.

@davepl I'll leave up to you which of Robert's and my remaining comments you want to process before you merge.

include/effects/strip/faneffects.h Outdated Show resolved Hide resolved
include/effects/strip/misceffects.h Show resolved Hide resolved
include/globals.h Outdated Show resolved Hide resolved
include/globals.h Outdated Show resolved Hide resolved
platformio.ini Outdated Show resolved Hide resolved
platformio.ini Outdated Show resolved Hide resolved
samples/videoserver/pcstats.py Outdated Show resolved Hide resolved
include/effects/strip/misceffects.h Outdated Show resolved Hide resolved
@rbergen
Copy link
Collaborator

rbergen commented Jul 10, 2024

Just noting here that the commits I just pushed address some of the review comments made. I will resolve the conversations in question.

@robertlipe
Copy link
Contributor

robertlipe commented Jul 11, 2024 via email

@rbergen rbergen mentioned this pull request Jul 12, 2024
4 tasks
@prschguy1
Copy link

Hello Dave, thanks for your work on getting us to the new library. I had tried doing that, but had failed to get it working. That being said, it seems your spectrum display is processing artifacts, rather than actual audio. I have included a couple of photos. 1 in the fork preview you provided, and 1 loaded from 11/18/2023. Both are in glass containers, under a slight vacuum. As you can see, m5 plus, plus 2, and stack 2 are processing audio that just isn't there. I don't think this is something that can be addressed with noise floor settings. Hoping you can get this figured out. Additionally, I was using the original soundanalyzer.h files for m5 stack for other esp32 boards. Perhaps that code could be kept. and re-named as misc
20240713_045324_resized
20240713_051315_resized
-digital mic or other. Just my 2 cents.

Craig

@davepl
Copy link
Contributor Author

davepl commented Jul 14, 2024 via email

@rbergen
Copy link
Collaborator

rbergen commented Jul 16, 2024

Merging after out-of-band alignment with @davepl.

@rbergen rbergen merged commit a96ab44 into PlummersSoftwareLLC:main Jul 16, 2024
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New M5StickC Plus2 doesn't work Update from M5Core2 to M5Unified
4 participants