arreglos varios y configuraciones
parent
07a0f53eb8
commit
809b2e6d64
|
|
@ -48,17 +48,17 @@ class AutomatismoPresencia//automatismo para encender luz con presencia
|
|||
|
||||
Actuador presenciaOn;
|
||||
Actuador presenciaOff;
|
||||
Actuador nivelLuzOff;
|
||||
//Actuador nivelLuzOff;
|
||||
float fnivelLuz;
|
||||
public:
|
||||
AutomatismoPresencia()
|
||||
{
|
||||
fnivelLuz=50;
|
||||
fnivelLuz=40;
|
||||
|
||||
|
||||
strcpy(presenciaOn.id, "PresOn");
|
||||
strcpy(presenciaOff.id, "PresOff");
|
||||
strcpy(nivelLuzOff.id, "luzOff");
|
||||
//strcpy(nivelLuzOff.id, "luzOff");
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ class AutomatismoPresencia//automatismo para encender luz con presencia
|
|||
{
|
||||
presenciaOff.AddActivador(bloqueo,'>',0);
|
||||
}
|
||||
|
||||
/*
|
||||
nivelLuzOff.set(nivelluz->topic, out->topic, "0");
|
||||
nivelLuzOff.AddActivador(out,'>',0, 0);//out encendido
|
||||
nivelLuzOff.AddActivador(nivelluz,'>',fnivelLuz, 0);//no luz
|
||||
|
|
@ -89,10 +89,10 @@ class AutomatismoPresencia//automatismo para encender luz con presencia
|
|||
{
|
||||
nivelLuzOff.AddActivador(bloqueo,'>',0);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
man->Add(&presenciaOn);
|
||||
man->Add(&nivelLuzOff);
|
||||
//man->Add(&nivelLuzOff);
|
||||
man->Add(&presenciaOff);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,12 +9,11 @@ DomoEspManager::DomoEspManager()
|
|||
n=0;
|
||||
tiempo=0;
|
||||
suscrito=false;
|
||||
tiempo_sens=0;
|
||||
SetTimeRefres(15);
|
||||
}
|
||||
void DomoEspManager::SetTimeRefres(int seg)
|
||||
{
|
||||
incre_tsens=seg*1000;
|
||||
timer.set(seg);
|
||||
}
|
||||
void DomoEspManager::inicia(DomoEspConfig* cnf)
|
||||
{
|
||||
|
|
@ -70,7 +69,7 @@ void DomoEspManager::loop()
|
|||
suscrito=true;
|
||||
}
|
||||
int tiempoAux=0;
|
||||
if(MqttUtiles::pasa_incre(&tiempo_sens, incre_tsens))
|
||||
if(timer.onTimerReset())
|
||||
{
|
||||
|
||||
tiempo=(tiempo+1)%2;
|
||||
|
|
|
|||
|
|
@ -26,8 +26,7 @@ class DomoEspManager: public MqttReceiver, public IMqttManager, public ISensorMa
|
|||
int n;
|
||||
int tiempo;
|
||||
bool suscrito;
|
||||
unsigned long tiempo_sens;
|
||||
unsigned long incre_tsens;
|
||||
Ctimer timer;
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
|||
|
|
@ -6,16 +6,19 @@ class SensorDin: public DomoEspSensorReceiver
|
|||
{
|
||||
bool val;
|
||||
uint8_t pin;
|
||||
|
||||
bool logTiempo2;
|
||||
public:
|
||||
|
||||
virtual float getVal()
|
||||
{
|
||||
return (float)val;
|
||||
}
|
||||
SensorDin(){}
|
||||
void set(uint8_t _pin, char* topic_id)
|
||||
SensorDin(){
|
||||
logTiempo2=true;
|
||||
}
|
||||
void set(uint8_t _pin, char* topic_id, bool _logTiempo2=true)
|
||||
{
|
||||
logTiempo2=_logTiempo2;
|
||||
pin=_pin;
|
||||
val=0;
|
||||
strcpy(topic, topic_id);
|
||||
|
|
@ -25,7 +28,7 @@ class SensorDin: public DomoEspSensorReceiver
|
|||
//mirar para configurar por interrupcion
|
||||
int val_ac=digitalRead(pin);
|
||||
|
||||
if(tiempo==2 || val_ac!=val)
|
||||
if((logTiempo2 && tiempo==2) || val_ac!=val)
|
||||
{
|
||||
val=val_ac;
|
||||
//loguea------------
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class SensorPulsante: public DomoEspSensorReceiver
|
|||
virtual void procesa(IMqttManager * man, int tiempo)
|
||||
{
|
||||
//mirar para configurar por interrupcion
|
||||
int val_ac=valDef;
|
||||
int val_ac=val;
|
||||
if(!espera || MqttUtiles::pasa_incre(&tiempo_sens, incre_tsens))
|
||||
{
|
||||
val_ac=digitalRead(pin);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class SensorVF: public DomoEspSensorReceiver
|
|||
val=0;
|
||||
topic[0]=0;
|
||||
}
|
||||
void set(char* topic_id, float valdef)
|
||||
void set(char* topic_id, float valdef=0)
|
||||
{
|
||||
val=valdef;
|
||||
strcpy(topic, topic_id);
|
||||
|
|
|
|||
|
|
@ -130,6 +130,63 @@ class ConfActual: public DomoEspConfig
|
|||
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
class ConfCocina: public DomoEspConfig
|
||||
{
|
||||
SensorDHT dht;
|
||||
SensorAin luz;
|
||||
SensorDout lampara;
|
||||
SensorPulsante presencia;
|
||||
SensorTimer tpresencia;
|
||||
|
||||
SensorDin interruptor;
|
||||
SensorVF enable;
|
||||
|
||||
AutomatismoPresencia actuador;
|
||||
AutomatismoPulsador actuadorPul;
|
||||
Actuador actp1;
|
||||
public:
|
||||
ConfCocina()
|
||||
{
|
||||
strcpy(ssidWifi,"Idhun");//nombre wifi
|
||||
strcpy(ideEsp,"Esp8266_cocina");//idenitificador del esp (sera único)
|
||||
|
||||
|
||||
/*
|
||||
int cociMov= vars->AddInternalVarInt( "casa/cocina/mov");
|
||||
int cociLuz= vars->AddInternalVarInt( "casa/cocina/luz");
|
||||
int cociLam= vars->AddInternalVarInt( "casa/cocina/lam");
|
||||
int cociAuto= vars->AddInternalVarInt("casa/cocina/luzAuto");
|
||||
*/
|
||||
dht.set(D4,"casa/cocina");
|
||||
|
||||
luz.set(0, "casa/cocina/luz",1,0);
|
||||
lampara.set(D2, "casa/cocina/lam",0,0);
|
||||
presencia.set(D5, "casa/cocina/movPul",0);
|
||||
tpresencia.set("casa/cocina/mov",0, 60);
|
||||
enable.set("casa/cocina/luzAuto");
|
||||
interruptor.set( D1, "casa/cocina/inter", false);
|
||||
actp1.set("casa/cocina/movPul", "casa/cocina/mov","1");
|
||||
|
||||
|
||||
}
|
||||
virtual void inicia(ISensorManager* man)
|
||||
{
|
||||
man->Add(&dht);
|
||||
|
||||
man->Add(&luz);
|
||||
man->Add(&lampara);
|
||||
man->Add(&presencia);
|
||||
man->Add(&tpresencia);
|
||||
man->Add(&enable);
|
||||
man->Add(&interruptor);
|
||||
man->Add(&actp1);
|
||||
|
||||
actuadorPul.inicia(man, &interruptor, &lampara);
|
||||
actuador.inicia(man, &tpresencia, &luz, &lampara, &enable);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
|
@ -203,7 +260,7 @@ class ConfigSalon: public DomoEspConfig
|
|||
strcpy(ideEsp,"Esp8266_Salon");//idenitificador del esp (sera único)
|
||||
|
||||
dht.set(D4, "casa/Salon");
|
||||
nivelLuz.set(0,"casa/Salon/luz",1, 0);
|
||||
nivelLuz.set(0,"casa/Salon/luz",0, 0);
|
||||
presencia.set(D5, "casa/Salon/movEven");
|
||||
presenciaTimer.set("casa/Salon/mov",0,60);
|
||||
actTimer.set("casa/Salon/movEven", "casa/Salon/mov","1");
|
||||
|
|
@ -321,6 +378,6 @@ class ConfPulSalon: public DomoEspConfig
|
|||
|
||||
|
||||
|
||||
ConfPulSalon ConfiguracionActual;
|
||||
ConfigSalon ConfiguracionActual;
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue