51 Screen_Width = APP_SCREEN_WIDTH;
52 Screen_Height = APP_SCREEN_HEIGHT;
67 LCD_Controller_init();
76 #if BACKLIGHT_INTERFACE
79 LCD_BackLightConfig();
81 LCDStatus = LCD_CheckLCDStatus();
98 void LCD_Controller_init(
void )
101 LCD_Write_Reg( ILI9325_TIMING_CTRL_1, 0x3008 );
102 LCD_Write_Reg( ILI9325_TIMING_CTRL_2, 0x0012 );
103 LCD_Write_Reg( ILI9325_TIMING_CTRL_3, 0x1231 );
105 LCD_Write_Reg( ILI9325_START_OSC, 0x0001 );
108 LCD_Write_Reg( ILI9325_DRV_OUTPUT_CTRL_1, 0x0100 );
109 LCD_Write_Reg( ILI9325_LCD_DRV_CTRL, 0x0700 );
111 LCD_Write_Reg( ILI9325_ENTRY_MOD, V12_MADCTRVAL );
114 LCD_Write_Reg( ILI9325_RESIZE_CTRL, 0x0000 );
115 LCD_Write_Reg( ILI9325_DIS_CTRL_2, 0x0202 );
116 LCD_Write_Reg( ILI9325_DIS_CTRL_3, 0x0000 );
117 LCD_Write_Reg( ILI9325_DIS_CTRL_4, 0x0000 );
118 LCD_Write_Reg( ILI9325_RGB_CTRL_1, 0x0000 );
120 LCD_Write_Reg( ILI9325_FRAME_MARKER_POS, 0x0000 );
121 LCD_Write_Reg( ILI9325_RGB_CTRL_2, 0x0000 );
130 LCD_Write_Reg( ILI9325_HOR_ADDR_START, 0x0000 );
131 LCD_Write_Reg( ILI9325_HOR_ADDR_END, 0x00EF );
132 LCD_Write_Reg( ILI9325_VET_ADDR_START, 0x0000 );
133 LCD_Write_Reg( ILI9325_VET_ADDR_END, 0x013F );
135 LCD_Write_Reg( ILI9325_DRV_OUTPUT_CTRL_2, 0xA700 );
137 LCD_Write_Reg( ILI9325_BASE_IMG_CTRL, 0x0001 );
138 LCD_Write_Reg( ILI9325_VSCROLL_CTRL, 0x0000 );
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 );
149 LCD_Write_Reg( ILI9325_PAN_CTRL_1, 0x0010 );
150 LCD_Write_Reg( ILI9325_PAN_CTRL_2, 0x0000 );
151 LCD_Write_Reg( ILI9325_PAN_CTRL_3, 0x0003 );
152 LCD_Write_Reg( ILI9325_PAN_CTRL_4, 0x0110 );
153 LCD_Write_Reg( ILI9325_PAN_CTRL_5, 0x0000 );
154 LCD_Write_Reg( ILI9325_PAN_CTRL_6, 0x0000 );
157 LCD_Write_Reg( ILI9325_DIS_CTRL_1, 0x0133 );
159 LCD_Write_Reg( 0xE4, 0x1430 );
162 LCD_Write_Reg( ILI9325_GRAM_HADDR, 0x0000 );
163 LCD_Write_Reg( ILI9325_GRAM_VADDR, 0x0000 );
178 void LCD_Power_ON(
void )
181 LCD_Write_Reg( ILI9325_POW_CTRL_1, 0x0000 );
182 LCD_Write_Reg( ILI9325_POW_CTRL_2, 0x0007 );
183 LCD_Write_Reg( ILI9325_POW_CTRL_3, 0x0000 );
184 LCD_Write_Reg( ILI9325_POW_CTRL_4, 0x0000 );
187 LCD_Write_Reg( ILI9325_POW_CTRL_1, 0x1690 );
189 LCD_Write_Reg( ILI9325_POW_CTRL_2, 0x0221 );
192 LCD_Write_Reg( ILI9325_POW_CTRL_3, 0x0018 );
195 LCD_Write_Reg( ILI9325_POW_CTRL_4, 0x1800 );
196 LCD_Write_Reg( ILI9325_POW_CTRL_7, 0x002A );
197 LCD_Write_Reg( ILI9325_FRM_RATE_COLOR, 0x000B );
213 void LCD_Gamma_Adjust(
void )
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 );
239 u16 LCD_CheckLCDStatus(
void )
242 u16 IDcode = LCD_Read_Reg( ILI9325_DRV_CODE );
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 )
264 static counter_t last_time = 0;
265 counter_t new_time = RTC_GetCounter();
269 UNREFERENCED_PARAMETER( BatState );
270 UNREFERENCED_PARAMETER( OldBatState );
271 UNREFERENCED_PARAMETER( divider_coord );
273 if ( ( flDisplayTime == 1 ) && ( last_time != new_time ) )
275 last_time = new_time;
276 switch ( PWR_CurrentState )
278 case PWR_STATE_UNDEF:
281 case PWR_STATE_NOBAT:
287 case PWR_STATE_CHARGING:
299 case PWR_STATE_NORMAL:
302 fill = PWR_BatteryLevel;
308 fill = PWR_BatteryLevel;
311 case PWR_STATE_EMPTY:
318 *widthBat = ( 20 * fill ) / 100;
320 if ( *widthBat > 20 )
325 if ( fBlink && ( new_time & 1 ) )
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 );
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 );
339 if ( ( ( divider_coord++ % 500 ) == 0 ) &&
340 ( ( BatState < ( *OldBatState - 100 ) ) || ( BatState > ( *OldBatState + 100 ) ) ) &&
341 ( flDisplayTime == 1 ) && ( BatState < NO_BAT_VOLTAGE ) )
343 *OldBatState = BatState;
345 *widthBat = ( ( BatState - 2000 ) ) / 70 ;
347 if ( *widthBat > 20 )
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 );
369 void LCD_Clear( u16 xBat, u16 yBat )
371 UNREFERENCED_PARAMETER( xBat );
372 UNREFERENCED_PARAMETER( yBat );
374 #if TOUCHSCREEN_AVAIL
383 #if TOUCHSCREEN_AVAIL
404 LCD_SendLCDCmd_Rotation_Access();
410 LCD_SendLCDData16( V3_MADCTRVAL >> 8, V3_MADCTRVAL & 0xFF );
415 LCD_SendLCDData16( V6_MADCTRVAL >> 8, V6_MADCTRVAL & 0xFF );
420 LCD_SendLCDData16( V9_MADCTRVAL >> 8, V9_MADCTRVAL & 0xFF );
426 LCD_SendLCDData16( V12_MADCTRVAL >> 8, V12_MADCTRVAL & 0xFF );
430 LCD_SendLCDData16( V12BMP_MADCTRVAL >> 8, V12BMP_MADCTRVAL & 0xFF );
435 LCD_SendLCDData16( V3BMP_MADCTRVAL >> 8, V3BMP_MADCTRVAL & 0xFF );
440 LCD_SendLCDData16( V6BMP_MADCTRVAL >> 8, V6BMP_MADCTRVAL & 0xFF );
445 LCD_SendLCDData16( V9BMP_MADCTRVAL >> 8, V9BMP_MADCTRVAL & 0xFF );
474 void LCD_RectRead( coord_t x, coord_t y, coord_t width, coord_t height, u8* bmp )
483 switch ( CurrentScreenOrientation )
487 col0 = Screen_Width - x - 1 + LCD_Offset;
488 line0 = y + LCD_Offset;
489 for ( col = 0; col < width; col++ )
492 LCD_Write_Reg( ILI9325_GRAM_HADDR, col0 - col );
494 for ( line = 0; line < height; line++ )
497 LCD_Write_Reg( ILI9325_GRAM_VADDR, line0 + line );
500 LCD_PixelRead( &bmp );
507 col0 = y + LCD_Offset;
508 line0 = x + LCD_Offset;
509 for ( line = 0; line < width; line++ )
512 LCD_Write_Reg( ILI9325_GRAM_VADDR, line0 + line );
514 for ( col = 0; col < height; col++ )
517 LCD_Write_Reg( ILI9325_GRAM_HADDR, col0 + col );
520 LCD_PixelRead( &bmp );
527 col0 = x + LCD_Offset;
528 line0 = Screen_Height - y - 1 + LCD_Offset;
529 for ( col = 0; col < width; col++ )
532 LCD_Write_Reg( ILI9325_GRAM_HADDR, col0 + col );
534 for ( line = 0; line < height; line++ )
537 LCD_Write_Reg( ILI9325_GRAM_VADDR, line0 - line );
540 LCD_PixelRead( &bmp );
547 col0 = Screen_Width - y - 1 + LCD_Offset;
548 line0 = Screen_Height - x - 1 + LCD_Offset;
549 for ( line = 0; line < width; line++ )
552 LCD_Write_Reg( ILI9325_GRAM_VADDR, line0 - line );
554 for ( col = 0; col < height; col++ )
557 LCD_Write_Reg( ILI9325_GRAM_HADDR, col0 - col );
560 LCD_PixelRead( &bmp );
595 val = ( pixel[1] << 8 ) | pixel[0];
635 switch ( CurrentScreenOrientation % 4 )
639 LCD_Write_Reg( ILI9325_HOR_ADDR_START, Screen_Width - x - width + LCD_Offset );
642 LCD_Write_Reg( ILI9325_HOR_ADDR_END, Screen_Width - x - 1 + LCD_Offset );
645 LCD_Write_Reg( ILI9325_VET_ADDR_START, y + LCD_Offset ) ;
648 LCD_Write_Reg( ILI9325_VET_ADDR_END, y + height - 1 + LCD_Offset );
651 LCD_Write_Reg( ILI9325_GRAM_HADDR, Screen_Width - x - 1 + LCD_Offset );
654 LCD_Write_Reg( ILI9325_GRAM_VADDR, y + LCD_Offset );
660 LCD_Write_Reg( ILI9325_HOR_ADDR_START, y + LCD_Offset );
663 LCD_Write_Reg( ILI9325_HOR_ADDR_END, y + height - 1 + LCD_Offset );
666 LCD_Write_Reg( ILI9325_VET_ADDR_START, x + LCD_Offset ) ;
669 LCD_Write_Reg( ILI9325_VET_ADDR_END, x + width - 1 + LCD_Offset );
672 LCD_Write_Reg( ILI9325_GRAM_HADDR, y + LCD_Offset );
675 LCD_Write_Reg( ILI9325_GRAM_VADDR, x + LCD_Offset );
680 LCD_Write_Reg( ILI9325_HOR_ADDR_START, x + LCD_Offset );
683 LCD_Write_Reg( ILI9325_HOR_ADDR_END, x + width - 1 + LCD_Offset );
686 LCD_Write_Reg( ILI9325_VET_ADDR_START, Screen_Height - y - height + LCD_Offset ) ;
689 LCD_Write_Reg( ILI9325_VET_ADDR_END, Screen_Height - y - 1 + LCD_Offset );
692 LCD_Write_Reg( ILI9325_GRAM_HADDR, x + LCD_Offset );
695 LCD_Write_Reg( ILI9325_GRAM_VADDR, Screen_Height - y - 1 + LCD_Offset );
700 LCD_Write_Reg( ILI9325_HOR_ADDR_START, Screen_Width - y - height + LCD_Offset );
703 LCD_Write_Reg( ILI9325_HOR_ADDR_END, Screen_Width - y - 1 + LCD_Offset );
706 LCD_Write_Reg( ILI9325_VET_ADDR_START, Screen_Height - x - width + LCD_Offset ) ;
709 LCD_Write_Reg( ILI9325_VET_ADDR_END, Screen_Height - x - 1 + LCD_Offset );
712 LCD_Write_Reg( ILI9325_GRAM_HADDR, Screen_Width - y - 1 + LCD_Offset );
715 LCD_Write_Reg( ILI9325_GRAM_VADDR, Screen_Height - x - 1 + LCD_Offset );
760 if ( FullScreenONOFF != 0 )
763 #if TOUCHSCREEN_AVAIL
770 Screen_Width = PHYS_SCREEN_WIDTH;
771 Screen_Height = PHYS_SCREEN_HEIGHT;
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 );
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 );
795 #if TOUCHSCREEN_AVAIL
804 LCD_DrawCharSetFilter( 0, APP_SCREEN_WIDTH, 0, APP_SCREEN_HEIGHT );