Exemplo n.º 1
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(7, new byte[] { 0x0, 0x4, 0xa, 0x4, 0x0, 0x0, 0x0, 0x0 });

            _thunderbolt = new ThunderBolt("COM1", AngleUnits.Degrees, AltitudeUnits.Meters, new OutputPort(Pins.GPIO_PIN_D13, false));
            _ntpServer = new NtpServer();

            _lcdshield.OnButtonPressed += LcdshieldOnOnButtonPressed;

            DisplaySplash();
            TestLeds();

            _thunderbolt.Open();
            _thunderbolt.TimingMode = TimingModes.UTC;

            Thread.Sleep(1500);

            _ntpServer.Start();

            //_thunderbolt.TimeChanged += ThunderboltOnTimeChanged;

            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:
                            DisplayScreenFive();
                            break;
                        default:
                            DisplayScreenOne();
                            break;
                    }

                    UpdateAlarmIndicators();

                }
                else
                {
                    DisplayNoSerialDataScreen();
                }

                Thread.Sleep(100);

            }
        }
Exemplo n.º 2
0
        private static void LcdshieldOnOnButtonPressed(object sender, DfRobotLcdShield.Buttons buttonPressed)
        {
            switch (buttonPressed)
            {
                case DfRobotLcdShield.Buttons.Command1:
                    _thunderbolt.ReceiverMode = ReceiverMode.FullPosition;
                    // Transmit COM 8 Packet ID: BB  Data Length: 40
                    // 00 04 FF 04 02 3E 32 B8 C3 40 80 00 00 41 00 00 00 40 C0 00 00 FF 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF

                    break;

                case DfRobotLcdShield.Buttons.Command2:

                    _thunderbolt.ReceiverMode = ReceiverMode.OverDeterminedClock;
                    // Transmit COM 8 Packet ID: BB  Data Length: 40
                    // 00 07 FF 04 02 3E 32 B8 C3 40 80 00 00 41 00 00 00 40 C0 00 00 FF 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF

                    break;

                case DfRobotLcdShield.Buttons.Command3:
                    //_thunderbolt.set_survey_params(1, 1, 5);
                    _thunderbolt.start_self_survey();
                    break;

                case DfRobotLcdShield.Buttons.Up:
                    _pageNumber++;
                    if (_pageNumber > 5) { _pageNumber = 1; }
                    _previousPageNumber = _pageNumber;  // Setting this value to override the survey finished change event.
                    break;

                case DfRobotLcdShield.Buttons.Down:
                    _pageNumber--;
                    if (_pageNumber < 1) { _pageNumber = 5; }
                    _previousPageNumber = _pageNumber;  // Setting this value to override the survey finished change event.
                    break;
            }
        }