![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
dsfa
Dependencies: dsf SDFileSystem TextLCD mbed stepper_moter
Fork of my_example_Nucleo_Ex05_SD_zhangyuxiang2 by
LCDShow/LCDShow.cpp@4:c88bf297ee75, 2018-05-08 (annotated)
- Committer:
- brainliang
- Date:
- Tue May 08 01:50:44 2018 +0000
- Revision:
- 4:c88bf297ee75
sdfa
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
brainliang | 4:c88bf297ee75 | 1 | #include "LCDShow.h" |
brainliang | 4:c88bf297ee75 | 2 | |
brainliang | 4:c88bf297ee75 | 3 | LCDShow::LCDShow(PinName rs,PinName e,PinName d4,PinName d5,PinName d6,PinName d7,LCDType type):TextLCD(rs,e,d4,d5,d6,d7,type) |
brainliang | 4:c88bf297ee75 | 4 | { |
brainliang | 4:c88bf297ee75 | 5 | Max_pos = PrePos = now_pos = 0; |
brainliang | 4:c88bf297ee75 | 6 | start = true; |
brainliang | 4:c88bf297ee75 | 7 | Pos_fresh = false; |
brainliang | 4:c88bf297ee75 | 8 | Neg_fresh = false; |
brainliang | 4:c88bf297ee75 | 9 | Now_fresh = false; |
brainliang | 4:c88bf297ee75 | 10 | Read_file = false; |
brainliang | 4:c88bf297ee75 | 11 | } |
brainliang | 4:c88bf297ee75 | 12 | void LCDShow::CurrPos() |
brainliang | 4:c88bf297ee75 | 13 | { |
brainliang | 4:c88bf297ee75 | 14 | int i = Choose.pulses_ % 4; |
brainliang | 4:c88bf297ee75 | 15 | if(i < 0) |
brainliang | 4:c88bf297ee75 | 16 | { |
brainliang | 4:c88bf297ee75 | 17 | Choose.pulses_ = 0; |
brainliang | 4:c88bf297ee75 | 18 | i = 0; |
brainliang | 4:c88bf297ee75 | 19 | } |
brainliang | 4:c88bf297ee75 | 20 | if(PrePos == 3 && i == 0) |
brainliang | 4:c88bf297ee75 | 21 | { |
brainliang | 4:c88bf297ee75 | 22 | Pos_fresh = true; |
brainliang | 4:c88bf297ee75 | 23 | } |
brainliang | 4:c88bf297ee75 | 24 | else if(PrePos == 0 && i == 3) |
brainliang | 4:c88bf297ee75 | 25 | { |
brainliang | 4:c88bf297ee75 | 26 | Neg_fresh = true; |
brainliang | 4:c88bf297ee75 | 27 | } |
brainliang | 4:c88bf297ee75 | 28 | else if(PrePos != i) |
brainliang | 4:c88bf297ee75 | 29 | { |
brainliang | 4:c88bf297ee75 | 30 | Now_fresh = true; |
brainliang | 4:c88bf297ee75 | 31 | } |
brainliang | 4:c88bf297ee75 | 32 | |
brainliang | 4:c88bf297ee75 | 33 | if(!Read_file) |
brainliang | 4:c88bf297ee75 | 34 | { |
brainliang | 4:c88bf297ee75 | 35 | PrePos = i; |
brainliang | 4:c88bf297ee75 | 36 | this->locate(18,i); |
brainliang | 4:c88bf297ee75 | 37 | this->printf("<-"); |
brainliang | 4:c88bf297ee75 | 38 | } |
brainliang | 4:c88bf297ee75 | 39 | } |
brainliang | 4:c88bf297ee75 | 40 | |
brainliang | 4:c88bf297ee75 | 41 | void LCDShow::ReadFile() |
brainliang | 4:c88bf297ee75 | 42 | { |
brainliang | 4:c88bf297ee75 | 43 | if(!btn3.read()) |
brainliang | 4:c88bf297ee75 | 44 | { |
brainliang | 4:c88bf297ee75 | 45 | file_name = "/sd/"; |
brainliang | 4:c88bf297ee75 | 46 | file_name += File_dir[now_pos + (PrePos - 4)]; |
brainliang | 4:c88bf297ee75 | 47 | Read_file = true; |
brainliang | 4:c88bf297ee75 | 48 | } |
brainliang | 4:c88bf297ee75 | 49 | } |
brainliang | 4:c88bf297ee75 | 50 | void LCDShow::getDir(vector<string> _dir) |
brainliang | 4:c88bf297ee75 | 51 | { |
brainliang | 4:c88bf297ee75 | 52 | File_dir = _dir; |
brainliang | 4:c88bf297ee75 | 53 | } |
brainliang | 4:c88bf297ee75 | 54 | void LCDShow::showdir() |
brainliang | 4:c88bf297ee75 | 55 | { |
brainliang | 4:c88bf297ee75 | 56 | if(start) |
brainliang | 4:c88bf297ee75 | 57 | { |
brainliang | 4:c88bf297ee75 | 58 | t1.attach(this,&LCDShow::showdir,0.2); |
brainliang | 4:c88bf297ee75 | 59 | t2.attach(this,&LCDShow::ReadFile,0.5); |
brainliang | 4:c88bf297ee75 | 60 | Max_pos = File_dir.size(); |
brainliang | 4:c88bf297ee75 | 61 | for(;now_pos < 4; now_pos ++) |
brainliang | 4:c88bf297ee75 | 62 | { |
brainliang | 4:c88bf297ee75 | 63 | this->printf("%s\n",File_dir[now_pos]); |
brainliang | 4:c88bf297ee75 | 64 | } |
brainliang | 4:c88bf297ee75 | 65 | start = false; |
brainliang | 4:c88bf297ee75 | 66 | return; |
brainliang | 4:c88bf297ee75 | 67 | } |
brainliang | 4:c88bf297ee75 | 68 | CurrPos(); |
brainliang | 4:c88bf297ee75 | 69 | if(!Read_file) |
brainliang | 4:c88bf297ee75 | 70 | { |
brainliang | 4:c88bf297ee75 | 71 | if(Pos_fresh == true) |
brainliang | 4:c88bf297ee75 | 72 | { |
brainliang | 4:c88bf297ee75 | 73 | this->cls(); |
brainliang | 4:c88bf297ee75 | 74 | for(int i = 0;i < 4; i ++) |
brainliang | 4:c88bf297ee75 | 75 | { |
brainliang | 4:c88bf297ee75 | 76 | if(now_pos >= Max_pos) |
brainliang | 4:c88bf297ee75 | 77 | { |
brainliang | 4:c88bf297ee75 | 78 | continue; |
brainliang | 4:c88bf297ee75 | 79 | } |
brainliang | 4:c88bf297ee75 | 80 | this->printf("%s\n",File_dir[now_pos]); |
brainliang | 4:c88bf297ee75 | 81 | now_pos ++; |
brainliang | 4:c88bf297ee75 | 82 | } |
brainliang | 4:c88bf297ee75 | 83 | Pos_fresh = false; |
brainliang | 4:c88bf297ee75 | 84 | } |
brainliang | 4:c88bf297ee75 | 85 | else if(Neg_fresh == true) |
brainliang | 4:c88bf297ee75 | 86 | { |
brainliang | 4:c88bf297ee75 | 87 | this->cls(); |
brainliang | 4:c88bf297ee75 | 88 | now_pos -= 8; |
brainliang | 4:c88bf297ee75 | 89 | if(now_pos < 0) |
brainliang | 4:c88bf297ee75 | 90 | now_pos = 0; |
brainliang | 4:c88bf297ee75 | 91 | for(int i = 0;i < 4; i ++) |
brainliang | 4:c88bf297ee75 | 92 | { |
brainliang | 4:c88bf297ee75 | 93 | this->printf("%s\n",File_dir[now_pos]); |
brainliang | 4:c88bf297ee75 | 94 | now_pos ++; |
brainliang | 4:c88bf297ee75 | 95 | } |
brainliang | 4:c88bf297ee75 | 96 | Neg_fresh = false; |
brainliang | 4:c88bf297ee75 | 97 | } |
brainliang | 4:c88bf297ee75 | 98 | else if(Now_fresh == true) |
brainliang | 4:c88bf297ee75 | 99 | { |
brainliang | 4:c88bf297ee75 | 100 | this->cls(); |
brainliang | 4:c88bf297ee75 | 101 | now_pos -= 4; |
brainliang | 4:c88bf297ee75 | 102 | for(int i = 0;i < 4; i ++) |
brainliang | 4:c88bf297ee75 | 103 | { |
brainliang | 4:c88bf297ee75 | 104 | this->printf("%s\n",File_dir[now_pos]); |
brainliang | 4:c88bf297ee75 | 105 | now_pos ++; |
brainliang | 4:c88bf297ee75 | 106 | } |
brainliang | 4:c88bf297ee75 | 107 | Now_fresh = false; |
brainliang | 4:c88bf297ee75 | 108 | } |
brainliang | 4:c88bf297ee75 | 109 | } |
brainliang | 4:c88bf297ee75 | 110 | else if(Read_file) |
brainliang | 4:c88bf297ee75 | 111 | { |
brainliang | 4:c88bf297ee75 | 112 | this->cls(); |
brainliang | 4:c88bf297ee75 | 113 | this->printf("OPEN %s\n",file_name); |
brainliang | 4:c88bf297ee75 | 114 | } |
brainliang | 4:c88bf297ee75 | 115 | return; |
brainliang | 4:c88bf297ee75 | 116 | } |