Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: TFT_fonts mbed-os
Fork of newTFTLCD by
lcd_base.cpp
00001 /* 00002 * Copyright (C)2010-2012 Henning Karlsen. All right reserved. 00003 * Copyright (C)2012 Todor Todorov. 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to: 00017 * 00018 * Free Software Foundation, Inc. 00019 * 51 Franklin St, 5th Floor, Boston, MA 02110-1301, USA 00020 * 00021 *********************************************************************/ 00022 #include "lcd_base.h" 00023 #include "helpers.h" 00024 00025 LCD::LCD( unsigned short width, unsigned short height ,PinName CS, PinName RS, PinName RESET, PinName BL, backlight_t blType, float defaultBacklight ) 00026 : _disp_width( width ), _disp_height( height ), _lcd_pin_cs( CS ), _lcd_pin_rs( RS ), _lcd_pin_reset( RESET ), _bl_type( blType ) 00027 { 00028 SetForeground(); 00029 SetBackground(); 00030 _font = &TerminusFont; 00031 if ( defaultBacklight < 0 ) _bl_pwm_default = 0; 00032 else if ( defaultBacklight > 1.0 ) _bl_pwm_default = 1.0; 00033 else _bl_pwm_default = defaultBacklight; 00034 if ( BL != NC ) 00035 { 00036 if ( blType == Constant ) 00037 { 00038 _bl_pwm = 0; 00039 _lcd_pin_bl = new DigitalOut( BL ); 00040 } 00041 else 00042 { 00043 _lcd_pin_bl = 0; 00044 _bl_pwm = new PwmOut( BL ); 00045 _bl_pwm->period_ms( 8.33 ); // 120 Hz 00046 _bl_pwm_current = _bl_pwm_default; 00047 // initially off 00048 *_bl_pwm = 0; 00049 } 00050 00051 } 00052 else 00053 { 00054 _lcd_pin_bl = 0; 00055 _bl_pwm = 0; 00056 } 00057 } 00058 00059 void LCD::Sleep( void ) 00060 { 00061 if ( _lcd_pin_bl != 0 ) 00062 *_lcd_pin_bl = LOW; 00063 else if ( _bl_pwm != 0 ) 00064 *_bl_pwm = 0; 00065 } 00066 00067 void LCD::WakeUp( void ) 00068 { 00069 if ( _lcd_pin_bl != 0 ) 00070 *_lcd_pin_bl = HIGH; 00071 else if ( _bl_pwm != 0 ) 00072 *_bl_pwm = _bl_pwm_current; 00073 } 00074 00075 inline 00076 void LCD::SetForeground( unsigned int color ) 00077 { 00078 _foreground = color; 00079 } 00080 00081 inline 00082 void LCD::SetBackground( unsigned int color ) 00083 { 00084 _background = color; 00085 } 00086 00087 void LCD::SetFont( const unsigned char font_t ) 00088 { 00089 //_font = font; 00090 _font = _font; 00091 } 00092 00093 inline 00094 unsigned short LCD::GetWidth( void ) 00095 { 00096 if ( _orientation == LANDSCAPE || _orientation == LANDSCAPE_REV ) return _disp_height; 00097 return _disp_width; 00098 } 00099 00100 inline 00101 unsigned short LCD::GetHeight( void ) 00102 { 00103 if ( _orientation == LANDSCAPE || _orientation == LANDSCAPE_REV ) return _disp_width; 00104 return _disp_height; 00105 } 00106 00107 inline 00108 uint8_t LCD::GetFontWidth( void ) 00109 { 00110 if ( _font != 0 ) return _font->Width; 00111 return 0; 00112 } 00113 00114 inline 00115 uint8_t LCD::GetFontHeight( void ) 00116 { 00117 if ( _font != 0 ) return _font->Height; 00118 return 0; 00119 } 00120 00121 void LCD::SetBacklightLevel( float level ) 00122 { 00123 switch ( _bl_type ) 00124 { 00125 case Direct: 00126 if ( _bl_pwm != 0 ) 00127 { 00128 *_bl_pwm = level; 00129 _bl_pwm_current = level; 00130 } 00131 break; 00132 00133 case Indirect: 00134 break; 00135 case Constant: 00136 default: 00137 break; 00138 } 00139 } 00140 00141 void LCD::FillScreen( int color ) 00142 { 00143 unsigned int rgb = color == -1 ? _background : color == -2 ? _foreground : ( unsigned int ) color; 00144 Activate(); 00145 ClearXY(); 00146 for ( int i = 0; i < ( ( _disp_width ) * ( _disp_height ) ); i++ ) 00147 SetPixelColor( rgb ); 00148 Deactivate(); 00149 } 00150 00151 inline 00152 void LCD::ClearScreen( void ) 00153 { 00154 FillScreen( 0 );//changed from -1 to 0 by madhu 00155 } 00156 00157 void LCD::DrawPixel( unsigned short x, unsigned short y, int color ) 00158 { 00159 Activate(); 00160 SetXY( x, y, x, y ); 00161 SetPixelColor( color == -1 ? _background : 00162 color == -2 ? _foreground : color ); 00163 Deactivate(); 00164 } 00165 00166 void LCD::DrawLine( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color ) 00167 { 00168 00169 double delta, tx, ty; 00170 00171 if ( ( ( x2 - x1 ) < 0 ) ) 00172 { 00173 swap( ushort, x1, x2 ) 00174 swap( ushort, y1, y2 ) 00175 } 00176 if ( ( ( y2 - y1 ) < 0 ) ) 00177 { 00178 swap( ushort, x1, x2 ) 00179 swap( ushort, y1, y2 ) 00180 } 00181 00182 if ( y1 == y2 ) 00183 { 00184 if ( x1 > x2 ) 00185 swap( ushort, x1, x2 ) 00186 DrawHLine( x1, y1, x2 - x1, color ); 00187 } 00188 else if ( x1 == x2 ) 00189 { 00190 if ( y1 > y2 ) 00191 swap( ushort, y1, y2 ) 00192 DrawVLine( x1, y1, y2 - y1, color ); 00193 } 00194 else 00195 { 00196 unsigned int usedColor = color == -1 ? _background : color == -2 ? _foreground : ( unsigned int ) color; 00197 Activate(); 00198 if ( abs( x2 - x1 ) > abs( y2 - y1 ) ) 00199 { 00200 delta = ( double( y2 - y1 ) / double( x2 - x1 ) ); 00201 ty = double( y1 ); 00202 if ( x1 > x2 ) 00203 { 00204 for ( int i = x1; i >= x2; i-- ) 00205 { 00206 SetXY( i, int( ty + 0.5 ), i, int( ty + 0.5 ) ); 00207 SetPixelColor( usedColor ); 00208 ty = ty - delta; 00209 } 00210 } 00211 else 00212 { 00213 for ( int i = x1; i <= x2; i++ ) 00214 { 00215 SetXY( i, int( ty + 0.5 ), i, int( ty + 0.5 ) ); 00216 SetPixelColor( usedColor ); 00217 ty = ty + delta; 00218 } 00219 } 00220 } 00221 else 00222 { 00223 delta = ( float( x2 - x1 ) / float( y2 - y1 ) ); 00224 tx = float( x1 ); 00225 if ( y1 > y2 ) 00226 { 00227 for ( int i = y2 + 1; i > y1; i-- ) 00228 { 00229 SetXY( int( tx + 0.5 ), i, int( tx + 0.5 ), i ); 00230 SetPixelColor( usedColor ); 00231 tx = tx + delta; 00232 } 00233 } 00234 else 00235 { 00236 for ( int i = y1; i < y2 + 1; i++ ) 00237 { 00238 SetXY( int( tx + 0.5 ), i, int( tx + 0.5 ), i ); 00239 SetPixelColor( usedColor ); 00240 tx = tx + delta; 00241 } 00242 } 00243 } 00244 Deactivate(); 00245 } 00246 } 00247 00248 void LCD::DrawRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color ) 00249 { 00250 if ( x1 > x2 ) swap( ushort, x1, x2 ) 00251 if ( y1 > y2 ) swap( ushort, y1, y2 ) 00252 00253 DrawHLine( x1, y1, x2 - x1, color ); 00254 DrawHLine( x1, y2, x2 - x1, color ); 00255 DrawVLine( x1, y1, y2 - y1, color ); 00256 DrawVLine( x2, y1, y2 - y1, color ); 00257 } 00258 00259 void LCD::DrawRoundRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color ) 00260 { 00261 if ( x1 > x2 ) swap( ushort, x1, x2 ) 00262 if ( y1 > y2 ) swap( ushort, y1, y2 ) 00263 00264 if ( ( x2 - x1 ) > 4 && ( y2 - y1 ) > 4 ) 00265 { 00266 DrawPixel( x1 + 1, y1 + 1, color ); 00267 DrawPixel( x2 - 1, y1 + 1, color ); 00268 DrawPixel( x1 + 1, y2 - 1, color ); 00269 DrawPixel( x2 - 1, y2 - 1, color ); 00270 DrawHLine( x1 + 2, y1, x2 - x1 - 4, color ); 00271 DrawHLine( x1 + 2, y2, x2 - x1 - 4, color ); 00272 DrawVLine( x1, y1 + 2, y2 - y1 - 4, color ); 00273 DrawVLine( x2, y1 + 2, y2 - y1 - 4, color ); 00274 } 00275 } 00276 00277 void LCD::FillRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color ) 00278 { 00279 if ( x1 > x2 ) swap( ushort, x1, x2 ); 00280 if ( y1 > y2 ) swap( ushort, y1, y2 ); 00281 00282 for ( int i = 0; i < ( ( y2 - y1 ) / 2 ) + 1; i++ ) 00283 { 00284 DrawHLine( x1, y1 + i, x2 - x1, color ); 00285 DrawHLine( x1, y2 - i, x2 - x1, color ); 00286 } 00287 } 00288 00289 void LCD::FillRoundRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color ) 00290 { 00291 if ( x1 > x2 ) swap( ushort, x1, x2 ) 00292 if ( y1 > y2 ) swap( ushort, y1, y2 ) 00293 00294 if ( ( x2 - x1 ) > 4 && ( y2 - y1 ) > 4 ) 00295 { 00296 for ( int i = 0; i < ( ( y2 - y1 ) / 2 ) + 1; i++ ) 00297 { 00298 switch ( i ) 00299 { 00300 case 0: 00301 DrawHLine( x1 + 2, y1 + i, x2 - x1 - 4, color ); 00302 DrawHLine( x1 + 2, y2 - i, x2 - x1 - 4, color ); 00303 break; 00304 00305 case 1: 00306 DrawHLine( x1 + 1, y1 + i, x2 - x1 - 2, color ); 00307 DrawHLine( x1 + 1, y2 - i, x2 - x1 - 2, color ); 00308 break; 00309 00310 default: 00311 DrawHLine( x1, y1 + i, x2 - x1, color ); 00312 DrawHLine( x1, y2 - i, x2 - x1, color ); 00313 break; 00314 } 00315 } 00316 } 00317 } 00318 00319 void LCD::DrawCircle( unsigned short x, unsigned short y, unsigned short radius, int color ) 00320 { 00321 int f = 1 - radius; 00322 int ddF_x = 1; 00323 int ddF_y = -2 * radius; 00324 int x1 = 0; 00325 int y1 = radius; 00326 unsigned int usedColor = color == -1 ? _background : color == -2 ? _foreground : ( unsigned int ) color; 00327 00328 Activate(); 00329 SetXY( x, y + radius, x, y + radius ); 00330 SetPixelColor( usedColor ); 00331 SetXY( x, y - radius, x, y - radius ); 00332 SetPixelColor( usedColor ); 00333 SetXY( x + radius, y, x + radius, y ); 00334 SetPixelColor( usedColor ); 00335 SetXY( x - radius, y, x - radius, y ); 00336 SetPixelColor( usedColor ); 00337 00338 while ( x1 < y1 ) 00339 { 00340 if ( f >= 0 ) 00341 { 00342 y1--; 00343 ddF_y += 2; 00344 f += ddF_y; 00345 } 00346 x1++; 00347 ddF_x += 2; 00348 f += ddF_x; 00349 SetXY( x + x1, y + y1, x + x1, y + y1 ); 00350 SetPixelColor( usedColor ); 00351 SetXY( x - x1, y + y1, x - x1, y + y1 ); 00352 SetPixelColor( usedColor ); 00353 SetXY( x + x1, y - y1, x + x1, y - y1 ); 00354 SetPixelColor( usedColor ); 00355 SetXY( x - x1, y - y1, x - x1, y - y1 ); 00356 SetPixelColor( usedColor ); 00357 SetXY( x + y1, y + x1, x + y1, y + x1 ); 00358 SetPixelColor( usedColor ); 00359 SetXY( x - y1, y + x1, x - y1, y + x1 ); 00360 SetPixelColor( usedColor ); 00361 SetXY( x + y1, y - x1, x + y1, y - x1 ); 00362 SetPixelColor( usedColor ); 00363 SetXY( x - y1, y - x1, x - y1, y - x1 ); 00364 SetPixelColor( usedColor ); 00365 } 00366 Deactivate(); 00367 } 00368 00369 void LCD::FillCircle( unsigned short x, unsigned short y, unsigned short radius, int color ) 00370 { 00371 unsigned int usedColor = color == -1 ? _background : color == -2 ? _foreground : ( unsigned int ) color; 00372 Activate(); 00373 for ( int y1 = -radius; y1 <= radius; y1++ ) 00374 for ( int x1 = -radius; x1 <= radius; x1++ ) 00375 if ( x1 * x1 + y1 * y1 <= radius * radius ) 00376 { 00377 SetXY( x + x1, y + y1, x + x1, y + y1 ); 00378 SetPixelColor( usedColor ); 00379 } 00380 Deactivate(); 00381 } 00382 00383 void LCD::Print( const char *str, unsigned short x, unsigned short y, int fgColor, int bgColor, unsigned short deg ) 00384 { 00385 int stl, i; 00386 char rot[100]; 00387 00388 stl = strlen( str ); 00389 00390 if ( x == RIGHT ) 00391 x = GetWidth() - ( stl * _font->Width ); 00392 if ( x == CENTER ) 00393 x = ( GetWidth() - ( stl * _font->Width ) ) / 2; 00394 00395 for ( i = 0; i < stl; i++ ) 00396 if ( deg == 0 ) 00397 PrintChar( *str++, x + ( i * ( _font->Width ) ), y, fgColor, bgColor ); 00398 else 00399 RotateChar( *str++, x, y, i, fgColor, bgColor, deg ); 00400 } 00401 void LCD::Printinv( const char *str, unsigned short x, unsigned short y, int fgColor, int bgColor, unsigned short deg ) 00402 { 00403 int stl, i; 00404 00405 stl = strlen( str ); 00406 00407 if ( x == RIGHT ) 00408 x = GetWidth() - ( stl * _font->Width ); 00409 if ( x == CENTER ) 00410 x = ( GetWidth() - ( stl * _font->Width ) ) / 2; 00411 00412 for ( i = 0; i < stl; i++ ) 00413 if ( deg == 180 ) 00414 PrintChar( *str++, y+( i * ( _font->Width ) ), x, fgColor, bgColor ); 00415 00416 else 00417 RotateChar( *str++, x, y, i, fgColor, bgColor, deg ); 00418 } 00419 00420 void LCD::DrawBitmap( unsigned short x, unsigned short y, const bitmap_t* img, unsigned char scale ) 00421 { 00422 int tx, ty, tc, tsx, tsy; 00423 00424 Activate(); 00425 if ( scale == 1 ) 00426 { 00427 SetXY( x, y, x + img->Width - 1, y + img->Height - 1 ); 00428 00429 if ( img->Format == RGB16 ) 00430 { 00431 const unsigned short *pixel = ( const unsigned short* ) img->PixelData; 00432 for ( tc = 0; tc < ( img->Width * img->Height ); tc++ ) 00433 SetPixelColor( *pixel++, img->Format ); 00434 } 00435 else if ( img->Format == RGB18 ) 00436 { 00437 const unsigned int *pixel = ( const unsigned int* ) img->PixelData; 00438 for ( tc = 0; tc < ( img->Width * img->Height ); tc++ ) 00439 SetPixelColor( *pixel++, img->Format ); 00440 } 00441 } 00442 else 00443 { 00444 if ( img->Format == RGB16 ) 00445 { 00446 const unsigned short *pixel = ( const unsigned short* ) img->PixelData; 00447 00448 for ( ty = 0; ty < img->Height; ty++ ) 00449 { 00450 SetXY( x, y + ( ty * scale ), x + ( ( img->Width * scale ) - 1 ), y + ( ty * scale ) + scale ); 00451 for ( tsy = 0; tsy < scale; tsy++ ) 00452 { 00453 for ( tx = 0; tx < img->Width; tx++ ) 00454 { 00455 for ( tsx = 0; tsx < scale; tsx++ ) 00456 SetPixelColor( pixel[ ( ty * img->Width ) + tx ], img->Format ); 00457 } 00458 } 00459 } 00460 } 00461 else if ( img->Format == RGB18 ) 00462 { 00463 const unsigned int *pixel = ( const unsigned int* ) img->PixelData; 00464 00465 for ( ty = 0; ty < img->Height; ty++ ) 00466 { 00467 SetXY( x, y + ( ty * scale ), x + ( ( img->Width * scale ) - 1 ), y + ( ty * scale ) + scale ); 00468 for ( tsy = 0; tsy < scale; tsy++ ) 00469 { 00470 for ( tx = 0; tx < img->Width; tx++ ) 00471 { 00472 for ( tsx = 0; tsx < scale; tsx++ ) 00473 SetPixelColor( pixel[ ( ty * img->Width ) + tx ], img->Format ); 00474 } 00475 } 00476 } 00477 } 00478 } 00479 Deactivate(); 00480 } 00481 00482 void LCD::DrawBitmap( unsigned short x, unsigned short y, const bitmap_t* img, unsigned short deg, unsigned short rox, unsigned short roy ) 00483 { 00484 int tx, ty, newx, newy; 00485 double radian; 00486 radian = deg * 0.0175; 00487 00488 if ( deg == 0 ) 00489 DrawBitmap( x, y, img ); 00490 else 00491 { 00492 Activate(); 00493 00494 if ( img->Format == RGB16 ) 00495 { 00496 const unsigned short *pixel = ( const unsigned short* ) img->PixelData; 00497 00498 for ( ty = 0; ty < img->Height; ty++ ) 00499 for ( tx = 0; tx < img->Width; tx++ ) 00500 { 00501 newx = x + rox + ( ( ( tx - rox ) * cos( radian ) ) - ( ( ty - roy ) * sin( radian ) ) ); 00502 newy = y + roy + ( ( ( ty - roy ) * cos( radian ) ) + ( ( tx - rox ) * sin( radian ) ) ); 00503 00504 SetXY( newx, newy, newx, newy ); 00505 SetPixelColor( pixel[ ( ty * img->Width ) + tx ], img->Format ); 00506 } 00507 } 00508 else if ( img->Format == RGB18 ) 00509 { 00510 const unsigned int *pixel = ( const unsigned int* ) img->PixelData; 00511 00512 for ( ty = 0; ty < img->Height; ty++ ) 00513 for ( tx = 0; tx < img->Width; tx++ ) 00514 { 00515 newx = x + rox + ( ( ( tx - rox ) * cos( radian ) ) - ( ( ty - roy ) * sin( radian ) ) ); 00516 newy = y + roy + ( ( ( ty - roy ) * cos( radian ) ) + ( ( tx - rox ) * sin( radian ) ) ); 00517 00518 SetXY( newx, newy, newx, newy ); 00519 SetPixelColor( pixel[ ( ty * img->Width ) + tx ], img->Format ); 00520 } 00521 } 00522 Deactivate(); 00523 } 00524 } 00525 00526 inline 00527 void LCD::Activate( void ) 00528 { 00529 _lcd_pin_cs = LOW; 00530 } 00531 00532 inline 00533 void LCD::Deactivate( void ) 00534 { 00535 _lcd_pin_cs = HIGH; 00536 } 00537 00538 inline 00539 void LCD::WriteCmdData( unsigned short cmd, unsigned short data ) 00540 { 00541 WriteCmd( cmd ); 00542 WriteData( data ); 00543 } 00544 00545 inline 00546 void LCD::ClearXY( void ) 00547 { 00548 SetXY( 0, 0, GetWidth() - 1, GetHeight() - 1 ); 00549 } 00550 00551 void LCD::DrawHLine( unsigned short x, unsigned short y, unsigned short len, int color ) 00552 { 00553 unsigned int usedColor = color == -1 ? _background : color == -2 ? _foreground : ( unsigned int ) color; 00554 00555 Activate(); 00556 SetXY( x, y, x + len, y ); 00557 for ( int i = 0; i < len + 1; i++ ) 00558 SetPixelColor( usedColor ); 00559 Deactivate(); 00560 } 00561 00562 void LCD::DrawVLine( unsigned short x, unsigned short y, unsigned short len, int color ) 00563 { 00564 unsigned int usedColor = color == -1 ? _background : color == -2 ? _foreground : ( unsigned int ) color; 00565 00566 Activate(); 00567 SetXY( x, y, x, y + len ); 00568 for ( int i = 0; i < len; i++ ) 00569 SetPixelColor( usedColor ); 00570 Deactivate(); 00571 } 00572 00573 void LCD::PrintChar( char c, unsigned short x, unsigned short y, int fgColor, int bgColor ) 00574 { 00575 uint8_t i, ch; 00576 uint16_t j; 00577 unsigned int usedColorFG = fgColor == -1 ? _background : fgColor == -2 ? _foreground : ( unsigned int ) fgColor; 00578 unsigned int usedColorBG = bgColor == -1 ? _background : bgColor == -2 ? _foreground : ( unsigned int ) bgColor; 00579 00580 uint16_t totalCharBytes = ( _font->Width * _font->Height ) / 8; 00581 int16_t position = _font->Position[ c - _font->Offset ]; 00582 if ( position == -1 ) position = 0; // will print space character 00583 00584 Activate(); 00585 00586 SetXY( x, y, x + _font->Width - 1, y + _font->Height - 1 ); 00587 00588 for ( j = 0; j < totalCharBytes; j++ ) 00589 { 00590 ch = _font->Data[ position ]; 00591 for ( i = 0; i < 8; i++ ) 00592 { 00593 if ( ( ch & ( 1 << ( 7 - i ) ) ) != 0 ) SetPixelColor( usedColorFG ); 00594 else SetPixelColor( usedColorBG ); 00595 } 00596 position++; 00597 } 00598 Deactivate(); 00599 } 00600 00601 void LCD::RotateChar( char c, unsigned short x, unsigned short y, int pos, int fgColor, int bgColor, unsigned short deg ) 00602 { char c1=c; 00603 uint8_t i, j, ch; 00604 int newx, newy; 00605 int ptr1[100][100],ptr2[100][100]; 00606 double radian; 00607 radian = deg * 0.0175; 00608 00609 unsigned int usedColorFG = fgColor == -1 ? _background : fgColor == -2 ? _foreground : ( unsigned int ) fgColor; 00610 unsigned int usedColorBG = bgColor == -1 ? _background : bgColor == -2 ? _foreground : ( unsigned int ) bgColor; 00611 00612 int16_t position = _font->Position[ c - _font->Offset ]; 00613 if ( position == -1 ) position = 0; // will print space character 00614 00615 Activate(); 00616 00617 for ( j = 0; j < _font->Height; j++ ) 00618 { 00619 for ( uint16_t zz = 0; zz < ( ( double ) _font->Width / 8 ); zz++ ) 00620 { 00621 ch = _font->Data[ position + zz ]; 00622 for ( i = 0; i < 8; i++ ) 00623 { 00624 ptr1[j][i]= newx = x + ( ( ( i + ( zz * 8 ) + ( pos * _font->Width ) ) * cos( radian ) ) - ( ( j ) * sin( radian ) ) ); 00625 ptr2[j][i]=newy = y + ( ( ( j ) * cos( radian ) ) + ( ( i + ( zz * 8 ) + ( pos * _font->Width ) ) * sin( radian ) ) ); 00626 00627 // SetXY( newx, newy, newx + 1, newy + 1 ); 00628 00629 //if ( ( ch & ( 1 << ( 7 - i ) ) ) != 0 ) SetPixelColor( usedColorFG ); 00630 //else SetPixelColor( usedColorBG ); 00631 } 00632 } 00633 position += ( _font->Width / 8 ); 00634 } 00635 00636 //Deactivate(); 00637 //} 00638 //adding 00639 position = _font->Position[ c1 - _font->Offset ]; 00640 if ( position == -1 ) position = 0; // will print space character 00641 for ( j = 0; j < _font->Height; j++ ) 00642 { 00643 for ( uint16_t zz = 0; zz < ( ( double ) _font->Width / 8 ); zz++ ) 00644 { 00645 ch = _font->Data[ position + zz ]; 00646 for ( i = 0; i < 8; i++ ) 00647 { 00648 newx = ptr1[j][i]; 00649 newy = ptr2[j][i]; 00650 00651 SetXY( newx, newy, newx + 1, newy + 1 ); 00652 00653 if ( ( ch & ( 1 << ( 7 - i ) ) ) != 0 ) SetPixelColor( usedColorFG ); 00654 else SetPixelColor( usedColorBG ); 00655 } 00656 } 00657 position += ( _font->Width / 8 ); 00658 } 00659 00660 Deactivate(); 00661 }
Generated on Tue Jul 12 2022 16:01:48 by
