Skip to content

Transaction #165

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Transaction #165

wants to merge 2 commits into from

Conversation

mzero
Copy link
Contributor

@mzero mzero commented Jan 14, 2020

The implementation of sending commands to the SSD1306 is factored out into a private Transaction class. This class gathers all the logic for handling sending multiple byte commands and data into one place.

This has several advantages:

  • Transactions are handled consistently throughout the code
  • Only one place needs to be touched if further connection methods (wire, SPI, etc..) are added
  • Code that sends commands (most of the rest of the file) is much easier to read
  • Compiled code is smaller, saving 100s of bytes of program memory.
  • Multi-command operations are more efficient

The second commit fleshes out the support for user code sending commands, so that multi-byte commands can be sent.

Addresses and fixes #164

@mzero
Copy link
Contributor Author

mzero commented Jan 14, 2020

oops - okay, documentation for the added things coming in a day or two....

void ssd1306_commandList(const uint8_t *c, uint8_t n);

class Transaction; // forward declartion
friend class Transaction;
Copy link
Contributor

Choose a reason for hiding this comment

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

This friendship has no effect. A member class already has private access to enclosing class.

Aside, I hope it is not necessary to have a comment explaining what a declaration is (line above).

@mzero mzero force-pushed the transaction branch 6 times, most recently from 8b13a9a to f739c8f Compare October 29, 2020 22:56
@mzero
Copy link
Contributor Author

mzero commented Oct 29, 2020

I have rebased this CL set to top of master... and fixed all the clang-format and doxygen issues.

mzero added 2 commits June 16, 2021 11:03
- this makes the code much more readable
- and ensures that transactions are always properly framed
- and makes multi-command transactions more efficient
- and as if that weren't enough, makes the compiled library smaller!
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.

refactor transaction code
2 participants