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