0.9" 128 x 32 Serial I2C uOLED Display (HCMODU0118 & 119)

LCD, TFT, OLED, LED modules
Post Reply
admin
Site Admin
Posts: 748
Joined: Sun Aug 05, 2012 4:02 pm

0.9" 128 x 32 Serial I2C uOLED Display (HCMODU0118 & 119)

Post by admin » Tue May 23, 2017 1:44 pm

Image


Image

These tiny 0.9 inch uOLED displays have a resolution of 128 x 32 pixels and use a standard serial I2C interface (address = 0x3C) for communication. Based on the SSD1306 controller, the module is available in both white and blue pixel colours. By making use of OLED screen technology these displays are self illuminated and therefore require no back light. When compared to standard LCD and TFT technology they have significantly less power consumption and a significantly clearer display. If using with an Arduino board they are also compatible with our own HCOLED graphic library (see http://forum.hobbycomponents.com/viewto ... =58&t=1817)

Image Image



Image



Image


Product code: HCMODU0118 (white) HCMODU0119 (blue)
Module size: 38 x 12mm
High pixel density
Resolution: 128 x 32
Ultra-low power consumption: normal display 0.06W (far below the TFT display)
Wide supply range: DC 3V-5V (without any changes, directly compatible with common 3.3V and 5V power supply system)
Industrial grade: Operating temperature range -30 C ~ 70 C
5V tolerant interface.
OLED screen, internal drive chip: SSD1306


Image

1....GND: Power ground
2....VCC: 3.3V or 5V power supply
3....SCL: I2C Clock
4....SDA: I2C Data



Image

Code: Select all

/* FILE:    HCuOLED_Things_Example_For_HCMODU0118_HCMODU0119   
   DATE:    23/05/17
   VERSION: 0.1
   
REVISIONS:

123/05/17 Created version 0.1

This example is specifically written for the 128 x 64 pixel 0.9" OLED screens
(HCMODU0118 & HCMODU0119). The example uses the line and rectangle graphic 
functions together with the INVERT DrawMode to create a simple animation.

Please visit http://forum.hobbycomponents.com/viewtopic.php?f=58&t=1817
for more information on how to use all the features within this library.

To use this example connect your uOLED display to the following pins of your 
Arduino:


MODULE..........ARDUINO UNO
GND.............GND
VCC.............3.3V
SCL.............A5
SDA.............A4


You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used directly for the purpose of promoting products that
directly compete with Hobby Components Ltd's own range of products.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, 
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR
LACK OF NEGLIGENCE. HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE
FOR ANY DAMAGES INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR 
CONSEQUENTIAL DAMAGES FOR ANY REASON WHATSOEVER. */

#include "HCuOLED.h"
#include "SPI.h"


/* Array indexes for the X and Y coordinates */
#define X1 0
#define Y1 1
#define X2 2
#define Y2 3

/* Arrays to store coordinates and direction for the line, rectangle and bitmap */
byte Box[4] = {1,1,20,20};
byte BoxDir[4] = {1,1,1,1};
byte Line[4] = {100,25,120,15};
byte LineDir[4] = {-1,-1,-1,-1};
byte Bitmap[2] = {5,5};
byte BitmapDir[2] = {-1,-1};

/* I2C address of the display */
#define I2C_ADD 0x3C

/* Create an instance of the library */
HCuOLED HCuOLED(SSD1306_128_32, I2C_ADD);



void setup() 
{
  /* Reset the display */
  HCuOLED.Reset();
}

void loop() 
{
  /* Display some text using a large 4 line LCD style font */
  HCuOLED.Cursor(20,0);
  HCuOLED.SetFont(LCDLarge_24pt);
  HCuOLED.Print("HCuOLED");

  /* Display some text using a small 8x8 fixed width font */
  HCuOLED.SetFont(Terminal_8pt);
  HCuOLED.Cursor(36,25);
  HCuOLED.Print("LIBRARY");

  HCuOLED.Rect(21,25,32,31, SOLID);
  HCuOLED.Rect(96,25,107,31, SOLID);
 

  /* Change the draw mode from NORMAL to INVERT */
  HCuOLED.DrawMode(INVERT);
  while(1)
  {
    /* Move the positions of the 3 objects */
    MoveRect();
    MoveLine();
    
    /* Draw the objects to the display buffer */
    HCuOLED.Rect(Box[X1],Box[Y1],Box[X2],Box[Y2], SOLID);
    HCuOLED.Line(Line[X1],Line[Y1],Line[X2],Line[Y2]);
    
    /* Write the display buffer to the screen */
    HCuOLED.Refresh();
    
    /* Draw the objects again. As we are in INVERT mode this will remove them */
    HCuOLED.Rect(Box[X1],Box[Y1],Box[X2],Box[Y2], SOLID); 
    HCuOLED.Line(Line[X1],Line[Y1],Line[X2],Line[Y2]);
  }
}


/* Update the X and Y coordinates for the box */
void MoveRect(void)
{
  if(Box[X1] == 0 || Box[X1] == 127)
    BoxDir[X1] *= -1;
  Box[X1] += BoxDir[X1];
  
  if(Box[Y1] == 0 || Box[Y1] == 31)
    BoxDir[Y1] *= -1;
  Box[Y1] += BoxDir[Y1];
  
  if(Box[X2] == 0 || Box[X2] == 127)
    BoxDir[X2] *= -1;
  Box[X2] += BoxDir[X2];
  
  if(Box[Y2] == 0 || Box[Y2] == 31)
    BoxDir[Y2] *= -1;
  Box[Y2] += BoxDir[Y2];   
}

/* Update the X and Y coordinates for the Line */
void MoveLine(void)
{
  if(Line[X1] == 0 || Line[X1] == 127)
    LineDir[X1] *= -1;
  Line[X1] += LineDir[X1];
  
  if(Line[Y1] == 0 || Line[Y1] == 31)
    LineDir[Y1] *= -1;
  Line[Y1] += LineDir[Y1];
  
  if(Line[X2] == 0 || Line[X2] == 127)
    LineDir[X2] *= -1;
  Line[X2] += LineDir[X2];
  
  if(Line[Y2] == 0 || Line[Y2] == 31)
    LineDir[Y2] *= -1;
  Line[Y2] += LineDir[Y2];   
}


Image

HCuOLED Arduino library for above sketch is available for download from the software section of our support forum here:

http://forum.hobbycomponents.com/viewto ... =58&t=1817

Or from github here:
https://github.com/HobbyComponents/HCuOLED



Diagrams, libraries, and example code are provided as an additional free service by Hobby Components and are not sold as part of this product. We do not provide any guarantees or warranties as to their accuracy or fitness for purpose.

Descriptions and diagrams on this page are copyright Hobby Components Ltd and may not be reproduced without permission.

pvrancke
Posts: 3
Joined: Tue Oct 01, 2013 3:27 pm

Re: 0.9" 128 x 32 Serial I2C uOLED Display (HCMODU0118 & 119)

Post by pvrancke » Sat Jan 05, 2019 11:36 am

Hello,
I tried to compile for ESP8266/Wemos D1 or Adafruit Huzzah but get the following error:

Arduino: 1.8.2 (Windows 10), Board: "WEMOS D1 & mini, 80 MHz, 921600, 4M (3M SPIFFS), Disabled, None"

In file included from C:\Users\cttp\Documents\Arduino\libraries\HCuOLED-master\HCuOLED.cpp:41:0:

C:\Users\cttp\Documents\Arduino\libraries\HCuOLED-master\fonts.h:3114:1: error: cannot convert 'const uint16_t* {aka const short unsigned int*}' to 'const unsigned int*' in initialization

};

