e-paper whereabouts board program
Dependencies: SDFileSystem mbed
main.cpp@0:e4c67c26ba3f, 2016-05-01 (annotated)
- Committer:
- kohacraft
- Date:
- Sun May 01 03:12:28 2016 +0000
- Revision:
- 0:e4c67c26ba3f
- Child:
- 1:cb28911c7ba5
ver1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kohacraft | 0:e4c67c26ba3f | 1 | #include "mbed.h" |
kohacraft | 0:e4c67c26ba3f | 2 | #include "eink.h" |
kohacraft | 0:e4c67c26ba3f | 3 | |
kohacraft | 0:e4c67c26ba3f | 4 | #include "SDFileSystem.h" |
kohacraft | 0:e4c67c26ba3f | 5 | #define SD_MOSI dp2 |
kohacraft | 0:e4c67c26ba3f | 6 | #define SD_MISO dp1 |
kohacraft | 0:e4c67c26ba3f | 7 | #define SD_SCLK dp6 |
kohacraft | 0:e4c67c26ba3f | 8 | #define SD_CS dp4 |
kohacraft | 0:e4c67c26ba3f | 9 | SDFileSystem sd(SD_MOSI, SD_MISO, SD_SCLK, SD_CS, "sd"); // mosi, miso, sclk, cs, name (HW modification candidate) |
kohacraft | 0:e4c67c26ba3f | 10 | |
kohacraft | 0:e4c67c26ba3f | 11 | |
kohacraft | 0:e4c67c26ba3f | 12 | DigitalIn key1(dp28); //key1 |
kohacraft | 0:e4c67c26ba3f | 13 | DigitalIn key2(dp25); //key2 |
kohacraft | 0:e4c67c26ba3f | 14 | DigitalIn key3(dp18); //key3 |
kohacraft | 0:e4c67c26ba3f | 15 | DigitalIn key4(dp15); //key4 |
kohacraft | 0:e4c67c26ba3f | 16 | |
kohacraft | 0:e4c67c26ba3f | 17 | int main() { |
kohacraft | 0:e4c67c26ba3f | 18 | |
kohacraft | 0:e4c67c26ba3f | 19 | initPort(); //initialize ports |
kohacraft | 0:e4c67c26ba3f | 20 | |
kohacraft | 0:e4c67c26ba3f | 21 | wait_ms(500); |
kohacraft | 0:e4c67c26ba3f | 22 | |
kohacraft | 0:e4c67c26ba3f | 23 | FILE *fp; |
kohacraft | 0:e4c67c26ba3f | 24 | char filePath[32] = ""; |
kohacraft | 0:e4c67c26ba3f | 25 | int fileNum = 0; |
kohacraft | 0:e4c67c26ba3f | 26 | |
kohacraft | 0:e4c67c26ba3f | 27 | powerOn(); |
kohacraft | 0:e4c67c26ba3f | 28 | wait_ms(500); |
kohacraft | 0:e4c67c26ba3f | 29 | |
kohacraft | 0:e4c67c26ba3f | 30 | //wait for keying |
kohacraft | 0:e4c67c26ba3f | 31 | while( fileNum == 0 ) |
kohacraft | 0:e4c67c26ba3f | 32 | { |
kohacraft | 0:e4c67c26ba3f | 33 | if( key1 == 1 ) |
kohacraft | 0:e4c67c26ba3f | 34 | fileNum = 1; |
kohacraft | 0:e4c67c26ba3f | 35 | if( key2 == 1 ) |
kohacraft | 0:e4c67c26ba3f | 36 | fileNum = 2; |
kohacraft | 0:e4c67c26ba3f | 37 | if( key3 == 1 ) |
kohacraft | 0:e4c67c26ba3f | 38 | fileNum = 3; |
kohacraft | 0:e4c67c26ba3f | 39 | if( key4 == 1 ) |
kohacraft | 0:e4c67c26ba3f | 40 | fileNum = 4; |
kohacraft | 0:e4c67c26ba3f | 41 | } |
kohacraft | 0:e4c67c26ba3f | 42 | |
kohacraft | 0:e4c67c26ba3f | 43 | clrdisp(0); //clear in black |
kohacraft | 0:e4c67c26ba3f | 44 | |
kohacraft | 0:e4c67c26ba3f | 45 | sprintf( filePath , "/sd/%d.bmp" , fileNum); |
kohacraft | 0:e4c67c26ba3f | 46 | fp = fopen(filePath, "r"); |
kohacraft | 0:e4c67c26ba3f | 47 | dispbmp( fp ); //draw bmp |
kohacraft | 0:e4c67c26ba3f | 48 | //dispbmp( fp ); //the white pixels are more white if 2 times drawing |
kohacraft | 0:e4c67c26ba3f | 49 | fclose( fp ); |
kohacraft | 0:e4c67c26ba3f | 50 | free(fp); |
kohacraft | 0:e4c67c26ba3f | 51 | |
kohacraft | 0:e4c67c26ba3f | 52 | wait(0.5); |
kohacraft | 0:e4c67c26ba3f | 53 | powerOff(); //turn off orer. |
kohacraft | 0:e4c67c26ba3f | 54 | |
kohacraft | 0:e4c67c26ba3f | 55 | //wait for turn off |
kohacraft | 0:e4c67c26ba3f | 56 | while(1) |
kohacraft | 0:e4c67c26ba3f | 57 | { |
kohacraft | 0:e4c67c26ba3f | 58 | wait(1); |
kohacraft | 0:e4c67c26ba3f | 59 | } |
kohacraft | 0:e4c67c26ba3f | 60 | } |