Assuming you're using Windows you can use ‘The Dot Factory’ to convert your bitmap. This can be downloaded from here:
http://www.eran.io/the-dot-factory-an-l ... generator/
Disclaimer: Links to external websites and software are used at your own risk.
Open the program and in the left hand window pane click the image tab to import a bitmap.
Note that your graphic should be a two colour (BW) bitmap that is smaller than the resolution of the display.
In the right hand pane click the wrench icon which can be found in the top right hand corner of the pane.
In the settings window that opens up, for the Byte settings, make sure you have Bit Layout set to 'ColumnMajor' and Order set to 'MsbFirst'
Click the apply button to close the settings window and then click the generate button to generate the bitmap data. You can then cut and paste the array it generates into your sketch.
For the HCuOLED.Bitmap(pixelCols, byteRows, bitmapName) function, it takes 3 parameters:
pixelCols is the horizontal resolution of your bitmap in pixels. For the example pasted below it is 20 pixels wide.
byteRows is the vertical resolution of your bitmap divided by 8. For the example below the vertical resolution is 32 pixels / 8 = 4
bitmapName is the name of the array used to store the bitmap.
Here is an example:
#include "HCuOLED.h"
#include "SPI.h"
/* Example bitmap */
const PROGMEM uint8_t bitmap[] =
{
// ######
// ##########
// ### ##
// ### ###
// ############
// ################
// ################
// ## ##
// ## ##
// ### ###### ###
// ### ######## ###
// ### ########## ###
// ### ###### ## ###
// ### #### ### ###
// ### ### ### ###
// ### ## #### ###
// ### ## #### ###
// ### ## ### ###
// ### ### ## ###
// ### #### ## ###
// ### #### ## ###
// ### ### ### ###
// ### ### #### ###
// ### ## ###### ###
// ### ########## ###
// ### ######## ###
// ### ###### ###
// ## ##
// ## ##
// ################
// ################
// ##########
0x00, 0x80, 0xE0, 0x60, 0x7C, 0x7E, 0x7E, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x7E, 0x7E, 0x78, 0x60, 0xE0, 0x80, 0x00,
0xFE, 0xFF, 0xFF, 0x00, 0x00, 0xF8, 0xFC, 0x7E, 0x3E, 0x1E, 0x1E, 0x8E, 0xEE, 0xFC, 0xF8, 0x00, 0x00, 0xFF, 0xFF, 0xFE,
0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x7C, 0x18, 0x80, 0x80, 0xC1, 0xE3, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
0x07, 0x1F, 0x7F, 0x60, 0x60, 0xE1, 0xE3, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE3, 0xE1, 0x60, 0x60, 0x7F, 0x1F, 0x07,
};
#define CS_DI 10
#define DC_DI 9
#define RST_DI 8
/* Create an instance of the library (uncomment one of the lines below) */
HCuOLED HCuOLED(SSD1307, CS_DI, DC_DI, RST_DI); // For SSD1307 displays (HCMODU0050 & HCMODU0052)
//HCuOLED HCuOLED(SH1106, CS_DI, DC_DI, RST_DI); // For SH1106 displays (HCMODU0058 & HCMODU0059)
void setup()
{
/* Reset the display */
HCuOLED.Reset();
HCuOLED.Cursor(0,0);
HCuOLED.Bitmap(20, 4, bitmap);
HCuOLED.Refresh();
}
void loop()
{
}
Note you’ll change how the software declares the array from this:
const uint_8 bitmap =
to this:
const PROGMEM uint8_t bitmap[] =
This will make sure the bitmap is stored in flash memory and not SRAM.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.