Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:a7e6ebc4cb72, committed 2016-07-03
- Comitter:
- jk1lot
- Date:
- Sun Jul 03 10:38:58 2016 +0000
- Parent:
- 0:4dbc7e226777
- Commit message:
- 1st published version
Changed in this revision
diff -r 4dbc7e226777 -r a7e6ebc4cb72 TextDisplay.h --- a/TextDisplay.h Fri Jul 01 13:22:18 2016 +0000 +++ b/TextDisplay.h Sun Jul 03 10:38:58 2016 +0000 @@ -12,7 +12,6 @@ * keep writing and will always get valid characters. The location is * maintained internally to the class to make this easy */ - #ifndef MBED_TEXTDISPLAY_H #define MBED_TEXTDISPLAY_H
diff -r 4dbc7e226777 -r a7e6ebc4cb72 YconP020.cpp
--- a/YconP020.cpp Fri Jul 01 13:22:18 2016 +0000
+++ b/YconP020.cpp Sun Jul 03 10:38:58 2016 +0000
@@ -1,10 +1,84 @@
#include "mbed.h"
#include "YconP020.h"
-#ifdef TARGET_LPC11U35_501
-#include "DirHandle.h" //トラ技ARMライタでは何故かこれが必要
+#if DEVICE_LOCALFILESYSTEM == 0
+#include "DirHandle.h"
#endif
#include <cctype>
+#include <functional>
+int toint(const string::const_iterator& begin, const string::const_iterator& end)
+{
+ if(begin==end) return 0;
+ int val=0;
+ bool minus=false;
+ string::const_iterator p=begin;
+ if(*p=='-') {
+ minus=true;
+ p++;
+ }
+ while( p!=end) {
+ if((*p)<'0' || '9'<(*p)) break;
+ val = val*10+(*p)-'0';
+ p++;
+ }
+ if(minus) val = 0-val;
+ return val;
+}
+int toint(const string& s) {return toint(s.begin(),s.end());}
+string tostring(int i)
+{
+ string s;
+ bool minus=false;
+ if(i<0) {
+ minus=true;
+ i=0-i;
+ }
+ do {
+ s += (i%10)+'0';
+ i/=10;
+ } while(i!=0);
+ if(minus) s += '-';
+ reverse(s.begin(),s.end());
+ return s;
+}
+template<class T>
+T skipspace(T begin, T end)
+{
+ return find_if(begin,end, bind1st(not2(equal_to<char>()), ' '));
+}
+
+// class YconP020GBuf
+void YconP020GBuf::pixel(int x, int y, int b)
+{
+ if(x<0 || x>=MAX_X/pixelsizex || y<0 || y>=MAX_Y/pixelsizey) return;
+ for(int i=0; i<pixelsizex; i++) {
+ for(int j=0; j<pixelsizey; j++) {
+ pixel1x1(x*pixelsizex+i, y*pixelsizey+j, b);
+ }
+ }
+}
+void YconP020GBuf::setfontscale(uint8_t x, uint8_t y)
+{
+ if(x==0 || y==0) return;
+ locate((_column*pixelsizex+x-1)/x, (_row*pixelsizey+y-1)/y);
+ pixelsizex=x;
+ pixelsizey=y;
+}
+void YconP020GBuf::cls()
+{
+ setfontscale();
+ GraphicsDisplay::cls();
+ locate(0,0);
+}
+
+void YconP020GBuf::pixel1x1(int x, int y, int b)
+{
+ if(x<0 || x>=MAX_X || y<0 || y>=MAX_Y) return;
+ if(!b) buffer[MAX_Y-1-y][x/8] |= 1<<(7-(x%8));
+ else buffer[MAX_Y-1-y][x/8] &= ~(1<<(7-(x%8)));
+}
+
+// class YconP020
YconP020::YconP020(PinName tx, PinName rx) : uart(tx,rx), use_recinbuf(false)
{
uart.baud(115200);
@@ -49,7 +123,7 @@
const vector<string>& YconP020::getfilelist(const vector<string>& dirs)
{
filelist.clear();
- for(vector<string>::const_iterator p=dirs.begin(); p<dirs.end(); p++) {
+ for(vector<string>::const_iterator p=dirs.begin(); p!=dirs.end(); p++) {
string dn;
if((*p)[0]!='/') dn='/';
dn += *p;
@@ -63,22 +137,17 @@
while((file=readdir(dir))!=NULL) {
filename=file->d_name;
if(filename.size()<4) continue;
- string extstr(4,' ');
- transform(filename.end()-4, filename.end(), extstr.begin(), toupper);
+ string extstr;
+ transform(filename.end()-4, filename.end(), back_inserter(extstr), toupper);
if(extstr==".BMP") {
filelist.push_back('/'+ *p +'/'+filename);
}
}
closedir(dir);
}
+ sort(filelist.begin(),filelist.end());
return filelist;
}
-const vector<string>& YconP020::getfilelist(const string& dir)
-{
- vector<string> fslist;
- fslist.push_back(dir);
- return getfilelist(fslist);
-}
const vector<string>& YconP020::getfilelistall()
{
vector<string> fslist;
@@ -110,15 +179,7 @@
recinbuf.clear();
return r;
}
-void YconP020::dispstoredpict(int picnum)
-{
- use_recinbuf=true;
- command_mode();
- uart.printf("D %d\r", picnum);
- wait_command_ready();
- use_recinbuf=false;
- recinbuf.clear();
-}
+
YconP020::error_t YconP020::storepictfile(const string& filename, const int picnum)
{
if(picnum>6 || picnum<0) return REGINDEXERR;
@@ -134,7 +195,7 @@
}
const size_t BMPHEADERSIZE = 62;
-const int8_t BMPHEADER[BMPHEADERSIZE]
+const uint8_t BMPHEADER[BMPHEADERSIZE]
= {0x42, 0x4d, 0xbd, 0x0a, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x28, 0x00,
0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x60, 0x00,
@@ -150,11 +211,11 @@
uart.puts("exit\r");
while(lastchar!='>') wait_ms(1);
lastchar='\0';
- for(size_t i=0; i<BMPHEADERSIZE; i++) {
+ for(int i=0; i<BMPHEADERSIZE; i++) {
uart.putc(BMPHEADER[i]);
}
- for(size_t y=0; y<internalbuf.height(); y++) {
- for(size_t x=0; x<internalbuf.width()/8; x++) uart.putc(internalbuf.get8(x,y));
+ for(int y=0; y<YconP020GBuf::MAX_Y; y++) {
+ for(int x=0; x<YconP020GBuf::MAX_X/8; x++) uart.putc(internalbuf.getbyte(x,y));
uart.putc(0x00);
uart.putc(0x00);
uart.putc(0x00);
@@ -189,17 +250,114 @@
mem_fun<void,YconP020,char>(&YconP020::push_recbuf), this));
}
-YconP020::error_t YconP020::sendfile(const string& filename) {
- FILE *fp=fopen(filename.c_str(),"r");
- if(fp==NULL) return FILEOPENERR;
- int c;
- while((c=fgetc(fp)) != EOF) {
- uart.putc(c);
+YconP020::error_t YconP020::sendfile(const string& filename)
+{
+ FILE *fp=fopen(filename.c_str(),"r");
+ if(fp==NULL) return FILEOPENERR;
+ int c;
+ while((c=fgetc(fp)) != EOF) {
+ uart.putc(c);
+ }
+ fclose(fp);
+ return NOERROR;
+}
+
+// 出力を横取りして拡張コマンドを処理するための関数群
+bool commandline_D(YconP020& epd, const string& comline, string& retstr)
+{
+ string::const_iterator cp=skipspace(comline.begin()+1,comline.end());
+ if(cp==comline.end()) return false;
+ switch(toupper(*cp)) {
+ case 'F':
+ if(++cp==comline.end()) return false;
+ if(*cp==' ') {
+ // "D F filename"
+ cp=skipspace(cp,comline.end());
+ if(cp!=comline.end()) {
+ string fn(cp,comline.end());
+ if(epd.dispfile(fn)!=YconP020::NOERROR) retstr += "\r\n"+fn+" not found\r\n!";
+ } else retstr += "Filename is required\r\n";
+ } else {
+ // "D Fnumber"
+ int i=toint(cp,comline.end());
+ if(0<=i && i<epd.getfilelist().size()) epd.dispfile(epd.getfilelist()[i]);
+ else retstr += "\r\nfile No."+string(cp,comline.end())+" not found\r\n!";
}
- fclose(fp);
- return NOERROR;
+ return true;
+ case 'I':
+ // "D I"
+ epd.display_internalbuf();
+ return true;
+ default:
+ return false;
+ }
+}
+bool commandline_L(YconP020& epd, const string &comline, string& retstr)
+{
+ string::const_iterator cp=comline.begin()+1;
+ if(cp==comline.end()) return false;
+ if(toupper(*cp)!='S') return false;
+ if(++cp==comline.end()) {
+ // "LS"
+ } else {
+ if(*cp!=' ') return false;
+ cp=skipspace(cp,comline.end());
+ if(cp==comline.end()) {
+ // "LS "
+ } else if(*cp=='*') {
+ // "LS *"
+ epd.getfilelistall();
+ } else {
+ // "LS pathname"
+ epd.getfilelist(string(cp,comline.end()));
+ }
+ }
+ for(int i=0; i<epd.getfilelist().size(); i++) {
+ retstr += tostring(i)+": "+epd.getfilelist()[i]+"\r\n";
}
-
+ return true;
+}
+void T_esc_num(YconP020& epd, string::const_iterator& p, const string::const_iterator& e)
+{
+ char c=*p++;
+ const string::const_iterator semicolon=find(p,e,';');
+ if(semicolon==e) return;
+ const string::const_iterator comma=find(p,semicolon,',');
+ int x,y;
+ if(comma==semicolon) {
+ x=0;
+ y=0;
+ } else {
+ x=toint(p, comma);
+ y=toint(comma+1,semicolon);
+ }
+ p=semicolon;
+ if(c=='l') epd.text()->locate(x,y);
+ if(x==0) x=1;
+ if(y==0) y=1;
+ if(c=='s') epd.setfontscale(x,y);
+}
+bool commandline_T(YconP020& epd, const string &comline)
+{
+ if(comline.size()>2 && comline[1]==' ') {
+ for(string::const_iterator p=comline.begin()+2; p<comline.end(); p++) {
+ if(*p=='\\') {
+ if(++p==comline.end()) break;
+ switch(*p) {
+ case 'c': epd.text()->cls(); break;
+ case 'f': epd.display_internalbuf(); break;
+ case 'n': epd.text()->putc('\n'); break;
+ case 'l': case 's':
+ T_esc_num(epd,p,comline.end()); break;
+ case '\\': epd.text()->putc('\\'); break;
+ default: epd.text()->putc(*p);
+ }
+ } else epd.text()->putc(*p);
+ }
+ return true;
+ }
+ return false;
+}
int YconP020::putc_intercept(int c)
{
if(localcomline.size()) {
@@ -210,56 +368,35 @@
return c;
}
push_recbuf('\n');
+ bool command_done=false;
+ string retstr;
switch(toupper(localcomline[0])) {
case 'D':
- if(commandline_D(localcomline)) {
- localcomline.clear();
- push_recbuf('!');
- lastchar='!';
- return c;
- }
+ command_done=commandline_D(*this, localcomline, retstr);
break;
case 'L':
- if(commandline_L(localcomline)) {
- localcomline.clear();
- push_recbuf('!');
- lastchar='!';
- return c;
- }
+ command_done=commandline_L(*this, localcomline, retstr);
break;
case 'T':
- if(localcomline.size()>2 && localcomline[1]==' ') {
- for(string::const_iterator p=localcomline.begin()+2; p<localcomline.end(); p++) {
- switch(*p) {
- case '\\':
- if(++p==localcomline.end()) break;
- if(*p=='n') {
- text()->putc('\n');
- } else if(*p=='\\') {
- text()->putc('\\');
- }
- break;
- default:
- text()->putc(*p);
- }
- }
- localcomline.clear();
- push_recbuf('!');
- lastchar='!';
- return c;
- }
+ command_done=commandline_T(*this, localcomline);
break;
case 'W':
if(localcomline.size()>=2 && toupper(localcomline[1])=='I') {
clear_internalbuf();
text()->locate(0,0);
- localcomline.clear();
- push_recbuf('!');
- lastchar='!';
- return c;
+ command_done=true;
}
break;
}
+ if(!retstr.empty()) push_recbuf(retstr);
+ if(command_done) {
+ //拡張コマンドとして処理した
+ localcomline.clear();
+ push_recbuf('!');
+ lastchar='!';
+ return c;
+ }
+ //拡張コマンドではなかったので Y-con P020に送る
uart.puts(localcomline.c_str());
uart.putc('\r');
localcomline.clear();
@@ -274,70 +411,9 @@
}
return c;
}
-bool skipspace(string::const_iterator &p, string::const_iterator end)
-{
- while(*++p==' ') {
- if(p==end) return false;
- }
- return true;
-}
-bool YconP020::commandline_D(const string &comline)
-{
- string::const_iterator cp=comline.begin();
- if(!skipspace(cp, comline.end())) return false;
- switch(toupper(*cp)) {
- case 'F':
- if(*++cp==' ') {
- while(*++cp==' ') {
- if(cp==comline.end()) break;
- }
- if(cp<comline.end()) {
- const string fn=comline.substr(cp-comline.begin());
- if(dispfile(fn)!=NOERROR) push_recbuf("\r\n"+fn+" not found\r\n!");
- }
- } else {
- const string fns=comline.substr(cp-comline.begin());
- int fn=atoi(fns.c_str());
- if(filelist.size()<fn || fn<0) push_recbuf("\r\nfile No."+fns+" not found\r\n!");
- else dispfile(filelist[fn]);
- }
- return true;
- case 'I':
- display_internalbuf();
- return true;
- default:
- return false;
- }
-}
-bool YconP020::commandline_L(const string &comline)
-{
- string::const_iterator cp=comline.begin();
- if(toupper(*++cp)=='S') {
- skipspace(cp,comline.end());
- if(cp==comline.end()) {
- //getfilelist();
- } else if(*cp=='*') {
- getfilelistall();
- } else {
- getfilelist(comline.substr(cp-comline.begin()));
- }
- for(vector<string>::const_iterator p=filelist.begin(); p<filelist.end(); p++) {
- /* ostringstream を使うとメモリ(RAM)使用量が跳ね上がっちゃう
- ostringstream s;
- s << p-filelist.begin() <<": " << *p << "\r\n";
- outputstr(s.str());
- */
- char buf[4];
- sprintf(buf,"%3d",p-filelist.begin());
- push_recbuf(string(buf)+": "+(*p)+"\r\n");
- }
- return true;
- }
- return false;
-}
-//sub-functions for execute commands
-void YconP020::void_command(const string& command, bool waitready)
+// Y-conP 020 のコマンドを関数化するためのヘルパー関数群
+void YconP020::send_command(const string& command, bool waitready)
{
use_recinbuf=true;
command_mode();
@@ -346,70 +422,44 @@
uart.putc('\r');
if(waitready) wait_command_ready();
use_recinbuf=false;
- recinbuf.clear();
- push_recbuf('!');
-}
-void YconP020::set_intparam(const string& command, int param)
+}
+void YconP020::void_command(const string& command, bool waitready)
{
- use_recinbuf=true;
- command_mode();
- lastchar=' ';
- uart.printf("%s %4d\r", command.c_str(), param);
- wait_command_ready();
- use_recinbuf=false;
+ send_command(command, waitready);
recinbuf.clear();
- push_recbuf('!');
+}
+void YconP020::set_param(const string& command, int param)
+{
+ send_command(command+' '+tostring(param));
+ recinbuf.clear();
}
int YconP020::get_intparam(const string& command, const string& retstr)
{
+ send_command(command);
int retval;
- use_recinbuf=true;
- command_mode();
- lastchar=' ';
- uart.puts(command.c_str());
- uart.putc('\r');
- wait_ms(100);
- size_t i=recinbuf.find(retstr);
- retval = atoi(recinbuf.substr(i+retstr.size()+1).c_str());
- wait_command_ready();
- use_recinbuf=false;
+ string::iterator p=search(recinbuf.begin(),recinbuf.end(),
+ retstr.begin(), retstr.end());
+ if(p!=recinbuf.end()) p+=retstr.size()+1;
+ retval=toint(p,recinbuf.end());
recinbuf.clear();
- push_recbuf('!');
return retval;
}
bool YconP020::get_boolparam(const string& command)
{
+ send_command(command);
bool retval=false;
- use_recinbuf=true;
- command_mode();
- lastchar=' ';
- uart.puts(command.c_str());
- uart.putc('\r');
- wait_ms(100);
if(recinbuf.find("Enable")!=string::npos) retval=true;
- wait_command_ready();
- use_recinbuf=false;
recinbuf.clear();
- push_recbuf('!');
return retval;
}
string YconP020::get_stringparam(const string& command)
{
- use_recinbuf=true;
- command_mode();
- lastchar=' ';
- uart.puts(command.c_str());
- uart.putc('\r');
- wait_command_ready();
- use_recinbuf=false;
- string retval;
- string::const_iterator p=recinbuf.begin()+recinbuf.find(command)+command.size();
- while(p<recinbuf.end()) {
- if(*p=='!') break;
- retval += *p++;
- }
+ send_command(command);
+ string::iterator p=search(recinbuf.begin(),recinbuf.end(),
+ command.begin(), command.end());
+ if(p!=recinbuf.end()) p+=command.size();
+ string retval(p,find(p,recinbuf.end(),'!'));
recinbuf.clear();
- push_recbuf('!');
return retval;
}
diff -r 4dbc7e226777 -r a7e6ebc4cb72 YconP020.h
--- a/YconP020.h Fri Jul 01 13:22:18 2016 +0000
+++ b/YconP020.h Sun Jul 03 10:38:58 2016 +0000
@@ -9,47 +9,40 @@
#include <queue>
using namespace std;
#include "GraphicsDisplay.h"
+/// \class TextDisplay
+/// \brief interface class for display text
+///
+/// Because it is derived from mbed::Stream, TextDisplay has function putc(),puts(),printf() and more
+
+// for internal baffer
class YconP020GBuf : public GraphicsDisplay {
public:
- enum INTERNALBUF { MAX_X=200,MAX_Y=96 };
- YconP020GBuf(const char *name=NULL) : GraphicsDisplay(name) {
- setpixelsize();
- }
- virtual void pixel(int x, int y, int b) {
- if(x<0 || x>=MAX_X/pixelsizex || y<0 || y>=MAX_Y/pixelsizey) return;
- for(int i=0; i<pixelsizex; i++) {
- for(int j=0; j<pixelsizey; j++) {
- pixel1x1(x*pixelsizex+i, y*pixelsizey+j, b);
- }
- }
- }
- void setpixelsize(int x=1, int y=1) {
- pixelsizex=x;
- pixelsizey=y;
- }
+ enum { MAX_X=200,MAX_Y=96 };
+ YconP020GBuf(const char *name=NULL) : GraphicsDisplay(name) { setfontscale(); }
+ virtual void pixel(int x, int y, int b);
+ void setfontscale(uint8_t x=1, uint8_t y=1);
+ void pixel1x1(int x, int y, int b);
+ virtual void cls();
+ uint8_t getbyte(size_t x,size_t y) const {return buffer[y][x];}
+protected:
+private:
virtual int width() {return MAX_X;}
virtual int height() {return MAX_Y;}
- int8_t get8(size_t x,size_t y) {return buffer[y][x];}
-protected:
- void pixel1x1(int x, int y, int b) {
- if(x<0 || x>=MAX_X || y<0 || y>=MAX_Y) return;
- if(!b) buffer[MAX_Y-1-y][x/8] |= 1<<(7-(x%8));
- else buffer[MAX_Y-1-y][x/8] &= ~(1<<(7-(x%8)));
- }
-private:
- int8_t buffer[MAX_Y][MAX_X/8];
- int pixelsizex;
- int pixelsizey;
+ uint8_t buffer[MAX_Y][MAX_X/8];
+ uint8_t pixelsizex;
+ uint8_t pixelsizey;
};
+/// Y-con P020 Electric Paper Display
class YconP020 : public Stream {
static const size_t MAXRECBUFSIZE=1000;
public:
typedef enum {
NOERROR=0,FILEOPENERR=1,REGINDEXERR=2,FILENOTEXIST=3,DIROPENERR=4
} error_t;
-
+
+ /// @param UART PinName to Y-con P020
YconP020(PinName tx, PinName rx);
/// Similar to Serial::readable()
@@ -64,36 +57,55 @@
bool command_mode();
//commands
- string help_str() {return get_stringparam("?");} // (1)?
- void clear_screen(bool white=true) {void_command(white? "W":"B");} //(2)W, (3)B
- void negative_screen() {void_command("N");} //(4)N
- void dispstoredpict(int picnum); //(5)D
- error_t storepictfile(const string& filename, const int picnum); //(6)R
- string infomation_str() {return get_stringparam("I");}//(7)I
- void start_demo() {void_command("DEMO",false);} //(8)DEMO
+ /// Y-con P020 command (1)?
+ string help_str() {return get_stringparam("?");}
+ /// Y-con P020 command (2)W, (3)B
+ void clear_screen(bool white=true) {void_command(white? "W":"B");}
+ /// Y-con P020 command (4)N
+ void negative_screen() {void_command("N");}
+ /// Y-con P020 command (5)D
+ void dispstoredpict(int picnum) {set_param("D", picnum);} //(5)D
+ /// Y-con P020 command (6)R
+ error_t storepictfile(const string& filename, const int picnum);
+ /// Y-con P020 command (7)I
+ string infomation_str() {return get_stringparam("I");}
+ /// Y-con P020 command (8)DEMO
+ void start_demo() {void_command("DEMO",false);}
+ /// Y-con P020 command (8)DEMO stop (send ctrl+Z)
void stop_demo();
- int get_interval() {return get_intparam("INTERVAL","Interval");} //(9)INTERVAL
- void set_interval(int t) {set_intparam("INTERVAL", t);}
- //(10)LASTWAIT
- int get_lastwait() {return get_intparam("LASTWAIT","Wait");}
- void set_lastwait(int t) {return set_intparam("LASTWAIT", t);}
- //(11)STANDBY
- bool get_standby() {return get_boolparam("STANDBY");}
- void set_standby(bool f) {return set_intparam("STANDBY", f);}
- //(12)LED
- bool get_led() {return get_boolparam("LED");}
- void set_led(bool f) {return set_intparam("LED", f);}
- //(13)P37
- int get_p37() {return get_boolparam("P37");}
- void set_p37(bool f) {return set_intparam("P37", f);}
- void exit_commandmode() {void_command("EXIT",false);} //(14)EXIT
- void reset_screen() {void_command("RESET",false);} //(15)RESET
- string yslab_info() {return get_stringparam("YSLAB");} //(16)YSLAB
+ /// Y-con P020 command (9)INTERVAL
+ int command_interval() {return get_intparam("INTERVAL","Interval");}
+ /// Y-con P020 command (9)INTERVAL time
+ void command_interval(int t) {set_param("INTERVAL", t);}
+ /// Y-con P020 command (10)LASTWAIT
+ int command_lastwait() {return get_intparam("LASTWAIT","Wait");}
+ /// Y-con P020 command (10)LASTWAIT time
+ void command_lastwait(int t) {return set_param("LASTWAIT", t);}
+ /// Y-con P020 command (11)STANDBY
+ bool command_standby() {return get_boolparam("STANDBY");}
+ /// Y-con P020 command (11)STANDBY [0|1]
+ void command_standby(bool f) {return set_param("STANDBY", f);}
+ /// Y-con P020 command (12)LED
+ bool command_led() {return get_boolparam("LED");}
+ /// Y-con P020 command (12)LED [0|1]
+ void command_led(bool f) {return set_param("LED", f);}
+ /// Y-con P020 command (13)P37
+ bool command_p37() {return get_boolparam("P37");}
+ /// Y-con P020 command (13)P37 [0|1]
+ void command_p37(bool f) {return set_param("P37", f);}
+ /// Y-con P020 command (14)EXIT
+ void command_exit() {void_command("EXIT",false);}
+ /// Y-con P020 command (15)RESET
+ void command_reset() {void_command("RESET",false);}
+ /// Y-con P020 command (16)YSLAB
+ string yslab_info() {return get_stringparam("YSLAB");}
/// get file list of directories
const vector<string>& getfilelist(const vector<string>& dirs);
/// get file list of directory
- const vector<string>& getfilelist(const string& dir);
+ const vector<string>& getfilelist(const string& dir) {
+ return getfilelist(vector<string>(1,dir));
+ }
/// return previous file list
const vector<string>& getfilelist() const {return filelist;}
/// get all file list
@@ -101,11 +113,29 @@
/// display file
error_t dispfile(const string& filename);
+ /** output text to internal buffer. for example
+ * @code
+ * epd.text()->cls();
+ * epd.setfontscale(2,3);
+ * epd.text()->puts("Hello World\nYconP020\n");
+ * epd.setfontscale();
+ * epd.text()->printf("%d\n", epd.command_led());
+ * epd.display_internalbuf();
+ * @endcode
+ */
TextDisplay* text() {return &internalbuf;}
- void setpixelsize(int x=0, int y=0) {internalbuf.setpixelsize(x,y);}
- void pset(int x, int y, bool b=true) {internalbuf.pixel(x,y,b);}
- void clear_internalbuf(int8_t data=0) { internalbuf.cls(); }
+ /// set size of pixel
+ void setfontscale(uint8_t x=1, uint8_t y=1) {internalbuf.setfontscale(x,y);}
+ /// set pixel at internal buffer
+ void pset(int x, int y, bool b=true) {internalbuf.pixel1x1(x,y,b);}
+ /// clear internal buffer
+ void clear_internalbuf() { internalbuf.cls(); }
+ /// send internal buffer to Y-con P020
void display_internalbuf();
+ /// width of Y-con P020 (==200)
+ int width() const { return YconP020GBuf::MAX_X; }
+ /// height of Y-con P020 (==96)
+ int height() const { return YconP020GBuf::MAX_Y; }
protected:
void uartint();
void push_recbuf(char c);
@@ -114,13 +144,14 @@
error_t sendfile(const string& filename);
//for command line intercept
- int putc_intercept(int c);
- bool commandline_D(const string &comline);
- bool commandline_L(const string &comline);
+ string localcomline;
+ virtual int putc_intercept(int c);
- //sub-functions for execute commands
+ //sub-functions for functions of Y-con P020 command
+ void send_command(const string& command, bool waitready=true);
void void_command(const string& command, bool waitready=true);
- void set_intparam(const string& command, int param);
+ void set_param(const string& command, int param);
+ //void set_param(const string& command, bool param); //int版で代用できるので要らない
int get_intparam(const string& command, const string& retstr);
bool get_boolparam(const string& command);
string get_stringparam(const string& command);
@@ -132,7 +163,6 @@
string recinbuf;
bool use_recinbuf;
vector<string> filelist;
- string localcomline;
YconP020GBuf internalbuf;
virtual int _getc();