public static void Main() { serialPort.ReadTimeout = 0; MonitorZonesDelegate monitorZones = new MonitorZonesDelegate(MonitorZones); MonitorMotionSensorDelegate monitorMotion = new MonitorMotionSensorDelegate(MonitorSensors); //based on a post by Valkyrie-MT //http://forums.netduino.com/index.php?/topic/475-still-learning-internet-way-to-grab-date-and-time-on-startup/ Debug.Print("Setting NTP-time"); SetTime(); SdCardEventLogger.parseConfigFileContents(Alarm.User_Definitions.Constants.ALARM_CONFIG_FILE_PATH); InitArrays(); IPAddress = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].IPAddress; Debug.Print(IPAddress); LastResetCycle = DateTime.Now.ToString("ddd, d MMM yyyy HH:mm:ss \r\n"); SdCardEventLogger.SDCardAccess(); if (SdCardEventLogger.IsSDCardAvailable()) { Table_CSS_Style = SdCardEventLogger.loadFileContent(Alarm.User_Definitions.Constants.HTML_RESOURCE_TABLE_STYLE); Css_header = SdCardEventLogger.loadFileContent(Alarm.User_Definitions.Constants.HTML_RESOURCE_HEADER_STYLE); } new Thread(Alarm.ProtoScrewShield_LED.Blink).Start(); //Web Server based on MFToolkit library by: Michael Schwarz //download latest library at: (http://mftoolkit.codeplex.com/") new Thread(Alarm.WebServer.startHttp).Start(); while (true) { Debug.Print("Memory available: " + Debug.GC(true)); monitorZones(); monitorMotion(); Thread.Sleep(Alarm.Common.Alarm_Constants.ALARM_DELAY_TIME); } }
public static void Main() { serialPort.ReadTimeout = 0; string InitMessage = "Initializing..."; // set up the LCD's number of columns and rows: lcd.Begin(columns: 16, lines: 2); lcd.Backlight = true; lcd.Clear(); lcd.Clear(); lcd.SetCursorPosition(0, 0); // Print a message to the LCD. lcd.Write(" *** ARMING ***"); Thread.Sleep(250); lcd.SetCursorPosition(column: 0, row: 1); lcd.Write("HomeAlarmPlus Pi"); Thread.Sleep(1600); lcd.Clear(); lcd.SetCursorPosition(column: 0, row: 0); lcd.Write(InitMessage); Thread.Sleep(1600); for (int i = 0; i < InitMessage.Length; i++) { lcd.ScrollDisplayLeft(); Thread.Sleep(85); } lcd.Clear(); lcd.SetCursorPosition(column: 0, row: 0); lcd.Write("HomeAlarmPlus Pi"); MonitorZonesDelegate monitorZones = new MonitorZonesDelegate(MonitorZones); MonitorMotionSensorDelegate monitorMotion = new MonitorMotionSensorDelegate(MonitorSensors); SdCardEventLogger.parseConfigFileContents(Alarm.User_Definitions.Constants.ALARM_CONFIG_FILE_PATH); syncHttpEvents = Stopwatch.StartNew(); InitArrays(); IPAddress = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].IPAddress; Console.DEBUG_ACTIVITY(IPAddress); lcd.SetCursorPosition(column: 0, row: 1); lcd.Write("IP: " + IPAddress + " "); Thread.Sleep(1000); SdCardEventLogger.SDCardAccess(); lcd.SetCursorPosition(column: 0, row: 1); lcd.Write("Port: " + Alarm.ConfigDefault.Data.Http_port + " "); Thread.Sleep(1000); new Thread(Alarm.WebServer.startHttp).Start(); //Time from Raspberry Pi Debug.Print("Setting Date and Time from Network"); lcd.SetCursorPosition(column: 0, row: 1); lcd.Write("Finding RPi-srvr"); Notification.PushingBox.Connect("vPUSHINGBOX"); //Let's notify Pushover //With extension.replace spaces are replaced with %20 so that is recognized by PHP when posting parameters. string time = DateTime.Now.ToString(); string ttime = Extension.Replace(time, " ", "%20"); Notification.Pushover.Connect(ttime, Extension.Replace("Netduino Plus Time set", " ", "%20"), Extension.Replace("Time set from Raspberry Pi", " ", "%20"), false); LastResetCycle = DateTime.Now.ToString("ddd, d MMM yyyy hh:mm:ss tt\r\n"); dLastResetCycle = DateTime.Now; Thread.Sleep(2000); lcd.SetCursorPosition(column: 0, row: 0); lcd.Write("Syncing data "); lcd.SetCursorPosition(column: 0, row: 1); lcd.Write("Wunderground "); parseWeatherData(ttime); Thread.Sleep(2000); lcd.Clear(); lcd.SetCursorPosition(column: 0, row: 0); lcd.Write("HomeAlarmPlus Pi"); lcd.SetCursorPosition(column: 0, row: 1); lcd.Write("Temp: " + Alarm.Common.Weather_Info.current_temperature + " "); Thread.Sleep(2000); lcd.SetCursorPosition(column: 0, row: 1); lcd.Write("SYSTEM READY "); Debug.Print("ARMED!"); Thread.Sleep(560); ATTINYx5.Write(true); lcd.Clear(); int count = 0, sub_count = 0; while (true) { Console.DEBUG_ACTIVITY("Main Method - Memory available: " + Debug.GC(true)); monitorZones(); //monitorMotion(); lcd.Clear(); if (count % 2 == 0) { lcd.SetCursorPosition(column: 0, row: 0); lcd.Write(" Date Time"); lcd.SetCursorPosition(column: 0, row: 1); lcd.Write(DateTime.Now.ToString("MMM dd/yy h:mmtt ").ToUpper()); } else { lcd.SetCursorPosition(column: 0, row: 0); lcd.Write(" Current Temp"); lcd.SetCursorPosition(column: 0, row: 1); if (sub_count % 2 == 0) { lcd.Write(Alarm.Common.Weather_Info.current_temperature + " " + Alarm.Common.Weather_Info.current_conditions); } else { lcd.Write("Hi: " + Alarm.Common.Weather_Info.today_high + " Lo: " + Alarm.Common.Weather_Info.today_low); } sub_count++; } Thread.Sleep(Alarm.Common.Alarm_Constants.ALARM_DELAY_TIME); double eHours = syncHttpEvents.ElapsedHours; if (eHours >= Alarm.ConfigDefault.Data.WUNDERGROUND_SYNC_FREQUENCY) { parseWeatherData(Extension.Replace(DateTime.Now.ToString(), " ", "%20")); syncHttpEvents = Stopwatch.StartNew(); } count++; } }
public static void Main() { serialPort.ReadTimeout = 0; MonitorZonesDelegate monitorZones = new MonitorZonesDelegate(MonitorZones); MonitorMotionSensorDelegate monitorMotion = new MonitorMotionSensorDelegate(MonitorSensors); //based on a post by Valkyrie-MT //http://forums.netduino.com/index.php?/topic/475-still-learning-internet-way-to-grab-date-and-time-on-startup/ Debug.Print("Setting NTP-time"); SetTime(); SdCardEventLogger.parseConfigFileContents(Alarm.User_Definitions.Constants.ALARM_CONFIG_FILE_PATH); InitArrays(); IPAddress = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].IPAddress; Debug.Print(IPAddress); LastResetCycle = DateTime.Now.ToString("ddd, d MMM yyyy HH:mm:ss \r\n"); SdCardEventLogger.SDCardAccess(); if (SdCardEventLogger.IsSDCardAvailable()) { Table_CSS_Style = SdCardEventLogger.loadFileContent(Alarm.User_Definitions.Constants.HTML_RESOURCE_TABLE_STYLE); Css_header = SdCardEventLogger.loadFileContent(Alarm.User_Definitions.Constants.HTML_RESOURCE_HEADER_STYLE); } new Thread(Alarm.ProtoScrewShield_LED.Blink).Start(); //Web Server based on MFToolkit library by: Michael Schwarz //download latest library at: (http://mftoolkit.codeplex.com/") new Thread(Alarm.WebServer.startHttp).Start(); while (true) { Debug.Print("Memory available: " + Debug.GC(true)); monitorZones(); monitorMotion(); Thread.Sleep(Alarm.Common.Alarm_Constants.ALARM_DELAY_TIME); } }
public static void Main() { serialPort.ReadTimeout = 0; string InitMessage = "Initializing..."; // set up the LCD's number of columns and rows: lcd.Begin(columns: 16, lines: 2); lcd.Backlight = true; lcd.Clear(); lcd.Clear(); lcd.SetCursorPosition(0, 0); // Print a message to the LCD. lcd.Write(" *** ARMING ***"); Thread.Sleep(250); lcd.SetCursorPosition(column: 0, row: 1); lcd.Write("HomeAlarmPlus Pi"); Thread.Sleep(1600); lcd.Clear(); lcd.SetCursorPosition(column: 0, row: 0); lcd.Write(InitMessage); Thread.Sleep(1600); for (int i = 0; i < InitMessage.Length; i++) { lcd.ScrollDisplayLeft(); Thread.Sleep(85); } lcd.Clear(); lcd.SetCursorPosition(column: 0, row: 0); lcd.Write("HomeAlarmPlus Pi"); MonitorZonesDelegate monitorZones = new MonitorZonesDelegate(MonitorZones); MonitorMotionSensorDelegate monitorMotion = new MonitorMotionSensorDelegate(MonitorSensors); SdCardEventLogger.parseConfigFileContents(Alarm.User_Definitions.Constants.ALARM_CONFIG_FILE_PATH); syncHttpEvents = Stopwatch.StartNew(); InitArrays(); IPAddress = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].IPAddress; Console.DEBUG_ACTIVITY(IPAddress); lcd.SetCursorPosition(column: 0, row: 1); lcd.Write("IP: " + IPAddress + " "); Thread.Sleep(1000); SdCardEventLogger.SDCardAccess(); lcd.SetCursorPosition(column: 0, row: 1); lcd.Write("Port: " + Alarm.ConfigDefault.Data.Http_port + " "); Thread.Sleep(1000); new Thread(Alarm.WebServer.startHttp).Start(); //Time from Raspberry Pi Debug.Print("Setting Date and Time from Network"); lcd.SetCursorPosition(column: 0, row: 1); lcd.Write("Finding RPi-srvr"); Notification.PushingBox.Connect("vPUSHINGBOX"); //Let's notify Pushover //With extension.replace spaces are replaced with %20 so that is recognized by PHP when posting parameters. string time = DateTime.Now.ToString(); string ttime = Extension.Replace(time, " ", "%20"); Notification.Pushover.Connect(ttime, Extension.Replace("Netduino Plus Time set", " ", "%20"), Extension.Replace("Time set from Raspberry Pi", " ", "%20"), false); LastResetCycle = DateTime.Now.ToString("ddd, d MMM yyyy hh:mm:ss tt\r\n"); dLastResetCycle = DateTime.Now; Thread.Sleep(2000); lcd.SetCursorPosition(column: 0, row: 0); lcd.Write("Syncing data "); lcd.SetCursorPosition(column: 0, row: 1); lcd.Write("Wunderground "); parseWeatherData(ttime); Thread.Sleep(2000); lcd.Clear(); lcd.SetCursorPosition(column: 0, row: 0); lcd.Write("HomeAlarmPlus Pi"); lcd.SetCursorPosition(column: 0, row: 1); lcd.Write("Temp: " + Alarm.Common.Weather_Info.current_temperature + " "); Thread.Sleep(2000); lcd.SetCursorPosition(column: 0, row: 1); lcd.Write("SYSTEM READY "); Debug.Print("ARMED!"); Thread.Sleep(560); ATTINYx5.Write(true); lcd.Clear(); int count = 0, sub_count = 0; while (true) { Console.DEBUG_ACTIVITY("Main Method - Memory available: " + Debug.GC(true)); monitorZones(); //monitorMotion(); lcd.Clear(); if (count % 2 == 0) { lcd.SetCursorPosition(column: 0, row: 0); lcd.Write(" Date Time"); lcd.SetCursorPosition(column: 0, row: 1); lcd.Write(DateTime.Now.ToString("MMM dd/yy h:mmtt ").ToUpper()); } else { lcd.SetCursorPosition(column: 0, row: 0); lcd.Write(" Current Temp"); lcd.SetCursorPosition(column: 0, row: 1); if (sub_count % 2 == 0) lcd.Write(Alarm.Common.Weather_Info.current_temperature + " " + Alarm.Common.Weather_Info.current_conditions); else lcd.Write("Hi: " + Alarm.Common.Weather_Info.today_high + " Lo: " + Alarm.Common.Weather_Info.today_low); sub_count++; } Thread.Sleep(Alarm.Common.Alarm_Constants.ALARM_DELAY_TIME); double eHours = syncHttpEvents.ElapsedHours; if (eHours >= Alarm.ConfigDefault.Data.WUNDERGROUND_SYNC_FREQUENCY) { parseWeatherData(Extension.Replace(DateTime.Now.ToString(), " ", "%20")); syncHttpEvents = Stopwatch.StartNew(); } count++; } }