使用了glcd、time库,可以在屏上显示图形和各种字体的时钟数字。
但是不知道如何直接显示中文,目前英文没问题。英文字体是用glcd库推荐的font creator 2.0
显示屏是lcdmk赠送活动中赠送的无字库屏,便宜实惠
http://www.ourdev.cn/bbs/bbs_content.jsp?bbs_sn=5339566&bbs_page_no=1&bbs_id=999910元邮费得的6个lcd
没有外接时钟芯片。
下面是代码:
#include <glcd.h>
#include <time.h>
#include "fonts/allfonts.h" // system and arial14 fonts are used
#include "bitmaps/allbitmaps.h" // all images in the bitmap dir
image_t icon;
gtext textarea; // a text area to be defined later in the sketch
gtext textareaarray[3]; // an array of text areas
gtext countdownarea = gtext(glcd.centerx, glcd.centery,1,1,arial_14); // text area for countdown digits
unsigned long startmillis;
unsigned int loops = 0;
unsigned int iter = 0;
int thedelay = 20;
void setup()
{
glcd.init(); // initialise the library, non inverted writes pixels onto a clear screen
settime(18,31,50,15,2,12); // set time to 4:37 am jan 2 2010
if(glcd.height >= 64)
icon = arduinoicon64x64; // the 64 pixel high icon
else
icon = arduinoicon64x32; // the 32 pixel high icon
glcd.clearscreen();
glcd.drawbitmap(icon, 0, 0);
}
void loop()
{
glcd.cursortoxy(72, 36);
glcd.selectfont(launica);
if(hour() < 10)
glcd.print(Ɔ');
glcd.print(hour());
printdigits(minute());
printdigits(second());
glcd.cursortoxy(72,50 );
if(month() < 10) glcd.print(Ɔ');glcd.print(month()); glcd.print("-");
if(day() < 10) glcd.print(Ɔ');glcd.println(day());
glcd.selectfont(arial14);
glcd.cursortoxy(94, 32);
if(month() < 10) glcd.print(Ɔ');glcd.print(month()); glcd.print("-");
if(day() < 10) glcd.print(Ɔ');glcd.println(day());
glcd.print("aprs test message...");
}
void printdigits(int digits){
// utility function for digital clock display: prints preceding colon and leading 0
glcd.print(":");
if(digits < 10)
glcd.print(Ɔ');
glcd.print(digits);
}