Graphic display sample code NHD-12832A1Z.
/*****************************************************/ /* NHD-C12832A1Z-NSW-FBW-3V3.c Program for writing to Newhaven Display COG LCD (c)2008 Newhaven Display International, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ /*****************************************************/ #include <REG52.H> #include "picture.h" /*****************************************************/ sbit RES = P3^4; sbit CS = P3^1; sbit A0 = P3^7; sbit SCL = P3^0; sbit SI = P1^7; /*****************************************************/ void delay(unsigned int n) { unsigned int i,j; for (i=0;i<n;i++) for (j=0;j<350;j++) {;} } /*****************************************************/ void data_out(unsigned char i) //Data Output Serial Interface { unsigned int n; CS = 0; A0 = 1; for(n=0; n<8; n++){ SCL = 0; P1 = i; delay(2); SCL = 1; i <<=1; } CS = 1; } void comm_out(unsigned char j) //Command Output Serial Interface { unsigned int n; CS = 0; A0 = 0; for(n=0; n<8; n++){ SCL = 0; P1 = j; delay(2); SCL = 1; j <<=1; } CS = 1; } /*****************************************************/ void dispPic(unsigned char *lcd_string) { unsigned int i,j; unsigned char page = 0xB0; comm_out(0xAE); comm_out(0x40); for(i=0;i<4;i++){ comm_out(page); comm_out(0x10); comm_out(0x00); for(j=0;j<128;j++){ data_out(*lcd_string); lcd_string++; } page++; } comm_out(0xAF); } /**************************************************** * Initialization For controller * *****************************************************/ void init_LCD() { comm_out(0xA0); comm_out(0xAE); comm_out(0xC0); comm_out(0xA2); comm_out(0x2F); comm_out(0x26); comm_out(0x81); comm_out(0x2F); } /*****************************************************/ int main(void) { P1 = 1; P3 = 1; delay(10); init_LCD(); while(1){ dispPic(logo); delay(1000); dispPic(graphic1); delay(1000); dispPic(graphic2); delay(1000); } }