예제 #1
0
        public static void Main()
        {
            WatchDog.Start(new TimeSpan(0, 0, 30));

            MinorLed.SetDriveMode(GpioPinDriveMode.Output);
            MajorLed.SetDriveMode(GpioPinDriveMode.Output);

            _lcdShield = new DfRobotLcdShield(20, 4);

            // Create a custom degrees symbol (°), store it on the LCD for later use with the lat/long display
            _lcdShield.CreateChar(0, new byte[] { 0x0, 0x4, 0xa, 0x4, 0x0, 0x0, 0x0, 0x0 });

            // 0 bars are not required as that would just require sending " "
            _lcdShield.CreateChar(1, new byte[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1F });
            _lcdShield.CreateChar(2, new byte[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1F, 0x1F });
            _lcdShield.CreateChar(3, new byte[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x1F, 0x1F, 0x1F });
            _lcdShield.CreateChar(4, new byte[] { 0x0, 0x0, 0x0, 0x0, 0x1F, 0x1F, 0x1F, 0x1F });
            _lcdShield.CreateChar(5, new byte[] { 0x0, 0x0, 0x0, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F });
            _lcdShield.CreateChar(6, new byte[] { 0x0, 0x0, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F });
            _lcdShield.CreateChar(7, new byte[] { 0x0, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F });
            // 8 bars are not required as that would just require sending byte 255.

            _thunderbolt = new ThunderBolt("COM1", AngleUnits.Degrees, AltitudeUnits.Meters, FEZ.GpioPin.D13);

            _lcdShield.OnButtonPressed += LcdShieldOnOnButtonPressed;

            DisplaySplash();

            var pwmController = PwmController.FromName(FEZ.PwmChannel.Controller3.Id);

            pwmController.SetDesiredFrequency(10000);

            var backlight = pwmController.OpenChannel(FEZ.PwmChannel.Controller3.D10);

            backlight.SetActiveDutyCyclePercentage(LcdBrightness / 100d);
            backlight.Start();

            TestLeds();

            _thunderbolt.Open();
            _thunderbolt.TimingMode = TimingModes.UTC;
            _thunderbolt.RequestManufacturingParameters();
            _thunderbolt.RequestFirmwareVersion();
            _thunderbolt.SetupUnitForDisciplining();
            _thunderbolt.RequestTrackedSatelliteStatus();

            _thunderbolt.TimeChanged += ThunderboltOnTimeChanged;

            Thread.Sleep(3000);

            DisplayVersion();

            while (true)
            {
                WatchDog.Reset();
                if (_thunderbolt.IsSerialDataBeingReceived)
                {
                    if (!_isSurveyInProgress && _thunderbolt.IsSurveyInProgress())
                    {
                        // Survey has just started.  Jump to the page displaying survey progress.
                        _previousPageNumber = _pageNumber; // Take note of the page we were on so we can switch back later.
                        _isSurveyInProgress = true;
                        _pageNumber         = 2;           // Set the new page to jump to.
                    }
                    else if (_isSurveyInProgress && !_thunderbolt.IsSurveyInProgress())
                    {
                        // Survey has just finished.  Jump to the previous page we were displaying.
                        _pageNumber         = _previousPageNumber;
                        _isSurveyInProgress = false;
                    }

                    switch (_pageNumber)
                    {
                    case 1:
                        DisplayScreenOne();
                        break;

                    case 2:
                        DisplayScreenTwo();
                        break;

                    case 3:
                        DisplayScreenThree();
                        break;

                    case 4:
                        DisplayScreenFour();
                        break;

                    case 5:
                        DisplaySatelliteSignalScreen();
                        break;

                    case 6:
                        DisplayPRNScreen();
                        break;

                    case 7:
                        DisplayDOPScreen();
                        break;

                    default:
                        DisplayScreenOne();
                        break;
                    }

                    UpdateAlarmIndicators();
                }
                else
                {
                    DisplayNoSerialDataScreen();
                }
            }
        }
