Graphic display sample code NHD-12232AZ.
/*****************************************************/ /* NHD-12232AZ.c Program for writing to Newhaven Display 122x32 AZ series Graphic 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 "pic.h" sbit D_I = P3^6; sbit R_W = P3^1; sbit E1 = P3^7; sbit E2 = P3^4; sbit RST = P3^0; void delay(unsigned int n); void init(); void Comleft(char i); void Comright(char i); void Writeright(char i); void Writeleft(char i); void graphic(unsigned char *img); void bothSides(char i); /*****************************************/ void delay(unsigned int n) { unsigned int i,j; for (i=0;i<n;i++) for (j=0;j<350;j++) {;} } /*****************************************/ void Comleft(char i) { P1 = i; R_W = 0; D_I = 0; E1 = 1; delay(2); E1 = 0; } void Comright(char i) { P1 = i; R_W = 0; D_I = 0; E2 = 1; delay(2); E2 = 0; } void Writeleft(char i) { P1 = i; R_W = 0; D_I = 1; E1 = 1; delay(2); E1 = 0; } void Writeright(char i) { P1 = i; R_W = 0; D_I = 1; E2 = 1; delay(2); E2= 0; } /*****************************************/ void bothSides(char i) { Comleft(i); Comright(i); } /*****************************************/ void init() { P1 = 0; P3 = 0; RST = 0; // Reset RST delay(1); RST = 1; // Reset RST= M68 Interface delay(10); D_I = 0; E1 = 1; E2 = 1; R_W = 1; bothSides(0xE2); delay(10); bothSides(0xA4); bothSides(0xA9); bothSides(0xA0); bothSides(0xEE); bothSides(0xC0); bothSides(0xAF); } /*****************************************/ void Graphic(unsigned char *img) { int m, n; char page = 0xB8; for(m=0;m<4;m++) { bothSides(page); bothSides(0x00); for(n=0;n<61;n++) { Writeleft(*img); img++; } for(n=0;n<61;n++) { Writeright(*img); img++; } page++; } } /*****************************************/ int main(void) { while(1) { init(); delay(30); Graphic(picture); delay(2000); } } /*****************************************/ //copy & paste this into pic.h 0x00,0x00,0x00,0x00,0x00,0xF0,0xF0,0xE0,0x80,0x00,0xF0,0xF0,0x00,0x00,0x80,0xC0,0x40,0xC0,0x80,0x00, 0xC0,0xC0,0x00,0xC0,0xC0,0xC0,0x00,0xC0,0xC0,0x00,0x00,0xF0,0xF0,0x80,0xC0,0x80,0x00,0x00,0x80,0xC0, 0x40,0xC0,0x80,0x00,0x40,0xC0,0x80,0x00,0x80,0xC0,0x40,0x00,0x80,0xC0,0x40,0xC0,0x80,0x00,0x00,0xC0, 0xC0, 0x80,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xF0,0x30,0x30,0x30,0xE0,0xC0,0x00,0x00,0xD0,0xD0, 0x00,0x00,0x80,0xC0,0x40,0x40,0x80,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0x80,0x00,0x00,0xF0,0xF0,0x00,0x00, 0x80,0xC0,0x40,0xC0,0x80,0x00,0x40,0xC0,0x80,0x00,0x80,0xC0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00, 0x00,0x00,0x00,0x00,0x00,0x0F,0x0F,0x00,0x01,0x07,0x0F,0x0F,0x00,0x00,0x07,0x0F,0x0D,0x0D,0x05,0x00, 0x00,0x07,0x0F,0x07,0x00,0x07,0x0F,0x07,0x00,0x00,0x00,0x0F,0x0F,0x00,0x0F,0x0F,0x00,0x00,0x0E,0x0E, 0x09,0x0F,0x0F,0x00,0x00,0x03,0x0F,0x0C,0x0F,0x03,0x00,0x00,0x07,0x0F,0x0D,0x0D,0x05,0x00,0x00,0x0F, 0x0F, 0x00,0x0F,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x0F,0x0C,0x0C,0x0C,0x07,0x03,0x00,0x00,0x0F,0x0F, 0x00,0x00,0x05,0x09,0x0B,0x0F,0x06,0x00,0x00,0x3F,0x3F,0x0C,0x0F,0x07,0x00,0x00,0x0F,0x0F,0x00,0x00, 0x0E,0x0E,0x09,0x0F,0x0F,0x00,0x20,0x23,0x3F,0x1C,0x0F,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x10,0xF8,0x00,0x00,0x10,0x08, 0x88,0x70,0x00,0x10,0x08,0x88,0x70,0x00,0x00,0x00,0x00,0x20,0x40,0x80,0x40,0x20,0x00,0x00,0x00,0x00, 0x10,0x48,0x48,0xB0,0x00,0x10,0x08,0x88,0x70,0x00,0x00,0x00,0x00,0xE0,0x10,0x08,0x88,0x88,0xB0,0x00, 0xE0, 0x40,0x20,0x20,0xA0,0xA0,0xC0,0x00,0xE0,0x40,0x20,0xC0,0x00,0xF8,0x40,0x20,0xC0,0x00,0xE8,0x00,0xC0, 0x20,0x20,0x40,0x00,0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0xE0,0x10,0x08,0x08,0x08,0x30,0x00,0xF8, 0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x06,0x05, 0x04,0x04,0x00,0x06,0x05,0x04,0x04,0x00,0x00,0x00,0x00,0x04,0x02,0x01,0x02,0x04,0x00,0x00,0x00,0x00, 0x02,0x04,0x04,0x03,0x00,0x06,0x05,0x04,0x04,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x04,0x04,0x03,0x00, 0x07, 0x00,0x00,0x03,0x04,0x04,0x07,0x00,0x1F,0x02,0x04,0x03,0x00,0x07,0x00,0x00,0x07,0x00,0x07,0x00,0x03, 0x04,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x04,0x04,0x04,0x00,0x01,0x02,0x04,0x04,0x04,0x03,0x00,0x07, 0x04,0x04,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00, /*****************************************/