📄 test2.c
字号:
#include <stdio.h>#include <string.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <stdlib.h>#include <sys/ioctl.h>#include <math.h>#include "../include/api.h"#include "bitmap.h"/*******************************************************************/void test_bitmap(void){ struct point p1,p2; int i,j; int x1=1,y1=128; unsigned char map1[1][128]; for(i=0;i<x1;i++){ for(j=0;j<y1;j++) map1[i][j]=0xff; } lcd_set_graphymode(); lcd_cls_graphy(); p1.x=0; p1.y=0; p2.x=x1; p2.y=y1; lcd_write_map(p1,p2,map1); //16*16 chinese font /* p1.x=0; p1.y=0; p2.x=30; p2.y=128; lcd_write_map(p1,p2,(unsigned char **)map); //full screen map */} /*******************************************************************/void test_cfont(void){ struct point p1,p2;// struct point linefirst,linelast; unsigned char chinese_zhong[32]={ 0x01,0x00,0x01,0x00,0x21,0x08,0x3F,0xFC, 0x21,0x08,0x21,0x08,0x21,0x08,0x21,0x08, 0x21,0x08,0x3F,0xF8,0x21,0x08,0x01,0x00, 0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00}; //display zhong character unsigned char chinese_wen[32]={ 0x02,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE, 0x08,0x20,0x08,0x20,0x08,0x20,0x04,0x40, 0x04,0x40,0x02,0x80,0x01,0x00,0x02,0x80, 0x04,0x60,0x18,0x1E,0xE0,0x08,0x00,0x00}; //display wen character lcd_set_graphymode(); lcd_cls_graphy(); p1.x=2; p1.y=0; p2.x=4; p2.y=16; lcd_write_map(p1,p2,chinese_wen); //16*16 chinese font } /*******************************************************************/int test_dot(void){ int i,j=0; printf("drow dot test\n"); lcd_set_graphymode(); lcd_cls_graphy(); for(i=0;i<239; i++){ j= (j+4)%127; lcd_write_dot(i,j,1); } //sleep(2); for(i=0; i<240; i++){ j = 64 - i & 63; lcd_write_dot(i,j,1); }}/*******************************************************************/int test_text(void){ char i; char msg[300]; printf("text test"); lcd_set_textmode(); lcd_cls_text(); lcd_write_string(1,8,"TEXT MODE STRING SHOW DEMO"); for(i=1; i<127; i++) msg[i]=i; msg[127]=0; //sleep(4); lcd_write_string(0,0,msg); lcd_write_string(0,8,msg);} /*******************************************************************/int main(int argc, char **argv){ if(lcd_open()<0){ printf("can't open lcd!\n"); return 1; } while(1){ test_text(); usleep(500000); test_cfont(); usleep(500000); test_dot(); usleep(500000); test_bitmap(); } lcd_close(); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -