首先声明近日二叔杂事较多,基本完全拷贝卓大的帖子啦
http://www.52pi.net/forum.php?mod=viewthread&tid=1384
有木有发现,两个问题,日期不居中,难看,时间也不对,
网络搜索,时区设置,
tzselect
5 - 9 - 1 - 1,不过运行起来问题依旧,重起也不管用,仔细一读,原来没有应用,
TZ='Asia/Shanghai'; export TZ
重起失效,可以写到.profile,
vi .profile
#include <stdio.h> #include <wiringPi.h> #include <mcp23017.h> #include <lcd.h> #include <time.h> int main() { time_t timep; struct tm *ptm; int display,i; wiringPiSetup(); mcp23017Setup (100, 0x20); for(i=0;i<16;i++) pinMode(100+i,OUTPUT); digitalWrite(107,1); digitalWrite(101,0); display=lcdInit(2,16,4,100,102,103,104,105,106,0,0,0,0); lcdHome(display); lcdClear(display); while(1) { time(&timep); ptm=localtime(&timep); lcdPosition(display,3,0); lcdPrintf(display,"%04d/%02d/%02d",1900+ptm->tm_year, 1+ptm->tm_mon, ptm- >tm_mday); lcdPosition(display,4,1); lcdPrintf(display,"%02d:%02d:%02d",ptm->tm_hour, ptm->tm_min, ptm->tm_sec); delay(100); } }
gcc lcd1602.c -lwiringPi /opt/gpio-lib/WiringBPi_Beta_V2.0/devLib/lcd.o -o lcd1602 ./lcd162
好啦,这次搞定啦,还是居中漂亮吧