
A class library for OLED on MARMEX_OB board. MARY拡張のMARMEX_OB基板のOLEDをmbed+MAPLE基板で動かすためのライブラリです.このサンプルではMAPLEに用意されているMARMEXスロットの1番に搭載したOLEDを制御するようになっています.詳細はCode&APIからソースやAPI詳細をご覧ください
MARMEX_OB_oled Class Reference
MARMEX_OB_oled OLED screen drawing class. More...
#include <MARMEX_OB_oled.h>
Public Types | |
enum | { ROWS = 15, COLS = 16, WIDTH = 128, HEIGHT = 128, SPI_FREQUENCY = 20000000 } |
General parameters for MARMEX_OB_oled. More... | |
enum | { OFF = 0, ON } |
Constants for power() function. More... | |
Public Member Functions | |
MARMEX_OB_oled (PinName mosi, PinName sclk, PinName cs, PinName rst, PinName power_pin) | |
Create a MARMEX_OB_oled object connected to specified SPI and DigitalOut pins. | |
int | putc (int c) |
Write a character to the LCD. | |
int | printf (const char *format,...) |
Write a formated string to the LCD. | |
void | foreground (int c) |
Set the foreground colour. | |
void | background (int c) |
Set the background colour. | |
void | reset (void) |
reset MARMEX_OB_oled | |
void | cls (void) |
Clear the screen and locate to 0,0. | |
virtual void | pixel (int x, int y, int colour) |
Set a pixel on te screen. | |
void | fill (int x, int y, int width, int height, int colour) |
Fill an area of the screen. | |
int | width () |
Screen width. | |
int | height () |
Screen height. | |
int | columns () |
Columns. | |
int | rows () |
Rows. | |
void | power (unsigned char sw) |
Power switch for OLED backlight. |
Detailed Description
MARMEX_OB_oled OLED screen drawing class.
MARMEX_OB OLED screen drawing library.
This is a driver code for MARMEX_OB_oled board OLED screen. This class inherits NokiaLCD class of mbed.org. To use this class, import the NokiaLCD class from here.. http://mbed.org/users/simon/libraries/NokiaLCD/
Example:
#include "mbed.h" #include "MARMEX_OB_oled.h" // oled1 is for MARMEX_OB_oled board on MAPLE slot 1 // oled1 is for MARMEX_OB_oled board on MAPLE slot 2 MARMEX_OB_oled oled1( p5, p7, p8, p30, p11 ); // mosi, sclk, cs, rst, power_control //MARMEX_OB_oled oled2( p5, p7, p26, p21, p17 ); // mosi, sclk, cs, rst, power_control int main() { oled1.background( 0x000000 ); oled1.cls(); int colorbar_width = MARMEX_OB_oled::WIDTH / 8; for ( int i = 0; i < 8; i++ ) oled1.fill( colorbar_width * i, 0, colorbar_width, MARMEX_OB_oled::HEIGHT, ((i & 0x4) ? 0xFF0000 : 0x000000) | ((i & 0x2) ? 0x00FF00 : 0x000000) | ((i & 0x1) ? 0x0000FF : 0x000000) ); oled1.fill( 50, 50, 64, 64, 0xCCCCCC );; oled1.locate( 0, 3 ); oled1.printf( "Hello World!" ); oled1.locate( 0, 4 ); oled1.printf( "SPI = %s", MERMEX_OB_SPI_MODE_STR ); for (int i = 0; i < MARMEX_OB_oled::WIDTH; i++ ) { oled1.pixel( i, 80 + sin( (float)i / 5.0 ) * 10, 0x000000 ); } } *
- Version:
- 0.51
- Date:
- 08-Apr-2011
Released under the MIT License: http://mbed.org/license/mit
MARMEX_OB_oled OLED screen drawing library for mbed This code has been written based on sample code and advises from Ochiai-san (Marutsu-Elec). Thank you!
SPI mode: 9bit or 8bit SPI mode can be selected by disabling/enabling "#define MARMEX_OB_SPI_8BIT_MODE". See source code in this (MARMEX_OB_oled.h) file.
Definition at line 76 of file MARMEX_OB_oled.h.
Member Enumeration Documentation
anonymous enum |
General parameters for MARMEX_OB_oled.
- Enumerator:
ROWS # of rows (lines) for displaying characters
COLS # of columns (width) for displaying characters
WIDTH screen width [pixels]
HEIGHT screen height [pixels]
SPI_FREQUENCY SPI (sclk) SPI_FREQUENCY.
Definition at line 81 of file MARMEX_OB_oled.h.
anonymous enum |
Constants for power() function.
Definition at line 90 of file MARMEX_OB_oled.h.
Constructor & Destructor Documentation
MARMEX_OB_oled | ( | PinName | mosi, |
PinName | sclk, | ||
PinName | cs, | ||
PinName | rst, | ||
PinName | power_pin | ||
) |
Create a MARMEX_OB_oled object connected to specified SPI and DigitalOut pins.
- Parameters:
-
mosi SPI-MOSI pin (for MAPLE board, use p5) sclk SPI-SCLK pin (for MAPLE board, use p8) cs chip select signal (for MAPLE board, use p8(slot1), p26(slot2)) rst reset signal (for MAPLE board, use p30(slot1), p21(slot2)) power_pin backlight power control signal (for MAPLE board, use p11(slot1), p17(slot2))
Example of MARMEX_OB_oled on MAPLE board:
#include "mbed.h" #include "MARMEX_OB_oled.h" MARMEX_OB_oled oled_on_maple_slot1( p5, p7, p8, p30, p11 ); // mosi, sclk, cs, rst, power_control MARMEX_OB_oled oled_on_maple_slot2( p5, p7, p26, p21, p17 ); // mosi, sclk, cs, rst, power_control ... ..
Definition at line 115 of file MARMEX_OB_oled.h.
Member Function Documentation
void background | ( | int | c ) |
Set the background colour.
- Parameters:
-
c 24-bit colour
void cls | ( | void | ) |
Clear the screen and locate to 0,0.
Definition at line 271 of file MARMEX_OB_oled.h.
int columns | ( | ) |
void fill | ( | int | x, |
int | y, | ||
int | width, | ||
int | height, | ||
int | colour | ||
) |
Fill an area of the screen.
- Parameters:
-
x horizontal position from left y vertical position from top width width in pixels height height in pixels colour 24-bit colour in format 0x00RRGGBB
Definition at line 300 of file MARMEX_OB_oled.h.
void foreground | ( | int | c ) |
Set the foreground colour.
- Parameters:
-
c 24-bit colour
int height | ( | ) |
virtual void pixel | ( | int | x, |
int | y, | ||
int | colour | ||
) | [virtual] |
Set a pixel on te screen.
- Parameters:
-
x horizontal position from left y vertical position from top colour 24-bit colour in format 0x00RRGGBB
Definition at line 284 of file MARMEX_OB_oled.h.
void power | ( | unsigned char | sw ) |
Power switch for OLED backlight.
- Parameters:
-
sw argument can be MARMEX_OB_oled::ON or MARMEX_OB_oled::OFF
Definition at line 373 of file MARMEX_OB_oled.h.
int printf | ( | const char * | format, |
... | |||
) |
Write a formated string to the LCD.
- Parameters:
-
format A printf-style format string, followed by the variables to use in formating the string.
!!! 16th character in the string will be disappeared !!! This problem is due to difference of screen size NokiaLCD library and its internal mechanism...
int putc | ( | int | c ) |
Write a character to the LCD.
- Parameters:
-
c The character to write to the display
void reset | ( | void | ) |
reset MARMEX_OB_oled
Executes hardware reset and initialize. See MARMEX_OB_oled manual for the initialization sequence and values For gamma correction table, using math function to make the code simple
Definition at line 158 of file MARMEX_OB_oled.h.
int rows | ( | ) |
int width | ( | ) |
Generated on Sun Jul 17 2022 08:23:23 by
