MARMEX_OB_oled_J sample

Dependencies:   MARMEX_OB_oled_J mbed

Fork of Q_nolkiaJapanese_3_tryBaikaku by Haron foo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "MARMEX_OB_oled_J.h"
00003 
00004 MARMEX_OB_oled_J oled( p5, p7,  p27, p24, p26 ); // mosi, sclk, cs, rst, power_control
00005 
00006 LocalFileSystem local("local");
00007 
00008 void lfTrim(char* text) {
00009     char *p;
00010     p = strchr( text, '\n' );
00011     if ( p != NULL )
00012     {
00013         *p = '\0';
00014     }
00015 }
00016 
00017 int main() {
00018     FILE *fp;
00019     char *filename = "/local/load.txt";
00020     if((fp = fopen(filename, "r")) == NULL){
00021         printf("Error: %s could not open.", filename);
00022         return 1;
00023     }
00024     
00025     char text[20];
00026     
00027     oled.cls();
00028     oled.locate(0,0); oled.fontsize(1,1);oled.foreground(0x00FFFFFF); oled.printf("ABC:123");
00029     oled.locate(0,1); oled.fontsize(2,1);oled.foreground(0x00FF0000); oled.printf("ABC:123");
00030     if(fgets(text, 20, fp ) != NULL) {
00031         lfTrim(text);
00032         oled.locate(0,1); oled.fontsize(1,2);oled.foreground(0x0000FF00); oled.printf("%s", text);
00033     }
00034     if(fgets(text, 20, fp ) != NULL) {
00035         lfTrim(text);
00036         oled.locate(0,4); oled.fontsize(2,1);oled.foreground(0x000000FF); oled.printf("%s", text);
00037     }
00038     if(fgets(text, 20, fp ) != NULL) {
00039         lfTrim(text);
00040         oled.locate(0,3); oled.fontsize(2,2);oled.foreground(0x0000FFFF); oled.printf("%s", text);
00041     }
00042     if(fgets(text, 20, fp ) != NULL) {
00043         lfTrim(text);
00044         oled.locate(0,3); oled.fontsize(3,3);oled.foreground(0x00FF00FF); oled.printf("%s", text);
00045     }
00046     fclose(fp);
00047 }