voor willem test

Dependencies:   4DGL MODSERIAL mbed mbos

Committer:
LvdK
Date:
Tue Jan 29 14:54:14 2013 +0000
Revision:
6:e0bf3b244d7c
Goed werkende mbos versie met 0.5 sec ALIVE message

Who changed what in which revision?

UserRevisionLine numberNew contents of line
LvdK 6:e0bf3b244d7c 1 // L. van der Kolk, ELVEDEKA, Holland //
LvdK 6:e0bf3b244d7c 2 // File: FS2CDU_data_2.cpp
LvdK 6:e0bf3b244d7c 3
LvdK 6:e0bf3b244d7c 4 #include "mbed.h"
LvdK 6:e0bf3b244d7c 5 #include "MODSERIAL.h"
LvdK 6:e0bf3b244d7c 6
LvdK 6:e0bf3b244d7c 7 // ---- FS-to-CDU data structures filled with received data ---------------------------------------
LvdK 6:e0bf3b244d7c 8 #define max_text0 48 // max text length font 0
LvdK 6:e0bf3b244d7c 9 #define max_text1 24 // max text length font 1
LvdK 6:e0bf3b244d7c 10 #define max_lines 14 // max nr of screen lines
LvdK 6:e0bf3b244d7c 11 #define max_font 1 // possible fonts are 0 to max_font, so now 0 and 1 possible
LvdK 6:e0bf3b244d7c 12 #define max_col_nr 255 // highest possible R,G, or B colour number
LvdK 6:e0bf3b244d7c 13 #define fstyle_1 'S' // possible font style character 1
LvdK 6:e0bf3b244d7c 14 #define fstyle_2 'N' // possible font style character 2
LvdK 6:e0bf3b244d7c 15 #define max_keys 100 // max total nr of select keys 0 - 99
LvdK 6:e0bf3b244d7c 16 #define max_leftkeys 6 // max nr of used LEFT select keys ( 0 - 49 )
LvdK 6:e0bf3b244d7c 17 #define max_rightkeys 6 // max nr of used RIGHT select keys ( 50 - 99 )
LvdK 6:e0bf3b244d7c 18
LvdK 6:e0bf3b244d7c 19 // Background colour of display:
LvdK 6:e0bf3b244d7c 20 struct { int RED; // : RED value
LvdK 6:e0bf3b244d7c 21 int GREEN; // : GREEN value
LvdK 6:e0bf3b244d7c 22 int BLUE; // : BLUE value
LvdK 6:e0bf3b244d7c 23 int updated; // : update flag, true when background colour was updated
LvdK 6:e0bf3b244d7c 24 } BACKGROUND_COL;
LvdK 6:e0bf3b244d7c 25
LvdK 6:e0bf3b244d7c 26 // Maintext lines at selectkeys:
LvdK 6:e0bf3b244d7c 27 struct { char text[max_text0+2]; // : maintext string, ending with '\0'
LvdK 6:e0bf3b244d7c 28 int font_size; // : fontsize
LvdK 6:e0bf3b244d7c 29 char font_style; // : style character
LvdK 6:e0bf3b244d7c 30 int text_RED; // : RED value of textline
LvdK 6:e0bf3b244d7c 31 int text_GREEN; // : GREEN value of textline
LvdK 6:e0bf3b244d7c 32 int text_BLUE; // : BLUE value of textline
LvdK 6:e0bf3b244d7c 33 int updated; // : update flag, true when a selectkey maintext was updated
LvdK 6:e0bf3b244d7c 34 } SELKEY_MAINTEXT[max_keys];// : array of selectkey Maintext structures
LvdK 6:e0bf3b244d7c 35
LvdK 6:e0bf3b244d7c 36 // Subtext lines at selectkeys:
LvdK 6:e0bf3b244d7c 37 struct { char text[max_text0+2]; // : subtext string, ending with '\0'
LvdK 6:e0bf3b244d7c 38 int font_size; // : fontsize
LvdK 6:e0bf3b244d7c 39 char font_style; // : style character
LvdK 6:e0bf3b244d7c 40 int text_RED; // : RED value of textline
LvdK 6:e0bf3b244d7c 41 int text_GREEN; // : GREEN value of textline
LvdK 6:e0bf3b244d7c 42 int text_BLUE; // : BLUE value of textline
LvdK 6:e0bf3b244d7c 43 int updated; // : update flag, true when a selectkey subtext was updated
LvdK 6:e0bf3b244d7c 44 } SELKEY_SUBTEXT[max_keys]; // : array of selectkey Subtext structures
LvdK 6:e0bf3b244d7c 45
LvdK 6:e0bf3b244d7c 46 // Screen textlines:
LvdK 6:e0bf3b244d7c 47 struct { char text[max_text0+2]; // : text line string, ending with '\0'
LvdK 6:e0bf3b244d7c 48 int font_size; // : fontsize of textline
LvdK 6:e0bf3b244d7c 49 char font_style; // : style character
LvdK 6:e0bf3b244d7c 50 int text_RED; // : RED value of textline
LvdK 6:e0bf3b244d7c 51 int text_GREEN; // : GREEN value of textline
LvdK 6:e0bf3b244d7c 52 int text_BLUE; // : BLUE value of textline
LvdK 6:e0bf3b244d7c 53 int updated; // : update flag, true when a textline was updated
LvdK 6:e0bf3b244d7c 54 } TEXTLINE[max_lines+1]; // : array of textline structures
LvdK 6:e0bf3b244d7c 55
LvdK 6:e0bf3b244d7c 56 // CDU status:
LvdK 6:e0bf3b244d7c 57 struct { int mess_light; // : 0 = light OFF, 1 = light ON
LvdK 6:e0bf3b244d7c 58 int exec_indicator; // : 0 = indicator OFF, 1 = indicator ON
LvdK 6:e0bf3b244d7c 59 int backlight; // : 0 = light OFF, 1 = light ON
LvdK 6:e0bf3b244d7c 60 int stby_mode; // : 0 = operational mode, 1 = standby mode
LvdK 6:e0bf3b244d7c 61 int updated; // : update flag, true when one or more status items were updated
LvdK 6:e0bf3b244d7c 62 } CDU_STATUS;
LvdK 6:e0bf3b244d7c 63
LvdK 6:e0bf3b244d7c 64 // Clear screen flag:
LvdK 6:e0bf3b244d7c 65 int DO_CLR_SCREEN = false; // : Clear screen flag, true = perform a clear-screen
LvdK 6:e0bf3b244d7c 66
LvdK 6:e0bf3b244d7c 67 // CDU settings:
LvdK 6:e0bf3b244d7c 68 struct { int Baud; // : Baudrate can be 2400, 4800, 9600, 19200, 38400
LvdK 6:e0bf3b244d7c 69 char Firmware_nr[15]; // : firmware ID string, terminated with '\0' !
LvdK 6:e0bf3b244d7c 70 char CDU_type[15]; // : CDU type ID string, terminated with '\0' !
LvdK 6:e0bf3b244d7c 71 int Serial_nr; // : integer serial number
LvdK 6:e0bf3b244d7c 72 char IP_address[20]; // : IP address, 0.0.0.0 to 255.255.255.255 , terminated with '\0' !
LvdK 6:e0bf3b244d7c 73 int Port_nr; // : integer Port number
LvdK 6:e0bf3b244d7c 74 char Server_ip[20]; // : IP address of server , terminated with '\0' !
LvdK 6:e0bf3b244d7c 75 int updated; // : update flag, true when one or more items were updated
LvdK 6:e0bf3b244d7c 76 } CDU_SET;
LvdK 6:e0bf3b244d7c 77
LvdK 6:e0bf3b244d7c 78 // Common flag to signal that one or more updates were performed:
LvdK 6:e0bf3b244d7c 79 int FSdata_received_flag = false; // : true when one or more FS-to-CDU data was updated
LvdK 6:e0bf3b244d7c 80 // --------------------------------------------------------------------------------------------------
LvdK 6:e0bf3b244d7c 81
LvdK 6:e0bf3b244d7c 82 extern MODSERIAL USB; // >>>>>>>>>>> alleen t.b.v TEST output !!
LvdK 6:e0bf3b244d7c 83 extern char string_received[];
LvdK 6:e0bf3b244d7c 84 extern int comma[];
LvdK 6:e0bf3b244d7c 85
LvdK 6:e0bf3b244d7c 86 void Send_VAL_message(int var, char *char_pntr);
LvdK 6:e0bf3b244d7c 87
LvdK 6:e0bf3b244d7c 88 void set_initial_CDU_screen()
LvdK 6:e0bf3b244d7c 89 { // Fill all FS-to-CDU datastructures with data for initial power-up conditions:
LvdK 6:e0bf3b244d7c 90 int key_nr, line_nr;
LvdK 6:e0bf3b244d7c 91
LvdK 6:e0bf3b244d7c 92 FSdata_received_flag = true; // <<<<<<<<<<<<<< !
LvdK 6:e0bf3b244d7c 93
LvdK 6:e0bf3b244d7c 94 // Init background colour of screen :
LvdK 6:e0bf3b244d7c 95 BACKGROUND_COL.RED = 0;
LvdK 6:e0bf3b244d7c 96 BACKGROUND_COL.GREEN = 0;
LvdK 6:e0bf3b244d7c 97 BACKGROUND_COL.BLUE = 0;
LvdK 6:e0bf3b244d7c 98 BACKGROUND_COL.updated = true;
LvdK 6:e0bf3b244d7c 99
LvdK 6:e0bf3b244d7c 100 // Init Maintext at left selectkeys starting from 0 :
LvdK 6:e0bf3b244d7c 101 for ( key_nr = 0; key_nr < max_leftkeys; key_nr++ )
LvdK 6:e0bf3b244d7c 102 { SELKEY_MAINTEXT[key_nr].text_RED = 255;
LvdK 6:e0bf3b244d7c 103 SELKEY_MAINTEXT[key_nr].text_GREEN = 255;
LvdK 6:e0bf3b244d7c 104 SELKEY_MAINTEXT[key_nr].text_BLUE = 255;
LvdK 6:e0bf3b244d7c 105 SELKEY_MAINTEXT[key_nr].font_size = 0;
LvdK 6:e0bf3b244d7c 106 SELKEY_MAINTEXT[key_nr].font_style = fstyle_1;
LvdK 6:e0bf3b244d7c 107 strncpy(SELKEY_MAINTEXT[key_nr].text, "0|....key maintext..............................|\0",
LvdK 6:e0bf3b244d7c 108 max_text0 + 2 ); // (max_text0+2) chars copied
LvdK 6:e0bf3b244d7c 109 SELKEY_MAINTEXT[key_nr].updated = true;
LvdK 6:e0bf3b244d7c 110 }
LvdK 6:e0bf3b244d7c 111 // Init Maintext at right selectkeys starting from 50 :
LvdK 6:e0bf3b244d7c 112 for ( key_nr = 50; key_nr < (50+max_rightkeys); key_nr++ )
LvdK 6:e0bf3b244d7c 113 { SELKEY_MAINTEXT[key_nr].text_RED = 255;
LvdK 6:e0bf3b244d7c 114 SELKEY_MAINTEXT[key_nr].text_GREEN = 255;
LvdK 6:e0bf3b244d7c 115 SELKEY_MAINTEXT[key_nr].text_BLUE = 255;
LvdK 6:e0bf3b244d7c 116 SELKEY_MAINTEXT[key_nr].font_size = 0;
LvdK 6:e0bf3b244d7c 117 SELKEY_MAINTEXT[key_nr].font_style = fstyle_1;
LvdK 6:e0bf3b244d7c 118 strncpy(SELKEY_MAINTEXT[key_nr].text, "0|....key maintext..............................|\0",
LvdK 6:e0bf3b244d7c 119 max_text0 + 2 ); // (max_text0+2) chars copied
LvdK 6:e0bf3b244d7c 120 SELKEY_MAINTEXT[key_nr].updated = true;
LvdK 6:e0bf3b244d7c 121 }
LvdK 6:e0bf3b244d7c 122 // Init Subtext at left selectkeys starting from 0 :
LvdK 6:e0bf3b244d7c 123 for ( key_nr = 0; key_nr < max_leftkeys; key_nr++ )
LvdK 6:e0bf3b244d7c 124 { SELKEY_SUBTEXT[key_nr].text_RED = 255;
LvdK 6:e0bf3b244d7c 125 SELKEY_SUBTEXT[key_nr].text_GREEN = 255;
LvdK 6:e0bf3b244d7c 126 SELKEY_SUBTEXT[key_nr].text_BLUE = 255;
LvdK 6:e0bf3b244d7c 127 SELKEY_SUBTEXT[key_nr].font_size = 0;
LvdK 6:e0bf3b244d7c 128 SELKEY_SUBTEXT[key_nr].font_style = fstyle_1;
LvdK 6:e0bf3b244d7c 129 strncpy(SELKEY_SUBTEXT[key_nr].text, "0|....key subtext...............................|\0",
LvdK 6:e0bf3b244d7c 130 max_text0 + 2 ); // (max_text0+2) chars copied
LvdK 6:e0bf3b244d7c 131 SELKEY_SUBTEXT[key_nr].updated = true;
LvdK 6:e0bf3b244d7c 132 }
LvdK 6:e0bf3b244d7c 133 // Init Subtext at right selectkeys starting from 50 :
LvdK 6:e0bf3b244d7c 134 for ( key_nr = 50; key_nr < (50+max_rightkeys); key_nr++ )
LvdK 6:e0bf3b244d7c 135 { SELKEY_SUBTEXT[key_nr].text_RED = 255;
LvdK 6:e0bf3b244d7c 136 SELKEY_SUBTEXT[key_nr].text_GREEN = 255;
LvdK 6:e0bf3b244d7c 137 SELKEY_SUBTEXT[key_nr].text_BLUE = 255;
LvdK 6:e0bf3b244d7c 138 SELKEY_SUBTEXT[key_nr].font_size = 0;
LvdK 6:e0bf3b244d7c 139 SELKEY_SUBTEXT[key_nr].font_style = fstyle_1;
LvdK 6:e0bf3b244d7c 140 strncpy(SELKEY_SUBTEXT[key_nr].text, "0|....key subtext...............................|\0",
LvdK 6:e0bf3b244d7c 141 max_text0 + 2 ); // (max_text0+2) chars copied
LvdK 6:e0bf3b244d7c 142 SELKEY_SUBTEXT[key_nr].updated = true;
LvdK 6:e0bf3b244d7c 143 }
LvdK 6:e0bf3b244d7c 144 // Init screentext :
LvdK 6:e0bf3b244d7c 145 for ( line_nr = 1; line_nr <= 14; line_nr++ )
LvdK 6:e0bf3b244d7c 146 { TEXTLINE[line_nr].text_RED = 255;
LvdK 6:e0bf3b244d7c 147 TEXTLINE[line_nr].text_GREEN = 255;
LvdK 6:e0bf3b244d7c 148 TEXTLINE[line_nr].text_BLUE = 255;
LvdK 6:e0bf3b244d7c 149 TEXTLINE[line_nr].font_size = 0;
LvdK 6:e0bf3b244d7c 150 TEXTLINE[line_nr].font_style = fstyle_1;
LvdK 6:e0bf3b244d7c 151 strncpy(TEXTLINE[line_nr].text, "0|....text line.................................|\0",
LvdK 6:e0bf3b244d7c 152 max_text0 + 2 ); // (max_text0+2) chars copied
LvdK 6:e0bf3b244d7c 153 TEXTLINE[line_nr].updated = true;
LvdK 6:e0bf3b244d7c 154 }
LvdK 6:e0bf3b244d7c 155 // Init CDU status items:
LvdK 6:e0bf3b244d7c 156 CDU_STATUS.mess_light = 1;
LvdK 6:e0bf3b244d7c 157 CDU_STATUS.exec_indicator = 1;
LvdK 6:e0bf3b244d7c 158 CDU_STATUS.backlight = 1;
LvdK 6:e0bf3b244d7c 159 CDU_STATUS.stby_mode = 0;
LvdK 6:e0bf3b244d7c 160 CDU_STATUS.updated = true;
LvdK 6:e0bf3b244d7c 161
LvdK 6:e0bf3b244d7c 162 // Init Clear screen flag:
LvdK 6:e0bf3b244d7c 163 DO_CLR_SCREEN = false;
LvdK 6:e0bf3b244d7c 164
LvdK 6:e0bf3b244d7c 165 // INIT CDU settings:
LvdK 6:e0bf3b244d7c 166 CDU_SET.Baud = 38400; // : will be default baudrate
LvdK 6:e0bf3b244d7c 167 strcpy(CDU_SET.Firmware_nr, "v1.0a\0"); // copy chars incl. '\0'
LvdK 6:e0bf3b244d7c 168 strcpy(CDU_SET.CDU_type, "colour CDU\0"); // copy chars incl. '\0'
LvdK 6:e0bf3b244d7c 169 CDU_SET.Serial_nr = 12345;
LvdK 6:e0bf3b244d7c 170 strcpy(CDU_SET.IP_address, "255.255.255.123\0"); // copy chars incl. '\0'
LvdK 6:e0bf3b244d7c 171 CDU_SET.Port_nr = 4321;
LvdK 6:e0bf3b244d7c 172 strcpy(CDU_SET.Server_ip, "255.255.255.456\0"); // copy chars incl. '\0'
LvdK 6:e0bf3b244d7c 173 CDU_SET.updated = true;
LvdK 6:e0bf3b244d7c 174 }
LvdK 6:e0bf3b244d7c 175
LvdK 6:e0bf3b244d7c 176 void read_datafields(int command_number) {
LvdK 6:e0bf3b244d7c 177 // Function to read all comma seperated datafields in string_received[]
LvdK 6:e0bf3b244d7c 178 // and fill in FS-to-CDU data structures.
LvdK 6:e0bf3b244d7c 179 // Parameter is found command_number.
LvdK 6:e0bf3b244d7c 180 int colour, size, pos, line, last, cnt, k_id, var, a ;
LvdK 6:e0bf3b244d7c 181 int modified, char_pntr;
LvdK 6:e0bf3b244d7c 182 char val_string[25]; // <<<<<---------------------------------------------------------Local !!!!!
LvdK 6:e0bf3b244d7c 183 char ch;
LvdK 6:e0bf3b244d7c 184
LvdK 6:e0bf3b244d7c 185 modified = false;
LvdK 6:e0bf3b244d7c 186 switch ( command_number )
LvdK 6:e0bf3b244d7c 187 {
LvdK 6:e0bf3b244d7c 188 case 0:
LvdK 6:e0bf3b244d7c 189 { // 0 is no valid commandnumber
LvdK 6:e0bf3b244d7c 190 break;
LvdK 6:e0bf3b244d7c 191 }
LvdK 6:e0bf3b244d7c 192
LvdK 6:e0bf3b244d7c 193 case 1: // MSG command, message indicator control CDU
LvdK 6:e0bf3b244d7c 194 {
LvdK 6:e0bf3b244d7c 195 // Get message indicator status:
LvdK 6:e0bf3b244d7c 196 char_pntr = comma[1] + 1; // : set char pointer to char after comma 1
LvdK 6:e0bf3b244d7c 197 if (string_received[char_pntr] == '0' || string_received[char_pntr] == '1')
LvdK 6:e0bf3b244d7c 198 { CDU_STATUS.mess_light = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 199 CDU_STATUS.updated = true; // : signal update of CDU status
LvdK 6:e0bf3b244d7c 200 FSdata_received_flag = true; // : set common update flag
LvdK 6:e0bf3b244d7c 201 }
LvdK 6:e0bf3b244d7c 202 break;
LvdK 6:e0bf3b244d7c 203 }
LvdK 6:e0bf3b244d7c 204
LvdK 6:e0bf3b244d7c 205 case 2: // EXC command, exec indicator control CDU
LvdK 6:e0bf3b244d7c 206 {
LvdK 6:e0bf3b244d7c 207 // Get exec indicator status:
LvdK 6:e0bf3b244d7c 208 char_pntr = comma[1] + 1; // : set char pointer to char after comma 1
LvdK 6:e0bf3b244d7c 209 if (string_received[char_pntr] == '0' || string_received[char_pntr] == '1')
LvdK 6:e0bf3b244d7c 210 { CDU_STATUS.exec_indicator = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 211 CDU_STATUS.updated = true; // : signal update of of CDU status
LvdK 6:e0bf3b244d7c 212 FSdata_received_flag = true; // : set common update flag
LvdK 6:e0bf3b244d7c 213 }
LvdK 6:e0bf3b244d7c 214 break;
LvdK 6:e0bf3b244d7c 215 }
LvdK 6:e0bf3b244d7c 216
LvdK 6:e0bf3b244d7c 217 case 3: // BLT command, backlight control CDU
LvdK 6:e0bf3b244d7c 218 {
LvdK 6:e0bf3b244d7c 219 // Get backlight status:
LvdK 6:e0bf3b244d7c 220 char_pntr = comma[1] + 1; // : set char pointer to char after comma 1
LvdK 6:e0bf3b244d7c 221 if (string_received[char_pntr] == '0' || string_received[char_pntr] == '1')
LvdK 6:e0bf3b244d7c 222 { CDU_STATUS.backlight = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 223 CDU_STATUS.updated = true; // : signal update of of CDU status
LvdK 6:e0bf3b244d7c 224 FSdata_received_flag = true; // : set common update flag
LvdK 6:e0bf3b244d7c 225 }
LvdK 6:e0bf3b244d7c 226 break;
LvdK 6:e0bf3b244d7c 227 }
LvdK 6:e0bf3b244d7c 228
LvdK 6:e0bf3b244d7c 229 case 4: // SBY command, standby control CDU
LvdK 6:e0bf3b244d7c 230 {
LvdK 6:e0bf3b244d7c 231 // Get standby status:
LvdK 6:e0bf3b244d7c 232 char_pntr = comma[1] + 1; // : set char pointer to char after comma 1
LvdK 6:e0bf3b244d7c 233 if (string_received[char_pntr] == '0' || string_received[char_pntr] == '1')
LvdK 6:e0bf3b244d7c 234 { CDU_STATUS.stby_mode = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 235 CDU_STATUS.updated = true; // : signal update of CDU status
LvdK 6:e0bf3b244d7c 236 FSdata_received_flag = true; // : set common update flag
LvdK 6:e0bf3b244d7c 237 }
LvdK 6:e0bf3b244d7c 238 break;
LvdK 6:e0bf3b244d7c 239 }
LvdK 6:e0bf3b244d7c 240
LvdK 6:e0bf3b244d7c 241 case 5: // CLS command, CDU clear screen control
LvdK 6:e0bf3b244d7c 242 {
LvdK 6:e0bf3b244d7c 243 DO_CLR_SCREEN = true; // : tell to clear the screen
LvdK 6:e0bf3b244d7c 244 FSdata_received_flag = true; // : set common update flag
LvdK 6:e0bf3b244d7c 245 break;
LvdK 6:e0bf3b244d7c 246 }
LvdK 6:e0bf3b244d7c 247
LvdK 6:e0bf3b244d7c 248
LvdK 6:e0bf3b244d7c 249 case 6: // SBC command, screen background colour control
LvdK 6:e0bf3b244d7c 250 {
LvdK 6:e0bf3b244d7c 251 char_pntr = comma[1] + 1; // : set char pointer to char after comma 1
LvdK 6:e0bf3b244d7c 252 colour = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 253 if ( colour >= 0 && colour <= max_col_nr ) {
LvdK 6:e0bf3b244d7c 254 BACKGROUND_COL.RED = colour;
LvdK 6:e0bf3b244d7c 255 modified = true;
LvdK 6:e0bf3b244d7c 256 }
LvdK 6:e0bf3b244d7c 257 char_pntr = comma[2] + 1; // : set char pointer to char after comma 2
LvdK 6:e0bf3b244d7c 258 colour = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 259 if ( colour >= 0 && colour <= max_col_nr ) {
LvdK 6:e0bf3b244d7c 260 BACKGROUND_COL.GREEN = colour;
LvdK 6:e0bf3b244d7c 261 modified = true;
LvdK 6:e0bf3b244d7c 262 }
LvdK 6:e0bf3b244d7c 263 char_pntr = comma[3] + 1; // : set char pointer to char after comma 3
LvdK 6:e0bf3b244d7c 264 colour = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 265 if ( colour >= 0 && colour <= max_col_nr ) {
LvdK 6:e0bf3b244d7c 266 BACKGROUND_COL.BLUE = colour;
LvdK 6:e0bf3b244d7c 267 modified = true;
LvdK 6:e0bf3b244d7c 268 }
LvdK 6:e0bf3b244d7c 269 if ( modified == true )
LvdK 6:e0bf3b244d7c 270 { BACKGROUND_COL.updated = true; // : signal update of background colour
LvdK 6:e0bf3b244d7c 271 FSdata_received_flag = true; // : set common update flag
LvdK 6:e0bf3b244d7c 272 }
LvdK 6:e0bf3b244d7c 273
LvdK 6:e0bf3b244d7c 274 break;
LvdK 6:e0bf3b244d7c 275 }
LvdK 6:e0bf3b244d7c 276
LvdK 6:e0bf3b244d7c 277
LvdK 6:e0bf3b244d7c 278 case 7: // WTX command, write textline to CDU screen
LvdK 6:e0bf3b244d7c 279 {
LvdK 6:e0bf3b244d7c 280 // Read linenumber:
LvdK 6:e0bf3b244d7c 281 char_pntr = comma[1] + 1; // : set char pointer to char after comma 1
LvdK 6:e0bf3b244d7c 282 line = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 283 // Read char position:
LvdK 6:e0bf3b244d7c 284 char_pntr = comma[2] + 1; // : set char pointer to char after comma 2
LvdK 6:e0bf3b244d7c 285 pos = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 286
LvdK 6:e0bf3b244d7c 287 // Test if char X,Y position is within range:
LvdK 6:e0bf3b244d7c 288 if ( line >= 1 && line <= max_lines && pos >= 1 && pos <= max_text0 )
LvdK 6:e0bf3b244d7c 289 { // Read font size 0 - 9:
LvdK 6:e0bf3b244d7c 290 char_pntr = comma[3] + 1; // : set char pointer to char after comma 3
LvdK 6:e0bf3b244d7c 291 size = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 292 // Test if size is valid:
LvdK 6:e0bf3b244d7c 293 if ( size >= 0 && size <= max_font ) {
LvdK 6:e0bf3b244d7c 294 TEXTLINE[line].font_size = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 295 modified = true;
LvdK 6:e0bf3b244d7c 296 }
LvdK 6:e0bf3b244d7c 297 // Read line font style:
LvdK 6:e0bf3b244d7c 298 char_pntr = comma[4] + 1; // : set char pointer to char after comma 4
LvdK 6:e0bf3b244d7c 299 ch = string_received[char_pntr];
LvdK 6:e0bf3b244d7c 300 if (ch == fstyle_1 || ch == fstyle_2 ) {
LvdK 6:e0bf3b244d7c 301 TEXTLINE[line].font_style = ch;
LvdK 6:e0bf3b244d7c 302 modified = true;
LvdK 6:e0bf3b244d7c 303 }
LvdK 6:e0bf3b244d7c 304 // Read RGB line colour:
LvdK 6:e0bf3b244d7c 305 char_pntr = comma[5] + 1; // : set char pointer to char after comma 5
LvdK 6:e0bf3b244d7c 306 colour = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 307 if ( colour >= 0 && colour <= max_col_nr ) {
LvdK 6:e0bf3b244d7c 308 TEXTLINE[line].text_RED = colour;
LvdK 6:e0bf3b244d7c 309 modified = true;
LvdK 6:e0bf3b244d7c 310 }
LvdK 6:e0bf3b244d7c 311 char_pntr = comma[6] + 1; // : set char pointer to char after comma 6
LvdK 6:e0bf3b244d7c 312 colour = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 313 if ( colour >= 0 && colour <= max_col_nr ) {
LvdK 6:e0bf3b244d7c 314 TEXTLINE[line].text_GREEN = colour;
LvdK 6:e0bf3b244d7c 315 modified = true;
LvdK 6:e0bf3b244d7c 316 }
LvdK 6:e0bf3b244d7c 317 char_pntr = comma[7] + 1; // : set char pointer to char after comma 7
LvdK 6:e0bf3b244d7c 318 colour = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 319 if ( colour >= 0 && colour <= max_col_nr ) {
LvdK 6:e0bf3b244d7c 320 TEXTLINE[line].text_BLUE = colour;
LvdK 6:e0bf3b244d7c 321 modified = true;
LvdK 6:e0bf3b244d7c 322 }
LvdK 6:e0bf3b244d7c 323 // Read textfield :
LvdK 6:e0bf3b244d7c 324 char_pntr = comma[8] + 1; // : set char pointer to first char of textfield
LvdK 6:e0bf3b244d7c 325 last = 0;
LvdK 6:e0bf3b244d7c 326 // read font size to determine last possible position:
LvdK 6:e0bf3b244d7c 327 if ( TEXTLINE[line].font_size == 0 )last = max_text0;
LvdK 6:e0bf3b244d7c 328 else if ( TEXTLINE[line].font_size == 1 )last = max_text1;
LvdK 6:e0bf3b244d7c 329
LvdK 6:e0bf3b244d7c 330 if (last > 0 && pos <= last) { // : test for valid area and valid fontsize
LvdK 6:e0bf3b244d7c 331 a = pos;
LvdK 6:e0bf3b244d7c 332 modified = true;
LvdK 6:e0bf3b244d7c 333 while ( a <= last )
LvdK 6:e0bf3b244d7c 334 { ch = string_received[char_pntr];
LvdK 6:e0bf3b244d7c 335 if (ch == '*') break; // : do not include * in text
LvdK 6:e0bf3b244d7c 336 TEXTLINE[line].text[a] = ch;
LvdK 6:e0bf3b244d7c 337 a++;
LvdK 6:e0bf3b244d7c 338 char_pntr++;
LvdK 6:e0bf3b244d7c 339 }
LvdK 6:e0bf3b244d7c 340 //TEXTLINE[line].text[a] = '\0'; // : mark end of text <<<<<<<<<< ??
LvdK 6:e0bf3b244d7c 341 }
LvdK 6:e0bf3b244d7c 342 }
LvdK 6:e0bf3b244d7c 343
LvdK 6:e0bf3b244d7c 344 if ( modified == true ) {
LvdK 6:e0bf3b244d7c 345 TEXTLINE[line].updated = true; // : signal update of text line
LvdK 6:e0bf3b244d7c 346 FSdata_received_flag = true; // : set common update flag
LvdK 6:e0bf3b244d7c 347 }
LvdK 6:e0bf3b244d7c 348
LvdK 6:e0bf3b244d7c 349 // Debug:
LvdK 6:e0bf3b244d7c 350 // Print all fields : ----------------------------------------------------------------
LvdK 6:e0bf3b244d7c 351 USB.printf("WTX line : %d\n",line ); // show line nr
LvdK 6:e0bf3b244d7c 352 USB.printf("WTX position : %d\n",pos ); // show pos
LvdK 6:e0bf3b244d7c 353 USB.printf("WTX text is : %s\n",TEXTLINE[line].text ); // show text
LvdK 6:e0bf3b244d7c 354 USB.printf("WTX fontsize is : %d\n",TEXTLINE[line].font_size ); // show fontsize
LvdK 6:e0bf3b244d7c 355 USB.printf("WTX fontstyle is: %c\n",TEXTLINE[line].font_style); // show fontstyle
LvdK 6:e0bf3b244d7c 356 USB.printf("WTX R_colour is : %d\n",TEXTLINE[line].text_RED ); // show textcolour
LvdK 6:e0bf3b244d7c 357 USB.printf("WTX G_colour is : %d\n",TEXTLINE[line].text_GREEN ); // show textcolour
LvdK 6:e0bf3b244d7c 358 USB.printf("WTX B_colour is : %d\n",TEXTLINE[line].text_BLUE ); // show textcolour
LvdK 6:e0bf3b244d7c 359 // END of debug printing --------------------------------------------------------------
LvdK 6:e0bf3b244d7c 360
LvdK 6:e0bf3b244d7c 361 break;
LvdK 6:e0bf3b244d7c 362 }
LvdK 6:e0bf3b244d7c 363
LvdK 6:e0bf3b244d7c 364 case 8: // ETX command, erase (part of) textline of CDU screen
LvdK 6:e0bf3b244d7c 365 {
LvdK 6:e0bf3b244d7c 366 // Read linenumber:
LvdK 6:e0bf3b244d7c 367 char_pntr = comma[1] + 1; // : set char pointer to char after comma 1
LvdK 6:e0bf3b244d7c 368 line = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 369 // Read char position:
LvdK 6:e0bf3b244d7c 370 char_pntr = comma[2] + 1; // : set char pointer to char after comma 2
LvdK 6:e0bf3b244d7c 371 pos = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 372 // Read nr of char to be erased:
LvdK 6:e0bf3b244d7c 373 char_pntr = comma[3] + 1; // : set char pointer to char after comma 3
LvdK 6:e0bf3b244d7c 374 cnt = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 375 // Test if char X,Y position is within range:
LvdK 6:e0bf3b244d7c 376 if ( line >= 1 && line <= max_lines && pos >= 1 && pos <= max_text0 )
LvdK 6:e0bf3b244d7c 377 {
LvdK 6:e0bf3b244d7c 378 last = 0;
LvdK 6:e0bf3b244d7c 379 // read font size to determine last possible position:
LvdK 6:e0bf3b244d7c 380 if ( TEXTLINE[line].font_size == 0 )last = max_text0;
LvdK 6:e0bf3b244d7c 381 else if ( TEXTLINE[line].font_size == 1 )last = max_text1;
LvdK 6:e0bf3b244d7c 382
LvdK 6:e0bf3b244d7c 383 if (last > 0 && pos <= last && cnt > 0) { // : test if in valid area and chars > 0
LvdK 6:e0bf3b244d7c 384 a = pos;
LvdK 6:e0bf3b244d7c 385 modified = true;
LvdK 6:e0bf3b244d7c 386 while ( a <= last && cnt > 0)
LvdK 6:e0bf3b244d7c 387 {
LvdK 6:e0bf3b244d7c 388 TEXTLINE[line].text[a] = ' '; //: write space
LvdK 6:e0bf3b244d7c 389 a++;
LvdK 6:e0bf3b244d7c 390 cnt--;
LvdK 6:e0bf3b244d7c 391 }
LvdK 6:e0bf3b244d7c 392 }
LvdK 6:e0bf3b244d7c 393 }
LvdK 6:e0bf3b244d7c 394 if ( modified == true ) {
LvdK 6:e0bf3b244d7c 395 TEXTLINE[line].updated = true; // : signal update of text line
LvdK 6:e0bf3b244d7c 396 FSdata_received_flag = true; // : set common update flag
LvdK 6:e0bf3b244d7c 397 }
LvdK 6:e0bf3b244d7c 398
LvdK 6:e0bf3b244d7c 399 // Debug:
LvdK 6:e0bf3b244d7c 400 // Print : -------------------------------------------------------------------------
LvdK 6:e0bf3b244d7c 401 USB.printf("ETX line : %d\n",line ); // show line nr
LvdK 6:e0bf3b244d7c 402 USB.printf("ETX position : %d\n",pos ); // show pos
LvdK 6:e0bf3b244d7c 403 USB.printf("ETX modified text : %s\n",TEXTLINE[line].text ); // show text
LvdK 6:e0bf3b244d7c 404 // END of debug printing ------------------------------------------------------------
LvdK 6:e0bf3b244d7c 405 }
LvdK 6:e0bf3b244d7c 406
LvdK 6:e0bf3b244d7c 407 case 9: // KTX command, write textline to select key area
LvdK 6:e0bf3b244d7c 408 {
LvdK 6:e0bf3b244d7c 409 // Read key ID:
LvdK 6:e0bf3b244d7c 410 char_pntr = comma[1] + 1; // : set char pointer to char after comma 1
LvdK 6:e0bf3b244d7c 411 k_id = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 412 // Read text type:
LvdK 6:e0bf3b244d7c 413 char_pntr = comma[2] + 1; // : set char pointer to char after comma 2
LvdK 6:e0bf3b244d7c 414 ch = string_received[char_pntr];
LvdK 6:e0bf3b244d7c 415
LvdK 6:e0bf3b244d7c 416 if (ch == 'M' && k_id < max_keys ) // : text type = MAIN text and keyID valid
LvdK 6:e0bf3b244d7c 417 { // Read font size 0 - 9:
LvdK 6:e0bf3b244d7c 418 char_pntr = comma[3] + 1; // : set char pointer to char after comma 3
LvdK 6:e0bf3b244d7c 419 size = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 420 // Test if size is valid:
LvdK 6:e0bf3b244d7c 421 if ( size >= 0 && size <= max_font ) {
LvdK 6:e0bf3b244d7c 422 SELKEY_MAINTEXT[k_id].font_size = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 423 modified = true;
LvdK 6:e0bf3b244d7c 424 }
LvdK 6:e0bf3b244d7c 425 // Read line font style:
LvdK 6:e0bf3b244d7c 426 char_pntr = comma[4] + 1; // : set char pointer to char after comma 4
LvdK 6:e0bf3b244d7c 427 ch = string_received[char_pntr];
LvdK 6:e0bf3b244d7c 428 if (ch == fstyle_1 || ch == fstyle_2 ) {
LvdK 6:e0bf3b244d7c 429 SELKEY_MAINTEXT[k_id].font_style = ch;
LvdK 6:e0bf3b244d7c 430 modified = true;
LvdK 6:e0bf3b244d7c 431 }
LvdK 6:e0bf3b244d7c 432 // Read RGB line colour:
LvdK 6:e0bf3b244d7c 433 char_pntr = comma[5] + 1; // : set char pointer to char after comma 5
LvdK 6:e0bf3b244d7c 434 colour = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 435 if ( colour >= 0 && colour <= max_col_nr ) {
LvdK 6:e0bf3b244d7c 436 SELKEY_MAINTEXT[k_id].text_RED = colour;
LvdK 6:e0bf3b244d7c 437 modified = true;
LvdK 6:e0bf3b244d7c 438 }
LvdK 6:e0bf3b244d7c 439 char_pntr = comma[6] + 1; // : set char pointer to char after comma 5
LvdK 6:e0bf3b244d7c 440 colour = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 441 if ( colour >= 0 && colour <= max_col_nr ) {
LvdK 6:e0bf3b244d7c 442 SELKEY_MAINTEXT[k_id].text_GREEN = colour;
LvdK 6:e0bf3b244d7c 443 modified = true;
LvdK 6:e0bf3b244d7c 444 }
LvdK 6:e0bf3b244d7c 445 char_pntr = comma[7] + 1; // : set char pointer to char after comma 7
LvdK 6:e0bf3b244d7c 446 colour = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 447 if ( colour >= 0 && colour <= max_col_nr ) {
LvdK 6:e0bf3b244d7c 448 SELKEY_MAINTEXT[k_id].text_BLUE = colour;
LvdK 6:e0bf3b244d7c 449 modified = true;
LvdK 6:e0bf3b244d7c 450 }
LvdK 6:e0bf3b244d7c 451 // Read textfield :
LvdK 6:e0bf3b244d7c 452 char_pntr = comma[8] + 1; // : set char pointer to first char of textfield
LvdK 6:e0bf3b244d7c 453 last = 0;
LvdK 6:e0bf3b244d7c 454 // read font size to determine last possible position:
LvdK 6:e0bf3b244d7c 455 if ( SELKEY_MAINTEXT[k_id].font_size == 0 )last = max_text0;
LvdK 6:e0bf3b244d7c 456 else if ( SELKEY_MAINTEXT[k_id].font_size == 1 )last = max_text1;
LvdK 6:e0bf3b244d7c 457
LvdK 6:e0bf3b244d7c 458 if (last > 0) { // : test on valid fontsize
LvdK 6:e0bf3b244d7c 459 a = 1;
LvdK 6:e0bf3b244d7c 460 modified = true;
LvdK 6:e0bf3b244d7c 461 while ( a <= last )
LvdK 6:e0bf3b244d7c 462 { ch = string_received[char_pntr];
LvdK 6:e0bf3b244d7c 463 if (ch == '*') break; // : do not include * in text
LvdK 6:e0bf3b244d7c 464 SELKEY_MAINTEXT[k_id].text[a] = ch;
LvdK 6:e0bf3b244d7c 465 a++;
LvdK 6:e0bf3b244d7c 466 char_pntr++;
LvdK 6:e0bf3b244d7c 467 }
LvdK 6:e0bf3b244d7c 468 //SELKEY_MAINTEXT[k_id].text[a] = '\0'; // : mark end of text <<< ???
LvdK 6:e0bf3b244d7c 469 }
LvdK 6:e0bf3b244d7c 470
LvdK 6:e0bf3b244d7c 471 if ( modified == true ) {
LvdK 6:e0bf3b244d7c 472 SELKEY_MAINTEXT[k_id].updated = true; // : signal update
LvdK 6:e0bf3b244d7c 473 FSdata_received_flag = true; // : set common update flag
LvdK 6:e0bf3b244d7c 474 }
LvdK 6:e0bf3b244d7c 475
LvdK 6:e0bf3b244d7c 476 // Debug:
LvdK 6:e0bf3b244d7c 477 // Print all fields : --------------------------------------------------------------------
LvdK 6:e0bf3b244d7c 478 USB.printf("KTX key nr is : %d\n",k_id ); // show key nr
LvdK 6:e0bf3b244d7c 479 USB.printf("KTX MAINTEXT is : %s\n",SELKEY_MAINTEXT[k_id].text ); // show text
LvdK 6:e0bf3b244d7c 480 USB.printf("KTX fontsize is : %d\n",SELKEY_MAINTEXT[k_id].font_size ); // show fontsize
LvdK 6:e0bf3b244d7c 481 USB.printf("KTX fontstyle is: %c\n",SELKEY_MAINTEXT[k_id].font_style); // show fontstyle
LvdK 6:e0bf3b244d7c 482 USB.printf("KTX R_colour is : %d\n",SELKEY_MAINTEXT[k_id].text_RED ); // show textcolour
LvdK 6:e0bf3b244d7c 483 USB.printf("KTX G_colour is : %d\n",SELKEY_MAINTEXT[k_id].text_GREEN ); // show textcolour
LvdK 6:e0bf3b244d7c 484 USB.printf("KTX B_colour is : %d\n",SELKEY_MAINTEXT[k_id].text_BLUE ); // show textcolour
LvdK 6:e0bf3b244d7c 485 // END of debug printing -----------------------------------------------------------------
LvdK 6:e0bf3b244d7c 486
LvdK 6:e0bf3b244d7c 487 }
LvdK 6:e0bf3b244d7c 488
LvdK 6:e0bf3b244d7c 489 else if ( ch == 'S' && k_id < max_keys ) // : text type = SUB text and keyID valid
LvdK 6:e0bf3b244d7c 490 { // Read font size 0 - 9:
LvdK 6:e0bf3b244d7c 491 char_pntr = comma[3] + 1; // : set char pointer to char after comma 3
LvdK 6:e0bf3b244d7c 492 size = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 493 // Test if size is valid:
LvdK 6:e0bf3b244d7c 494 if ( size >= 0 && size <= max_font ) {
LvdK 6:e0bf3b244d7c 495 SELKEY_SUBTEXT[k_id].font_size = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 496 modified = true;
LvdK 6:e0bf3b244d7c 497 }
LvdK 6:e0bf3b244d7c 498 // Read line font style:
LvdK 6:e0bf3b244d7c 499 char_pntr = comma[4] + 1; // : set char pointer to char after comma 4
LvdK 6:e0bf3b244d7c 500 ch = string_received[char_pntr];
LvdK 6:e0bf3b244d7c 501 if (ch == fstyle_1 || ch == fstyle_2 ) {
LvdK 6:e0bf3b244d7c 502 SELKEY_SUBTEXT[k_id].font_style = ch;
LvdK 6:e0bf3b244d7c 503 modified = true;
LvdK 6:e0bf3b244d7c 504 }
LvdK 6:e0bf3b244d7c 505 // Read RGB line colour:
LvdK 6:e0bf3b244d7c 506 char_pntr = comma[5] + 1; // : set char pointer to char after comma 5
LvdK 6:e0bf3b244d7c 507 colour = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 508 if ( colour >= 0 && colour <= max_col_nr ) {
LvdK 6:e0bf3b244d7c 509 SELKEY_SUBTEXT[k_id].text_RED = colour;
LvdK 6:e0bf3b244d7c 510 modified = true;
LvdK 6:e0bf3b244d7c 511 }
LvdK 6:e0bf3b244d7c 512 char_pntr = comma[6] + 1; // : set char pointer to char after comma 6
LvdK 6:e0bf3b244d7c 513 colour = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 514 if ( colour >= 0 && colour <= max_col_nr ) {
LvdK 6:e0bf3b244d7c 515 SELKEY_SUBTEXT[k_id].text_GREEN = colour;
LvdK 6:e0bf3b244d7c 516 modified = true;
LvdK 6:e0bf3b244d7c 517 }
LvdK 6:e0bf3b244d7c 518 char_pntr = comma[7] + 1; // : set char pointer to char after comma 7
LvdK 6:e0bf3b244d7c 519 colour = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 520 if ( colour >= 0 && colour <= max_col_nr ) {
LvdK 6:e0bf3b244d7c 521 SELKEY_SUBTEXT[k_id].text_BLUE = colour;
LvdK 6:e0bf3b244d7c 522 modified = true;
LvdK 6:e0bf3b244d7c 523 }
LvdK 6:e0bf3b244d7c 524 // Read textfield :
LvdK 6:e0bf3b244d7c 525 char_pntr = comma[8] + 1; // : set char pointer to first char of textfield
LvdK 6:e0bf3b244d7c 526 last = 0;
LvdK 6:e0bf3b244d7c 527 // read font size to determine last possible position:
LvdK 6:e0bf3b244d7c 528 if ( SELKEY_SUBTEXT[k_id].font_size == 0 )last = max_text0;
LvdK 6:e0bf3b244d7c 529 else if ( SELKEY_SUBTEXT[k_id].font_size == 1 )last = max_text1;
LvdK 6:e0bf3b244d7c 530
LvdK 6:e0bf3b244d7c 531 if (last > 0) { // : test on valid fontsize
LvdK 6:e0bf3b244d7c 532 a = 1;
LvdK 6:e0bf3b244d7c 533 modified = true;
LvdK 6:e0bf3b244d7c 534 while ( a <= last )
LvdK 6:e0bf3b244d7c 535 { ch = string_received[char_pntr];
LvdK 6:e0bf3b244d7c 536 if (ch == '*') break; // : do not include * in text
LvdK 6:e0bf3b244d7c 537 SELKEY_SUBTEXT[k_id].text[a] = ch;
LvdK 6:e0bf3b244d7c 538 a++;
LvdK 6:e0bf3b244d7c 539 char_pntr++;
LvdK 6:e0bf3b244d7c 540 }
LvdK 6:e0bf3b244d7c 541 //SELKEY_SUBTEXT[k_id].text[a] = '\0'; // : mark end of text <<<<<<< ???
LvdK 6:e0bf3b244d7c 542 }
LvdK 6:e0bf3b244d7c 543
LvdK 6:e0bf3b244d7c 544 if ( modified == true ) {
LvdK 6:e0bf3b244d7c 545 SELKEY_SUBTEXT[k_id].updated = true; // : signal update
LvdK 6:e0bf3b244d7c 546 FSdata_received_flag = true; // : set common update flag
LvdK 6:e0bf3b244d7c 547 }
LvdK 6:e0bf3b244d7c 548
LvdK 6:e0bf3b244d7c 549 // Debug:
LvdK 6:e0bf3b244d7c 550 // Print all fields : --------------------------------------------------------------------
LvdK 6:e0bf3b244d7c 551 USB.printf("KTX key nr is : %d\n",k_id ); // show key nr
LvdK 6:e0bf3b244d7c 552 USB.printf("KTX SUBTEXT is : %s\n",SELKEY_SUBTEXT[k_id].text ); // show text
LvdK 6:e0bf3b244d7c 553 USB.printf("KTX fontsize is : %d\n",SELKEY_SUBTEXT[k_id].font_size ); // show fontsize
LvdK 6:e0bf3b244d7c 554 USB.printf("KTX fontstyle is: %c\n",SELKEY_SUBTEXT[k_id].font_style); // show fontstyle
LvdK 6:e0bf3b244d7c 555 USB.printf("KTX R_colour is : %d\n",SELKEY_SUBTEXT[k_id].text_RED ); // show textcolour
LvdK 6:e0bf3b244d7c 556 USB.printf("KTX G_colour is : %d\n",SELKEY_SUBTEXT[k_id].text_GREEN ); // show textcolour
LvdK 6:e0bf3b244d7c 557 USB.printf("KTX B_colour is : %d\n",SELKEY_SUBTEXT[k_id].text_BLUE ); // show textcolour
LvdK 6:e0bf3b244d7c 558 // END of debug printing -----------------------------------------------------------------
LvdK 6:e0bf3b244d7c 559
LvdK 6:e0bf3b244d7c 560 }
LvdK 6:e0bf3b244d7c 561
LvdK 6:e0bf3b244d7c 562 break;
LvdK 6:e0bf3b244d7c 563 }
LvdK 6:e0bf3b244d7c 564
LvdK 6:e0bf3b244d7c 565 case 10: // STV command, set a status value:
LvdK 6:e0bf3b244d7c 566 { // Read var_number :
LvdK 6:e0bf3b244d7c 567 char_pntr = comma[1] + 1; // : set char pointer to char after comma 1
LvdK 6:e0bf3b244d7c 568 var = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 569 if ( var == 0 ) // : test if valid var to write (var 0 = baudrate permitted only now)
LvdK 6:e0bf3b244d7c 570 { // Set baudrate :
LvdK 6:e0bf3b244d7c 571 char_pntr = comma[2] + 1; // : set char pointer to char after comma 2
LvdK 6:e0bf3b244d7c 572 a = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 573 // Test for valid baudrates:
LvdK 6:e0bf3b244d7c 574 if (a==2400 || a==4800 || a==9600 || a== 19200 || a==38400 )
LvdK 6:e0bf3b244d7c 575 { CDU_SET.Baud = a;
LvdK 6:e0bf3b244d7c 576 CDU_SET.updated = true; // : signal status update
LvdK 6:e0bf3b244d7c 577 // Send a responding VAL message:
LvdK 6:e0bf3b244d7c 578 sprintf(val_string,"%d",CDU_SET.Baud);
LvdK 6:e0bf3b244d7c 579 Send_VAL_message(var,val_string);
LvdK 6:e0bf3b244d7c 580 FSdata_received_flag = true; // : set common update flag
LvdK 6:e0bf3b244d7c 581 }
LvdK 6:e0bf3b244d7c 582 else { // no valid baudrate in command
LvdK 6:e0bf3b244d7c 583 // Send a responding VAL NACK message :
LvdK 6:e0bf3b244d7c 584 strcpy(val_string,"NACK\0"); // copy chars incl. '\0'
LvdK 6:e0bf3b244d7c 585 Send_VAL_message(var,val_string);
LvdK 6:e0bf3b244d7c 586 }
LvdK 6:e0bf3b244d7c 587 }
LvdK 6:e0bf3b244d7c 588 else { // var is not valid var for writing
LvdK 6:e0bf3b244d7c 589 // Send a responding VAL NACK message :
LvdK 6:e0bf3b244d7c 590 strcpy(val_string,"NACK\0"); // copy chars incl. '\0'
LvdK 6:e0bf3b244d7c 591 Send_VAL_message(var,val_string);
LvdK 6:e0bf3b244d7c 592 }
LvdK 6:e0bf3b244d7c 593
LvdK 6:e0bf3b244d7c 594 break;
LvdK 6:e0bf3b244d7c 595 }
LvdK 6:e0bf3b244d7c 596
LvdK 6:e0bf3b244d7c 597 case 11: // GTV command, get a status value:
LvdK 6:e0bf3b244d7c 598 { // Read var_number :
LvdK 6:e0bf3b244d7c 599 char_pntr = comma[1] + 1; // : set char pointer to char after comma 1
LvdK 6:e0bf3b244d7c 600 var = atoi(&string_received[char_pntr]);
LvdK 6:e0bf3b244d7c 601 if ( var >= 0 && var <= 6) // : test if valid var to read
LvdK 6:e0bf3b244d7c 602 { // Read value :
LvdK 6:e0bf3b244d7c 603 switch ( var ) {
LvdK 6:e0bf3b244d7c 604 case 0: { // baudrate asked
LvdK 6:e0bf3b244d7c 605 sprintf(val_string,"%d",CDU_SET.Baud);
LvdK 6:e0bf3b244d7c 606 Send_VAL_message(var,val_string);
LvdK 6:e0bf3b244d7c 607 break;
LvdK 6:e0bf3b244d7c 608 }
LvdK 6:e0bf3b244d7c 609 case 1: { // firmware ID asked
LvdK 6:e0bf3b244d7c 610 strcpy(val_string,CDU_SET.Firmware_nr); // copy chars incl. '\0'
LvdK 6:e0bf3b244d7c 611 Send_VAL_message(var,val_string);
LvdK 6:e0bf3b244d7c 612 break;
LvdK 6:e0bf3b244d7c 613 }
LvdK 6:e0bf3b244d7c 614 case 2: { // CDU type ID asked
LvdK 6:e0bf3b244d7c 615 strcpy(val_string,CDU_SET.CDU_type); // copy chars incl. '\0'
LvdK 6:e0bf3b244d7c 616 Send_VAL_message(var,val_string);
LvdK 6:e0bf3b244d7c 617 break;
LvdK 6:e0bf3b244d7c 618 }
LvdK 6:e0bf3b244d7c 619 case 3: { // serial number asked
LvdK 6:e0bf3b244d7c 620 sprintf(val_string,"%d",CDU_SET.Serial_nr);
LvdK 6:e0bf3b244d7c 621 Send_VAL_message(var,val_string);
LvdK 6:e0bf3b244d7c 622 break;
LvdK 6:e0bf3b244d7c 623 }
LvdK 6:e0bf3b244d7c 624 case 4: { // IP address of CDU asked
LvdK 6:e0bf3b244d7c 625 strcpy(val_string,CDU_SET.IP_address); // copy chars incl. '\0''
LvdK 6:e0bf3b244d7c 626 Send_VAL_message(var,val_string);
LvdK 6:e0bf3b244d7c 627 break;
LvdK 6:e0bf3b244d7c 628 }
LvdK 6:e0bf3b244d7c 629 case 5: { // Port number asked
LvdK 6:e0bf3b244d7c 630 sprintf(val_string,"%d",CDU_SET.Port_nr);
LvdK 6:e0bf3b244d7c 631 Send_VAL_message(var,val_string);
LvdK 6:e0bf3b244d7c 632 break;
LvdK 6:e0bf3b244d7c 633 }
LvdK 6:e0bf3b244d7c 634 case 6: { // IP address of server asked
LvdK 6:e0bf3b244d7c 635 strcpy(val_string,CDU_SET.Server_ip); // copy chars incl. '\0'
LvdK 6:e0bf3b244d7c 636 Send_VAL_message(var,val_string);
LvdK 6:e0bf3b244d7c 637 break;
LvdK 6:e0bf3b244d7c 638 }
LvdK 6:e0bf3b244d7c 639
LvdK 6:e0bf3b244d7c 640 default : { // invalid var , not possible
LvdK 6:e0bf3b244d7c 641 break;
LvdK 6:e0bf3b244d7c 642 }
LvdK 6:e0bf3b244d7c 643
LvdK 6:e0bf3b244d7c 644 }
LvdK 6:e0bf3b244d7c 645 }
LvdK 6:e0bf3b244d7c 646 else { // var is not valid
LvdK 6:e0bf3b244d7c 647 // Send a responding VAL NACK message :
LvdK 6:e0bf3b244d7c 648 strcpy(val_string,"NACK\0"); // copy chars incl. '\0'
LvdK 6:e0bf3b244d7c 649 Send_VAL_message(var,val_string);
LvdK 6:e0bf3b244d7c 650 }
LvdK 6:e0bf3b244d7c 651 break;
LvdK 6:e0bf3b244d7c 652 }
LvdK 6:e0bf3b244d7c 653
LvdK 6:e0bf3b244d7c 654 case 12: // dbg, special debug command
LvdK 6:e0bf3b244d7c 655 {
LvdK 6:e0bf3b244d7c 656
LvdK 6:e0bf3b244d7c 657 break;
LvdK 6:e0bf3b244d7c 658 }
LvdK 6:e0bf3b244d7c 659
LvdK 6:e0bf3b244d7c 660 default:
LvdK 6:e0bf3b244d7c 661 {
LvdK 6:e0bf3b244d7c 662 // unknown commandnumber !
LvdK 6:e0bf3b244d7c 663 break;
LvdK 6:e0bf3b244d7c 664 }
LvdK 6:e0bf3b244d7c 665
LvdK 6:e0bf3b244d7c 666
LvdK 6:e0bf3b244d7c 667 }
LvdK 6:e0bf3b244d7c 668 }
LvdK 6:e0bf3b244d7c 669