A class library for OLED on MARMEX_OB board. MARY拡張のMARMEX_OB基板のOLEDをmbed+MAPLE基板で動かすためのライブラリです.このサンプルではMAPLEに用意されているMARMEXスロットの1番に搭載したOLEDを制御するようになっています.詳細はCode&APIからソースやAPI詳細をご覧ください

Dependencies:   mbed NokiaLCD

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /** A sample app of MARMEX_OB OLED screen drawing library
00002  *
00003  *  @author  Tedd
00004  *  @version 0.51
00005  *  @date    08-Apr-2011
00006  *
00007  *  Released under the MIT License: http://mbed.org/license/mit
00008  *
00009  *  MARMEX_OB_oled OLED screen drawing library for mbed
00010  *  This code has been written based on sample code and advises
00011  *    from Ochiai-san (Marutsu-Elec). Thank you!
00012  *
00013  *  To build this code, "NokiaLCD" and "mbed" libraries are needed to be imported in a project.
00014  *     NokiaLCD library :  http://mbed.org/users/simon/libraries/NokiaLCD/
00015  */
00016 
00017 
00018 #include "mbed.h"
00019 #include "MARMEX_OB_oled.h"
00020 
00021 //  oled1 is for MARMEX_OB_oled board on MAPLE slot 1
00022 //  oled1 is for MARMEX_OB_oled board on MAPLE slot 2
00023 
00024 MARMEX_OB_oled   oled1( p5, p7,  p8, p30, p11 ); // mosi, sclk, cs, rst, power_control
00025 //MARMEX_OB_oled   oled2( p5, p7, p26, p21, p17 ); // mosi, sclk, cs, rst, power_control
00026 
00027 
00028 int main() {
00029     oled1.background( 0x000000 );
00030     oled1.cls();
00031 
00032     int colorbar_width  = MARMEX_OB_oled::WIDTH / 8;
00033 
00034     for ( int i = 0; i < 8; i++ )
00035         oled1.fill( colorbar_width * i, 0, colorbar_width, MARMEX_OB_oled::HEIGHT, ((i & 0x4) ? 0xFF0000 : 0x000000) | ((i & 0x2) ? 0x00FF00 : 0x000000) | ((i & 0x1) ? 0x0000FF : 0x000000) );
00036 
00037     oled1.fill(  50,  50,  64,  64, 0xCCCCCC );;
00038 
00039     oled1.locate( 0, 3 );
00040     oled1.printf( "Hello World!" );
00041     oled1.locate( 0, 4 );
00042     oled1.printf( "SPI = %s", MERMEX_OB_SPI_MODE_STR );
00043 
00044     for (int i = 0; i < MARMEX_OB_oled::WIDTH; i++ ) {
00045         oled1.pixel( i, 80 + sin( (float)i / 5.0 ) * 10, 0x000000 );
00046     }
00047 }
00048 
00049 /*
00050  *  history:
00051  *      0.5  (2011-Apr-07) :  initial published version
00052  *      0.51 (2011-Apr-08) :  minor modification to make the source more consistent (use " MARMEX_OB_oled::HEIGHT" instead of 128)
00053  */