oledswitch  2.0.0.0
Main Page

OLED Switch click

If you are building any type of human machine interface, OLED Switch click can help you keep the design simple, clear and interactive. It can be used in designing a control panel for an industrial machine… or a DIY arcade.

click Product page


Click library

  • Author : MikroE Team
  • Date : Feb 2020.
  • Type : SPI type

Software Support

We provide a library for the OledSwitch Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.

Library Description

This library contains API for OledSwitch Click driver.

Standard key functions :

  • Config Object Initialization function.

    void oledswitch_cfg_setup ( oledswitch_cfg_t *cfg );

  • Initialization function.

    OLEDSWITCH_RETVAL oledswitch_init ( oledswitch_t *ctx, oledswitch_cfg_t *cfg );

  • Click Default Configuration function.

    void oledswitch_default_cfg ( oledswitch_t *ctx );

Example key functions :

  • This function writes to control and configuration registers on the chip.

    oledswitch_reg_write ( oledswitch_t *ctx, uint8_t *write_buf, uint8_t len );

  • This function sets the digital output signal for the PWM pin.

    void oledswitch_digital_write_pwm ( oledswitch_t *ctx, uint8_t signal );

  • This function sets the digital output signal for the RST pin.

    void oledswitch_digital_write_rst ( oledswitch_t *ctx, uint8_t signal );

Examples Description

This example showcases how to configure and use the OLED Switch click. This click is a combination of a button and a full color organic LED display. Displays settings are first loaded onto the chip and after that you can show any 64x48 pixel image on the display.

The demo application is composed of two sections :

Application Init

This function initializes and configures the click modules. In order for the click to work properly, you need to configure display and power settings. The full initialization of the chip is done in the default_cfg(...) function.

{
// Click initialization.
OLEDSWITCH_MAP_MIKROBUS( cfg, MIKROBUS_1 );
oledswitch_init( &oledswitch, &cfg );
}

Application Task

This function shows the user how to display images on the OLED screen. Every image you'd like to display needs to have a resolution of 64x48 and be stored in a 6144 cell array.

Note

Every pixel on the OLED screen is displayed at the time of writing to the chip (PWM 1). Displaying speed can be directly controled by adding delays in the for loop section of the draw_image(...) function.

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.OledSwitch

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all Mikroelektronika compilers, or any other terminal application of your choice, can be used to read the message.


application_init
void application_init()
Definition: main.c:42
OLEDSWITCH_MAP_MIKROBUS
#define OLEDSWITCH_MAP_MIKROBUS(cfg, mikrobus)
Definition: oledswitch.h:67
oledswitch_init
OLEDSWITCH_RETVAL oledswitch_init(oledswitch_t *ctx, oledswitch_cfg_t *cfg)
Initialization function.
oledswitch_cfg_setup
void oledswitch_cfg_setup(oledswitch_cfg_t *cfg)
Config Object Initialization function.
array_green
const uint8_t array_green[6144]
Definition: oledswitch_image.h:389
application_task
void application_task()
Definition: main.c:54
oledswitch_default_cfg
void oledswitch_default_cfg(oledswitch_t *ctx, uint8_t buffer_size)
Click Default Configuration function.
array_red
const uint8_t array_red[6144]
Definition: oledswitch_image.h:776
array_blue
const uint8_t array_blue[6144]
Definition: oledswitch_image.h:2
oledswitch_draw_image
void oledswitch_draw_image(oledswitch_t *ctx, const uint8_t *image_buf, uint16_t image_size)
Register write function.
OLEDSWITCH_BUFFER_SIZE_SMALL
#define OLEDSWITCH_BUFFER_SIZE_SMALL
Definition: oledswitch.h:159
OLEDSWITCH_IMG_SIZE_NORMAL
#define OLEDSWITCH_IMG_SIZE_NORMAL
Definition: oledswitch.h:175
oledswitch_cfg_t
Click configuration structure definition.
Definition: oledswitch.h:267