d

Dependencies:   TS_DISCO_F746NG LCD_DISCO_F746NG BSP_DISCO_F746NG BD_SD_DISCO_F746NG

Committer:
Photonium
Date:
Tue Apr 28 12:10:04 2020 +0000
Revision:
0:2e2716e8edb3
d

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Photonium 0:2e2716e8edb3 1 #include "mbed.h"
Photonium 0:2e2716e8edb3 2 #include "FATFileSystem.h"
Photonium 0:2e2716e8edb3 3 #include "SDBlockDeviceDISCOF746NG.h"
Photonium 0:2e2716e8edb3 4 #include <stdio.h>
Photonium 0:2e2716e8edb3 5 #include <errno.h>
Photonium 0:2e2716e8edb3 6 #include "TS_DISCO_F746NG.h"
Photonium 0:2e2716e8edb3 7 #include "LCD_DISCO_F746NG.h"
Photonium 0:2e2716e8edb3 8 #include <string>
Photonium 0:2e2716e8edb3 9 #include <fstream> //library für file streams
Photonium 0:2e2716e8edb3 10 //#include <iostream> //für input/output von streams
Photonium 0:2e2716e8edb3 11 LCD_DISCO_F746NG lcd;
Photonium 0:2e2716e8edb3 12 TS_DISCO_F746NG ts;
Photonium 0:2e2716e8edb3 13 TS_StateTypeDef TS_State;
Photonium 0:2e2716e8edb3 14 I2C i2c(I2C_SDA, I2C_SCL );
Photonium 0:2e2716e8edb3 15 SDBlockDeviceDISCOF746NG bd;
Photonium 0:2e2716e8edb3 16 FATFileSystem fs ("fs");
Photonium 0:2e2716e8edb3 17 uint32_t linecheck(uint8_t Channel); //Function to Check a wire connection
Photonium 0:2e2716e8edb3 18 uint8_t channel;
Photonium 0:2e2716e8edb3 19 uint8_t g=0,lc=0,gmax=0;
Photonium 0:2e2716e8edb3 20 uint8_t channel_max =32;
Photonium 0:2e2716e8edb3 21 char channel_result[32]; //Array for test-result
Photonium 0:2e2716e8edb3 22 string Result = "NOK";
Photonium 0:2e2716e8edb3 23 uint8_t mode=0,quad=0,cp=0,bc=0; //Modus of program (1:1==1, Load from SDCard==2, Learn==3)
Photonium 0:2e2716e8edb3 24 uint8_t escrep=0;//escape=1 or repeat=2 same mode?
Photonium 0:2e2716e8edb3 25 uint8_t trippelchoose (uint8_t mode);
Photonium 0:2e2716e8edb3 26 uint8_t quadchoose (uint8_t quad);
Photonium 0:2e2716e8edb3 27 uint8_t readCabletext();
Photonium 0:2e2716e8edb3 28 uint16_t x, y,temp_count;
Photonium 0:2e2716e8edb3 29 uint32_t rv,cv; //32Bitvariable rv=resultvector cv=channelvector
Photonium 0:2e2716e8edb3 30 uint8_t idx;
Photonium 0:2e2716e8edb3 31 uint8_t prev_nb_touches = 0;
Photonium 0:2e2716e8edb3 32 uint8_t cleared = 0;
Photonium 0:2e2716e8edb3 33 string ws,sz,ls;
Photonium 0:2e2716e8edb3 34 //#################
Photonium 0:2e2716e8edb3 35 struct Cable {
Photonium 0:2e2716e8edb3 36 string internal_name; // Kabelname und Bezeichnung ggf. interne Nummer
Photonium 0:2e2716e8edb3 37 string navision_number;
Photonium 0:2e2716e8edb3 38 char wiring_in[32];
Photonium 0:2e2716e8edb3 39 char wiring_out[32];
Photonium 0:2e2716e8edb3 40 } CableIndex [127];
Photonium 0:2e2716e8edb3 41
Photonium 0:2e2716e8edb3 42
Photonium 0:2e2716e8edb3 43 void
Photonium 0:2e2716e8edb3 44 return_error (int ret_val)
Photonium 0:2e2716e8edb3 45 {
Photonium 0:2e2716e8edb3 46 if(ret_val)
Photonium 0:2e2716e8edb3 47 printf ("Failure. %d\r\n", ret_val);
Photonium 0:2e2716e8edb3 48 else
Photonium 0:2e2716e8edb3 49 printf ("done.\r\n");
Photonium 0:2e2716e8edb3 50 }
Photonium 0:2e2716e8edb3 51
Photonium 0:2e2716e8edb3 52 void
Photonium 0:2e2716e8edb3 53 errno_error (void* ret_val)
Photonium 0:2e2716e8edb3 54 {
Photonium 0:2e2716e8edb3 55 if(ret_val == NULL)
Photonium 0:2e2716e8edb3 56 printf (" Failure. %d \r\n", errno);
Photonium 0:2e2716e8edb3 57 else
Photonium 0:2e2716e8edb3 58 printf (" done.\r\n");
Photonium 0:2e2716e8edb3 59 }
Photonium 0:2e2716e8edb3 60
Photonium 0:2e2716e8edb3 61 int main()
Photonium 0:2e2716e8edb3 62 {
Photonium 0:2e2716e8edb3 63
Photonium 0:2e2716e8edb3 64 Serial pc (SERIAL_TX, SERIAL_RX);
Photonium 0:2e2716e8edb3 65 pc.baud(115200);
Photonium 0:2e2716e8edb3 66 //################ INIT I2C devices
Photonium 0:2e2716e8edb3 67 const int I2C_ChOut = 0x20<<1; // I2C address for input devices
Photonium 0:2e2716e8edb3 68 char cmd [2]; //Variable for commandstring (send / read )input
Photonium 0:2e2716e8edb3 69
Photonium 0:2e2716e8edb3 70 for(int i=0;i<4;i++) { //set all I2C output to LOW
Photonium 0:2e2716e8edb3 71 cmd[0] = 0x03;//configuration-register I2C device
Photonium 0:2e2716e8edb3 72 cmd[1] = 0x00;//sets this device for output
Photonium 0:2e2716e8edb3 73 i2c.write(I2C_ChOut+2*i, cmd, 2);//send 2 configbyte to I2C device
Photonium 0:2e2716e8edb3 74 cmd[0] = 0x01;// I2C device for output
Photonium 0:2e2716e8edb3 75 cmd[1] = 0x00;//bitpattern == 8bit LOW
Photonium 0:2e2716e8edb3 76 i2c.write(I2C_ChOut+2*i, cmd, 2);//Send bitpattern for output
Photonium 0:2e2716e8edb3 77 }
Photonium 0:2e2716e8edb3 78
Photonium 0:2e2716e8edb3 79 //################ Init Touchsreen and LCD
Photonium 0:2e2716e8edb3 80 TS_StateTypeDef TS_State;
Photonium 0:2e2716e8edb3 81 char text[30];
Photonium 0:2e2716e8edb3 82 uint8_t status;
Photonium 0:2e2716e8edb3 83 uint8_t idx;
Photonium 0:2e2716e8edb3 84 //uint32_t PURPLE=0xffC800C8; //Colorcode
Photonium 0:2e2716e8edb3 85 uint32_t DBLUE=0xff000064; //Colorcode
Photonium 0:2e2716e8edb3 86 uint8_t channel_idx;
Photonium 0:2e2716e8edb3 87 //uint8_t escrep;//escape=1 or repeat=2 same mode?
Photonium 0:2e2716e8edb3 88
Photonium 0:2e2716e8edb3 89 lcd.SetFont(&Font20);
Photonium 0:2e2716e8edb3 90 status = ts.Init(lcd.GetXSize(), lcd.GetYSize());
Photonium 0:2e2716e8edb3 91 if (status != TS_OK) {
Photonium 0:2e2716e8edb3 92 lcd.Clear(LCD_COLOR_RED);
Photonium 0:2e2716e8edb3 93 lcd.SetBackColor(LCD_COLOR_RED);
Photonium 0:2e2716e8edb3 94 lcd.SetTextColor(LCD_COLOR_WHITE);
Photonium 0:2e2716e8edb3 95 lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT FAIL", CENTER_MODE);
Photonium 0:2e2716e8edb3 96 } else {
Photonium 0:2e2716e8edb3 97 lcd.Clear(LCD_COLOR_GREEN);
Photonium 0:2e2716e8edb3 98 lcd.SetBackColor(LCD_COLOR_GREEN);
Photonium 0:2e2716e8edb3 99 lcd.SetTextColor(LCD_COLOR_WHITE);
Photonium 0:2e2716e8edb3 100 lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT OK", CENTER_MODE);
Photonium 0:2e2716e8edb3 101 }
Photonium 0:2e2716e8edb3 102 lcd.Clear(DBLUE);
Photonium 0:2e2716e8edb3 103 lcd.SetBackColor(DBLUE);
Photonium 0:2e2716e8edb3 104 lcd.SetTextColor(LCD_COLOR_WHITE);
Photonium 0:2e2716e8edb3 105 lcd.SetFont(&Font24);
Photonium 0:2e2716e8edb3 106 sprintf((char*)text, "Advanced Cable Tester");
Photonium 0:2e2716e8edb3 107 lcd.DisplayStringAt(0, LINE(2), (uint8_t *)&text, CENTER_MODE);
Photonium 0:2e2716e8edb3 108 lcd.SetBackColor(DBLUE);
Photonium 0:2e2716e8edb3 109 lcd.SetTextColor(LCD_COLOR_WHITE);
Photonium 0:2e2716e8edb3 110 lcd.SetFont(&Font20);
Photonium 0:2e2716e8edb3 111 lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"Reading cabledata from sd-card...", CENTER_MODE);
Photonium 0:2e2716e8edb3 112
Photonium 0:2e2716e8edb3 113 printf("Start\n");
Photonium 0:2e2716e8edb3 114 int error = 0;
Photonium 0:2e2716e8edb3 115 return_error(error);
Photonium 0:2e2716e8edb3 116
Photonium 0:2e2716e8edb3 117 printf("Mounting the filesystem on \"/fs\". ");
Photonium 0:2e2716e8edb3 118 error = fs.mount(&bd);
Photonium 0:2e2716e8edb3 119 return_error(error);
Photonium 0:2e2716e8edb3 120 gmax=readCabletext();
Photonium 0:2e2716e8edb3 121 sprintf((char*)text, "Read %d cables from file", gmax);
Photonium 0:2e2716e8edb3 122 lcd.DisplayStringAt(0, LINE(6), (uint8_t *)&text, CENTER_MODE);
Photonium 0:2e2716e8edb3 123 printf("Read %d cables from file \r\n", gmax); //
Photonium 0:2e2716e8edb3 124 wait(2);
Photonium 0:2e2716e8edb3 125 do {
Photonium 0:2e2716e8edb3 126 mode=0;
Photonium 0:2e2716e8edb3 127
Photonium 0:2e2716e8edb3 128 lcd.Clear(DBLUE);
Photonium 0:2e2716e8edb3 129 lcd.SetBackColor(DBLUE);
Photonium 0:2e2716e8edb3 130 lcd.SetTextColor(LCD_COLOR_WHITE);
Photonium 0:2e2716e8edb3 131 lcd.SetFont(&Font24);
Photonium 0:2e2716e8edb3 132 sprintf((char*)text, "Advanced Cable Tester");
Photonium 0:2e2716e8edb3 133 lcd.DisplayStringAt(0, LINE(2), (uint8_t *)&text, CENTER_MODE);
Photonium 0:2e2716e8edb3 134 sprintf((char*)text, "choose Mode");
Photonium 0:2e2716e8edb3 135 lcd.DisplayStringAt(0, LINE(3), (uint8_t *)&text, CENTER_MODE);
Photonium 0:2e2716e8edb3 136 lcd.SetFont(&Font16);
Photonium 0:2e2716e8edb3 137 // lcd.DisplayStringAt(0, LINE(10), (uint8_t *)"IPG", CENTER_MODE);
Photonium 0:2e2716e8edb3 138
Photonium 0:2e2716e8edb3 139 while(mode==0) {
Photonium 0:2e2716e8edb3 140
Photonium 0:2e2716e8edb3 141 mode=trippelchoose (mode);
Photonium 0:2e2716e8edb3 142 //printf("Modus=%d \r\n",mode);
Photonium 0:2e2716e8edb3 143 }
Photonium 0:2e2716e8edb3 144 switch(mode) {
Photonium 0:2e2716e8edb3 145 case 1: {
Photonium 0:2e2716e8edb3 146 // Check of 1:1 Cable here (32 Positions)
Photonium 0:2e2716e8edb3 147 lcd.DisplayStringAt(20, LINE(1), (uint8_t *)&text, LEFT_MODE);
Photonium 0:2e2716e8edb3 148 lcd.Clear(DBLUE);
Photonium 0:2e2716e8edb3 149 lcd.SetBackColor(DBLUE);
Photonium 0:2e2716e8edb3 150 lcd.SetFont(&Font16);
Photonium 0:2e2716e8edb3 151 lcd.SetTextColor(LCD_COLOR_WHITE);
Photonium 0:2e2716e8edb3 152 sprintf((char*)text, "+++++++++ 1:1 Test running +++++++++");
Photonium 0:2e2716e8edb3 153 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, CENTER_MODE);
Photonium 0:2e2716e8edb3 154 lcd.SetTextColor(LCD_COLOR_RED);
Photonium 0:2e2716e8edb3 155 lcd.FillRect(200, 15, 50, 250);
Photonium 0:2e2716e8edb3 156 //lcd.Clear(LCD_COLOR_BLUE);
Photonium 0:2e2716e8edb3 157 lcd.SetBackColor(LCD_COLOR_RED);
Photonium 0:2e2716e8edb3 158 lcd.SetTextColor(LCD_COLOR_WHITE);
Photonium 0:2e2716e8edb3 159 lcd.SetFont(&Font24);
Photonium 0:2e2716e8edb3 160 sprintf((char*)text, "E");
Photonium 0:2e2716e8edb3 161 lcd.DisplayStringAt(216, LINE(3), (uint8_t *)&text, LEFT_MODE);
Photonium 0:2e2716e8edb3 162 sprintf((char*)text, "S");
Photonium 0:2e2716e8edb3 163 lcd.DisplayStringAt(216, LINE(4), (uint8_t *)&text, LEFT_MODE);
Photonium 0:2e2716e8edb3 164 sprintf((char*)text, "C");
Photonium 0:2e2716e8edb3 165 lcd.DisplayStringAt(216, LINE(5), (uint8_t *)&text, LEFT_MODE);
Photonium 0:2e2716e8edb3 166 sprintf((char*)text, "A");
Photonium 0:2e2716e8edb3 167 lcd.DisplayStringAt(216, LINE(6), (uint8_t *)&text, LEFT_MODE);
Photonium 0:2e2716e8edb3 168 sprintf((char*)text, "P");
Photonium 0:2e2716e8edb3 169 lcd.DisplayStringAt(216, LINE(7), (uint8_t *)&text, LEFT_MODE);
Photonium 0:2e2716e8edb3 170 sprintf((char*)text, "E");
Photonium 0:2e2716e8edb3 171 lcd.DisplayStringAt(216, LINE(8), (uint8_t *)&text, LEFT_MODE);
Photonium 0:2e2716e8edb3 172 lcd.SetFont(&Font16);
Photonium 0:2e2716e8edb3 173 lcd.SetBackColor(DBLUE);
Photonium 0:2e2716e8edb3 174 while(mode==1) {
Photonium 0:2e2716e8edb3 175 for (channel_idx = 0 ; channel_idx < channel_max/2; channel_idx++) {
Photonium 0:2e2716e8edb3 176 rv=linecheck(channel_idx); //Line check (#)
Photonium 0:2e2716e8edb3 177 cv=1<<channel_idx;
Photonium 0:2e2716e8edb3 178 printf ("Index%d CV:%d RV:%d \r\n",channel_idx,cv,rv);
Photonium 0:2e2716e8edb3 179 if (channel_idx <16) {
Photonium 0:2e2716e8edb3 180 if(rv==cv) {
Photonium 0:2e2716e8edb3 181 lcd.SetTextColor(LCD_COLOR_GREEN);
Photonium 0:2e2716e8edb3 182 Result = "Okay";
Photonium 0:2e2716e8edb3 183 } else {
Photonium 0:2e2716e8edb3 184 lcd.SetTextColor(LCD_COLOR_RED);
Photonium 0:2e2716e8edb3 185 Result = "Error";
Photonium 0:2e2716e8edb3 186 }
Photonium 0:2e2716e8edb3 187 sprintf(text,"Line(%d)=%s",channel_idx+1," ");
Photonium 0:2e2716e8edb3 188 lcd.DisplayStringAt(35, LINE(channel_idx+1), (uint8_t *)&text, LEFT_MODE);
Photonium 0:2e2716e8edb3 189 wait(.005);
Photonium 0:2e2716e8edb3 190 sprintf(text,"Line(%d)=%s",channel_idx+1,Result.c_str());
Photonium 0:2e2716e8edb3 191 lcd.DisplayStringAt(35, LINE(channel_idx+1), (uint8_t *)&text, LEFT_MODE);
Photonium 0:2e2716e8edb3 192 }
Photonium 0:2e2716e8edb3 193 rv=linecheck(channel_idx+16); //Line check (#)
Photonium 0:2e2716e8edb3 194 cv=1<<channel_idx+16;
Photonium 0:2e2716e8edb3 195 if (channel_idx+16 >15) {
Photonium 0:2e2716e8edb3 196 if(rv==cv) {
Photonium 0:2e2716e8edb3 197 lcd.SetTextColor(LCD_COLOR_GREEN);
Photonium 0:2e2716e8edb3 198 Result = "Okay";
Photonium 0:2e2716e8edb3 199 } else {
Photonium 0:2e2716e8edb3 200 lcd.SetTextColor(LCD_COLOR_RED);
Photonium 0:2e2716e8edb3 201 Result = "Error";
Photonium 0:2e2716e8edb3 202 }
Photonium 0:2e2716e8edb3 203 sprintf((char*)text,"Line(%d)=%s",channel_idx+16+1," ");
Photonium 0:2e2716e8edb3 204 lcd.DisplayStringAt(260, LINE(channel_idx+16-16+1), (uint8_t *)&text, LEFT_MODE);
Photonium 0:2e2716e8edb3 205 wait(.005);
Photonium 0:2e2716e8edb3 206 sprintf((char*)text,"Line(%d)=%s",channel_idx+16+1,Result.c_str());
Photonium 0:2e2716e8edb3 207 lcd.DisplayStringAt(260, LINE(channel_idx+16-16+1), (uint8_t *)&text, LEFT_MODE);
Photonium 0:2e2716e8edb3 208 }
Photonium 0:2e2716e8edb3 209 ts.ResetTouchData(&TS_State);
Photonium 0:2e2716e8edb3 210 ts.GetState(&TS_State);
Photonium 0:2e2716e8edb3 211 if (TS_State.touchDetected) {
Photonium 0:2e2716e8edb3 212 x = TS_State.touchX[idx];
Photonium 0:2e2716e8edb3 213 y = TS_State.touchY[idx];
Photonium 0:2e2716e8edb3 214 if (y>15 and y<275) {
Photonium 0:2e2716e8edb3 215 if (x>200 and x<250) {
Photonium 0:2e2716e8edb3 216 printf("Stop running 1:1 checking");
Photonium 0:2e2716e8edb3 217 mode=0;
Photonium 0:2e2716e8edb3 218 break;
Photonium 0:2e2716e8edb3 219 }
Photonium 0:2e2716e8edb3 220 }
Photonium 0:2e2716e8edb3 221 }
Photonium 0:2e2716e8edb3 222 }
Photonium 0:2e2716e8edb3 223 wait (.1);
Photonium 0:2e2716e8edb3 224 }
Photonium 0:2e2716e8edb3 225 }
Photonium 0:2e2716e8edb3 226 case 2: {
Photonium 0:2e2716e8edb3 227 while(mode==2) {
Photonium 0:2e2716e8edb3 228 lcd.Clear(DBLUE);
Photonium 0:2e2716e8edb3 229 lcd.SetBackColor(DBLUE);
Photonium 0:2e2716e8edb3 230 lcd.SetFont(&Font16);
Photonium 0:2e2716e8edb3 231 lcd.SetTextColor(LCD_COLOR_WHITE);
Photonium 0:2e2716e8edb3 232 sprintf((char*)text, "++++++++++++ Choose Cable ++++++++++++");
Photonium 0:2e2716e8edb3 233 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, CENTER_MODE);
Photonium 0:2e2716e8edb3 234 //printf("gmax= %d, g= %d CP=%d \r\n",gmax,g,g+10*bc);
Photonium 0:2e2716e8edb3 235 cp=1; //Cablepointer inside this codeblock (--> point actuell index onto cabledata )
Photonium 0:2e2716e8edb3 236 bc=0; //blockcounter (usage for second decimal value 10th)
Photonium 0:2e2716e8edb3 237 for (g=0; g<10; g++) {
Photonium 0:2e2716e8edb3 238 //.substr(0, myString.size()-2);
Photonium 0:2e2716e8edb3 239 //sprintf((char*)text,"(%d) %s\n",g+1,CableIndex[g].internal_name.c_str());
Photonium 0:2e2716e8edb3 240 sprintf((char*)text,"(%d) %s", g+1,CableIndex[g].internal_name.substr(0, CableIndex[g].internal_name.size()-1).c_str());
Photonium 0:2e2716e8edb3 241 lcd.DisplayStringAt(25, LINE(g+1), (uint8_t *)&text, LEFT_MODE);
Photonium 0:2e2716e8edb3 242 lcd.SetTextColor(LCD_COLOR_GREEN);
Photonium 0:2e2716e8edb3 243 lcd.DisplayStringAt(5, LINE(cp), (uint8_t *)"=>", LEFT_MODE);
Photonium 0:2e2716e8edb3 244 lcd.SetTextColor(LCD_COLOR_WHITE);
Photonium 0:2e2716e8edb3 245 }
Photonium 0:2e2716e8edb3 246 do {
Photonium 0:2e2716e8edb3 247 quad=quadchoose (quad);
Photonium 0:2e2716e8edb3 248 //printf("Quad=%c ",quad);
Photonium 0:2e2716e8edb3 249 if (quad=='>') {
Photonium 0:2e2716e8edb3 250 for(int n=1; n<11; n++) {
Photonium 0:2e2716e8edb3 251 lcd.DisplayStringAt(5, LINE(n), (uint8_t *)" ", LEFT_MODE);
Photonium 0:2e2716e8edb3 252 } //Clear of old ">" indicator
Photonium 0:2e2716e8edb3 253 cp++;
Photonium 0:2e2716e8edb3 254 if (cp==11) {
Photonium 0:2e2716e8edb3 255 if (gmax > cp+10*bc) {
Photonium 0:2e2716e8edb3 256 bc++;
Photonium 0:2e2716e8edb3 257 cp=1;
Photonium 0:2e2716e8edb3 258 } else {
Photonium 0:2e2716e8edb3 259 cp=10;
Photonium 0:2e2716e8edb3 260 }
Photonium 0:2e2716e8edb3 261 lcd.Clear(DBLUE);
Photonium 0:2e2716e8edb3 262 lcd.SetBackColor(DBLUE);
Photonium 0:2e2716e8edb3 263 sprintf((char*)text, "++++++++++++ Choose Cable ++++++++++++");
Photonium 0:2e2716e8edb3 264 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, CENTER_MODE);
Photonium 0:2e2716e8edb3 265 for (g=0; g<10; g++) {
Photonium 0:2e2716e8edb3 266 //sprintf((char*)text,"(%d) %s",(bc*10+g+1),CableIndex[(bc*10)+g].internal_name.c_str());
Photonium 0:2e2716e8edb3 267 sprintf((char*)text,"(%d) %s", (bc*10+g+1),CableIndex[(bc*10)+g].internal_name.substr(0, CableIndex[(bc*10)+g].internal_name.size()-1).c_str());
Photonium 0:2e2716e8edb3 268 lcd.DisplayStringAt(25, LINE(g+1), (uint8_t *)&text, LEFT_MODE);
Photonium 0:2e2716e8edb3 269 printf("(%d) %s",(bc*10+g+1),CableIndex[(bc*10)+g].internal_name.c_str());
Photonium 0:2e2716e8edb3 270 }
Photonium 0:2e2716e8edb3 271 }
Photonium 0:2e2716e8edb3 272 lcd.SetTextColor(LCD_COLOR_GREEN);
Photonium 0:2e2716e8edb3 273 lcd.DisplayStringAt(5, LINE(cp), (uint8_t *)"=>", LEFT_MODE);
Photonium 0:2e2716e8edb3 274 lcd.SetTextColor(LCD_COLOR_WHITE);
Photonium 0:2e2716e8edb3 275 }
Photonium 0:2e2716e8edb3 276 if (quad=='<') {
Photonium 0:2e2716e8edb3 277 for(int n=1; n<11; n++) {
Photonium 0:2e2716e8edb3 278
Photonium 0:2e2716e8edb3 279 lcd.DisplayStringAt(5, LINE(n), (uint8_t *)" ", LEFT_MODE);
Photonium 0:2e2716e8edb3 280 } //Clear of old ">" indicator
Photonium 0:2e2716e8edb3 281 cp--;
Photonium 0:2e2716e8edb3 282 printf("cp=%d\r\n",cp);
Photonium 0:2e2716e8edb3 283 if (cp==0) {
Photonium 0:2e2716e8edb3 284 if(bc>0) {
Photonium 0:2e2716e8edb3 285 bc--;
Photonium 0:2e2716e8edb3 286 cp=10;
Photonium 0:2e2716e8edb3 287 } else {
Photonium 0:2e2716e8edb3 288 cp=1;
Photonium 0:2e2716e8edb3 289 }
Photonium 0:2e2716e8edb3 290 lcd.Clear(DBLUE);
Photonium 0:2e2716e8edb3 291 lcd.SetBackColor(DBLUE);
Photonium 0:2e2716e8edb3 292 sprintf((char*)text, "++++++++++++ Choose Cable ++++++++++++");
Photonium 0:2e2716e8edb3 293 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, CENTER_MODE);
Photonium 0:2e2716e8edb3 294 for (g=0; g<10; g++) {
Photonium 0:2e2716e8edb3 295 printf("g=%d, bc=%d \r\n",g,bc);
Photonium 0:2e2716e8edb3 296 //sprintf((char*)text,"(%d) %s",(bc*10+g+1),CableIndex[bc*10+g].internal_name.c_str());
Photonium 0:2e2716e8edb3 297 sprintf((char*)text,"(%d) %s", (bc*10+g+1),CableIndex[(bc*10)+g].internal_name.substr(0, CableIndex[(bc*10)+g].internal_name.size()-1).c_str());
Photonium 0:2e2716e8edb3 298 lcd.DisplayStringAt(25, LINE(g+1), (uint8_t *)&text, LEFT_MODE);
Photonium 0:2e2716e8edb3 299 }
Photonium 0:2e2716e8edb3 300 }
Photonium 0:2e2716e8edb3 301 lcd.SetFont(&Font16);
Photonium 0:2e2716e8edb3 302 lcd.SetTextColor(LCD_COLOR_GREEN);
Photonium 0:2e2716e8edb3 303 lcd.DisplayStringAt(5, LINE(cp), (uint8_t *)"=>", LEFT_MODE);
Photonium 0:2e2716e8edb3 304 lcd.SetTextColor(LCD_COLOR_WHITE);
Photonium 0:2e2716e8edb3 305 }
Photonium 0:2e2716e8edb3 306
Photonium 0:2e2716e8edb3 307
Photonium 0:2e2716e8edb3 308 if (quad==13) {
Photonium 0:2e2716e8edb3 309 printf("ENTER DETECTED");
Photonium 0:2e2716e8edb3 310 mode=0;
Photonium 0:2e2716e8edb3 311
Photonium 0:2e2716e8edb3 312 //Testfunktion aufrufen
Photonium 0:2e2716e8edb3 313 //break;
Photonium 0:2e2716e8edb3 314 }
Photonium 0:2e2716e8edb3 315 if (quad==27) {
Photonium 0:2e2716e8edb3 316 printf("Escape DETECTED");
Photonium 0:2e2716e8edb3 317 mode=0;
Photonium 0:2e2716e8edb3 318 break;
Photonium 0:2e2716e8edb3 319 }
Photonium 0:2e2716e8edb3 320
Photonium 0:2e2716e8edb3 321 printf("CableIndex=%d \r\n",cp+10*bc);
Photonium 0:2e2716e8edb3 322 printf("---->Quad=%d \r\n",quad);
Photonium 0:2e2716e8edb3 323
Photonium 0:2e2716e8edb3 324 wait(.1);
Photonium 0:2e2716e8edb3 325 } while ((quad!=0x13)or(quad!=0x1b));
Photonium 0:2e2716e8edb3 326 }
Photonium 0:2e2716e8edb3 327
Photonium 0:2e2716e8edb3 328 break;
Photonium 0:2e2716e8edb3 329 //escrep=1;
Photonium 0:2e2716e8edb3 330 }
Photonium 0:2e2716e8edb3 331 default :
Photonium 0:2e2716e8edb3 332 printf("Switch/Case default code here");
Photonium 0:2e2716e8edb3 333 break;
Photonium 0:2e2716e8edb3 334 }
Photonium 0:2e2716e8edb3 335
Photonium 0:2e2716e8edb3 336
Photonium 0:2e2716e8edb3 337 /*wait(1);
Photonium 0:2e2716e8edb3 338 lcd.SetFont(&Font20);
Photonium 0:2e2716e8edb3 339 lcd.SetBackColor(DBLUE);
Photonium 0:2e2716e8edb3 340 lcd.SetTextColor(LCD_COLOR_WHITE);
Photonium 0:2e2716e8edb3 341 sprintf((char*)text,"ENDE ? Advanced Cable Tester" );
Photonium 0:2e2716e8edb3 342 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);
Photonium 0:2e2716e8edb3 343 while(1) {
Photonium 0:2e2716e8edb3 344 lcd.SetFont(&Font24);
Photonium 0:2e2716e8edb3 345 sprintf((char*)text, "Advanced Cable Tester");
Photonium 0:2e2716e8edb3 346 lcd.DisplayStringAt(60, LINE(4), (uint8_t *)&text, LEFT_MODE);
Photonium 0:2e2716e8edb3 347 sprintf((char*)text, "(Touch to start test)");
Photonium 0:2e2716e8edb3 348 lcd.DisplayStringAt(60, LINE(6), (uint8_t *)&text, LEFT_MODE);
Photonium 0:2e2716e8edb3 349 lcd.SetFont(&Font16);
Photonium 0:2e2716e8edb3 350 ts.GetState(&TS_State);
Photonium 0:2e2716e8edb3 351 if (TS_State.touchDetected) {
Photonium 0:2e2716e8edb3 352 // Clear lines corresponding to old touches coordinates
Photonium 0:2e2716e8edb3 353 if (TS_State.touchDetected < prev_nb_touches) {
Photonium 0:2e2716e8edb3 354 for (idx = (TS_State.touchDetected + 1); idx <= 5; idx++) {
Photonium 0:2e2716e8edb3 355 lcd.ClearStringLine(idx);
Photonium 0:2e2716e8edb3 356 }
Photonium 0:2e2716e8edb3 357 }
Photonium 0:2e2716e8edb3 358 prev_nb_touches = TS_State.touchDetected;
Photonium 0:2e2716e8edb3 359 cleared = 0;
Photonium 0:2e2716e8edb3 360 lcd.SetBackColor(DBLUE);
Photonium 0:2e2716e8edb3 361 lcd.SetTextColor(LCD_COLOR_WHITE);
Photonium 0:2e2716e8edb3 362 wait(1);
Photonium 0:2e2716e8edb3 363 x = TS_State.touchX[idx];
Photonium 0:2e2716e8edb3 364 y = TS_State.touchY[idx];
Photonium 0:2e2716e8edb3 365 } else {
Photonium 0:2e2716e8edb3 366 if (!cleared) {
Photonium 0:2e2716e8edb3 367 lcd.Clear(DBLUE);
Photonium 0:2e2716e8edb3 368 //sprintf((char*)text, "Touches: 0");
Photonium 0:2e2716e8edb3 369 //lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);
Photonium 0:2e2716e8edb3 370 cleared = 1;
Photonium 0:2e2716e8edb3 371 }
Photonium 0:2e2716e8edb3 372 }
Photonium 0:2e2716e8edb3 373 }
Photonium 0:2e2716e8edb3 374 */
Photonium 0:2e2716e8edb3 375 } while (1);
Photonium 0:2e2716e8edb3 376 }
Photonium 0:2e2716e8edb3 377
Photonium 0:2e2716e8edb3 378 uint32_t linecheck(uint8_t channel)
Photonium 0:2e2716e8edb3 379 {
Photonium 0:2e2716e8edb3 380 //####################################################################
Photonium 0:2e2716e8edb3 381 //Strategy: set only ONE bit ON of 32 channels and read all 32channel input
Photonium 0:2e2716e8edb3 382 //Save result in Array
Photonium 0:2e2716e8edb3 383 //then repeat that for next bit
Photonium 0:2e2716e8edb3 384 const int I2C_ChOut = 0x20<<1; // I2C address for input devices
Photonium 0:2e2716e8edb3 385 const int I2C_ChIn = 0x24<<1; // I2C address for output devices
Photonium 0:2e2716e8edb3 386 char channel_set [8] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
Photonium 0:2e2716e8edb3 387 char cmd [2]; //Variable for commandstring (send / read )input
Photonium 0:2e2716e8edb3 388
Photonium 0:2e2716e8edb3 389 char channel_result[4]; //Array for test-result
Photonium 0:2e2716e8edb3 390 uint8_t ChOffset=0;
Photonium 0:2e2716e8edb3 391 //uint8_t text[30];
Photonium 0:2e2716e8edb3 392 uint8_t channel_idx;
Photonium 0:2e2716e8edb3 393 //uint8_t channel_result=0;
Photonium 0:2e2716e8edb3 394
Photonium 0:2e2716e8edb3 395 channel_idx = channel;//-1;
Photonium 0:2e2716e8edb3 396 //wait (.005);
Photonium 0:2e2716e8edb3 397 ChOffset = abs(channel_idx/8);
Photonium 0:2e2716e8edb3 398 cmd[0] = 0x03;//configuration-register I2C device
Photonium 0:2e2716e8edb3 399 cmd[1] = 0x00;//sets this device for output
Photonium 0:2e2716e8edb3 400 i2c.write(I2C_ChOut+2*ChOffset, cmd, 2);//send 2 configbyte to I2C device
Photonium 0:2e2716e8edb3 401 cmd[0] = 0x01;// I2C device for output
Photonium 0:2e2716e8edb3 402 //cmd[1] = 0xFF & (channel_set[channel_idx%8]); //set bit for channel
Photonium 0:2e2716e8edb3 403 cmd[1] = channel_set[channel_idx%8];//bitpattern
Photonium 0:2e2716e8edb3 404 i2c.write(I2C_ChOut+2*ChOffset, cmd, 2);//Send bitpattern for output
Photonium 0:2e2716e8edb3 405 //wait(0.001);// on for 5ms !!!!!!!!!!! modified
Photonium 0:2e2716e8edb3 406 /////cmd[0] = 0x03;//configurationregister I2C device
Photonium 0:2e2716e8edb3 407 /////cmd[1] = 0xFF;//set this 8Bit device for Input
Photonium 0:2e2716e8edb3 408 /////i2c.write(I2C_ChIn, cmd, 2);//send 2 configbyte to I2C device
Photonium 0:2e2716e8edb3 409 cmd[0] = 0x00;
Photonium 0:2e2716e8edb3 410 i2c.write(I2C_ChIn+0, cmd, 1);
Photonium 0:2e2716e8edb3 411 i2c.read(I2C_ChIn+0, cmd, 1);
Photonium 0:2e2716e8edb3 412 channel_result[0]=cmd[0];
Photonium 0:2e2716e8edb3 413 //printf ("R=%d ch=%d \r\n", cmd[0],channel_idx);
Photonium 0:2e2716e8edb3 414 cmd[0] = 0x00;
Photonium 0:2e2716e8edb3 415 i2c.write(I2C_ChIn+2, cmd, 1);
Photonium 0:2e2716e8edb3 416 i2c.read(I2C_ChIn+2, cmd, 1);
Photonium 0:2e2716e8edb3 417 channel_result[1]=cmd[0];
Photonium 0:2e2716e8edb3 418 //printf ("R=%d ch=%d \r\n", cmd[0],channel_idx);
Photonium 0:2e2716e8edb3 419 cmd[0] = 0x00;
Photonium 0:2e2716e8edb3 420 i2c.write(I2C_ChIn+4, cmd, 1);
Photonium 0:2e2716e8edb3 421 i2c.read(I2C_ChIn+4, cmd, 1);
Photonium 0:2e2716e8edb3 422 channel_result[2]=cmd[0];
Photonium 0:2e2716e8edb3 423 //printf ("R=%d ch=%d \r\n", cmd[0],channel_idx);
Photonium 0:2e2716e8edb3 424 cmd[0] = 0x00;
Photonium 0:2e2716e8edb3 425 i2c.write(I2C_ChIn+6, cmd, 1);
Photonium 0:2e2716e8edb3 426 i2c.read(I2C_ChIn+6, cmd, 1);
Photonium 0:2e2716e8edb3 427 channel_result[3]=cmd[0];
Photonium 0:2e2716e8edb3 428 printf ("Ch:%d R%d %d %d %d \r\n",channel_idx,channel_result[0],channel_result[1],channel_result[2],channel_result[3]);
Photonium 0:2e2716e8edb3 429 /////////------ read
Photonium 0:2e2716e8edb3 430 /*cmd[0] = 0x03;//configurationregister I2C device
Photonium 0:2e2716e8edb3 431 cmd[1] = 0xFF;//sets 8bit of this device for intput
Photonium 0:2e2716e8edb3 432 i2c.write(I2C_ChIn+2*0, cmd, 2);//send config I2C device for output
Photonium 0:2e2716e8edb3 433 cmd[0]= 0x0;
Photonium 0:2e2716e8edb3 434 i2c.write(I2C_ChIn+2*0, cmd, 1);// prepare to read
Photonium 0:2e2716e8edb3 435 i2c.read(I2C_ChIn+2*0, cmd, 1);
Photonium 0:2e2716e8edb3 436 printf ("R=%d ch=%d \r\n", cmd[0],channel_idx);*/
Photonium 0:2e2716e8edb3 437 //channel_result=cmd[0];
Photonium 0:2e2716e8edb3 438 ////////
Photonium 0:2e2716e8edb3 439
Photonium 0:2e2716e8edb3 440 cmd[0] = 0x03;
Photonium 0:2e2716e8edb3 441 cmd[1] = 0x00;//config to out
Photonium 0:2e2716e8edb3 442 i2c.write(I2C_ChOut+2*ChOffset, cmd, 2);
Photonium 0:2e2716e8edb3 443 cmd[0] = 0x01;
Photonium 0:2e2716e8edb3 444 cmd[1] = 0x00; //bitpattern
Photonium 0:2e2716e8edb3 445 i2c.write(I2C_ChOut+2*ChOffset, cmd, 2);
Photonium 0:2e2716e8edb3 446 //wait (.001);
Photonium 0:2e2716e8edb3 447 rv=256*256*256*channel_result[3]+256*256*channel_result[2]+256*channel_result[1]+channel_result[0];
Photonium 0:2e2716e8edb3 448 printf ("RV: %d \r\n",rv);
Photonium 0:2e2716e8edb3 449 return rv; // 32Bit in 4 Byte
Photonium 0:2e2716e8edb3 450 }
Photonium 0:2e2716e8edb3 451
Photonium 0:2e2716e8edb3 452 uint8_t trippelchoose (uint8_t mode)
Photonium 0:2e2716e8edb3 453 {
Photonium 0:2e2716e8edb3 454
Photonium 0:2e2716e8edb3 455 lcd.DrawRect(13, 185, 135, 40);
Photonium 0:2e2716e8edb3 456 lcd.DisplayStringAt(25, LINE(12), (uint8_t *)"1:1 Cable", LEFT_MODE);
Photonium 0:2e2716e8edb3 457
Photonium 0:2e2716e8edb3 458 lcd.DrawRect(173, 185, 135, 40);
Photonium 0:2e2716e8edb3 459 lcd.DisplayStringAt(180, LINE(12), (uint8_t *)"Choose from", LEFT_MODE);
Photonium 0:2e2716e8edb3 460 lcd.DisplayStringAt(180, LINE(13), (uint8_t *)" SD-Card", LEFT_MODE);
Photonium 0:2e2716e8edb3 461
Photonium 0:2e2716e8edb3 462 lcd.DrawRect(333, 185, 135, 40);
Photonium 0:2e2716e8edb3 463 lcd.DisplayStringAt(340, LINE(12), (uint8_t *)"Learn new", LEFT_MODE);
Photonium 0:2e2716e8edb3 464 wait(.1);
Photonium 0:2e2716e8edb3 465 //printf("#####\r\n");
Photonium 0:2e2716e8edb3 466 ts.ResetTouchData(&TS_State);
Photonium 0:2e2716e8edb3 467 ts.GetState(&TS_State);
Photonium 0:2e2716e8edb3 468 if (TS_State.touchDetected) {
Photonium 0:2e2716e8edb3 469 x = TS_State.touchX[idx];
Photonium 0:2e2716e8edb3 470 y = TS_State.touchY[idx];
Photonium 0:2e2716e8edb3 471
Photonium 0:2e2716e8edb3 472 if (y>185 and y<185+40) {
Photonium 0:2e2716e8edb3 473 if (x>13 and x<135+13) {
Photonium 0:2e2716e8edb3 474 mode=1;
Photonium 0:2e2716e8edb3 475 }
Photonium 0:2e2716e8edb3 476 if (x>173 and x<173+135) {
Photonium 0:2e2716e8edb3 477 mode=2;
Photonium 0:2e2716e8edb3 478 }
Photonium 0:2e2716e8edb3 479 if (x>333 and x<333+135) {
Photonium 0:2e2716e8edb3 480 mode=3;
Photonium 0:2e2716e8edb3 481 }
Photonium 0:2e2716e8edb3 482 }
Photonium 0:2e2716e8edb3 483 printf("X=%d Y=%d Modus=%d \r\n",TS_State.touchX[idx],y,mode);
Photonium 0:2e2716e8edb3 484 //prev_nb_touches = TS_State.touchDetected;
Photonium 0:2e2716e8edb3 485 //cleared = 0;
Photonium 0:2e2716e8edb3 486 }
Photonium 0:2e2716e8edb3 487
Photonium 0:2e2716e8edb3 488 return mode;
Photonium 0:2e2716e8edb3 489 }
Photonium 0:2e2716e8edb3 490 uint8_t readCabletext()
Photonium 0:2e2716e8edb3 491 {
Photonium 0:2e2716e8edb3 492 //Read and Parsing of intput file "cable.txt" from SD-Card
Photonium 0:2e2716e8edb3 493 printf("Opening file read-only.");
Photonium 0:2e2716e8edb3 494 //FILE* fd = fopen("/fs/numbers5.txt", "w");
Photonium 0:2e2716e8edb3 495 //FILE* fd = fopen("/fs/cable.txt", "r");
Photonium 0:2e2716e8edb3 496
Photonium 0:2e2716e8edb3 497 std::ifstream fd("/fs/cable.txt"); //öffnet die Datei als c++ stream. fd = name der variable
Photonium 0:2e2716e8edb3 498 std::string line; //variable für die aktuelle Zeile
Photonium 0:2e2716e8edb3 499 printf("geoeffnet ?\n");
Photonium 0:2e2716e8edb3 500 while(std::getline(fd, line)) { //solange die zeilen gelesen werden können
Photonium 0:2e2716e8edb3 501 printf("%s\n", line.c_str()); //gelesene zeile als c-string ausgeben
Photonium 0:2e2716e8edb3 502 //printf("inWhile ?\n");
Photonium 0:2e2716e8edb3 503 }
Photonium 0:2e2716e8edb3 504 //Der zweite Teil ist C++ aber mit ein bisschen C an einigen Stellen
Photonium 0:2e2716e8edb3 505 FILE* fd2 = fopen("/fs/cable.txt", "r"); //datei zum "lesen als textdatei" öffnen
Photonium 0:2e2716e8edb3 506 std::string line2;
Photonium 0:2e2716e8edb3 507 printf("geoeffnet ?\r\n");
Photonium 0:2e2716e8edb3 508 int lc=0;
Photonium 0:2e2716e8edb3 509 while(!feof(fd2)) {
Photonium 0:2e2716e8edb3 510 char buffer[1] = {0}; //buffer für das zu lesende byte
Photonium 0:2e2716e8edb3 511 int bytes_read = fread(&buffer, 1, sizeof(char), fd2); // 1 byte (zeichen) lesen
Photonium 0:2e2716e8edb3 512 if (*buffer != '\n') { //wenn buffer nicht '\n' (neue zeile) ist
Photonium 0:2e2716e8edb3 513 line2 = line2 + &buffer[0]; //string um aktuelles zeichen erweitern
Photonium 0:2e2716e8edb3 514 }
Photonium 0:2e2716e8edb3 515 if (*buffer == '\n') { //wenn neue zeile gefunden
Photonium 0:2e2716e8edb3 516 //printf("(%d) %s\n",lc%4, line2.c_str()); //zeile ausgeben
Photonium 0:2e2716e8edb3 517 switch(lc%4) {
Photonium 0:2e2716e8edb3 518 case 0:{
Photonium 0:2e2716e8edb3 519 CableIndex[g].internal_name=line2.c_str();
Photonium 0:2e2716e8edb3 520 printf("(g=%d)(lc=%d) Internal-Name= %s\r\n",g,lc, CableIndex[g].internal_name.c_str());
Photonium 0:2e2716e8edb3 521 line2 = ""; //zeile löschen
Photonium 0:2e2716e8edb3 522 lc++;
Photonium 0:2e2716e8edb3 523 break;
Photonium 0:2e2716e8edb3 524 }
Photonium 0:2e2716e8edb3 525 case 1:{
Photonium 0:2e2716e8edb3 526 CableIndex[g].navision_number=line2.c_str();
Photonium 0:2e2716e8edb3 527 printf("(g=%d) (lc=%d) Navision-Number= %s\r\n", g,lc,CableIndex[g].navision_number.c_str());
Photonium 0:2e2716e8edb3 528 line2 = ""; //zeile löschen
Photonium 0:2e2716e8edb3 529 lc++;
Photonium 0:2e2716e8edb3 530 break;
Photonium 0:2e2716e8edb3 531 }
Photonium 0:2e2716e8edb3 532 case 2:{
Photonium 0:2e2716e8edb3 533 string hs=line2.c_str();
Photonium 0:2e2716e8edb3 534 string::iterator zg;
Photonium 0:2e2716e8edb3 535 uint8_t cf=0;
Photonium 0:2e2716e8edb3 536 for (zg=hs.begin();zg<hs.end(); zg++) {
Photonium 0:2e2716e8edb3 537 if ((*zg>47)&&(*zg<59)) {
Photonium 0:2e2716e8edb3 538 CableIndex[g].wiring_in[cf] = (*(zg)-48)*10+(*(zg+1)-48);
Photonium 0:2e2716e8edb3 539 zg=zg+2;
Photonium 0:2e2716e8edb3 540 cf++;
Photonium 0:2e2716e8edb3 541 }//end_if
Photonium 0:2e2716e8edb3 542 }// end_for
Photonium 0:2e2716e8edb3 543 line2 = ""; //zeile löschen
Photonium 0:2e2716e8edb3 544 for (int ci = 0; ci < 32; ci++) //Fertige Zeile einmal ausgeben
Photonium 0:2e2716e8edb3 545 {
Photonium 0:2e2716e8edb3 546 printf("[%d]", CableIndex[g].wiring_in[ci]);
Photonium 0:2e2716e8edb3 547 } //end_for
Photonium 0:2e2716e8edb3 548 printf("\r\n");
Photonium 0:2e2716e8edb3 549 line2 = ""; //zeile löschen
Photonium 0:2e2716e8edb3 550 lc++;
Photonium 0:2e2716e8edb3 551 break;
Photonium 0:2e2716e8edb3 552 }
Photonium 0:2e2716e8edb3 553 case 3:{
Photonium 0:2e2716e8edb3 554 string hs=line2.c_str();
Photonium 0:2e2716e8edb3 555 string::iterator zg;
Photonium 0:2e2716e8edb3 556 uint8_t cf=0;
Photonium 0:2e2716e8edb3 557 for (zg=hs.begin();zg<hs.end(); zg++) {
Photonium 0:2e2716e8edb3 558 if ((*zg>47)&&(*zg<59)) {
Photonium 0:2e2716e8edb3 559 CableIndex[g].wiring_out[cf] = (*(zg)-48)*10+(*(zg+1)-48);
Photonium 0:2e2716e8edb3 560 zg=zg+2;
Photonium 0:2e2716e8edb3 561 cf++;
Photonium 0:2e2716e8edb3 562 }//end_if
Photonium 0:2e2716e8edb3 563 }// end_for
Photonium 0:2e2716e8edb3 564 line2 = ""; //zeile löschen
Photonium 0:2e2716e8edb3 565 for (int ci = 0; ci < 32; ci++) //Fertige Zeile einmal ausgeben
Photonium 0:2e2716e8edb3 566 {
Photonium 0:2e2716e8edb3 567 printf("(%d)", CableIndex[g].wiring_out[ci]);
Photonium 0:2e2716e8edb3 568 } //end_for
Photonium 0:2e2716e8edb3 569 printf("\r\n");
Photonium 0:2e2716e8edb3 570
Photonium 0:2e2716e8edb3 571 line2 = ""; //zeile löschen
Photonium 0:2e2716e8edb3 572 lc++;
Photonium 0:2e2716e8edb3 573 break;
Photonium 0:2e2716e8edb3 574 }
Photonium 0:2e2716e8edb3 575
Photonium 0:2e2716e8edb3 576
Photonium 0:2e2716e8edb3 577
Photonium 0:2e2716e8edb3 578
Photonium 0:2e2716e8edb3 579
Photonium 0:2e2716e8edb3 580 }
Photonium 0:2e2716e8edb3 581
Photonium 0:2e2716e8edb3 582 line2 = ""; //zeile löschen
Photonium 0:2e2716e8edb3 583
Photonium 0:2e2716e8edb3 584 if (lc==4) {
Photonium 0:2e2716e8edb3 585 lc=0;
Photonium 0:2e2716e8edb3 586 g++;}
Photonium 0:2e2716e8edb3 587 }
Photonium 0:2e2716e8edb3 588 }
Photonium 0:2e2716e8edb3 589 fclose(fd2);//datei nach dem lesen schließen
Photonium 0:2e2716e8edb3 590 //return 0;
Photonium 0:2e2716e8edb3 591
Photonium 0:2e2716e8edb3 592 //fd.close(); //datei nach lesen schließen
Photonium 0:2e2716e8edb3 593 //errno_error(fd);
Photonium 0:2e2716e8edb3 594
Photonium 0:2e2716e8edb3 595 gmax=g;
Photonium 0:2e2716e8edb3 596 return gmax;
Photonium 0:2e2716e8edb3 597
Photonium 0:2e2716e8edb3 598 }
Photonium 0:2e2716e8edb3 599
Photonium 0:2e2716e8edb3 600 uint8_t quadchoose (uint8_t quad)
Photonium 0:2e2716e8edb3 601 {
Photonium 0:2e2716e8edb3 602 quad =0;
Photonium 0:2e2716e8edb3 603 lcd.SetFont(&Font24);
Photonium 0:2e2716e8edb3 604 lcd.DrawRect(15, 200, 90, 60);
Photonium 0:2e2716e8edb3 605 lcd.DisplayStringAt(45, LINE(9), (uint8_t *)"<", LEFT_MODE);
Photonium 0:2e2716e8edb3 606
Photonium 0:2e2716e8edb3 607 lcd.DrawRect(135, 200, 90,60);
Photonium 0:2e2716e8edb3 608 lcd.DisplayStringAt(155, LINE(9), (uint8_t *)"ESC", LEFT_MODE);
Photonium 0:2e2716e8edb3 609
Photonium 0:2e2716e8edb3 610 lcd.DrawRect(255, 200, 90, 60);
Photonium 0:2e2716e8edb3 611 lcd.DisplayStringAt(275, LINE(9), (uint8_t *)"ENT", LEFT_MODE);
Photonium 0:2e2716e8edb3 612
Photonium 0:2e2716e8edb3 613 lcd.DrawRect(375, 200, 90, 60);
Photonium 0:2e2716e8edb3 614 lcd.DisplayStringAt(405, LINE(9), (uint8_t *)">", LEFT_MODE);
Photonium 0:2e2716e8edb3 615
Photonium 0:2e2716e8edb3 616 lcd.SetFont(&Font16);
Photonium 0:2e2716e8edb3 617 do {
Photonium 0:2e2716e8edb3 618 ts.ResetTouchData(&TS_State);
Photonium 0:2e2716e8edb3 619 ts.GetState(&TS_State);
Photonium 0:2e2716e8edb3 620 if (TS_State.touchDetected) {
Photonium 0:2e2716e8edb3 621 x = TS_State.touchX[idx];
Photonium 0:2e2716e8edb3 622 y = TS_State.touchY[idx];
Photonium 0:2e2716e8edb3 623 if (y>200 and y<200+60) {
Photonium 0:2e2716e8edb3 624 if (x>15 and x<15+90) {
Photonium 0:2e2716e8edb3 625 quad='<';//back
Photonium 0:2e2716e8edb3 626 }
Photonium 0:2e2716e8edb3 627 if (x>135 and x<135+90) {
Photonium 0:2e2716e8edb3 628 quad=0x1b;//escape
Photonium 0:2e2716e8edb3 629 }
Photonium 0:2e2716e8edb3 630 if (x>255 and x<255+90) {
Photonium 0:2e2716e8edb3 631 quad=0x0d;//enter
Photonium 0:2e2716e8edb3 632 }
Photonium 0:2e2716e8edb3 633 if (x>375 and x<375+90) {
Photonium 0:2e2716e8edb3 634 quad='>';//forward
Photonium 0:2e2716e8edb3 635 }
Photonium 0:2e2716e8edb3 636 }
Photonium 0:2e2716e8edb3 637 }
Photonium 0:2e2716e8edb3 638 } while (quad==0);
Photonium 0:2e2716e8edb3 639 return quad;
Photonium 0:2e2716e8edb3 640 }