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:
Fri Oct 10 18:23:36 2014 +0000
Parent:
20:150afde94910
Commit message:
Additional files: CDU_Maintenance.cpp / mbps_def3.h
; Rewrite of main() function for power checks

Changed in this revision

4DGL.lib Show annotated file Show diff for this revision Revisions of this file
CDU_Maintenance.cpp Show annotated file Show diff for this revision Revisions of this file
CDU_hw_sw.cpp 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
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbos_def3.h 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
screen_handler.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/4DGL.lib	Thu Sep 25 11:34:21 2014 +0000
+++ b/4DGL.lib	Fri Oct 10 18:23:36 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/Engravity-CDU/code/4DGL-UC/#f90479eeca36
+http://mbed.org/teams/Engravity-CDU/code/4DGL-UC/#f4c0e65c4561
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CDU_Maintenance.cpp	Fri Oct 10 18:23:36 2014 +0000
@@ -0,0 +1,146 @@
+/****************************************************************************/
+/* This file contains entry points to setup and test procedures for the CDU */
+/* Prerequisitions:                                                         */
+/* 1. S-EXEC flag must be set to avoid interference from fs communications  */
+/* 2. Keyboard interrupt routine must be redefined                          */
+/****************************************************************************/
+
+#include "mbed.h"
+#include "TFT_4DGL.h"
+#include "display.h"
+
+#include <string>
+using namespace std;
+
+void CDU_ScreenAlign();
+void CDU_displayclear();
+void ExitKey( string cTitleText );
+
+extern TFT_4DGL display; 
+//extern void CDU_KB_INT_DISABLE(); //disable keyhandler and start internal keyhandler
+extern int key_hit_ID;
+
+//int righttext( string cString, int nChars, int nCharWidth )
+//int centertext( string cString, int nChars, int nCharWidth )
+extern char* str2char( string cString );
+extern int righttext( string cString, int nChars, int nCharWidth );
+extern int centertext( string cString, int nChars, int nCharWidth );
+
+
+void CDU_Maint()
+// Main selection screen SETUP and MAINT
+{
+    ExitKey( "CDU MAINTENANCE");
+    display.graphic_string( str2char( "< SETUP" ), 0, LINE3, FONT_24X34, WHITE, 2, 2 ); 
+    display.graphic_string( str2char( "LIGHT TEST >" ), righttext( "LIGHT TEST >", 24,24) , LINE3, FONT_24X34, WHITE, 2, 2 );     
+    display.graphic_string( str2char( "KEYBOARD TEST >" ), righttext( "KEYBOARD TEST >", 24,24) , LINE5, FONT_24X34, WHITE, 2, 2 );         
+    display.graphic_string( str2char( "FIRMWARE >" ), righttext( "FIRMWARE >", 24,24) , LINE9, FONT_24X34, WHITE, 2, 2 );
+}
+
+//Setup screens
+void CDU_Setup()
+{
+    ExitKey( "CDU SETUP" );
+    display.graphic_string( str2char( "< USB" ), 0, LINE3, FONT_24X34, WHITE, 2, 2 ); 
+    display.graphic_string( str2char( "< ETHERNET" ), 0, LINE5, FONT_24X34, WHITE, 2, 2 ); 
+    display.graphic_string( str2char( "DISPLAY SOURCE >" ), righttext( "DISPLAY SOURCE >", 24,24) , LINE9, FONT_24X34, WHITE, 2, 2 );     
+}
+
+
+void CDU_USB_Setup()
+{
+    ExitKey( "CDU USB SETUP" );
+    display.graphic_string( str2char( "< BAUDRATE" ), 0, LINE3, FONT_24X34, WHITE, 2, 2 ); 
+    display.graphic_string( str2char( "< DATABITS" ), 0, LINE5, FONT_24X34, WHITE, 2, 2 );        
+    display.graphic_string( str2char( "< PARITY" ), 0, LINE7, FONT_24X34, WHITE, 2, 2 ); 
+    display.graphic_string( str2char( "< STOPBITS" ), 0, LINE9, FONT_24X34, WHITE, 2, 2 ); 
+}
+
+void CDU_Ethernet_Setup()
+{
+    ExitKey( "CDU ETHERNET SETUP" );
+    display.graphic_string( str2char( "< AUTO IP" ), 0, LINE3, FONT_24X34, WHITE, 2, 2 ); 
+    display.graphic_string( str2char( "< IP ADDRESS" ), 0, LINE5, FONT_24X34, WHITE, 2, 2 );        
+    display.graphic_string( str2char( "< GATEWAY" ), 0, LINE7, FONT_24X34, WHITE, 2, 2 ); 
+    display.graphic_string( str2char( "< MAC ADDRESS" ), 0, LINE9, FONT_24X34, WHITE, 2, 2 );    
+    
+}
+
+
+void CDU_Source_Setup()
+{
+    ExitKey( "CDU VIDEO SOURCE" );
+    display.graphic_string( str2char( "< INTERNAL" ), 0, LINE3, FONT_24X34, WHITE, 2, 2 ); 
+    display.graphic_string( str2char( "EXTERNAL >" ), righttext( "EXTERNAL >", 24,24) , LINE3, FONT_24X34, WHITE, 2, 2 );   
+}
+
+
+
+//Maintenance screens
+
+void CDU_FW_Update()
+{
+    ExitKey( "FIRMWARE UPDATE" );
+    display.graphic_string( str2char( "REBOOT CDU >" ), righttext( "REBOOT CDU >", 24,24) , LINE3, FONT_24X34, WHITE, 2, 2 );   
+}
+
+void CDU_LightTest()
+{
+    ExitKey( "CDU LIGHT TEST" );
+    display.graphic_string( str2char( "< BACKLIGHT" ), 0, LINE3, FONT_24X34, WHITE, 2, 2 ); 
+    display.graphic_string( str2char( "*=ON" ), centertext( "*=ON", 24, 24 ), LINE2, FONT_24X34, WHITE, 2, 2 ); 
+    display.graphic_string( str2char( "----ANNUNCIATOR TEST----" ), 0, LINE4, FONT_24X34, WHITE, 2, 2 );  
+       
+    display.graphic_string( str2char( "< DSP" ), 0, LINE7, FONT_24X34, RED, 2, 2 );        
+    display.graphic_string( str2char( "< FAIL" ), 0, LINE9, FONT_24X34, RED, 2, 2 ); 
+    
+    display.graphic_string( str2char( "EXEC >" ), righttext( "EXEC >", 24,24) , LINE5, FONT_24X34, GREEN, 2, 2 );  
+    display.graphic_string( str2char( "MSG >" ),  righttext( "MSG >", 24,24) ,  LINE7, FONT_24X34, YELLOW, 2, 2 );  
+    display.graphic_string( str2char( "OFST >" ), righttext( "OFST >", 24,24) , LINE9, FONT_24X34, YELLOW, 2, 2 );              
+}
+
+void CDU_KeyboardTest()
+{
+    ExitKey( "CDU KEYBOARD TEST");
+    display.graphic_string( str2char( "KEYSCAN CODE: " ), 0, LINE6, FONT_24X34, WHITE, 2, 2 );   
+    display.graphic_string( str2char( "FS KEY VALUE: " ), 0, LINE7, FONT_24X34, WHITE, 2, 2 ); 
+    display.graphic_string( str2char( "PRESS 2x [EXEC]" ), 6, LINE12, FONT_24X34, WHITE, 2, 2 );        
+}
+
+void ExitKey( string cTitleText )
+{
+    //clear screen and place exit text
+    CDU_displayclear();
+    display.graphic_string( str2char( cTitleText ), centertext( cTitleText, 24, 24 ), LINE1, FONT_24X34, WHITE, 2, 2 ); 
+    display.graphic_string( str2char( "< EXIT" ), 0, LINE13, FONT_24X34, WHITE, 2, 2 ); 
+}
+
+//Show all setup screens
+
+void CDU_Screens()
+{
+    CDU_Maint();
+    wait_ms( 4000 );
+    
+    CDU_Setup();
+    wait_ms( 4000 );
+    
+    CDU_USB_Setup();
+    wait_ms( 4000 );
+
+    CDU_Ethernet_Setup();
+    wait_ms( 4000 );
+    
+    CDU_Source_Setup();
+    wait_ms( 4000 );
+    
+    CDU_LightTest();
+    wait_ms( 4000);
+    
+    CDU_KeyboardTest();
+    wait_ms( 4000 );
+
+    CDU_FW_Update();
+    wait_ms( 4000 );
+   
+}
\ No newline at end of file
--- a/CDU_hw_sw.cpp	Thu Sep 25 11:34:21 2014 +0000
+++ b/CDU_hw_sw.cpp	Fri Oct 10 18:23:36 2014 +0000
@@ -3,6 +3,9 @@
 #include "pins.h"
 
 extern "C" void mbed_mac_address(char *mac); //for reading MAC Address
