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

Design considerations #5

Closed
Pimmetje opened this issue Jun 1, 2018 · 3 comments
Closed

Design considerations #5

Pimmetje opened this issue Jun 1, 2018 · 3 comments
Assignees

Comments

@Pimmetje
Copy link

Pimmetje commented Jun 1, 2018

First of all thanks for this library. It used some macro's i haven't seen before.
I use library's like this on atmel 328. Those have 1024 bytes of ram. So i always try to limit the memory usage to as little as possible.

So i have some questions as i do not fully understand the bidirectional registry.
U can read and write only one byte to the register. If u write one byte u would read the same byte back. Because it would set a low powered pullup or down it's a in and output at the same time.

At startup all pins are high. Given no pins are grounded it will give 0xFF.
So i only think u need two bytes or memory. One for (last) readed value. One for last written value. If i request the status i would be interested in the difference between the two.
Maybe it could be useful to track if a pin was output or input. But on the other hand it does not matter for the device. So why spent a byte on it?

As for the status structure. Why use 8 bytes? 1 byte would do it?

It's not meant to criticize your work. I would like to learn from your considerations. And maybe mine can add something as well.

@xreef xreef self-assigned this Jun 2, 2018
@xreef
Copy link
Owner

xreef commented Jun 2, 2018

The stats structure is a complex structure more flexible and direct usable, and not all like bitwise operation.
When I have more time I add a little enhancement to remove that structure with define flag for low memory usage.

The input and output mask is to prevent human error, and help readability of code.

Thanks

xreef pushed a commit that referenced this issue Jun 2, 2018
Add variable to prevent use of complex structure and free 7 byte of mem.
@xreef
Copy link
Owner

xreef commented Jun 2, 2018

I add the define variable, if you decomment PCF8574_LOW_MEM on lib you use byte instead of complex structure.

@xreef xreef closed this as completed Jun 2, 2018
@Pimmetje
Copy link
Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants