Author Topic: Turn off the LCD?  (Read 3403 times)

Harteex (OP)

  • * Administrator
  • Posts: 709
    • Harteex Productions
Turn off the LCD?
« on: November 17, 2009, 09:49:17 pm »
I would like to be able to turn off the LCD (put it to sleep), and then wake it up again in a program.

Does anyone know anything on how this could be achieved?

This code (void LCD_ExitSleep_ILI9331() / void LCD_EnterSleep_ILI9331()) sounds promising, but I have no idea how it should be used.

Code: [Select]
void Initial_ILI9331_Hydis28(void)
{
// RESET=0;
// Delayms(5);
// RESET=1;
// Delayms(10);

WriteRegister(0xe7,0x1014); // Set internal timing
WriteRegister(0x01,0x0100); // set SS and SM bit
WriteRegister(0x02,0x0200); // set 1 line inversion
WriteRegister(0x03,0x1030); // set GRAM write direction and BGR=1.

WriteRegister(0x08,0x0202); // set the back porch and front porch
WriteRegister(0x09,0x0000); // set non-display area refresh cycle ISC[3:0]
WriteRegister(0x0A,0x0000); // FMARK function
WriteRegister(0x0C,0x0000); // RGB interface setting
WriteRegister(0x0D,0x0000); // Frame marker Position
WriteRegister(0x0F,0x0000); // RGB interface polarity

// Power On Sequence //
WriteRegister(0x10,0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
WriteRegister(0x11,0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
WriteRegister(0x12,0x0000); // VREG1OUT voltage
WriteRegister(0x13,0x0000); // VDV[4:0] for VCOM amplitude
Delayms(100);

WriteRegister(0x10,0x1690); // SAP, BT[3:0], AP, DSTB, SLP, STB
WriteRegister(0x11,0x0227); // DC1[2:0], DC0[2:0], VC[2:0]
Delayms(50);
WriteRegister(0x12,0x000c);
Delayms(50);
WriteRegister(0x13,0x0800); //0X1A
WriteRegister(0x29,0x0011);
WriteRegister(0x2b,0x000b);
Delayms(50);


//Adjust the Gamma curve//
WriteRegister(0x30,0x0000);
WriteRegister(0x31,0x0106);
WriteRegister(0x32,0x0000);
WriteRegister(0x35,0x0204);
WriteRegister(0x36,0x160a);
WriteRegister(0x37,0x0707);
WriteRegister(0x38,0x0106);
WriteRegister(0x39,0x0706);
WriteRegister(0x3c,0x0402);
WriteRegister(0x3d,0x0c0f);

//--------- set GRAM area -----------
WriteRegister(0x50,0x0000); //Horizontal RAM Address Position start
WriteRegister(0x51,0x00ef); //Horizontal RAM Address Position end
WriteRegister(0x52,0x0000); //Vertical RAM Address Position start
WriteRegister(0x53,0x013f); //Vertical RAM Address Position end
WriteRegister(0x20,0x0000); //Set horizontal address
WriteRegister(0x21,0x0000); //Set vertical address

WriteRegister(0x60,0x2700);
WriteRegister(0x61,0x0001);
WriteRegister(0x6a,0x0000);

// Partial display control //
WriteRegister(0x80,0x0000);
WriteRegister(0x81,0x0000);
WriteRegister(0x82,0x0000);
WriteRegister(0x83,0x0000);
WriteRegister(0x84,0x0000);
WriteRegister(0x85,0x0000);

// Panel control //
WriteRegister(0x90,0x0010);
WriteRegister(0x92,0x0600);

WriteRegister(0x07,0x0133); //display on

// write display data
// WriteRegister(0x20,0x0000); //Set horizontal address
// WriteRegister(0x21,0x0000); //Set vertical address
// WriteIndex(0x00,0x22); //write data to GRAM
}



void LCD_ExitSleep_ILI9331()
{
WriteRegister(0x10,0x0080); //
WriteRegister(0x11,0x0000); //
WriteRegister(0x12,0x0000); //
WriteRegister(0x13,0x0000); //
Delayms(200);
WriteRegister(0x10,0x1690); //
WriteRegister(0x11,0x0227); //
Delayms(50);
WriteRegister(0x12,0x000C); //
Delayms(50);
WriteRegister(0x13,0x0800); //
WriteRegister(0x29,0x0011); //
Delayms(50);
WriteRegister(0x07,0x0133); //


}

void LCD_EnterSleep_ILI9331()
{
WriteRegister(0x07,0x0131); //
Delayms(10);
WriteRegister(0x07,0x0130); //
Delayms(10);
WriteRegister(0x07,0x0000); // display off
//power off sequence
WriteRegister(0x10,0x0080); //
WriteRegister(0x11,0x0000); //
WriteRegister(0x12,0x0000); //
WriteRegister(0x13,0x0000); //
Delayms(200);
WriteRegister(0x10,0x0082); //

}


Maybe there are also other ways to achieve this, but I don't know how..

Spiller

  • *
  • Posts: 106
Re: Turn off the LCD?
« Reply #1 on: November 18, 2009, 08:57:47 am »
Don't forget that already two different types of LCD controllers are being used. The JZ47xx hardware won't change easily, but expect to find other types of LCDs in future versions of Dingoos and other PMPs.

batman52

  • *
  • Posts: 111
Re: Turn off the LCD?
« Reply #2 on: November 18, 2009, 04:08:28 pm »
I am assuming that by "turning off the LCD" you are actually meaning "turning off the LCD backlight". In that case the code shouldn't be related to the LDC controller in use. Indeed, according to the GPIO mapped by booboo http://code.google.com/p/dingoo-linux/wiki/GPIO the LCD backlight is drived by the embedded PWM modulator (PWM7), connected to the pin PORTD:31. So in order to shut down the LCD backlight, you should read in the JZ4740 manual how to turn off the PWM7 modulator, then set PORTD:31 to 0.
« Last Edit: November 18, 2009, 04:11:45 pm by batman52 »

Harteex (OP)

  • * Administrator
  • Posts: 709
    • Harteex Productions
Re: Turn off the LCD?
« Reply #3 on: November 18, 2009, 11:17:15 pm »
I am assuming that by "turning off the LCD" you are actually meaning "turning off the LCD backlight". In that case the code shouldn't be related to the LDC controller in use. Indeed, according to the GPIO mapped by booboo http://code.google.com/p/dingoo-linux/wiki/GPIO the LCD backlight is drived by the embedded PWM modulator (PWM7), connected to the pin PORTD:31. So in order to shut down the LCD backlight, you should read in the JZ4740 manual how to turn off the PWM7 modulator, then set PORTD:31 to 0.

Thank you very much!
Yes I meant turning off the backlight :)

It seems like there are quite much things I have to try to wrap my mind around...

I have found some code on the Ingenic FTP that might be useful, however, there is so much, it'll take a while..


Edit: Ok looking through the manual, there seems to be a lot of good info, but I need to understand the process of how this is going to be made. I suppose I first have to select the right register / port (unsure of terminology), possibly using PDSEL. And then... clear it maybe (with PDDATC?).
All these things are new to me so I might be doing bad assumpations.
I have not yet found any info on how to turn off the PWM7, but I might be looking in the wrong place.

Too tired now, I'll have to continue tomorrow.
« Last Edit: November 19, 2009, 12:54:42 am by Harteex »

Harteex (OP)

  • * Administrator
  • Posts: 709
    • Harteex Productions
Re: Turn off the LCD?
« Reply #4 on: November 20, 2009, 05:04:12 pm »
Now it works :)

I had great use of jz4740.h from Ingenic (and the information from batman52 :)).

1.
I did manage to stop the timer by setting the appropriate bit in the TSR (Timer STOP) register. (__tcu_stop_timer_clock)
With PDPIN (using __gpio_get_pin), I can see the pin (bit 31, GROUP D) change (well before I stopped the timer of course), but I cannot set it myself directly. For that I will probably have to go via PDFUN or similiar first.

2.
However I might not need to continue with trying to set the pin, since I found out you can just use the TER (Timer Counter Enable) register, and that seems to actually set the pin above to 0. So using this alone, it seems to work :) To do this with jz4740.h, just do __tcu_stop_counter(7), which simply writes 1000 0000 to TECR.

I also messed around a bit with TCSR7 (Timer Control Register 7), where you can enable and disable PWM output.

 

Post a new topic
Post a new topic