Req: drawBitmaps inverse B&W on monochrome OLED display?

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
Adadonuts
 
Posts: 1
Joined: Wed Jun 18, 2014 12:38 pm

Req: drawBitmaps inverse B&W on monochrome OLED display?

Post by Adadonuts »

Hi

I've made some bitmaps for display on an SSD1306 Adafruit 128 x 64 monochrome OLED display.

I'd like to invert the displayed bitmaps (black <--> white), without inverting the rest of the screen.
(e.g. to show "collision" between two moving sprites).

Is there a command to "drawBitmap" as its inverse ?

(I'm hoping so: I've made a whole bunch of bitmaps, and individually defining a corresponding new "inverse" bitmap for each one will take a lot of time and Arduino memory...)

Have been unable to find an answer to this on the forum & web, and would be grateful for your expert help

Many thanks in anticipation

Dave
(UK)

(I'm using an Arduino Uno with Include files: SPI.h, Wire.h, Adafruit_GFX.h and Adafruit_SSD1306.h)

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Req: drawBitmaps inverse B&W on monochrome OLED display?

Post by adafruit_support_rick »

No such command, You are more than welcome to hack the library to add that functionality, however!

Hazender
 
Posts: 2
Joined: Thu Jul 31, 2014 11:31 am

Re: Req: drawBitmaps inverse B&W on monochrome OLED display?

Post by Hazender »

Hellos in case someone would like to know more.

This simple change of DrawBitmap code works :

Code: Select all

void drawInvertBitmapColor(int16_t x, int16_t y,
            const uint8_t *bitmap, int16_t w, int16_t h,
            uint16_t color) {

  int16_t i, j, byteWidth = (w + 7) / 8;

  for(j=0; j<h; j++) {
    for(i=0; i<w; i++ ) {
      if((pgm_read_byte(bitmap + j * byteWidth + i / 8) & (128 >> (i & 7)))==0) {
        display.drawPixel(x+i, y+j, color);
      }
    }
  }
}
Sorry for my English and thank you has googletrad

User avatar
yerevan
 
Posts: 3
Joined: Wed Aug 22, 2012 1:01 am

Re: Req: drawBitmaps inverse B&W on monochrome OLED display?

Post by yerevan »

Thank you Hazender,
I tried use your function to able to make same thing which did this guy.
https://www.youtube.com/watch?v=FW2Ft24 ... oOS2FBScOQ
The first part is showing how bitmap is inverting when white bar is flowing it.
Anyway I don't able to do it and asking your help.
Can you please recreate your function which will dynamically invert any of bitmap?
Thanks in advance.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”