21 #define ROTATE_DIVIDER 127
23 #define abs(X) ( ( (X) < 0 ) ? -(X) : (X) )
24 #define sgn(X) ( ( (X) < 0 ) ? -1 : 1 )
28 mag_t CharMagniCoeff = 1;
35 coord_t LeftMarginX = 0;
36 coord_t RightMarginX = APP_SCREEN_WIDTH;
37 coord_t HighMarginY = APP_SCREEN_HEIGHT;
38 coord_t LowMarginY = 0;
40 bool fDisplayTime = 0;
50 divider_t divider_coord = 0;
53 divider_t rotate_counter = 0;
60 bool CurrentRotateScreen = 1;
67 void DRAW_Clear_Text( coord_t x, coord_t y, len_t len,
bool mode );
91 void DRAW_Clear_Text( coord_t x, coord_t y, len_t len,
bool mode )
97 for ( i = 0 ; i < len ; i++ )
100 LCD_DisplayChar( ref_x, y,
' ', mode ? BGndColor : TextColor, mode ? TextColor : BGndColor, CharMagniCoeff );
103 ref_x += ( Char_Width * CharMagniCoeff );
123 NODEBUG
void DRAW_Init(
void )
126 #if MEMS_POINTER // Not necessary if no MEMS menu handling
132 xBat = Screen_Width - 30;
135 PosCurY = Screen_Height - Char_Height;
136 RightMarginX = Screen_Width;
137 HighMarginY = Screen_Height;
142 LCD_Batt( xBat, yBat, fDisplayTime, BatState, &OldBatState, divider_coord, &widthBat, &heightBat );
159 void DRAW_Handler(
void )
163 LCD_Batt( xBat, yBat, fDisplayTime, BatState, &OldBatState, divider_coord, &widthBat, &heightBat );
165 #if MEMS_POINTER // Not necessary if no MEMS menu handling
171 if ( rotate_counter == ROTATE_DIVIDER )
175 if ( new_orient != previous_previous_orient )
177 if ( ( new_orient == previous_orient ) && ( new_orient != CurrentScreenOrientation ) )
179 CurrentScreenOrientation = new_orient;
182 #if TOUCHSCREEN_AVAIL
183 TOOLBAR_RedrawToolbar( TOOLBAR_REDRAW );
187 if ( CurrentMenu != 0 )
194 previous_previous_orient = previous_orient;
195 previous_orient = new_orient;
202 DMA_LCD_UpdateScreen();
218 NODEBUG2
void DRAW_Batt(
void )
223 LCD_FillRect_Circle( xBat, yBat, widthBat, heightBat,
RGB_BLUE );
224 LCD_FillRect_Circle( xBat + 1 , yBat + 1 , widthBat - 2 , heightBat - 2 ,
RGB_WHITE );
229 LCD_FillRect_Circle( xBat - 2 , yBat + 2 , widthBat , heightBat,
RGB_BLUE );
230 LCD_FillRect_Circle( xBat - 1 , yBat + 3 , widthBat - 1 , heightBat - 2 ,
RGB_WHITE );
253 NODEBUG2
void DRAW_Line_Circle( coord_t x1, coord_t y1, coord_t x2, coord_t y2, color_t color )
257 coord_t dxabs, dyabs;
272 LCD_FillRect_Circle( x1, y1, 1, y2 - y1 + 1, color );
286 LCD_FillRect_Circle( x1, y1, x2 - x1 + 1, 1, color );
299 if ( dxabs >= dyabs )
301 for ( i = 0; i < dxabs; i++ )
315 for ( i = 0; i < dyabs; i++ )
340 NODEBUG2
void DRAW_RestoreCharMagniCoeff(
void )
362 NODEBUG2
void DRAW_Cross_Absolute( coord_t x1, coord_t y1, color_t color, u16 CrossSize )
364 DRAW_Line( x1 - CrossSize, y1, x1 + CrossSize, y1, color );
365 DRAW_Line( x1, y1 - CrossSize, x1, y1 + CrossSize, color );
387 NODEBUG2
void DRAW_DisplayTemp( coord_t x, coord_t y )
392 char TempTextBuffer[6];
409 if ( ( Temp != OldTemp ) || firstTime )
413 c = ( ( Temp - r ) / 100 );
415 TempTextBuffer[0] = c + 0x30;
418 c = ( ( Temp - r ) / 10 );
420 TempTextBuffer[1] = c + 0x30;
423 TempTextBuffer[2] =
'.';
426 c = ( ( Temp - r ) );
427 TempTextBuffer[3] = c + 0x30;
430 TempTextBuffer[4] = fTemperatureInFahrenheit ?
'F' :
'C';
431 TempTextBuffer[5] = 0;
453 NODEBUG2 color_t DRAW_GetIndexedColorBMP( u8* color_table, u16 i )
456 color = ( color_table[i] & 0x1c ) << 11;
457 color |= ( color_table[i + 1] & 0xf8 ) << 5;
458 color |= ( color_table[i + 3] & 0xf8 );
459 color |= ( color_table[i] & 0xe0 ) >> 5;
483 CharMagniCoeff = Coeff;
501 return CharMagniCoeff;
593 LCD_FillRect_Circle( 0, 0, Screen_Height, Screen_Width, BGndColor );
595 LCD_FillRect_Circle( 0, 0, Screen_Width, Screen_Height, BGndColor );
597 if ( ( CurrentMenu == 0 ) && ( CurrentCommand == 0 )
602 LCD_Clear( xBat, yBat );
649 void DRAW_SetImage(
const color_t* imageptr, coord_t x, coord_t y, coord_t width, coord_t height )
678 void DRAW_SetImageSel(
const color_t* imageptr, coord_t x, coord_t y, coord_t width, coord_t height, color_t oldBgndColor, color_t newBgndColor )
693 if ( ( imageptr[0] == 0x424D ) && ( imageptr[3] == 0 ) )
697 imagetemp = ( color_t* )( imageptr ) + ( imageptr[5] >> 9 ) + ( ( imageptr[5] & 0xff ) << 7 ) ;
701 LCD_SendLCDCmd_RAM_Access();
703 switch ( ( ( imageptr[14] >> 8 ) + ( imageptr[15] & 0xff00 ) ) )
708 for ( i = 0; i < j ; i++ )
710 if ( imageptr[i] != oldBgndColor )
724 color_table = ( u8* )imageptr + 0x36;
725 for ( i = 0; ( 2 * i ) < j ; i++ )
727 color = DRAW_GetIndexedColorBMP( color_table, 4 * ( imagetemp[i] >> 8 ) );
728 if ( color == oldBgndColor )
729 color = newBgndColor;
732 color = DRAW_GetIndexedColorBMP( color_table, 4 * ( imagetemp[i] & 0xff ) );
739 color_table = ( u8* )imageptr + 0x36;
744 if ( ( imagetemp[i] >> 8 ) == 0 )
746 k = imagetemp[i] & 0xff;
751 color = newBgndColor;
752 while ( ( j % width ) != 0 )
769 color = DRAW_GetIndexedColorBMP( color_table , 4 * ( imagetemp[i] >> 8 ) );
775 color = DRAW_GetIndexedColorBMP( color_table , 4 * ( imagetemp[i] & 0xff ) );
776 if ( color == oldBgndColor )
777 color = newBgndColor;
789 color = DRAW_GetIndexedColorBMP( color_table , 4 * ( imagetemp[i] & 0xff ) );
790 if ( color == oldBgndColor )
791 color = newBgndColor;
792 k = imagetemp[i] >> 8;
794 for ( ; k > 0 ; k-- )
807 LCD_SendLCDCmd_RAM_Access_End();
816 LCD_SendLCDCmd_RAM_Access();
818 for ( i = 0; i < j ; i++ )
820 if ( imageptr[i] != oldBgndColor )
832 LCD_SendLCDCmd_RAM_Access_End();
859 void DRAW_SetImageBW(
const u8* imageptr, coord_t x, coord_t y, coord_t width, coord_t height )
863 k = ( width * height ) >> 3;
869 LCD_SendLCDCmd_RAM_Access();
872 for ( i = 0; i < k; i++ )
875 for ( j = 0; j < 8; j++ )
878 if ( imageptr && ( ( ( imageptr[i] ) >> ( 7 - j ) ) & 1 ) )
893 LCD_SendLCDCmd_RAM_Access_End();
951 static u8 OldTHH = 100;
952 static u8 OldTMM = 100;
953 static u8 OldTSS = 100;
955 static char TimeTextBuffer[9];
965 TimeTextBuffer[2] =
':';
971 TimeTextBuffer[5] =
':';
977 TimeTextBuffer[8] =
'\0';
1023 Display_Width = Screen_Height;
1027 Display_Width = Screen_Width;
1032 len = my_strlen( ptr );
1034 len = Display_Width / ( Char_Width * CharMagniCoeff );
1037 CharWidth = Char_Width * CharMagniCoeff;
1038 lx = x + ( len * CharWidth );
1039 if ( lx > Display_Width )
1041 if ( ( ( lx - Display_Width ) % CharWidth ) == 0 )
1042 len -= ( ( lx - Display_Width ) / CharWidth );
1044 len -= ( ( ( lx - Display_Width ) / CharWidth ) + 1 );
1048 if ( ( Transparency == 0 ) || ( CharMagniCoeff > 3 ) )
1049 DRAW_Clear_Text( x, y, len, mode );
1053 lgc = my_strlen( ptr );
1061 ref_x += (( len - lgc ) * CharWidth ) / 2;
1067 for (i = 0 ; i < (lgc - len); i++)
1071 ref_x += ( len - lgc ) * CharWidth;
1082 for ( i = 0 ; i < lgc; i++ )
1085 LCD_DisplayChar( ref_x, y, *ptr++, mode ? BGndColor : TextColor, mode ? TextColor : BGndColor, CharMagniCoeff );
1182 void DRAW_Line( coord_t x1, coord_t y1, coord_t x2, coord_t y2, color_t color )
1190 if ( x1 > Screen_Width - 1 )
1191 x1 = Screen_Width - 1;
1192 if ( x2 > Screen_Width - 1 )
1193 x2 = Screen_Width - 1;
1201 if ( y1 > Screen_Height - 1 )
1202 y1 = Screen_Height - 1;
1203 if ( y2 > Screen_Height - 1 )
1204 y2 = Screen_Height - 1;
1207 DRAW_Line_Circle( x1, y1, x2, y2, color );
1232 u16 Char_Y = Char_Height * CharMagniCoeff;
1235 if ( ( Ascii ==
'\n' ) )
1237 PosCurX = LeftMarginX;
1238 if ( PosCurY >= LowMarginY )
1246 if ( ( PosCurX + ( Char_Width * CharMagniCoeff ) ) > RightMarginX )
1248 PosCurX = LeftMarginX;
1253 if ( PosCurY >= LowMarginY )
1256 LCD_DisplayChar( PosCurX, PosCurY, Ascii, TextColor, BGndColor, CharMagniCoeff );
1260 LCD_Scroll( Ascii, PosCurX, &PosCurY, RightMarginX, LeftMarginX, HighMarginY, LowMarginY, BGndColor, TextColor, CharMagniCoeff );
1263 PosCurX += ( Char_Width * CharMagniCoeff );
1320 if ( x < LeftMarginX )
1322 else if ( x > RightMarginX )
1326 if ( y < LowMarginY )
1328 else if ( y > HighMarginY - ( Char_Height * CharMagniCoeff ) )
1329 y = HighMarginY - ( Char_Height * CharMagniCoeff );
1350 return ( PosCurX | ( PosCurY << 8 ) );
1377 if ( rx > Screen_Width )
1388 if ( hy > Screen_Height )
1449 void DRAW_Circle( coord_t CENTER_x, coord_t CENTER_y, coord_t RADIUS_r, color_t Color, color_t Fill_Color,
bool Fill,
bool Circle )
1451 int Error = 1 - RADIUS_r;
1453 int ddF_y = -2 * RADIUS_r;
1458 if ( CENTER_x - RADIUS_r < 0 )
1459 CENTER_x = RADIUS_r;
1461 if ( CENTER_x + RADIUS_r > Screen_Width - 1 )
1462 CENTER_x = Screen_Width - RADIUS_r - 1;
1465 if ( CENTER_y - RADIUS_r < 0 )
1466 CENTER_y = RADIUS_r;
1468 if ( CENTER_y + RADIUS_r > Screen_Height - 1 )
1469 CENTER_y = Screen_Height - RADIUS_r - 1;
1476 DRAW_Circle( CENTER_x, CENTER_y, RADIUS_r, Color, Fill_Color, 1, 0 );
1482 DRAW_Line( CENTER_x + RADIUS_r, CENTER_y, CENTER_x - RADIUS_r, CENTER_y, Fill_Color );
1483 DRAW_Line( CENTER_x , CENTER_y - RADIUS_r, CENTER_x, CENTER_y + RADIUS_r, Fill_Color );
1507 DRAW_Line( CENTER_x + x, CENTER_y + y, CENTER_x + x, CENTER_y - y, Fill_Color );
1508 DRAW_Line( CENTER_x - x, CENTER_y + y, CENTER_x - x, CENTER_y - y, Fill_Color );
1509 DRAW_Line( CENTER_x + y, CENTER_y + x, CENTER_x + y, CENTER_y - x, Fill_Color );
1510 DRAW_Line( CENTER_x - y, CENTER_y + x, CENTER_x - y, CENTER_y - x, Fill_Color );
1546 void DRAW_Ellipse( coord_t CENTER_x, coord_t CENTER_y, coord_t RADIUS_a, coord_t RADIUS_b, color_t Color, color_t Fill_Color,
bool Fill,
bool Ellipse )
1549 int XChange, YChange;
1551 int TwoASquare, TwoBSquare;
1552 int StoppingX, StoppingY;
1553 TwoASquare = 2 * RADIUS_a * RADIUS_a;
1554 TwoBSquare = 2 * RADIUS_b * RADIUS_b;
1557 XChange = RADIUS_b * RADIUS_b * ( 1 - 2 * RADIUS_a );
1558 YChange = RADIUS_a * RADIUS_a;
1560 StoppingX = TwoBSquare * RADIUS_a;
1564 if ( CENTER_x - RADIUS_a < 0 )
1565 CENTER_x = RADIUS_a;
1567 if ( CENTER_x + RADIUS_a > Screen_Width - 1 )
1568 CENTER_x = Screen_Width - RADIUS_a - 1;
1571 if ( CENTER_y - RADIUS_b < 0 )
1572 CENTER_y = RADIUS_b;
1574 if ( CENTER_y + RADIUS_b > Screen_Height - 1 )
1575 CENTER_y = Screen_Height - RADIUS_b - 1;
1582 DRAW_Ellipse( CENTER_x, CENTER_y, RADIUS_a, RADIUS_b, Color, Fill_Color, 1, 0 );
1586 while ( StoppingX >= StoppingY )
1590 DRAW_Line( CENTER_x + X, CENTER_y + Y, CENTER_x - X , CENTER_y + Y, Fill_Color );
1591 DRAW_Line( CENTER_x - X, CENTER_y - Y, CENTER_x + X , CENTER_y - Y, Fill_Color );
1602 StoppingY += TwoASquare;
1603 EllipseError += YChange;
1604 YChange += TwoASquare;
1605 if ( ( 2 * EllipseError + XChange ) > 0 )
1608 StoppingX -= TwoBSquare;
1609 EllipseError += XChange;
1610 XChange += TwoBSquare;
1617 XChange = RADIUS_b * RADIUS_b;
1618 YChange = RADIUS_a * RADIUS_a * ( 1 - 2 * RADIUS_b );
1621 StoppingY = TwoASquare * RADIUS_b;
1623 while ( StoppingX <= StoppingY )
1627 DRAW_Line( CENTER_x + X, CENTER_y + Y, CENTER_x - X , CENTER_y + Y, Fill_Color );
1628 DRAW_Line( CENTER_x - X, CENTER_y - Y, CENTER_x + X , CENTER_y - Y, Fill_Color );
1640 StoppingX += TwoBSquare;
1641 EllipseError += XChange;
1642 XChange += TwoBSquare;
1644 if ( ( 2 * EllipseError + YChange ) > 0 )
1647 StoppingY -= TwoASquare;
1648 EllipseError += YChange;
1649 YChange += TwoASquare;
1676 for ( i = 1; i < NUM_Points >> 1 ; i++ )
1678 DRAW_Line( points[( i - 1 ) * 2], points[1 + ( i - 1 ) * 2], points[( i ) * 2], points[1 + ( i ) * 2], Line_Color );