![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
MARMEX_OB_oled_J sample
Dependencies: MARMEX_OB_oled_J mbed
Fork of Q_nolkiaJapanese_3_tryBaikaku by
Diff: main.cpp
- Revision:
- 1:5e0d5c8ade80
- Parent:
- 0:4ef525e32ebc
--- a/main.cpp Mon Jul 18 01:30:20 2011 +0000 +++ b/main.cpp Fri Feb 01 11:52:28 2013 +0000 @@ -1,25 +1,47 @@ #include "mbed.h" -#include "Moled.h" -DigitalOut myled1(LED1); -DigitalOut myled2(LED2); +#include "MARMEX_OB_oled_J.h" + +MARMEX_OB_oled_J oled( p5, p7, p27, p24, p26 ); // mosi, sclk, cs, rst, power_control + +LocalFileSystem local("local"); -Moled oled (p5, p7, p8, p30 , p11); //( p5, p7, p26, p21, p17 ); //(p5, p7, p8, p30,p11); // mosi, sclk, cs, rst,power +void lfTrim(char* text) { + char *p; + p = strchr( text, '\n' ); + if ( p != NULL ) + { + *p = '\0'; + } +} int main() { - - oled.cls(); - oled.locate(0,0); oled.fontsize(1,1);oled.foreground(0x00FFFFFF); oled.printf("ABC:123"); - oled.locate(0,1); oled.fontsize(2,1);oled.foreground(0x00FF0000); oled.printf("ABC:123"); - oled.locate(0,1); oled.fontsize(1,2);oled.foreground(0x0000FF00); oled.printf("Ø:123"); - oled.locate(0,2); oled.fontsize(2,2);oled.foreground(0x000000FF); oled.printf("Rì:123"); - oled.locate(0,2); oled.fontsize(3,3);oled.foreground(0x00FFFFFF); oled.printf("c¨:1"); - oled.fill(100,100,20,20,0x00FFFFFF); - oled.pixel(110,110,0x00FFFF00); - - while(1) { - myled1 = 1; - wait(0.25); - myled1 = 0; - wait(0.25); + FILE *fp; + char *filename = "/local/load.txt"; + if((fp = fopen(filename, "r")) == NULL){ + printf("Error: %s could not open.", filename); + return 1; } -} + + char text[20]; + + oled.cls(); + oled.locate(0,0); oled.fontsize(1,1);oled.foreground(0x00FFFFFF); oled.printf("ABC:123"); + oled.locate(0,1); oled.fontsize(2,1);oled.foreground(0x00FF0000); oled.printf("ABC:123"); + if(fgets(text, 20, fp ) != NULL) { + lfTrim(text); + oled.locate(0,1); oled.fontsize(1,2);oled.foreground(0x0000FF00); oled.printf("%s", text); + } + if(fgets(text, 20, fp ) != NULL) { + lfTrim(text); + oled.locate(0,4); oled.fontsize(2,1);oled.foreground(0x000000FF); oled.printf("%s", text); + } + if(fgets(text, 20, fp ) != NULL) { + lfTrim(text); + oled.locate(0,3); oled.fontsize(2,2);oled.foreground(0x0000FFFF); oled.printf("%s", text); + } + if(fgets(text, 20, fp ) != NULL) { + lfTrim(text); + oled.locate(0,3); oled.fontsize(3,3);oled.foreground(0x00FF00FF); oled.printf("%s", text); + } + fclose(fp); +} \ No newline at end of file