Home Resources

Drawing Bitmaps onto the OLED Screen ( PART I )

 Overview

This is a short tutorial that goes through how to store bitmap images into the available external memories, namely the MMC card (SD-Compatible) and the Dataflash chip, and then access these bitmaps and draw it to the OLED screen.


In PART I, we’ll cover using the MMC card.


What you would need:

Hardware

  • BlazingCore100 Board
  • 2.83” OLED w/ Touch Screen Interface Board
  • Serial Comm.Key
  • Power Supply (6V – 9V DC)


Software

  • Sonata IDE

 

In this tutorial, we’ll be using the image as shown below;

File Name: Peony.bmp
Resolution: 320 x 240 pixels

 

Storing the Bitmap Images into the MMC Card
Make sure you have a couple of images prepared beforehand that you’d like to draw onto the OLED screen.
PS: Only images of bitmap extensions (.bmp) are allowed. Max Resolution (320 * 240 pixels)
PPS: Filenames should not exceed 8 letters in length! (Not including the extension)

  1. Insert your MMC card into your card-reader.  
  2. Using Windows® Explorer, locate the drive of your MMC Card.
  3. Drag and drop your bitmap files into the root directory of the MMC card.


Remove the MMC card from your card reader and slot it into the Memory card socket on the OLED board.


Initialising the MMC Card
We will need to initialise the memory card before we can use it.  MCard.Init() does just that.
It will return a value stating if the initialisation is successful, or if there was an error (eg, Card not found etc.)
If successful, the value returned should be (-1).

BC CodeCode:

Public Sub Main()
I = MCARD.INIT()
DEBUG.PRINT "INIT ";CSTR(I) 'I = Success/Error
End Sub

We will need to declare a point and string variable.
Assign the Point variable a position of [0,0]. We will start drawing the bitmap from 0,0.
Next, assign the string variable with the name of the bitmap to draw onto the screen. In this case, we’ll use “Peony.bmp”.

Drawing the Bitmap to Screen

 I = OLED.Draw.BitmapFromMCard(FileName,Position)

Parameters:

  • FileName:  Name of Bitmap File in String
  • Position: Point XY location to draw bitmap


Returns; results of operation. I = (-1) = successful.

BC CodeCode:

Dim P1 As Point
Public Sub Main()
Dim I As Integer
Dim STR1 AS STRING
OLED.Init(0)

I = MCard.Init()
STR1 = "Peony.bmp"
P1.X = 0
P1.Y = 0
I = OLED.Draw.BitmapFromMCard(STR1, P1)
End Sub

And that’s it!

PART II will cover how to draw bitmaps that are stored in the dataflash chip (onboard the BCore Board) to screen.