Modifications in 4DGL library. Added CDU_hw_sw.h for version info. Added pins.h for hardware pin remapping

Dependencies:   4DGL-UC MODSERIAL mbed mbos

Fork of CDU_Mbed_30 by Engravity-CDU

Files at this revision

API Documentation at this revision

Comitter:
WillemBraat
Date:
Thu Sep 25 11:34:21 2014 +0000
Parent:
19:9d8032cb0f12
Child:
21:f348e6f0f7d4
Commit message:
Definitive version.
; New developments started in version _36

Changed in this revision

CDU_hw_sw.cpp Show annotated file Show diff for this revision Revisions of this file
CDU_hw_sw.h Show annotated file Show diff for this revision Revisions of this file
display.cpp Show annotated file Show diff for this revision Revisions of this file
display.h Show annotated file Show diff for this revision Revisions of this file
keyboard.h Show annotated file Show diff for this revision Revisions of this file
keyboard2.cpp Show annotated file Show diff for this revision Revisions of this file
keys.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
pins.h Show annotated file Show diff for this revision Revisions of this file
--- a/CDU_hw_sw.cpp	Thu Aug 28 14:39:32 2014 +0000
+++ b/CDU_hw_sw.cpp	Thu Sep 25 11:34:21 2014 +0000
@@ -8,10 +8,10 @@
 {
     string cHardware = "HW version: ";
     char   buf[1];
-    sprintf(buf, "%d", HW_VERSION_MAIN );
+    sprintf(buf, "%d", HW_VERSION_MAJOR );
     cHardware += buf;
     cHardware += ".";
-    sprintf(buf, "%d", HW_VERSION_SUB );
+    sprintf(buf, "%d", HW_VERSION_MINOR );
     cHardware += buf;
  return cHardware;
  }
@@ -20,10 +20,10 @@
 {
     string cFirmware = "FW version: ";
     char   buf[1];
-    sprintf(buf, "%d", SW_VERSION_MAIN );
+    sprintf(buf, "%d", SW_VERSION_MAJOR );
     cFirmware += buf;
     cFirmware += ".";
-    sprintf(buf, "%d", SW_VERSION_SUB );
+    sprintf(buf, "%d", SW_VERSION_MINOR );
     cFirmware += buf;
 return cFirmware;
 }
@@ -63,4 +63,4 @@
     string cIP = "IP address: ";
     cIP += "000:000:000:000 (not defined)";
     return cIP;
-}
\ No newline at end of file
+}
--- a/CDU_hw_sw.h	Thu Aug 28 14:39:32 2014 +0000
+++ b/CDU_hw_sw.h	Thu Sep 25 11:34:21 2014 +0000
@@ -1,7 +1,10 @@
 //**********Hardware platform definition**********
-#define HW_VERSION_MAIN 1
-#define HW_VERSION_SUB  0
+#define HW_VERSION_MAJOR 1
+#define HW_VERSION_MINOR 0
 
 //**********Software Version**********
-#define SW_VERSION_MAIN 0
-#define SW_VERSION_SUB  35
\ No newline at end of file
+#define SW_VERSION_MAJOR 0
+#define SW_VERSION_MINOR 35
+
+//**********Checksum control on incoming commands**********
+#define CHECKSUM 0  //0=disable 1= enable
--- a/display.cpp	Thu Aug 28 14:39:32 2014 +0000
+++ b/display.cpp	Thu Sep 25 11:34:21 2014 +0000
@@ -15,6 +15,7 @@
 
 DigitalOut VGA_SOURCE( VGA_SOURCE_SELECT ); //control line for video switch between INT and EXT video
 DigitalOut VGA_SELECT( VGA_ON_OFF ); //control line to select/deselect video switch
+
 /*
 =====================================================
 SGC (Serial Graphics Controller) PLATFORM OUTPUT FILE
@@ -37,6 +38,7 @@
 0x40, 0x49, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00
 4DSL command:
 NewUSDImage(0, 135, 0x000000)
+
 ---------------------------------------------------------------------------------------
 File "Testscreen.png" (Testscreen.png)
 Sector Address 0x00021A
@@ -49,52 +51,8 @@
 4DSL command:
 NewUSDImage(0, 0, 0x00021A)
 */
