C++ file for display control
Dependencies: 4DGL mbed ConfigFile
Fork of 4DGLtest by
Diff: display.cpp
- Revision:
- 7:779c5b8d3b14
- Parent:
- 6:904d00252480
- Child:
- 10:5706b75d40fa
--- a/display.cpp Tue Jul 01 13:27:43 2014 +0000 +++ b/display.cpp Sat Jul 05 16:32:03 2014 +0000 @@ -136,6 +136,167 @@ return nStart; } +int nFontSize( int nfont_number ) +{ + int nFont = 0; + switch ( nfont_number ) + { + case 0: + { + nFont = FONT_12X34; + break; + } + case 1: + { + nFont = FONT_24X34; + break; + } + } + return ( nFont ); +} + +int nFontWidth (int nfont_number ) +{ + int nFont = 12; + switch ( nfont_number ) + { + case 0: + { + nFont = 12; + break; + } + case 1: + { + nFont = 24; + break; + } + } + return ( nFont ); +} + +int cRGB( int cRED, int cGREEN, int cBLUE ) +{ + //assemble separate colors into 1 integer value as 0xRRGGBB + //Display driver requires this format + int RGB = cBLUE + 8*cGREEN + 64*cRED; + return ( RGB ); +} + +int LeftOrRight( int nTextLine, string cString, int nChars, int nCharWidth ) +{ + //decide to print data left aligned or right aligned + //00 - 49 is left side of screen + //50 - 99 is right side of screen + int nHorPos = 0; + // nChars is number of characters on this line (24 or 48) + // nCharWidth is the character width in pixels + + if ( nTextLine < 50 ) + // Left side adjust + { + nHorPos = 0; + } + else + // Right side adjust + { + nHorPos = righttext( cString, nChars, nCharWidth ); + } + return ( nHorPos ); +} + +int nLine2Pixel( int nLine ) +{ + //calculate vertical pixelposition from linenumber + int nPixel = 0; + switch ( nLine ) + { + case 1: + { + nPixel = LINE1; + break; + } + case 2: + { + nPixel = LINE2; + break; + } + + case 3: + { + nPixel = LINE3; + break; + } + + case 4: + { + nPixel = LINE4; + break; + } + + case 5: + { + nPixel = LINE5; + break; + } + + case 6: + { + nPixel = LINE6; + break; + } + + case 7: + { + nPixel = LINE7; + break; + } + + case 8: + { + nPixel = LINE8; + break; + } + + case 9: + { + nPixel = LINE9; + break; + } + + case 10: + { + nPixel = LINE10; + break; + } + + case 11: + { + nPixel = LINE11; + break; + } + + case 12: + { + nPixel = LINE12; + break; + } + + case 13: + { + nPixel = LINE13; + break; + } + + case 14: + { + nPixel = LINE14; + break; + } + + } + return ( nPixel ) ; +} + void CDU_StartScreen() { string cTitle1="ENGRAVITY"; @@ -143,15 +304,15 @@ display.cls(); display.graphic_string( str2char( cTitle1 ), centertext( cTitle1, 24, LARGECHAR), LINE6, FONT_24X34, WHITE, 1, 1 ); - wait_ms(2000); + wait_ms(1000); display.graphic_string( str2char( cTitle2 ), centertext( cTitle2, 24, LARGECHAR), LINE8, FONT_24X34, RED, 1, 1 ); - wait_ms(2000); + wait_ms(1000); display.graphic_string( str2char( cTitle2 ), centertext( cTitle2, 24, LARGECHAR), LINE8, FONT_24X34, GREEN, 1, 1 ); - wait_ms(2000); + wait_ms(1000); display.graphic_string( str2char( cTitle2) , centertext( cTitle2, 24, LARGECHAR), LINE8, FONT_24X34, BLUE, 1, 1 ); - wait_ms(2000); + wait_ms(1000); display.graphic_string( str2char( cTitle2) , centertext( cTitle2, 24, LARGECHAR), LINE8, FONT_24X34, WHITE, 1, 1 ); - wait_ms(2000); + wait_ms(1000); } void CDU_ScreenAlign() @@ -177,4 +338,16 @@ } +void CDU_TestScreen() +{ + display.display_control(IMAGE_FORMAT, NEW); //set correct image for reading from SD + display.cls(); + display.showpicture(0x00, 0x00, 0x00, 0x14, 0x00, 0x01, 0xB5); // Testscreen +} +void CDU_LogoScreen() +{ + display.display_control(IMAGE_FORMAT, NEW); //set correct image for reading from SD + display.cls(); + display.showpicture(0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00); // Engravity logo +}