Beispiel #1
0
        //lora data received
        void _loraSerial_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {
            _dataInLora = _loraSerial.Deserialize();
            for (int index = 0; index < _dataInLora.Length; index++)
            {
                rx = _dataInLora[index];
                //if error
                if (_dataInLora[index].Length > 7)
                {
                    if (rx.Substring(0, 9) == "radio_err")
                    {
                        Debug.Print("!!!!!!!!!!!!! Radio Error !!!!!!!!!!!!!!");
                        _restPort.Write(false);
                        Thread.Sleep(1000);
                        _restPort.Write(true);
                        Thread.Sleep(1000);
                        _loraSerial.WriteLine("mac pause");
                        Thread.Sleep(1000);
                        _loraSerial.WriteLine("radio rx 0");
                        return;
                    }
                    //if receive data
                    if (rx.Substring(0, 8) == "radio_rx")
                    {
                        string hex = _dataInLora[index].Substring(10);
                        multicolorLED.BlinkRepeatedly(GT.Color.Blue);

                        //Debug.Print(hex);
                        //Debug.Print(Unpack(hex));
                        //update display
                        PrintToLCD(Unpack(hex));
                        Thread.Sleep(100);
                        // set module to RX
                        _loraSerial.WriteLine("radio rx 0");
                    }
                }
            }
        }
Beispiel #2
0
        // This method is run when the mainboard is powered up or reset.
        void ProgramStarted()
        {
            multicolorLED.BlinkOnce(GT.Color.Red);
            //7" Displays
            Display.Width  = 800;
            Display.Height = 480;
            Display.OutputEnableIsFixed      = false;
            Display.OutputEnablePolarity     = true;
            Display.PixelPolarity            = false;
            Display.PixelClockRateKHz        = 30000;
            Display.HorizontalSyncPolarity   = false;
            Display.HorizontalSyncPulseWidth = 48;
            Display.HorizontalBackPorch      = 88;
            Display.HorizontalFrontPorch     = 40;
            Display.VerticalSyncPolarity     = false;
            Display.VerticalSyncPulseWidth   = 3;
            Display.VerticalBackPorch        = 32;
            Display.VerticalFrontPorch       = 13;
            Display.Type = Display.DisplayType.Lcd;
            if (Display.Save())      // Reboot required?
            {
                PowerState.RebootDevice(false);
            }
            //set up touch screen
            CapacitiveTouchController.Initialize(GHI.Pins.FEZRaptor.Socket13.Pin3);

            window = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.MyForm));
            //glide init
            GlideTouch.Initialize();

            GHI.Glide.UI.Button btn = (GHI.Glide.UI.Button)window.GetChildByName("btnTest");
            img          = (GHI.Glide.UI.Image)window.GetChildByName("img1");
            txtLora      = (GHI.Glide.UI.TextBlock)window.GetChildByName("txtLora");
            txtStatus    = (GHI.Glide.UI.TextBlock)window.GetChildByName("txtStatus");
            txtSPO2      = (GHI.Glide.UI.TextBlock)window.GetChildByName("txtSPO2");
            txtSignal    = (GHI.Glide.UI.TextBlock)window.GetChildByName("txtSignal");
            txtPulseRate = (GHI.Glide.UI.TextBlock)window.GetChildByName("txtPulseRate");
            txtDesc      = (GHI.Glide.UI.TextBlock)window.GetChildByName("txtDesc");
            img.Visible  = false;

            btn.TapEvent += btn_TapEvent;

            Glide.MainWindow = window;
            //reset lora
            _restPort.Write(false);
            Thread.Sleep(1000);
            _restPort.Write(true);
            Thread.Sleep(1000);

            _loraSerial = new SimpleSerial(GHI.Pins.FEZRaptor.Socket10.SerialPortName, 57600);
            _loraSerial.Open();
            _loraSerial.DataReceived += _loraSerial_DataReceived;
            //get version
            _loraSerial.WriteLine("sys get ver");
            Thread.Sleep(1000);
            //pause join
            _loraSerial.WriteLine("mac pause");
            Thread.Sleep(1000);
            //antena power
            _loraSerial.WriteLine("radio set pwr 14");
            Thread.Sleep(1000);
            //set device to receive
            _loraSerial.WriteLine("radio rx 0"); //set module to RX
        }
Beispiel #3
0
        // This method is run when the mainboard is powered up or reset.
        void ProgramStarted()
        {
            multicolorLED.BlinkOnce(GT.Color.Red);
            //7" Displays
            Display.Width = 800;
            Display.Height = 480;
            Display.OutputEnableIsFixed = false;
            Display.OutputEnablePolarity = true;
            Display.PixelPolarity = false;
            Display.PixelClockRateKHz = 30000;
            Display.HorizontalSyncPolarity = false;
            Display.HorizontalSyncPulseWidth = 48;
            Display.HorizontalBackPorch = 88;
            Display.HorizontalFrontPorch = 40;
            Display.VerticalSyncPolarity = false;
            Display.VerticalSyncPulseWidth = 3;
            Display.VerticalBackPorch = 32;
            Display.VerticalFrontPorch = 13;
            Display.Type = Display.DisplayType.Lcd;
            if (Display.Save())      // Reboot required?
            {
                PowerState.RebootDevice(false);
            }
            //set up touch screen
            CapacitiveTouchController.Initialize(GHI.Pins.FEZRaptor.Socket13.Pin3);

            window = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.MyForm));
            //glide init
            GlideTouch.Initialize();

            GHI.Glide.UI.Button btn = (GHI.Glide.UI.Button)window.GetChildByName("btnTest");
            img = (GHI.Glide.UI.Image)window.GetChildByName("img1");
            txtLora = (GHI.Glide.UI.TextBlock)window.GetChildByName("txtLora");
            txtStatus = (GHI.Glide.UI.TextBlock)window.GetChildByName("txtStatus");
            txtSPO2 = (GHI.Glide.UI.TextBlock)window.GetChildByName("txtSPO2");
            txtSignal = (GHI.Glide.UI.TextBlock)window.GetChildByName("txtSignal");
            txtPulseRate = (GHI.Glide.UI.TextBlock)window.GetChildByName("txtPulseRate");
            txtDesc = (GHI.Glide.UI.TextBlock)window.GetChildByName("txtDesc");
            img.Visible = false;

            btn.TapEvent += btn_TapEvent;

            Glide.MainWindow = window;
            //reset lora
            _restPort.Write(false);
            Thread.Sleep(1000);
            _restPort.Write(true);
            Thread.Sleep(1000);

            _loraSerial = new SimpleSerial(GHI.Pins.FEZRaptor.Socket10.SerialPortName, 57600);
            _loraSerial.Open();
            _loraSerial.DataReceived += _loraSerial_DataReceived;
            //get version
            _loraSerial.WriteLine("sys get ver");
            Thread.Sleep(1000);
            //pause join
            _loraSerial.WriteLine("mac pause");
            Thread.Sleep(1000);
            //antena power
            _loraSerial.WriteLine("radio set pwr 14");
            Thread.Sleep(1000);
            //set device to receive
            _loraSerial.WriteLine("radio rx 0"); //set module to RX
        }