-/*Display Commands
-$PCDUCLS Erase to active background colour (default black) or white
-===================================================================
-Syntax: $PCDUCLS, <mode>*<checksum>CRLF
-<mode>=0 : Clear screen to current background colour (default=black)
-<mode>=1 : Clear screen to white
-$PCDUSBC Set Background Color
-====================================================================
-Syntax: $PCDUSBC,<Rcolour>,<Gcolour>,<Bcolour>*<checksum>CRLF
-< Rcolour > : RED (000‐255)
-< Gcolour > : GREEN (000‐255)
-< Bcolour > : BLUE (000‐255)
-Set background colour to RGB as defined in the three data fields.
-$PCDUWTX WTX=WRITE TEXT Write text on any X,Y position on the screen.
-=====================================================================
-Syntax: $PCDUWTX,<Fsize>,<Fstyle>,<Rcolour>,<Gcolour>,<Bcolour>,<Text><Col>,<Row>*<checksum>CRLF
-<Fsize> : Font size (F0..F9). Currently F0 and F1 are implemented.
-<Fstyle> : Font style (S=Standard, B=Bold, I=Italic, U=Underline, N=Negative)
-< Rcolour > : RED (000‐255)
-< Gcolour > : GREEN (000‐255)
-< Bcolour > : BLUE (000‐255)
-<Text> : Any printable ASCII character except the * character as this is used as the text field delimiter.
-  Maximum length is 24 characters, minimum length is 1 character for font F0.
-  Maximum length is 48 characters, minumum length is 1 character for font F1.
-<Col> : Horizontal position of the first character (1..24)
-<Row> : Vertical position of the line (1..14)
-$PCDUETX ETX=ERASE TEXT
-=============================================================
-Syntax: $PCDUETX, <Col>,<Row>,<n>*<checksum>CRLF
-<Col> : Horizontal position of the first character (1..24 for font F0 or 1..48 for font F1)
-<Row> : Vertical position of the line (1‐14)
-<n> : number of characters to be erased (1..24 for font F0 or 1..48 for font F1)
-$PCDUKTX                Write text attached to a Select Key
-===========================================================
-Syntax: $PCDUKTX,<KeyID>,<Texttype>,<Fsize>,<Fstyle>,<Rcolour>,<Gcolour>,<Bcolour>,<Text>*< checksum>CRLF
-<KeyID> : Numbering is 00 – 49 for left keys and 50 – 99 for right keys. Top keys are 00 and 50.
-<Texttype> : M or S, meaning Main text or Subtext.
-<Fsize> : Font size (F0..F9). Currently F0 and F1 are implemented.
-<Fstyle> : Font style (S=Standard, B=Bold, I=Italic, U=Underline, N=Negative)
-< Rcolour > : RED (000‐255)
-< Gcolour > : GREEN (000‐255)
-< Bcolour > : BLUE (000‐255)
-<Text> : Any printable ASCII character within the character set.except the * character as this is used as the text field delimiter.
- Maximum length is 24 characters, minimum length is 1 character for font F0
-Maximum length is 48 characters, minumum length is 1 character for font F1.
-*/
+
+
 
 //Control lines for VGA driver board
 TFT_4DGL display(VGA_TX,VGA_RX,VGA_RESET); // serial tx, serial rx, reset pin
@@ -302,7 +260,23 @@
 void CDU_InitDisplay()
 {
     display.baudrate( 9600 );       //init uVGAIII card
-    VGA_SIGNAL( VGA_INT, VGA_ON );  //select INTERNTAL video and set VGA switch ON
+    VGA_SIGNAL( VGA_INT, VGA_ON );  //select INTERNAL video and set VGA switch ON
+}
+
+
+void CDU_TVScreen()
+{
+    display.display_control(IMAGE_FORMAT, NEW); //set correct image for reading from SD
+    display.cls();
+    display.showpicture( 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xCD );    // TVscreen
+}
+
+
+void CDU_LogoScreen()
+{
+    display.display_control(IMAGE_FORMAT, NEW); //set correct image for reading from SD    
+    display.cls();
+    display.showpicture( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);    // Engravity logo
 }
 
 
