BRISIO NOS CAES MAL

Dependencies:   Led7Seg mbed tsi_sensor MMA8451Q FastPWM

Committer:
Jalle
Date:
Thu Nov 28 03:41:10 2019 +0000
Revision:
0:4a439d892f7c
COMMIT AGUANTE LA COMICSANS;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jalle 0:4a439d892f7c 1 #include "mbed.h"
Jalle 0:4a439d892f7c 2 #include "tsi_sensor.h"
Jalle 0:4a439d892f7c 3 #include "MMA8451Q.h"
Jalle 0:4a439d892f7c 4 #include "math.h"
Jalle 0:4a439d892f7c 5 #if defined (TARGET_KL25Z) || defined (TARGET_KL46Z)
Jalle 0:4a439d892f7c 6 PinName const SDA = PTE25;
Jalle 0:4a439d892f7c 7 PinName const SCL = PTE24;
Jalle 0:4a439d892f7c 8 #elif defined (TARGET_KL05Z)
Jalle 0:4a439d892f7c 9 PinName const SDA = PTB4;
Jalle 0:4a439d892f7c 10 PinName const SCL = PTB3;
Jalle 0:4a439d892f7c 11 #elif defined (TARGET_K20D50M)
Jalle 0:4a439d892f7c 12 PinName const SDA = PTB1;
Jalle 0:4a439d892f7c 13 PinName const SCL = PTB0;
Jalle 0:4a439d892f7c 14 #else
Jalle 0:4a439d892f7c 15 #error TARGET NOT DEFINED
Jalle 0:4a439d892f7c 16 #endif
Jalle 0:4a439d892f7c 17 #define M_PI 3.14159265358979323846
Jalle 0:4a439d892f7c 18
Jalle 0:4a439d892f7c 19 #define MMA8451_I2C_ADDRESS (0x1d<<1)
Jalle 0:4a439d892f7c 20
Jalle 0:4a439d892f7c 21 /* This defines will be replaced by PinNames soon */
Jalle 0:4a439d892f7c 22 #if defined (TARGET_KL25Z) || defined (TARGET_KL46Z)
Jalle 0:4a439d892f7c 23 #define ELEC0 9
Jalle 0:4a439d892f7c 24 #define ELEC1 10
Jalle 0:4a439d892f7c 25 #elif defined (TARGET_KL05Z)
Jalle 0:4a439d892f7c 26 #define ELEC0 9
Jalle 0:4a439d892f7c 27 #define ELEC1 8
Jalle 0:4a439d892f7c 28 #else
Jalle 0:4a439d892f7c 29 #error TARGET NOT DEFINED
Jalle 0:4a439d892f7c 30 #endif
Jalle 0:4a439d892f7c 31
Jalle 0:4a439d892f7c 32 //unidades:
Jalle 0:4a439d892f7c 33 DigitalOut uni1(PTC9); //(g)
Jalle 0:4a439d892f7c 34 DigitalOut uni2(PTC8); //(f)
Jalle 0:4a439d892f7c 35 DigitalOut uni3(PTD4); //(e)
Jalle 0:4a439d892f7c 36 DigitalOut uni4(PTA12); //(d)
Jalle 0:4a439d892f7c 37 DigitalOut uni5(PTA4); //(c)
Jalle 0:4a439d892f7c 38 DigitalOut uni6(PTA5); //(b)
Jalle 0:4a439d892f7c 39 DigitalOut uni7(PTC6); //(a)
Jalle 0:4a439d892f7c 40
Jalle 0:4a439d892f7c 41 DigitalOut dec1(PTC12);
Jalle 0:4a439d892f7c 42 DigitalOut dec2(PTC13);
Jalle 0:4a439d892f7c 43 DigitalOut dec3(PTC16);
Jalle 0:4a439d892f7c 44 DigitalOut dec4(PTC17);
Jalle 0:4a439d892f7c 45 DigitalOut dec5(PTA13);
Jalle 0:4a439d892f7c 46 DigitalOut dec6(PTD5);
Jalle 0:4a439d892f7c 47 DigitalOut dec7(PTD0);
Jalle 0:4a439d892f7c 48
Jalle 0:4a439d892f7c 49 BusOut display(PTC9,PTC8,PTD4,PTA12,PTA4,PTA5,PTC6);
Jalle 0:4a439d892f7c 50
Jalle 0:4a439d892f7c 51 DigitalOut habuni(PTD7);
Jalle 0:4a439d892f7c 52 DigitalOut habdec(PTD6);
Jalle 0:4a439d892f7c 53
Jalle 0:4a439d892f7c 54 DigitalIn enta(PTC7);
Jalle 0:4a439d892f7c 55 DigitalIn entb(PTC0);
Jalle 0:4a439d892f7c 56 DigitalIn entc(PTC3);
Jalle 0:4a439d892f7c 57 DigitalIn entd(PTC4);
Jalle 0:4a439d892f7c 58
Jalle 0:4a439d892f7c 59 AnalogIn analog1(PTB1);
Jalle 0:4a439d892f7c 60
Jalle 0:4a439d892f7c 61 DigitalIn digital1(PTB2);
Jalle 0:4a439d892f7c 62 DigitalIn digital2(PTB3);
Jalle 0:4a439d892f7c 63 int a=0;
Jalle 0:4a439d892f7c 64 unsigned int e=0,cuenta=2,cantidad=4,estado=0,mal=0,nuevo=0,erro=0,b=0,demo=0,ap=4,tiempo=20,s=0,acta=0,actb=0,actc=0,actd=0,uni=0,dec=0,bar=0,guar1=0,guar2=0,l1,l2,l3,d=0,la1=0,la2=0,la3=0,partea,parteb;
Jalle 0:4a439d892f7c 65 int anl1,anl2,esto;
Jalle 0:4a439d892f7c 66 int dig1,dig2;
Jalle 0:4a439d892f7c 67 int dato[50]= {0,1,2,3},almacen[15];
Jalle 0:4a439d892f7c 68 int dato2[50];
Jalle 0:4a439d892f7c 69 Ticker barrido;
Jalle 0:4a439d892f7c 70 Ticker jorge;
Jalle 0:4a439d892f7c 71 void funcion();
Jalle 0:4a439d892f7c 72 void ctrl_barrido();
Jalle 0:4a439d892f7c 73
Jalle 0:4a439d892f7c 74
Jalle 0:4a439d892f7c 75
Jalle 0:4a439d892f7c 76 //Definimos que el puerto serie se llama pc
Jalle 0:4a439d892f7c 77 Serial pc(USBTX, USBRX);
Jalle 0:4a439d892f7c 78 //Variable donde se guarda lo leido
Jalle 0:4a439d892f7c 79 char buffer[128];
Jalle 0:4a439d892f7c 80 char c;
Jalle 0:4a439d892f7c 81 //bit usado como flag para procesar datos
Jalle 0:4a439d892f7c 82 bool newdata = false; //Se pone en true cuando hay nuevos datos
Jalle 0:4a439d892f7c 83
Jalle 0:4a439d892f7c 84 //Creamos los tres leds pra usar
Jalle 0:4a439d892f7c 85 DigitalOut led1(LED1);
Jalle 0:4a439d892f7c 86 DigitalOut led2(LED2);
Jalle 0:4a439d892f7c 87 DigitalOut led3(LED3);
Jalle 0:4a439d892f7c 88
Jalle 0:4a439d892f7c 89 AnalogOut dac(PTE30);
Jalle 0:4a439d892f7c 90
Jalle 0:4a439d892f7c 91 //Callback cuando se detecta una entrada
Jalle 0:4a439d892f7c 92 void onCharReceived()
Jalle 0:4a439d892f7c 93 {
Jalle 0:4a439d892f7c 94 //Copiamos lo leido en c
Jalle 0:4a439d892f7c 95
Jalle 0:4a439d892f7c 96
Jalle 0:4a439d892f7c 97 c = pc.getc();
Jalle 0:4a439d892f7c 98 newdata = true;
Jalle 0:4a439d892f7c 99
Jalle 0:4a439d892f7c 100
Jalle 0:4a439d892f7c 101
Jalle 0:4a439d892f7c 102 }
Jalle 0:4a439d892f7c 103
Jalle 0:4a439d892f7c 104
Jalle 0:4a439d892f7c 105
Jalle 0:4a439d892f7c 106 //function : hex2int
Jalle 0:4a439d892f7c 107 //this function will return integer value against
Jalle 0:4a439d892f7c 108 //hexValue - which is in string format
Jalle 0:4a439d892f7c 109
Jalle 0:4a439d892f7c 110
Jalle 0:4a439d892f7c 111
Jalle 0:4a439d892f7c 112 int main()
Jalle 0:4a439d892f7c 113 {
Jalle 0:4a439d892f7c 114 //Apagamos los leds
Jalle 0:4a439d892f7c 115 led1 = 1;
Jalle 0:4a439d892f7c 116 led2 = 1;
Jalle 0:4a439d892f7c 117 led3 = 1;
Jalle 0:4a439d892f7c 118 //Ejecutar onCharReceived por cada entrada por puerto
Jalle 0:4a439d892f7c 119 pc.attach(&onCharReceived);
Jalle 0:4a439d892f7c 120 TSIAnalogSlider tsi(ELEC0, ELEC1, 100);
Jalle 0:4a439d892f7c 121
Jalle 0:4a439d892f7c 122 while (true) {
Jalle 0:4a439d892f7c 123
Jalle 0:4a439d892f7c 124 if(newdata==true) {
Jalle 0:4a439d892f7c 125 newdata=false;
Jalle 0:4a439d892f7c 126
Jalle 0:4a439d892f7c 127
Jalle 0:4a439d892f7c 128 switch(estado) {
Jalle 0:4a439d892f7c 129 default:
Jalle 0:4a439d892f7c 130 case 0:
Jalle 0:4a439d892f7c 131 esto=0;
Jalle 0:4a439d892f7c 132 //printf("caso 1\n");
Jalle 0:4a439d892f7c 133
Jalle 0:4a439d892f7c 134 d=0;
Jalle 0:4a439d892f7c 135 if(c=='$')
Jalle 0:4a439d892f7c 136 estado=1;
Jalle 0:4a439d892f7c 137 a='$';
Jalle 0:4a439d892f7c 138 la1=led1;
Jalle 0:4a439d892f7c 139 la2=led2;
Jalle 0:4a439d892f7c 140
Jalle 0:4a439d892f7c 141 la3=led3;
Jalle 0:4a439d892f7c 142
Jalle 0:4a439d892f7c 143
Jalle 0:4a439d892f7c 144 break;
Jalle 0:4a439d892f7c 145 case 1:
Jalle 0:4a439d892f7c 146 if (c=='R') {
Jalle 0:4a439d892f7c 147 estado=2;
Jalle 0:4a439d892f7c 148 a=a^'R';
Jalle 0:4a439d892f7c 149 }
Jalle 0:4a439d892f7c 150 if (c=='W') {
Jalle 0:4a439d892f7c 151 estado=11;
Jalle 0:4a439d892f7c 152 a=a^'W';
Jalle 0:4a439d892f7c 153 }
Jalle 0:4a439d892f7c 154
Jalle 0:4a439d892f7c 155 if(estado==1)
Jalle 0:4a439d892f7c 156 estado=0;
Jalle 0:4a439d892f7c 157
Jalle 0:4a439d892f7c 158 if (c=='$') {
Jalle 0:4a439d892f7c 159 estado=1;
Jalle 0:4a439d892f7c 160 a='$';
Jalle 0:4a439d892f7c 161 }
Jalle 0:4a439d892f7c 162
Jalle 0:4a439d892f7c 163 break;
Jalle 0:4a439d892f7c 164 case 2:
Jalle 0:4a439d892f7c 165 if(c=='A') {
Jalle 0:4a439d892f7c 166
Jalle 0:4a439d892f7c 167 a=a^'A';
Jalle 0:4a439d892f7c 168 estado=4;
Jalle 0:4a439d892f7c 169 }
Jalle 0:4a439d892f7c 170 if(c=='L') {
Jalle 0:4a439d892f7c 171 a=a^'L';
Jalle 0:4a439d892f7c 172 estado=6;
Jalle 0:4a439d892f7c 173 }
Jalle 0:4a439d892f7c 174 if(c=='D') {
Jalle 0:4a439d892f7c 175 a=a^'L';
Jalle 0:4a439d892f7c 176 estado=26;
Jalle 0:4a439d892f7c 177 }
Jalle 0:4a439d892f7c 178
Jalle 0:4a439d892f7c 179 if(c=='I') {
Jalle 0:4a439d892f7c 180 a=a^'I';
Jalle 0:4a439d892f7c 181 estado=5;
Jalle 0:4a439d892f7c 182 }
Jalle 0:4a439d892f7c 183 if(estado==2)
Jalle 0:4a439d892f7c 184 estado=0;
Jalle 0:4a439d892f7c 185
Jalle 0:4a439d892f7c 186
Jalle 0:4a439d892f7c 187 break;
Jalle 0:4a439d892f7c 188
Jalle 0:4a439d892f7c 189 case 26:
Jalle 0:4a439d892f7c 190 if(c=='1') {
Jalle 0:4a439d892f7c 191 a=a^'1';
Jalle 0:4a439d892f7c 192 e=26;
Jalle 0:4a439d892f7c 193 //$RD1ff!
Jalle 0:4a439d892f7c 194 estado=27;
Jalle 0:4a439d892f7c 195 }
Jalle 0:4a439d892f7c 196 break;
Jalle 0:4a439d892f7c 197
Jalle 0:4a439d892f7c 198 case 27:
Jalle 0:4a439d892f7c 199
Jalle 0:4a439d892f7c 200
Jalle 0:4a439d892f7c 201 //$RD1f
Jalle 0:4a439d892f7c 202
Jalle 0:4a439d892f7c 203
Jalle 0:4a439d892f7c 204 esto=c*10;
Jalle 0:4a439d892f7c 205 estado=28;
Jalle 0:4a439d892f7c 206 // printf("tenemos ahora %d\n",esto);
Jalle 0:4a439d892f7c 207
Jalle 0:4a439d892f7c 208
Jalle 0:4a439d892f7c 209 break;
Jalle 0:4a439d892f7c 210
Jalle 0:4a439d892f7c 211 case 28:
Jalle 0:4a439d892f7c 212
Jalle 0:4a439d892f7c 213 esto=esto+c;
Jalle 0:4a439d892f7c 214 float susso =(((esto/99.0)-5.5)/1.3);
Jalle 0:4a439d892f7c 215 printf("eee %f eee",susso);
Jalle 0:4a439d892f7c 216
Jalle 0:4a439d892f7c 217
Jalle 0:4a439d892f7c 218 dac=susso;
Jalle 0:4a439d892f7c 219 estado=0;
Jalle 0:4a439d892f7c 220 break;
Jalle 0:4a439d892f7c 221 /*if(c=='0')
Jalle 0:4a439d892f7c 222 c=0;
Jalle 0:4a439d892f7c 223 if(c=='1')
Jalle 0:4a439d892f7c 224 c=1;
Jalle 0:4a439d892f7c 225 if(c=='2')
Jalle 0:4a439d892f7c 226 c=2;
Jalle 0:4a439d892f7c 227 if(c=='3')
Jalle 0:4a439d892f7c 228 c=3;
Jalle 0:4a439d892f7c 229 if(c=='4')
Jalle 0:4a439d892f7c 230 c=4;
Jalle 0:4a439d892f7c 231 if(c=='5')
Jalle 0:4a439d892f7c 232 c=5;
Jalle 0:4a439d892f7c 233 if(c=='6')
Jalle 0:4a439d892f7c 234 c=6;
Jalle 0:4a439d892f7c 235 if(c=='7')
Jalle 0:4a439d892f7c 236 c=7;
Jalle 0:4a439d892f7c 237 if(c=='8')
Jalle 0:4a439d892f7c 238 c=8;
Jalle 0:4a439d892f7c 239 if(c=='9')
Jalle 0:4a439d892f7c 240 c=9;
Jalle 0:4a439d892f7c 241 if(c=='A')
Jalle 0:4a439d892f7c 242 c=10;
Jalle 0:4a439d892f7c 243 if(c=='B')
Jalle 0:4a439d892f7c 244 c=11;
Jalle 0:4a439d892f7c 245 if(c=='C')
Jalle 0:4a439d892f7c 246 c=12;
Jalle 0:4a439d892f7c 247 if(c=='D')
Jalle 0:4a439d892f7c 248 c=13;
Jalle 0:4a439d892f7c 249 if(c=='E')
Jalle 0:4a439d892f7c 250 c=14;
Jalle 0:4a439d892f7c 251 if(c=='F')
Jalle 0:4a439d892f7c 252 c=15;
Jalle 0:4a439d892f7c 253 esto=esto+c;
Jalle 0:4a439d892f7c 254 //$RD1ff!
Jalle 0:4a439d892f7c 255 estado=0;
Jalle 0:4a439d892f7c 256 //printf("tenemos %d\n",esto);
Jalle 0:4a439d892f7c 257 float susso = (1.0/165.0)*esto;
Jalle 0:4a439d892f7c 258 dac=susso;
Jalle 0:4a439d892f7c 259 break;*/
Jalle 0:4a439d892f7c 260
Jalle 0:4a439d892f7c 261
Jalle 0:4a439d892f7c 262 case 3:
Jalle 0:4a439d892f7c 263
Jalle 0:4a439d892f7c 264 if(c=='R') {
Jalle 0:4a439d892f7c 265 a=a^'R';
Jalle 0:4a439d892f7c 266 e=81;
Jalle 0:4a439d892f7c 267 }
Jalle 0:4a439d892f7c 268 if(c=='G') {
Jalle 0:4a439d892f7c 269 a=a^'G';
Jalle 0:4a439d892f7c 270
Jalle 0:4a439d892f7c 271 e=91;
Jalle 0:4a439d892f7c 272 }
Jalle 0:4a439d892f7c 273 if(c=='B') {
Jalle 0:4a439d892f7c 274 a=a^'B';
Jalle 0:4a439d892f7c 275 e=111;
Jalle 0:4a439d892f7c 276 }
Jalle 0:4a439d892f7c 277
Jalle 0:4a439d892f7c 278 estado=12;
Jalle 0:4a439d892f7c 279 if(c!='R'&&c!='G'&&c!='B')
Jalle 0:4a439d892f7c 280 estado=9;
Jalle 0:4a439d892f7c 281
Jalle 0:4a439d892f7c 282 break;
Jalle 0:4a439d892f7c 283
Jalle 0:4a439d892f7c 284 case 4:
Jalle 0:4a439d892f7c 285 if(c=='1') {
Jalle 0:4a439d892f7c 286 a=a^'1';
Jalle 0:4a439d892f7c 287 e=1;
Jalle 0:4a439d892f7c 288
Jalle 0:4a439d892f7c 289 }
Jalle 0:4a439d892f7c 290 if(c=='2') {
Jalle 0:4a439d892f7c 291 a=a^'2';
Jalle 0:4a439d892f7c 292 e=2;
Jalle 0:4a439d892f7c 293
Jalle 0:4a439d892f7c 294 }
Jalle 0:4a439d892f7c 295
Jalle 0:4a439d892f7c 296 estado=7;
Jalle 0:4a439d892f7c 297 if(c!='2'&&c!='1')
Jalle 0:4a439d892f7c 298 estado=9;
Jalle 0:4a439d892f7c 299
Jalle 0:4a439d892f7c 300 break;
Jalle 0:4a439d892f7c 301
Jalle 0:4a439d892f7c 302 case 5:
Jalle 0:4a439d892f7c 303 if(c=='1') {
Jalle 0:4a439d892f7c 304 a=a^'1';
Jalle 0:4a439d892f7c 305 e=3;
Jalle 0:4a439d892f7c 306 }
Jalle 0:4a439d892f7c 307 if(c=='2') {
Jalle 0:4a439d892f7c 308 a=a^'2';
Jalle 0:4a439d892f7c 309 e=4;
Jalle 0:4a439d892f7c 310 }
Jalle 0:4a439d892f7c 311
Jalle 0:4a439d892f7c 312 estado=7;
Jalle 0:4a439d892f7c 313 if(c!='2'&&c!='1')
Jalle 0:4a439d892f7c 314 estado=9;
Jalle 0:4a439d892f7c 315 break;
Jalle 0:4a439d892f7c 316
Jalle 0:4a439d892f7c 317 case 6:
Jalle 0:4a439d892f7c 318 l1=led1;
Jalle 0:4a439d892f7c 319 l2=led2;
Jalle 0:4a439d892f7c 320 l3=led3;
Jalle 0:4a439d892f7c 321 if(c=='R') {
Jalle 0:4a439d892f7c 322 a=a^'R';
Jalle 0:4a439d892f7c 323 e=5;
Jalle 0:4a439d892f7c 324 }
Jalle 0:4a439d892f7c 325 if(c=='G') {
Jalle 0:4a439d892f7c 326 a=a^'G';
Jalle 0:4a439d892f7c 327 e=6;
Jalle 0:4a439d892f7c 328 }
Jalle 0:4a439d892f7c 329 if(c=='B') {
Jalle 0:4a439d892f7c 330 a=a^'B';
Jalle 0:4a439d892f7c 331 e=7;
Jalle 0:4a439d892f7c 332
Jalle 0:4a439d892f7c 333 }
Jalle 0:4a439d892f7c 334 estado=7;
Jalle 0:4a439d892f7c 335 if(c!='R'&&c!='G'&&c!='B')
Jalle 0:4a439d892f7c 336 estado=9;
Jalle 0:4a439d892f7c 337 break;
Jalle 0:4a439d892f7c 338
Jalle 0:4a439d892f7c 339 case 7:
Jalle 0:4a439d892f7c 340
Jalle 0:4a439d892f7c 341 if(c<97)
Jalle 0:4a439d892f7c 342 b=c-48;
Jalle 0:4a439d892f7c 343 else
Jalle 0:4a439d892f7c 344 b=c-87;
Jalle 0:4a439d892f7c 345 estado=8;
Jalle 0:4a439d892f7c 346 break;
Jalle 0:4a439d892f7c 347
Jalle 0:4a439d892f7c 348 case 8:
Jalle 0:4a439d892f7c 349
Jalle 0:4a439d892f7c 350 if(c<97)
Jalle 0:4a439d892f7c 351 d=c-48;
Jalle 0:4a439d892f7c 352 else
Jalle 0:4a439d892f7c 353 d=c-87;
Jalle 0:4a439d892f7c 354 b=(b*16)+d;
Jalle 0:4a439d892f7c 355 estado=10;
Jalle 0:4a439d892f7c 356 if(b!=a) {
Jalle 0:4a439d892f7c 357 estado=9;
Jalle 0:4a439d892f7c 358
Jalle 0:4a439d892f7c 359 }
Jalle 0:4a439d892f7c 360
Jalle 0:4a439d892f7c 361 break;
Jalle 0:4a439d892f7c 362
Jalle 0:4a439d892f7c 363 case 9:
Jalle 0:4a439d892f7c 364 printf("algo estaba mal\n");
Jalle 0:4a439d892f7c 365
Jalle 0:4a439d892f7c 366 estado=0;
Jalle 0:4a439d892f7c 367 break;
Jalle 0:4a439d892f7c 368
Jalle 0:4a439d892f7c 369 case 11:
Jalle 0:4a439d892f7c 370 if(c=='L') {
Jalle 0:4a439d892f7c 371 a=a^'L';
Jalle 0:4a439d892f7c 372 estado=3;
Jalle 0:4a439d892f7c 373 } else
Jalle 0:4a439d892f7c 374 estado=0;
Jalle 0:4a439d892f7c 375 break;
Jalle 0:4a439d892f7c 376 case 12:
Jalle 0:4a439d892f7c 377 if(e==81) {
Jalle 0:4a439d892f7c 378 if(c=='1') {
Jalle 0:4a439d892f7c 379 e=8;
Jalle 0:4a439d892f7c 380 }
Jalle 0:4a439d892f7c 381 if(c=='0') {
Jalle 0:4a439d892f7c 382 e=9;
Jalle 0:4a439d892f7c 383 }
Jalle 0:4a439d892f7c 384 }
Jalle 0:4a439d892f7c 385 if(e==91) {
Jalle 0:4a439d892f7c 386 if(c=='1') {
Jalle 0:4a439d892f7c 387 e=10;
Jalle 0:4a439d892f7c 388 }
Jalle 0:4a439d892f7c 389
Jalle 0:4a439d892f7c 390 if(c=='0') {
Jalle 0:4a439d892f7c 391 e=11;
Jalle 0:4a439d892f7c 392 }
Jalle 0:4a439d892f7c 393 }
Jalle 0:4a439d892f7c 394 if(e==111) {
Jalle 0:4a439d892f7c 395 if(c=='1') {
Jalle 0:4a439d892f7c 396 e=12;
Jalle 0:4a439d892f7c 397 }
Jalle 0:4a439d892f7c 398
Jalle 0:4a439d892f7c 399 if(c=='0') {
Jalle 0:4a439d892f7c 400 e=13;
Jalle 0:4a439d892f7c 401 }
Jalle 0:4a439d892f7c 402 }
Jalle 0:4a439d892f7c 403 a=a^c;
Jalle 0:4a439d892f7c 404 estado=7;
Jalle 0:4a439d892f7c 405 if(c!='0'&&c!='1')
Jalle 0:4a439d892f7c 406 estado=9;
Jalle 0:4a439d892f7c 407
Jalle 0:4a439d892f7c 408 break;
Jalle 0:4a439d892f7c 409
Jalle 0:4a439d892f7c 410 case 10:
Jalle 0:4a439d892f7c 411 if(c=='!') {
Jalle 0:4a439d892f7c 412 switch(e) {
Jalle 0:4a439d892f7c 413
Jalle 0:4a439d892f7c 414 case 1:
Jalle 0:4a439d892f7c 415 anl1=tsi.readPercentage()*255;
Jalle 0:4a439d892f7c 416
Jalle 0:4a439d892f7c 417 printf("$RA1%x060%x!\n",anl1,b);
Jalle 0:4a439d892f7c 418 break;
Jalle 0:4a439d892f7c 419 case 2:
Jalle 0:4a439d892f7c 420 anl2=analog1*255;
Jalle 0:4a439d892f7c 421
Jalle 0:4a439d892f7c 422 printf("$RA2%x050%x!\n",anl2,b);
Jalle 0:4a439d892f7c 423 break;
Jalle 0:4a439d892f7c 424 case 3:
Jalle 0:4a439d892f7c 425 dig1=digital1;
Jalle 0:4a439d892f7c 426 dig2=digital2;
Jalle 0:4a439d892f7c 427 printf("$RI1%d0e0%x!\n",dig1,b);
Jalle 0:4a439d892f7c 428 break;
Jalle 0:4a439d892f7c 429 case 4:
Jalle 0:4a439d892f7c 430 dig1=digital1;
Jalle 0:4a439d892f7c 431 dig2=digital2;
Jalle 0:4a439d892f7c 432 printf("$RI2%d0d0%x!\n",dig2,b);
Jalle 0:4a439d892f7c 433 break;
Jalle 0:4a439d892f7c 434 case 5:
Jalle 0:4a439d892f7c 435 printf("$RLR%d68%x!\n",l1,b);
Jalle 0:4a439d892f7c 436 break;
Jalle 0:4a439d892f7c 437 case 6:
Jalle 0:4a439d892f7c 438 printf("$RLG%d7d%x!\n",l2,b);
Jalle 0:4a439d892f7c 439 break;
Jalle 0:4a439d892f7c 440 case 7:
Jalle 0:4a439d892f7c 441 printf("$RLB%d78%x!\n",l3,b);
Jalle 0:4a439d892f7c 442 break;
Jalle 0:4a439d892f7c 443
Jalle 0:4a439d892f7c 444 case 8:
Jalle 0:4a439d892f7c 445 led1=1;
Jalle 0:4a439d892f7c 446 printf("$WLR15c%x!\n",b);
Jalle 0:4a439d892f7c 447 break;
Jalle 0:4a439d892f7c 448 case 9:
Jalle 0:4a439d892f7c 449 led1=0;
Jalle 0:4a439d892f7c 450 printf("$WLR05d%x!\n",b);
Jalle 0:4a439d892f7c 451 break;
Jalle 0:4a439d892f7c 452 case 10:
Jalle 0:4a439d892f7c 453 led2=1;
Jalle 0:4a439d892f7c 454 printf("$WLG149%x!\n",b);
Jalle 0:4a439d892f7c 455 break;
Jalle 0:4a439d892f7c 456 case 11:
Jalle 0:4a439d892f7c 457 led2=0;
Jalle 0:4a439d892f7c 458 printf("$WLG048%x!\n",b);
Jalle 0:4a439d892f7c 459 break;
Jalle 0:4a439d892f7c 460 case 12:
Jalle 0:4a439d892f7c 461 led3=1;
Jalle 0:4a439d892f7c 462 printf("$WLB14c%x!\n",b);
Jalle 0:4a439d892f7c 463 break;
Jalle 0:4a439d892f7c 464 case 13:
Jalle 0:4a439d892f7c 465 led3=0;
Jalle 0:4a439d892f7c 466 printf("$WLB04f%x!\n",b);
Jalle 0:4a439d892f7c 467 break;
Jalle 0:4a439d892f7c 468
Jalle 0:4a439d892f7c 469
Jalle 0:4a439d892f7c 470
Jalle 0:4a439d892f7c 471 }
Jalle 0:4a439d892f7c 472 }
Jalle 0:4a439d892f7c 473 estado=0;
Jalle 0:4a439d892f7c 474
Jalle 0:4a439d892f7c 475 }
Jalle 0:4a439d892f7c 476
Jalle 0:4a439d892f7c 477
Jalle 0:4a439d892f7c 478
Jalle 0:4a439d892f7c 479 }
Jalle 0:4a439d892f7c 480
Jalle 0:4a439d892f7c 481 }
Jalle 0:4a439d892f7c 482 }
Jalle 0:4a439d892f7c 483