This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Generating an array for use with an LCD

I'm working on a project using an AT89C51CC03 to drive an LCD (SED1330 based). I'm using Bresenhams Line Drawing Algorithm to calculate where a straight line should go given start & end points. The algorithm writes to a character array where it draws a '*' if the line is supposed to go there and a *-* if the pixel (array element) will be empty.

To send the finished line to the screen, it needs to be in bit format, ie each '*' needs to be a 1 and an empty pixel 0. How can I address a big array (64 x 64 pixels in the end) like this? I don't mind writing the line image to an array then transferring it to a 1D bitmap array which I will then send to the screen.

Cheers.

Parents
  • You cannot, unfortunately, have arrays of bits, even with the 8051 bit-addressable memory. (The architecture lacks a pointer-to-bit, so there's no real way to implement C array semantics using the 8051 feature.)

    But all is not lost, as you can just roll your own data structure, and use mod (%), div (/), and bitmasks to set individual bits.

    // set bit
    array[i / 8] |= 1 << (i % 8);
    // clear bit
    array[i / 8] &= ~(1 << (i % 8));

    I'd skip the ASCII representation entirely. There's no need for it.

Reply
  • You cannot, unfortunately, have arrays of bits, even with the 8051 bit-addressable memory. (The architecture lacks a pointer-to-bit, so there's no real way to implement C array semantics using the 8051 feature.)

    But all is not lost, as you can just roll your own data structure, and use mod (%), div (/), and bitmasks to set individual bits.

    // set bit
    array[i / 8] |= 1 << (i % 8);
    // clear bit
    array[i / 8] &= ~(1 << (i % 8));

    I'd skip the ASCII representation entirely. There's no need for it.

Children