+extern "C" void mbed_reset();                //reboot CDU
+
+extern int PWR_led;
 
 string CDU_Hardware()
 {
@@ -64,3 +67,8 @@
     cIP += "000:000:000:000 (not defined)";
     return cIP;
 }
+
+void CDU_BOOT()
+{
+    mbed_reset();
+}
--- a/display.cpp	Thu Sep 25 11:34:21 2014 +0000
+++ b/display.cpp	Fri Oct 10 18:23:36 2014 +0000
@@ -53,7 +53,6 @@
 */
 
 
-
 //Control lines for VGA driver board
 TFT_4DGL display(VGA_TX,VGA_RX,VGA_RESET); // serial tx, serial rx, reset pin
 
@@ -274,8 +273,8 @@
 
 void CDU_LogoScreen()
 {
+    display.cls();
     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
 }
 
@@ -287,23 +286,23 @@
     
     display.cls();  
     
-    display.graphic_string( str2char( cTitle1 ), centertext( cTitle1, 24, LARGECHAR), LINE6, FONT_24X34, WHITE, 1, 1 );
+    display.graphic_string( str2char( cTitle1 ), centertext( cTitle1, 24, LARGECHAR), LINE6, FONT_24X34, WHITE, TEXT_SCALE, TEXT_SCALE );
     wait_ms(100);
