![](/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
main.cpp@2:f76d5cea25f3, 2013-02-16 (annotated)
- Committer:
- diasea
- Date:
- Sat Feb 16 15:13:29 2013 +0000
- Revision:
- 2:f76d5cea25f3
- Parent:
- 1:5e0d5c8ade80
modify SPI_FREQUENCY = 16000000
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
s_s_s | 0:4ef525e32ebc | 1 | #include "mbed.h" |
diasea | 1:5e0d5c8ade80 | 2 | #include "MARMEX_OB_oled_J.h" |
diasea | 1:5e0d5c8ade80 | 3 | |
diasea | 1:5e0d5c8ade80 | 4 | MARMEX_OB_oled_J oled( p5, p7, p27, p24, p26 ); // mosi, sclk, cs, rst, power_control |
diasea | 1:5e0d5c8ade80 | 5 | |
diasea | 1:5e0d5c8ade80 | 6 | LocalFileSystem local("local"); |
s_s_s | 0:4ef525e32ebc | 7 | |
diasea | 1:5e0d5c8ade80 | 8 | void lfTrim(char* text) { |
diasea | 1:5e0d5c8ade80 | 9 | char *p; |
diasea | 1:5e0d5c8ade80 | 10 | p = strchr( text, '\n' ); |
diasea | 1:5e0d5c8ade80 | 11 | if ( p != NULL ) |
diasea | 1:5e0d5c8ade80 | 12 | { |
diasea | 1:5e0d5c8ade80 | 13 | *p = '\0'; |
diasea | 1:5e0d5c8ade80 | 14 | } |
diasea | 1:5e0d5c8ade80 | 15 | } |
s_s_s | 0:4ef525e32ebc | 16 | |
s_s_s | 0:4ef525e32ebc | 17 | int main() { |
diasea | 1:5e0d5c8ade80 | 18 | FILE *fp; |
diasea | 1:5e0d5c8ade80 | 19 | char *filename = "/local/load.txt"; |
diasea | 1:5e0d5c8ade80 | 20 | if((fp = fopen(filename, "r")) == NULL){ |
diasea | 1:5e0d5c8ade80 | 21 | printf("Error: %s could not open.", filename); |
diasea | 1:5e0d5c8ade80 | 22 | return 1; |
s_s_s | 0:4ef525e32ebc | 23 | } |
diasea | 1:5e0d5c8ade80 | 24 | |
diasea | 1:5e0d5c8ade80 | 25 | char text[20]; |
diasea | 1:5e0d5c8ade80 | 26 | |
diasea | 1:5e0d5c8ade80 | 27 | oled.cls(); |
diasea | 1:5e0d5c8ade80 | 28 | oled.locate(0,0); oled.fontsize(1,1);oled.foreground(0x00FFFFFF); oled.printf("ABC:123"); |
diasea | 1:5e0d5c8ade80 | 29 | oled.locate(0,1); oled.fontsize(2,1);oled.foreground(0x00FF0000); oled.printf("ABC:123"); |
diasea | 1:5e0d5c8ade80 | 30 | if(fgets(text, 20, fp ) != NULL) { |
diasea | 1:5e0d5c8ade80 | 31 | lfTrim(text); |
diasea | 1:5e0d5c8ade80 | 32 | oled.locate(0,1); oled.fontsize(1,2);oled.foreground(0x0000FF00); oled.printf("%s", text); |
diasea | 1:5e0d5c8ade80 | 33 | } |
diasea | 1:5e0d5c8ade80 | 34 | if(fgets(text, 20, fp ) != NULL) { |
diasea | 1:5e0d5c8ade80 | 35 | lfTrim(text); |
diasea | 1:5e0d5c8ade80 | 36 | oled.locate(0,4); oled.fontsize(2,1);oled.foreground(0x000000FF); oled.printf("%s", text); |
diasea | 1:5e0d5c8ade80 | 37 | } |
diasea | 1:5e0d5c8ade80 | 38 | if(fgets(text, 20, fp ) != NULL) { |
diasea | 1:5e0d5c8ade80 | 39 | lfTrim(text); |
diasea | 1:5e0d5c8ade80 | 40 | oled.locate(0,3); oled.fontsize(2,2);oled.foreground(0x0000FFFF); oled.printf("%s", text); |
diasea | 1:5e0d5c8ade80 | 41 | } |
diasea | 1:5e0d5c8ade80 | 42 | if(fgets(text, 20, fp ) != NULL) { |
diasea | 1:5e0d5c8ade80 | 43 | lfTrim(text); |
diasea | 1:5e0d5c8ade80 | 44 | oled.locate(0,3); oled.fontsize(3,3);oled.foreground(0x00FF00FF); oled.printf("%s", text); |
diasea | 1:5e0d5c8ade80 | 45 | } |
diasea | 1:5e0d5c8ade80 | 46 | fclose(fp); |
diasea | 1:5e0d5c8ade80 | 47 | } |