CircleOS  1
lcd_spe_IL9325.c
Go to the documentation of this file.
1 /****************** COPYRIGHT (C) 2007-2013 KEOLABS S.A.S. ********************/
13 /******************************************************************************/
14 
15 /* Includes ------------------------------------------------------------------*/
16 #include "circle.h"
17 #if DMA2D_AVAIL
18 #include "DMA2D_Graphic.h"
19 #endif
20 
22 
23 /* Private define ------------------------------------------------------------*/
24 
25 /* Private variables ---------------------------------------------------------*/
26 u16 LCDStatus = 0;
27 
28 /* Public variables ---------------------------------------------------------*/
29 
30 /* External variable ---------------------------------------------------------*/
31 
32 /* Private function prototypes -----------------------------------------------*/
33 
34 /* Private functions ---------------------------------------------------------*/
35 
36 /*******************************************************************************
37 *
38 * LCD_Init
39 *
40 *******************************************************************************/
48 /******************************************************************************/
49 void LCD_Init( void )
50 {
51  Screen_Width = APP_SCREEN_WIDTH;
52  Screen_Height = APP_SCREEN_HEIGHT;
53 
54  // Starting delay (for LCD startup)
55  Delayms( 10 );
56 
57 #if DMA2D_AVAIL
58  int DMALCD_ModeLCDAccess_bak = DMALCD_ModeLCDAccess;
59  DMALCD_ModeLCDAccess = LCD_Only;
60 #endif
61 
62  /* Configure microcontroller interface for LCD management */
63  LCD_Interface_Init();
64 
65  LCD_Reset();
66 
67  LCD_Controller_init();
68 
72 
73  LCD_ClearAllScreen( RGB_WHITE );
74 
75  /* Init BackLight*/
76 #if BACKLIGHT_INTERFACE
77  LCD_SetBackLight( UTIL_ReadBackupRegister( BKP_BKLIGHT ) );
78 #endif
79  LCD_BackLightConfig();
80 
81  LCDStatus = LCD_CheckLCDStatus(); //for test
82 
83 #if DMA2D_AVAIL
84  DMALCD_ModeLCDAccess = DMALCD_ModeLCDAccess_bak ;
85 #endif
86 }
87 
88 /*******************************************************************************
89 *
90 * LCD_Controller_init
91 *
92 *******************************************************************************/
97 /******************************************************************************/
98 void LCD_Controller_init( void )
99 {
100 
101  LCD_Write_Reg( ILI9325_TIMING_CTRL_1, 0x3008 ); // Set internal timing
102  LCD_Write_Reg( ILI9325_TIMING_CTRL_2, 0x0012 ); // Set internal timing
103  LCD_Write_Reg( ILI9325_TIMING_CTRL_3, 0x1231 ); // Set internal timing
104 
105  LCD_Write_Reg( ILI9325_START_OSC, 0x0001 ); // Start oscillator
106  Delayms( 50 );
107 
108  LCD_Write_Reg( ILI9325_DRV_OUTPUT_CTRL_1, 0x0100 ); // Set SS=1 (Shift direction = 720->1) and SM=0 bit
109  LCD_Write_Reg( ILI9325_LCD_DRV_CTRL, 0x0700 ); // Set 1 line inversion
110 
111  LCD_Write_Reg( ILI9325_ENTRY_MOD, V12_MADCTRVAL ); // TRI=0/DFM=0 (2x8 bits), BGR=1 (RGB swap)
112  // HWM=0 (no high speed), ORG=0, AM=1, I/D=10
113 
114  LCD_Write_Reg( ILI9325_RESIZE_CTRL, 0x0000 ); // Resize register = no resizing
115  LCD_Write_Reg( ILI9325_DIS_CTRL_2, 0x0202 ); // Set the back porch and front porch = 2 lines
116  LCD_Write_Reg( ILI9325_DIS_CTRL_3, 0x0000 ); // Set non-display area refresh cycle ISC[3:0]
117  LCD_Write_Reg( ILI9325_DIS_CTRL_4, 0x0000 ); // FMARK function
118  LCD_Write_Reg( ILI9325_RGB_CTRL_1, 0x0000 ); // RGB interface setting DM=00 (internal clock)
119  // RM=0 (RAM acces by system interface)
120  LCD_Write_Reg( ILI9325_FRAME_MARKER_POS, 0x0000 ); // Frame marker Position
121  LCD_Write_Reg( ILI9325_RGB_CTRL_2, 0x0000 ); // RGB interface polarity (not concerned)
122 
123  // Power ON sequence
124  LCD_Power_ON();
125 
126  // Gamma adjustement
127  LCD_Gamma_Adjust();
128 
129  /* Set GRAM area */
130  LCD_Write_Reg( ILI9325_HOR_ADDR_START, 0x0000 ); // Horizontal GRAM Start Address
131  LCD_Write_Reg( ILI9325_HOR_ADDR_END, 0x00EF ); // Horizontal GRAM End Address (239)
132  LCD_Write_Reg( ILI9325_VET_ADDR_START, 0x0000 ); // Vertical GRAM Start Address
133  LCD_Write_Reg( ILI9325_VET_ADDR_END, 0x013F ); // Vertical GRAM End Address (319)
134 
135  LCD_Write_Reg( ILI9325_DRV_OUTPUT_CTRL_2, 0xA700 ); // Gate Scan Line : GS=1, NL=0X27 (320 lines),
136  // SCN=00000 (start scan G320)
137  LCD_Write_Reg( ILI9325_BASE_IMG_CTRL, 0x0001 ); // NDL=0 (non display level), VLE=0 (vertical scroll disable), REV=1 (non grayscale inversion)
138  LCD_Write_Reg( ILI9325_VSCROLL_CTRL, 0x0000 ); // Set scrolling line
139 
140  // Partial image configuration
141  LCD_Write_Reg( ILI9325_PAR_IMG1_POS, 0 );
142  LCD_Write_Reg( ILI9325_PAR_IMG1_START, 0 );
143  LCD_Write_Reg( ILI9325_PAR_IMG1_END, 0 );
144  LCD_Write_Reg( ILI9325_PAR_IMG2_POS, 0 );
145  LCD_Write_Reg( ILI9325_PAR_IMG2_START, 0 );
146  LCD_Write_Reg( ILI9325_PAR_IMG2_END, 0 );
147 
148  // Panel interface control
149  LCD_Write_Reg( ILI9325_PAN_CTRL_1, 0x0010 ); // RTNI=10000 DIVI=00 (16 clocks/horizontal line, internal sync mode)
150  LCD_Write_Reg( ILI9325_PAN_CTRL_2, 0x0000 ); // NOWI=000(non overlap period = 0 clocks)
151  LCD_Write_Reg( ILI9325_PAN_CTRL_3, 0x0003 ); // ???
152  LCD_Write_Reg( ILI9325_PAN_CTRL_4, 0x0110 ); // RTNE=010000 DIVE=01 (DOTCLK ratio 4, 16 clocks/horizontal line, RGB mode)
153  LCD_Write_Reg( ILI9325_PAN_CTRL_5, 0x0000 ); // ???
154  LCD_Write_Reg( ILI9325_PAN_CTRL_6, 0x0000 ); // ???
155 
156  // Color mode display
157  LCD_Write_Reg( ILI9325_DIS_CTRL_1, 0x0133 ); // D0/D1=11, BASEE=1, GON=1 (display ON), CL=0 (262K colors)
158  // PTDE=00 (no partial image)
159  LCD_Write_Reg( 0xE4, 0x1430 ); // Set full frame read enable
160 
161  // Prepare write into graphical RAM
162  LCD_Write_Reg( ILI9325_GRAM_HADDR, 0x0000 ); // GRAM horizontal Address
163  LCD_Write_Reg( ILI9325_GRAM_VADDR, 0x0000 ); // GRAM Vertical Address
164 
165 
166 }
167 
168 /*******************************************************************************
169 *
170 * LCD_Power_ON
171 *
172 *******************************************************************************/
177 /******************************************************************************/
178 void LCD_Power_ON( void )
179 {
180  // Reset registers
181  LCD_Write_Reg( ILI9325_POW_CTRL_1, 0x0000 ); // SAP=0, BT[3:0]=0000, AP=0, DSTB=0, SLP=0, STB=0
182  LCD_Write_Reg( ILI9325_POW_CTRL_2, 0x0007 ); // DC1[2:0]=000, DC0[2:0]=000 (osc/1), VC[2:0]=111 (Vci/1)
183  LCD_Write_Reg( ILI9325_POW_CTRL_3, 0x0000 ); // VREG1OUT voltage = halt
184  LCD_Write_Reg( ILI9325_POW_CTRL_4, 0x0000 ); // VDV[4:0]=00000 for VCOM amplitude = VREG1OUT * 0.7
185  Delayms( 200 ); // Dis-charge capacitor power voltage
186 
187  LCD_Write_Reg( ILI9325_POW_CTRL_1, 0x1690 ); // SAP=1 (soure driver enable), BT[3:0]=101, AP=001 (driver =1),
188  // APE=1 (power supply enbale), DSTB=0, SLP=0, STB=0
189  LCD_Write_Reg( ILI9325_POW_CTRL_2, 0x0221 ); // DC1[2:0]=010 (f/4), DC0[2:0]=010 (f/16), VC[2:0]=001 (Vci*0.9 = 2,8V)
190  Delayms( 50 );
191 
192  LCD_Write_Reg( ILI9325_POW_CTRL_3, 0x0018 ); // PON=1 (Power ON), VCIRE=0 (external reference)
193  Delayms( 50 ); // VRH=1000 (VREG1OUT voltage = Vci * 1,60 = 4,96V)
194 
195  LCD_Write_Reg( ILI9325_POW_CTRL_4, 0x1800 ); // VDV[4:0]=11000 (VCOM amplitude = VRegout * 1,10 = 5,45V)
196  LCD_Write_Reg( ILI9325_POW_CTRL_7, 0x002A ); // VCM[5:0]=101010 (VCOMH = VREG1 * 0,895 = 4,44V)
197  LCD_Write_Reg( ILI9325_FRM_RATE_COLOR, 0x000B ); /* Frame Rate = 70Hz */
198  Delayms( 50 );
199 
200  return;
201 }
202 
203 /*******************************************************************************
204 *
205 * LCD_Gamma_Adjust
206 *
207 *******************************************************************************/
212 /*****************************************************************************/
213 void LCD_Gamma_Adjust( void )
214 {
215  LCD_Write_Reg( ILI9325_GAMMA_CTRL_1, 0x0004 );
216  LCD_Write_Reg( ILI9325_GAMMA_CTRL_2, 0x0007 );
217  LCD_Write_Reg( ILI9325_GAMMA_CTRL_3, 0x0006 );
218  LCD_Write_Reg( ILI9325_GAMMA_CTRL_4, 0x0206 );
219  LCD_Write_Reg( ILI9325_GAMMA_CTRL_5, 0x0408 );
220  LCD_Write_Reg( ILI9325_GAMMA_CTRL_6, 0x0507 );
221  LCD_Write_Reg( ILI9325_GAMMA_CTRL_7, 0x0200 );
222  LCD_Write_Reg( ILI9325_GAMMA_CTRL_8, 0x0707 );
223  LCD_Write_Reg( ILI9325_GAMMA_CTRL_9, 0x0504 );
224  LCD_Write_Reg( ILI9325_GAMMA_CTRL_10, 0x0F02 );
225  return;
226 }
227 
228 
229 /*******************************************************************************
230 *
231 * LCD_CheckLCDStatus
232 *
233 *******************************************************************************/
238 /******************************************************************************/
239 u16 LCD_CheckLCDStatus( void )
240 {
241  /* Read LCD device IDs*/
242  u16 IDcode = LCD_Read_Reg( ILI9325_DRV_CODE ); // Must return 0x9325
243  return IDcode;
244 }
245 
246 
247 /*******************************************************************************
248 *
249 * LCD_Batt
250 *
251 *******************************************************************************/
256 /******************************************************************************/
257 void LCD_Batt( coord_t xBat, coord_t yBat, bool flDisplayTime, u16 BatState,
258  u16* OldBatState, divider_t divider_coord, coord_t* widthBat, coord_t* heightBat )
259 {
260 
261 #if POWER_MNGT
262 
263  color_t bat_color;
264  static counter_t last_time = 0;
265  counter_t new_time = RTC_GetCounter();
266  u8 fill;
267  bool fBlink;
268 
269  UNREFERENCED_PARAMETER( BatState );
270  UNREFERENCED_PARAMETER( OldBatState );
271  UNREFERENCED_PARAMETER( divider_coord );
272 
273  if ( ( flDisplayTime == 1 ) && ( last_time != new_time ) )
274  {
275  last_time = new_time;
276  switch ( PWR_CurrentState )
277  {
278  case PWR_STATE_UNDEF:
279  return;
280 
281  case PWR_STATE_NOBAT:
282  bat_color = RGB_PINK;
283  fill = 100;
284  fBlink = TRUE;
285  break;
286 
287  case PWR_STATE_CHARGING:
288  bat_color = RGB_BLUE;
289  fill = 50;
290  fBlink = TRUE;
291  break;
292 
293  case PWR_STATE_FULL:
294  bat_color = RGB_GREEN;
295  fill = 100;
296  fBlink = FALSE;
297  break;
298 
299  case PWR_STATE_NORMAL:
300  bat_color = RGB_BLACK;
301  fBlink = FALSE;
302  fill = PWR_BatteryLevel;
303  break;
304 
305  case PWR_STATE_LOW:
306  bat_color = RGB_YELLOW;
307  fBlink = TRUE;
308  fill = PWR_BatteryLevel;
309  break;
310 
311  case PWR_STATE_EMPTY:
312  bat_color = RGB_RED;
313  fill = 100;
314  fBlink = TRUE;
315  break;
316  }
317 
318  *widthBat = ( 20 * fill ) / 100;
319 
320  if ( *widthBat > 20 )
321  {
322  *widthBat = 20;
323  }
324 
325  if ( fBlink && ( new_time & 1 ) )
326  {
327  LCD_FillRect_Circle( ( xBat + 22 ) - *widthBat , yBat + 2 , *widthBat , *heightBat , ( PWR_CurrentState == PWR_STATE_LOW ) ? bat_color : RGB_WHITE );
328  LCD_FillRect_Circle( xBat + 2 , yBat + 2 , 20 - *widthBat , *heightBat , ( PWR_CurrentState == PWR_STATE_LOW ) ? bat_color : RGB_WHITE );
329  }
330  else
331  {
332  LCD_FillRect_Circle( ( xBat + 22 ) - *widthBat , yBat + 2 , *widthBat , *heightBat , ( PWR_CurrentState == PWR_STATE_LOW ) ? RGB_WHITE : bat_color );
333  LCD_FillRect_Circle( xBat + 2 , yBat + 2 , 20 - *widthBat , *heightBat , ( PWR_CurrentState == PWR_STATE_LOW ) ? RGB_RED : RGB_WHITE );
334  }
335  }
336 
337 #else
338 
339  if ( ( ( divider_coord++ % 500 ) == 0 ) &&
340  ( ( BatState < ( *OldBatState - 100 ) ) || ( BatState > ( *OldBatState + 100 ) ) ) &&
341  ( flDisplayTime == 1 ) && ( BatState < NO_BAT_VOLTAGE ) )
342  {
343  *OldBatState = BatState;
344  *heightBat = 4;
345  *widthBat = ( ( BatState - 2000 ) ) / 70 ;
346 
347  if ( *widthBat > 20 )
348  {
349  *widthBat = 20;
350  }
351 
352  LCD_FillRect_Circle( ( xBat + 22 ) - *widthBat , yBat + 2 , *widthBat , *heightBat , RGB_BLUE );
353  LCD_FillRect_Circle( xBat + 2 , yBat + 2 , 20 - *widthBat , *heightBat , RGB_LIGHTBLUE );
354  }
355 
356 #endif
357 }
358 
359 /*******************************************************************************
360 *
361 * LCD_Clear
362 *
363 *******************************************************************************/
368 /******************************************************************************/
369 void LCD_Clear( u16 xBat, u16 yBat )
370 {
371  UNREFERENCED_PARAMETER( xBat );
372  UNREFERENCED_PARAMETER( yBat );
373 
374 #if TOUCHSCREEN_AVAIL
375  if ( TOUCHSCR_GetMode() != TS_CALIBRATION )
376  {
377  TOUCHSCR_SetMode( TS_DRAWING );
378  }
379 #endif
380 
381  DRAW_Batt();
382 
383 #if TOUCHSCREEN_AVAIL
385 #endif
386 }
387 
388 /*******************************************************************************
389 *
390 * LCD_DisplayRotate
391 *
392 *******************************************************************************/
399 /******************************************************************************/
400 void LCD_DisplayRotate( Rotate_H12_V_Match_TypeDef H12 )
401 {
402 
403  /* Memory Access Control */
404  LCD_SendLCDCmd_Rotation_Access();
405 
406  // Apply desired direction
407  switch ( H12 )
408  {
409  case V3 :
410  LCD_SendLCDData16( V3_MADCTRVAL >> 8, V3_MADCTRVAL & 0xFF );
411 
412  break;
413 
414  case V6 :
415  LCD_SendLCDData16( V6_MADCTRVAL >> 8, V6_MADCTRVAL & 0xFF );
416 
417  break;
418 
419  case V9 :
420  LCD_SendLCDData16( V9_MADCTRVAL >> 8, V9_MADCTRVAL & 0xFF );
421 
422  break;
423 
424  case V12 :
425  default :
426  LCD_SendLCDData16( V12_MADCTRVAL >> 8, V12_MADCTRVAL & 0xFF );
427  break;
428 
429  case V12BMP :
430  LCD_SendLCDData16( V12BMP_MADCTRVAL >> 8, V12BMP_MADCTRVAL & 0xFF );
431 
432  break;
433 
434  case V3BMP :
435  LCD_SendLCDData16( V3BMP_MADCTRVAL >> 8, V3BMP_MADCTRVAL & 0xFF );
436 
437  break;
438 
439  case V6BMP :
440  LCD_SendLCDData16( V6BMP_MADCTRVAL >> 8, V6BMP_MADCTRVAL & 0xFF );
441 
442  break;
443 
444  case V9BMP :
445  LCD_SendLCDData16( V9BMP_MADCTRVAL >> 8, V9BMP_MADCTRVAL & 0xFF );
446  break;
447  }
448 }
449 
451 
452 /* Public functions ----------------------------------------------------------*/
453 
454 /*******************************************************************************
455 *
456 * LCD_RectRead
457 *
458 *******************************************************************************/
473 /******************************************************************************/
474 void LCD_RectRead( coord_t x, coord_t y, coord_t width, coord_t height, u8* bmp )
475 {
476  u32 line, col;
477  u16 col0, line0;
478 
479  if (!bmp)
480  return;
481 
482  // Reading pixel / pixel
483  switch ( CurrentScreenOrientation )
484  {
485  case V12:
486  // Read pixels from LCD screen
487  col0 = Screen_Width - x - 1 + LCD_Offset;
488  line0 = y + LCD_Offset;
489  for ( col = 0; col < width; col++ )
490  {
491  // Current GRAM horizontal position
492  LCD_Write_Reg( ILI9325_GRAM_HADDR, col0 - col );
493 
494  for ( line = 0; line < height; line++ )
495  {
496  // Current GRAM Vertical position
497  LCD_Write_Reg( ILI9325_GRAM_VADDR, line0 + line );
498 
499  // Read pixel 2 bytes
500  LCD_PixelRead( &bmp );
501  }
502  }
503  break;
504 
505  case V3:
506  // Read pixels from LCD screen
507  col0 = y + LCD_Offset;
508  line0 = x + LCD_Offset;
509  for ( line = 0; line < width; line++ )
510  {
511  // Current GRAM Vertical position
512  LCD_Write_Reg( ILI9325_GRAM_VADDR, line0 + line );
513 
514  for ( col = 0; col < height; col++ )
515  {
516  // Current GRAM horizontal position
517  LCD_Write_Reg( ILI9325_GRAM_HADDR, col0 + col );
518 
519  // Read pixel 2 bytes
520  LCD_PixelRead( &bmp );
521  }
522  }
523  break;
524 
525  case V6:
526  // Read pixels from LCD screen
527  col0 = x + LCD_Offset;
528  line0 = Screen_Height - y - 1 + LCD_Offset;
529  for ( col = 0; col < width; col++ )
530  {
531  // Current GRAM horizontal position
532  LCD_Write_Reg( ILI9325_GRAM_HADDR, col0 + col );
533 
534  for ( line = 0; line < height; line++ )
535  {
536  // Current GRAM Vertical position
537  LCD_Write_Reg( ILI9325_GRAM_VADDR, line0 - line );
538 
539  // Read pixel 2 bytes
540  LCD_PixelRead( &bmp );
541  }
542  }
543  break;
544 
545  case V9:
546  // Read pixels from LCD screen
547  col0 = Screen_Width - y - 1 + LCD_Offset;
548  line0 = Screen_Height - x - 1 + LCD_Offset;
549  for ( line = 0; line < width; line++ )
550  {
551  // Current GRAM Vertical position
552  LCD_Write_Reg( ILI9325_GRAM_VADDR, line0 - line );
553 
554  for ( col = 0; col < height; col++ )
555  {
556  // Current GRAM horizontal position
557  LCD_Write_Reg( ILI9325_GRAM_HADDR, col0 - col );
558 
559  // Read pixel 2 bytes
560  LCD_PixelRead( &bmp );
561  }
562  }
563  break;
564 
565  default:
566  break;
567 
568  }
569 }
570 
571 /*******************************************************************************
572 *
573 * LCD_GetPixel
574 *
575 *******************************************************************************/
588 /******************************************************************************/
589 u16 LCD_GetPixel( coord_t x, coord_t y )
590 {
591  u16 val;
592  u8 pixel[2];
593 
594  LCD_RectRead( x, y, 1, 1, &pixel[0] );
595  val = ( pixel[1] << 8 ) | pixel[0];
596  return val;
597 }
598 
599 /*******************************************************************************
600 *
601 * LCD_SetRect_For_Cmd
602 *
603 *******************************************************************************/
616 /******************************************************************************/
617 NODEBUG void LCD_SetRect_For_Cmd( coord_t x, coord_t y, coord_t width, coord_t height )
618 {
619 #if DMA2D_AVAIL
620  if ( SelectedObject )
621  {
622  SelectedObject -> mCurrentRect_x = x;
623  SelectedObject -> mCurrentRect_y = y;
624  SelectedObject -> mCurrentRect_width = width;
625  SelectedObject -> mCurrentRect_height = height;
626  SelectedObject -> mCurrentRect_relpos_x = 0;
627  SelectedObject -> mCurrentRect_relpos_y = 0;
628  return;
629  }
630 
631  LCD_ScreenDirty = 1;
632 #endif
633 
634  // Set GRAM window
635  switch ( CurrentScreenOrientation % 4 )
636  {
637  case V12:
638  // Horizontal GRAM Start Address
639  LCD_Write_Reg( ILI9325_HOR_ADDR_START, Screen_Width - x - width + LCD_Offset );
640 
641  // Horizontal GRAM End Address
642  LCD_Write_Reg( ILI9325_HOR_ADDR_END, Screen_Width - x - 1 + LCD_Offset );
643 
644  // Window Vertical GRAM Start Address
645  LCD_Write_Reg( ILI9325_VET_ADDR_START, y + LCD_Offset ) ;
646 
647  // Window Vertical GRAM End Address
648  LCD_Write_Reg( ILI9325_VET_ADDR_END, y + height - 1 + LCD_Offset );
649 
650  // Current GRAM horizontal position
651  LCD_Write_Reg( ILI9325_GRAM_HADDR, Screen_Width - x - 1 + LCD_Offset );
652 
653  // Current GRAM Vertical position
654  LCD_Write_Reg( ILI9325_GRAM_VADDR, y + LCD_Offset );
655 
656  break;
657 
658  case V3:
659  // Horizontal GRAM Start Address
660  LCD_Write_Reg( ILI9325_HOR_ADDR_START, y + LCD_Offset );
661 
662  // Horizontal GRAM End Address
663  LCD_Write_Reg( ILI9325_HOR_ADDR_END, y + height - 1 + LCD_Offset );
664 
665  // Window Vertical GRAM Start Address
666  LCD_Write_Reg( ILI9325_VET_ADDR_START, x + LCD_Offset ) ;
667 
668  // Window Vertical GRAM End Address
669  LCD_Write_Reg( ILI9325_VET_ADDR_END, x + width - 1 + LCD_Offset );
670 
671  // Current GRAM horizontal position
672  LCD_Write_Reg( ILI9325_GRAM_HADDR, y + LCD_Offset );
673 
674  // Current GRAM Vertical position
675  LCD_Write_Reg( ILI9325_GRAM_VADDR, x + LCD_Offset );
676  break;
677 
678  case V6:
679  // Horizontal GRAM Start Address
680  LCD_Write_Reg( ILI9325_HOR_ADDR_START, x + LCD_Offset );
681 
682  // Horizontal GRAM End Address
683  LCD_Write_Reg( ILI9325_HOR_ADDR_END, x + width - 1 + LCD_Offset );
684 
685  // Window Vertical GRAM Start Address
686  LCD_Write_Reg( ILI9325_VET_ADDR_START, Screen_Height - y - height + LCD_Offset ) ;
687 
688  // Window Vertical GRAM End Address
689  LCD_Write_Reg( ILI9325_VET_ADDR_END, Screen_Height - y - 1 + LCD_Offset );
690 
691  // Current GRAM horizontal position
692  LCD_Write_Reg( ILI9325_GRAM_HADDR, x + LCD_Offset );
693 
694  // Current GRAM Vertical position
695  LCD_Write_Reg( ILI9325_GRAM_VADDR, Screen_Height - y - 1 + LCD_Offset );
696  break;
697 
698  case V9:
699  // Horizontal GRAM Start Address
700  LCD_Write_Reg( ILI9325_HOR_ADDR_START, Screen_Width - y - height + LCD_Offset );
701 
702  // Horizontal GRAM End Address
703  LCD_Write_Reg( ILI9325_HOR_ADDR_END, Screen_Width - y - 1 + LCD_Offset );
704 
705  // Window Vertical GRAM Start Address
706  LCD_Write_Reg( ILI9325_VET_ADDR_START, Screen_Height - x - width + LCD_Offset ) ;
707 
708  // Window Vertical GRAM End Address
709  LCD_Write_Reg( ILI9325_VET_ADDR_END, Screen_Height - x - 1 + LCD_Offset );
710 
711  // Current GRAM horizontal position
712  LCD_Write_Reg( ILI9325_GRAM_HADDR, Screen_Width - y - 1 + LCD_Offset );
713 
714  // Current GRAM Vertical position
715  LCD_Write_Reg( ILI9325_GRAM_VADDR, Screen_Height - x - 1 + LCD_Offset );
716  break;
717  }
718 
719 #if DMA2D_AVAIL
720  if ( DMALCD_ModeLCDAccess == SDRAM_Only )
721  {
722  if ( ( Xmin & Xmax & Ymin & Ymax ) == ( -1 ) )
723  {
724  Xmin = DMALCD_Register_Table[ILI9325_HOR_ADDR_START];
725  Xmax = DMALCD_Register_Table[ILI9325_HOR_ADDR_END];
726  Ymin = DMALCD_Register_Table[ILI9325_VET_ADDR_START];
727  Ymax = DMALCD_Register_Table[ILI9325_VET_ADDR_END];
728  }
729  else
730  {
731  Xmin = MIN( Xmin, DMALCD_Register_Table[ILI9325_HOR_ADDR_START] );
732  Xmax = MAX( Xmax, DMALCD_Register_Table[ILI9325_HOR_ADDR_END] );
733  Ymin = MIN( Ymin, DMALCD_Register_Table[ILI9325_VET_ADDR_START] );
734  Ymax = MAX( Ymax, DMALCD_Register_Table[ILI9325_VET_ADDR_END] );
735  }
736  }
737 #endif
738 }
739 
740 /*******************************************************************************
741 *
742 * LCD_FullScreen
743 *
744 *******************************************************************************/
756 /******************************************************************************/
757 void LCD_FullScreen( bool FullScreenONOFF )
758 {
759  // Fullscreen requested ?
760  if ( FullScreenONOFF != 0 )
761  {
762  // Yes, we stop the toolbar handler
763 #if TOUCHSCREEN_AVAIL
765 #endif
766 
767  // We block rotation, offset and change limits for screen, char and pointer to whole screen
768  LCD_SetRotateScreen( 0 );
770  Screen_Width = PHYS_SCREEN_WIDTH;
771  Screen_Height = PHYS_SCREEN_HEIGHT;
772 
773  // If V3 or V9 orientation, we swap width and height limits
774  if ( ( LCD_GetScreenOrientation() % 2 ) == 1 )
775  {
776  PosCurY = PHYS_SCREEN_WIDTH - Char_Height;
777  RightMarginX = PHYS_SCREEN_HEIGHT;
778  HighMarginY = PHYS_SCREEN_WIDTH;
779  LCD_DrawCharSetFilter( 0, PHYS_SCREEN_HEIGHT, 0, PHYS_SCREEN_WIDTH );
780  POINTER_SetRect( 0, 0, PHYS_SCREEN_HEIGHT - CurrentPointerWidth, PHYS_SCREEN_WIDTH - CurrentPointerHeight );
781  }
782  else
783  {
784  PosCurY = PHYS_SCREEN_HEIGHT - Char_Height;
785  RightMarginX = PHYS_SCREEN_WIDTH;
786  HighMarginY = PHYS_SCREEN_HEIGHT;
787  LCD_DrawCharSetFilter( 0, PHYS_SCREEN_WIDTH, 0, PHYS_SCREEN_HEIGHT );
788  POINTER_SetRect( 0, 0, PHYS_SCREEN_WIDTH - CurrentPointerWidth, PHYS_SCREEN_HEIGHT - CurrentPointerHeight );
789  }
790  }
791  else
792  {
793  // No, we come back normal mode
794  // We restore toolbar handler
795 #if TOUCHSCREEN_AVAIL
796  UTIL_SetSchHandler( TOOLBAR_SCHHDL_ID, TOOLBAR_Handler );
797 #endif
798 
799  // We allow rotation,
800  LCD_SetRotateScreen( 1 );
801 
802  // We restore screen, char and pointer to application screen limits
804  LCD_DrawCharSetFilter( 0, APP_SCREEN_WIDTH, 0, APP_SCREEN_HEIGHT );
806  }
807 
808 }
809 
810 /*******************************************************************************
811 *
812 * LCD_SendPixelData
813 *
814 *******************************************************************************/
824 /******************************************************************************/
825 void LCD_SendPixelData( color_t color )
826 {
827  LCD_SendLCDData( color & 0xFF );
828  LCD_SendLCDData( color >> 8 );
829 }