-    display.graphic_string( str2char( cTitle2 ), centertext( cTitle2, 24, LARGECHAR), LINE8, FONT_24X34, RED, 1, 1 );
+    display.graphic_string( str2char( cTitle2 ), centertext( cTitle2, 24, LARGECHAR), LINE8, FONT_24X34, RED, TEXT_SCALE, TEXT_SCALE );
     wait_ms(100);
-    display.graphic_string( str2char( cTitle2 ), centertext( cTitle2, 24, LARGECHAR), LINE8, FONT_24X34, GREEN, 1, 1 );
+    display.graphic_string( str2char( cTitle2 ), centertext( cTitle2, 24, LARGECHAR), LINE8, FONT_24X34, GREEN, TEXT_SCALE, TEXT_SCALE );
     wait_ms(100);
-    display.graphic_string( str2char( cTitle2) , centertext( cTitle2, 24, LARGECHAR), LINE8, FONT_24X34, BLUE, 1, 1 );
+    display.graphic_string( str2char( cTitle2) , centertext( cTitle2, 24, LARGECHAR), LINE8, FONT_24X34, BLUE, TEXT_SCALE, TEXT_SCALE );
     wait_ms(100);
     
     display.cls();
     
     //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 );          
+    display.graphic_string( str2char( CDU_Hardware() ), centertext( CDU_Hardware(), 48, SMALLCHAR), LINE6,  FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );
+    display.graphic_string( str2char( CDU_Firmware() ), centertext( CDU_Firmware(), 48, SMALLCHAR), LINE7,  FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );
+    display.graphic_string( str2char( CDU_Compile() ) , centertext( CDU_Compile() , 48, SMALLCHAR), LINE8,  FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );
+    display.graphic_string( str2char( CDU_MAC() )     , centertext( CDU_MAC()     , 48, SMALLCHAR), LINE10, FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );  
+    display.graphic_string( str2char( CDU_IP() )      , centertext( CDU_IP()      , 48, SMALLCHAR), LINE11, FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );          
     wait_ms(5000);    
 }
 
@@ -329,51 +328,54 @@
     display.line(XMIN,LINE14,XMAX,LINE14, WHITE);
     
     //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 );          
