原帖由 nissin 於 2007-2-26 08:18 發表
不如share....
等其他有心人同你改 呢個係將 192x64 的 wbmp 經 stdin 輸入,再 display 到 lcd 的程式…- #include <stdio.h>
- #include <stdlib.h>
- #include "serdisplib/serdisp.h"
- int main(int argc, char **argv) {
- char sdcdev[] = "0x378";/* use parallel port */
- char dispname[] = "KS0108";/* display name */
- serdisp_CONN_t* sdcd;
- serdisp_t* dd = 0;
- int i,j,x,y;
- unsigned char b;
- sdcd = SDCONN_open(sdcdev);
- dd = serdisp_init(sdcd, dispname, "width=192;delay=400;invert=yes");
- //serdisp_clear(dd);
- x=0;y=0;
- getchar();getchar();getchar();getchar();getchar();
- for (j=0;j<64;j++) {
- for (i=0;i<24;i++) {
- b = getchar();
- if (b >= 128) {serdisp_setpixel(dd, x, y, SD_COL_BLACK); b-=128;}
- else serdisp_setpixel(dd, x, y, SD_COL_WHITE); x++;
- if (b >= 64 ) {serdisp_setpixel(dd, x, y, SD_COL_BLACK); b-=64;}
- else serdisp_setpixel(dd, x, y, SD_COL_WHITE); x++;
- if (b >= 32 ) {serdisp_setpixel(dd, x, y, SD_COL_BLACK); b-=32;}
- else serdisp_setpixel(dd, x, y, SD_COL_WHITE); x++;
- if (b >= 16 ) {serdisp_setpixel(dd, x, y, SD_COL_BLACK); b-=16;}
- else serdisp_setpixel(dd, x, y, SD_COL_WHITE); x++;
- if (b >= 8 ) {serdisp_setpixel(dd, x, y, SD_COL_BLACK); b-=8;}
- else serdisp_setpixel(dd, x, y, SD_COL_WHITE); x++;
- if (b >= 4 ) {serdisp_setpixel(dd, x, y, SD_COL_BLACK); b-=4;}
- else serdisp_setpixel(dd, x, y, SD_COL_WHITE); x++;
- if (b >= 2 ) {serdisp_setpixel(dd, x, y, SD_COL_BLACK); b-=2;}
- else serdisp_setpixel(dd, x, y, SD_COL_WHITE); x++;
- if (b >= 1 ) {serdisp_setpixel(dd, x, y, SD_COL_BLACK); b-=1;}
- else serdisp_setpixel(dd, x, y, SD_COL_WHITE); x++;
- } x=0; y++;
- }
- serdisp_setpixel(dd, 191,63,SD_COL_BLACK); // This statement is used to prevent some bugs of libserdisp.
- serdisp_update(dd);
- return(0);
- }
複製代碼 |