New work version with additional functions

Dependencies:   4DGL-UC ConfigFile MODSERIAL mbed mbos

Fork of CDU_Mbed_35 by Engravity-CDU

Committer:
LvdK
Date:
Thu Jul 17 10:09:14 2014 +0000
Revision:
7:6576a287e563
Child:
8:422544d24df3
CDU V21

Who changed what in which revision?

UserRevisionLine numberNew 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 7:6576a287e563 7
LvdK 7:6576a287e563 8 #include <string>
LvdK 7:6576a287e563 9 using namespace std;
LvdK 7:6576a287e563 10
LvdK 7:6576a287e563 11 extern MODSERIAL SERIAL_DEBUG; // <----- debug only !!
LvdK 7:6576a287e563 12
LvdK 7:6576a287e563 13 extern int FSdata_received_flag; //Prototype of data flag (declared in main.cpp)
LvdK 7:6576a287e563 14 extern TFT_4DGL display; //Prototype of Display Driver (declared in display.cpp)
LvdK 7:6576a287e563 15
LvdK 7:6576a287e563 16 //Prototype of indicators (declared in keyboard.cpp)
LvdK 7:6576a287e563 17 extern DigitalOut EXEC;
LvdK 7:6576a287e563 18 extern DigitalOut FAIL;
LvdK 7:6576a287e563 19 extern DigitalOut DSPY;
LvdK 7:6576a287e563 20 extern DigitalOut MSG;
LvdK 7:6576a287e563 21 extern DigitalOut OFST;
LvdK 7:6576a287e563 22
LvdK 7:6576a287e563 23 extern void CDU_SET_BGL_INTENSITY( int nVal ); //Prototype of function controlling CDU backlight (declared in keyboard.cpp)
LvdK 7:6576a287e563 24 extern int nFontSize( int nfont_number ); //Prototype of function for fontselection (declared in display.cpp)
LvdK 7:6576a287e563 25 extern int nFontWidth (int nfont_number ); //Prototype of function to retrieve font width (declared in display.cpp)
LvdK 7:6576a287e563 26 extern int nLine2Pixel( int nLine ); //Prototype of function to calculate vertical pixelposition from line number (declared in display.cpp)
LvdK 7:6576a287e563 27 extern int LeftOrRight( int nTextLine, string cString, int nChars, int nCharWidth ); //declared in display.cpp
LvdK 7:6576a287e563 28 extern int cRGB( char cRED, char cGREEN, char cBLUE ); //Prototype of function for assembly color word (declared in display.cpp)
LvdK 7:6576a287e563 29
LvdK 7:6576a287e563 30 // FS_data_update_ID:
LvdK 7:6576a287e563 31 // These global flags indicate what data has been updated.
LvdK 7:6576a287e563 32 // Should be tested when FS_DATA_EVENT occurs.
LvdK 7:6576a287e563 33 extern int Background_Col_Update; // 1 when color was updated, must be reset to 0 when data has been read
LvdK 7:6576a287e563 34 extern int CDU_Status_Update ; // 1 when status was updated, must be reset to 0 when data has been read
LvdK 7:6576a287e563 35 extern int DO_CLR_SCREEN ; // 1 when screen should be cleared, must be reset to 0 when done
LvdK 7:6576a287e563 36 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 37 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 38 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 7:6576a287e563 39
LvdK 7:6576a287e563 40 // Common flag to signal that one or more updates were performed:
LvdK 7:6576a287e563 41 //int FSdata_received_flag = false; // : true when one or more FS-to-CDU data structures were updated
LvdK 7:6576a287e563 42
LvdK 7:6576a287e563 43 // --------------------------------------------------------------------------------------------------
LvdK 7:6576a287e563 44
LvdK 7:6576a287e563 45 void CDU_DSP_CSS()
LvdK 7:6576a287e563 46 /*Check flags to see if action is required
LvdK 7:6576a287e563 47 Background_Col_Update; // : 1 when color was updated, must be reset to 0 when data has been read
LvdK 7:6576a287e563 48 CDU_Status_Update ; // : 1 when status was updated, must be reset to 0 when data has been read
LvdK 7:6576a287e563 49 DO_CLR_SCREEN ; // : 1 when screen should be cleared, must be reset to 0 when done
LvdK 7:6576a287e563 50 Text_Line_Update ; // : equal to line number whose text was updated, must be reset to 0 when text has been read
LvdK 7:6576a287e563 51 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 52 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 53 */
LvdK 7:6576a287e563 54
LvdK 7:6576a287e563 55 {
LvdK 7:6576a287e563 56 int nLine = 1; //default value
LvdK 7:6576a287e563 57 //check common flag
LvdK 7:6576a287e563 58
LvdK 7:6576a287e563 59 if ( Background_Col_Update == 1)
LvdK 7:6576a287e563 60 {
LvdK 7:6576a287e563 61 display.background_color( cRGB( BACKGROUND_COL.BG_RED, BACKGROUND_COL.BG_GREEN, BACKGROUND_COL.BG_BLUE ) );
LvdK 7:6576a287e563 62 Background_Col_Update = 0;
LvdK 7:6576a287e563 63 }
LvdK 7:6576a287e563 64
LvdK 7:6576a287e563 65 if ( Key_Maintext_Update > -1 )
LvdK 7:6576a287e563 66 //Key_Maintext_Update contains the line number 00-49 is LSK text, 50-99 is RSK text
LvdK 7:6576a287e563 67 //Currently used:
LvdK 7:6576a287e563 68 //00-14 left side of screen --> left adjust, horizontal position = 0
LvdK 7:6576a287e563 69 //50-64 right side of screen --> right adjust, horizontal position calculated with righttext() (declared in display.cpp)
LvdK 7:6576a287e563 70
LvdK 7:6576a287e563 71 //00 = LSK1 50 = RSK1 Print on LINE 3
LvdK 7:6576a287e563 72 //01 = LSK2 51 = RSK2 Print on LINE 5
LvdK 7:6576a287e563 73 //02 = LSK3 52 = RSK3 Print on LINE 7
LvdK 7:6576a287e563 74 //03 = LSK4 53 = RSK4 Print on LINE 9
LvdK 7:6576a287e563 75 //04 = LSK5 54 = RSK5 Print on LINE 11
LvdK 7:6576a287e563 76 //05 = LSK6 55 = RSK6 Print on LINE 13
LvdK 7:6576a287e563 77 {
LvdK 7:6576a287e563 78 switch ( Key_Maintext_Update )
LvdK 7:6576a287e563 79 {
LvdK 7:6576a287e563 80 case ( 00 ): nLine = 3; break;
LvdK 7:6576a287e563 81 case ( 50 ): nLine = 3; break;
LvdK 7:6576a287e563 82 case ( 01 ): nLine = 5; break;
LvdK 7:6576a287e563 83 case ( 51 ): nLine = 5; break;
LvdK 7:6576a287e563 84 case ( 02 ): nLine = 7; break;
LvdK 7:6576a287e563 85 case ( 52 ): nLine = 7; break;
LvdK 7:6576a287e563 86 case ( 03 ): nLine = 9; break;
LvdK 7:6576a287e563 87 case ( 53 ): nLine = 9; break;
LvdK 7:6576a287e563 88 case ( 04 ): nLine = 11; break;
LvdK 7:6576a287e563 89 case ( 54 ): nLine = 11; break;
LvdK 7:6576a287e563 90 case ( 05 ): nLine = 13; break;
LvdK 7:6576a287e563 91 case ( 55 ): nLine = 13; break;
LvdK 7:6576a287e563 92 }
LvdK 7:6576a287e563 93
LvdK 7:6576a287e563 94 SERIAL_DEBUG.printf("Key MAINTEXT is : %s\r\n",SELKEY_MAINTEXT[Key_Maintext_Update].text ); // show text
LvdK 7:6576a287e563 95
LvdK 7:6576a287e563 96 //display.graphic_string(char *s, int x, int y, char font, int color, char width multiplier, char height multiplier)
LvdK 7:6576a287e563 97 /*
LvdK 7:6576a287e563 98 display.graphic_string( SELKEY_MAINTEXT[Key_Maintext_Update].text , //Text to display
LvdK 7:6576a287e563 99 LeftOrRight( Key_Maintext_Update, SELKEY_MAINTEXT[Key_Maintext_Update].text,24,24*nFontWidth( SELKEY_MAINTEXT[Key_Maintext_Update].font_size )) , //Horizontal position
LvdK 7:6576a287e563 100 nLine2Pixel( nLine ), //Vertical position
LvdK 7:6576a287e563 101 nFontSize( SELKEY_MAINTEXT[Key_Maintext_Update].font_size ), //Font
LvdK 7:6576a287e563 102 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 103 1, 1 );
LvdK 7:6576a287e563 104 */
LvdK 7:6576a287e563 105 display.graphic_string( SELKEY_MAINTEXT[Key_Maintext_Update].text , //Text to display
LvdK 7:6576a287e563 106 12*24 , //Horizontal position
LvdK 7:6576a287e563 107 nLine2Pixel( nLine ), //Vertical position
LvdK 7:6576a287e563 108 nFontSize( 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 7:6576a287e563 112
LvdK 7:6576a287e563 113 Key_Maintext_Update = -1;
LvdK 7:6576a287e563 114 }
LvdK 7:6576a287e563 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 7:6576a287e563 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 7:6576a287e563 143 //display.graphic_string(char *s, int x, int y, char font, int color, char width multiplier, char height multiplier)
LvdK 7:6576a287e563 144 display.graphic_string( SELKEY_SUBTEXT[Key_Subtext_Update].text , //Text to display
LvdK 7:6576a287e563 145 LeftOrRight( Key_Subtext_Update, SELKEY_SUBTEXT[Key_Subtext_Update].text,12,48*nFontWidth( SELKEY_SUBTEXT[Key_Subtext_Update].font_size )) , //Horizontal position
LvdK 7:6576a287e563 146 nLine2Pixel( nLine ), //Vertical position
LvdK 7:6576a287e563 147 nFontSize( SELKEY_SUBTEXT[Key_Subtext_Update].font_size ), //Font
LvdK 7:6576a287e563 148 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 149 1, 1 ); //multiplier always on 1
LvdK 7:6576a287e563 150 Key_Subtext_Update = -1;
LvdK 7:6576a287e563 151 }
LvdK 7:6576a287e563 152
LvdK 7:6576a287e563 153 if ( Text_Line_Update > 0)
LvdK 7:6576a287e563 154 {
LvdK 7:6576a287e563 155 //Text_Line_Update contains the the line number to write
LvdK 7:6576a287e563 156 display.graphic_string( TEXTLINE[Text_Line_Update].text , //Text to display
LvdK 7:6576a287e563 157 0, //Horizontal position always 0
LvdK 7:6576a287e563 158 nLine2Pixel( Text_Line_Update ), //Vertical position
LvdK 7:6576a287e563 159 nFontSize( TEXTLINE[Text_Line_Update].font_size ), //Font
LvdK 7:6576a287e563 160 cRGB( TEXTLINE[Text_Line_Update].text_RED ,TEXTLINE[Text_Line_Update].text_GREEN ,TEXTLINE[Text_Line_Update].text_BLUE ),
LvdK 7:6576a287e563 161 1, 1 ); //multiplier always on 1
LvdK 7:6576a287e563 162 Text_Line_Update = 0;
LvdK 7:6576a287e563 163 }
LvdK 7:6576a287e563 164
LvdK 7:6576a287e563 165 if ( CDU_Status_Update == 1 )
LvdK 7:6576a287e563 166 {
LvdK 7:6576a287e563 167 /*
LvdK 7:6576a287e563 168 CDU_STATUS.stby_mode; // : 0 = operational mode, 1 = standby mode
LvdK 7:6576a287e563 169 */ if ( CDU_STATUS.backlight ) // Backlight control
LvdK 7:6576a287e563 170 {
LvdK 7:6576a287e563 171 CDU_SET_BGL_INTENSITY( 255 );
LvdK 7:6576a287e563 172 }
LvdK 7:6576a287e563 173 else
LvdK 7:6576a287e563 174 {
LvdK 7:6576a287e563 175 CDU_SET_BGL_INTENSITY( 0 );
LvdK 7:6576a287e563 176 }
LvdK 7:6576a287e563 177 // Set CDU indicators
LvdK 7:6576a287e563 178 MSG = CDU_STATUS.msg_indicator;
LvdK 7:6576a287e563 179 EXEC = CDU_STATUS.exec_indicator;
LvdK 7:6576a287e563 180 FAIL = CDU_STATUS.fail_indicator;
LvdK 7:6576a287e563 181 DSPY = CDU_STATUS.dspy_indicator;
LvdK 7:6576a287e563 182 OFST = CDU_STATUS.ofst_indicator;
LvdK 7:6576a287e563 183
LvdK 7:6576a287e563 184 CDU_Status_Update =0;
LvdK 7:6576a287e563 185 }
LvdK 7:6576a287e563 186 if ( DO_CLR_SCREEN )
LvdK 7:6576a287e563 187 {
LvdK 7:6576a287e563 188 display.cls();
LvdK 7:6576a287e563 189 DO_CLR_SCREEN =0;
LvdK 7:6576a287e563 190 }
LvdK 7:6576a287e563 191 }