+    display.graphic_string( str2char( CDU_Hardware() ), centertext( CDU_Hardware(), 48, SMALLCHAR), LINE6,  FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );
+    display.graphic_string( str2char( CDU_Firmware() ), centertext( CDU_Firmware(), 48, SMALLCHAR), LINE7,  FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );
+    display.graphic_string( str2char( CDU_Compile() ) , centertext( CDU_Compile() , 48, SMALLCHAR), LINE8,  FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );
+    display.graphic_string( str2char( CDU_MAC() )     , centertext( CDU_MAC()     , 48, SMALLCHAR), LINE10, FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );  
+    display.graphic_string( str2char( CDU_IP() )      , centertext( CDU_IP()      , 48, SMALLCHAR), LINE11, FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );          
     
 }
 
-
- 
 void CDU_Page()
 {
     display.cls();
-    display.graphic_string( "PERF INIT" , 8*24,  LINE1, FONT_24X34, WHITE, 1, 1 );
+    display.graphic_string( "PERF INIT" , 8*24,  LINE1, FONT_24X34, WHITE, TEXT_SCALE, TEXT_SCALE );
   
-    display.graphic_string( "GW/CRZ CG" , 0,  LINE2, FONT_12X34, WHITE, 1, 1 );
-    display.graphic_string( "CRZ ALT"   , 41*12, LINE2, FONT_12X34, WHITE, 1, 1 );
+    display.graphic_string( "GW/CRZ CG" , 0,  LINE2, FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );
+    display.graphic_string( "CRZ ALT"   , 41*12, LINE2, FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );
    
-    display.graphic_string( "___._ / 26.2%" , 0,  LINE3, FONT_24X34, WHITE, 1, 1 );
-    display.graphic_string( "_____"     , 19*24, LINE3, FONT_24X34, WHITE, 1, 1 );
-    display.graphic_string( "FUEL" , 0,  LINE4, FONT_12X34, WHITE, 1, 1 );
-    display.graphic_string( "CRZ/WIND"   , 40*12, LINE4, FONT_12X34, WHITE, 1, 1 );
+    display.graphic_string( "___._ / 26.2%" , 0,  LINE3, FONT_24X34, WHITE, TEXT_SCALE, TEXT_SCALE );
+    display.graphic_string( "_____"     , 19*24, LINE3, FONT_24X34, WHITE, TEXT_SCALE, TEXT_SCALE );
+    display.graphic_string( "FUEL" , 0,  LINE4, FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );
+    display.graphic_string( "CRZ/WIND"   , 40*12, LINE4, FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );
        
-    display.graphic_string( "0.0" , 0,  LINE5, FONT_24X34, WHITE, 1, 1 );
-    display.graphic_string( "000$ /---" , 15*24,  LINE5, FONT_24X34, WHITE, 1, 1 );
+    display.graphic_string( "0.0" , 0,  LINE5, FONT_24X34, WHITE, TEXT_SCALE, TEXT_SCALE );
+    display.graphic_string( "000$ /---" , 15*24,  LINE5, FONT_24X34, WHITE, TEXT_SCALE, TEXT_SCALE );
   
-    display.graphic_string( "ZFW" , 0,  LINE6, FONT_12X34, WHITE, 1, 1 );
-    display.graphic_string( "___._ " , 0,  LINE7, FONT_24X34, WHITE, 1, 1 );
+    display.graphic_string( "ZFW" , 0,  LINE6, FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );
+    display.graphic_string( "___._ " , 0,  LINE7, FONT_24X34, WHITE, TEXT_SCALE, TEXT_SCALE );
   
-    display.graphic_string( "RESERVES" , 0,  LINE8, FONT_12X34, WHITE, 1, 1 );
-    display.graphic_string( "__._ " , 0,  LINE9, FONT_24X34, WHITE, 1, 1 );
+    display.graphic_string( "RESERVES" , 0,  LINE8, FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );
+    display.graphic_string( "__._ " , 0,  LINE9, FONT_24X34, WHITE, TEXT_SCALE, TEXT_SCALE );
        
-    display.graphic_string( "COST INDEX" , 0,  LINE10, FONT_12X34, WHITE, 1, 1 );
-    display.graphic_string( "TRANS ALT"   , 39*12, LINE10, FONT_12X34, WHITE, 1, 1 );
+    display.graphic_string( "COST INDEX" , 0,  LINE10, FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );
+    display.graphic_string( "TRANS ALT"   , 39*12, LINE10, FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );
     
-    display.graphic_string( "___" , 0,  LINE11, FONT_24X34, WHITE, 1, 1 );
-    display.graphic_string( "_____"     , 19*24, LINE11, FONT_24X34, WHITE, 1, 1 );
+    display.graphic_string( "___" , 0,  LINE11, FONT_24X34, WHITE, TEXT_SCALE, TEXT_SCALE );
+    display.graphic_string( "_____"     , 19*24, LINE11, FONT_24X34, WHITE, TEXT_SCALE, TEXT_SCALE );
   
-    display.graphic_string( "------------------------------------------------"   , 0, LINE12, FONT_12X34, WHITE, 1, 1 );
+    display.graphic_string( "------------------------------------------------"   , 0, LINE12, FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );
  
-    display.graphic_string( "<INDEX" , 0,  LINE13, FONT_24X34, WHITE, 1, 1 );
-    display.graphic_string( "N1 LIMIT>"     , 15*24, LINE13, FONT_24X34, WHITE, 1, 1 );
+    display.graphic_string( "<INDEX" , 0,  LINE13, FONT_24X34, WHITE, TEXT_SCALE, TEXT_SCALE );
+    display.graphic_string( "N1 LIMIT>"     , 15*24, LINE13, FONT_24X34, WHITE, TEXT_SCALE, TEXT_SCALE );
   
-    display.graphic_string( "SCRATCHPAD DATA LINE", centertext("SCRATCHPAD DATA LINE", 24, LARGECHAR) , LINE14, FONT_24X34, RED, 1, 1 );
-   
+    display.graphic_string( "SCRATCHPAD DATA LINE", centertext("SCRATCHPAD DATA LINE", 24, LARGECHAR) , LINE14, FONT_24X34, RED, TEXT_SCALE, TEXT_SCALE ); 
+}
+ 
+ void CDU_Waiting()
+{
+    display.cls();
+    display.graphic_string( "WAITING" , 0,  LINE1, FONT_12X34, WHITE, TEXT_SCALE, TEXT_SCALE );
 }
  
 void  CDU_displayclear(){
--- a/display.h	Thu Sep 25 11:34:21 2014 +0000
+++ b/display.h	Fri Oct 10 18:23:36 2014 +0000
@@ -4,6 +4,8 @@
 #define VGA_EXT 1   //loop through external VGA screen from DB9 connector to display
 #define VGA_ON  0   //switch VGA on
 #define VGA_OFF 1   //switch VGA off
+
+#define TEXT_SCALE 2
  
 //LINE and pixel definitions
 #define LINE1 0 
--- a/keyboard.h	Thu Sep 25 11:34:21 2014 +0000
+++ b/keyboard.h	Fri Oct 10 18:23:36 2014 +0000
@@ -1,5 +1,5 @@
 /*Backlighting scale factor*/
- #define BGL_SCALE              5 //Percentage between 0 and 100
+ #define BGL_SCALE              50 //Percentage between 0 and 100
  
 /* Keyboard TCA8418 declarations */
  
--- a/main.cpp	Thu Sep 25 11:34:21 2014 +0000
+++ b/main.cpp	Fri Oct 10 18:23:36 2014 +0000
@@ -6,13 +6,15 @@
 #include "mbed.h"
 #include "MODSERIAL.h"
 #include "mbos.h"
-#include "mbos_def2.h"   // : Mbos tasks, timer and resource definitions
+#include "mbos_def3.h"   // : Mbos tasks, timer and resource definitions
 #include "pins.h"
 
 // Setup USB communication defined by Mbed USB TX and RX lines
 // with TX and RX ringbuffers :
-MODSERIAL USB(USBTX, USBRX, 256, 1024);
+MODSERIAL USB(USBTX, USBRX, 256, 2048);
 DigitalOut alive_led( HEARTBEAT ); // : LED 1 on Mbed board toggles when CDU is alive
+DigitalOut PWR_led( PWR_ON );      // : LED 4 on Mbed board is ON when external power applied to board
+InterruptIn PWR_MON( PWR_IN );     // : Power monitor: input is connected to +5V and indirect to +12V
 
 //void test_update_flags(); // << for testing only << !!!!!!!
 
@@ -51,11 +53,14 @@
 void CDU_ScreenAlign(void);
 void CDU_StartScreen(void);
 void CDU_LogoScreen(void);
+void CDU_Waiting(void);
 void CDU_TVSCreen(void);
 void CDU_Page(void);
 void CDU_DSP_CSS(void);
 void CDU_displayclear(void);
 
+void CDU_BOOT();    //reboot CDU
+
 //------ USB buffer overflow interrupt handling: -------------
 void rx_buf_overflow(MODSERIAL_IRQ_INFO *q)
 {   // This functiom will be called when RX buffer overflows.
@@ -80,8 +85,51 @@
     USB.attach(&tx_buf_overflow, MODSERIAL::TxOvIrq); // : attach function to call when USB TX buffer overflows
 }
 
+char CheckExtPower()
+{
+    char ExtPower =0;
+    
+    ExtPower = PWR_MON; //check on power input: if +5V is ON return 1 else 0
+    PWR_led=1;
+    alive_led=1;
+    wait_ms(100);
+    PWR_led=0;
+    alive_led=0;
+    wait_ms(100);
+    PWR_led=PWR_MON;
+
+    return ExtPower;
+}
+
+void EXT_PWR_DN()
+{
+    //external power failed, reboot CDU after power up
+    while (! CheckExtPower()); //wait for power up....
+    CDU_BOOT();
+}
+
 main() // : MBOS main() 
 {
+    /* Check for a valid external power flag during boot sequence
+       When no external power is applied the VGA board and Keyboard chip are not operational
+       After initialization disconnecting external power will trigger interrupt to reboot.
+    */    
+    char PWR_OK=0;
+    
+    PWR_MON.mode( PullDown );    //create a solid 0 when no external power supplied
+    PWR_MON.fall(&EXT_PWR_DN);   //Bind function to handle interrupt when external power fails 
+         
+    PWR_OK = PWR_MON;        //use as boot flag           
+
+    if (! PWR_OK )
+    {
+        while (! CheckExtPower() );   //wait for external power to come up
+        CDU_BOOT();
+    }
+ 
+    PWR_led = PWR_MON ;          //switch on LED for external power indicator
+ 
+       
     init_USB();  // : setup USB communication to FS
      
     // CDU keyboard initialisation and keyboard interrrupt setup:
@@ -92,10 +140,11 @@
     // CDU display initialisation:
     CDU_InitDisplay();
     //CDU_StartScreen();
-    CDU_LogoScreen();
+    //CDU_LogoScreen();
     wait(0.2);
     //CDU_Page();
-    CDU_ScreenAlign();
+    //CDU_ScreenAlign();
+    CDU_Waiting();
             
     set_initial_data(); //: fill FS datastructures with initial data
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbos_def3.h	Fri Oct 10 18:23:36 2014 +0000
@@ -0,0 +1,64 @@
+/* // File: mbos_def3.h
+/  New priority for testing communication crash
+/
+/  Also changed: input buffer 1024-2048 bytes in main.cpp
+/
+/
+#define RECEIVE_DECODE_TASK_PRIO        80->95  // : highest
+#define CDU_DSP_CSS_TASK_PRIO           95->90
+#define SEND_KEYMESSAGE_TASK_PRIO       90->80
+#define ALIVE_TASK_PRIO                 50              deze zo houden maar
+#define READ_POT_TASK_PRIO              40  // : lowest priority       deze zo houden maar
+*/ 
+// File: mbos_def2.h
+// L. van der Kolk, ELVEDEKA, Holland
+
+// -------------- Mbos definitions for CDU -------------------------------------------
+// MBOS TASKS:
+// ALIVE_TASK properties:
+#define ALIVE_TASK_ID             1
+#define ALIVE_TASK_PRIO          50
+#define ALIVE_TASK_STACK_SZ     100    
+// READ_POT_TASK properties: 
+#define READ_POT_TASK_ID            4       
+#define READ_POT_TASK_PRIO         40  // : lowest priority    
+#define READ_POT_TASK_STACK_SZ    100
+// RECEIVE_DECODE_TASK properties:
+#define RECEIVE_DECODE_TASK_ID         2
+#define RECEIVE_DECODE_TASK_PRIO      95  
+#define RECEIVE_DECODE_TASK_STACK_SZ  256  
+// SEND_KEYMESSAGE_TASK properties:
+#define SEND_KEYMESSAGE_TASK_ID         3
+#define SEND_KEYMESSAGE_TASK_PRIO      80
+#define SEND_KEYMESSAGE_TASK_STACK_SZ 256 
+// CDU_DSP_CSS_TASK properties: 
+#define CDU_DSP_CSS_TASK_ID            5
+#define CDU_DSP_CSS_TASK_PRIO         90  // : highest priority !
+#define CDU_DSP_CSS_TASK_STACK_SZ    512
+
+// MBOS TIMERS:
+// ALIVE_TIMER properties:
+#define ALIVE_TIMER_ID               1
+#define ALIVE_TIMER_PERIOD        5000   // = 5 sec
+// READ_POT_TIMER properties: 
+#define READ_POT_TIMER_ID            2   
+#define READ_POT_TIMER_PERIOD      100   // = 100msec scan time
+// DECODE_TIMER properties:
+#define DECODE_TIMER_ID              3   
+#define DECODE_TIMER_PERIOD         50   // = 50msec scan time   
+
+// MBOS EVENTS:
+#define ALIVE_EVENT             1      
+#define DECODE_TIMER_EVENT      2   
+#define KEY_EVENT               4 
+#define READ_POT_TIMER_EVENT    8   
+#define FS_DATA_EVENT          16    
+
+// MBOS RESOURCES:
+// NOTE: priority should be higher than that of any task which will access the resource !
+#define USB_TX_RESOURCE     2       // : for locking USB TX buffer
+#define USB_TX_PRIO         99      // : USB TX buffer resource priority 
+#define FS_DATA_RESOURCE    1       // : for locking FS data structures
+#define FS_DATA_PRIO        97      // : FS data resource priority 
+
+// -------------------------------------------------------------------------------------------  
\ No newline at end of file
--- a/pins.h	Thu Sep 25 11:34:21 2014 +0000
+++ b/pins.h	Fri Oct 10 18:23:36 2014 +0000
@@ -52,6 +52,11 @@
 
     //DigitalOut Key_led(LED2); // : LED 2 on Mbed board toggles when CDU key is pressed
     #define KEY_PRESSED         LED2
+
+    #define PWR_IN              p6   //This pin is connected to the +5V and is 1 when external power is applied
+                                     //Level transition from 1->0 indicates an external power failure
+    #define PWR_ON              LED4 //monitor of external power and reboot CDU after 1-0-1 state change
+        
     #endif
 
 
@@ -106,6 +111,11 @@
 
     //DigitalOut Key_led(LED2); // : LED 2 on Mbed board toggles when CDU key is pressed
     #define KEY_PRESSED         LED2
+
+    #define PWR_IN              p6   //This pin is connected to the +5V and is 1 when external power is applied
+                                     //Level transition from 1->0 indicates an external power failure
+    #define PWR_ON              LED4 //monitor of external power and reboot CDU after 1-0-1 state change
+        
     #endif
 
 #endif
\ No newline at end of file
--- a/screen_handler.cpp	Thu Sep 25 11:34:21 2014 +0000
+++ b/screen_handler.cpp	Fri Oct 10 18:23:36 2014 +0000
@@ -109,7 +109,7 @@
                                     nLine2Pixel( nLine ),                                 //Vertical position
                                     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 );
+                                    TEXT_SCALE, TEXT_SCALE );
           
  
             Key_Maintext_Update = -1;
@@ -154,7 +154,7 @@
                                     nLine2Pixel( nLine ),                              //Vertical position
                                     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
+                                    TEXT_SCALE, TEXT_SCALE ); //multiplier always on 1
             Key_Subtext_Update = -1;
         }
       
@@ -166,7 +166,7 @@
                                     nLine2Pixel( Text_Line_Update ),                        //Vertical position
                                     TEXTLINE[Text_Line_Update].font_size,      //Font
                                     cRGB( TEXTLINE[Text_Line_Update].text_RED ,TEXTLINE[Text_Line_Update].text_GREEN ,TEXTLINE[Text_Line_Update].text_BLUE ),
-                                    1, 1 ); //multiplier always on 1
+                                    TEXT_SCALE, TEXT_SCALE ); //multiplier always on 1
             Text_Line_Update = 0;
         }