Lcd estable
parent
4a9023ba27
commit
3ac8960648
|
|
@ -4,12 +4,13 @@ DomoEspManager::DomoEspManager()
|
|||
{
|
||||
vars.config(NULL, NULL);
|
||||
vars.AddListenner(&sens);
|
||||
vars.AddListenner(&des);
|
||||
sens.Config(&vars);
|
||||
suscrito=false;
|
||||
|
||||
}
|
||||
|
||||
void DomoEspManager::inicia(PubSubClient *mqttClient, WiFiClient* espClient, DomoConfig* conf)
|
||||
void DomoEspManager::inicia( LiquidCrystal *lcd, PubSubClient *mqttClient, WiFiClient* espClient, DomoConfig* conf)
|
||||
{
|
||||
#ifdef DEBUG_PS
|
||||
Serial.println("Inicia Wifi");
|
||||
|
|
@ -23,7 +24,7 @@ void DomoEspManager::inicia(PubSubClient *mqttClient, WiFiClient* espClient, Dom
|
|||
Serial.println("Configura Sensores");
|
||||
#endif
|
||||
//pasar funcion de configuracion de añadir sensores
|
||||
conf->ConfigSens(&sens);
|
||||
conf->ConfigGen(&sens, &vars, &lcdm);
|
||||
#ifdef DEBUG_PS
|
||||
Serial.println("Inicia variables");
|
||||
#endif
|
||||
|
|
@ -35,6 +36,12 @@ void DomoEspManager::inicia(PubSubClient *mqttClient, WiFiClient* espClient, Dom
|
|||
#ifdef DEBUG_PS
|
||||
Serial.println("Iniciado esp");
|
||||
#endif
|
||||
des.inicia(&vars);
|
||||
#if CON_LCD
|
||||
|
||||
lcdm.inicia(&vars, lcd, conf->lcd.colum, conf->lcd.lines);
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -61,11 +68,19 @@ void DomoEspManager::loop()
|
|||
|
||||
sens.loop();
|
||||
vars.loop();
|
||||
des.loop();
|
||||
#if CON_LCD
|
||||
lcdm.loop();
|
||||
#endif
|
||||
}
|
||||
|
||||
void DomoEspManager::OnMqtt(char* topic, char* payload)
|
||||
{
|
||||
vars.OnMqtt(topic, payload);
|
||||
//des.OnMqtt(topic, payload);
|
||||
#ifdef DEBUG_PS
|
||||
Serial.println("DomoEspManager::OnMqtt fin");
|
||||
#endif
|
||||
}
|
||||
|
||||
void DomoEspManager::SubscribeMqtt(PubSubClient *client_mqtt)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
//#include <ESP8266WiFi.h>//este para esp8266
|
||||
//#include <PubSubClient.h>
|
||||
#include <SPI.h>
|
||||
#include <LiquidCrystal.h>
|
||||
/*
|
||||
#include <SimpleDHT.h>
|
||||
#include <Wire.h>
|
||||
|
|
@ -14,16 +15,45 @@
|
|||
#include "MqttUtiles.h"
|
||||
#include "MqttSensManager.h"
|
||||
#include "MqttDesencadenadorManager.h"
|
||||
#include "LcdMQTTViewer.h"
|
||||
|
||||
#if CON_LCD
|
||||
//configuracion del lcd--------------------------
|
||||
#include <LiquidCrystal.h>
|
||||
|
||||
|
||||
#include "LcdMQTTViewer.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
class PubSubClient;
|
||||
class WiFiClient;
|
||||
class MqttSensManager;
|
||||
/*
|
||||
* clase principal
|
||||
*/
|
||||
class DomoLcdConfig
|
||||
{
|
||||
public:
|
||||
//pines
|
||||
byte rs;
|
||||
byte en;//eneable
|
||||
byte d0;
|
||||
byte d1;
|
||||
byte d2;
|
||||
byte d3;
|
||||
|
||||
byte colum;
|
||||
byte lines;
|
||||
};
|
||||
|
||||
class DomoConfig
|
||||
{
|
||||
public:
|
||||
DomoLcdConfig lcd;
|
||||
|
||||
|
||||
|
||||
char ssidWifi[24];
|
||||
char keyWifi[32];
|
||||
|
|
@ -36,8 +66,7 @@ class DomoConfig
|
|||
|
||||
int refresTimeSens;//tiempo de refresco en segundos de los sensores
|
||||
|
||||
virtual void ConfigSens(MqttSensManager* sens)=0;
|
||||
|
||||
virtual void ConfigGen(MqttSensManager* sens, MqttVarManager* vars, LcdMQTTViewer *lcd)=0;
|
||||
|
||||
|
||||
};
|
||||
|
|
@ -45,6 +74,9 @@ class DomoConfig
|
|||
class DomoEspManager: public MqttReceiver
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
|
||||
//variables-------------
|
||||
//MqttVarArray avar;
|
||||
//MqttTopicAttay topics;
|
||||
|
|
@ -56,12 +88,13 @@ class DomoEspManager: public MqttReceiver
|
|||
MqttManager mqtt;
|
||||
|
||||
MqttDesencadenadorManager des;
|
||||
LcdMQTTViewer lcdm;
|
||||
bool suscrito;
|
||||
|
||||
//PubSubClient client_qqtt(WifiManager::espClient);
|
||||
DomoEspManager();
|
||||
//PubSubClient client_qqtt(espClient);
|
||||
void inicia(PubSubClient *mqttClient, WiFiClient* espClient, DomoConfig* conf);
|
||||
void inicia( LiquidCrystal *lcd,PubSubClient *mqttClient, WiFiClient* espClient, DomoConfig* conf);
|
||||
void loop();
|
||||
|
||||
//funciones auxiliares
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ Y PROBAR RF*/
|
|||
|
||||
|
||||
//includes-----------------------------------------
|
||||
#include <SPI.h>
|
||||
#include <ESP8266WiFi.h>//este para esp8266
|
||||
//#include <WiFi.h>//este para esp32
|
||||
|
||||
|
|
@ -45,16 +46,25 @@ DomoEspManager domoManager;
|
|||
DomoEspManager domoEspManager;
|
||||
WiFiClient EspClient;
|
||||
PubSubClient clienteMqtt(EspClient);
|
||||
LiquidCrystal *plcd=NULL;
|
||||
#if CON_LCD
|
||||
LiquidCrystal lcd(
|
||||
ConfiguracionActual.lcd.rs,
|
||||
ConfiguracionActual.lcd.en,
|
||||
ConfiguracionActual.lcd.d0,ConfiguracionActual.lcd.d1,ConfiguracionActual.lcd.d2,ConfiguracionActual.lcd.d3);
|
||||
|
||||
#endif
|
||||
//funciones principales------------------------
|
||||
void setup()
|
||||
{
|
||||
plcd=&lcd;
|
||||
#ifdef DEBUG_PS
|
||||
Serial.begin(ConfiguracionActual.velocidadPortSerie);
|
||||
delay(10);
|
||||
Serial.println("");
|
||||
Serial.println("Iniciando");
|
||||
#endif
|
||||
domoManager.inicia(&clienteMqtt,&EspClient,&ConfiguracionActual);
|
||||
domoManager.inicia(plcd,&clienteMqtt,&EspClient,&ConfiguracionActual);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,103 @@
|
|||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <LiquidCrystal.h>
|
||||
|
||||
#include "MqttDefines.h"
|
||||
#include "MqttUtiles.h"
|
||||
#include "MqttVarManager.h"
|
||||
|
||||
#include "LcdMQTTViewer.h"
|
||||
|
||||
void LcdMQTTViewer::envia(char* txt, int pos, int line)
|
||||
{
|
||||
lcd->setCursor(pos, line);
|
||||
int l = strlen(txt);
|
||||
if (l < nchar)
|
||||
for (int i = l; i < nchar; i++)
|
||||
txt[i] = ' ';
|
||||
txt[nchar] = 0;
|
||||
lcd->print(txt);
|
||||
}
|
||||
LcdMQTTViewer::LcdMQTTViewer()
|
||||
{
|
||||
maxpan = 0;
|
||||
tiempo = 0;
|
||||
incre_t = 10 * 1000;
|
||||
for (int i = 0; i < MAXINFOLCD; i++)
|
||||
{
|
||||
LcdConf[i].ivar=-1;
|
||||
LcdConf[i].formatLCD[0] = 0;
|
||||
LcdConf[i].pan = 255;
|
||||
}
|
||||
}
|
||||
void LcdMQTTViewer::setTimer(int seg)
|
||||
{
|
||||
incre_t = seg * 1000;
|
||||
}
|
||||
|
||||
void LcdMQTTViewer::envia(int pan)
|
||||
{
|
||||
char val[16];
|
||||
char buf[32];
|
||||
for (int i = 0; i < maxtInfo; i++)
|
||||
{
|
||||
if (LcdConf[i].pan != pan)
|
||||
continue;
|
||||
if(LcdConf[i].ivar>=0)
|
||||
{
|
||||
MqttVar *v=vars->Get(LcdConf[i].ivar);
|
||||
if(v==NULL)
|
||||
continue;
|
||||
//pilla valor
|
||||
if(v->flags & MqttVar::FLOAT_VAR)
|
||||
dtostrf(v->val.f,3, 2, val);
|
||||
else
|
||||
sprintf(val, "%d", (int)v->val.i);
|
||||
sprintf(buf, LcdConf[i].formatLCD, val);
|
||||
}
|
||||
else
|
||||
|
||||
strcpy( buf, LcdConf[i].formatLCD);
|
||||
|
||||
|
||||
envia(buf,0, LcdConf[i].line);
|
||||
}
|
||||
}
|
||||
|
||||
void LcdMQTTViewer::inicia(MqttVarManager *v, LiquidCrystal* lcdEx, int digi, int lines)
|
||||
{
|
||||
vars=v;
|
||||
lcd =lcdEx;
|
||||
nchar = digi;
|
||||
lcd->begin(nchar, lines);
|
||||
for(int i=0; i<lines; i++)
|
||||
{
|
||||
envia("Iniciando",0,i);
|
||||
}
|
||||
}
|
||||
void LcdMQTTViewer::loop()
|
||||
{
|
||||
if (!MqttUtiles::pasa_incre(&tiempo, incre_t))
|
||||
return;
|
||||
#ifdef DEBUG_PS
|
||||
Serial.println("Refres lcd");
|
||||
#endif
|
||||
envia(panActual);
|
||||
panActual = (panActual + 1) % (maxpan+1);
|
||||
|
||||
}
|
||||
|
||||
void LcdMQTTViewer::add(byte ivar, char* formatLCD, int line, int pan)
|
||||
{
|
||||
if (maxtInfo >= MAXINFOLCD)
|
||||
return;
|
||||
LcdConf[maxtInfo].ivar=ivar;
|
||||
strcpy(LcdConf[maxtInfo].formatLCD, formatLCD);
|
||||
LcdConf[maxtInfo].line = line;
|
||||
LcdConf[maxtInfo].pan = pan;
|
||||
maxtInfo++;
|
||||
//recalcula numero de pantallas
|
||||
if (maxpan < pan)
|
||||
maxpan = pan;
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*#if ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif*/
|
||||
#ifndef LcdMQTTViewerdef
|
||||
#define LcdMQTTViewerdef 1
|
||||
|
||||
#include "MqttDefines.h"
|
||||
class LiquidCrystal;
|
||||
class PubSubClient;
|
||||
class MqttVarManager;
|
||||
struct LcdMQTTInfo
|
||||
{
|
||||
byte ivar;//indice a variable
|
||||
char formatLCD[32];//formato
|
||||
byte pan;//pantalla en la que sale
|
||||
byte line;//linea en la que sale
|
||||
|
||||
};
|
||||
|
||||
#define MAXINFOLCD 8
|
||||
class LcdMQTTViewer
|
||||
{
|
||||
public:
|
||||
LiquidCrystal *lcd;
|
||||
int nchar;
|
||||
int maxtInfo;
|
||||
int maxpan;
|
||||
int panActual = 0;
|
||||
unsigned long tiempo;
|
||||
unsigned long incre_t;
|
||||
|
||||
|
||||
MqttVarManager* vars;
|
||||
|
||||
LcdMQTTInfo LcdConf[MAXINFOLCD];
|
||||
|
||||
LcdMQTTViewer();
|
||||
|
||||
void inicia(MqttVarManager *vars, LiquidCrystal* lcdEx, int digi, int lines);
|
||||
void loop();//publica datos variables
|
||||
|
||||
//auxiliares----------------------------------------------------------
|
||||
void add(byte ivar, char* formatLCD, int line, int pan);
|
||||
void setTimer(int seg);
|
||||
void envia(char* txt, int pos, int line);
|
||||
void envia(int pan);
|
||||
void revisa();
|
||||
};
|
||||
#endif
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
#ifndef MqttDefinesDef
|
||||
#define MqttDefinesDef 1
|
||||
#define DEBUG_PS 1
|
||||
#define CON_LCD 1
|
||||
class MqttOnVarChangeListenner
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ MqttDesencadenadorManager::MqttDesencadenadorManager()
|
|||
|
||||
void MqttDesencadenadorManager::OnVarChange(int ivar)
|
||||
{
|
||||
revisa=true;
|
||||
//revisa=true;
|
||||
//marca Accion--
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,11 @@ class MqttOperArray
|
|||
class MqttCausa
|
||||
{
|
||||
public:
|
||||
enum TipoCausa
|
||||
{
|
||||
AND_CAUSA=1,
|
||||
OR_CAUSA,
|
||||
};
|
||||
byte ini;//indice a primer oper
|
||||
byte n;//numero de operadores totales
|
||||
byte tipo;//tipo de causa (and or ...)
|
||||
|
|
@ -73,7 +78,6 @@ class MqttCausaManager
|
|||
public:
|
||||
MqttCausaArray caus;
|
||||
MqttOperArray oper;
|
||||
|
||||
MqttCausaManager();
|
||||
bool IsTrue(int icau, MqttVarManager *vars);
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@ MqttSensor* MqttSensArray::Ivar2Sen(int ivar)
|
|||
if(res->ivar==ivar)
|
||||
return res;
|
||||
}
|
||||
#ifdef DEBUG_PS
|
||||
Serial.print("Sens::Ivar2Sen: no encontrada sensor de variable: ");
|
||||
Serial.println(ivar);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -270,11 +274,18 @@ void MqttSensManager::procesaSensor(int i)
|
|||
void MqttSensManager::OnVarChange(int ivar)
|
||||
{
|
||||
#ifdef DEBUG_PS
|
||||
Serial.println("Sens::OnVarChange");
|
||||
Serial.print("Sens::OnVarChange: ");
|
||||
Serial.println(ivar);
|
||||
#endif
|
||||
|
||||
MqttVar *v=vars->Get(ivar);
|
||||
#ifdef DEBUG_PS
|
||||
Serial.print(" topic: ");
|
||||
Serial.println(vars->topics->Get(v->topic));
|
||||
#endif
|
||||
MqttSensor *s = sens.Ivar2Sen(ivar);
|
||||
MqttVar *v=vars->Get(ivar);
|
||||
if(!s)
|
||||
|
||||
if(s==NULL)
|
||||
{
|
||||
#ifdef DEBUG_PS
|
||||
Serial.println("Sens::OnVarChange Sensor no encontrado");
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ void MqttVarManager::config(MqttVarArray *vArray, MqttTopicAttay* t)
|
|||
topics=&_t;
|
||||
}
|
||||
|
||||
int MqttVarManager::OnMqtt(char* topic, char* payload)
|
||||
void MqttVarManager::OnMqtt(char* topic, char* payload)
|
||||
{
|
||||
char buf[32];
|
||||
#ifdef DEBUG_PS
|
||||
|
|
@ -111,8 +111,8 @@ int MqttVarManager::OnMqtt(char* topic, char* payload)
|
|||
Serial.println(topic);
|
||||
Serial.print("val: ");
|
||||
Serial.println(payload);
|
||||
|
||||
#endif
|
||||
int res=-1;
|
||||
sprintf(buf, "%s",topic);
|
||||
int nt=strlen(buf);
|
||||
int ng=strlen("/get");
|
||||
|
|
@ -126,7 +126,7 @@ int MqttVarManager::OnMqtt(char* topic, char* payload)
|
|||
byte f=MqttVar::OUT_VAR;
|
||||
if(isGet)
|
||||
{
|
||||
f=MqttVar::PRIV_VAR;
|
||||
f=(byte)MqttVar::PRIV_VAR;
|
||||
#ifdef DEBUG_PS
|
||||
Serial.println("OnmqttVars: get detectado");
|
||||
#endif
|
||||
|
|
@ -138,7 +138,7 @@ int MqttVarManager::OnMqtt(char* topic, char* payload)
|
|||
#ifdef DEBUG_PS
|
||||
Serial.println("OnmqttVars: Ni get ni set");
|
||||
#endif
|
||||
return res;//no es ni get ni set
|
||||
return;//no es ni get ni set
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PS
|
||||
|
|
@ -150,15 +150,13 @@ int MqttVarManager::OnMqtt(char* topic, char* payload)
|
|||
|
||||
//comprueba variables
|
||||
MqttVar* v;
|
||||
int res=-1;
|
||||
for(int i=0; i<vars->n; i++)
|
||||
{
|
||||
v=vars->Get(i);
|
||||
|
||||
if((v->flags & f) && !strcmp(topics->Get(v->topic),buf))
|
||||
{
|
||||
#ifdef DEBUG_PS
|
||||
Serial.println("OnmqttVars: Encontrada var");
|
||||
#endif
|
||||
if(v->flags & MqttVar::FLOAT_VAR)
|
||||
{
|
||||
float ff=v->val.f;
|
||||
|
|
@ -173,12 +171,15 @@ int MqttVarManager::OnMqtt(char* topic, char* payload)
|
|||
if(ii!=v->val.i)
|
||||
res=i;
|
||||
}
|
||||
if(res>0 || isGet)
|
||||
OnChange(i);
|
||||
break;//suponemos solo una variable con el mismo topic
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
#ifdef DEBUG_PS
|
||||
Serial.println("OnmqttVars: fin");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
void MqttVarManager::loop()
|
||||
|
|
@ -238,26 +239,15 @@ void MqttVarManager::Suscribe()
|
|||
v=vars->Get(i);
|
||||
if(v->flags & MqttVar::OUT_VAR)//suscribe al set
|
||||
{
|
||||
|
||||
sprintf(buffer_t, "%s/set",topics->Get(v->topic));
|
||||
client_qqtt->subscribe(buffer_t);
|
||||
#ifdef DEBUG_PS
|
||||
Serial.print("Suscribe: ");
|
||||
Serial.println(buffer_t);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
#ifdef DEBUG_PS
|
||||
Serial.println("Variables:");
|
||||
for(int i=0; i<vars->n; i++)
|
||||
if(v->flags & MqttVar::PRIV_VAR)//suscribe al get
|
||||
{
|
||||
v=vars->Get(i);
|
||||
sprintf(buffer_t, "%s",topics->Get(v->topic));
|
||||
Serial.println(buffer_t);
|
||||
sprintf(buffer_t, "%s/get",topics->Get(v->topic));
|
||||
client_qqtt->subscribe(buffer_t);
|
||||
}
|
||||
}
|
||||
Serial.println("Fin Variables Suscritas");
|
||||
#endif
|
||||
}
|
||||
int MqttVarManager::AddVar(byte flags, char*topic)
|
||||
{
|
||||
|
|
@ -266,6 +256,14 @@ int MqttVarManager::AddVar(byte flags, char*topic)
|
|||
v.topic=topics->Add(topic);
|
||||
return vars->Add(&v);
|
||||
}
|
||||
int MqttVarManager::AddInternalVarFloat( char*topic)
|
||||
{
|
||||
return AddVar((byte)(MqttVar::PRIV_VAR|MqttVar::FLOAT_VAR ),topic);
|
||||
}
|
||||
int MqttVarManager::AddInternalVarInt( char*topic)
|
||||
{
|
||||
return AddVar((byte)(MqttVar::PRIV_VAR),topic);
|
||||
}
|
||||
MqttVar* MqttVarManager::Get(int i)
|
||||
{
|
||||
return vars->Get(i);
|
||||
|
|
@ -282,7 +280,7 @@ void MqttVarManager::OnChange(int ivar)
|
|||
}
|
||||
for (int i=0; i<nListenner; i++)
|
||||
{
|
||||
onChangeListener[i]->OnVarChange(i);
|
||||
onChangeListener[i]->OnVarChange(ivar);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class MqttVar
|
|||
PRIV_VAR=0x04,//variable privada de entrada (acepta get como si fueran set)
|
||||
FLOAT_VAR=0x08,//variable en coma flotante
|
||||
ACCION_VAR=0x10,//variable de accion (publica en cada cambio)
|
||||
VOLATILE_VAR=0X20 //marca variable que una vez revisada se cambia internamente su valor (usado en desencadenadores para variables de accion)
|
||||
VOLATILE_VAR=0x20 //marca variable que una vez revisada se cambia internamente su valor (usado en desencadenadores para variables de accion)
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ class MqttVarManager
|
|||
|
||||
void inicia(PubSubClient *client_qqtt);//inicia variables si hace falta
|
||||
void Suscribe();//subscribe variables a mqtt
|
||||
int OnMqtt(char* topic, char* payload);//entra trama mqtt devuelve indice a sensor cambiado
|
||||
void OnMqtt(char* topic, char* payload);//entra trama mqtt devuelve indice a sensor cambiado
|
||||
void loop();//publica datos variables
|
||||
|
||||
|
||||
|
|
@ -108,6 +108,8 @@ class MqttVarManager
|
|||
MqttVar* Get(int i);
|
||||
|
||||
int AddVar(byte flags, char*topic);
|
||||
int AddInternalVarFloat( char*topic);
|
||||
int AddInternalVarInt( char*topic);
|
||||
void PublicaVars();
|
||||
void PublicaVar(int ivar);
|
||||
void OnChange(int ivar);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
//parametros configurables*************************************************
|
||||
#define DEBUG_PS 1//Descomentar para debug
|
||||
#define CON_LCD 1
|
||||
|
||||
class ActualDomoConfig: public DomoConfig
|
||||
{
|
||||
public:
|
||||
|
|
@ -11,17 +13,27 @@ class ActualDomoConfig: public DomoConfig
|
|||
|
||||
strcpy(ideEsp,"Esp8266_011");//idenitificador del esp (sera único)
|
||||
strcpy(hostMQTT,"192.168.2.50");//servidor mqttBroker
|
||||
|
||||
portMQTT=1883;//puerto del servidor mqtt Broker
|
||||
|
||||
refresTimeVars=30;//tiempo de refresco en segundos de las variables
|
||||
|
||||
refresTimeSens=15;//tiempo de refresco en segundos de los sensores
|
||||
|
||||
//config lcd--------------------
|
||||
lcd.colum=16;//columnas lcd
|
||||
lcd.lines=2;//lineas
|
||||
//pines lcd
|
||||
lcd.rs=D5;
|
||||
lcd.en=D6;//eneable
|
||||
lcd.d0=D3;
|
||||
lcd.d1=D2;
|
||||
lcd.d2=D1;
|
||||
lcd.d3=D0;
|
||||
|
||||
}
|
||||
//configuracion de sensores---------------------------------
|
||||
virtual void ConfigSens(MqttSensManager* sens)
|
||||
//configuracion de sensores, variables, lcd---------------------------------
|
||||
virtual void ConfigGen(MqttSensManager* sens, MqttVarManager* vars, LcdMQTTViewer *lcd)
|
||||
{
|
||||
//sensores--------------------------------------------------------
|
||||
/*
|
||||
sens->AddHDT22(int pin, char* topic);
|
||||
//tempe y presion varometrica
|
||||
|
|
@ -34,13 +46,38 @@ class ActualDomoConfig: public DomoConfig
|
|||
Sensor analogico
|
||||
sens->AddAnalogIn(int pin, char* topic, bool ValNegado);//nivel de luz, nivel de lluvia ...
|
||||
*/
|
||||
sens->AddHDT22(D4, "casa/cocina");
|
||||
sens->AddDinAccion(D5, "casa/cocina/mov");
|
||||
sens->AddAnalogIn(0, "casa/cocina/luz",true);
|
||||
sens->AddHDT22(D4, "casa/desp");
|
||||
sens->AddAnalogIn(0, "casa/desp/luz",true);
|
||||
//variables----------------------------------------------------
|
||||
/*
|
||||
int ivar= vars->AddVar(byte flags, char*topic);//variable con flags a elegir
|
||||
int ivar= vars->AddInternalVarFloat( char*topic);//variable privada
|
||||
int ivar= vars->AddInternalVarInt( char*topic);//variable privada
|
||||
*/
|
||||
int temCoci= vars->AddInternalVarFloat( "casa/cocina/t");//variable privada
|
||||
int temDesp= vars->AddInternalVarFloat( "casa/cocina/h");//variable privada
|
||||
|
||||
//lcd---------------------------------------------------------
|
||||
|
||||
lcd->add(0,"T des: %s",0,0);
|
||||
lcd->add(1,"H des: %s",1,0);
|
||||
lcd->add(temCoci,"T coci: %s",0,1);
|
||||
lcd->add(temDesp,"H coci: %s",1,1);
|
||||
/*
|
||||
lcd->add(-1,"Hola",0,0);
|
||||
lcd->add(-1,"como va",1,0);
|
||||
|
||||
lcd->add(-1,"Mi ritmo",0,1);
|
||||
lcd->add(-1,"bueno pa goza",1,1);*/
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Lcd.add("casa/Ext/dht/t", "TempEx: %s", 0, 0);
|
||||
Lcd.add("casa/Ext/dht/h", "HumExt: %s", 1, 0);
|
||||
Lcd.add("casa/Desp/dht/t", "TempIn: %s", 0, 1);
|
||||
Lcd.add("casa/Desp/dht/h", "HumIn: %s", 1, 1);
|
||||
*/
|
||||
class CocinaDomoConfig: public DomoConfig
|
||||
{
|
||||
public:
|
||||
|
|
@ -56,7 +93,7 @@ class CocinaDomoConfig: public DomoConfig
|
|||
refresTimeSens=15;//tiempo de refresco en segundos de los sensores
|
||||
}
|
||||
//configuracion de sensores---------------------------------
|
||||
virtual void ConfigSens(MqttSensManager* sens)
|
||||
virtual void ConfigGen(MqttSensManager* sens, MqttVarManager* vars, LcdMQTTViewer *lcd)
|
||||
{
|
||||
sens->AddHDT22(D4, "casa/cocina");
|
||||
sens->AddDinAccion(D5, "casa/cocina/mov");
|
||||
|
|
|
|||
Loading…
Reference in New Issue