lcd字符显示子程序:
[cpp] viewplaincopyprint?
- void Paint_text(unsigned int x, unsigned int y, unsigned int color, unsigned char ch[], unsigned int lengx,int lengy){
- int i, j, test, t = -1;
- for(i = 0; i < lengy; i++){
- for(j = 0; j < lengx; j++){
- if(j%8 == 0){
- test = 0x80;
- t++;
- }
- if(ch[t] & test)
- LCD_BUFFER[y+i][x+j] = color;
- else
- LCD_BUFFER[y+i][x+j] = 0xffffff;
-
- test >>= 1;
- }
- }
- }
头文件中字符数据定义:
[cpp] viewplaincopyprint?
- unsigned char charnum[10][16]={
- {0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00},
- {0x00,0x00,0x00,0x10,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},
- {0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x04,0x04,0x08,0x10,0x20,0x42,0x7E,0x00,0x00},
- {0x00,0x00,0x00,0x3C,0x42,0x42,0x04,0x18,0x04,0x02,0x02,0x42,0x44,0x38,0x00,0x00},
- {0x00,0x00,0x00,0x04,0x0C,0x14,0x24,0x24,0x44,0x44,0x7E,0x04,0x04,0x1E,0x00,0x00},
- {0x00,0x00,0x00,0x7E,0x40,0x40,0x40,0x58,0x64,0x02,0x02,0x42,0x44,0x38,0x00,0x00},
- {0x00,0x00,0x00,0x1C,0x24,0x40,0x40,0x58,0x64,0x42,0x42,0x42,0x24,0x18,0x00,0x00},
- {0x00,0x00,0x00,0x7E,0x44,0x44,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00},
- {0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00},
- {0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x26,0x1A,0x02,0x02,0x24,0x38,0x00,0x00}};
-
-
-
-
- unsigned char charnumc[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x22,0x40,0x40,0x40,0x22,0x1C,0x00,0x00};
- unsigned char charnumo[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00};
- unsigned char charnumn[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xDC,0x62,0x42,0x42,0x42,0x42,0xE7,0x00,0x00};
- unsigned char charnumv[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x28,0x10,0x10,0x00,0x00};
- unsigned char charnume[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x7E,0x40,0x40,0x42,0x3C,0x00,0x00};
- unsigned char charnumr[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEE,0x32,0x20,0x20,0x20,0x20,0xF8,0x00,0x00};
- unsigned char charnums[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x42,0x40,0x3C,0x02,0x42,0x7C,0x00,0x00};
- unsigned char charnumi[]={0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00};
主函数程序:
[cpp] viewplaincopyprint?
- adc_init();
-
- LCD_Init();
- Paint_background(0xffffff,0,0,480,272);
-
-
- while(1)
- {
- adc_data = read_adc();
- adc_data = (adc_data*32226);
-
- adc_data_tmp[0] = adc_data/100000/100;
- //adc_data_tmp[1] = ((adc_data/100)0000)/10000;
- adc_data_tmp[1] = adc_data000000/1000000;
- adc_data_tmp[2] = adc_data00000/100000;
- adc_data_tmp[3] = adc_data0000/10000;
- adc_data_tmp[4] = adc_data000/1000;
- adc_data_tmp[5] = adc_data00/100;
- adc_data_tmp[6] = adc_data0/10;
- adc_data_tmp[7] = adc_data;
-
-
- Paint_text(124+8*0, 20, 0x0,charnum[adc_data_tmp[0]],8, 16);
- Paint_text(124+8*1, 20, 0x0,charnum[adc_data_tmp[1]],8, 16);
- Paint_text(124+8*2, 20, 0x0,charnum[adc_data_tmp[2]],8, 16);
- Paint_text(124+8*3, 20, 0x0,charnum[adc_data_tmp[3]],8, 16);
- Paint_text(124+8*4, 20, 0x0,charnum[adc_data_tmp[4]],8, 16);
- Paint_text(124+8*5, 20, 0x0,charnum[adc_data_tmp[5]],8, 16);
- Paint_text(124+8*6, 20, 0x0,charnum[adc_data_tmp[6]],8, 16);
- Paint_text(124+8*7, 20, 0x0,charnum[adc_data_tmp[7]],8, 16);
- delay_adc();
-
- }
|