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

Menagerie of changes - Stocks effect, AMOLED support, etc. #626

Merged
merged 27 commits into from
May 20, 2024

Conversation

davepl
Copy link
Contributor

@davepl davepl commented May 13, 2024

Description

Adds a new Stock effect and the required API, as well as AMOLED S3 support

Contributing requirements

  • 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.

@davepl davepl requested a review from rbergen May 13, 2024 03:33
Copy link
Contributor

@robertlipe robertlipe left a comment

Choose a reason for hiding this comment

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

Looks good! Nice use of modern C++ for time. Minor style bits for consistency.

(Oh, and use "changes" in title.)

{
// Lambda to split the symbols string by comma, because somehow this is cooler than strtok() was in 1989
// and I want to flex, but also because strtok() is not thread-safe and we're using threads here. So there.
// Also, I'm using std::string here because std::getline() is easier to use with std::string than with String.
Copy link
Contributor

Choose a reason for hiding this comment

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

Fwiw, I have very similar code sitting in a branch for the same reasons. Expect to see something like this in utils some day.


// GetAllQuotes
//
// Retrieves all quotes for the given list of symbols, provided as a comma-separated string
Copy link
Contributor

Choose a reason for hiding this comment

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

Please end sentences in periods throughout.

system_clock::time_point lastUpdate; // Time of last update
system_clock::time_point nextFetch = system_clock::now(); // Time of last quote pull

std::map<String, StockData> stockData; // map of stock symbols to quotes
Copy link
Contributor

Choose a reason for hiding this comment

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

Bonus points for modern time handling. SO much easier to read than struct timeval.

}
else
{
Serial.printf("Failed to parse JSON: %s\n", error.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider DebugE so it shows in red.

}
else
{
Serial.printf("[HTTP] GET failed, error: %s\n", http.errorToString(httpCode).c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Likewise.

g()->fillScreen(BLACK16);
g()->fillRect(0, 0, MATRIX_WIDTH, 9, g()->to16bit(CRGB(0,0,128)));

// Periodically refecth the stock data from the server
Copy link
Contributor

Choose a reason for hiding this comment

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

Typos.

}

void drawPixel(int16_t x, int16_t y, uint16_t color) override
{
if (isValidPixel(x, y))
leds[XY(x, y)] = from16Bit(color);
else
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these just become asserts as they indicate a programming error?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, they're not always. The error messages were removed because a dependency that can be used to move text across the panel doesn't do boundary checking. With the validity check already ignoring out of bounds pixels, it seemed unnecessary to also create a lot of debugging noise.

@@ -1326,7 +1312,7 @@ extern RemoteDebug Debug; // Let everyone in the project know about it

#define USE_M5DISPLAY 1 // enable the M5's LCD screen

#elif ESP32FEATHERTFT || PANLEE || LILYGOTDISPLAYS3
#elif USE_TFTSPI || ESP32FEATHERTFT || PANLEE || LILYGOTDISPLAYS3
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider just moving use-tftspi into those three build definitions?

We have a constant tension of the build and the config trying to outsmart each other...

platformio.ini Outdated
upload_port =
monitor_port =
upload_port =
monitor_port =
Copy link
Contributor

Choose a reason for hiding this comment

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

No trailing spaces, please. This causes diff thrash.

-DLV_CONF_PATH="../../../../include/amoled/lv_conf.h"
-DLV_CONF_INCLUDE_SIMPLE
${psram_flags.build_flags}
${unity_double_flags.build_flags}
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this have to do with Unity?

@davepl
Copy link
Contributor Author

davepl commented May 13, 2024 via email

@davepl
Copy link
Contributor Author

davepl commented May 13, 2024 via email

Copy link
Contributor

@robertlipe robertlipe left a comment

Choose a reason for hiding this comment

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

Esp32-s3 has simd.

Std:algorithm is almost always clearer to a reader and is usually computationally a win.

@davepl
Copy link
Contributor Author

davepl commented May 13, 2024 via email

@Thermotronica
Copy link

Thermotronica commented May 13, 2024 via email

@robertlipe
Copy link
Contributor

robertlipe commented May 14, 2024 via email

@davepl
Copy link
Contributor Author

davepl commented May 14, 2024 via email

@davepl
Copy link
Contributor Author

davepl commented May 14, 2024 via email

@robertlipe
Copy link
Contributor

robertlipe commented May 14, 2024 via email

@rbergen
Copy link
Collaborator

rbergen commented May 14, 2024

I've just pushed an update to this PR, which includes the following changes:

  • I made the stock data fetch thread a NetworkReader entry, saving us a thread
  • I trigger a stock data fetch on Init(), to have stock data ready before the stock effect is shown - unless it's the first up, which I don't think we can really address?
  • I made the stock server and stock symbol list stock effect settings. They're accessible in the UI via the cogwheel on the Stocks effect. Notes about this one:
    • I was able to get the HTTPClient to work with the port number added to the location string
    • If the list of ticker symbols is changed, an immediate reload of stock data is triggered
    • I removed the defaults for server and ticker symbols from secrets(.example).h, as we did before with the identifiers for the Subscriber effect - those are effect settings too.
    • I refactored the way settings specs for effect settings are provided by the effects in question. I think the new way is much easier as it hides a lot of the under-the-hood stuff that's in place in LEDStripEffect to save memory.
  • I modified the logic that decides when PatternStocks::Draw() cycles to the next stock. The old way made the effect "flip through" the configured stocks at high speed when the stock data was first loaded (or more accurately, if the stock data count increased while the effect was running).
    I now only move to the next stock (index) if the update interval passes or the current stock index may be invalid because we have less stock data available than before.
  • I fixed a bug in the NetworkReader implementation that meant it would try to retrieve data when WiFi wasn't up (yet).
  • I bumped some actions in the GitHub workflow to a higher version as the previous action versions were using Node.JS 16, which is now deprecated.

I note that the CI build of the heltecv3demo project started failing sometime during today - this is unrelated to the last bullet in the list of changes I just mentioned. The error message is that pins_arduino.h cannot be found for that project, and Google seems to say that this is always caused by an underlying problem (board or platformio.ini configuration).

This could be a temporary issue that is located and is to be fixed in a dependency. If it persists until the time this PR is ready to merge otherwise, I will exclude the heltecv3demo project from CI builds for the time being.

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.

Looks good to me, with the suggestion to either finish or remove the UPC block at the end of README.md.

Also, I think we should wait a day or two to see if heltecv3demo will start building again before we proceed with merging this.

README.md Outdated
Comment on lines 400 to 407

UPC Codes
-----------------------------------------------------------------------------
1 646680745383 MESMERKIT Mesmerizer Kit w/64x32 Matrix, Remote, Receiver
2 646680745390 MESMERPCB Assembled PCB Only
3 646680745406
4 646680745413
5 646680745420
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this be work in progress, or an accidental paste? It seems a bit lost here...

}

void drawPixel(int16_t x, int16_t y, uint16_t color) override
{
if (isValidPixel(x, y))
leds[XY(x, y)] = from16Bit(color);
else
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, they're not always. The error messages were removed because a dependency that can be used to move text across the panel doesn't do boundary checking. With the validity check already ignoring out of bounds pixels, it seemed unnecessary to also create a lot of debugging noise.

@rbergen rbergen changed the title Menagerie of changed - Stocks effect, AMOLED support, etc. Menagerie of changes - Stocks effect, AMOLED support, etc. May 14, 2024
@rbergen
Copy link
Collaborator

rbergen commented May 19, 2024

I've removed the UPC block from the README as I suggested. As the heltecv3demo build still fails for a reason that must be rooted in a dependency, I've disabled CI for that env for the time being.

Barring any objections, I will merge this PR in its current state tomorrow (May 20, 2024) morning (GMT+2).

@rbergen rbergen merged commit 48ac73c into PlummersSoftwareLLC:main May 20, 2024
35 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.

None yet

4 participants