Coder Social home page Coder Social logo

Comments (4)

eulphean avatar eulphean commented on September 4, 2024 1

thanks

Thanks for explaining that, Richard. That's exactly what I was looking for :) Just a small correction. I think you probably meant (pageColumn == 0 && column == 3). Here's how I got it working. Not the cleanest solution but works smoothly.

static void display_bitmap(uint8_t address, const uint8_t *bitmap) {
    DisplayContext context;
    display_begin(&context, address, 0);

    for (int8_t pageRow = 0; pageRow < 8; pageRow++) {
        for (int8_t pageCol = 0; pageCol < 8; pageCol++) {
            display_bitmapSection(&context, bitmap, pageRow, pageCol);
        }
    }
}

void display_bitmapSection(DisplayContext *context, const uint8_t *bitmap, int8_t pageRow, int8_t pageColumn) {
    // Image matrix width and height.
    int8_t w = 16; int8_t h = 64;

    // 8-bit chunk that will be flushed to the display.
    uint8_t chunk = 0x0;

    // Draw the 16x8 pixel page at pageRow and pageColumn
    // Calculate the starting position based on pageColumn and pageRow variables. 
    int8_t startColumn = pageColumn * 2;
    int8_t startRow = pageRow * 8; 
    for (int8_t col = startColumn; col < startColumn + 2; col++) {
         for (int8_t bit = 0; bit <= 7; bit++) { // 8 columns in each column (2 HEX characters)
            for (int8_t row = startRow + 7; row >= startRow; row--) { // Start creating a chunk from the last bit in this column. That's how the OLED likes it. 
                int32_t idx = w * row + col;
                chunk = (chunk << 1) | (pgm_read_byte(&bitmap[idx]) >> (7 - bit)) & 0x01; // Bitwise operation to get the bit I need in the current column.
            }
            // Flush the 8 bit chunk.
            display_chunks(context, chunk, 1);
            // Reset chunk
            chunk = 0x0;
       }
    }
}

from wallet.

eulphean avatar eulphean commented on September 4, 2024

Hey Richard, any insights on this?

from wallet.

ricmoo avatar ricmoo commented on September 4, 2024

Heya! Sorry for the delay in responding...

We are working on an animatable bitmap format for the upcoming release and scripts to generate these bitmaps. It's a tight fit, but we think we can squeeze it into the final kilobyte of program space.

This will allow for better co-branding, for people who want their logo, with maybe a small spin or glimmer.

If you want to hack something in the meantime, you will want to use display_chunk, which writes a single column of a single page to the screen. Since there is not enough memory to store a back-buffer, we compute each page (16 columns, with 17 bytes, the first byte is 0x40 to indicate "draw the next page") on-the-fly.

It's a bit complicated, but I will try to give a quick overview of the drawing order. The screen is broken into pages, each page is 16 bytes, and each call to display_chunk will add the byte to the 17 byte buffer (includes a command byte of 0x40), and after 16 calls to display_chunk, will flush the page to the display.

There are 8 pages across, and 8 pages down for a total of 64 pages. Pages are drawn, left-to-right, top-to-bottom. Each page represents a 16x8 pixel portion of the screen, where each byte is one of the 16 columns. So, for example, to draw a vertical line from (3, 0) to (3, 64) you would need something like:

for pageRow in (0, 8):
    for pageColumn in (0, 8):
        for column in (0, 16):
            if pageColumn == 1 && column == 3:
                display_chunk(0xff);
            else:
                display_chunk(0x00); 

It's quite complicated, which is why we are working on making the API easier to deal with, and also compact, so that a fully animated bitmap can be sent over the BLECast payload, so it has to fit in about 700 bytes.

We have code right now for displaying images, but it is not ready for humans yet, but basically, we use a loop similar to the above and compute the virtual pixel for real pixel for each page and flush it at once. So, we draw 64 viewports, rendering the relevant portion of the image in each page.

Make sense? No worries if not... ;)

from wallet.

ricmoo avatar ricmoo commented on September 4, 2024

Oh yes! I did. :)

Glad it worked for you, that’s awesome. :)

from wallet.

Related Issues (14)

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.