Graphic display sample code NHD-16032AZ.
/*****************************************************/
/*
NHD-16032AZ.c
Program for writing to Newhaven Display 160x32 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 "picture.h"
/*****************************************************/
sbit RS = P3^0;
sbit RW = P3^7;
sbit E = P3^4;
/*****************************************************/
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 Parallel Interface
{
P1 = i;
RS = 0;
RW = 0;
E = 1;
delay(1);
E = 0;
}
void comm_out(unsigned char j) //Command Output Parallel Interface
{
P1 = j;
RS = 1;
RW = 0;
E = 1;
delay(1);
E = 0;
}
/*****************************************************/
void dispPic(unsigned char *lcd_string)
{
unsigned int i,j;
unsigned char column = 0x80;
for(i=0;i<32;i++){
comm_out(0x3E);
comm_out(column);
comm_out(0x80);
for(j=0;j<18;j++){
data_out(*lcd_string);
lcd_string++;
}
column++;
}
}
/****************************************************/
void scroll(unsigned int n)
{
unsigned int i;
comm_out(0x38);
for(i=0;i<n;i++){
comm_out(0x1C);
delay(100);
}
}
/****************************************************
* Initialization For controller *
*****************************************************/
void init_LCD()
{
comm_out(0x38);
comm_out(0x0C);
comm_out(0x06);
comm_out(0x02);
comm_out(0x01);
}
/*****************************************************/
int main(void)
{
P1 = 0;
P3 = 0;
delay(10);
init_LCD();
delay(10);
while(1){
dispPic(logo);
delay(1000);
dispPic(graphic1);
delay(1000);
dispPic(graphic2);
delay(1000);
dispPic(graphic3);
delay(1000);
scroll(16);
}
}