next up previous
Next: Makefile Up: Source Code Previous: Graphic LCD Library: glcd.c

Demo Program: hz-xbm.h, pic1.xbm, q.xbm, and main.c

ATTENTION: main.c must be in GB2312 encoding due to display Chinese characters!
hz-xbm.h:

#define sun_width 16
#define sun_height 16
static unsigned char sun_bits[] PROGMEM = {
0x80, 0x00, 0x80, 0x40, 0x02, 0x41, 0x01, 0x41, 0xfe, 0x4f, 0x20, 0x52, 0x40, 0x64, 0x80, 0x01, 0x02, 0x06, 0x01, 0x00, 0xfe, 0xff, 0x00, 0x04, 0x00, 0x02, 0x80, 0x01, 0xc0, 0x00, 0x00, 0x00};
#define ge_width 16
#define ge_height 16
static unsigned char ge_bits[] PROGMEM = {
0x01, 0x01, 0xfe, 0x3f, 0x40, 0x69, 0x32, 0xa5, 0x01, 0x21, 0xfe, 0x7f, 0x00, 0x20, 0xf0, 0x27, 0x20, 0x24, 0x20, 0x24, 0xf2, 0x27, 0x01, 0x20, 0xfe, 0x3f, 0x00, 0x60, 0x00, 0x20, 0x00, 0x00};
#define shi_width 16
#define shi_height 16
static unsigned char shi_bits[] PROGMEM = {
0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x84, 0x00, 0xb8, 0xfe, 0x84, 0x92, 0x82, 0x92, 0xfe, 0x92, 0x91, 0x92, 0x91, 0x92, 0xb1, 0xfe, 0x91, 0x00, 0x81, 0x00, 0x83, 0x01, 0x82, 0x00, 0x00, 0x00};
#define bai_width 16
#define bai_height 16
static unsigned char bai_bits[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0xfe, 0x1f, 0x84, 0x10, 0x84, 0x30, 0x84, 0x50, 0x84, 0x90, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0xfe, 0x3f, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00};
#define chi_width 16
#define chi_height 16
static unsigned char chi_bits[] PROGMEM = {
0x20, 0x08, 0x62, 0x06, 0x84, 0x00, 0xf8, 0x3f, 0x41, 0x21, 0x42, 0x22, 0x4c, 0x3c, 0xf0, 0xa7, 0x48, 0x64, 0x44, 0x24, 0xfe, 0x27, 0x04, 0x24, 0x04, 0x24, 0xfe, 0x6f, 0x00, 0x24, 0x00, 0x00};

pic1.xbm:

#define pic1_width 32
#define pic1_height 43
static char PROGMEM pic1_bits[] = {
  0x00, 0x80, 0x00, 0x10, 0x00, 0xC0, 0x07, 0x00, 0x00, 0xF8, 0x3F, 0x80, 
  0x00, 0xFE, 0xFF, 0x00, 0x00, 0xFE, 0xFF, 0x01, 0x00, 0xFF, 0xFF, 0x01, 
  0x40, 0xFD, 0xFF, 0x07, 0xA0, 0xFF, 0xFF, 0x8F, 0xF0, 0xFF, 0xFF, 0x1F, 
  0xF0, 0xFF, 0xFF, 0x3F, 0xF0, 0xFF, 0xFB, 0xFF, 0xF8, 0xBF, 0xFD, 0x3F, 
  0xF8, 0x5F, 0xD2, 0x7F, 0xFC, 0x1F, 0xF9, 0x7F, 0xF8, 0xC7, 0xF8, 0x7F, 
  0xFC, 0x1F, 0xFD, 0x7F, 0xFC, 0x5F, 0x1A, 0xFD, 0xFC, 0x37, 0xD5, 0x76, 
  0xFC, 0xA9, 0xE0, 0x7F, 0x3C, 0x48, 0xEB, 0x7D, 0x78, 0x2F, 0x6A, 0x36, 
  0xF8, 0x96, 0x94, 0x39, 0x18, 0xA0, 0x2C, 0x02, 0x30, 0x28, 0x94, 0x14, 
  0x00, 0x20, 0x18, 0x11, 0x00, 0x00, 0xE0, 0x15, 0x00, 0x00, 0x38, 0x0C, 
  0x00, 0x91, 0x59, 0x02, 0x00, 0xC0, 0xBB, 0x08, 0x00, 0x81, 0x6E, 0x13, 
  0x00, 0x00, 0xD2, 0x09, 0x00, 0x24, 0x1C, 0x05, 0x00, 0x00, 0x76, 0x0A, 
  0x00, 0xD4, 0xFF, 0x09, 0x00, 0xF0, 0x3E, 0x05, 0x00, 0x00, 0xE1, 0x07, 
  0x00, 0x5C, 0x9D, 0x3E, 0x00, 0xEE, 0x65, 0xFE, 0x00, 0x9E, 0xDA, 0xFF, 
  0x00, 0x6F, 0xB5, 0xFF, 0x80, 0xFF, 0xF7, 0xFF, 0xC0, 0xFF, 0x7F, 0xFF, 
  0xE0, 0xFF, 0xFF, 0xFF, };

