#include #include #include //I2C library #include "LiquidCrystalShift.h" #include "IRremote.h" #include "constants.h" #include "pin_definition.h" #include "WiFlyUDP.h" #include "TimerOne.h" #define LANGUAGE_ES // Language of menus: LANGUAGE_ES for (Spanish)- LANGUAGE_EN for (English) #include "languages.h" int result; // Global variables byte lastKey = NO_KEY; // Last key pressed boolean flagHoldKey = false; // Flag to ignore keys after a hold key int batmax; // Nivel maximo de bateria int batmin; // Nivel minimo de bateria //Variables de configuracion boolean system_useBacklight; boolean system_useSpeaker; unsigned int system_models; unsigned long remoterec; unsigned long remotestop; unsigned long lancrec; unsigned long lancstop; int frame = 0; int seconds = 0; int minutes = 0; int hours = 0; unsigned long timecode = 0; byte id = 0; char* ssid = "hangar_nau3"; //char* pass = "m1cr0fug4s"; char pass[33] = "m1cr0fug4s"; uint16_t remote_Port=8000; uint16_t local_Port=9000; char* ip_host = "172.26.0.187"; WiFlyUDP udp(&Serial); long baudrate = 9600; void timerIsr() { timecode++; frame++; if (frame>sistema) {frame=0; seconds++;} if (seconds>59) {seconds = 0; minutes++;} if (minutes>59) {minutes = 0; hours++;} if (hours>99) hours = 0; } boolean WiFly_detect(long *baudrate) { boolean detect=false; Serial.begin(*baudrate); delay(100); byte i=0; while ((i<=4)&&(!detect)) { detect = udp.enterCommandMode(); if (!detect) { if(i<4) { *baudrate=vel[i]; Serial.begin(*baudrate); } i++; } } return(detect); } void ini() { lanc.begin(9600); Wire.begin(); // Iniciar librerias i2c Timer1.initialize(1000000/sistema); // set a timer of length 1000000 microseconds (or 1 sec - or 1Hz) Timer1.attachInterrupt( timerIsr ); // attach the service routine here for(int i=0; i<=4; i++) { pinMode(bot[i], INPUT); digitalWrite(bot[i],HIGH); } pinMode(xbee_cts, INPUT); pinMode(PINS_BUZZER, OUTPUT); lcd.shiftWrite(red, HIGH); lcd.shiftWrite(green, HIGH); lcd.begin(16, 2); // set up the LCD's number of columns and rows: lcd.shiftWrite(LCD_L, LOW); config_init(); // EPRROM init calibrate_level_battery(); display_vdossier(); } void setup() { ini(); if(WiFly_detect(&baudrate)) { //display_WiFlyResetting(&baudrate); display_WiFlyConnecting(&baudrate); } else { lcd.clear(); lcd.print("Sin WiFly"); delay(2000); } lcd.shiftWrite(LCD_L, !system_useBacklight); system_beep(200); irrecv.enableIRIn(); // Start the receiver result = memoryTest(); Serial.print("Memory test results: "); Serial.print(result,DEC); Serial.println(" bytes free"); } void loop() { controller_run(); }