Example #1
0
        public void Load()
        {
            var rtc = DS1307.GetSingleton();
            var s   = rtc.GetStrings();

            if (s.Length == 11)
            {
                try
                {
                    //DualAxis = s[0] == "Y";
                    DualAxis         = false;
                    EastAzimuth      = Convert.ToInt32(s[1]);
                    WestAzimuth      = Convert.ToInt32(s[2]);
                    Latitude         = (float)Convert.ToDouble(s[3]);
                    Longitude        = (float)Convert.ToDouble(s[4]);
                    MaximumElevation = Convert.ToInt32(s[5]);
                    MinimumElevation = Convert.ToInt32(s[6]);
                    VerticalLength   = Convert.ToInt32(s[7]);
                    HorizontalLength = Convert.ToInt32(s[8]);
                    VerticalSpeed    = Convert.ToInt32(s[9]);
                    HorizontalSpeed  = Convert.ToInt32(s[10]);
                }
                catch (Exception ex)
                {
                    DefaultSettings();
                }
            }
            else // default
            {
                DefaultSettings();
            }
        }
Example #2
0
        public void Initialize()
        {
            SetupLCD();
            if (SetupLCD())
            {
                if (SetupRTC())
                {
                    //45.421389, 75.691667
                    //_latitude = DegreesMinuteSecondDecimalDegrees("45.24.40");
                    //_longitude = DegreesMinuteSecondDecimalDegrees("75.41.53");

                    _latitude  = 45.421389;
                    _longitude = -75.691667;

                    while (true)
                    {
                        var x1 = CalcSun(_latitude, _longitude, DateTime.Now, -4);
#if DEBUG
                        Debug.Print("azimuth: " + x1.azimuth.ToString("f2"));
                        Debug.Print("elevation: " + x1.elevation.ToString("f2"));
                        Debug.Print("eqTime: " + x1.eqTime.ToString("f2"));
                        Debug.Print("solarDec: " + x1.solarDec.ToString("f2"));
                        Debug.Print("coszen: " + x1.coszen.ToString("f4"));
                        Debug.Print(x1.dark ? "night" : "day");
#else
                        if (x1.dark)
                        {
                            _lcd.Clear();
                            _lcd.SetCursorPosition(0, 0);
                            _lcd.Write(Resources.GetString(Resources.StringResources.Dark));
                        }
                        else
                        {
                            //_lcd.Clear();
                            //_lcd.SetCursorPosition(0, 0);
                            //_lcd.Write(Resources.GetString(Resources.StringResources.Azimuth));
                            //_lcd.Write(x1.azimuth.ToString("f2"));
                            //_lcd.SetCursorPosition(0, 1);
                            //_lcd.Write(Resources.GetString(Resources.StringResources.Elevation));
                            //_lcd.Write(x1.elevation.ToString("f2"));

                            _lcd.Clear();
                            _lcd.SetCursorPosition(0, 0);
                            var rtc  = DS1307.GetSingleton();
                            var time = rtc.Get();
                            _lcd.Write(time.ToString(Resources.GetString(Resources.StringResources.DateFormat)));

                            _lcd.SetCursorPosition(0, 1);
                            _lcd.Write("A:");
                            _lcd.Write(x1.azimuth.ToString("f2"));
                            _lcd.Write(" E:");
                            _lcd.Write(x1.elevation.ToString("f2"));
                        }
#endif
                        Thread.Sleep(10000);
                    }
                }
            }
        }
Example #3
0
        private bool SetupRTC()
        {
            bool rVal = true;

            try
            {
                //var browserTime = new DateTime(2015, 09, 04, 14, 55, 30);
                //DS1307.SetRTCTime(browserTime);
                var rtc = DS1307.GetSingleton();
                DS1307.SetNetduinoTimeFromRTC();
                TrackerState = State.ClockSet;
                Thread.Sleep(2000);
            }
            catch (Exception)
            {
                rVal = false;
            }
            return(rVal);
        }
Example #4
0
        public void Save()
        {
            // verify limits
            if (MaximumElevation > 90)
            {
                MaximumElevation = 90;
            }
            if (MaximumElevation < 45)
            {
                MaximumElevation = 45;
            }

            if (MinimumElevation > 45)
            {
                MinimumElevation = 45;
            }
            if (MinimumElevation < 0)
            {
                MinimumElevation = 0;
            }

            if (EastAzimuth < 45)
            {
                EastAzimuth = 45;
            }
            if (EastAzimuth > 135)
            {
                EastAzimuth = 135;
            }

            if (WestAzimuth < 225)
            {
                WestAzimuth = 225;
            }
            if (WestAzimuth > 315)
            {
                WestAzimuth = 315;
            }
            var rtc = DS1307.GetSingleton();

            string[] sa = new[] { DualAxis ? "Y" : "N", EastAzimuth.ToString(), WestAzimuth.ToString(), Latitude.ToString("f6"), Longitude.ToString("f6"), MaximumElevation.ToString(), MinimumElevation.ToString(), VerticalLength.ToString(), HorizontalLength.ToString(), VerticalSpeed.ToString(), HorizontalSpeed.ToString() };
            rtc.SetRam(sa);
        }
Example #5
0
        private static bool SetupRTC()
        {
            bool rVal = true;

            try
            {
                var rtc = DS1307.GetSingleton();
                //DS1307.SetRTCTime(new DateTime(2014, 11, 17, 15, 14, 01));
                var time = rtc.Get();
                _lcd.SetCursorPosition(0, 0);
                _lcd.Write(time.ToString(Resources.GetString(Resources.StringResources.DateFormat)));
                DS1307.SetNetduinoTimeFromRTC();
                Thread.Sleep(2000);
            }
            catch (Exception)
            {
                rVal = false;
            }
            return(rVal);
        }