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

Code cleanup spi #119

Merged
merged 4 commits into from
Dec 18, 2019
Merged

Code cleanup spi #119

merged 4 commits into from
Dec 18, 2019

Conversation

PerMalmberg
Copy link
Owner

@PerMalmberg PerMalmberg commented Nov 30, 2019

@enelson1001 I've made some adjustments to the code after merging your PR into master. It's mainly C++-ifying it a bit. Would be great if you can have a look and try it out on your display as I don't have one myself.

Simply checkout the code-cleanup-SPI branch of Smooth.

- Renamed hello_world to starter_example since it clashes with IDF's component name.
- Changed NULL to nullptr.
- Use operator[] instead of at() since there should be no need to do index-checking.
- Use std::for_each instead of indexed loops.
- Updated README.md.
@@ -204,43 +202,45 @@ namespace smooth::application::display
// stack; we need this memory even when this function is finished because
// the SPI driver needs access to it even while we're already calculating
// the next line.
static std::array<spi_transaction_t, 6> trans;
static std::array<spi_transaction_t, 6> trans{};
Copy link
Owner Author

Choose a reason for hiding this comment

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

@enelson1001 I can't get the comment block below to make sense. trans is not on the stack, so we really shouldn't need to initialize it each time, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the delay I am in the USA and this week is Thanksgiving.
To be honest I just copied from esp-idf/examples/spi_master/main/spi_master_example_main.c without digging into the code. I can see that some of the trans can be initialized once but x1, x2, y1,y2, data and pre and post trans states would still need to be set every time.

  1. Seems better to remove comment. What would you like me to do?
  2. I updated my fork with git fetch upstream and did a git checkout code-cleanup-SPI. I tested the ili9341 with my M5Stack Demo 1 program and everything thing is still working.
  3. I have some other questions but will wait until we get your current question resolved.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Ok, I'll give it some thought. There is no rush, enjoy your stay.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I ended up simply removing comment.

@enelson1001
Copy link
Contributor

enelson1001 commented Dec 12, 2019 via email

@PerMalmberg
Copy link
Owner Author

If the code is general enough for use outside the M5 stack, then I'll welcome the PR.

at does bound checking. In this code we know the size of the vector so we don't need that extra overhead.

@PerMalmberg PerMalmberg merged commit f8b54da into master Dec 18, 2019
@PerMalmberg PerMalmberg deleted the code-cleanup-SPI branch December 18, 2019 17:54
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.

2 participants