@@ -353,19 +327,17 @@
     display.line(XMIN,LINE12,XMAX,LINE12, WHITE);
     display.line(XMIN,LINE13,XMAX,LINE13, WHITE);
     display.line(XMIN,LINE14,XMAX,LINE14, WHITE);
-}
-void CDU_TestScreen()
-{
-    display.display_control(IMAGE_FORMAT, NEW); //set correct image for reading from SD
-    display.cls();
-    display.showpicture(0x00, 0x00, 0x00, 0x14, 0x00, 0x01, 0xB5);    // Testscreen
+    
+    //Hardware & Firmware information
+    display.graphic_string( str2char( CDU_Hardware() ), centertext( CDU_Hardware(), 48, SMALLCHAR), LINE6,  FONT_12X34, WHITE, 1, 1 );
+    display.graphic_string( str2char( CDU_Firmware() ), centertext( CDU_Firmware(), 48, SMALLCHAR), LINE7,  FONT_12X34, WHITE, 1, 1 );
+    display.graphic_string( str2char( CDU_Compile() ) , centertext( CDU_Compile() , 48, SMALLCHAR), LINE8,  FONT_12X34, WHITE, 1, 1 );
+    display.graphic_string( str2char( CDU_MAC() )     , centertext( CDU_MAC()     , 48, SMALLCHAR), LINE10, FONT_12X34, WHITE, 1, 1 );  
+    display.graphic_string( str2char( CDU_IP() )      , centertext( CDU_IP()      , 48, SMALLCHAR), LINE11, FONT_12X34, WHITE, 1, 1 );          
+    
 }
