/*
int tiempoANTIREBOTE_MS = 150; // tiempo antirebote de espera
byte statusTIMER_TECLA_DERECHA = 0 ; //estado del temporizador, 1= activo 0= inactivo
byte status_ANTIREBOTE = 0 ; // DESACTIVADO
unsigned long tiempoAnterior = 0 ; //guarda tiempo de referencia para comparar
void setup() {
pinMode(13,OUTPUT); //configura la salida
//tengo un pulsador conectado al pin 7 usando la resistencia pull-up
//cuando lo presiono leo cero
pinMode(7,INPUT_PULLUP); //configura la entrada con resistencia pull-up
}
void loop() {
if ( digitalRead(7) == PULSADA && status_ANTIREBOTE == DESACTIVADO)
{ //si el BOTON TECLA fue presionado
tiempoAnterior=millis() ; // guarda el tiempo actual como referencia
statusTIMER_TECLA_DERECHA = 1 ; // indica que esta activo el temporizador INICIO TIMER
//digitalWrite(13,LOW); // apaga el LED BOTON_TECLA = NO_PULSADA
status_ANTIREBOTE == ACTIVADO
}
if( (millis() - tiempoAnterior >= tiempoANTIREBOTE_MS ) && ( statusTIMER == 1 ) )
{ //si ha transcurrido el periodo programado
status_ANTIREBOTE == DESACTIVADO ;
//digitalWrite(13,HIGH); //enciendo el LED BOTON_TECLA = RESET
statusTIMER = 0; //y desactivo el temporizador
}
}
**************************** ver 002 ***********************************************
// const int pinPulsador = 8 ;
// int pulsadorActual ; int pulsadorAnterior;
// int contador =0 ; int tiempoAntirebote = 50 ; // tiempo del antirebote en miliseg
int tiempoANTIREBOTE_MS = 50 ;
boton_DERECHA = NO_PULSADA ; // estado actual logica positiva
boton_DERECHA_estadoAnterior = NO_PULSADA ; // logica positiva 0
boolean antireboteACTIVADO_br = false ;
unsigned long tiempoAnterior_br = 0 ; // tiempo de referencia
void setup()
{
Serial.begin(9600); // Inicializa la comunicación serial
pinMode( pinPulsador, INPUT_PULLUP) ;
Serial.print(" El contador inicia en : ");
Serial.println( contador ) ;
}
void loop(){
//pulsadorActual = digitalRead(pinPulsador);
boton_DERECHA = !digitalRead(bt_r) ; // logica positiva !LOW = !0 = 1 pulsada envia !0 = 1
if ( ( boton_DERECHA != boton_DERECHA_estadoAnterior ) && antireboteACTIVADO_br == 0 )
{ tiempoAnterior = mills() ;
antireboteACTIVADO_br = 1 ;
}
if ( ( mills() - tiempoAnterior) >= tiempoANTIREBOTE_MS) && antireboteACTIVADO_br == 1 )
{
if ( boton_DERECHA == 0 ) { // SI esta ACTIVADO PULSADO RECIVIENDO "0" LOW 0VOLT
// contador ++;
// Serial.println( contador ) ;
}
antireboteACTIVADO_br = false;
}
boton_DERECHA_estadoAnterior = boton_DERECHA ;
} // fin loop
************************************************************************************************************
*/
// =============================================================================================================
// --- Bibliotecas Auxiliares ---
//#include <LiquidCrystal.h>//
//#include <LiquidCrystal_I2C.h>
// Importar las librerias LiquidCrystal I2C y Wire
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Iniciar la libreria
LiquidCrystal_I2C lcd(0x27, 16, 2);
// =============================================================================================================
// --- Mapeamento de Hardware --- ARDUINO
#define bt_r 14 //botão direita
#define bt_l 15 //botão esquerda
#define bt_e 16 //botão enter
#define bt_b 17 //botão voltar
#define motor_M1_ABRIR_VALVULAS 7 //
#define motor_M2_CEPILLO 6 //
#define motor_M3_BOMBA 5 //
#define electro_VALVULA 4 //
#define S1_FC_ABIERTO 3 //
#define S2_FC_CERRADO 2 //
#define PULSADA 1 // logica positiva
#define NO_PULSADA 0 // logica positiva
#define RESET_boton 0 // para limpiar flag de estado de boton
// GLOBALES
char boton_DERECHA = RESET_boton ;
char boton_IZQUIERDA = RESET_boton ;
char boton_ENTER = RESET_boton ;
char boton_BACK = RESET_boton ; // buffer de botones
// ============================================================================================================
// *** Antirebote TECLA DERECHA version que no funciona 30 abril **************************************************
int tiempoANTIREBOTE_MS = 50; // tiempo antirebote de espera
byte statusTIMER_TECLA_DERECHA = 0 ; //estado del temporizador, 1= activo 0= inactivo
byte status_ANTIREBOTE = 0 ; // DESACTIVADO
unsigned long tiempoAnterior = 0 ; //guarda tiempo de referencia para comparar
#define status_TIMER_HABILITADO 1 //
#define status_TIMER_DESABILITADO 0 //
#define status_ANTIREBOTE_ACTIVADO 1 //
#define status_ANTIREBOTE_DESACTIVADO 0 //
// ***************************************************************************************************************
// ver 002 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
char boton_DERECHA_estadoAnterior = RESET_boton ; // logica positiva 0
boolean antireboteACTIVADO_br = false ;
unsigned long tiempoAnterior_br = 0 ; // tiempo de referencia
// $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// =============================================================================================================
// --- Constantes e Objetos ---
#define menu_max 5 //número máximo de menus existentes
//const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
//LiquidCrystal_I2C lcd(rs, en, d4, d5, d6, d7);
// =============================================================================================================
// --- Protótipo das Funções ---
// void keyboard(); no se usa
void navegacionMenu();
void control_botonS() ; // para registro por puerto Serie
void menu1();
void menu2();
void menu3();
void menu4();
void menu5();
void config_SICLO_MARCHA();
void config_TIEMPO_SICLO_ENTRE_MARCHAS() ;
void config_MODO_SICLO_FILTRO();
void config_MODO_LOCAL_REMOTO_FILTRO();
void control_LOCAL_MANUAL_FILTRO();
// =============================================================================================================
// --- Variáveis Globais ---
int menu_num = 1, sub_menu = 1, submenu1 = 1 , submenu2 = 1 , submenu3 =1 , submenu4 =1 , submenu5 = 1 ;
int tiempo_SICLO_ON_FILTRO = 10; // tiempo en segundos
int tiempo_SICLO_OFF_FILTRO = 10;
#define HABILITADO 1 //
#define DESABILITADO 0 //
int FLAG_ENABLE_MENU = HABILITADO ;
#define AUTOMATICO 1 //
#define MANUAL 0 //
int MODO_FILTRO = MANUAL ; // realizar etiquetas
#define LOCAL 1 //
#define REMOTO 0 //
int MODO_FILTRO_LR = LOCAL ; // realizar etiquetas
// int FLAG_INCREMENTAR = 0 , FLAG_DECREMENTAR = 0 ; // no implementados
// =========================================================================================
// --- Configurações Iniciais ---
void setup()
{
lcd.backlight();
pinMode(bt_r, INPUT_PULLUP);
pinMode(bt_l, INPUT_PULLUP);
pinMode(bt_e, INPUT_PULLUP);
pinMode(bt_b, INPUT_PULLUP);
/*
#define pinMode(motor_M1_ABRIR_VALVULAS , OUTPUT); // 4 //
#define pinMode(motor_M2_CEPILLO , OUTPUT); // 0 //
#define pinMode(motor_M3_BOMBA , OUTPUT); // 2 //
#define pinMode(electro_VALVULA , OUTPUT); // 15 //
#define pinMode(S1_FC_ABIERTO , OUTPUT); // 25 //
#define pinMode(S2_FC_CERRADO , OUTPUT); // 26 //
*/
pinMode(motor_M1_ABRIR_VALVULAS , OUTPUT); // 4 //
pinMode(motor_M2_CEPILLO , OUTPUT); // 0 //
pinMode(motor_M3_BOMBA , OUTPUT); // 2 //
pinMode(electro_VALVULA , OUTPUT); // 15 //
pinMode(S1_FC_ABIERTO , OUTPUT); // 25 //
pinMode(S2_FC_CERRADO , OUTPUT); // 26 //
lcd.begin(16, 2);
Serial.begin(9600);
} //end setup
// =============================================================================================================
// --- Configurações Iniciais ---
void loop()
{
// keyboard();
navegacionMenu() ;
switch(menu_num)
{
case 1: menu1(); break;
case 2: menu2(); break;
case 3: menu3(); break;
case 4: menu4(); break;
case 5: menu5(); break;
} //end switch
// depuracion
} //end loop
// =============================================================================================================
// --- Desenvolvimiento de Funciones ---
void navegacionMenu()
{
//if (menu_num <= 0 ) menu_num = 1 ;
//if (menu_num > menu_max) menu_num = 1 ;
//if (sub_menu <= 0 ) sub_menu = 1 ;
//if (sub_menu > menu_max) sub_menu = 1 ;
//if (submenu1 <= 0 ) submenu1 = 1 ;
//if (submenu1 > 3 ) submenu1 = 1 ; // max submenu1 !!
// boton_DERECHA =0, boton_IZQUIERDA = 0; boton_ENTER = 0, boton_BACK =0;
//***************************************************************
/*
boton_DERECHA = !digitalRead(bt_r) ;
if((boton_DERECHA == PULSADA ) && sub_menu == 1 )
{ control_botonS() ;
boton_DERECHA = RESET_boton ;
delay (350);
control_botonS() ;
if(menu_num <= menu_max) menu_num += 1;
if(menu_num > menu_max) menu_num = 1;
} //end bt_r
*/
/*
int tiempoANTIREBOTE_MS = 150; // tiempo antirebote de espera
byte statusTIMER_TECLA_DERECHA = 0 ; //estado del temporizador, 1= activo 0= inactivo
byte status_ANTIREBOTE = 0 ; // DESACTIVADO
unsigned long tiempoAnterior = 0 ; //guarda tiempo de referencia para comparar
#define status_TIMER_HABILITADO 1 //
#define status_TIMER_DESABILITADO 0 //
#define status_ANTIREBOTE_ACTIVADO 1 //
#define status_ANTIREBOTE_DESACTIVADO 0 //
boton_DERECHA = !digitalRead(bt_r) ;
if((boton_DERECHA == PULSADA ) && sub_menu == 1 )
{ control_botonS() ;
boton_DERECHA = RESET_boton ;
delay (350);
control_botonS() ;
if(menu_num <= menu_max) menu_num += 1;
if(menu_num > menu_max) menu_num = 1;
} //end bt_r
*/
//*************************************************************************************************************
boton_DERECHA = !digitalRead(bt_r) ; // logica positiva !LOW = !0 = 1 pulsada envia !0 = 1
if(( boton_DERECHA != boton_DERECHA_estadoAnterior ) && antireboteACTIVADO_br == 0)
{ tiempoAnterior = millis() ;
antireboteACTIVADO_br = 1 ;
}
if(( millis() - tiempoAnterior) >= tiempoANTIREBOTE_MS && antireboteACTIVADO_br == 1)
{
if ( boton_DERECHA == PULSADA && sub_menu == 1 )
{
if(menu_num <= menu_max) menu_num += 1;
if(menu_num > menu_max) menu_num = 1;
control_botonS() ;
}
antireboteACTIVADO_br = false;
}
boton_DERECHA_estadoAnterior = boton_DERECHA ;
//*********************************************************************************************************
//
//
boton_IZQUIERDA = !digitalRead(bt_l) ; // lectura de boton IZQ
if( ( boton_IZQUIERDA == PULSADA ) && sub_menu == 1 )
{ control_botonS() ;
boton_IZQUIERDA = RESET_boton;
delay (350) ;
if(menu_num > 0) menu_num -= 1;
if(menu_num <= 0) menu_num = menu_max;
control_botonS() ;
} //end bt_l
boton_ENTER = !digitalRead(bt_e) ; // lectura de boton ENTER
if( boton_ENTER == PULSADA &&
FLAG_ENABLE_MENU == HABILITADO )
{ control_botonS() ;
boton_ENTER = RESET_boton;
delay (350) ;
if(sub_menu <= 2 ) sub_menu += 1;
if(sub_menu > 5 ) sub_menu = 1; // max sub_menu opciones
} //end bt_e
boton_BACK = !digitalRead(bt_b) ; // lectura de boton BACK
if( boton_BACK == PULSADA )
{ control_botonS() ; // contro por puerto serie de los flags estados de botones
boton_BACK = RESET_boton ;
delay (350) ;
if(sub_menu > 0) sub_menu -= 1 ;
if(sub_menu <= 0) sub_menu = 1 ;
} //end bt_b
if ( sub_menu > 1 ) FLAG_ENABLE_MENU = DESABILITADO ; // si se encuentra en un submenu de ejecucion
if ( sub_menu <= 1) FLAG_ENABLE_MENU = HABILITADO ; // desabilitar navegacion de menu principal
} //end navegacionMenu
void menu1()
{
switch(sub_menu)
{
case 1:
lcd.setCursor(0,0);
lcd.print("CONFIG Tiempo >");
lcd.setCursor(0,1);
lcd.print(" SICLO MARCHA ");
break;
case 2:
config_SICLO_MARCHA();
break;
}
} //end menu1
void menu2()
{
switch(sub_menu)
{
case 1:
lcd.setCursor(0,0);
lcd.print("CONFIG Tiempo >");
lcd.setCursor(0,1);
lcd.print("ENTRE SICLOS ");
break;
case 2:
lcd.setCursor(0,0);
// lcd.print("TiempoSICLO OFF");
lcd.setCursor(0,1);
// lcd.print(" 10 MIN ");
config_TIEMPO_SICLO_ENTRE_MARCHAS();
break;
}
} //end menu2
void menu3()
{
switch(sub_menu)
{
case 1:
lcd.setCursor(0,0);
lcd.print("< CONFIG MODO >");
lcd.setCursor(0,1);
lcd.print(" TRABAJO FILTRO ");
break;
case 2:
lcd.setCursor(0,0);
//lcd.print(" Ohmimetro ");
lcd.setCursor(0,1);
//lcd.print(" 100 Ohms ");
config_MODO_SICLO_FILTRO();
break;
}
} //end menu3
void menu4()
{
switch(sub_menu)
{
case 1:
lcd.setCursor(0,0);
lcd.print("< CONFIG LOC/REM"); // CONFIGURACION LOCAL REMOTO
lcd.setCursor(0,1);
lcd.print(" ");
break;
case 2:
lcd.setCursor(0,0);
//lcd.print(" Wattimetro ");
lcd.setCursor(0,1);
//lcd.print(" 55 Watts ");
config_MODO_LOCAL_REMOTO_FILTRO();
break;
}
} //end menu4
void menu5()
{
switch(sub_menu)
{
case 1:
lcd.setCursor(0,0);
lcd.print("< CONTROL L/M"); // CONFIGURACION LOCAL REMOTO
lcd.setCursor(0,1);
lcd.print(" ");
break;
case 2:
lcd.setCursor(0,0);
//lcd.print(" Wattimetro ");
lcd.setCursor(0,1);
//lcd.print(" 55 Watts ");
control_LOCAL_MANUAL_FILTRO();
break;
}
} //end menu4
// $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// =======================================================================
// --- Direccionamiento de Hardware Teclado ---
/*
#define PULSADA 1 //
#define NO_PULSADA 0 //
#define RESET_boton 0 // para limpiar flag de estado de boton
// GLOBALES
char boton_DERECHA = RESET_boton ;
char boton_IZQUIERDA = RESET_boton ;
char boton_ENTER = RESET_boton ;
char boton_BACK = RESET_boton ; // buffer de botones
*/
/* ###############################################################
// =======================================================================
// se debe implementar sin esta rutina
// =======================================================================
// --- Desarrollo de Funcion Teclado keyboard() ---
void keyboard()
{
// static char boton_DERECHA =0; boton_IZQUIERDA = 0; boton_ENTER = 0; boton_BACK =0; // buffer de botones
if(!digitalRead(bt_r)) boton_DERECHA = PULSADA ;
if(!digitalRead(bt_l)) boton_IZQUIERDA = PULSADA ;
if(!digitalRead(bt_e)) boton_ENTER = PULSADA ;
if(!digitalRead(bt_b)) boton_BACK = PULSADA ;
// $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
} // fin keyboard
// ###############################################################
*/
void config_SICLO_MARCHA()
{
lcd.setCursor(0,0);
lcd.print("Tiempo SICLO ON ");
switch(submenu1)
{
case 1:
lcd.setCursor(0,1);
lcd.print("INCREMENTAR S >");
boton_ENTER = !digitalRead(bt_e) ;
if ( boton_ENTER == PULSADA) {
tiempo_SICLO_ON_FILTRO += 1 ;
control_botonS() ;
boton_ENTER = RESET_boton ;
// FLAG_ENABLE_MENU = DESABILITADO ;
// guardar en buffer ROM --> tiempo_SICLO_ON_FILTRO
// controles de limites
delay (350) ;
//control_botonS() ;
}
boton_BACK = !digitalRead(bt_e) ;
if ( boton_BACK == PULSADA) {
control_botonS() ;
boton_BACK = RESET_boton ;
// guardar en buffer ROM --> tiempo_SICLO_ON_FILTRO
// controles de limites
delay (350) ;
//control_botonS() ;
}
boton_DERECHA = !digitalRead(bt_r) ;
if( boton_DERECHA == PULSADA ) {
control_botonS() ;
boton_DERECHA = RESET_boton;
delay (350) ; submenu1 ++;}
boton_IZQUIERDA = !digitalRead(bt_l) ;
if( boton_IZQUIERDA == PULSADA ) {
control_botonS() ;
boton_IZQUIERDA = RESET_boton;
delay (350) ; submenu1 = 3;}
break;
case 2:
lcd.setCursor(0,1);
lcd.print("< DECREMENTAR >");
boton_ENTER = !digitalRead(bt_e) ;
if( boton_ENTER == PULSADA) {
tiempo_SICLO_ON_FILTRO -= 1 ;
control_botonS() ;
boton_ENTER = RESET_boton ;
// guardar en buffer ROM --> tiempo_SICLO_ON_FILTRO
// controles de limites
// FLAG_DECREMENTAR = 1;
delay (350) ;
}
boton_DERECHA = !digitalRead(bt_r) ;
if(boton_DERECHA == PULSADA) {
control_botonS() ;
boton_DERECHA = RESET_boton;
delay (350); submenu1 ++;}
boton_IZQUIERDA = !digitalRead(bt_l) ;
if(boton_IZQUIERDA == PULSADA) {
control_botonS() ;
boton_IZQUIERDA = RESET_boton; delay (350); submenu1 --;}
break;
case 3:
lcd.setCursor(0,1);
lcd.print("< FINALIZAR ");
boton_IZQUIERDA = !digitalRead(bt_l) ;
if(boton_IZQUIERDA == PULSADA ) {
control_botonS() ;
boton_IZQUIERDA = RESET_boton ;
delay (350); submenu1 -- ;
}
break;
} //end switch
} //end SICLO TIME FILTRO
// config_TIEMPO_SICLO_ENTRE_MARCHAS();
void config_TIEMPO_SICLO_ENTRE_MARCHAS()
{
lcd.setCursor(0,0);
lcd.print("TiempoSICLO OFF");
switch(submenu2)
{
case 1:
lcd.setCursor(0,1);
lcd.print(" INCREMENTAR >");
boton_ENTER = !digitalRead(bt_e) ;
if ( boton_ENTER == PULSADA) {
tiempo_SICLO_OFF_FILTRO += 1 ;
control_botonS() ;
boton_ENTER = RESET_boton ;
// FLAG_ENABLE_MENU = DESABILITADO ;
// guardar en buffer ROM --> tiempo_SICLO_ON_FILTRO
// controles de limites
delay (350) ;
//control_botonS() ;
}
boton_BACK = !digitalRead(bt_e) ;
if ( boton_BACK == PULSADA) {
control_botonS() ;
boton_BACK = RESET_boton ;
// guardar en buffer ROM --> tiempo_SICLO_ON_FILTRO
// controles de limites
delay (350) ;
//control_botonS() ;
}
boton_DERECHA = !digitalRead(bt_r) ;
if( boton_DERECHA == PULSADA ) {
control_botonS() ;
boton_DERECHA = RESET_boton;
delay (350) ; submenu2 =2;}
boton_IZQUIERDA = !digitalRead(bt_l) ;
if( boton_IZQUIERDA == PULSADA ) {
control_botonS() ;
boton_IZQUIERDA = RESET_boton;
delay (350) ; submenu2 =3;}
break;
case 2:
lcd.setCursor(0,1);
lcd.print("< DECREMENTAR >");
boton_ENTER = !digitalRead(bt_e) ;
if( boton_ENTER == PULSADA) {
tiempo_SICLO_OFF_FILTRO -= 1 ;
control_botonS() ;
boton_ENTER = RESET_boton ;
// guardar en buffer ROM --> tiempo_SICLO_ON_FILTRO
// controles de limites
//FLAG_DECREMENTAR = 1;
delay (350) ;
}
boton_DERECHA = !digitalRead(bt_r) ;
if(boton_DERECHA == PULSADA) {
control_botonS() ;
boton_DERECHA = RESET_boton;
delay (350); submenu1 =3 ;}
boton_IZQUIERDA = !digitalRead(bt_l) ;
if(boton_IZQUIERDA == PULSADA) {
control_botonS() ;
boton_IZQUIERDA = RESET_boton; delay (350); submenu2 = 1;}
break;
case 3:
lcd.setCursor(0,1);
lcd.print("< FINALIZAR ");
boton_IZQUIERDA = !digitalRead(bt_l) ;
if(boton_IZQUIERDA == PULSADA ) {
control_botonS() ;
boton_IZQUIERDA = RESET_boton ;
delay (350); submenu2 =2 ;
}
break;
} //end switch
//
} //end SICLO TIME OFF FILTRO
void config_MODO_SICLO_FILTRO()
{
lcd.setCursor(0,0);
lcd.print(" MODO FILTRO ");
switch(submenu3)
{
case 1:
lcd.setCursor(0,1);
lcd.print(" ACTIVAR MANUAL >");
boton_ENTER = !digitalRead(bt_e) ;
if ( boton_ENTER == PULSADA) {
MODO_FILTRO = MANUAL ; // realizar etiquetas
control_botonS() ;
boton_ENTER = RESET_boton ;
// FLAG_ENABLE_MENU = DESABILITADO ;
// guardar en buffer ROM --> tiempo_SICLO_ON_FILTRO
// controles de limites
delay (350) ;
//control_botonS() ;
}
boton_BACK = !digitalRead(bt_e) ;
if ( boton_BACK == PULSADA) {
control_botonS() ;
boton_BACK = RESET_boton ;
// guardar en buffer ROM --> tiempo_SICLO_ON_FILTRO
// controles de limites
delay (350) ;
//control_botonS() ;
}
boton_DERECHA = !digitalRead(bt_r) ;
if( boton_DERECHA == PULSADA ) {
control_botonS() ;
boton_DERECHA = RESET_boton;
delay (350) ; submenu3 ++;}
boton_IZQUIERDA = !digitalRead(bt_l) ;
if( boton_IZQUIERDA == PULSADA ) {
control_botonS() ;
boton_IZQUIERDA = RESET_boton;
delay (350) ; submenu3 = 3;}
break;
case 2:
lcd.setCursor(0,1);
lcd.print("< ACT AUTOMATIC >");
boton_ENTER = !digitalRead(bt_e) ;
if( boton_ENTER == PULSADA) {
MODO_FILTRO = AUTOMATICO ; // realizar etiquetas
control_botonS() ;
boton_ENTER = RESET_boton ;
// guardar en buffer ROM --> tiempo_SICLO_ON_FILTRO
// controles de limites
//FLAG_DECREMENTAR = 1;
delay (350) ;
}
boton_DERECHA = !digitalRead(bt_r) ;
if(boton_DERECHA == PULSADA) {
control_botonS() ;
boton_DERECHA = RESET_boton;
delay (350); submenu3 ++;}
boton_IZQUIERDA = !digitalRead(bt_l) ;
if(boton_IZQUIERDA == PULSADA) {
control_botonS() ;
boton_IZQUIERDA = RESET_boton; delay (350); submenu3 --;}
break;
case 3:
lcd.setCursor(0,1);
lcd.print("< MODO ACTUAL "); // implementar visualizacion de modo actual de trabajo
boton_IZQUIERDA = !digitalRead(bt_l) ;
if(boton_IZQUIERDA == PULSADA ) {
control_botonS() ;
boton_IZQUIERDA = RESET_boton ;
delay (350); submenu3 -- ;
}
break;
} //end switch
}
void config_MODO_LOCAL_REMOTO_FILTRO()
{
lcd.setCursor(0,0);
lcd.print("MOD LOCAL/REMOTO");
switch(submenu4)
{
case 1:
lcd.setCursor(0,1);
lcd.print(" ACTIVAR LOCAL >");
boton_ENTER = !digitalRead(bt_e) ;
if ( boton_ENTER == PULSADA) {
MODO_FILTRO_LR = LOCAL ; // realizar etiquetas
control_botonS() ;
boton_ENTER = RESET_boton ;
// FLAG_ENABLE_MENU = DESABILITADO ;
// guardar en buffer ROM --> tiempo_SICLO_ON_FILTRO
// controles de limites
delay (350) ;
//control_botonS() ;
}
boton_BACK = !digitalRead(bt_e) ;
if ( boton_BACK == PULSADA) {
control_botonS() ;
boton_BACK = RESET_boton ;
// guardar en buffer ROM --> tiempo_SICLO_ON_FILTRO
// controles de limites
delay (350) ;
//control_botonS() ;
}
boton_DERECHA = !digitalRead(bt_r) ;
if( boton_DERECHA == PULSADA ) {
control_botonS() ;
boton_DERECHA = RESET_boton;
delay (350) ; submenu4 ++;}
boton_IZQUIERDA = !digitalRead(bt_l) ;
if( boton_IZQUIERDA == PULSADA ) {
control_botonS() ;
boton_IZQUIERDA = RESET_boton;
delay (350) ; submenu4 = 3;}
break;
case 2:
lcd.setCursor(0,1);
lcd.print("< ACTIVR REMOTO >"); // ACTIVAR MODO REMOTO
boton_ENTER = !digitalRead(bt_e) ;
if( boton_ENTER == PULSADA) {
MODO_FILTRO_LR = REMOTO ; // realizar etiquetas
control_botonS() ;
boton_ENTER = RESET_boton ;
// guardar en buffer ROM --> tiempo_SICLO_ON_FILTRO
// controles de limites
//FLAG_DECREMENTAR = 1;
delay (350) ;
}
boton_DERECHA = !digitalRead(bt_r) ;
if(boton_DERECHA == PULSADA) {
control_botonS() ;
boton_DERECHA = RESET_boton;
delay (350); submenu4 ++;}
boton_IZQUIERDA = !digitalRead(bt_l) ;
if(boton_IZQUIERDA == PULSADA) {
control_botonS() ;
boton_IZQUIERDA = RESET_boton; delay (350); submenu4 --;}
break;
case 3:
lcd.setCursor(0,1);
lcd.print("< MOD ACTUAL L/R"); // implementar visualizacion de modo actual de trabajo
boton_IZQUIERDA = !digitalRead(bt_l) ;
if(boton_IZQUIERDA == PULSADA ) {
control_botonS() ;
boton_IZQUIERDA = RESET_boton ;
delay (350); submenu4 -- ;
}
break;
} //end switch
}
// control_LOCAL_MANUAL_FILTRO
void control_LOCAL_MANUAL_FILTRO()
{
lcd.setCursor(0,0);
lcd.print("CONTROL LOC/MAN");
switch(submenu5)
{
case 1:
lcd.setCursor(0,1);
lcd.print("ARRANQUE FILTRO");
boton_ENTER = !digitalRead(bt_e) ;
if ( boton_ENTER == PULSADA) {
boton_ENTER = RESET_boton ;
// SUBRUTINA ARRANQUE
ejecutarARRANQUE_LOCAL_MANUAL();
control_botonS() ;
delay (350) ;
//control_botonS() ;
}
boton_DERECHA = !digitalRead(bt_r) ;
if( boton_DERECHA == PULSADA ) {
control_botonS() ;
boton_DERECHA = RESET_boton;
delay (350) ;
submenu5 =2;
}
boton_IZQUIERDA = !digitalRead(bt_l) ;
if( boton_IZQUIERDA == PULSADA ) {
control_botonS() ;
boton_IZQUIERDA = RESET_boton;
delay (350) ;
submenu5 = 3;
}
break;
case 2:
lcd.setCursor(0,1);
lcd.print("<DETENER FILTRO>");
boton_ENTER = !digitalRead(bt_e) ;
if( boton_ENTER == PULSADA)
{
control_botonS() ;
boton_ENTER = RESET_boton ;
// DETENER FILTRO
// guardar en buffer ROM --> tiempo_SICLO_ON_FILTRO
// controles de limites
delay (350) ;
}
boton_DERECHA = !digitalRead(bt_r) ;
if(boton_DERECHA == PULSADA) {
control_botonS() ;
boton_DERECHA = RESET_boton;
delay (350);
submenu5 = 3;
}
boton_IZQUIERDA = !digitalRead(bt_l) ;
if(boton_IZQUIERDA == PULSADA) {
control_botonS() ;
boton_IZQUIERDA = RESET_boton;
delay (350);
submenu5 = 1;
}
break;
case 3:
lcd.setCursor(0,1);
lcd.print("< FINALIZAR ");
boton_IZQUIERDA = !digitalRead(bt_l) ;
if(boton_IZQUIERDA == PULSADA ) {
control_botonS() ;
boton_IZQUIERDA = RESET_boton ;
delay (350);
submenu5 =2 ;
}
boton_DERECHA = !digitalRead(bt_r) ;
if(boton_DERECHA == PULSADA) {
control_botonS() ;
boton_DERECHA = RESET_boton;
delay (350);
submenu5 = 1;
}
break;
} //end switch
} //end MENU 5 CONTROL MARCHA LOCAL MANUAL
// opcion case 1 de menu 5
void ejecutarARRANQUE_LOCAL_MANUAL()
{
lcd.setCursor(0,0);
lcd.print("ARRANCANDO FLTR");
// digitalWrite(LATCH_PIN, LOW);
digitalWrite(motor_M1_ABRIR_VALVULAS , HIGH); // 4 //
digitalWrite(motor_M2_CEPILLO , HIGH); // 0 //
digitalWrite(motor_M3_BOMBA , HIGH); // 2 //
digitalWrite(electro_VALVULA , HIGH); // 15 //
digitalWrite(S1_FC_ABIERTO , HIGH); // 25 //
digitalWrite(S2_FC_CERRADO , HIGH); // 26 //
/*
lcd.setCursor(0,1);
lcd.print(" INCREMENTAR >");
boton_ENTER = !digitalRead(bt_e) ;
if ( boton_ENTER == PULSADA) {
tiempo_SICLO_OFF_FILTRO += 1 ;
control_botonS() ;
boton_ENTER = RESET_boton ;
// FLAG_ENABLE_MENU = DESABILITADO ;
// guardar en buffer ROM --> tiempo_SICLO_ON_FILTRO
// controles de limites
delay (350) ;
//control_botonS() ;
}
boton_BACK = !digitalRead(bt_e) ;
if ( boton_BACK == PULSADA) {
control_botonS() ;
boton_BACK = RESET_boton ;
// guardar en buffer ROM --> tiempo_SICLO_ON_FILTRO
// controles de limites
delay (350) ;
//control_botonS() ;
}
boton_DERECHA = !digitalRead(bt_r) ;
if( boton_DERECHA == PULSADA ) {
control_botonS() ;
boton_DERECHA = RESET_boton;
delay (350) ; submenu2 =2;}
boton_IZQUIERDA = !digitalRead(bt_l) ;
if( boton_IZQUIERDA == PULSADA ) {
control_botonS() ;
boton_IZQUIERDA = RESET_boton;
delay (350) ; submenu2 =3;}
break;
case 2:
lcd.setCursor(0,1);
lcd.print("< DECREMENTAR >");
boton_ENTER = !digitalRead(bt_e) ;
if( boton_ENTER == PULSADA) {
tiempo_SICLO_OFF_FILTRO -= 1 ;
control_botonS() ;
boton_ENTER = RESET_boton ;
// guardar en buffer ROM --> tiempo_SICLO_ON_FILTRO
// controles de limites
//FLAG_DECREMENTAR = 1;
delay (350) ;
}
boton_DERECHA = !digitalRead(bt_r) ;
if(boton_DERECHA == PULSADA) {
control_botonS() ;
boton_DERECHA = RESET_boton;
delay (350); submenu1 =3 ;}
boton_IZQUIERDA = !digitalRead(bt_l) ;
if(boton_IZQUIERDA == PULSADA) {
control_botonS() ;
boton_IZQUIERDA = RESET_boton; delay (350); submenu2 = 1;}
break;
case 3:
lcd.setCursor(0,1);
lcd.print("< FINALIZAR ");
boton_IZQUIERDA = !digitalRead(bt_l) ;
if(boton_IZQUIERDA == PULSADA ) {
control_botonS() ;
boton_IZQUIERDA = RESET_boton ;
delay (350); submenu2 =2 ;
}
break;
} //end switch
*/
}
void control_botonS()
{
if( boton_DERECHA == PULSADA )
{
Serial.print(F("BT R DERECHA menu_num "));
Serial.print( menu_num );
Serial.print(F(" sub_menu " ));
Serial.print( sub_menu );
Serial.print(F(" submenu1 " )) ;
Serial.println( submenu1 ); // PULSADO BT R
Serial.print(F(" modo LOC/REM " )) ;
Serial.print( MODO_FILTRO_LR ) ;
Serial.print(F(" modo AUT/MAN " )) ;
Serial.print( MODO_FILTRO ) ;
Serial.print(F(" Time ON FILTRO: " )) ;
Serial.print( tiempo_SICLO_ON_FILTRO ) ; // PULSADO BT R
Serial.print(F(" Time OFF FILTRO: " )) ;
Serial.println( tiempo_SICLO_OFF_FILTRO ) ; // PULSADO BT R
}
if( boton_IZQUIERDA == PULSADA )
{
Serial.print(F(" BT L IZQ menu_num "));
Serial.print( menu_num );
Serial.print(F(" sub_menu " ));
Serial.print( sub_menu );
Serial.print(F(" submenu1 " )) ;
Serial.println( submenu1 ); // PULSADO BT R
Serial.print(F(" modo LOC/REM " )) ;
Serial.print( MODO_FILTRO_LR ) ;
Serial.print(F(" modo AUT/MAN " )) ;
Serial.print( MODO_FILTRO ) ;
Serial.print(F(" modo AUT/MAN " )) ;
Serial.print( tiempo_SICLO_ON_FILTRO ) ; // PULSADO BT R
Serial.print(F(" Time OFF FILTRO: " )) ;
Serial.println( tiempo_SICLO_OFF_FILTRO ) ; // PULSADO BT R
}
if( boton_ENTER == PULSADA )
{
Serial.print(F(" BT ENTER menu_num ")); Serial.print( menu_num );
Serial.print(F(" sub_menu " )) ; Serial.print( sub_menu );
Serial.print(F(" submenu1 " )) ; Serial.println( submenu1 ); // PULSADO BT ENTER
Serial.print(F(" modo LOC/REM " )) ;
Serial.print( MODO_FILTRO_LR ) ;
Serial.print(F(" modo AUT/MAN " )) ;
Serial.print( MODO_FILTRO ) ;
Serial.print(F(" Time ON FILTRO: " )) ;
Serial.print( tiempo_SICLO_ON_FILTRO ) ; // PULSADO BT R
Serial.print(F(" Time OFF FILTRO: " )) ;
Serial.println( tiempo_SICLO_OFF_FILTRO ) ; // PULSADO BT R
}
if(boton_BACK == PULSADA )
{
Serial.print(F(" BT B BACK menu_num "));
Serial.print( menu_num );
Serial.print(F(" sub_menu " ));
Serial.print( sub_menu );
Serial.print(F(" submenu1 " )) ;
Serial.println( submenu1 ); // PULSADO BT BACK
Serial.print(F(" modo AUT/MAN " )) ;
Serial.print( MODO_FILTRO ) ;
Serial.print(F(" modo LOC/REM " )) ;
Serial.print( MODO_FILTRO_LR ) ;
Serial.print(F(" Time ON FILTRO: " )) ;
Serial.print( tiempo_SICLO_ON_FILTRO ) ; // PULSADO BT R
Serial.print(F(" Time OFF FILTRO: " )) ;
Serial.println( tiempo_SICLO_OFF_FILTRO ) ; // PULSADO BT R
}
} // fin void control_botonS