示例#1
0
void LCDDisplay::Plot(UINT  X, UINT  Y, Color C)
{
    WORD Address;
    BYTE BitSetCommand;

    if ((X > MaxX) || (Y > MaxY))
        IgnorableError(LCDDisplay_PlotOutOfBounds);
    else
    {
        Address = (30*Y+X/8)+GraphicsHomeAddress;
  
        // Now that we know what byte contains the specified dot,
        // set the LCD display address pointer to point to that
        // location
        LCDWriteData(LOBYTE(Address));
        LCDWriteData(HIBYTE(Address));
        LCDWriteCommand(0x24); // address pointer set command
  
        // Set or clear the correct bit at that address.
        // Figure out which bit in that byte to set.
        BitSetCommand = 7 - (X % 8);
        // Set the color of the bit.
        if (C == Black)
            BitSetCommand = BitSetCommand | 0x08; // Set the bit
        // Finish the command
        BitSetCommand = BitSetCommand | 0xF0; 
        LCDWriteCommand(BitSetCommand);
    }
}
// Configure display controller to write to defined display area
void LCDAddressWindow(const tRectangle *pRect)
{
#ifdef PORTRAIT
	LCDWriteCommand(ILI_HOR_START_AD);
	LCDWriteData(pRect->sXMin);
	LCDWriteCommand(ILI_HOR_END_AD);
	LCDWriteData(pRect->sXMax);
	LCDWriteCommand(ILI_VER_START_AD);
	LCDWriteData(pRect->sYMin);
	LCDWriteCommand(ILI_VER_END_AD);
	LCDWriteData(pRect->sYMax);
#else
	LCDWriteCommand(ILI_HOR_START_AD);
	LCDWriteData(LCD_X - pRect->sYMax);
	LCDWriteCommand(ILI_HOR_END_AD);
	LCDWriteData(LCD_X - pRect->sYMin);
	LCDWriteCommand(ILI_VER_START_AD);
	LCDWriteData(pRect->sXMin);
	LCDWriteCommand(ILI_VER_END_AD);
	LCDWriteData(pRect->sXMax);
#endif

	// Set pointer to first address in that window
	LCDGoto(pRect->sXMin, pRect->sYMin);
}
示例#3
0
static int lcd_16207_ioctl(struct inode *inode,struct file *filp,
			   unsigned int cmd,unsigned long arg)
{
  volatile unsigned long display;

  switch (cmd) {
  case LCD_On:
    if (copy_from_user
	(&display, (unsigned long *) arg,
	 sizeof(display)))
      return -EFAULT;

    LCDWriteInst(display);
    break;

  case LCD_Off:
    if (copy_from_user
	(&display, (unsigned long *) arg,
	 sizeof(display)))
      return -EFAULT;

    LCDWriteData(display);
    break;


  default:
    return -EINVAL;
  }

  return 0;
}
// Clear display
void LCDClear(void)
{
	LCDGoto(0, 0);
	int i = 0;
	while(i < LCD_WIDTH * LCD_HEIGHT)
	{
		LCDWriteData(0);	// Write black pixel
		i++;
	}
}
void Adafruit320x240x16_ILI9325PixelDrawMultiple(void *pvDisplayData,
												 long lX, long lY, long lX0, long lCount, long lBPP,
												 const unsigned char *pucData,
												 const unsigned char *pucPalette)
{
	// Start talking to LCD
	LCD_CS_ACTIVE

#ifdef LANDSCAPE
	// Configure write direction to horizontal
	LCDWriteCommand(ILI_ENTRY_MOD);
	LCDWriteData(0x1038);
#endif

	LCDGoto(lX,lY);

	unsigned long ulPixel = 0;
	unsigned long ulColor = 0;

    if(lBPP == 1)
    {
    	// 1 bit per pixel in pucData
    	// lX0 is the index of the bit processed within a byte
    	// pucPalette holds the pre-translated 32bit display color
    	while(lCount)
    	{
    		ulPixel = *pucData++;

    		while(lCount && lX0 < 8)	// while there are pixels in this byte
    		{
    			ulColor = ((unsigned long *)pucPalette)[ulPixel & 1];	// retrieve already translated color
    			LCDWriteData(ulColor);

    			lCount--;		// processed another pixel
    			lX0++;			// done with this bit
    			ulPixel >>= 1;	// prepare next bit
    		}

    		lX0 = 0;	// process next byte, reset bit counter
    	}
    }
    else if(lBPP == 4)
void Adafruit320x240x16_ILI9325PixelDraw(void *pvDisplayData, long lX, long lY, unsigned long ulValue)
{
	// Start talking to LCD
	LCD_CS_ACTIVE

	LCDGoto(lX, lY);
	LCDWriteData(ulValue);

	// Done talking to LCD
	LCD_CS_IDLE
}
示例#7
0
文件: DHT11.C 项目: hnulong/C51
void main()
{
	uchar len,i;
	uchar xdata Tvalue[6],Hvalue[6];
	SerialInit();
	LCDInit();
	while(1)
	{ 
	    RH();
		SerialPutString(buff);
		sprintf(Tvalue,"%2.2f",temperature);
		sprintf(Hvalue,"%2.2f%%",humidity);
		LCDWriteCom(0x01);//ÇåÆÁ
		LCDWriteCom(0x80);
		len=strlen(info1);
		//дÊý¾Ýµ½LCD1602
		for(i=0;i<len;i++)
			LCDWriteData(info1[i]);
		len=strlen(Tvalue);
		for(i=0;i<len;i++)
			LCDWriteData(Tvalue[i]);
		LCDWriteData((uchar)223);
		LCDWriteData('C');
		LCDWriteCom(0x80+0x43);
		len=strlen(info2);
		for(i=0;i<len;i++)
			LCDWriteData(info2[i]);
		len=strlen(Hvalue);
		for(i=0;i<len;i++)
			LCDWriteData(Hvalue[i]);
	   //
	   Delay(10000);
	}

}
// Coordinates of next display write
void LCDGoto(unsigned short x, unsigned short y)
{
	if(x >= LCD_WIDTH) x = LCD_WIDTH - 1;
	if(y >= LCD_HEIGHT) y = LCD_HEIGHT - 1;

#ifdef PORTRAIT
	LCDWriteCommand(ILI_GRAM_HOR_AD);	// GRAM Address Set (Horizontal Address) (R20h)
	LCDWriteData(x);
	LCDWriteCommand(ILI_GRAM_VER_AD);	// GRAM Address Set (Vertical Address) (R21h)
	LCDWriteData(y);
	LCDWriteCommand(ILI_RW_GRAM);		// Write Data to GRAM (R22h)
#else
	LCDWriteCommand(ILI_GRAM_HOR_AD);	// GRAM Address Set (Horizontal Address) (R20h)
	LCDWriteData(LCD_X - y);
	LCDWriteCommand(ILI_GRAM_VER_AD);	// GRAM Address Set (Vertical Address) (R21h)
	LCDWriteData(x);
	LCDWriteCommand(ILI_RW_GRAM);		// Write Data to GRAM (R22h)
#endif

	g_usPosX = x;
	g_usPosY = y;
}
示例#9
0
文件: PM2.5.c 项目: hnulong/C51
void main()
{
    //uchar i;
    //EX1=1;
    //IT1=1;
    LCDInit();
    SerialInit();
    len=strlen(value);
    for(i=0; i<len; i++)
        LCDWriteData(value[i]);
    //sendsms();
    //DialVoiceCall();
    //
    while(1)
    {
        ConnectGPRS(0.3,0.4,0.8);
        //delay(3000);
        //LCDWriteCom(0x01);//清屏
        /*
        LCDWriteCom(0x80);
        if(pulse==1)
        {
        	TL0=0;
        	while(pulse);
        	TR0=1;
        	while(!pulse);
        	TR0=0;
        	count=TL0;
        	P1=count;
        	duration=(unsigned long)count;
        	lowpulseoccupancy = lowpulseoccupancy+duration;
        	ratio = lowpulseoccupancy/(sampletime_ms*10.0);  // Integer percentage 0=>100
            concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve
            //Serial.print("yeelink:");
            //Serial.println(concentration);
            //ConnectGPRS(concentration,(float)DHT11.temperature,(float)DHT11.humidity);
        	memset(value,0x00,20);
        	sprintf(value,"%s%f","yeelink:",concentration);
        	len=strlen(value);
        	for(i=0;i<len;i++)
        		LCDWriteData(value[i]);
            lowpulseoccupancy = 0;
        //	delay(3000);
        }
        */
    }
}
示例#10
0
static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 
			unsigned long arg)
{
	struct lcd_display button_display;
	unsigned long address, a;
	int index;

	switch (cmd) {
	case LCD_On:
		udelay(150);
		BusyCheck();
		LCDWriteInst(0x0F);
		break;		

	case LCD_Off:
		udelay(150);
		BusyCheck();
		LCDWriteInst(0x08);
		break;

	case LCD_Reset:
		udelay(150);
		LCDWriteInst(0x3F);
		udelay(150);
		LCDWriteInst(0x3F);
		udelay(150);
		LCDWriteInst(0x3F);
		udelay(150);
		LCDWriteInst(0x3F);
		udelay(150);
		LCDWriteInst(0x01);
		udelay(150);
		LCDWriteInst(0x06);
		break;

	case LCD_Clear:
		udelay(150);
		BusyCheck();
       		LCDWriteInst(0x01);     
		break;

	case LCD_Cursor_Left:
		udelay(150);
		BusyCheck();
		LCDWriteInst(0x10);
		break;

	case LCD_Cursor_Right:
		udelay(150);
		BusyCheck();
		LCDWriteInst(0x14);
		break;	

	case LCD_Cursor_Off:
		udelay(150);
                BusyCheck();
                LCDWriteInst(0x0C);
	        break;

        case LCD_Cursor_On:
                udelay(150);
                BusyCheck();
                LCDWriteInst(0x0F);
                break;

        case LCD_Blink_Off:
                udelay(150);
                BusyCheck();
                LCDWriteInst(0x0E);
                break;

	case LCD_Get_Cursor_Pos:{
                struct lcd_display display;

		udelay(150);
                BusyCheck();
		display.cursor_address = ( LCDReadInst ); 
		display.cursor_address = ( display.cursor_address & 0x07F );
		if(copy_to_user((struct lcd_display*)arg, &display, sizeof(struct lcd_display)))
		  return -EFAULT;

		break;
		}


	case LCD_Set_Cursor_Pos: {
                struct lcd_display display;

                if(copy_from_user(&display, (struct lcd_display*)arg, sizeof(struct lcd_display)))
		  return -EFAULT;

		a = (display.cursor_address | kLCD_Addr ); 

                udelay(150);
                BusyCheck();    
                LCDWriteInst( a );

                break;
		}
	
	case LCD_Get_Cursor: {
                struct lcd_display display;

                udelay(150);
                BusyCheck();    
		display.character = LCDReadData;	

		if(copy_to_user((struct lcd_display*)arg, &display, sizeof(struct lcd_display)))
		  return -EFAULT;
                udelay(150);
                BusyCheck();
                LCDWriteInst(0x10);

		break;
		}

	case LCD_Set_Cursor:{
                struct lcd_display display;
   
                if(copy_from_user(&display, (struct lcd_display*)arg, sizeof(struct lcd_display)))
		  return -EFAULT;

                udelay(150);
		BusyCheck();    
                LCDWriteData( display.character );
                udelay(150);
                BusyCheck();
                LCDWriteInst(0x10);

                break;
                }


	case LCD_Disp_Left:
		udelay(150);
		BusyCheck();
		LCDWriteInst(0x18);
		break;

	case LCD_Disp_Right:
		udelay(150);
		BusyCheck();
		LCDWriteInst(0x1C);
		break;

	case LCD_Home:
		udelay(150);
		BusyCheck();
		LCDWriteInst(0x02);
		break;

	case LCD_Write: {
		struct lcd_display display;
   

                if(copy_from_user(&display, (struct lcd_display*)arg, sizeof(struct lcd_display)))
		  return -EFAULT;
 
		udelay(150);
                BusyCheck();    
                LCDWriteInst(0x80);
		udelay(150);
		BusyCheck();
	
		for (index = 0; index < (display.size1); index++) {
			udelay(150);
			BusyCheck();	
			LCDWriteData( display.line1[index]);
			BusyCheck();	
		}		
		
		udelay(150);
		BusyCheck();	
		LCDWriteInst(0xC0);	
		udelay(150);
		BusyCheck();	
                for (index = 0; index < (display.size2); index++) {
                        udelay(150);
                        BusyCheck();    
                        LCDWriteData( display.line2[index]);
		}
 
		break;	
	}
	
	case LCD_Read: {	
        	struct lcd_display display;

		BusyCheck();
		for (address = kDD_R00; address <= kDD_R01; address++) {
			a = (address | kLCD_Addr );	

			udelay(150);
			BusyCheck();
			LCDWriteInst( a );
			udelay(150);
			BusyCheck();
			display.line1[address] = LCDReadData;
		}

		display.line1[ 0x27 ] = '\0';
	
		for (address = kDD_R10; address <= kDD_R11; address++) {
			a = (address | kLCD_Addr );     
        
			udelay(150);
	 		BusyCheck();
        		LCDWriteInst( a );
       
        		udelay(150);
	 		BusyCheck();
        		display.line2[address - 0x40 ] = LCDReadData;
		 }

		display.line2[ 0x27 ] = '\0';

		if(copy_to_user((struct lcd_display*)arg, &display,
				sizeof(struct lcd_display)))
		  return -EFAULT;
		break;
	}

//  set all GPIO leds to led_display.leds 

	case LED_Set: {	
		struct lcd_display led_display;
	

	        if(copy_from_user(&led_display, (struct lcd_display*)arg,
				  sizeof(struct lcd_display)))
		  return -EFAULT;

		led_state = led_display.leds;
		LEDSet(led_state);

        	break;
	}


//  set only bit led_display.leds

        case LED_Bit_Set: {
                int i;
		int bit=1;
                struct lcd_display led_display;


                if(copy_from_user(&led_display, (struct lcd_display*)arg,
				  sizeof(struct lcd_display)))
		  return -EFAULT;

		for (i=0;i<(int)led_display.leds;i++)
			{
				bit = 2*bit;	
			}

		led_state = led_state | bit;
                LEDSet(led_state);
                break;
        }

//  clear only bit led_display.leds

        case LED_Bit_Clear: {
                int i;
		int bit=1;
                struct lcd_display led_display;


                if(copy_from_user(&led_display, (struct lcd_display*)arg,
				  sizeof(struct lcd_display)))
		  return -EFAULT;

                for (i=0;i<(int)led_display.leds;i++)
                        {
                                bit = 2*bit;
                        }

		led_state = led_state &  ~bit;
                LEDSet(led_state);
                break;
        }


	case BUTTON_Read: {
		button_display.buttons = GPIRead;
                if(copy_to_user((struct lcd_display*)arg, &button_display, sizeof(struct lcd_display)))
		  return -EFAULT;
		break;
	}

        case LINK_Check: {
                button_display.buttons = *((volatile unsigned long *) (0xB0100060) );
                if(copy_to_user((struct lcd_display*)arg, &button_display, sizeof(struct lcd_display)))
		  return -EFAULT;
                break;
        }

	case LINK_Check_2: {
		int iface_num;

		/* panel-utils should pass in the desired interface status is wanted for
		 * in "buttons" of the structure.  We will set this to non-zero if the
		 * link is in fact up for the requested interface.  --DaveM
		 */
		if(copy_from_user(&button_display, (struct lcd_display *)arg, sizeof(button_display)))
		  return -EFAULT;
		iface_num = button_display.buttons;
#if defined(CONFIG_TULIP) && 0
		if (iface_num >= 0 &&
		    iface_num < MAX_INTERFACES &&
		    linkcheck_callbacks[iface_num] != NULL) {
			button_display.buttons =
				linkcheck_callbacks[iface_num](linkcheck_cookies[iface_num]);
		} else
#endif
			button_display.buttons = 0;

                if(__copy_to_user((struct lcd_display*)arg, &button_display, sizeof(struct lcd_display)))
		  return -EFAULT;
                break;
	}

//  Erase the flash

	case FLASH_Erase: {

		int ctr=0;

		    // Chip Erase Sequence
		WRITE_FLASH( kFlash_Addr1, kFlash_Data1 );
		WRITE_FLASH( kFlash_Addr2, kFlash_Data2 );
		WRITE_FLASH( kFlash_Addr1, kFlash_Erase3 );
		WRITE_FLASH( kFlash_Addr1, kFlash_Data1 );
		WRITE_FLASH( kFlash_Addr2, kFlash_Data2 );
		WRITE_FLASH( kFlash_Addr1, kFlash_Erase6 );

		printk( "Erasing Flash.\n");

		while ( (!dqpoll(0x00000000,0xFF)) && (!timeout(0x00000000)) ) {
		    ctr++;
		}

		printk("\n");
		printk("\n");
		printk("\n");

		if (READ_FLASH(0x07FFF0)==0xFF) { printk("Erase Successful\r\n"); }
		else if (timeout) { printk("Erase Timed Out\r\n"); }

	break;
	}

// burn the flash 

	case FLASH_Burn: {

		volatile unsigned long burn_addr;
		unsigned long flags;
		int i;
		unsigned char *rom;
		

                struct lcd_display display;

                if(copy_from_user(&display, (struct lcd_display*)arg, sizeof(struct lcd_display)))
		  return -EFAULT;
		rom = (unsigned char *) kmalloc((128),GFP_ATOMIC);
                if ( rom == NULL ) {
                       printk ("broken\n");
                       return 1;
                   }

		printk("Churning and Burning -");
		save_flags(flags);
		for (i=0; i<FLASH_SIZE; i=i+128) {

		        if(copy_from_user(rom, display.RomImage + i, 128))
			   return -EFAULT;
			burn_addr = kFlashBase + i;
			cli();
			for ( index = 0; index < ( 128 ) ; index++ ) 
		  	  {

				WRITE_FLASH( kFlash_Addr1, kFlash_Data1 );
		 	    	WRITE_FLASH( kFlash_Addr2, kFlash_Data2 );
		 	    	WRITE_FLASH( kFlash_Addr1, kFlash_Prog );
		 	    	*((volatile unsigned char *)burn_addr) = (volatile unsigned char) rom[index];

		   	 	 while ( (!dqpoll(burn_addr,(volatile unsigned char) rom[index])) && (!timeout(burn_addr)) ) {
		  	   		}
		  	   	burn_addr++;
		  	  }
			restore_flags(flags);
                	if ( *((volatile unsigned char *)(burn_addr-1)) == (volatile unsigned char) rom[index-1]  ) {
               		 } else if (timeout) {
                	    printk("Program timed out\r\n");
               		 }


		}
		kfree(rom);

	break;
	}

//  read the flash all at once 
	
	case FLASH_Read: {

		unsigned char *user_bytes;
                volatile unsigned long read_addr;
                int i;

		user_bytes = &(((struct lcd_display *)arg)->RomImage[0]);

		if(!access_ok(VERIFY_WRITE, user_bytes, FLASH_SIZE))
                         return -EFAULT;

		printk("Reading Flash");
		for (i=0; i<FLASH_SIZE; i++) {
			unsigned char tmp_byte;
			read_addr = kFlashBase + i;
			tmp_byte = *((volatile unsigned char *)read_addr);
			if(__put_user (tmp_byte, &user_bytes[i]))
			  return -EFAULT;
		}


	break;
	}





	default:
		return 0;
	break;

	}

	return 0;

}
// Initializing display
void Adafruit320x240x16_ILI9325Init(void)
{
	unsigned short usAddress, usData;

	// Reset global variables
	g_ulWait1ms = SysCtlClockGet() / (3 * 1000);

	// Enable GPIO peripherals
	SysCtlPeripheralEnable(LCD_DATA_PERIPH);
    SysCtlPeripheralEnable(LCD_CS_PERIPH);
	SysCtlPeripheralEnable(LCD_CD_PERIPH);
    SysCtlPeripheralEnable(LCD_WR_PERIPH);
    SysCtlPeripheralEnable(LCD_RD_PERIPH);
    SysCtlPeripheralEnable(LCD_RST_PERIPH);
    SysCtlPeripheralEnable(LCD_BKLT_PERIPH);

    // Configure pins, all output
    GPIOPinTypeGPIOOutput(LCD_DATA_BASE, LCD_DATA_PINS);
    GPIOPinTypeGPIOOutput(LCD_CS_BASE, LCD_CS_PIN);
    GPIOPinTypeGPIOOutput(LCD_CD_BASE, LCD_CD_PIN);
    GPIOPinTypeGPIOOutput(LCD_WR_BASE, LCD_WR_PIN);
    GPIOPinTypeGPIOOutput(LCD_RD_BASE, LCD_RD_PIN);
    GPIOPinTypeGPIOOutput(LCD_BKLT_BASE, LCD_BKLT_PIN);
    GPIOPinTypeGPIOOutput(LCD_RST_BASE, LCD_RST_PIN);

    // Set control pins to idle/off state
    LCD_CS_IDLE
    LCD_RD_IDLE
    LCD_WR_IDLE
    LCD_BKLT_OFF

	// Reset LCD
    LCD_RST_ACTIVE
	LCD_DELAY(50);
	LCD_RST_IDLE
	LCD_DELAY(50);

	// Talk to LCD for init
	LCD_CS_ACTIVE

	// Sync communication
	LCDWriteData(0);
	LCDWriteData(0);
	LCDWriteData(0);
	LCDWriteData(0);
	LCD_DELAY(50);

	// Process initialization sequence of display driver
	int i = 0;
	while(usInitScript[i] != ILI_STOPCMD)
	{
		usAddress = usInitScript[i++];
		usData = usInitScript[i++];

		if(usAddress == ILI_DELAYCMD)
		{
			LCD_DELAY(usData);
		}
		else
		{
			LCDWriteCommand(usAddress);
			LCDWriteData(usData);
		}
	}

	// Clear display of any stray pixels
	LCDClear();

	// Done talking to LCD
	LCD_CS_IDLE

	// Turn back light on
	LCD_BKLT_ON

	return;
}
示例#12
0
static int lcd_ioctl(struct inode *inode, struct file *file,
		     unsigned int cmd, unsigned long arg)
{
	struct lcd_display button_display;
	unsigned long address, a;

	switch (cmd) {
	case LCD_On:
		udelay(150);
		BusyCheck();
		LCDWriteInst(0x0F);
		break;

	case LCD_Off:
		udelay(150);
		BusyCheck();
		LCDWriteInst(0x08);
		break;

	case LCD_Reset:
		udelay(150);
		LCDWriteInst(0x3F);
		udelay(150);
		LCDWriteInst(0x3F);
		udelay(150);
		LCDWriteInst(0x3F);
		udelay(150);
		LCDWriteInst(0x3F);
		udelay(150);
		LCDWriteInst(0x01);
		udelay(150);
		LCDWriteInst(0x06);
		break;

	case LCD_Clear:
		udelay(150);
		BusyCheck();
		LCDWriteInst(0x01);
		break;

	case LCD_Cursor_Left:
		udelay(150);
		BusyCheck();
		LCDWriteInst(0x10);
		break;

	case LCD_Cursor_Right:
		udelay(150);
		BusyCheck();
		LCDWriteInst(0x14);
		break;

	case LCD_Cursor_Off:
		udelay(150);
		BusyCheck();
		LCDWriteInst(0x0C);
		break;

	case LCD_Cursor_On:
		udelay(150);
		BusyCheck();
		LCDWriteInst(0x0F);
		break;

	case LCD_Blink_Off:
		udelay(150);
		BusyCheck();
		LCDWriteInst(0x0E);
		break;

	case LCD_Get_Cursor_Pos:{
			struct lcd_display display;

			udelay(150);
			BusyCheck();
			display.cursor_address = (LCDReadInst);
			display.cursor_address =
			    (display.cursor_address & 0x07F);
			if (copy_to_user
			    ((struct lcd_display *) arg, &display,
			     sizeof(struct lcd_display)))
				return -EFAULT;

			break;
		}


	case LCD_Set_Cursor_Pos:{
			struct lcd_display display;

			if (copy_from_user
			    (&display, (struct lcd_display *) arg,
			     sizeof(struct lcd_display)))
				return -EFAULT;

			a = (display.cursor_address | kLCD_Addr);

			udelay(150);
			BusyCheck();
			LCDWriteInst(a);

			break;
		}

	case LCD_Get_Cursor:{
			struct lcd_display display;

			udelay(150);
			BusyCheck();
			display.character = LCDReadData;

			if (copy_to_user
			    ((struct lcd_display *) arg, &display,
			     sizeof(struct lcd_display)))
				return -EFAULT;
			udelay(150);
			BusyCheck();
			LCDWriteInst(0x10);

			break;
		}

	case LCD_Set_Cursor:{
			struct lcd_display display;

			if (copy_from_user
			    (&display, (struct lcd_display *) arg,
			     sizeof(struct lcd_display)))
				return -EFAULT;

			udelay(150);
			BusyCheck();
			LCDWriteData(display.character);
			udelay(150);
			BusyCheck();
			LCDWriteInst(0x10);

			break;
		}


	case LCD_Disp_Left:
		udelay(150);
		BusyCheck();
		LCDWriteInst(0x18);
		break;

	case LCD_Disp_Right:
		udelay(150);
		BusyCheck();
		LCDWriteInst(0x1C);
		break;

	case LCD_Home:
		udelay(150);
		BusyCheck();
		LCDWriteInst(0x02);
		break;

	case LCD_Write:{
			struct lcd_display display;
			unsigned int index;


			if (copy_from_user
			    (&display, (struct lcd_display *) arg,
			     sizeof(struct lcd_display)))
				return -EFAULT;

			udelay(150);
			BusyCheck();
			LCDWriteInst(0x80);
			udelay(150);
			BusyCheck();

			for (index = 0; index < (display.size1); index++) {
				udelay(150);
				BusyCheck();
				LCDWriteData(display.line1[index]);
				BusyCheck();
			}

			udelay(150);
			BusyCheck();
			LCDWriteInst(0xC0);
			udelay(150);
			BusyCheck();
			for (index = 0; index < (display.size2); index++) {
				udelay(150);
				BusyCheck();
				LCDWriteData(display.line2[index]);
			}

			break;
		}

	case LCD_Read:{
			struct lcd_display display;

			BusyCheck();
			for (address = kDD_R00; address <= kDD_R01;
			     address++) {
				a = (address | kLCD_Addr);

				udelay(150);
				BusyCheck();
				LCDWriteInst(a);
				udelay(150);
				BusyCheck();
				display.line1[address] = LCDReadData;
			}

			display.line1[0x27] = '\0';

			for (address = kDD_R10; address <= kDD_R11;
			     address++) {
				a = (address | kLCD_Addr);

				udelay(150);
				BusyCheck();
				LCDWriteInst(a);

				udelay(150);
				BusyCheck();
				display.line2[address - 0x40] =
				    LCDReadData;
			}

			display.line2[0x27] = '\0';

			if (copy_to_user
			    ((struct lcd_display *) arg, &display,
			     sizeof(struct lcd_display)))
				return -EFAULT;
			break;
		}

//  set all GPIO leds to led_display.leds

	case LED_Set:{
			struct lcd_display led_display;


			if (copy_from_user
			    (&led_display, (struct lcd_display *) arg,
			     sizeof(struct lcd_display)))
				return -EFAULT;

			led_state = led_display.leds;
			LEDSet(led_state);

			break;
		}


//  set only bit led_display.leds

	case LED_Bit_Set:{
			unsigned int i;
			int bit = 1;
			struct lcd_display led_display;


			if (copy_from_user
			    (&led_display, (struct lcd_display *) arg,
			     sizeof(struct lcd_display)))
				return -EFAULT;

			for (i = 0; i < (int) led_display.leds; i++) {
				bit = 2 * bit;
			}

			led_state = led_state | bit;
			LEDSet(led_state);
			break;
		}

//  clear only bit led_display.leds

	case LED_Bit_Clear:{
			unsigned int i;
			int bit = 1;
			struct lcd_display led_display;


			if (copy_from_user
			    (&led_display, (struct lcd_display *) arg,
			     sizeof(struct lcd_display)))
				return -EFAULT;

			for (i = 0; i < (int) led_display.leds; i++) {
				bit = 2 * bit;
			}

			led_state = led_state & ~bit;
			LEDSet(led_state);
			break;
		}


	case BUTTON_Read:{
			button_display.buttons = GPIRead;
			if (copy_to_user
			    ((struct lcd_display *) arg, &button_display,
			     sizeof(struct lcd_display)))
				return -EFAULT;
			break;
		}

	case LINK_Check:{
			button_display.buttons =
			    *((volatile unsigned long *) (0xB0100060));
			if (copy_to_user
			    ((struct lcd_display *) arg, &button_display,
			     sizeof(struct lcd_display)))
				return -EFAULT;
			break;
		}

	case LINK_Check_2:{
			int iface_num;

			/* panel-utils should pass in the desired interface status is wanted for
			 * in "buttons" of the structure.  We will set this to non-zero if the
			 * link is in fact up for the requested interface.  --DaveM
			 */
			if (copy_from_user
			    (&button_display, (struct lcd_display *) arg,
			     sizeof(button_display)))
				return -EFAULT;
			iface_num = button_display.buttons;
#if defined(CONFIG_TULIP) && 0
			if (iface_num >= 0 &&
			    iface_num < MAX_INTERFACES &&
			    linkcheck_callbacks[iface_num] != NULL) {
				button_display.buttons =
				    linkcheck_callbacks[iface_num]
				    (linkcheck_cookies[iface_num]);
			} else
#endif
				button_display.buttons = 0;

			if (__copy_to_user
			    ((struct lcd_display *) arg, &button_display,
			     sizeof(struct lcd_display)))
				return -EFAULT;
			break;
		}

	default:
		return -EINVAL;

	}

	return 0;

}