Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 // example to test out OLED on mbed + XPresso baseboard, sford 00002 00003 #include "mbed.h" 00004 #include "EAOLED.h" 00005 00006 // NOTE: The xpresso board does not provide the data/command signal to the mbed, so I added a wire: 00007 // Connect: 00008 // PIO2_7 of baseboard mbed socket (empty 2nd hole below mbed pin 21) 00009 // to 00010 // PIO0_8(p13) of J6 (7th hole down on left side of J6) 00011 // to provide OLED data/command signal 00012 00013 DigitalOut led(LED1); 00014 00015 EAOLED oled(p5, p6, p7, p8, p25); // mosi, dnc, sclk, cs, power 00016 BusIn js(p13, p14, p22, p23); // down, right, left, up 00017 DigitalIn push (p12); 00018 00019 int Cur_X = 48; 00020 int Cur_Y = 32; 00021 int Cur_Colour = 0xffffff; // white 00022 00023 void plot (int); 00024 00025 int main() { 00026 00027 oled.cls(); 00028 oled.printf("Hello World!"); 00029 oled.locate(0,3); 00030 oled.printf("I'm an OLED!"); 00031 wait(1); 00032 oled.cls(); 00033 00034 oled.pixel(Cur_X,Cur_Y,Cur_Colour); 00035 00036 while (1) { 00037 plot(js); 00038 wait (0.1); 00039 } 00040 } 00041 00042 00043 void plot (int dir) { 00044 00045 // clear the screen 00046 if (push == 0) { 00047 oled.cls(); 00048 } 00049 00050 // if possible, move down 00051 else if (js == 0x7){ 00052 if ( Cur_Y > 0) { 00053 Cur_Y--; 00054 oled.pixel(Cur_X,Cur_Y,Cur_Colour); 00055 } 00056 } 00057 00058 // if possible, move right 00059 else if (js == 0xb){ 00060 if (Cur_X > 0) { 00061 Cur_X--; 00062 oled.pixel(Cur_X,Cur_Y,Cur_Colour); 00063 } 00064 } 00065 00066 // if possible, move left 00067 else if (js == 0xd){ 00068 if (Cur_X < 96) { 00069 Cur_X++; 00070 oled.pixel(Cur_X,Cur_Y,Cur_Colour); 00071 } 00072 } 00073 00074 // if possible, move up 00075 else if (js == 0xe){ 00076 if (Cur_Y < 64) { 00077 Cur_Y++; 00078 oled.pixel(Cur_X,Cur_Y,Cur_Colour); 00079 } 00080 } 00081 }
Generated on Wed Jul 13 2022 04:56:00 by
1.7.2