-void CDU_LogoScreen()
-{
-    display.display_control(IMAGE_FORMAT, NEW); //set correct image for reading from SD   
-    display.cls();
-    display.showpicture(0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00);    // Engravity logo
-}
+
+
  
 void CDU_Page()
 {
--- a/display.h	Thu Aug 28 14:39:32 2014 +0000
+++ b/display.h	Thu Sep 25 11:34:21 2014 +0000
@@ -2,11 +2,11 @@
 //VGA selector lines
 #define VGA_INT 0   //use internal VGA screen
 #define VGA_EXT 1   //loop through external VGA screen from DB9 connector to display
-#define VGA_ON  0   //wwitch VGA on
+#define VGA_ON  0   //switch VGA on
 #define VGA_OFF 1   //switch VGA off
  
 //LINE and pixel definitions
-#define LINE1 0
+#define LINE1 0 
 #define LINE2 34
 #define LINE3 68
 #define LINE4 102
--- a/keyboard.h	Thu Aug 28 14:39:32 2014 +0000
+++ b/keyboard.h	Thu Sep 25 11:34:21 2014 +0000
@@ -1,6 +1,8 @@
+/*Backlighting scale factor*/
+ #define BGL_SCALE              5 //Percentage between 0 and 100
+ 
 /* Keyboard TCA8418 declarations */
  
- 
 /* TCA8418 hardware limits */
 #define TCA8418_MAX_ROWS        8
 #define TCA8418_MAX_COLS        10
--- a/keyboard2.cpp	Thu Aug 28 14:39:32 2014 +0000
+++ b/keyboard2.cpp	Thu Sep 25 11:34:21 2014 +0000
@@ -18,7 +18,7 @@
  
 //CDU Keyboard communications KEYBOARD_INT
 InterruptIn CDU_KB_INT( KBD_INT );  //Set CDU keyboard interrupt line
-I2C CDU_I2C(I2C_SDA, I2C_SCL);         //I2C bus for keyboard/temp chip.
+I2C CDU_I2C(I2C_SDA, I2C_SCL);         //I2C bus for keyboard and temp chip.
  
 //CDU Keyboard LEDS
 DigitalOut EXEC( LED_EXEC );
@@ -143,6 +143,8 @@
 {
     //This routine must be called 5-10x per second. Manual test to see what is pleasant to see
     //AnalogIn BGL_POT( p15 ); //background light control potmeter. Returns a value between 0.0 and 1.0
+    //Will be multiplied by a factor (BGL_SCALE/100) to define max light intensity
+    //
     //PwmOut BGL_LED( p21 );   //PWM output
     //calculate required brightness in percentage from 0%-100%
     //nVal 255     --> calculate brightness from potmeter value (default value if no parameter is passed)
@@ -151,13 +153,13 @@
 
     static int LightOn    = 1;
     static int FullBright = 0;
-
+    
     switch (nVal) 
     {
         case 0:
         {
             //switch off backlighting
-            BGL_LED = 0.0 ;
+            BGL_LED = 0.0f ;
             LightOn = 0;
             FullBright = 0;
             break;
@@ -165,7 +167,7 @@
         case 100:
         {
             //switch on backlighting to normal
-            BGL_LED = BGL_POT;
+            BGL_LED = BGL_POT*(float(BGL_SCALE)/100.0f);
             LightOn = 1;
             FullBright = 0;
             break;
@@ -174,7 +176,7 @@
         case 128:
         {
             //switch backlighting to MAX
-            BGL_LED= 1;
+            BGL_LED= 1*(float(BGL_SCALE)/100.0f);
             FullBright = 1;   
         }
     
@@ -189,12 +191,12 @@
                     }
                 else
                     {
-                        BGL_LED = BGL_POT; 
+                        BGL_LED = BGL_POT*(float(BGL_SCALE)/100.0f); 
                     }
             }
             else  if ( ( LightOn == 1) && (FullBright== 1) ) 
             {
-                BGL_LED = 1;
+                BGL_LED = 1*(float(BGL_SCALE)/100.0f);
                 
             }
         }
--- a/keys.h	Thu Aug 28 14:39:32 2014 +0000
+++ b/keys.h	Thu Sep 25 11:34:21 2014 +0000
@@ -25,7 +25,7 @@
              "N1LMT*",   // key 18 
              "EXEC*",    // key 19
              "RSK2*",    // key 20            
-             "???*",     // key 21             
+             "LSK3*",    // key 21             
              "N1LMT*",   // key 22
              "FIX*",     // key 23             
              "???*",     // key 24
--- a/main.cpp	Thu Aug 28 14:39:32 2014 +0000
+++ b/main.cpp	Thu Sep 25 11:34:21 2014 +0000
@@ -50,6 +50,8 @@
 void CDU_InitDisplay(void);
 void CDU_ScreenAlign(void);
 void CDU_StartScreen(void);
+void CDU_LogoScreen(void);
+void CDU_TVSCreen(void);
 void CDU_Page(void);
 void CDU_DSP_CSS(void);
 void CDU_displayclear(void);
@@ -89,7 +91,8 @@
     
     // CDU display initialisation:
     CDU_InitDisplay();
-    CDU_StartScreen();
+    //CDU_StartScreen();
+    CDU_LogoScreen();
     wait(0.2);
     //CDU_Page();
     CDU_ScreenAlign();
--- a/pins.h	Thu Aug 28 14:39:32 2014 +0000
+++ b/pins.h	Thu Sep 25 11:34:21 2014 +0000
@@ -1,15 +1,15 @@
 #include "CDU_hw_sw.h"
 
-#ifdef HW_VERSION_MAIN
-    #if HW_VERSION_MAIN == 1
-    //NOTE: THESE PIN DEFINITIONS ARE FOR HARDWARE VERSION 1.0
+#ifdef HW_VERSION_MAJOR
+    #if HW_VERSION_MAJOR == 1
+    //NOTE: THESE PIN DEFINITIONS ARE FOR HARDWARE VERSION 1.X
     //
     //*********************************
     //pins in main.cpp
     //*********************************
     //MODSERIAL SERIAL_DEBUG(p9, p10, 512, 64);  //: tx, rx
     #define MODSERIAL_TX        p9
-    #define MODSERIAL_RX       p10
+    #define MODSERIAL_RX        p10
     //DigitalOut alive_led(LED1); // : LED 1 on Mbed board toggles when CDU is alive
     #define HEARTBEAT           LED1
 
@@ -55,8 +55,8 @@
     #endif
 
 
-    #if HW_VERSION_MAIN == 2
-    //NOTE: THESE PIN DEFINITIONS ARE FOR HARDWARE VERSION 2.0
+    #if HW_VERSION_MAJOR == 2
+    //NOTE: THESE PIN DEFINITIONS ARE FOR HARDWARE VERSION 2.X
     //
     //*********************************
     //pins in main.cpp