![](/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
- Committer:
- brainliang
- Date:
- 2018-05-08
- Revision:
- 4:c88bf297ee75
File content as of revision 4:c88bf297ee75:
#include "LCDShow.h" LCDShow::LCDShow(PinName rs,PinName e,PinName d4,PinName d5,PinName d6,PinName d7,LCDType type):TextLCD(rs,e,d4,d5,d6,d7,type) { Max_pos = PrePos = now_pos = 0; start = true; Pos_fresh = false; Neg_fresh = false; Now_fresh = false; Read_file = false; } void LCDShow::CurrPos() { int i = Choose.pulses_ % 4; if(i < 0) { Choose.pulses_ = 0; i = 0; } if(PrePos == 3 && i == 0) { Pos_fresh = true; } else if(PrePos == 0 && i == 3) { Neg_fresh = true; } else if(PrePos != i) { Now_fresh = true; } if(!Read_file) { PrePos = i; this->locate(18,i); this->printf("<-"); } } void LCDShow::ReadFile() { if(!btn3.read()) { file_name = "/sd/"; file_name += File_dir[now_pos + (PrePos - 4)]; Read_file = true; } } void LCDShow::getDir(vector<string> _dir) { File_dir = _dir; } void LCDShow::showdir() { if(start) { t1.attach(this,&LCDShow::showdir,0.2); t2.attach(this,&LCDShow::ReadFile,0.5); Max_pos = File_dir.size(); for(;now_pos < 4; now_pos ++) { this->printf("%s\n",File_dir[now_pos]); } start = false; return; } CurrPos(); if(!Read_file) { if(Pos_fresh == true) { this->cls(); for(int i = 0;i < 4; i ++) { if(now_pos >= Max_pos) { continue; } this->printf("%s\n",File_dir[now_pos]); now_pos ++; } Pos_fresh = false; } else if(Neg_fresh == true) { this->cls(); now_pos -= 8; if(now_pos < 0) now_pos = 0; for(int i = 0;i < 4; i ++) { this->printf("%s\n",File_dir[now_pos]); now_pos ++; } Neg_fresh = false; } else if(Now_fresh == true) { this->cls(); now_pos -= 4; for(int i = 0;i < 4; i ++) { this->printf("%s\n",File_dir[now_pos]); now_pos ++; } Now_fresh = false; } } else if(Read_file) { this->cls(); this->printf("OPEN %s\n",file_name); } return; }