You are reading a single comment by @DrAzzy and its replies. Click here to read the full conversation.
  • Yeah - read2(adr) makes no sense to me, when it could be read(adr,2) - only then you can read as many as you want.

    Currently my modules have these functions:
    readc(bytes) -Continues read from where it last read from.
    reads(address,bytes) -works like read(), but reads 64 bytes at a time and converts to string.
    writes(address,data) -writing a string is faster than an array, as we have to convert the array to a string.
    writel(address,data) -write long block of data (more than 1 page), supplied as string.

    My thinking for the overhaul is:

    Remove readc(), and instead allow read(,bytes) to have same functionality (should be easy).

    Combine writeb() and writes() and detect the type of the data, and react appropriately. I think this will also shrink code size.

    That leaves reads() and writel()

    reads() is necessary to read long strings, because you need to read those piecewise and convert to string, and combine those, since you don't have the memory to read it in all at once as a simple array. I'm still thinking about what the right way to handle this is.

    writel() handles long writes (ie, ones longer than a page). I think I can probably make writel smart enough to determine when it needs to do this.

    I'm also toying with the idea of a couple of helper functions that you could add if you need, like easy ones for converting to signed/unsigned 16 bit numbers and stuff, whether in the modules, or in a second module (that would add methods to the first, like the font modules do).

    Re: small AT24's: Ones with 12-19 bits of address space are addressed using 2 bytes of data and up to 3 bits of the device address. Ones with 11 or less bits of address space are addressed using 1 byte of data and up to 3 bits of the device address. I hadn't given much thought to how to do this before, but there may be an easy way of doing it that I hadn't thought of before.


Avatar for DrAzzy @DrAzzy started