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

I2C Expander #90

Open
dealero opened this issue Jul 14, 2019 · 2 comments
Open

I2C Expander #90

dealero opened this issue Jul 14, 2019 · 2 comments

Comments

@dealero
Copy link

dealero commented Jul 14, 2019

Hi, I'm using Arduino Leonardo and your Library works perfect! However I'd like to make MIDI controller using I2C expanders such as PCF8574. Is there possible to implement this? I tried to do this, but no success. In my MIDI controller I want to put 8 encoders with buttons and additionally 16 more switches.

@tttapa
Copy link
Owner

tttapa commented Jul 23, 2019

You can implement this rather easily by implementing the ExtendedIOElement interface:

virtual void pinMode(pin_t pin, uint8_t mode){};
virtual void digitalWrite(pin_t pin, uint8_t mode){};
virtual int digitalRead(pin_t pin){};
virtual analog_t analogRead(pin_t pin){};
virtual void analogWrite(pin_t pin, analog_t val){};
virtual void begin(){};
virtual void refresh(){};
virtual void reset(){};

The documentation of ExtIO in the MIDI Controller library is rather poor, so I'd recommend checking out its successor, the Control Surface library.

Take a look at the interface here:
https://github.com/tttapa/Control-Surface/blob/a310ba8a19a4b929c6ef7d4758bcc1bb70436b1b/src/Hardware/ExtendedInputOutput/ExtendedIOElement.hpp#L70-L142
You have to implement all pure virtual functions (virtual ... = 0;).

Take a look at how the AnalogMultiplex class is implemented:
https://github.com/tttapa/Control-Surface/blob/master/src/Hardware/ExtendedInputOutput/AnalogMultiplex.hpp

Do note that you can't use rotary encoders with I2C expanders, as they require interrupts. You could implement it, but it's not supported by the library.

@cferrarini
Copy link

I´m trying to address some digital pins to a PCF8574 i2c port expander but my programing skills are not so good, maybe some ready library could create virtual i2c pins so this midi library would not need to include the i2c code and would see them as regular pins. Any ideas?

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

No branches or pull requests

3 participants