Giter VIP home page Giter VIP logo

Comments (7)

supersjimmie avatar supersjimmie commented on August 27, 2024 1

Just to do something, I started to make a small library that melts your brzo library and the old Wire together. It creates a new class called Wire2 (because it cannot be named Wire). So in an Arduino code, you need to include this translating library and rename any Wire to Wire2.
I will call this library Wire2brzo. So instead of #include <Wire.h> it's going to be #include <Wire2brzo.h>. Then everything works with the object Wire2 and functions like Wire2.begin().

That was the easy (but not for me) step.

Next, more difficult, step is to let my library do the same as the original Wire library by using your code.
I'll start my attempt with the base functions like begin, write, read, beginTransmission, endTransmission. Next must be requestFrom. If I manage to get those working, all is enough as a replacement to test it with my problematic PN532...

(Fingers crossed, I am not a programmer)

from brzo_i2c.

supersjimmie avatar supersjimmie commented on August 27, 2024

I think(...) that it's not very hard to replace these 'Wire' like functions:

begin
beginTransmission
endTransmission
write / send
read / receive

With those respectively:

brzo_i2c_setup
brzo_i2c_start_transaction
brzo_i2c_end_transaction
brzo_i2c_write
brzo_i2c_read

More a problem will be Wire like functions as:

requestFrom

And I think these Wire functions will need a lot of extra coding:

available
onReceive
onRequest

I would personally be happy if the first part and a requestFrom equivalent can be added somehow.

from brzo_i2c.

pasko-zh avatar pasko-zh commented on August 27, 2024

Yes, it's true, it would be nice to have a wrapper for a drop in replacement of the wire library and its methods.

When I started to develop brzo i2c I had this case in mind, of course. However on the other hand, there are some "concepts" in the wire library which I don't like (or either never fully understood). For instance, this asymmetry between sending and receiving bytes, i.e. .beginTransmission, and then only .write commands, no reads, and finally end this transmission with .endTransmission, where all the date is trasmitted over the i2c bus. Versus .requestFrom and then the read commands, where the bytes are read from the i2c slave; and no bracket for beginning and ending a transmission. Or, how errors are treated and reported back to the caller...

But, jumping over this "I don't like" stuff and thinking on ;-)

There are many overloads of the methods in the wire library. So, I think I/we would have to find a compromise which one should be made ported. For instance, you can write a single byte or as I did in brzo i2c, write from a buffer.

Then, overall, I need to think a bit more on how these two concepts could be married :-) But nothing is impossible!

from brzo_i2c.

FWeinb avatar FWeinb commented on August 27, 2024

@supersjimmie Thanks for your effort. That sound really great.
@pasko-zh
Just a usage question. I could not get it to work. I want to send some data from an existing uint8_t array like this:

  [... setup and begin ...]
    uint8_t  buffer[10] = [0,0,1,1,1,2,3,3,4,5];
    brzo_i2c_write(&buffer[4], 5, true);
  [... end ...]

That should send 1,2,3,3,4 right?

from brzo_i2c.

pasko-zh avatar pasko-zh commented on August 27, 2024

Not quite :-) In brzo_i2c_write it expects a pointer to a buffer, it then sends the n elements starting from the beginning of the buffer. (Inside the function I pass the pointer to the first element to the inline assembly, [r_adr_array_element] "+r" (&data[0]) ...
Maybe my use cases were a bit too narrow, but I thought one would always send n bytes from the beginning of the buffer. But I could change that...
EDIT: I will change this in the next version. Since I don't have a compiler/esp in front of me for the
next days it will take ~ 1 week.

EDIT 2: I have moved this to a new issue, #2 .

from brzo_i2c.

FWeinb avatar FWeinb commented on August 27, 2024

I would really like that. Maybe just expect a raw pointer (like memcpy) and dont do the (&data[0]) query in this library. Than one could just pass in a pointer that points to the start of the array you would like.

from brzo_i2c.

pasko-zh avatar pasko-zh commented on August 27, 2024

I have included a section in the wiki on "How to migrate from Wire Library", see here

from brzo_i2c.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.