esp8266 / esp8266/Arduino

suggestion , do not deprecate wire.pins()

Open
#2,774 2 comments 2 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
16.7k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

I notice wire.pins() is marked deprecated.

Please consider, I did not see an explanation for reasoning, maybe I missed it.

A lot of libraries have a Wire.begin() inside their own `begin()` or init function.
Then they immediately send initialization codes to lcds or oleds.

Short of modifying libraries, or pushing authors to have to modify their code to include arguments for passing through sda and scl, there is no way other than calling pins() or begin() before the libraries begin() to change the pins. Also to be pedantic `begin` is now being called twice once for just kludging the pins then inside the library using wire and also makes it confusing if you wanted to toggle pins back and forth so you can use twi on 2 buses.

It is easier to do something like ( granted this is not ideal but if you must use twi twice )
```
//init
Wire.begin(0,1);
Wire.begin(3,4);
Wire.setSpeed(400000); // must be reset after a begin always !

lcd.begin();

lcd.write(blargh);
Wire.pins(0,1); // dynamic pin reassignment WITHOUT calling twi_init and losing custom clock or stretch coding.
lcd.write(blargh);
```

❗️ So another issue with calling begin is that it hardcodes clock and stretch in twi_init, so you must keep redoing those. This might be another "bug" that can be improved by using twi_dcount and twi_clockStretchLimit in twi_init instead of hardcoded values, and init those globals instead.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.