New work version with additional functions
Dependencies: 4DGL-UC ConfigFile MODSERIAL mbed mbos
Fork of CDU_Mbed_35 by
Diff: screen_handler.cpp
- Revision:
- 8:422544d24df3
- Parent:
- 7:6576a287e563
- Child:
- 10:9a5f1b389973
--- a/screen_handler.cpp Thu Jul 17 10:09:14 2014 +0000 +++ b/screen_handler.cpp Sun Jul 20 16:33:53 2014 +0000 @@ -3,45 +3,37 @@ #include "display.h" #include "FS_datastructures.h" #include "MODSERIAL.h" - -#include <string> +#include <string> using namespace std; - + extern MODSERIAL SERIAL_DEBUG; // <----- debug only !! - -extern int FSdata_received_flag; //Prototype of data flag (declared in main.cpp) + +extern int FSdata_received_flag; extern TFT_4DGL display; //Prototype of Display Driver (declared in display.cpp) - //Prototype of indicators (declared in keyboard.cpp) extern DigitalOut EXEC; extern DigitalOut FAIL; extern DigitalOut DSPY; extern DigitalOut MSG; extern DigitalOut OFST; - extern void CDU_SET_BGL_INTENSITY( int nVal ); //Prototype of function controlling CDU backlight (declared in keyboard.cpp) extern int nFontSize( int nfont_number ); //Prototype of function for fontselection (declared in display.cpp) extern int nFontWidth (int nfont_number ); //Prototype of function to retrieve font width (declared in display.cpp) extern int nLine2Pixel( int nLine ); //Prototype of function to calculate vertical pixelposition from line number (declared in display.cpp) extern int LeftOrRight( int nTextLine, string cString, int nChars, int nCharWidth ); //declared in display.cpp extern int cRGB( char cRED, char cGREEN, char cBLUE ); //Prototype of function for assembly color word (declared in display.cpp) - // FS_data_update_ID: // These global flags indicate what data has been updated. // Should be tested when FS_DATA_EVENT occurs. extern int Background_Col_Update; // 1 when color was updated, must be reset to 0 when data has been read extern int CDU_Status_Update ; // 1 when status was updated, must be reset to 0 when data has been read extern int DO_CLR_SCREEN ; // 1 when screen should be cleared, must be reset to 0 when done -extern int Text_Line_Update ; // equal to line number whose text was updated, must be reset to 0 when text has been read +extern int Text_Line_Update ; // equal to line number whose text was updated, must be reset to 0 when text has been read extern int Key_Maintext_Update ; // equal to keynumber whose main text line was updated, must be reset to -1 (!)when text has been read extern int Key_Subtext_Update ; // equal to keynumber whose sub text line was updated, must be reset to -1 (!) when text has been read - -// Common flag to signal that one or more updates were performed: -//int FSdata_received_flag = false; // : true when one or more FS-to-CDU data structures were updated - + // -------------------------------------------------------------------------------------------------- - void CDU_DSP_CSS() /*Check flags to see if action is required Background_Col_Update; // : 1 when color was updated, must be reset to 0 when data has been read @@ -51,23 +43,24 @@ Key_Maintext_Update ; // : equal to keynumber whose main text line was updated, must be reset to -1 (!)when text has been read Key_Subtext_Update ; // : equal to keynumber whose sub text line was updated, must be reset to -1 (!) when text has been read */ - + { - int nLine = 1; //default value + int nLine = 1; //default line number + int nCharsLine = 24; //characters per line //check common flag - + if ( Background_Col_Update == 1) { display.background_color( cRGB( BACKGROUND_COL.BG_RED, BACKGROUND_COL.BG_GREEN, BACKGROUND_COL.BG_BLUE ) ); Background_Col_Update = 0; } - + if ( Key_Maintext_Update > -1 ) //Key_Maintext_Update contains the line number 00-49 is LSK text, 50-99 is RSK text //Currently used: //00-14 left side of screen --> left adjust, horizontal position = 0 //50-64 right side of screen --> right adjust, horizontal position calculated with righttext() (declared in display.cpp) - + //00 = LSK1 50 = RSK1 Print on LINE 3 //01 = LSK2 51 = RSK2 Print on LINE 5 //02 = LSK3 52 = RSK3 Print on LINE 7 @@ -90,34 +83,41 @@ case ( 05 ): nLine = 13; break; case ( 55 ): nLine = 13; break; } - - SERIAL_DEBUG.printf("Key MAINTEXT is : %s\r\n",SELKEY_MAINTEXT[Key_Maintext_Update].text ); // show text + + switch ( SELKEY_MAINTEXT[Key_Maintext_Update].font_size ) + { + case ( 0 ): nCharsLine = 48; break; + case ( 1 ): nCharsLine = 24; break; + } + + //SERIAL_DEBUG.printf("Key MAINTEXT is : %s\r\n",SELKEY_MAINTEXT[Key_Maintext_Update].text ); // DEBUG, show text //display.graphic_string(char *s, int x, int y, char font, int color, char width multiplier, char height multiplier) + + display.graphic_string( SELKEY_MAINTEXT[Key_Maintext_Update].text , //Text to display + LeftOrRight( Key_Maintext_Update, SELKEY_MAINTEXT[Key_Maintext_Update].text, nCharsLine, nFontWidth( SELKEY_MAINTEXT[Key_Maintext_Update].font_size )) , //Horizontal position + nLine2Pixel( nLine ), //Vertical position + SELKEY_MAINTEXT[Key_Maintext_Update].font_size, //Font + cRGB( SELKEY_MAINTEXT[Key_Maintext_Update].text_RED ,SELKEY_MAINTEXT[Key_Maintext_Update].text_GREEN ,SELKEY_MAINTEXT[Key_Maintext_Update].text_BLUE ), + 1, 1 ); + /* display.graphic_string( SELKEY_MAINTEXT[Key_Maintext_Update].text , //Text to display - LeftOrRight( Key_Maintext_Update, SELKEY_MAINTEXT[Key_Maintext_Update].text,24,24*nFontWidth( SELKEY_MAINTEXT[Key_Maintext_Update].font_size )) , //Horizontal position + 12*24 , //Horizontal position nLine2Pixel( nLine ), //Vertical position - nFontSize( SELKEY_MAINTEXT[Key_Maintext_Update].font_size ), //Font + SELKEY_MAINTEXT[Key_Maintext_Update].font_size, //Font cRGB( SELKEY_MAINTEXT[Key_Maintext_Update].text_RED ,SELKEY_MAINTEXT[Key_Maintext_Update].text_GREEN ,SELKEY_MAINTEXT[Key_Maintext_Update].text_BLUE ), 1, 1 ); */ - display.graphic_string( SELKEY_MAINTEXT[Key_Maintext_Update].text , //Text to display - 12*24 , //Horizontal position - nLine2Pixel( nLine ), //Vertical position - nFontSize( SELKEY_MAINTEXT[Key_Maintext_Update].font_size ), //Font - cRGB( SELKEY_MAINTEXT[Key_Maintext_Update].text_RED ,SELKEY_MAINTEXT[Key_Maintext_Update].text_GREEN ,SELKEY_MAINTEXT[Key_Maintext_Update].text_BLUE ), - 1, 1 ); - - + Key_Maintext_Update = -1; } - + if ( Key_Subtext_Update > -1 ) //Key Subtext_Update contains the line number 00-49 is LSK subtext, 50-99 is RSK subtext //Currently used: //00-14 left side of screen --> left adjust, horizontal position = 0 - //50-64 right side of screen --> right adjust, horizontal position calculated with righttext() (declared in display.cpp) + //50-64 right side of screen --> right adjust, horizontal position calculated with righttext() (declared in display.cpp) //00 = LSK1 50 = RSK1 Print on LINE 2 //01 = LSK2 51 = RSK2 Print on LINE 4 //02 = LSK3 52 = RSK3 Print on LINE 6 @@ -140,31 +140,37 @@ case ( 05 ): nLine = 12; break; case ( 55 ): nLine = 12; break; } - //display.graphic_string(char *s, int x, int y, char font, int color, char width multiplier, char height multiplier) + + switch ( SELKEY_SUBTEXT[Key_Subtext_Update].font_size ) + { + case ( 0 ): nCharsLine = 48; break; + case ( 1 ): nCharsLine = 24; break; + } + //display.graphic_string(char *s, int x, int y, char font, int color, char width multiplier, char height multiplier) display.graphic_string( SELKEY_SUBTEXT[Key_Subtext_Update].text , //Text to display - LeftOrRight( Key_Subtext_Update, SELKEY_SUBTEXT[Key_Subtext_Update].text,12,48*nFontWidth( SELKEY_SUBTEXT[Key_Subtext_Update].font_size )) , //Horizontal position + LeftOrRight( Key_Subtext_Update, SELKEY_SUBTEXT[Key_Subtext_Update].text, nCharsLine, nFontWidth( SELKEY_SUBTEXT[Key_Subtext_Update].font_size )) , //Horizontal position nLine2Pixel( nLine ), //Vertical position - nFontSize( SELKEY_SUBTEXT[Key_Subtext_Update].font_size ), //Font + SELKEY_SUBTEXT[Key_Subtext_Update].font_size, //Font cRGB( SELKEY_SUBTEXT[Key_Subtext_Update].text_RED ,SELKEY_SUBTEXT[Key_Subtext_Update].text_GREEN ,SELKEY_SUBTEXT[Key_Subtext_Update].text_BLUE ), 1, 1 ); //multiplier always on 1 Key_Subtext_Update = -1; } - + if ( Text_Line_Update > 0) { //Text_Line_Update contains the the line number to write display.graphic_string( TEXTLINE[Text_Line_Update].text , //Text to display 0, //Horizontal position always 0 nLine2Pixel( Text_Line_Update ), //Vertical position - nFontSize( TEXTLINE[Text_Line_Update].font_size ), //Font + TEXTLINE[Text_Line_Update].font_size, //Font cRGB( TEXTLINE[Text_Line_Update].text_RED ,TEXTLINE[Text_Line_Update].text_GREEN ,TEXTLINE[Text_Line_Update].text_BLUE ), 1, 1 ); //multiplier always on 1 Text_Line_Update = 0; } - + if ( CDU_Status_Update == 1 ) { -/* +/* CDU_STATUS.stby_mode; // : 0 = operational mode, 1 = standby mode */ if ( CDU_STATUS.backlight ) // Backlight control { @@ -172,7 +178,7 @@ } else { - CDU_SET_BGL_INTENSITY( 0 ); + CDU_SET_BGL_INTENSITY( 0 ); } // Set CDU indicators MSG = CDU_STATUS.msg_indicator; @@ -180,7 +186,6 @@ FAIL = CDU_STATUS.fail_indicator; DSPY = CDU_STATUS.dspy_indicator; OFST = CDU_STATUS.ofst_indicator; - CDU_Status_Update =0; } if ( DO_CLR_SCREEN ) @@ -188,4 +193,7 @@ display.cls(); DO_CLR_SCREEN =0; } -} \ No newline at end of file + + FSdata_received_flag = false; // : reset commomn FS data update flag = all updates ready <-------- !!!! + +} \ No newline at end of file