New work version with additional functions
Dependencies: 4DGL-UC ConfigFile MODSERIAL mbed mbos
Fork of CDU_Mbed_35 by
display.cpp@18:fd672797458c, 2014-08-28 (annotated)
- Committer:
- WillemBraat
- Date:
- Thu Aug 28 12:01:12 2014 +0000
- Revision:
- 18:fd672797458c
- Parent:
- 17:b3545e9d38f7
- Child:
- 19:9d8032cb0f12
Modified 4DGL lib. Lowercase is converted to uppercase.
; All pin definitions of hardware are now in pins.h
; Software/Hardware info in CDU_hw_sh.H
; Binary is stamped with Hardware Version, Firmware Version and compile (UTC) time date stamp.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
LvdK | 7:6576a287e563 | 1 | //Display control functions -- |
LvdK | 7:6576a287e563 | 2 | #include "mbed.h" |
LvdK | 7:6576a287e563 | 3 | #include "TFT_4DGL.h" |
LvdK | 7:6576a287e563 | 4 | #include "display.h" |
LvdK | 8:422544d24df3 | 5 | #include <string> |
WillemBraat | 17:b3545e9d38f7 | 6 | #include "pins.h" |
WillemBraat | 18:fd672797458c | 7 | |
LvdK | 7:6576a287e563 | 8 | using namespace std; |
WillemBraat | 17:b3545e9d38f7 | 9 | |
WillemBraat | 17:b3545e9d38f7 | 10 | DigitalOut VGA_SOURCE( VGA_SOURCE_SELECT ); //control line for video switch between INT and EXT video |
WillemBraat | 17:b3545e9d38f7 | 11 | DigitalOut VGA_SELECT( VGA_ON_OFF ); //control line to select/deselect video switch |
LvdK | 7:6576a287e563 | 12 | /* |
LvdK | 7:6576a287e563 | 13 | ===================================================== |
LvdK | 7:6576a287e563 | 14 | SGC (Serial Graphics Controller) PLATFORM OUTPUT FILE |
LvdK | 7:6576a287e563 | 15 | ===================================================== |
LvdK | 7:6576a287e563 | 16 | ******************************************************* |
LvdK | 7:6576a287e563 | 17 | * Must set 'New image format' for usage on Picaso SGC * |
LvdK | 7:6576a287e563 | 18 | * Data: * |
LvdK | 7:6576a287e563 | 19 | * 0x59, 0x06, 0x00 * |
LvdK | 7:6576a287e563 | 20 | * 4DSL command: * |
LvdK | 7:6576a287e563 | 21 | * Control(6,0) * |
LvdK | 7:6576a287e563 | 22 | ******************************************************* |
LvdK | 7:6576a287e563 | 23 | --------------------------------------------------------------------------------------- |
LvdK | 7:6576a287e563 | 24 | File "logo_flyengravity.jpg" (logo_flyengravity.jpg) |
LvdK | 7:6576a287e563 | 25 | Sector Address 0x000000 |
LvdK | 7:6576a287e563 | 26 | X = 0 Y = 135 Width = 640 Height = 215 Bits = 16 |
LvdK | 7:6576a287e563 | 27 | Display Image from Memory Card (Serial Command): |
LvdK | 7:6576a287e563 | 28 | Syntax: |
LvdK | 7:6576a287e563 | 29 | @, I, x, y, SectorAdd(hi), SectorAdd(mid), SectorAdd(lo) |
LvdK | 7:6576a287e563 | 30 | Picaso Data: |
LvdK | 7:6576a287e563 | 31 | 0x40, 0x49, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00 |
LvdK | 7:6576a287e563 | 32 | 4DSL command: |
LvdK | 7:6576a287e563 | 33 | NewUSDImage(0, 135, 0x000000) |
LvdK | 7:6576a287e563 | 34 | --------------------------------------------------------------------------------------- |
LvdK | 7:6576a287e563 | 35 | File "Testscreen.png" (Testscreen.png) |
LvdK | 7:6576a287e563 | 36 | Sector Address 0x00021A |
LvdK | 7:6576a287e563 | 37 | X = 0 Y = 0 Width = 640 Height = 480 Bits = 16 |
LvdK | 7:6576a287e563 | 38 | Display Image from Memory Card (Serial Command): |
LvdK | 7:6576a287e563 | 39 | Syntax: |
LvdK | 7:6576a287e563 | 40 | @, I, x, y, SectorAdd(hi), SectorAdd(mid), SectorAdd(lo) |
LvdK | 7:6576a287e563 | 41 | Picaso Data: |
LvdK | 7:6576a287e563 | 42 | 0x40, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1A |
LvdK | 7:6576a287e563 | 43 | 4DSL command: |
LvdK | 7:6576a287e563 | 44 | NewUSDImage(0, 0, 0x00021A) |
LvdK | 7:6576a287e563 | 45 | */ |
LvdK | 7:6576a287e563 | 46 | /*Display Commands |
LvdK | 7:6576a287e563 | 47 | $PCDUCLS Erase to active background colour (default black) or white |
LvdK | 7:6576a287e563 | 48 | =================================================================== |
LvdK | 7:6576a287e563 | 49 | Syntax: $PCDUCLS, <mode>*<checksum>CRLF |
LvdK | 8:422544d24df3 | 50 | <mode>=0 : Clear screen to current background colour (default=black) |
LvdK | 8:422544d24df3 | 51 | <mode>=1 : Clear screen to white |
LvdK | 7:6576a287e563 | 52 | $PCDUSBC Set Background Color |
LvdK | 7:6576a287e563 | 53 | ==================================================================== |
LvdK | 7:6576a287e563 | 54 | Syntax: $PCDUSBC,<Rcolour>,<Gcolour>,<Bcolour>*<checksum>CRLF |
LvdK | 8:422544d24df3 | 55 | < Rcolour > : RED (000‐255) |
LvdK | 8:422544d24df3 | 56 | < Gcolour > : GREEN (000‐255) |
LvdK | 8:422544d24df3 | 57 | < Bcolour > : BLUE (000‐255) |
LvdK | 8:422544d24df3 | 58 | Set background colour to RGB as defined in the three data fields. |
LvdK | 7:6576a287e563 | 59 | $PCDUWTX WTX=WRITE TEXT Write text on any X,Y position on the screen. |
LvdK | 7:6576a287e563 | 60 | ===================================================================== |
LvdK | 7:6576a287e563 | 61 | Syntax: $PCDUWTX,<Fsize>,<Fstyle>,<Rcolour>,<Gcolour>,<Bcolour>,<Text><Col>,<Row>*<checksum>CRLF |
LvdK | 8:422544d24df3 | 62 | <Fsize> : Font size (F0..F9). Currently F0 and F1 are implemented. |
LvdK | 8:422544d24df3 | 63 | <Fstyle> : Font style (S=Standard, B=Bold, I=Italic, U=Underline, N=Negative) |
LvdK | 8:422544d24df3 | 64 | < Rcolour > : RED (000‐255) |
LvdK | 8:422544d24df3 | 65 | < Gcolour > : GREEN (000‐255) |
LvdK | 8:422544d24df3 | 66 | < Bcolour > : BLUE (000‐255) |
LvdK | 8:422544d24df3 | 67 | <Text> : Any printable ASCII character except the * character as this is used as the text field delimiter. |
LvdK | 7:6576a287e563 | 68 | Maximum length is 24 characters, minimum length is 1 character for font F0. |
LvdK | 7:6576a287e563 | 69 | Maximum length is 48 characters, minumum length is 1 character for font F1. |
LvdK | 8:422544d24df3 | 70 | <Col> : Horizontal position of the first character (1..24) |
LvdK | 8:422544d24df3 | 71 | <Row> : Vertical position of the line (1..14) |
LvdK | 7:6576a287e563 | 72 | $PCDUETX ETX=ERASE TEXT |
LvdK | 8:422544d24df3 | 73 | ============================================================= |
LvdK | 7:6576a287e563 | 74 | Syntax: $PCDUETX, <Col>,<Row>,<n>*<checksum>CRLF |
LvdK | 8:422544d24df3 | 75 | <Col> : Horizontal position of the first character (1..24 for font F0 or 1..48 for font F1) |
LvdK | 8:422544d24df3 | 76 | <Row> : Vertical position of the line (1‐14) |
LvdK | 8:422544d24df3 | 77 | <n> : number of characters to be erased (1..24 for font F0 or 1..48 for font F1) |
LvdK | 7:6576a287e563 | 78 | $PCDUKTX Write text attached to a Select Key |
LvdK | 7:6576a287e563 | 79 | =========================================================== |
LvdK | 7:6576a287e563 | 80 | Syntax: $PCDUKTX,<KeyID>,<Texttype>,<Fsize>,<Fstyle>,<Rcolour>,<Gcolour>,<Bcolour>,<Text>*< checksum>CRLF |
LvdK | 8:422544d24df3 | 81 | <KeyID> : Numbering is 00 – 49 for left keys and 50 – 99 for right keys. Top keys are 00 and 50. |
LvdK | 8:422544d24df3 | 82 | <Texttype> : M or S, meaning Main text or Subtext. |
LvdK | 8:422544d24df3 | 83 | <Fsize> : Font size (F0..F9). Currently F0 and F1 are implemented. |
LvdK | 8:422544d24df3 | 84 | <Fstyle> : Font style (S=Standard, B=Bold, I=Italic, U=Underline, N=Negative) |
LvdK | 8:422544d24df3 | 85 | < Rcolour > : RED (000‐255) |
LvdK | 8:422544d24df3 | 86 | < Gcolour > : GREEN (000‐255) |
LvdK | 8:422544d24df3 | 87 | < Bcolour > : BLUE (000‐255) |
LvdK | 8:422544d24df3 | 88 | <Text> : Any printable ASCII character within the character set.except the * character as this is used as the text field delimiter. |
LvdK | 7:6576a287e563 | 89 | Maximum length is 24 characters, minimum length is 1 character for font F0 |
LvdK | 8:422544d24df3 | 90 | Maximum length is 48 characters, minumum length is 1 character for font F1. |
LvdK | 7:6576a287e563 | 91 | */ |
WillemBraat | 17:b3545e9d38f7 | 92 | |
LvdK | 7:6576a287e563 | 93 | //Control lines for VGA driver board |
WillemBraat | 17:b3545e9d38f7 | 94 | TFT_4DGL display(VGA_TX,VGA_RX,VGA_RESET); // serial tx, serial rx, reset pin |
WillemBraat | 17:b3545e9d38f7 | 95 | |
LvdK | 7:6576a287e563 | 96 | //Character & String functions |
LvdK | 7:6576a287e563 | 97 | char* str2char( string cString ) //convert a string to a character array |
LvdK | 7:6576a287e563 | 98 | { |
LvdK | 7:6576a287e563 | 99 | int nStrLen=cString.size(); |
LvdK | 7:6576a287e563 | 100 | std::string cInput( cString ); |
LvdK | 7:6576a287e563 | 101 | char* cText = new char[nStrLen+1]; |
LvdK | 7:6576a287e563 | 102 | strncpy(cText, cInput.c_str(), nStrLen); |
LvdK | 7:6576a287e563 | 103 | cText[nStrLen] = '\0'; |
LvdK | 7:6576a287e563 | 104 | return cText; |
LvdK | 7:6576a287e563 | 105 | } |
LvdK | 8:422544d24df3 | 106 | |
LvdK | 7:6576a287e563 | 107 | int centertext( string cString, int nChars, int nCharWidth ) |
LvdK | 7:6576a287e563 | 108 | //calculates the startposition on the screen to center the text |
LvdK | 7:6576a287e563 | 109 | //needs the actual string (cString), screenwidth in characters (nChars) and the character width (nCharWidth) |
LvdK | 7:6576a287e563 | 110 | { |
LvdK | 7:6576a287e563 | 111 | int nStart; |
LvdK | 7:6576a287e563 | 112 | nStart = nCharWidth*( nChars/2-( cString.size()/2 )); |
LvdK | 7:6576a287e563 | 113 | return nStart; |
LvdK | 7:6576a287e563 | 114 | } |
LvdK | 8:422544d24df3 | 115 | |
LvdK | 7:6576a287e563 | 116 | int righttext( string cString, int nChars, int nCharWidth ) |
LvdK | 7:6576a287e563 | 117 | //calculates the startposition on the screen to right-align the text |
LvdK | 7:6576a287e563 | 118 | //needs the actual string (cString), screenwidth in characters (nChars) and the character width (nCharWidth) |
LvdK | 7:6576a287e563 | 119 | { |
LvdK | 7:6576a287e563 | 120 | int nStart; |
LvdK | 7:6576a287e563 | 121 | nStart = nCharWidth*( nChars - cString.size()); |
LvdK | 7:6576a287e563 | 122 | return nStart; |
LvdK | 7:6576a287e563 | 123 | } |
WillemBraat | 13:d60c746c097c | 124 | |
LvdK | 7:6576a287e563 | 125 | int nFontSize( int nfont_number ) |
LvdK | 7:6576a287e563 | 126 | { |
LvdK | 8:422544d24df3 | 127 | int nFontWidth = 24; |
LvdK | 7:6576a287e563 | 128 | switch ( nfont_number ) |
LvdK | 7:6576a287e563 | 129 | { |
LvdK | 7:6576a287e563 | 130 | case 0: |
LvdK | 7:6576a287e563 | 131 | { |
LvdK | 8:422544d24df3 | 132 | nFontWidth = SMALLCHAR; |
LvdK | 8:422544d24df3 | 133 | //nFontWidth = FONT_12X34; |
LvdK | 7:6576a287e563 | 134 | break; |
LvdK | 7:6576a287e563 | 135 | } |
LvdK | 7:6576a287e563 | 136 | case 1: |
LvdK | 7:6576a287e563 | 137 | { |
LvdK | 8:422544d24df3 | 138 | nFontWidth = LARGECHAR; |
LvdK | 8:422544d24df3 | 139 | //nFontWidth = FONT_24X34; |
LvdK | 7:6576a287e563 | 140 | break; |
LvdK | 7:6576a287e563 | 141 | } |
LvdK | 7:6576a287e563 | 142 | } |
LvdK | 8:422544d24df3 | 143 | return ( nFontWidth ); |
LvdK | 8:422544d24df3 | 144 | } |
LvdK | 7:6576a287e563 | 145 | |
LvdK | 7:6576a287e563 | 146 | int nFontWidth (int nfont_number ) |
LvdK | 7:6576a287e563 | 147 | { |
LvdK | 7:6576a287e563 | 148 | int nFont = 12; |
LvdK | 7:6576a287e563 | 149 | switch ( nfont_number ) |
LvdK | 7:6576a287e563 | 150 | { |
LvdK | 7:6576a287e563 | 151 | case 0: |
LvdK | 7:6576a287e563 | 152 | { |
LvdK | 7:6576a287e563 | 153 | nFont = 12; |
LvdK | 7:6576a287e563 | 154 | break; |
LvdK | 7:6576a287e563 | 155 | } |
LvdK | 7:6576a287e563 | 156 | case 1: |
LvdK | 7:6576a287e563 | 157 | { |
LvdK | 7:6576a287e563 | 158 | nFont = 24; |
LvdK | 7:6576a287e563 | 159 | break; |
LvdK | 7:6576a287e563 | 160 | } |
LvdK | 7:6576a287e563 | 161 | } |
LvdK | 7:6576a287e563 | 162 | return ( nFont ); |
LvdK | 8:422544d24df3 | 163 | } |
LvdK | 7:6576a287e563 | 164 | |
LvdK | 7:6576a287e563 | 165 | unsigned int cRGB( char cRED, char cGREEN, char cBLUE ) |
LvdK | 7:6576a287e563 | 166 | { |
LvdK | 7:6576a287e563 | 167 | //assemble separate colors into 1 integer value as 0xRRGGBB |
LvdK | 7:6576a287e563 | 168 | //Display driver requires this format |
LvdK | 7:6576a287e563 | 169 | unsigned int RGB = cBLUE + 256*cGREEN + 65536*cRED; |
LvdK | 7:6576a287e563 | 170 | return ( RGB ); |
LvdK | 8:422544d24df3 | 171 | } |
LvdK | 7:6576a287e563 | 172 | |
LvdK | 7:6576a287e563 | 173 | int LeftOrRight( int nTextLine, string cString, int nChars, int nCharWidth ) |
LvdK | 7:6576a287e563 | 174 | { |
LvdK | 8:422544d24df3 | 175 | // nChars is the maximum numbers of characters on the line |
LvdK | 8:422544d24df3 | 176 | // nCharWidth is the characterwidth in pixels |
LvdK | 7:6576a287e563 | 177 | //decide to print data left aligned or right aligned |
LvdK | 7:6576a287e563 | 178 | //00 - 49 is left side of screen |
LvdK | 7:6576a287e563 | 179 | //50 - 99 is right side of screen |
LvdK | 8:422544d24df3 | 180 | int nHorPos = 0; |
LvdK | 7:6576a287e563 | 181 | // nChars is number of characters on this line (24 or 48) |
LvdK | 7:6576a287e563 | 182 | // nCharWidth is the character width in pixels |
LvdK | 8:422544d24df3 | 183 | |
LvdK | 7:6576a287e563 | 184 | if ( nTextLine < 50 ) |
LvdK | 7:6576a287e563 | 185 | // Left side adjust |
LvdK | 7:6576a287e563 | 186 | { |
LvdK | 7:6576a287e563 | 187 | nHorPos = 0; |
LvdK | 7:6576a287e563 | 188 | } |
LvdK | 7:6576a287e563 | 189 | else |
LvdK | 7:6576a287e563 | 190 | // Right side adjust |
LvdK | 7:6576a287e563 | 191 | { |
LvdK | 7:6576a287e563 | 192 | nHorPos = righttext( cString, nChars, nCharWidth ); |
LvdK | 7:6576a287e563 | 193 | } |
LvdK | 7:6576a287e563 | 194 | return ( nHorPos ); |
LvdK | 7:6576a287e563 | 195 | } |
WillemBraat | 18:fd672797458c | 196 | |
LvdK | 7:6576a287e563 | 197 | int nLine2Pixel( int nLine ) |
LvdK | 7:6576a287e563 | 198 | { |
LvdK | 7:6576a287e563 | 199 | //calculate vertical pixelposition from linenumber |
LvdK | 7:6576a287e563 | 200 | int nPixel = 0; |
LvdK | 7:6576a287e563 | 201 | switch ( nLine ) |
LvdK | 7:6576a287e563 | 202 | { |
LvdK | 7:6576a287e563 | 203 | case 1: |
LvdK | 7:6576a287e563 | 204 | { |
LvdK | 7:6576a287e563 | 205 | nPixel = LINE1; |
LvdK | 7:6576a287e563 | 206 | break; |
LvdK | 7:6576a287e563 | 207 | } |
LvdK | 7:6576a287e563 | 208 | case 2: |
LvdK | 7:6576a287e563 | 209 | { |
LvdK | 7:6576a287e563 | 210 | nPixel = LINE2; |
LvdK | 7:6576a287e563 | 211 | break; |
LvdK | 7:6576a287e563 | 212 | } |
LvdK | 8:422544d24df3 | 213 | |
LvdK | 7:6576a287e563 | 214 | case 3: |
LvdK | 7:6576a287e563 | 215 | { |
LvdK | 7:6576a287e563 | 216 | nPixel = LINE3; |
LvdK | 7:6576a287e563 | 217 | break; |
LvdK | 7:6576a287e563 | 218 | } |
LvdK | 8:422544d24df3 | 219 | |
LvdK | 7:6576a287e563 | 220 | case 4: |
LvdK | 7:6576a287e563 | 221 | { |
LvdK | 7:6576a287e563 | 222 | nPixel = LINE4; |
LvdK | 7:6576a287e563 | 223 | break; |
LvdK | 7:6576a287e563 | 224 | } |
LvdK | 8:422544d24df3 | 225 | |
LvdK | 7:6576a287e563 | 226 | case 5: |
LvdK | 7:6576a287e563 | 227 | { |
LvdK | 7:6576a287e563 | 228 | nPixel = LINE5; |
LvdK | 7:6576a287e563 | 229 | break; |
LvdK | 7:6576a287e563 | 230 | } |
LvdK | 8:422544d24df3 | 231 | |
LvdK | 7:6576a287e563 | 232 | case 6: |
LvdK | 7:6576a287e563 | 233 | { |
LvdK | 7:6576a287e563 | 234 | nPixel = LINE6; |
LvdK | 7:6576a287e563 | 235 | break; |
LvdK | 7:6576a287e563 | 236 | } |
LvdK | 8:422544d24df3 | 237 | |
LvdK | 7:6576a287e563 | 238 | case 7: |
LvdK | 7:6576a287e563 | 239 | { |
LvdK | 7:6576a287e563 | 240 | nPixel = LINE7; |
LvdK | 7:6576a287e563 | 241 | break; |
LvdK | 7:6576a287e563 | 242 | } |
LvdK | 8:422544d24df3 | 243 | |
LvdK | 7:6576a287e563 | 244 | case 8: |
LvdK | 7:6576a287e563 | 245 | { |
LvdK | 7:6576a287e563 | 246 | nPixel = LINE8; |
LvdK | 7:6576a287e563 | 247 | break; |
LvdK | 7:6576a287e563 | 248 | } |
LvdK | 8:422544d24df3 | 249 | |
LvdK | 7:6576a287e563 | 250 | case 9: |
LvdK | 7:6576a287e563 | 251 | { |
LvdK | 7:6576a287e563 | 252 | nPixel = LINE9; |
LvdK | 7:6576a287e563 | 253 | break; |
LvdK | 7:6576a287e563 | 254 | } |
LvdK | 8:422544d24df3 | 255 | |
LvdK | 7:6576a287e563 | 256 | case 10: |
LvdK | 7:6576a287e563 | 257 | { |
LvdK | 7:6576a287e563 | 258 | nPixel = LINE10; |
LvdK | 7:6576a287e563 | 259 | break; |
LvdK | 7:6576a287e563 | 260 | } |
LvdK | 8:422544d24df3 | 261 | |
LvdK | 7:6576a287e563 | 262 | case 11: |
LvdK | 7:6576a287e563 | 263 | { |
LvdK | 7:6576a287e563 | 264 | nPixel = LINE11; |
LvdK | 7:6576a287e563 | 265 | break; |
LvdK | 7:6576a287e563 | 266 | } |
LvdK | 8:422544d24df3 | 267 | |
LvdK | 7:6576a287e563 | 268 | case 12: |
LvdK | 7:6576a287e563 | 269 | { |
LvdK | 7:6576a287e563 | 270 | nPixel = LINE12; |
LvdK | 7:6576a287e563 | 271 | break; |
LvdK | 7:6576a287e563 | 272 | } |
LvdK | 8:422544d24df3 | 273 | |
LvdK | 7:6576a287e563 | 274 | case 13: |
LvdK | 7:6576a287e563 | 275 | { |
LvdK | 7:6576a287e563 | 276 | nPixel = LINE13; |
LvdK | 7:6576a287e563 | 277 | break; |
LvdK | 7:6576a287e563 | 278 | } |
LvdK | 8:422544d24df3 | 279 | |
LvdK | 7:6576a287e563 | 280 | case 14: |
LvdK | 7:6576a287e563 | 281 | { |
LvdK | 7:6576a287e563 | 282 | nPixel = LINE14; |
LvdK | 7:6576a287e563 | 283 | break; |
LvdK | 7:6576a287e563 | 284 | } |
LvdK | 8:422544d24df3 | 285 | |
LvdK | 7:6576a287e563 | 286 | } |
LvdK | 7:6576a287e563 | 287 | return ( nPixel ) ; |
LvdK | 7:6576a287e563 | 288 | } |
WillemBraat | 18:fd672797458c | 289 | |
LvdK | 7:6576a287e563 | 290 | void VGA_SIGNAL( int Source, int On_Off) |
LvdK | 7:6576a287e563 | 291 | { |
LvdK | 7:6576a287e563 | 292 | VGA_SOURCE = Source; |
LvdK | 7:6576a287e563 | 293 | VGA_SELECT = On_Off; |
LvdK | 7:6576a287e563 | 294 | } |
WillemBraat | 18:fd672797458c | 295 | |
LvdK | 7:6576a287e563 | 296 | void CDU_InitDisplay() |
LvdK | 7:6576a287e563 | 297 | { |
LvdK | 7:6576a287e563 | 298 | display.baudrate( 9600 ); //init uVGAIII card |
LvdK | 7:6576a287e563 | 299 | VGA_SIGNAL( VGA_INT, VGA_ON ); //select INTERNTAL video and set VGA switch ON |
LvdK | 7:6576a287e563 | 300 | } |
WillemBraat | 18:fd672797458c | 301 | |
WillemBraat | 18:fd672797458c | 302 | string CDU_Hardware() |
WillemBraat | 18:fd672797458c | 303 | { |
WillemBraat | 18:fd672797458c | 304 | string cHardware = "HW version: "; |
WillemBraat | 18:fd672797458c | 305 | char buf[10]; |
WillemBraat | 18:fd672797458c | 306 | sprintf(buf, "%d", HW_VERSION_MAIN ); |
WillemBraat | 18:fd672797458c | 307 | cHardware += buf; |
WillemBraat | 18:fd672797458c | 308 | cHardware += "."; |
WillemBraat | 18:fd672797458c | 309 | sprintf(buf, "%d", HW_VERSION_SUB ); |
WillemBraat | 18:fd672797458c | 310 | cHardware += buf; |
WillemBraat | 18:fd672797458c | 311 | return cHardware; |
WillemBraat | 18:fd672797458c | 312 | } |
WillemBraat | 18:fd672797458c | 313 | |
WillemBraat | 18:fd672797458c | 314 | string CDU_Firmware() |
WillemBraat | 18:fd672797458c | 315 | { |
WillemBraat | 18:fd672797458c | 316 | string cFirmware = "FW version: "; |
WillemBraat | 18:fd672797458c | 317 | char buf[10]; |
WillemBraat | 18:fd672797458c | 318 | sprintf(buf, "%d", SW_VERSION_MAIN ); |
WillemBraat | 18:fd672797458c | 319 | cFirmware += buf; |
WillemBraat | 18:fd672797458c | 320 | cFirmware += "."; |
WillemBraat | 18:fd672797458c | 321 | sprintf(buf, "%d", SW_VERSION_SUB ); |
WillemBraat | 18:fd672797458c | 322 | cFirmware += buf; |
WillemBraat | 18:fd672797458c | 323 | return cFirmware; |
WillemBraat | 18:fd672797458c | 324 | } |
WillemBraat | 18:fd672797458c | 325 | |
WillemBraat | 18:fd672797458c | 326 | string CDU_Compile() |
WillemBraat | 18:fd672797458c | 327 | { |
WillemBraat | 18:fd672797458c | 328 | string cCompile = "FW Timestamp: " ; |
WillemBraat | 18:fd672797458c | 329 | cCompile += __DATE__; |
WillemBraat | 18:fd672797458c | 330 | cCompile += " "; |
WillemBraat | 18:fd672797458c | 331 | cCompile += __TIME__; |
WillemBraat | 18:fd672797458c | 332 | return cCompile ; |
WillemBraat | 18:fd672797458c | 333 | } |
WillemBraat | 18:fd672797458c | 334 | |
LvdK | 7:6576a287e563 | 335 | void CDU_StartScreen() |
LvdK | 8:422544d24df3 | 336 | { |
LvdK | 7:6576a287e563 | 337 | string cTitle1="ENGRAVITY"; |
LvdK | 7:6576a287e563 | 338 | string cTitle2="CONTROL & DISPLAY UNIT"; |
WillemBraat | 18:fd672797458c | 339 | |
WillemBraat | 18:fd672797458c | 340 | |
LvdK | 8:422544d24df3 | 341 | display.cls(); |
LvdK | 7:6576a287e563 | 342 | |
LvdK | 7:6576a287e563 | 343 | display.graphic_string( str2char( cTitle1 ), centertext( cTitle1, 24, LARGECHAR), LINE6, FONT_24X34, WHITE, 1, 1 ); |
LvdK | 8:422544d24df3 | 344 | wait_ms(100); |
LvdK | 7:6576a287e563 | 345 | display.graphic_string( str2char( cTitle2 ), centertext( cTitle2, 24, LARGECHAR), LINE8, FONT_24X34, RED, 1, 1 ); |
LvdK | 8:422544d24df3 | 346 | wait_ms(100); |
LvdK | 7:6576a287e563 | 347 | display.graphic_string( str2char( cTitle2 ), centertext( cTitle2, 24, LARGECHAR), LINE8, FONT_24X34, GREEN, 1, 1 ); |
LvdK | 8:422544d24df3 | 348 | wait_ms(100); |
LvdK | 7:6576a287e563 | 349 | display.graphic_string( str2char( cTitle2) , centertext( cTitle2, 24, LARGECHAR), LINE8, FONT_24X34, BLUE, 1, 1 ); |
LvdK | 8:422544d24df3 | 350 | wait_ms(100); |
WillemBraat | 18:fd672797458c | 351 | |
WillemBraat | 18:fd672797458c | 352 | display.cls(); |
WillemBraat | 18:fd672797458c | 353 | //Firmware information |
WillemBraat | 18:fd672797458c | 354 | display.graphic_string( str2char( CDU_Hardware() ), centertext( CDU_Hardware(), 48, SMALLCHAR), LINE6, FONT_12X34, WHITE, 1, 1 ); |
WillemBraat | 18:fd672797458c | 355 | display.graphic_string( str2char( CDU_Firmware() ), centertext( CDU_Firmware(), 48, SMALLCHAR), LINE7, FONT_12X34, WHITE, 1, 1 ); |
WillemBraat | 18:fd672797458c | 356 | display.graphic_string( str2char( CDU_Compile() ), centertext( CDU_Compile(), 48, SMALLCHAR), LINE8, FONT_12X34, WHITE, 1, 1 ); |
WillemBraat | 18:fd672797458c | 357 | wait_ms(5000); |
LvdK | 8:422544d24df3 | 358 | } |
WillemBraat | 18:fd672797458c | 359 | |
LvdK | 7:6576a287e563 | 360 | void CDU_ScreenAlign() |
LvdK | 7:6576a287e563 | 361 | //Draw a wireframe for aligning the screen on display with keys |
LvdK | 7:6576a287e563 | 362 | { |
LvdK | 7:6576a287e563 | 363 | display.cls(); |
LvdK | 8:422544d24df3 | 364 | |
LvdK | 7:6576a287e563 | 365 | display.pen_size(WIREFRAME); |
LvdK | 7:6576a287e563 | 366 | display.rectangle(XMIN,YMIN,XMAX,YMAX, WHITE); |
LvdK | 7:6576a287e563 | 367 | display.line(XMIN,LINE2,XMAX,LINE2, WHITE); |
LvdK | 7:6576a287e563 | 368 | display.line(XMIN,LINE3,XMAX,LINE3, WHITE); |
LvdK | 7:6576a287e563 | 369 | display.line(XMIN,LINE4,XMAX,LINE4, WHITE); |
LvdK | 7:6576a287e563 | 370 | display.line(XMIN,LINE5,XMAX,LINE5, WHITE); |
LvdK | 7:6576a287e563 | 371 | display.line(XMIN,LINE6,XMAX,LINE6, WHITE); |
LvdK | 7:6576a287e563 | 372 | display.line(XMIN,LINE7,XMAX,LINE7, WHITE); |
LvdK | 7:6576a287e563 | 373 | display.line(XMIN,LINE8,XMAX,LINE8, WHITE); |
LvdK | 7:6576a287e563 | 374 | display.line(XMIN,LINE9,XMAX,LINE9, WHITE); |
LvdK | 7:6576a287e563 | 375 | display.line(XMIN,LINE10,XMAX,LINE10, WHITE); |
LvdK | 7:6576a287e563 | 376 | display.line(XMIN,LINE11,XMAX,LINE11, WHITE); |
LvdK | 7:6576a287e563 | 377 | display.line(XMIN,LINE12,XMAX,LINE12, WHITE); |
LvdK | 7:6576a287e563 | 378 | display.line(XMIN,LINE13,XMAX,LINE13, WHITE); |
LvdK | 7:6576a287e563 | 379 | display.line(XMIN,LINE14,XMAX,LINE14, WHITE); |
LvdK | 7:6576a287e563 | 380 | } |
LvdK | 7:6576a287e563 | 381 | void CDU_TestScreen() |
LvdK | 7:6576a287e563 | 382 | { |
LvdK | 7:6576a287e563 | 383 | display.display_control(IMAGE_FORMAT, NEW); //set correct image for reading from SD |
LvdK | 7:6576a287e563 | 384 | display.cls(); |
LvdK | 7:6576a287e563 | 385 | display.showpicture(0x00, 0x00, 0x00, 0x14, 0x00, 0x01, 0xB5); // Testscreen |
LvdK | 7:6576a287e563 | 386 | } |
LvdK | 7:6576a287e563 | 387 | void CDU_LogoScreen() |
LvdK | 7:6576a287e563 | 388 | { |
LvdK | 8:422544d24df3 | 389 | display.display_control(IMAGE_FORMAT, NEW); //set correct image for reading from SD |
LvdK | 7:6576a287e563 | 390 | display.cls(); |
LvdK | 7:6576a287e563 | 391 | display.showpicture(0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00); // Engravity logo |
LvdK | 7:6576a287e563 | 392 | } |
LvdK | 8:422544d24df3 | 393 | |
LvdK | 7:6576a287e563 | 394 | void CDU_Page() |
LvdK | 7:6576a287e563 | 395 | { |
LvdK | 7:6576a287e563 | 396 | display.cls(); |
LvdK | 7:6576a287e563 | 397 | display.graphic_string( "PERF INIT" , 8*24, LINE1, FONT_24X34, WHITE, 1, 1 ); |
LvdK | 8:422544d24df3 | 398 | |
LvdK | 7:6576a287e563 | 399 | display.graphic_string( "GW/CRZ CG" , 0, LINE2, FONT_12X34, WHITE, 1, 1 ); |
LvdK | 7:6576a287e563 | 400 | display.graphic_string( "CRZ ALT" , 41*12, LINE2, FONT_12X34, WHITE, 1, 1 ); |
LvdK | 8:422544d24df3 | 401 | |
LvdK | 7:6576a287e563 | 402 | display.graphic_string( "___._ / 26.2%" , 0, LINE3, FONT_24X34, WHITE, 1, 1 ); |
LvdK | 7:6576a287e563 | 403 | display.graphic_string( "_____" , 19*24, LINE3, FONT_24X34, WHITE, 1, 1 ); |
LvdK | 7:6576a287e563 | 404 | display.graphic_string( "FUEL" , 0, LINE4, FONT_12X34, WHITE, 1, 1 ); |
LvdK | 7:6576a287e563 | 405 | display.graphic_string( "CRZ/WIND" , 40*12, LINE4, FONT_12X34, WHITE, 1, 1 ); |
LvdK | 8:422544d24df3 | 406 | |
LvdK | 7:6576a287e563 | 407 | display.graphic_string( "0.0" , 0, LINE5, FONT_24X34, WHITE, 1, 1 ); |
LvdK | 7:6576a287e563 | 408 | display.graphic_string( "000$ /---" , 15*24, LINE5, FONT_24X34, WHITE, 1, 1 ); |
LvdK | 8:422544d24df3 | 409 | |
LvdK | 7:6576a287e563 | 410 | display.graphic_string( "ZFW" , 0, LINE6, FONT_12X34, WHITE, 1, 1 ); |
LvdK | 7:6576a287e563 | 411 | display.graphic_string( "___._ " , 0, LINE7, FONT_24X34, WHITE, 1, 1 ); |
LvdK | 8:422544d24df3 | 412 | |
LvdK | 7:6576a287e563 | 413 | display.graphic_string( "RESERVES" , 0, LINE8, FONT_12X34, WHITE, 1, 1 ); |
LvdK | 7:6576a287e563 | 414 | display.graphic_string( "__._ " , 0, LINE9, FONT_24X34, WHITE, 1, 1 ); |
LvdK | 8:422544d24df3 | 415 | |
LvdK | 7:6576a287e563 | 416 | display.graphic_string( "COST INDEX" , 0, LINE10, FONT_12X34, WHITE, 1, 1 ); |
LvdK | 8:422544d24df3 | 417 | display.graphic_string( "TRANS ALT" , 39*12, LINE10, FONT_12X34, WHITE, 1, 1 ); |
LvdK | 7:6576a287e563 | 418 | |
LvdK | 7:6576a287e563 | 419 | display.graphic_string( "___" , 0, LINE11, FONT_24X34, WHITE, 1, 1 ); |
LvdK | 7:6576a287e563 | 420 | display.graphic_string( "_____" , 19*24, LINE11, FONT_24X34, WHITE, 1, 1 ); |
LvdK | 8:422544d24df3 | 421 | |
LvdK | 8:422544d24df3 | 422 | display.graphic_string( "------------------------------------------------" , 0, LINE12, FONT_12X34, WHITE, 1, 1 ); |
LvdK | 7:6576a287e563 | 423 | |
LvdK | 7:6576a287e563 | 424 | display.graphic_string( "<INDEX" , 0, LINE13, FONT_24X34, WHITE, 1, 1 ); |
LvdK | 7:6576a287e563 | 425 | display.graphic_string( "N1 LIMIT>" , 15*24, LINE13, FONT_24X34, WHITE, 1, 1 ); |
LvdK | 8:422544d24df3 | 426 | |
LvdK | 7:6576a287e563 | 427 | display.graphic_string( "SCRATCHPAD DATA LINE", centertext("SCRATCHPAD DATA LINE", 24, LARGECHAR) , LINE14, FONT_24X34, RED, 1, 1 ); |
LvdK | 8:422544d24df3 | 428 | |
LvdK | 7:6576a287e563 | 429 | } |
LvdK | 8:422544d24df3 | 430 | |
LvdK | 7:6576a287e563 | 431 | void CDU_displayclear(){ |
LvdK | 7:6576a287e563 | 432 | display.cls(); |
LvdK | 7:6576a287e563 | 433 | } |
LvdK | 8:422544d24df3 | 434 | |
LvdK | 7:6576a287e563 | 435 |