Examples of how to use arduboy.drawBitmap()

Thanks to everyone posting such useful information here. Even though I’ve read every single post on how to draw a bitmap, I’m still not getting it. There are no errors when compiling the sketch, but there’s no image either. I’ve used the browser based tool for converting the PNG file and included the bitmap.cpp and bitmap.h files in the folder. And I know the function is documented in a post, but not exactly how it should be implemented. Would someone be nice enough to post some examples with how they got it working? TIA

Hey Darrell

Do you by chance have the source for what you have tried so far? Maybe you have a github repository where we can view it for any errors? Gist is a pretty good way to share source ( https://gist.github.com/ )

If you don’t want it shared on the web, the IRC channel is a good place to share links and you’ll find a couple of users who will help you out if you hang out for a minute.

1 Like

Darrell all you should need is this example just substitute the variables for your own.

This is to draw a 128 wide by 64 pixel tall bitmap called “bitmap_name” at the origin which is the upper left hand corner. If you have a correctly formatted image it should fill the screen. Feel free to paste in what you’re getting from the bitmap tool if you think that’s a problem.

Give this a shot and let us know where you end up:
#include “arduboy.h”
#include “bitmap.cpp”

void setup() {
  arduboy.start();
  arduboy.drawBitmap(0,0,bitmap_name,128,64,1);
  arduboy.display();
}

My guess is you may have been missing the display() call at the end, I often forget it myself :slight_smile:

3 Likes

If the browser based image converter that you used is this one
http://www.andrewlowndes.co.uk/blog/graphics/arduboy-image-converter

Then you’ll want to use the drawSlowXYBitmap() call.

Check out my ‘setup’ call https://github.com/andrewlow/flappyhalloween/blob/master/flappyhalloween.ino#L74 it draws a full screen bitmap that I converted using the web converter above.

1 Like

Perfect! It was a combination of both things. Once I got the display() function in the right place and then switched to drawSlowXYBitmap(), it worked!

It’s a fun little sketch called Eight Ball Magic - feel free to tinker around with it:

Thanks @ekem, @bateske and @Roo

2 Likes