入手了几个LCD5110,自己整理了一些5*8的ASCII码点阵。心血来潮又画了一些原创图标。共享给有需要的人使用。
字库文件中的字符已经按照ASCII码表顺序排列,可以直接使用字符串索引显示:
LCD_draw_string("ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`");
LCD_draw_string("abcdefghijklmnopqrstuvwxyz{|}~");
LCD_draw_string函数在帖末的LCD5110驱动模板中。
无图无真相:
//-----------------------------font.c
#include
const uint8 font_5_8[][5] = {
/*
* delta = SPCACE(0x20)
*/
0x00, 0x00, 0x00, 0x00, 0x00, // SPACE
0x00, 0x00, 0x4f, 0x00, 0x00, // !
0x00, 0x07, 0x00, 0x07, 0x00, // "
0x14, 0x7f, 0x14, 0x7f, 0x14, // #
0x24, 0x2a, 0x7f, 0x2a, 0x12, // $
0x23, 0x13, 0x08, 0x64, 0x62, // %
0x36, 0x49, 0x55, 0x22, 0x50, // &
0x00, 0x05, 0x03, 0x00, 0x00, // '
0x00, 0x1c, 0x22, 0x41, 0x00, // (
0x00, 0x41, 0x22, 0x1c, 0x00, // )
0x14, 0x08, 0x3e, 0x08, 0x14, // *
0x08, 0x08, 0x3e, 0x08, 0x08, // +
0x00, 0x50, 0x30, 0x00, 0x00, // ,
0x08, 0x08, 0x08, 0x08, 0x08, // -
0x00, 0x60, 0x60, 0x00, 0x00, // .
0x20, 0x10, 0x08, 0x04, 0x02, // /
0x3e, 0x51, 0x49, 0x45, 0x3e, // 0
0x00, 0x42, 0x7f, 0x40, 0x00, // 1
0x42, 0x61, 0x51, 0x49, 0x46, // 2
0x21, 0x41, 0x45, 0x4b, 0x31, // 3
0x18, 0x14, 0x12, 0x7f, 0x10, // 4
0x27, 0x45, 0x45, 0x45, 0x39, // 5
0x3c, 0x4a, 0x49, 0x49, 0x30, // 6
0x01, 0x71, 0x09, 0x05, 0x03, // 7
0x36, 0x49, 0x49, 0x49, 0x36, // 8
0x06, 0x49, 0x49, 0x29, 0x1e, // 9
0x00, 0x36, 0x36, 0x00, 0x00, // :
0x00, 0x56, 0x36, 0x00, 0x00, // ;
0x08, 0x14, 0x22, 0x41, 0x00, // <
0x14, 0x14, 0x14, 0x14, 0x14, // =
0x00, 0x41, 0x22, 0x14, 0x08, // >
0x02, 0x01, 0x51, 0x09, 0x06, // ?
0x32, 0x49, 0x79, 0x41, 0x3e, // @
0x7e, 0x11, 0x11, 0x11, 0x7e, // A
0x7f, 0x49, 0x49, 0x49, 0x36, // B
0x3e, 0x41, 0x41, 0x41, 0x22, // C
0x7f, 0x41, 0x41, 0x22, 0x1c, // D
0x7f, 0x49, 0x49, 0x49, 0x41, // E
0x7f, 0x09, 0x09, 0x09, 0x01, // F
0x3e, 0x41, 0x49, 0x49, 0x7a, // G
0x7f, 0x08, 0x08, 0x08, 0x7f, // H
0x00, 0x41, 0x7f, 0x41, 0x00, // I
0x20, 0x40, 0x41, 0x3f, 0x01, // J
0x7f, 0x08, 0x14, 0x22, 0x41, // K
0x7f, 0x40, 0x40, 0x40, 0x40, // L
0x7f, 0x02, 0x0c, 0x02, 0x7f, // M
0x7f, 0x04, 0x08, 0x10, 0x7f, // N
0x3e, 0x41, 0x41, 0x41, 0x3e, // O
0x7f, 0x09, 0x09, 0x09, 0x06, // P
0x3e, 0x41, 0x51, 0x21, 0x5e, // Q
0x7f, 0x09, 0x19, 0x29, 0x46, // R
0x46, 0x49, 0x49, 0x49, 0x31, // S
0x01, 0x01, 0x7f, 0x01, 0x01, // T
0x3f, 0x40, 0x40, 0x40, 0x3f, // U
0x1f, 0x20, 0x40, 0x20, 0x1f, // V
0x3f, 0x40, 0x38, 0x40, 0x3f, // W
0x63, 0x14, 0x08, 0x14, 0x63, // X
0x07, 0x08, 0x70, 0x08, 0x07, // Y
0x61, 0x51, 0x49, 0x45, 0x43, // Z
0x00, 0x7f, 0x41, 0x41, 0x00, // [
0x02, 0x04, 0x08, 0x10, 0x20, //
0x00, 0x41, 0x41, 0x7f, 0x00, // ]
0x04, 0x02, 0x01, 0x02, 0x04, // ^
0x40, 0x40, 0x40, 0x40, 0x40, // _
0x00, 0x01, 0x02, 0x04, 0x00, // `
0x20, 0x54, 0x54, 0x54, 0x78, // a
0x7f, 0x48, 0x44, 0x44, 0x38, // b
0x38, 0x44, 0x44, 0x44, 0x20, // c
0x38, 0x44, 0x44, 0x48, 0x7f, // d
0x38, 0x54, 0x54, 0x54, 0x18, // e
0x08, 0x7e, 0x09, 0x01, 0x02, // f
0x0c, 0x52, 0x52, 0x52, 0x3e, // g
0x7f, 0x08, 0x04, 0x04, 0x78, // h
0x00, 0x44, 0x7d, 0x40, 0x00, // i
0x20, 0x40, 0x44, 0x3d, 0x00, // j
0x7f, 0x10, 0x28, 0x44, 0x00, // k
0x00, 0x41, 0x7f, 0x40, 0x00, // l
0x7c, 0x04, 0x18, 0x04, 0x78, // m
0x7c, 0x08, 0x04, 0x04, 0x78, // n
0x38, 0x44, 0x44, 0x44, 0x38, // o
0x7c, 0x14, 0x14, 0x14, 0x08, // p
0x08, 0x14, 0x14, 0x18, 0x7c, // q
0x7c, 0x08, 0x04, 0x04, 0x08, // r
0x48, 0x54, 0x54, 0x54, 0x20, // s
0x04, 0x3f, 0x44, 0x40, 0x20, // t
0x3c, 0x40, 0x40, 0x20, 0x7c, // u
0x1c, 0x20, 0x40, 0x20, 0x1c, // v
0x3c, 0x40, 0x30, 0x40, 0x3c, // w
0x44, 0x28, 0x10, 0x28, 0x44, // x
0x0c, 0x50, 0x50, 0x50, 0x3c, // y
0x44, 0x64, 0x54, 0x4c, 0x44, // z
0x00, 0x08, 0x36, 0x41, 0x00, // {
0x00, 0x00, 0x7f, 0x00, 0x00, // |
0x00, 0x41, 0x36, 0x08, 0x00, // }
0x08, 0x04, 0x08, 0x10, 0x08, // ~
/*
* Index = 0x5f
*/
0x08, 0x08, 0x2a, 0x1c, 0x08, // -> [0x5f]
0x08, 0x1c, 0x2a, 0x08, 0x08, // <- [0x60]
0x04, 0x02, 0x7f, 0x02, 0x04, // ↑ [0x61]
0x10, 0x20, 0x7f, 0x20, 0x10, // ↓ [0x62]
0x15, 0x16, 0x7c, 0x16, 0x15, // ¥ [0x63]
0x03, 0x3b, 0x44, 0x44, 0x44, // ℃ [0x64]
0x03, 0x03, 0x7c, 0x14, 0x14, // ℉ [0x65]
0x44, 0x28, 0x10, 0x28, 0x44, // × [0x66]
0x08, 0x08, 0x2a, 0x08, 0x08, // ÷ [0x67]
0x38, 0x44, 0x48, 0x30, 0x2c, // α [0x68]
0xf8, 0x54, 0x54, 0x54, 0x28, // β [0x69]
0x28, 0x54, 0x54, 0x44, 0x20, // ε [0x6a]
0x3e, 0x49, 0x09, 0x09, 0x06, // ρ [0x6b]
0x38, 0x44, 0x4c, 0x54, 0x24, // σ [0x6c]
0x40, 0x3f, 0x08, 0x08, 0x1f, // μ [0x6d]
0x1f, 0x08, 0x08, 0x3f, 0x40, // η [0x6e]
0x3c, 0x4a, 0x4a, 0x4a, 0x3c, // θ [0x6f]
0x58, 0x64, 0x04, 0x64, 0x58, // Ω [0x70]
0x44, 0x3c, 0x04, 0x7c, 0x44, // π [0x71]
0x30, 0x28, 0x10, 0x28, 0x18, // ∞ [0x72]
0x30, 0x28, 0x24, 0x28, 0x30, // △ [0x73]
0x08, 0x1c, 0x08, 0x08, 0x0e, // Enter<-[0x74]
};
//------------------ icon.c
#include
const uint8 icon[][10] = {
// battery
0x1c, 0x3e, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x3e, // battery level 0
0x1c, 0x3e, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x3e, 0x3e, // battery level 1
0x1c, 0x3e, 0x22, 0x22, 0x22, 0x22, 0x22, 0x3e, 0x3e, 0x3e, // battery level 2
0x1c, 0x3e, 0x22, 0x22, 0x22, 0x22, 0x3e, 0x3e, 0x3e, 0x3e, // battery level 3
0x1c, 0x3e, 0x22, 0x22, 0x22, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, // battery level 4
0x1c, 0x3e, 0x22, 0x22, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, // battery level 5
0x1c, 0x3e, 0x22, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, // battery level 6
0x1c, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, // battery level 7
// resistance
0x08, 0x08, 0x3e, 0x22, 0x22, 0x22, 0x3e, 0x08, 0x08, 0x00,
// capacity A
0x08, 0x08, 0x08, 0x3e, 0x00, 0x1c, 0x2a, 0x08, 0x08, 0x00,
// capacity B
0x08, 0x08, 0x08, 0x3e, 0x00, 0x3e, 0x08, 0x08, 0x08, 0x00,
// transistor
0x00, 0x08, 0x08, 0x3e, 0x08, 0x14, 0x63, 0x00, 0x00, 0x00,
// inductance
0x08, 0x08, 0x08, 0x00, 0x3e, 0x20, 0x20, 0x08, 0x08, 0x08,
// diode
0x08, 0x08, 0x3e, 0x14, 0x08, 0x3e, 0x08, 0x08, 0x00, 0x00,
// GND
0x00, 0x00, 0x08, 0x18, 0x28, 0x4e, 0x28, 0x18, 0x08, 0x00,
// wave
0x08, 0x08, 0x0e, 0x02, 0x3e, 0x20, 0x38, 0x08, 0x08, 0x00,
// music A
0x00, 0x00, 0x60, 0x7e, 0x02, 0x02, 0x62, 0x7e, 0x00, 0x00,
// music B
0x00, 0x00, 0x20, 0x50, 0x50, 0x3f, 0x06, 0x0c, 0x00, 0x00,
// heart
0x00, 0x0c, 0x12, 0x22, 0x44, 0x22, 0x12, 0x0c, 0x00, 0x00,
// rocket or dick
0x00, 0x00, 0xe0, 0xbe, 0x41, 0xbe, 0xe0, 0x00, 0x00, 0x00,
// satellite
0x00, 0x32, 0x34, 0x48, 0x4f, 0x48, 0x34, 0x32, 0x00, 0x00,
// speaker
0x00, 0x00, 0x3c, 0x3c, 0x24, 0x42, 0xff, 0x00, 0x00, 0x00,
// play
0x00, 0x00, 0x00, 0x7f, 0x3e, 0x1c, 0x08, 0x00, 0x00, 0x00,
// pause
0x00, 0x00, 0x3e, 0x3e, 0x00, 0x3e, 0x3e, 0x3e, 0x00, 0x00,
// stop
0x00, 0x00, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x00, 0x00, 0x00,
// forward
0x00, 0x3e, 0x1c, 0x08, 0x00, 0x3e, 0x1c, 0x08, 0x00, 0x00,
// backward
0x00, 0x08, 0x1c, 0x3e, 0x00, 0x08, 0x1c, 0x3e, 0x00, 0x00,
};
最后上传一个LCD5110驱动模板:
extern const uint8 font_5_8[97][5];
extern const uint8 icon[][10];
// SPI write byte
#define LCDSPI_WRITE(dat) while(0){}
// clear the D/C line
#define LCD_SPICMD() while(0){}
// set the D/C line
#define LCD_SPIDAT() while(0){}
// clear the RESET line
#define LCD_RSTL() while(0){}
// set the RESET line
#define LCD_RSTH() while(0){}
// dummy delay
void delay_ms(int time) {
while(time --);
}
/* @ horizontal addressing (V = 0)
*/
void LCD_draw_bytes(const uint8 *buffer, int nbytes) {
while(nbytes --) {
LCDSPI_WRITE(*(buffer ++));
}
}
/* @ x: [0, 83]
* @ y: [0, 5]
*/
void LCD_set_xy(uint8 x, uint8 y) {
LCD_SPICMD();
LCDSPI_WRITE(0x40 | y);
LCDSPI_WRITE(0x80 | x);
LCD_SPIDAT();
}
/*
* @ clear the LCD
*/
void LCD_clear() {
int i;
uint8 buffer = 0x00;
LCD_set_xy(0, 0);
for(i = 0; i < 504; i ++) {
LCD_draw_bytes(&buffer, sizeof(buffer));
}
LCD_set_xy(0, 0);
}
/*
* @ write char by ascii code
*/
void LCD_draw_string(uint8 *str) {
int index;
uint8 c;
while(*str != 0) {
c = *str;
index = c - ' ';
str ++;
LCD_draw_bytes(font_5_8[index], 5);
LCDSPI_WRITE(0x00);
}
}
/*
* @ write symble by id
* @ id = [0, 21]
*/
void LCD_draw_symble(uint8 id) {
if(id > 21) {
id = 0;
}
LCD_draw_bytes(font_5_8[id + 0x5f], 5);
LCDSPI_WRITE(0x00);
}
/*
* @ LCD draw icon
* @ id = [0, 26]
*/
void LCD_draw_icon(uint8 id) {
LCD_draw_bytes(icon[id], 10);
LCDSPI_WRITE(0x00);
LCDSPI_WRITE(0x00);
}
/* Init LCD and IOs
*/
void LCD_init(){
// init spi and ios here
LCD_RSTL();
delay_ms(1000000);
LCD_RSTH();
delay_ms(1000000);
LCD_SPICMD();
// config the LCD at 3.3V
LCDSPI_WRITE(0x21); // ext cmd
LCDSPI_WRITE(0xBF); // VLCD
LCDSPI_WRITE(0x13); // BIAS = 1:48
LCDSPI_WRITE(0x20); // basic cmd
LCDSPI_WRITE(0x0c); // normal display
// clear screen
LCD_SPIDAT();
LCD_clear();
}
#if (0)
// test only
void LCD_test() {
int i;
TRACE_DEBUG("LCD TEST");
LCD_init();
LCD_draw_string("!\"#$%&'()*+,-./");
LCD_draw_string("0123456789:;<=>?@");
for(i = 0; i < 22; i ++) {
LCD_draw_symble(i);
}
LCD_clear();
LCD_draw_string("ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`");
LCD_draw_string("abcdefghijklmnopqrstuvwxyz{|}~");
LCD_clear();
for(i = 0; i < 27; i ++) {
LCD_draw_icon(i);
}
}
#endif
【必读】版权免责声明
1、本主题所有言论和内容纯属会员个人意见,与本论坛立场无关。2、本站对所发内容真实性、客观性、可用性不做任何保证也不负任何责任,网友之间仅出于学习目的进行交流。3、对提供的数字内容不拥有任何权利,其版权归原著者拥有。请勿将该数字内容进行商业交易、转载等行为,该内容只为学习所提供,使用后发生的一切问题与本站无关。 4、本网站不保证本站提供的下载资源的准确性、安全性和完整性;同时本网站也不承担用户因使用这些下载资源对自己和他人造成任何形式的损失或伤害。 5、本网站所有软件和资料均为网友推荐收集整理而来,仅供学习用途使用,请务必下载后两小时内删除,禁止商用。6、如有侵犯你版权的,请及时联系我们(电子邮箱1370723259@qq.com)指出,本站将立即改正。
|