Exemple #1
0
//Subroutine to initialize LCD for input and outpute
//Inputs: none
//Outputs: none
//Notes:..
void LCDinit(void) {
	_delay_ms(40);
	LCDcom(0b00110000);
	_delay_ms(5);
	LCDcom(0b00110000);
	_delay_us(120);
	LCDcom(0b00110000);
	//choose setup MK
	_delay_ms(1);
	functionSet(0x10, 0x08, 0x00);
	displayControl(0, 0, 0);
	displayClear();
	entryMode(0x02, 0);
	displayControl(0x04, 0, 0);
}
void Main(void) {
	char bitmap, bitmapL, bitmapH; 
	char row, rowmask;
	char firstP1,firstP2,secondP1,secondP2,chr1;	
	int charCount=0;
	
	functionSet();
	
	IRWRITE(0x06);//entryModeSet(1, 0); // increment and no shift
	
	IRWRITE(0x0F);//displayOnOffControl(1, 1, 1); // display on, cursor on and blinking on
	//IRWRITE(0x80);
	setDdRamAddress(0x00); 
	
	
	while (1) {
		//
		for (row=bitmapL=bitmapH=0, rowmask = 0xf7; row < 4; row++, rowmask >>= 1) {
			bitmap=colScan(rowmask);
			if (row==2) {
				bitmapH = (bitmapL >> 2);
			}
			bitmapL = (bitmapL<<3) | bitmap;
		}
		//P1 = bitmapL;
		//P2 = bitmapH;
		if(bitmapL==0x00 && bitmapH==0x00){
			;
		}else if(charCount==0){//first char
			
			charCount=1;
			firstP1=P2= bitmapL;
			firstP2=P3= bitmapH;
			delay();
		}else if(charCount==1){//second char
			
			charCount=0;
			secondP1=P2= bitmapL;
			secondP2=P3= bitmapH;		
			chr1=firstChar(firstP1,firstP2);
			secondChar(chr1,secondP1,secondP2);//secondChar() returns the input of this time
			delay();
			
		}
		
	}