eta-systems / MAX7313-Arduino

Arduino Library for the MAX7313 Port Expander

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Read Input

jhnwmr opened this issue · comments

Hello, the library is very helpful so far.
However, I have a problem with reading out inputs.
I need a bit mask for the exact evaluation of the inputs.
As it is currently in the library, only a numerical value from 0-255 is output.
Do you have a possibility to improve the whole thing, so that one gets only a simple HIGH or LOW for each input?

Many thanks

Thanks for the comment. Lovely to hear that this piece of software is actually used out there.
At our company we only used the PWM output feature of this port expander. So this slipped our minds.
I see where the issue lies: max7313.cpp#L118

You could implement the bit mask right there yourself and send a pull request.

Ah yes, probably needs an if-clause because it is two different 8-bit registers for all 16 I/Os
max7313.h#L50

Thank you for the answer.
Do you have experience with bit masks?
Unfortunately, I have no experience and don't know how to do it yet.
Maybe you can give another approach.

I just implemented something that should work. Apparently it did not even read the chip but just returned a constant. Good job finding this issue.

max7313.cpp#L117
Can you understand and verify what I did?
Or better yet, do you have a board where you can test the updated function?

I have an ESP32 on which I test everything and I just tried the code change. It works!
Now every input has 0 or 1, just as I imagined.
Thanks!

Perfect, have fun experimenting