New work version with additional functions
Dependencies: 4DGL-UC ConfigFile MODSERIAL mbed mbos
Fork of CDU_Mbed_35 by
screen_handler.cpp@10:9a5f1b389973, 2014-07-20 (annotated)
- Committer:
- WillemBraat
- Date:
- Sun Jul 20 17:55:46 2014 +0000
- Revision:
- 10:9a5f1b389973
- Parent:
- 8:422544d24df3
- Child:
- 13:d60c746c097c
Modified:
; -keyboard2.cpp --> backlight control flag
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
LvdK | 7:6576a287e563 | 1 | #include "mbed.h" |
LvdK | 7:6576a287e563 | 2 | #include "TFT_4DGL.h" |
LvdK | 7:6576a287e563 | 3 | #include "display.h" |
LvdK | 7:6576a287e563 | 4 | #include "FS_datastructures.h" |
LvdK | 7:6576a287e563 | 5 | #include "MODSERIAL.h" |
LvdK | 7:6576a287e563 | 6 | |
LvdK | 8:422544d24df3 | 7 | #include <string> |
LvdK | 7:6576a287e563 | 8 | using namespace std; |
LvdK | 8:422544d24df3 | 9 | |
LvdK | 7:6576a287e563 | 10 | extern MODSERIAL SERIAL_DEBUG; // <----- debug only !! |
LvdK | 8:422544d24df3 | 11 | |
LvdK | 8:422544d24df3 | 12 | extern int FSdata_received_flag; |
LvdK | 7:6576a287e563 | 13 | extern TFT_4DGL display; //Prototype of Display Driver (declared in display.cpp) |
LvdK | 7:6576a287e563 | 14 | //Prototype of indicators (declared in keyboard.cpp) |
LvdK | 7:6576a287e563 | 15 | extern DigitalOut EXEC; |
LvdK | 7:6576a287e563 | 16 | extern DigitalOut FAIL; |
LvdK | 7:6576a287e563 | 17 | extern DigitalOut DSPY; |
LvdK | 7:6576a287e563 | 18 | extern DigitalOut MSG; |
LvdK | 7:6576a287e563 | 19 | extern DigitalOut OFST; |
LvdK | 7:6576a287e563 | 20 | extern void CDU_SET_BGL_INTENSITY( int nVal ); //Prototype of function controlling CDU backlight (declared in keyboard.cpp) |
LvdK | 7:6576a287e563 | 21 | extern int nFontSize( int nfont_number ); //Prototype of function for fontselection (declared in display.cpp) |
LvdK | 7:6576a287e563 | 22 | extern int nFontWidth (int nfont_number ); //Prototype of function to retrieve font width (declared in display.cpp) |
LvdK | 7:6576a287e563 | 23 | extern int nLine2Pixel( int nLine ); //Prototype of function to calculate vertical pixelposition from line number (declared in display.cpp) |
LvdK | 7:6576a287e563 | 24 | extern int LeftOrRight( int nTextLine, string cString, int nChars, int nCharWidth ); //declared in display.cpp |
LvdK | 7:6576a287e563 | 25 | extern int cRGB( char cRED, char cGREEN, char cBLUE ); //Prototype of function for assembly color word (declared in display.cpp) |
LvdK | 7:6576a287e563 | 26 | // FS_data_update_ID: |
LvdK | 7:6576a287e563 | 27 | // These global flags indicate what data has been updated. |
LvdK | 7:6576a287e563 | 28 | // Should be tested when FS_DATA_EVENT occurs. |
LvdK | 7:6576a287e563 | 29 | extern int Background_Col_Update; // 1 when color was updated, must be reset to 0 when data has been read |
LvdK | 7:6576a287e563 | 30 | extern int CDU_Status_Update ; // 1 when status was updated, must be reset to 0 when data has been read |
LvdK | 7:6576a287e563 | 31 | extern int DO_CLR_SCREEN ; // 1 when screen should be cleared, must be reset to 0 when done |
LvdK | 8:422544d24df3 | 32 | extern int Text_Line_Update ; // equal to line number whose text was updated, must be reset to 0 when text has been read |
LvdK | 7:6576a287e563 | 33 | extern int Key_Maintext_Update ; // equal to keynumber whose main text line was updated, must be reset to -1 (!)when text has been read |
LvdK | 7:6576a287e563 | 34 | extern int Key_Subtext_Update ; // equal to keynumber whose sub text line was updated, must be reset to -1 (!) when text has been read |
LvdK | 8:422544d24df3 | 35 | |
LvdK | 7:6576a287e563 | 36 | // -------------------------------------------------------------------------------------------------- |
LvdK | 7:6576a287e563 | 37 | void CDU_DSP_CSS() |
LvdK | 7:6576a287e563 | 38 | /*Check flags to see if action is required |
LvdK | 7:6576a287e563 | 39 | Background_Col_Update; // : 1 when color was updated, must be reset to 0 when data has been read |
LvdK | 7:6576a287e563 | 40 | CDU_Status_Update ; // : 1 when status was updated, must be reset to 0 when data has been read |
LvdK | 7:6576a287e563 | 41 | DO_CLR_SCREEN ; // : 1 when screen should be cleared, must be reset to 0 when done |
LvdK | 7:6576a287e563 | 42 | Text_Line_Update ; // : equal to line number whose text was updated, must be reset to 0 when text has been read |
LvdK | 7:6576a287e563 | 43 | Key_Maintext_Update ; // : equal to keynumber whose main text line was updated, must be reset to -1 (!)when text has been read |
LvdK | 7:6576a287e563 | 44 | Key_Subtext_Update ; // : equal to keynumber whose sub text line was updated, must be reset to -1 (!) when text has been read |
LvdK | 7:6576a287e563 | 45 | */ |
LvdK | 8:422544d24df3 | 46 | |
LvdK | 7:6576a287e563 | 47 | { |
LvdK | 8:422544d24df3 | 48 | int nLine = 1; //default line number |
LvdK | 8:422544d24df3 | 49 | int nCharsLine = 24; //characters per line |
LvdK | 7:6576a287e563 | 50 | //check common flag |
LvdK | 8:422544d24df3 | 51 | |
LvdK | 7:6576a287e563 | 52 | if ( Background_Col_Update == 1) |
LvdK | 7:6576a287e563 | 53 | { |
LvdK | 7:6576a287e563 | 54 | display.background_color( cRGB( BACKGROUND_COL.BG_RED, BACKGROUND_COL.BG_GREEN, BACKGROUND_COL.BG_BLUE ) ); |
LvdK | 7:6576a287e563 | 55 | Background_Col_Update = 0; |
LvdK | 7:6576a287e563 | 56 | } |
LvdK | 8:422544d24df3 | 57 | |
LvdK | 7:6576a287e563 | 58 | if ( Key_Maintext_Update > -1 ) |
LvdK | 7:6576a287e563 | 59 | //Key_Maintext_Update contains the line number 00-49 is LSK text, 50-99 is RSK text |
LvdK | 7:6576a287e563 | 60 | //Currently used: |
LvdK | 7:6576a287e563 | 61 | //00-14 left side of screen --> left adjust, horizontal position = 0 |
LvdK | 7:6576a287e563 | 62 | //50-64 right side of screen --> right adjust, horizontal position calculated with righttext() (declared in display.cpp) |
LvdK | 8:422544d24df3 | 63 | |
LvdK | 7:6576a287e563 | 64 | //00 = LSK1 50 = RSK1 Print on LINE 3 |
LvdK | 7:6576a287e563 | 65 | //01 = LSK2 51 = RSK2 Print on LINE 5 |
LvdK | 7:6576a287e563 | 66 | //02 = LSK3 52 = RSK3 Print on LINE 7 |
LvdK | 7:6576a287e563 | 67 | //03 = LSK4 53 = RSK4 Print on LINE 9 |
LvdK | 7:6576a287e563 | 68 | //04 = LSK5 54 = RSK5 Print on LINE 11 |
LvdK | 7:6576a287e563 | 69 | //05 = LSK6 55 = RSK6 Print on LINE 13 |
LvdK | 7:6576a287e563 | 70 | { |
LvdK | 7:6576a287e563 | 71 | switch ( Key_Maintext_Update ) |
LvdK | 7:6576a287e563 | 72 | { |
LvdK | 7:6576a287e563 | 73 | case ( 00 ): nLine = 3; break; |
LvdK | 7:6576a287e563 | 74 | case ( 50 ): nLine = 3; break; |
LvdK | 7:6576a287e563 | 75 | case ( 01 ): nLine = 5; break; |
LvdK | 7:6576a287e563 | 76 | case ( 51 ): nLine = 5; break; |
LvdK | 7:6576a287e563 | 77 | case ( 02 ): nLine = 7; break; |
LvdK | 7:6576a287e563 | 78 | case ( 52 ): nLine = 7; break; |
LvdK | 7:6576a287e563 | 79 | case ( 03 ): nLine = 9; break; |
LvdK | 7:6576a287e563 | 80 | case ( 53 ): nLine = 9; break; |
LvdK | 7:6576a287e563 | 81 | case ( 04 ): nLine = 11; break; |
LvdK | 7:6576a287e563 | 82 | case ( 54 ): nLine = 11; break; |
LvdK | 7:6576a287e563 | 83 | case ( 05 ): nLine = 13; break; |
LvdK | 7:6576a287e563 | 84 | case ( 55 ): nLine = 13; break; |
LvdK | 7:6576a287e563 | 85 | } |
LvdK | 8:422544d24df3 | 86 | |
LvdK | 8:422544d24df3 | 87 | switch ( SELKEY_MAINTEXT[Key_Maintext_Update].font_size ) |
LvdK | 8:422544d24df3 | 88 | { |
LvdK | 8:422544d24df3 | 89 | case ( 0 ): nCharsLine = 48; break; |
LvdK | 8:422544d24df3 | 90 | case ( 1 ): nCharsLine = 24; break; |
LvdK | 8:422544d24df3 | 91 | } |
LvdK | 8:422544d24df3 | 92 | |
LvdK | 8:422544d24df3 | 93 | //SERIAL_DEBUG.printf("Key MAINTEXT is : %s\r\n",SELKEY_MAINTEXT[Key_Maintext_Update].text ); // DEBUG, show text |
LvdK | 7:6576a287e563 | 94 | |
LvdK | 7:6576a287e563 | 95 | //display.graphic_string(char *s, int x, int y, char font, int color, char width multiplier, char height multiplier) |
LvdK | 8:422544d24df3 | 96 | |
LvdK | 8:422544d24df3 | 97 | display.graphic_string( SELKEY_MAINTEXT[Key_Maintext_Update].text , //Text to display |
LvdK | 8:422544d24df3 | 98 | LeftOrRight( Key_Maintext_Update, SELKEY_MAINTEXT[Key_Maintext_Update].text, nCharsLine, nFontWidth( SELKEY_MAINTEXT[Key_Maintext_Update].font_size )) , //Horizontal position |
LvdK | 8:422544d24df3 | 99 | nLine2Pixel( nLine ), //Vertical position |
LvdK | 8:422544d24df3 | 100 | SELKEY_MAINTEXT[Key_Maintext_Update].font_size, //Font |
LvdK | 8:422544d24df3 | 101 | cRGB( SELKEY_MAINTEXT[Key_Maintext_Update].text_RED ,SELKEY_MAINTEXT[Key_Maintext_Update].text_GREEN ,SELKEY_MAINTEXT[Key_Maintext_Update].text_BLUE ), |
LvdK | 8:422544d24df3 | 102 | 1, 1 ); |
LvdK | 8:422544d24df3 | 103 | |
LvdK | 7:6576a287e563 | 104 | /* |
LvdK | 7:6576a287e563 | 105 | display.graphic_string( SELKEY_MAINTEXT[Key_Maintext_Update].text , //Text to display |
LvdK | 8:422544d24df3 | 106 | 12*24 , //Horizontal position |
LvdK | 7:6576a287e563 | 107 | nLine2Pixel( nLine ), //Vertical position |
LvdK | 8:422544d24df3 | 108 | SELKEY_MAINTEXT[Key_Maintext_Update].font_size, //Font |
LvdK | 7:6576a287e563 | 109 | cRGB( SELKEY_MAINTEXT[Key_Maintext_Update].text_RED ,SELKEY_MAINTEXT[Key_Maintext_Update].text_GREEN ,SELKEY_MAINTEXT[Key_Maintext_Update].text_BLUE ), |
LvdK | 7:6576a287e563 | 110 | 1, 1 ); |
LvdK | 7:6576a287e563 | 111 | */ |
LvdK | 8:422544d24df3 | 112 | |
LvdK | 7:6576a287e563 | 113 | Key_Maintext_Update = -1; |
LvdK | 7:6576a287e563 | 114 | } |
LvdK | 8:422544d24df3 | 115 | |
LvdK | 7:6576a287e563 | 116 | if ( Key_Subtext_Update > -1 ) |
LvdK | 7:6576a287e563 | 117 | //Key Subtext_Update contains the line number 00-49 is LSK subtext, 50-99 is RSK subtext |
LvdK | 7:6576a287e563 | 118 | //Currently used: |
LvdK | 7:6576a287e563 | 119 | //00-14 left side of screen --> left adjust, horizontal position = 0 |
LvdK | 8:422544d24df3 | 120 | //50-64 right side of screen --> right adjust, horizontal position calculated with righttext() (declared in display.cpp) |
LvdK | 7:6576a287e563 | 121 | //00 = LSK1 50 = RSK1 Print on LINE 2 |
LvdK | 7:6576a287e563 | 122 | //01 = LSK2 51 = RSK2 Print on LINE 4 |
LvdK | 7:6576a287e563 | 123 | //02 = LSK3 52 = RSK3 Print on LINE 6 |
LvdK | 7:6576a287e563 | 124 | //03 = LSK4 53 = RSK4 Print on LINE 8 |
LvdK | 7:6576a287e563 | 125 | //04 = LSK5 54 = RSK5 Print on LINE 10 |
LvdK | 7:6576a287e563 | 126 | //05 = LSK6 55 = RSK6 Print on LINE 12 |
LvdK | 7:6576a287e563 | 127 | { |
LvdK | 7:6576a287e563 | 128 | switch ( Key_Subtext_Update ) |
LvdK | 7:6576a287e563 | 129 | { |
LvdK | 7:6576a287e563 | 130 | case ( 00 ): nLine = 2; break; |
LvdK | 7:6576a287e563 | 131 | case ( 50 ): nLine = 2; break; |
LvdK | 7:6576a287e563 | 132 | case ( 01 ): nLine = 4; break; |
LvdK | 7:6576a287e563 | 133 | case ( 51 ): nLine = 4; break; |
LvdK | 7:6576a287e563 | 134 | case ( 02 ): nLine = 6; break; |
LvdK | 7:6576a287e563 | 135 | case ( 52 ): nLine = 6; break; |
LvdK | 7:6576a287e563 | 136 | case ( 03 ): nLine = 8; break; |
LvdK | 7:6576a287e563 | 137 | case ( 53 ): nLine = 8; break; |
LvdK | 7:6576a287e563 | 138 | case ( 04 ): nLine = 10; break; |
LvdK | 7:6576a287e563 | 139 | case ( 54 ): nLine = 10; break; |
LvdK | 7:6576a287e563 | 140 | case ( 05 ): nLine = 12; break; |
LvdK | 7:6576a287e563 | 141 | case ( 55 ): nLine = 12; break; |
LvdK | 7:6576a287e563 | 142 | } |
LvdK | 8:422544d24df3 | 143 | |
LvdK | 8:422544d24df3 | 144 | switch ( SELKEY_SUBTEXT[Key_Subtext_Update].font_size ) |
LvdK | 8:422544d24df3 | 145 | { |
LvdK | 8:422544d24df3 | 146 | case ( 0 ): nCharsLine = 48; break; |
LvdK | 8:422544d24df3 | 147 | case ( 1 ): nCharsLine = 24; break; |
LvdK | 8:422544d24df3 | 148 | } |
LvdK | 8:422544d24df3 | 149 | //display.graphic_string(char *s, int x, int y, char font, int color, char width multiplier, char height multiplier) |
LvdK | 7:6576a287e563 | 150 | display.graphic_string( SELKEY_SUBTEXT[Key_Subtext_Update].text , //Text to display |
LvdK | 8:422544d24df3 | 151 | LeftOrRight( Key_Subtext_Update, SELKEY_SUBTEXT[Key_Subtext_Update].text, nCharsLine, nFontWidth( SELKEY_SUBTEXT[Key_Subtext_Update].font_size )) , //Horizontal position |
LvdK | 7:6576a287e563 | 152 | nLine2Pixel( nLine ), //Vertical position |
LvdK | 8:422544d24df3 | 153 | SELKEY_SUBTEXT[Key_Subtext_Update].font_size, //Font |
LvdK | 7:6576a287e563 | 154 | cRGB( SELKEY_SUBTEXT[Key_Subtext_Update].text_RED ,SELKEY_SUBTEXT[Key_Subtext_Update].text_GREEN ,SELKEY_SUBTEXT[Key_Subtext_Update].text_BLUE ), |
LvdK | 7:6576a287e563 | 155 | 1, 1 ); //multiplier always on 1 |
LvdK | 7:6576a287e563 | 156 | Key_Subtext_Update = -1; |
LvdK | 7:6576a287e563 | 157 | } |
LvdK | 8:422544d24df3 | 158 | |
LvdK | 7:6576a287e563 | 159 | if ( Text_Line_Update > 0) |
LvdK | 7:6576a287e563 | 160 | { |
LvdK | 7:6576a287e563 | 161 | //Text_Line_Update contains the the line number to write |
LvdK | 7:6576a287e563 | 162 | display.graphic_string( TEXTLINE[Text_Line_Update].text , //Text to display |
LvdK | 7:6576a287e563 | 163 | 0, //Horizontal position always 0 |
LvdK | 7:6576a287e563 | 164 | nLine2Pixel( Text_Line_Update ), //Vertical position |
LvdK | 8:422544d24df3 | 165 | TEXTLINE[Text_Line_Update].font_size, //Font |
LvdK | 7:6576a287e563 | 166 | cRGB( TEXTLINE[Text_Line_Update].text_RED ,TEXTLINE[Text_Line_Update].text_GREEN ,TEXTLINE[Text_Line_Update].text_BLUE ), |
LvdK | 7:6576a287e563 | 167 | 1, 1 ); //multiplier always on 1 |
LvdK | 7:6576a287e563 | 168 | Text_Line_Update = 0; |
LvdK | 7:6576a287e563 | 169 | } |
LvdK | 8:422544d24df3 | 170 | |
LvdK | 7:6576a287e563 | 171 | if ( CDU_Status_Update == 1 ) |
LvdK | 7:6576a287e563 | 172 | { |
LvdK | 8:422544d24df3 | 173 | /* |
LvdK | 7:6576a287e563 | 174 | CDU_STATUS.stby_mode; // : 0 = operational mode, 1 = standby mode |
WillemBraat | 10:9a5f1b389973 | 175 | */ |
WillemBraat | 10:9a5f1b389973 | 176 | |
WillemBraat | 10:9a5f1b389973 | 177 | if ( CDU_STATUS.backlight ) // Backlight control |
LvdK | 7:6576a287e563 | 178 | { |
WillemBraat | 10:9a5f1b389973 | 179 | CDU_SET_BGL_INTENSITY( 100 ); |
LvdK | 7:6576a287e563 | 180 | } |
LvdK | 7:6576a287e563 | 181 | else |
LvdK | 7:6576a287e563 | 182 | { |
LvdK | 8:422544d24df3 | 183 | CDU_SET_BGL_INTENSITY( 0 ); |
LvdK | 7:6576a287e563 | 184 | } |
LvdK | 7:6576a287e563 | 185 | // Set CDU indicators |
LvdK | 7:6576a287e563 | 186 | MSG = CDU_STATUS.msg_indicator; |
LvdK | 7:6576a287e563 | 187 | EXEC = CDU_STATUS.exec_indicator; |
LvdK | 7:6576a287e563 | 188 | FAIL = CDU_STATUS.fail_indicator; |
LvdK | 7:6576a287e563 | 189 | DSPY = CDU_STATUS.dspy_indicator; |
LvdK | 7:6576a287e563 | 190 | OFST = CDU_STATUS.ofst_indicator; |
LvdK | 7:6576a287e563 | 191 | CDU_Status_Update =0; |
LvdK | 7:6576a287e563 | 192 | } |
WillemBraat | 10:9a5f1b389973 | 193 | |
LvdK | 7:6576a287e563 | 194 | if ( DO_CLR_SCREEN ) |
LvdK | 7:6576a287e563 | 195 | { |
LvdK | 7:6576a287e563 | 196 | display.cls(); |
LvdK | 7:6576a287e563 | 197 | DO_CLR_SCREEN =0; |
LvdK | 7:6576a287e563 | 198 | } |
LvdK | 8:422544d24df3 | 199 | |
LvdK | 8:422544d24df3 | 200 | FSdata_received_flag = false; // : reset commomn FS data update flag = all updates ready <-------- !!!! |
LvdK | 8:422544d24df3 | 201 | |
LvdK | 8:422544d24df3 | 202 | } |