q.xbm:

#define q_width 32
#define q_height 61
static unsigned char q_bits[] PROGMEM = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x10, 0x00, 0x00, 0xf0, 0xff, 0x03, 0x00, 0xf8, 0xff, 0x3f, 0x00,
   0xfe, 0xff, 0xff, 0x01, 0xfe, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x0f,
   0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x3f,
   0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f,
   0xfe, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0x7f, 0xf8, 0xff, 0xff, 0x7f,
   0xa0, 0xa5, 0xff, 0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x80, 0xff, 0x3f,
   0x00, 0x80, 0xff, 0x3f, 0x00, 0x80, 0xff, 0x3f, 0x00, 0xe0, 0xff, 0x3f,
   0x00, 0xe0, 0xff, 0x1f, 0x00, 0xf0, 0xff, 0x1f, 0x00, 0xf8, 0xff, 0x1f,
   0x00, 0xfc, 0xff, 0x1f, 0x00, 0xfc, 0xff, 0x0f, 0x00, 0xfe, 0xff, 0x0f,
   0x00, 0xff, 0xff, 0x07, 0x80, 0xff, 0xff, 0x03, 0x80, 0xff, 0xff, 0x01,
   0xc0, 0xff, 0xff, 0x00, 0xc0, 0xff, 0x7f, 0x00, 0xe0, 0xff, 0x7f, 0x00,
   0xe0, 0xff, 0x3f, 0x00, 0xe0, 0xff, 0x1f, 0x00, 0xc0, 0xff, 0x0f, 0x00,
   0xc0, 0xff, 0x0f, 0x00, 0xc0, 0xff, 0x07, 0x00, 0x80, 0xff, 0x03, 0x00,
   0x00, 0xff, 0x01, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x80, 0x07, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xe0, 0x1f, 0x00,
   0x00, 0xe0, 0x1f, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xc0, 0x0f, 0x00,
   0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00 };

main.c:

/*
  demo of glcd lib.
 */
#include <avr/io.h>
#include <inttypes.h>
#include <avr/pgmspace.h>
#include "glcd.h"

#include "pic1.xbm"
#include "q.xbm"

//hz font in xbm format
#include "hz-xbm.h"

//fonts stored in flash completely.
PGM_P s[] PROGMEM = {
  sun_bits, ge_bits, shi_bits, bai_bits, chi_bits};

const char msg[] PROGMEM = "SD卡汉字库演示程序";

int main (void)
{
  int i;

  glcd_init_write();
  
  glcd_write_command(LCD_DISP_ON,CS_BOTH);

  glcd_fill(0, CS_BOTH);
  
  glcd_puts_hz(msg, 10, 0, 0, CS_LEFT, CEMENT);

  for(i=0;i<80;i++)
    _delay_ms(100);

  glcd_fill(0, CS_BOTH);
  /*attention: it can only display 7 chinese character per page(per line),
    14 character per screen*/
  glcd_puts_hz(PSTR("◎SD字库:输出程序区的汉字☆"), 15, 0, 0, CS_LEFT, CEMENT);

  for(i=0;i<80;i++)
    _delay_ms(100);
  
  glcd_fill(0, CS_BOTH);
  glcd_puts_hz(PSTR("∥以下文字图案使用程序区字体"), 14, 0, 0, CS_LEFT, CEMENT);
  for(i=0;i<40;i++)
    _delay_ms(100);

  glcd_fill(0, CS_BOTH);
  glcd_puts_hz16x16(s, 5, 0, 0, CS_LEFT, CEMENT);
  
  for(i=0;i<40;i++)
    _delay_ms(100);
  
  glcd_fill(0, CS_BOTH);
  glcd_show_xbm(pic1_bits, 32, 43, CS_LEFT);
  glcd_puts_5x7("WANTED!!! Name:Sun Ge Sex: Male", 31, 0, 0, CS_RIGHT, NOT_CEMENT);
  
  for(i=0;i<30;i++)
    _delay_ms(100);

  glcd_fill(0, CS_BOTH);  
  glcd_puts_5x7("WHO is this man? ??Sun Ge????!!", 31, 0, 0, CS_LEFT, NOT_CEMENT);
  glcd_show_xbm(q_bits, 32, 61, CS_RIGHT);

  for(i=0;i<30;i++)
    _delay_ms(100);

  glcd_fill(0, CS_BOTH);  
  glcd_puts_5x7("Demo End", 8, 3, 0, CS_BOTH, NOT_CEMENT);

  for (;;) {
  }

  return 0;
}



sun ge 2007-10-24