Change Hardwire class to TwoWire

Post Reply
User avatar
RogerClark
Posts: 7478
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Change Hardwire class to TwoWire

Post by RogerClark » Thu Dec 07, 2017 5:43 am

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

https://github.com/rogerclarkmelbourne/ ... 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.

User avatar
mrburnette
Posts: 1885
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: Change Hardwire class to TwoWire

Post by mrburnette » Thu Dec 07, 2017 2:00 pm

Snippet from my edited post of yesterday: http://stm32duino.com/viewtopic.php?f=3 ... 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.

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

victor_pv
Posts: 1746
Joined: Mon Apr 27, 2015 12:12 pm

Re: Change Hardwire class to TwoWire

Post by victor_pv » Thu Dec 07, 2017 3:51 pm

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.

User avatar
RogerClark
Posts: 7478
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Change Hardwire class to TwoWire

Post by RogerClark » Thu Dec 07, 2017 8:16 pm

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 Arduino.cc 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

Post Reply