e-paper whereabouts board program

Dependencies:   SDFileSystem mbed

main.cpp

Committer:
kohacraft
Date:
2017-05-23
Revision:
2:9150515ecd68
Parent:
1:cb28911c7ba5

File content as of revision 2:9150515ecd68:

/* EDP experiment kit program */

#include "mbed.h"
#include "eink.h"

//setup for using SD Card
#include "SDFileSystem.h"
#define     SD_MOSI     dp2
#define     SD_MISO     dp1
#define     SD_SCLK     dp6
#define     SD_CS       dp4
SDFileSystem  sd(SD_MOSI, SD_MISO, SD_SCLK, SD_CS,  "sd");  //  mosi, miso, sclk, cs, name  (HW modification candidate)


DigitalIn key1(dp28);  //key1 input
DigitalIn key2(dp25);  //key2 input
DigitalIn key3(dp18);  //key3 input
DigitalIn key4(dp15);  //key4 input

int main() {
    
    initPort();   //Initialize Port
    
    //turn on EDP
    powerOn();

    FILE *fp;
    char filePath[32] = "";
    int fileNum = 0;
    

    //wait until het key
    while( fileNum == 0 )
    {
        if( key1 == 1 )
            fileNum = 1;
        if( key2 == 1 )
            fileNum = 2;
        if( key3 == 1 )
            fileNum = 3;
        if( key4 == 1 )
            fileNum = 4;
    }

    //open file
    sprintf( filePath , "/sd/%d.bmp" , fileNum);        
    fp = fopen(filePath, "r");

    /* -------------------------------------- */
    /* Please select display mode            */
    /* from mode1 to mode3 for your EDP.     */
    /* Please comment out any not need modes  */
    /* -------------------------------------- */

    //DisplayMode1 fill Black and draw white
    //for ED060SC4(LF)H2
    clrDisp(EDP_BLACK); //fill Black
    clrDisp(EDP_BLACK);
    dispBmp( fp , EDP_WHITE );    //draw bmp
    dispBmp( fp , EDP_WHITE );

    //DisplayMode2 fill white and draw black
    //for ED060SC4(LF)H2-00
    //for ED060SC4(LF)H1
    clrDisp(EDP_WHITE); //fill white
    clrDisp(EDP_WHITE);
    dispBmp( fp , EDP_BLACK );
    dispBmp( fp , EDP_BLACK );

    //DisplayMode3 fill white and draw black and white
    //for ED060SC4(LF)
    clrDisp(EDP_WHITE); //fill white
    clrDisp(EDP_WHITE);
    dispBmp( fp , EDP_BLACK_WHITE );
    dispBmp( fp , EDP_BLACK_WHITE );

    //close file
    fclose( fp );
    free(fp);
    
    //turn off EDP
    powerOff();

    //wait for torn off myself
    while(1)
    {
        wait(1);
    }
}