Page 1 of 1

Change Hardwire class to TwoWire

Posted: Thu Dec 07, 2017 5:43 am
by RogerClark
Currently the SoftWire.cpp / .h contains the TwoWire class and Wire contains the HardWire class

However its been pointed out that some libs directly instantiate TwoWire as the I2C class, and although this worked fine when we used software I2C as its class name was TwoWire, this no longer works since I changed the default to HardWire

See this PR ... 2/pull/399

Although this may break some things, I personally think it needs to be done, as I should have change HardWire to TwoWire when I changed HardWire to being the default.

Re: Change Hardwire class to TwoWire

Posted: Thu Dec 07, 2017 2:00 pm
by mrburnette
Snippet from my edited post of yesterday: ... 063#p38063
I have decided that I really don't care (anymore.)

Because there are constant forces pressing to change "this" or change "that" and I might as well accept that no one really cares about how or why things are the way they are ... folks just want what they want. Fortunately, I am a unique member and can do what the heck I want locally and I do not rely upon the forum or the STM32duino github cores for my own homebrew. Lastly, I'm tired... it is rare that I use the STM32F103 anymore... newer boards, more SRAM and more flash at the same or lower price-point of the Baite Maple Mini of 3 years ago. It is good to be eclectic.

The above being said, I do agree that if you broke something, it needs to be fixed.

Re: Change Hardwire class to TwoWire

Posted: Thu Dec 07, 2017 3:51 pm
by victor_pv
Haven't looked at the i2c code in a while, so I may be off.

Question, can't we have hardware and software like we did and have twowire be derived from either one of those, with some flag in the files? And not modify the software and hardwire classes any more.

Re: Change Hardwire class to TwoWire

Posted: Thu Dec 07, 2017 8:16 pm
by RogerClark
Yes. I believe I broke it.

I did not take into consideration that people would try to instantiate internal classes e.g. TwoWire

I checked and do not appear to document the TwoWire class as being an way of using Wire, but I suspect it’s fairly commonplace, and my mistake was not to rename Hardwire to TwoWire.

I simply changed that class that the published API “Wire” instance, was instantiated as.

I think the change needs to be made,but also, unlike last time, we better test the examples to make sure they compile after they change, as people have been using references to the LibMaple internal classes as well, in examples that I included via PR without fully realising the implications

Basiclally, I can’t read every line of code or even look in every file that is submitted by a PR. In some cases i have the hardware and I can compile and do a real test, but in a lot of cases the best I can do is compile.

But I don’t have time even to compile every example with every library submission