e-paper whereabouts board program

Dependencies:   SDFileSystem mbed

Committer:
kohacraft
Date:
Tue May 23 05:06:14 2017 +0000
Revision:
1:cb28911c7ba5
Parent:
0:e4c67c26ba3f
Child:
2:9150515ecd68
change mbed official newest SDFilesystem.; you can select display mode for your EDP.; modify to simply code.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kohacraft 1:cb28911c7ba5 1 /* EDP experiment kit program */
kohacraft 1:cb28911c7ba5 2
kohacraft 0:e4c67c26ba3f 3 #include "mbed.h"
kohacraft 0:e4c67c26ba3f 4 #include "eink.h"
kohacraft 0:e4c67c26ba3f 5
kohacraft 1:cb28911c7ba5 6 //setup for using SD Card
kohacraft 0:e4c67c26ba3f 7 #include "SDFileSystem.h"
kohacraft 0:e4c67c26ba3f 8 #define SD_MOSI dp2
kohacraft 0:e4c67c26ba3f 9 #define SD_MISO dp1
kohacraft 0:e4c67c26ba3f 10 #define SD_SCLK dp6
kohacraft 0:e4c67c26ba3f 11 #define SD_CS dp4
kohacraft 0:e4c67c26ba3f 12 SDFileSystem sd(SD_MOSI, SD_MISO, SD_SCLK, SD_CS, "sd"); // mosi, miso, sclk, cs, name (HW modification candidate)
kohacraft 0:e4c67c26ba3f 13
kohacraft 0:e4c67c26ba3f 14
kohacraft 1:cb28911c7ba5 15 DigitalIn key1(dp28); //key1 input
kohacraft 1:cb28911c7ba5 16 DigitalIn key2(dp25); //key2 input
kohacraft 1:cb28911c7ba5 17 DigitalIn key3(dp18); //key3 input
kohacraft 1:cb28911c7ba5 18 DigitalIn key4(dp15); //key4 input
kohacraft 0:e4c67c26ba3f 19
kohacraft 0:e4c67c26ba3f 20 int main() {
kohacraft 0:e4c67c26ba3f 21
kohacraft 1:cb28911c7ba5 22 initPort(); //Initialize Port
kohacraft 0:e4c67c26ba3f 23
kohacraft 0:e4c67c26ba3f 24 FILE *fp;
kohacraft 0:e4c67c26ba3f 25 char filePath[32] = "";
kohacraft 0:e4c67c26ba3f 26 int fileNum = 0;
kohacraft 0:e4c67c26ba3f 27
kohacraft 0:e4c67c26ba3f 28
kohacraft 1:cb28911c7ba5 29 //wait until het key
kohacraft 0:e4c67c26ba3f 30 while( fileNum == 0 )
kohacraft 0:e4c67c26ba3f 31 {
kohacraft 0:e4c67c26ba3f 32 if( key1 == 1 )
kohacraft 0:e4c67c26ba3f 33 fileNum = 1;
kohacraft 0:e4c67c26ba3f 34 if( key2 == 1 )
kohacraft 0:e4c67c26ba3f 35 fileNum = 2;
kohacraft 0:e4c67c26ba3f 36 if( key3 == 1 )
kohacraft 0:e4c67c26ba3f 37 fileNum = 3;
kohacraft 0:e4c67c26ba3f 38 if( key4 == 1 )
kohacraft 0:e4c67c26ba3f 39 fileNum = 4;
kohacraft 0:e4c67c26ba3f 40 }
kohacraft 0:e4c67c26ba3f 41
kohacraft 1:cb28911c7ba5 42 //turn on EDP
kohacraft 1:cb28911c7ba5 43 powerOn();
kohacraft 1:cb28911c7ba5 44
kohacraft 1:cb28911c7ba5 45 //open file
kohacraft 0:e4c67c26ba3f 46 sprintf( filePath , "/sd/%d.bmp" , fileNum);
kohacraft 0:e4c67c26ba3f 47 fp = fopen(filePath, "r");
kohacraft 1:cb28911c7ba5 48
kohacraft 1:cb28911c7ba5 49 /* -------------------------------------- */
kohacraft 1:cb28911c7ba5 50 /* Please select display mode */
kohacraft 1:cb28911c7ba5 51 /* from mode1 to mode3 for your EDP. */
kohacraft 1:cb28911c7ba5 52 /* Please comment out any not need mode */
kohacraft 1:cb28911c7ba5 53 /* -------------------------------------- */
kohacraft 1:cb28911c7ba5 54
kohacraft 1:cb28911c7ba5 55 //DisplayMode1 fill Black and draw white
kohacraft 1:cb28911c7ba5 56 //for ED060SC4(LF)H2
kohacraft 1:cb28911c7ba5 57 clrDisp(EDP_BLACK); //fill Black
kohacraft 1:cb28911c7ba5 58 clrDisp(EDP_BLACK);
kohacraft 1:cb28911c7ba5 59 dispBmp( fp , EDP_WHITE ); //draw bmp
kohacraft 1:cb28911c7ba5 60 dispBmp( fp , EDP_WHITE );
kohacraft 1:cb28911c7ba5 61
kohacraft 1:cb28911c7ba5 62 //DisplayMode2 fill white and draw black
kohacraft 1:cb28911c7ba5 63 //for ED060SC4(LF)H2-00
kohacraft 1:cb28911c7ba5 64 //for ED060SC4(LF)H1
kohacraft 1:cb28911c7ba5 65 clrDisp(EDP_WHITE); //fill white
kohacraft 1:cb28911c7ba5 66 clrDisp(EDP_WHITE);
kohacraft 1:cb28911c7ba5 67 dispBmp( fp , EDP_BLACK );
kohacraft 1:cb28911c7ba5 68 dispBmp( fp , EDP_BLACK );
kohacraft 1:cb28911c7ba5 69
kohacraft 1:cb28911c7ba5 70 //DisplayMode3 fill white and draw black and white
kohacraft 1:cb28911c7ba5 71 //for ED060SC4(LF)
kohacraft 1:cb28911c7ba5 72 clrDisp(EDP_WHITE); //fill white
kohacraft 1:cb28911c7ba5 73 clrDisp(EDP_WHITE);
kohacraft 1:cb28911c7ba5 74 dispBmp( fp , EDP_BLACK_WHITE );
kohacraft 1:cb28911c7ba5 75 dispBmp( fp , EDP_BLACK_WHITE );
kohacraft 1:cb28911c7ba5 76
kohacraft 1:cb28911c7ba5 77 //close file
kohacraft 0:e4c67c26ba3f 78 fclose( fp );
kohacraft 0:e4c67c26ba3f 79 free(fp);
kohacraft 0:e4c67c26ba3f 80
kohacraft 1:cb28911c7ba5 81 //turn off EDP
kohacraft 1:cb28911c7ba5 82 powerOff();
kohacraft 0:e4c67c26ba3f 83
kohacraft 1:cb28911c7ba5 84 //wait for torn off myself
kohacraft 0:e4c67c26ba3f 85 while(1)
kohacraft 0:e4c67c26ba3f 86 {
kohacraft 0:e4c67c26ba3f 87 wait(1);
kohacraft 0:e4c67c26ba3f 88 }
kohacraft 0:e4c67c26ba3f 89 }