^

C:\Users\cttp\Documents\Arduino\libraries\HCuOLED-master\HCuOLED.cpp: In static member function 'static void HCuOLED::SetFont(const byte*)':

C:\Users\cttp\Documents\Arduino\libraries\HCuOLED-master\HCuOLED.cpp:807:19: error: cannot convert 'const unsigned int* const' to 'const uint16_t* {aka const short unsigned int*}' in assignment

_FontDescriptor = Terminal_8ptFontInfo.Descriptors;

^

C:\Users\cttp\Documents\Arduino\libraries\HCuOLED-master\HCuOLED.cpp:812:19: error: cannot convert 'const unsigned int* const' to 'const uint16_t* {aka const short unsigned int*}' in assignment

_FontDescriptor = MedProp_11ptFontInfo.Descriptors;

^

C:\Users\cttp\Documents\Arduino\libraries\HCuOLED-master\HCuOLED.cpp:817:19: error: cannot convert 'const unsigned int* const' to 'const uint16_t* {aka const short unsigned int*}' in assignment

_FontDescriptor = LCDLarge_24ptFontInfo.Descriptors;

^

exit status 1
Error compiling for board WEMOS D1 & mini.

Can you help me ?
thanks !!
patrick

andrew
Site Admin
Posts: 911
Joined: Sun Aug 05, 2012 4:15 pm

Re: 0.9" 128 x 32 Serial I2C uOLED Display (HCMODU0118 & 119)

Post by andrew » Sun Jan 06, 2019 9:51 am

I've been able to replicate the problem and have uploaded an updated version of the library. I don't have access to a display to test it with at the moment but hopefully it has fixed the issue.

You can download the new version (V0.5) from the software section of the forum here:

viewtopic.php?f=58&t=1817&p=4337

Don't use the github link as I've not updated it there yet, just use the V0.5 link in the first post of the above thread.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

pvrancke
Posts: 3
Joined: Tue Oct 01, 2013 3:27 pm

Re: 0.9" 128 x 32 Serial I2C uOLED Display (HCMODU0118 & 119)

Post by pvrancke » Sun Jan 06, 2019 4:03 pm

Dear Andrew,
it compiles and works !!
thanks a lot !

andrew
Site Admin
Posts: 911
Joined: Sun Aug 05, 2012 4:15 pm

Re: 0.9" 128 x 32 Serial I2C uOLED Display (HCMODU0118 & 119)

Post by andrew » Mon Jan 07, 2019 12:01 pm

Great, and thanks for letting me know.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Post Reply