Libreria para el Ejercicio N°3
Revision 0:c274503f9285, committed 2018-06-05
- Comitter:
- JAgustinOtero
- Date:
- Tue Jun 05 23:30:18 2018 +0000
- Commit message:
- EJN?3:; Sistema de control de una heladera
Changed in this revision
diff -r 000000000000 -r c274503f9285 Display16.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Display16.h Tue Jun 05 23:30:18 2018 +0000 @@ -0,0 +1,86 @@ +#include "mbed.h" +#define PT_CLK PTC0 +#define PT_DATA PTC7 +#define PT_BCD0 PTC5 +#define PT_BCD1 PTC4 +#define PT_BCD2 PTC3 +#define PT_PUNTO PTB0 +#define C 11 +#define H 12 +#define I 13 +#define G 14 +#define P 15 + +DigitalOut CLK(PT_CLK); +DigitalOut DATA(PT_DATA); +DigitalOut BCD0(PT_BCD0); +DigitalOut BCD1(PT_BCD1); +DigitalOut BCD2(PT_BCD2); +DigitalOut PUNTO(PT_PUNTO); +unsigned char t = 0; +unsigned char StoreData=0; + +void display16(unsigned char var_RetainData, unsigned char tempSeteada,unsigned char tempMedida,unsigned int alarma) +{ + unsigned char k = 0; + unsigned int n[4] = {1,2,10,11}; + unsigned long Disp[16] = { + /*numeros:*/ + /*0*/0b1111110110000000, + /*1*/0b0011000000000000, + /*2*/0b1110110100010010, + /*3*/0b1111110000010010, + /*4*/0b0011000010010010, + /*5*/0b1101110010010010, + /*6*/0b1101110110010010, + /*7*/0b1111000000000000, + /*8*/0b1111110110010010, + /*9*/0b1111000010010010, + /*simbolos*/ + /*º*/0b0110000001010000, + /*letras*/ + /*C*/0b1100110110000000, + /*H*/0b0011000110010010, + /*I*/0b1100110001000100, + /*G*/0b1101110110010000, + /*P*/0b1110000110010010 + }; + /*0/g1/!/0/g2/0/¡/f/e/0/d2/d1/c/b/a2/a1*/ + BCD2 = 0; + if(var_RetainData != 0) { + n[0] = tempSeteada / 10; + n[1] = tempSeteada - (n[0] * 10); + } + else{ + if(tempMedida!=0) { + StoreData=tempMedida; + } + if(StoreData<100) { + n[0] = StoreData / 10; + n[1] = StoreData - (n[0] * 10); + PUNTO=0; + } else if(StoreData>=100) { + n[0]= H; + n[1]= I; + n[2]= G; + n[3]= H; + PUNTO=1; + }} + if(alarma==1){ + n[0]= P; + n[1]= I; + n[2]= I; + n[3]= P; + PUNTO=1; + } + for(k = 0; k < 16; k++) { + DATA=(Disp[n[t]] >> (15 - k)) & 1; + CLK = 1; + CLK = 0; + } + BCD0 = t & 1; + BCD1 = (t & 2)>>1; + t++; + if(t >= 4)t = 0; +} +
diff -r 000000000000 -r c274503f9285 ME_Alarma.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ME_Alarma.h Tue Jun 05 23:30:18 2018 +0000 @@ -0,0 +1,28 @@ +#define presionado 0 +#define no_presionado 1 +char ME_Alarma_estado=0; +enum {A_off,espera,A_on}; +DigitalOut alarma(LED3); +DigitalIn FC(PTC2); +void ME_Alarma(unsigned int var_alarma) +{ + switch(ME_Alarma_estado) { + case A_off: + alarma=1; + if(FC==no_presionado) { + ME_Alarma_estado = espera; + var_alarma=30; + } + break; + case espera: + alarma=1; + if(FC==no_presionado && var_alarma==0 ) { + ME_Alarma_estado = A_on; + } + break; + case A_on: + alarma=0; + if(FC==presionado) ME_Alarma_estado = A_off; + break; + } +}
diff -r 000000000000 -r c274503f9285 ME_Compresor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ME_Compresor.h Tue Jun 05 23:30:18 2018 +0000 @@ -0,0 +1,27 @@ +#include "mbed.h" +#define apagado 1 +#define encendido 0 + +DigitalOut comp(LED1); +char ME_Compresor_estado=0; +enum {C_off,C_on}; + +unsigned char ME_Compresor(unsigned char VSet,unsigned char VMed) +{ + switch(ME_Compresor_estado) { + case C_off: + comp=apagado; + if(VMed>(VSet+20)) { + ME_Compresor_estado=C_on; + } + break; + case C_on: + comp=encendido; + if(VSet>=20){ + if(VMed<(VSet-20)) ME_Compresor_estado=C_off;} + else { + if(VMed==1) ME_Compresor_estado=C_off;} + break; + } + return comp; +} \ No newline at end of file
diff -r 000000000000 -r c274503f9285 ME_Ventilador.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ME_Ventilador.h Tue Jun 05 23:30:18 2018 +0000 @@ -0,0 +1,21 @@ +#define DIFERENCIA 2 +DigitalOut vent(LED2); +enum {V_off,V_on}; +char ME_Ventilador_estado=0; +void ME_Ventilador(float t1, float t2) +{ + switch(ME_Ventilador_estado) { + case V_off: + if(t1<(t2-DIFERENCIA) || t1>(t2+DIFERENCIA)) { + vent=0; + ME_Ventilador_estado=V_on; + } + break; + case V_on: + if(t1>(t2-DIFERENCIA) && t1<(t2+DIFERENCIA)) { + vent=1; + ME_Ventilador_estado=V_off; + } + break; + } +} \ No newline at end of file
diff -r 000000000000 -r c274503f9285 SETdata_TSI.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SETdata_TSI.h Tue Jun 05 23:30:18 2018 +0000 @@ -0,0 +1,25 @@ +#include "mbed.h" +#include "TSISensor.h" +#define InterruptTime 0.1 +#define RetainTime 3 +#define MAXValue 10 //Valor entre 0 y 9 +#define MINValue 1 + +unsigned char tempSeteada = 0; +unsigned char var_RetainData = 0; +TSISensor PanelTactil; + +unsigned char SETData() +{ + if(PanelTactil.readPercentage() != 0) + tempSeteada = (PanelTactil.readPercentage() * ((MAXValue - MINValue) * 10)) + (MINValue * 10); + return tempSeteada; +} + +unsigned char RetainData() +{ + if(PanelTactil.readPercentage() > 0) var_RetainData=RetainTime / InterruptTime; + if(var_RetainData != 0) + var_RetainData--; + return var_RetainData; +}