示例#1
0
        private static void DisplayEspState(GHIElectronics.TinyCLR.BrainPad.Display display, Esp8266WIFI esp8266Client)
        {
            display.Clear();
            switch (esp8266Client.WifiState)
            {
            case WifiState.Disconnected:
                display.DrawSmallText(0, 0, "NO WIFI");
                break;

            case WifiState.Connected:
            case WifiState.GotIP:
                display.DrawSmallText(0, 0, "WIFI CONNECTED");
                break;

            case WifiState.NoAP:
                display.DrawSmallText(0, 0, "NO AP");
                break;

            case WifiState.Busy:
            case WifiState.Unknown:
            default:
                display.DrawSmallText(0, 0, "ERROR");
                break;
            }
            display.DrawSmallText(0, 10, $"IP: {esp8266Client.IPAddress}");
            string ready = esp8266Client.ConnectionState == ConnectionState.Ready ? "REMOTE CONNECTED" : "REMOTE CLOSED";

            display.DrawSmallText(0, 20, ready);
            display.RefreshScreen();
        }
示例#2
0
        static void Main()
        {
            _buzzer = new GHIElectronics.TinyCLR.BrainPad.Buzzer();


            //Setup wifi and remote computer connection
            _connection = new Connection {
                SSID = "MOTOROLA-3258C", Password = "******", Target = "192.168.0.6"
            };
            //_connection = new Connection { SSID = "K7 8181", Password = "******", Target = "192.168.43.133" };

            GpioController gpioController = GpioController.GetDefault();

            var display = new GHIElectronics.TinyCLR.BrainPad.Display();

            display.DrawSmallText(0, 0, "Hi there!");

            display.RefreshScreen();


            _pin1 = gpioController.OpenPin(BrainPad.Expansion.GpioPin.Int);
            _pin1.SetDriveMode(GpioPinDriveMode.Output);
            _pin1.Write(GpioPinValue.Low);


            _pins.Add(_pin1);

            InitializeButtonComponents(gpioController);
            GpioPin CH_PD = gpioController.OpenPin(BrainPad.Expansion.GpioPin.Cs);

            InitializeEsp8266Wifi(display, CH_PD);

            _buzzer.Beep();

            Thread.Sleep(-1);
        }