private async void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {
            if (LightningProvider.IsLightningEnabled)
            {
                LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider();

                var pwmControllers = await PwmController.GetControllersAsync(LightningPwmProvider.GetPwmProvider());

                var pwmController = pwmControllers[1]; // the on-device controller
                pwmController.SetDesiredFrequency(50); // try to match 50Hz


                internetLed = new InternetLed();

                _pin18 = pwmController.OpenPin(18);

                while (true)
                {
                    await internetLed.GetThrottleFromWeb();

                    double test = internetLed.getThrottle() / 100.0;

                    _pin18.SetActiveDutyCyclePercentage(internetLed.getThrottle() / 100.0);
                    _pin18.Start();


                    await Task.Delay(200);
                }
            }
        }
예제 #2
0
        // This method will be called by the application framework when the page is first loaded.
        protected override async void OnNavigatedTo(NavigationEventArgs navArgs)
        {
            Debug.WriteLine("MainPage::OnNavigatedTo");

            MakePinWebAPICall();

            try
            {
                // Create a new InternetLed object
                internetLed = new InternetLed(GPIOToUse);

                // Initialize it for use
                internetLed.InitalizeLed();

                // Now have it make the web API call and get the led blink delay
                int blinkDelay = await internetLed.GetBlinkDelayFromWeb();

                for (int i = 0; i < 100; i++)
                {
                    internetLed.Blink();
                    await Task.Delay(blinkDelay);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
        }
예제 #3
0
        protected override async void OnNavigatedTo(NavigationEventArgs navArgs)
        {
            Debug.WriteLine("MainPage::OnNavigatedTo");

            try
            {
                // Create a new InternetLed object
                internetLed = new InternetLed(GPIOToUse);

                // Initialize it for use
                internetLed.InitalizeLed();

                // Now have it make the web API call and get the led state.
                InternetLed.eLedState ledState = await internetLed.MakeWebApiCall();

                // And finally set the state of the led to that new value.
                internetLed.LedState = ledState;

                // And for fun do that 100 more times so we can see if things change over time.
                for (int i = 0; i < 100; i++)
                {
                    ledState = await internetLed.MakeWebApiCall();

                    internetLed.LedState = ledState;
                    await Task.Delay(100);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
        }
예제 #4
0
        // This method will be called by the application framework when the page is first loaded.
        protected override async void OnNavigatedTo(NavigationEventArgs navArgs)
        {
            Debug.WriteLine("MainPage::OnNavigatedTo");

            MakePinWebAPICall();

            try
            {
                // Create a new InternetLed object
                internetLed = new InternetLed(GPIOToUse);

                // Initialize it for use
                internetLed.InitalizeLed();

                // Now have it make the web API call and get the led blink delay
                int blinkDelay = await internetLed.GetBlinkDelayFromWeb();

                for (int i = 0; i < 100; i++)
                {
                    internetLed.Blink();
                    await Task.Delay(blinkDelay);
                }

            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
        }
예제 #5
0
        protected override async void OnNavigatedTo(NavigationEventArgs navArgs)
        {
            Debug.WriteLine("MainPage::OnNavigatedTo");

            try
            {
                // Create a new InternetLed object
                internetLed = new InternetLed(GPIOToUse);

                // Initialize it for use
                internetLed.InitalizeLed();

                // Now have it make the web API call and get the led state.
                InternetLed.eLedState ledState = await internetLed.MakeWebApiCall();

                // And finally set the state of the led to that new value.
                internetLed.LedState = ledState;

                // And for fun do that 100 more times so we can see if things change over time.
                for (int i = 0; i < 100; i++)
                {
                    ledState = await internetLed.MakeWebApiCall();
                    internetLed.LedState = ledState;
                    await Task.Delay(100);
                }

            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
        }