예제 #2
0
        public static void Main()
        {
            _lcdShield = new DfRobotLcdShield(20, 4);

            // Create a custom degrees symbol (°), store it on the LCD for later use with the lat/long display
            _lcdShield.CreateChar(0, new byte[] { 0x0, 0x4, 0xa, 0x4, 0x0, 0x0, 0x0, 0x0 });

            // 0 bars are not required as that would just require sending " "
            _lcdShield.CreateChar(1, new byte[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1F });
            _lcdShield.CreateChar(2, new byte[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1F, 0x1F });
            _lcdShield.CreateChar(3, new byte[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x1F, 0x1F, 0x1F });
            _lcdShield.CreateChar(4, new byte[] { 0x0, 0x0, 0x0, 0x0, 0x1F, 0x1F, 0x1F, 0x1F });
            _lcdShield.CreateChar(5, new byte[] { 0x0, 0x0, 0x0, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F });
            _lcdShield.CreateChar(6, new byte[] { 0x0, 0x0, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F });
            _lcdShield.CreateChar(7, new byte[] { 0x0, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F });
            // 8 bars are not required as that would just require sending byte 255.

#if (NETDUINO)
            _thunderbolt = new ThunderBolt("COM1", AngleUnits.Degrees, AltitudeUnits.Meters, new OutputPort(Pins.GPIO_PIN_D13, false));
#endif
#if (FEZLEMUR)
            _thunderbolt = new ThunderBolt("COM1", AngleUnits.Degrees, AltitudeUnits.Meters, new OutputPort(GHI.Pins.FEZLemur.Gpio.D13, false));
#endif

#if (NTP)
            _ntpServer = new NtpServer();
#endif

            _lcdShield.OnButtonPressed += LcdshieldOnOnButtonPressed;

            DisplaySplash();

#if (NETDUINO)
            var backlight = new Microsoft.SPOT.Hardware.PWM(PWMChannels.PWM_PIN_D10, 10000, LcdBrightness / 100d, false);
            backlight.Start();
#endif

            TestLeds();

            _thunderbolt.Open();
            _thunderbolt.TimingMode = TimingModes.UTC;
            _thunderbolt.RequestManufacturingParameters();
            _thunderbolt.RequestFirmwareVersion();
            _thunderbolt.SetupUnitForDisciplining();
            _thunderbolt.RequestTrackedSatelliteStatus();

            _thunderbolt.TimeChanged += ThunderboltOnTimeChanged;

            Thread.Sleep(3000);

            DisplayVersion();

#if (NTP)
            _ntpServer.Start();
#endif

            while (true)
            {
                if (_thunderbolt.IsSerialDataBeingReceived)
                {
                    if (!_isSurveyInProgress && _thunderbolt.IsSurveyInProgress())
                    {
                        // Survey has just started.  Jump to the page displaying survey progress.
                        _previousPageNumber = _pageNumber; // Take note of the page we were on so we can switch back later.
                        _isSurveyInProgress = true;
                        _pageNumber         = 2;           // Set the new page to jump to.
                    }
                    else if (_isSurveyInProgress && !_thunderbolt.IsSurveyInProgress())
                    {
                        // Survey has just finished.  Jump to the previous page we were displaying.
                        _pageNumber         = _previousPageNumber;
                        _isSurveyInProgress = false;
                    }

                    switch (_pageNumber)
                    {
                    case 1:
                        DisplayScreenOne();
                        break;

                    case 2:
                        DisplayScreenTwo();
                        break;

                    case 3:
                        DisplayScreenThree();
                        break;

                    case 4:
                        DisplayScreenFour();
                        break;

                    case 5:
                        DisplaySatelliteSignalScreen();
                        break;

                    case 6:
                        DisplayPRNScreen();
                        break;

                    case 7:
                        DisplayDOPScreen();
                        break;

#if (NTP)
                    case 8:
                        DisplayScreenNTP();
                        break;
#endif
                    default:
                        DisplayScreenOne();
                        break;
                    }

                    UpdateAlarmIndicators();
                }
                else
                {
                    DisplayNoSerialDataScreen();
                }
            }
        }