C++ file for display control

Dependencies:   4DGL mbed ConfigFile

Fork of 4DGLtest by Stephane ROCHON

Files at this revision

API Documentation at this revision

Comitter:
WillemBraat
Date:
Wed Jul 16 19:15:40 2014 +0000
Parent:
10:5706b75d40fa
Commit message:
Rewritten function CDU_DSP_CSS()

Changed in this revision

display.cpp Show annotated file Show diff for this revision Revisions of this file
fs_datastructures.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 5706b75d40fa -r a5b0d98794c0 display.cpp
--- a/display.cpp	Wed Jul 16 08:05:54 2014 +0000
+++ b/display.cpp	Wed Jul 16 19:15:40 2014 +0000
@@ -103,8 +103,8 @@
 */
 
 
-DigitalOut VGA_SOURCE( p7 ); // control line for video switch between internal and external video
-DigitalOut VGA_SELECT( p8 ); // select or deselect video switch
+//DigitalOut VGA_SOURCE( p7 ); // control line for video switch between internal and external video
+//DigitalOut VGA_SELECT( p8 ); // select or deselect video switch
 
 //Control lines for VGA driver board
 TFT_4DGL display(p13,p14,p15); // serial tx, serial rx, reset pin
@@ -117,7 +117,7 @@
     std::string cInput( cString );
     char* cText = new char[nStrLen+1];
     strncpy(cText, cInput.c_str(), nStrLen);
-    cText[nStrLen+1] = '\0';
+    cText[nStrLen] = '\0';
     return cText;
     }
     
@@ -177,11 +177,11 @@
     return ( nFont );
 }    
 
-int cRGB( int cRED, int cGREEN, int cBLUE )
+unsigned int cRGB( char cRED, char cGREEN, char cBLUE )
 {
     //assemble separate colors into 1 integer value as 0xRRGGBB
     //Display driver requires this format
-    int RGB = cBLUE + 8*cGREEN + 64*cRED;
+    unsigned int RGB = cBLUE + 256*cGREEN + 65536*cRED;
     return ( RGB );
 }    
 
@@ -190,6 +190,14 @@
     //decide to print data left aligned or right aligned
     //00 - 49 is left  side of screen
     //50 - 99 is right side of screen
+    
+    //00 = LSK1         50 = RSK1
+    //01 = LSK2         51 = RSK2
+    //02 = LSK3         52 = RSK3
+    //03 = LSK4         53 = RSK4
+    //05 = LSK5         54 = RSK5
+    //06 = LSK6         56 = RSK6
+
     int nHorPos = 0; 
     // nChars is number of characters on this line (24 or 48)
     // nCharWidth is the character width in pixels
diff -r 5706b75d40fa -r a5b0d98794c0 fs_datastructures.cpp
--- a/fs_datastructures.cpp	Wed Jul 16 08:05:54 2014 +0000
+++ b/fs_datastructures.cpp	Wed Jul 16 19:15:40 2014 +0000
@@ -35,7 +35,7 @@
 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( int cRED, int cGREEN, int cBLUE ); //Prototype of function for assembly color word (declared in display.cpp)
+extern unsigned 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.
@@ -61,8 +61,9 @@
 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
     //check common flag
     if ( FSdata_received_flag )
     //if set, check all structures and lock dynamic storage
@@ -72,36 +73,82 @@
             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
+            //03 = LSK4         53 = RSK4   Print on LINE 9
+            //04 = LSK5         54 = RSK5   Print on LINE 11
+            //05 = LSK6         55 = RSK6   Print on LINE 13
         {
+            switch ( Key_Maintext_Update )
+            {
+                case ( 00 ): nLine = 3; break;
+                case ( 50 ): nLine = 3; break;
+                case ( 01 ): nLine = 5; break;
+                case ( 51 ): nLine = 5; break;
+                case ( 02 ): nLine = 7; break;
+                case ( 52 ): nLine = 7; break;
+                case ( 03 ): nLine = 9; break;
+                case ( 53 ): nLine = 9; break;
+                case ( 04 ): nLine = 11; break;
+                case ( 54 ): nLine = 11; break;
+                case ( 05 ): nLine = 13; break;
+                case ( 55 ): nLine = 13; break;
+            }
             //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,24,24 )*nFontWidth( SELKEY_MAINTEXT[Key_Maintext_Update].font_size ) ,    //Horizontal position
-                                    nLine2Pixel( Key_Maintext_Update ),                                 //Vertical 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)            
+            //00 = LSK1         50 = RSK1   Print on LINE 2
+            //01 = LSK2         51 = RSK2   Print on LINE 4
+            //02 = LSK3         52 = RSK3   Print on LINE 6
+            //03 = LSK4         53 = RSK4   Print on LINE 8
+            //04 = LSK5         54 = RSK5   Print on LINE 10
+            //05 = LSK6         55 = RSK6   Print on LINE 12
         {
+            switch ( Key_Maintext_Update )
+            {
+                case ( 00 ): nLine = 2; break;
+                case ( 50 ): nLine = 2; break;
+                case ( 01 ): nLine = 4; break;
+                case ( 51 ): nLine = 4; break;
+                case ( 02 ): nLine = 6; break;
+                case ( 52 ): nLine = 6; break;
+                case ( 03 ): nLine = 8; break;
+                case ( 53 ): nLine = 8; break;
+                case ( 04 ): nLine = 10; break;
+                case ( 54 ): nLine = 10; break;
+                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)            
             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
-                                    nLine2Pixel( Key_Subtext_Update ),                              //Vertical position
+                                    nLine2Pixel( nLine ),                              //Vertical position
                                     nFontSize( 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
@@ -113,6 +160,7 @@
                                     1, 1 ); //multiplier always on 1
             Text_Line_Update = 0;
         }
+        
         if ( CDU_Status_Update == 1 )
         {
  /*