Exemplo n.º 1
0
        public NotePage(ParticleDevice device)
        {
            ViewModel      = new NotePageViewModel(device);
            BindingContext = ViewModel;

            var piano = new Piano();

            piano.upOctive.Command   = new Command(() => ViewModel.IncreaseOctive());
            piano.downOctive.Command = new Command(() => ViewModel.DecreaseOctive());
            piano.cKey.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => ViewModel.SendNote("C"))
            });
            piano.bKey.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => ViewModel.SendNote("B"))
            });
            piano.aKey.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => ViewModel.SendNote("A"))
            });
            piano.gKey.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => ViewModel.SendNote("G"))
            });
            piano.fKey.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => ViewModel.SendNote("F"))
            });
            piano.eKey.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => ViewModel.SendNote("E"))
            });
            piano.dKey.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => ViewModel.SendNote("D"))
            });

            Content = piano;
        }
Exemplo n.º 2
0
 public static async Task InitializeDevice()
 {
     if (Device == null)
     {
         Device = await ParticleCloud.SharedInstance.GetDeviceAsync(Settings.DeviceId);
     }
 }
        public static void AskUnclaimDevice(ParticleDevice particleDevice, Page page, FrameworkElement placementTarget)
        {
            var flyout       = (Flyout)page.Resources["UnclaimDeviceFlyout"];
            var actionButton = FindNameInContainer <Button>(flyout.Content, "UnclaimDeviceButton");
            var cancelButton = FindNameInContainer <Button>(flyout.Content, "UnclaimCancelButton");

            actionButton.DataContext = particleDevice;

            RoutedEventHandler actionClickDelegate = null;
            RoutedEventHandler cancelClickDelegate = null;

            actionClickDelegate = new RoutedEventHandler(async delegate(object sender, RoutedEventArgs e) {
                actionButton.Click -= actionClickDelegate;

                var unclaimed = await particleDevice.UnclaimAsync();
                if (unclaimed)
                {
                    TinkerData.Devices.Remove(particleDevice);
                }

                flyout.Hide();
            });

            cancelClickDelegate = new RoutedEventHandler(delegate(object sender, RoutedEventArgs e) {
                flyout.Hide();
                cancelButton.Click -= cancelClickDelegate;
            });

            actionButton.Click += actionClickDelegate;
            cancelButton.Click += cancelClickDelegate;

            flyout.ShowAt(placementTarget);
        }
        public async Task <double> RequestCurrentTemperature(DeviceConfiguration deviceConfig)
        {
            ParticleDevice device = await LoginAndGetParticleDevice(deviceConfig);

            ParticleVariableResponse response = await device.GetVariableAsync(SPARKVARIABLE_AIRTEMPERATURE);

            return(double.Parse(response.Result));
        }
        public async Task <double> RequestCurrentAirHumidityPercentage(DeviceConfiguration deviceConfig)
        {
            ParticleDevice device = await LoginAndGetParticleDevice(deviceConfig);

            ParticleVariableResponse response = await device.GetVariableAsync(SPARKVARIABLE_AIRHUMIDITY);

            return(double.Parse(response.Result));
        }
        public async Task <double> RequestCurrentAirDewpoint(DeviceConfiguration deviceConfig)
        {
            ParticleDevice device = await LoginAndGetParticleDevice(deviceConfig);

            ParticleVariableResponse response = await device.GetVariableAsync(SPARKVARIABLE_AIRDEWPOINT);

            return(double.Parse(response.Result));
        }
        public async Task <double> RequestCurrentLightLevelPercentage(DeviceConfiguration deviceConfig)
        {
            ParticleDevice device = await LoginAndGetParticleDevice(deviceConfig);

            ParticleVariableResponse response = await device.GetVariableAsync(SPARKVARIABLE_LIGHTLEVEL);

            return(double.Parse(response.Result));
        }
Exemplo n.º 8
0
        public DeviceLandingPageViewModel(ParticleDevice device)
        {
            Device = device;

            if (!device.Connected)
            {
                SetLock();
                IsBusy = false;
            }
        }
Exemplo n.º 9
0
        public async Task <bool> GetDevice(string id)
        {
            IsBusy = true;

            Device = await ParticleCloud.SharedInstance.GetDeviceAsync(id);

            if (Device == null)
            {
                //device not owned
                var success = await ParticleCloud.SharedInstance.ClaimDeviceAsync(id);

                if (success)
                {
                    Device = await ParticleCloud.SharedInstance.GetDeviceAsync(id);

                    IsBusy = false;
                    return(true);
                }
                else
                {
                    IsBusy = false;
                    var device = InternetButtonHelper.GetDeviceName(id);
                    Application.Current.MainPage.DisplayAlert("Uh Oh", $"Can you get a Xamarin to help reset {device}?", "Will do");
                    return(false);
                }
            }
            else if (Device.Connected)
            {
                //Device is owned and connected
                IsBusy = false;
                return(true);
            }
            else if (!Device.Connected)
            {
                //Device is owned but disconnected
                IsBusy = false;
                return(true);
            }

            return(false);
            //var success = await ParticleCloud.SharedInstance.ClaimDeviceAsync(id);
            //if (success)
            //{
            //	Device = await ParticleCloud.SharedInstance.GetDeviceAsync(id);
            //	IsBusy = false;
            //	return true;
            //}
            //else
            //{
            //	IsBusy = false;
            //	var device = InternetButtonHelper.GetDeviceName(id);
            //	Application.Current.MainPage.DisplayAlert("Uh Oh", $"Someone already has this device claimed, can you please ask a Xamarin to reset {device}", "Will do");
            //	return false;
            //}
        }
        /// <summary>
        /// Starts the watering process
        /// </summary>
        /// <param name="wateringLocation"></param>
        /// <returns>Convention: -1 Failure</returns>
        public async void StartWatering(DeviceConfiguration deviceConfig, WateringLocation wateringLocation)
        {
            ParticleDevice device = await LoginAndGetParticleDevice(deviceConfig);

            ParticleFunctionResponse functionResponse = await device.RunFunctionAsync(SPARKFUNCTION_ACTION_STARTWATERING, Enum.GetName(typeof(WateringLocation), wateringLocation));


            if (functionResponse.ReturnValue < 0)
            {
                throw new Exception("Error occurred while starting the watering process");
            }
        }
Exemplo n.º 11
0
        async void Task1()
        {
            List <ParticleDevice> devices = await ParticleCloud.SharedInstance.GetDevicesAsync();

            foreach (ParticleDevice device in devices)
            {
                if (device.Name.Equals("Master2"))
                {
                    myDevice = device;
                }
            }
        }
        public async Task <double> RequestCurrentSoilMoisturePercentage(DeviceConfiguration deviceConfig, WateringLocation wateringLocation)
        {
            string variableName = wateringLocation == WateringLocation.First
                ? SPARKVARIABLE_ZONEONE_SOILHUMIDITY
                : SPARKVARIABLE_ZONETWO_SOILHUMIDITY;

            ParticleDevice device = await LoginAndGetParticleDevice(deviceConfig);

            ParticleVariableResponse response = await device.GetVariableAsync(variableName);

            return(double.Parse(response.Result));
        }
Exemplo n.º 13
0
        public ChangeLEDColorViewModel(ParticleDevice device, Dictionary <string, string> variables)
        {
            ColorBoxColor = Color.FromRgb(0, 0, 0);

            Makeup.R = ToInt32(variables["red"]);
            Makeup.G = ToInt32(variables["grn"]);
            Makeup.B = ToInt32(variables["blu"]);

            ColorBoxColor = Color.FromHsla(Makeup.R, Makeup.G, Makeup.B);

            Device = device;
        }
Exemplo n.º 14
0
        public async void ViewDeviceDetails(object sender, SelectedItemChangedEventArgs e)
        {
            ParticleDevice device = e.SelectedItem as ParticleDevice;

            if (device == null)
            {
                return;
            }

            await Navigation.PushAsync(new DeviceDetailPage ((ParticleDevice)e.SelectedItem));

            deviceListView.SelectedItem = null;
        }
        public static void AskRenameDevice(ParticleDevice particleDevice, Page page, FrameworkElement placementTarget)
        {
            var flyout            = (Flyout)page.Resources["RenameDeviceFlyout"];
            var newDeviceNameGrid = FindNameInContainer <Grid>(flyout.Content, "NewDeviceNameGrid");
            var textbox           = FindNameInContainer <TextBox>(flyout.Content, "NewDeviceName");
            var refreshButton     = FindNameInContainer <Button>(flyout.Content, "RefreshButton");
            var actionButton      = FindNameInContainer <Button>(flyout.Content, "RenameDeviceButton");
            var cancelButton      = FindNameInContainer <Button>(flyout.Content, "RenameCancelButton");

            textbox.Text = DeviceNameGenerator.GenerateUniqueName(TinkerData.GetDeviceNames());
            textbox.SelectAll();

            actionButton.DataContext = particleDevice;

            RoutedEventHandler refreshButtonDelegate = null;
            RoutedEventHandler actionClickDelegate   = null;
            RoutedEventHandler cancelClickDelegate   = null;

            refreshButtonDelegate = new RoutedEventHandler(delegate(object sender, RoutedEventArgs e)
            {
                textbox.Text = DeviceNameGenerator.GenerateUniqueName(TinkerData.GetDeviceNames());
                textbox.SelectAll();
            });

            actionClickDelegate = new RoutedEventHandler(async delegate(object sender, RoutedEventArgs e)
            {
                var newName = textbox.Text;

                flyout.Hide();
                refreshButton.Click -= refreshButtonDelegate;
                actionButton.Click  -= actionClickDelegate;
                cancelButton.Click  -= cancelClickDelegate;

                await particleDevice.RenameAsync(newName);
            });

            cancelClickDelegate = new RoutedEventHandler(delegate(object sender, RoutedEventArgs e)
            {
                flyout.Hide();
                refreshButton.Click -= refreshButtonDelegate;
                actionButton.Click  -= actionClickDelegate;
                cancelButton.Click  -= cancelClickDelegate;
            });

            refreshButton.Click += refreshButtonDelegate;
            actionButton.Click  += actionClickDelegate;
            cancelButton.Click  += cancelClickDelegate;

            flyout.ShowAt(placementTarget);
        }
Exemplo n.º 16
0
        public static bool CanFlashTinker(ParticleDevice particleDevice)
        {
            switch (particleDevice.KnownProductId)
            {
            case ParticleDeviceType.ParticleCore:
            case ParticleDeviceType.ParticlePhoton:
            case ParticleDeviceType.ParticleP1:
            case ParticleDeviceType.ParticleElectron:
                return(true);

            default:
                return(false);
            }
        }
        public async Task <SparkDeviceOperationState> RequestCurrentState(DeviceConfiguration deviceConfig)
        {
            ParticleDevice device = await LoginAndGetParticleDevice(deviceConfig);

            ParticleVariableResponse currentStateResult = await device.GetVariableAsync(SPARKVARIABLE_CURRENTSTATE);

            try
            {
                SparkDeviceOperationState operationState = (SparkDeviceOperationState)int.Parse(currentStateResult.Result);
                return(operationState);
            }
            catch (Exception e)
            {
                throw new InvalidOperationException("Enum value not supported for SparkDeviceOperationState");
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Execute start up tasks
        /// </summary>
        /// <param name="sender">object sending the event</param>
        /// <param name="e">event arguments</param>
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            Debug.WriteLine("Loaded event is fired");
            eventPipeLine            = new EventPipeline();
            eventPipeLine.OnEnqueue += EventPipeLine_EventWaiting;
            eventPipeLine.OnDequeue += EventPipeLine_EventPublished;
            if (this.bodyFrameReader != null)
            {
                this.bodyFrameReader.FrameArrived += this.Reader_FrameArrived;
            }
            var loginSuccess = Task.Run(loginAsync).Result;

            if (loginSuccess)
            {
                myDevice = Task.Run(getDeviceAsync).Result;
            }
        }
        private void SetupPage()
        {
            particleDevice = startupVariableData.ParticleDevice;

            DataGrid.DataContext = particleDevice;

            for (var index = 0; index < VariablesComboBox.Items.Count; ++index)
            {
                var selectedItem = (KeyValuePair <string, string>)startupVariableData.SelectedItem;

                var item = (KeyValuePair <string, string>)VariablesComboBox.Items[index];
                if (item.Key == selectedItem.Key)
                {
                    VariablesComboBox.SelectedIndex = index;
                    break;
                }
            }
        }
Exemplo n.º 20
0
        private void SetupPage()
        {
            particleDevice = startupVariableData.ParticleDevice;

            DataGrid.DataContext = particleDevice;

            for (var index = 0; index < VariablesComboBox.Items.Count; ++index)
            {
                var selectedItem = (KeyValuePair<string, string>)startupVariableData.SelectedItem;

                var item = (KeyValuePair<string, string>)VariablesComboBox.Items[index];
                if (item.Key == selectedItem.Key)
                {
                    VariablesComboBox.SelectedIndex = index;
                    break;
                }
            }
        }
Exemplo n.º 21
0
        private void SetupPage()
        {
            particleDevice = startupVariableData.ParticleDevice;

            DataGrid.DataContext = particleDevice;

            var selectedItem = (string)startupVariableData.SelectedItem;

            for (var index = 0; index < FunctionComboBox.Items.Count; ++index)
            {
                var item = (string)FunctionComboBox.Items[index];
                if (item == selectedItem)
                {
                    FunctionComboBox.SelectedIndex = index;
                    break;
                }
            }
        }
Exemplo n.º 22
0
        public async Task <ActionResult> Index(string txtId)
        {
            var success = await ParticleCloud.SharedCloud.LoginAsync("*****@*****.**", "eystbots");

            List <ParticleDevice> devices = await ParticleCloud.SharedCloud.GetDevicesAsync();

            foreach (ParticleDevice device in devices)
            {
                //MessageBox.Show(device.Name.ToString());
                myDevice = device;
            }
            ViewBag.PhotonMessage = "You device is" + " " + myDevice.Name.ToString();
            var functionResponse = await myDevice.RunFunctionAsync("relayOff", "1");

            var result = functionResponse.ReturnValue;

            return(View());
        }
Exemplo n.º 23
0
        private void SetupPage()
        {
            particleDevice = startupVariableData.ParticleDevice;

            DataGrid.DataContext = particleDevice;

            var selectedItem = (string)startupVariableData.SelectedItem;

            for (var index = 0; index < FunctionComboBox.Items.Count; ++index)
            {
                var item = (string)FunctionComboBox.Items[index];
                if (item == selectedItem)
                {
                    FunctionComboBox.SelectedIndex = index;
                    break;
                }
            }
        }
Exemplo n.º 24
0
        private async Task LoginToCloudAndGetDevice()
        {
            ParticleCloud.SharedCloud.SynchronizationContext = System.Threading.SynchronizationContext.Current;
            var success = await ParticleCloud.SharedCloud.TokenLoginAsync(TrayResources.ParticleToken);

            if (success)
            {
                List <ParticleDevice> devices = await ParticleCloud.SharedCloud.GetDevicesAsync();

                myDevice = devices[0];

                deviceSuccessfullyInitiated = myDevice.State == ParticleDeviceState.Online;
            }

            if (!deviceSuccessfullyInitiated)
            {
                MessageBox.Show("Device seems offline, please check your internet connectivity and try again.", "Please try again", MessageBoxButtons.OK);
            }
        }
Exemplo n.º 25
0
 public ParticleDeviceWrapper(ParticleDevice device)
 {
     Device = device;
     device.PropertyChanged += Device_PropertyChanged;
     ViewModelLocator.Messenger.Register <YourWebEventMessage>(this, (a) =>
     {
         var args = a.EventArgs;
         if (args != null)
         {
             if (args.Data != null && args.Data.Length > 0)
             {
                 var d1 = args.Data[0];
                 if (String.Compare(d1.CoreId, Device?.Id) == 0)
                 {
                     deviceEvent(args.Event, d1);
                 }
             }
         }
     });
 }
		public ParticleDeviceWrapper(ParticleDevice device)
		{
			Device = device;
			device.PropertyChanged += Device_PropertyChanged;
			ViewModelLocator.Messenger.Register<YourWebEventMessage>(this, (a) =>
			{
				var args = a.EventArgs;
				if(args != null)
				{
					if(args.Data != null && args.Data.Length > 0)
					{
						var d1 = args.Data[0];
						if(String.Compare(d1.CoreId, Device?.Id) == 0)
						{
							deviceEvent(args.Event, d1);
						}
					}
				}
			});
		}
        public async void SaveDeviceConfiguration(DeviceConfiguration deviceConfig)
        {
            if (deviceConfig != null)
            {
                string setupString = CreateDeviceConfigurationString(deviceConfig);

                ParticleDevice device = await LoginAndGetParticleDevice(deviceConfig);

                //send each config param separately to minimize problems with the size restriction (63 char)
                foreach (string configParameter in setupString.Split(';'))
                {
                    if (!string.IsNullOrWhiteSpace(configParameter))
                    {
                        ParticleFunctionResponse functionResponse = await device.RunFunctionAsync(SPARKFUNCTION_ACTION_SAVECONFIG, configParameter);

                        if (functionResponse.ReturnValue < 0)
                        {
                            throw new Exception("Error occurred while saving the confguration params");
                        }
                    }
                }
            }
        }
Exemplo n.º 28
0
        public DeviceLandingPage(ParticleDevice device)
        {
            Title           = "Mission Control";
            BackgroundColor = AppColors.BackgroundColor;
            ViewModel       = new DeviceLandingPageViewModel(device);
            BindingContext  = ViewModel;

            var refreshDevice = new ToolbarItem {
                Icon = "ic_cached_white_24dp.png"
            };
            var back = new ToolbarItem {
                Icon = "ic_clear_white.png"
            };
            var layout = new RelativeLayout();

            var indicator  = new ActivityIndicator();
            var deviceName = new StyledLabel {
                CssStyle = "h1"
            };
            var deviceConnected = new Image {
                Source = "notconnected.png"
            };
            var currentAppLabel = new StyledLabel {
                CssStyle = "h2"
            };
            var variableWidget = new DashboardWidget();
            var functionWidget = new DashboardWidget();
            var appDescription = new StyledLabel {
                CssStyle = "body"
            };
            var interactButton = new StyledButton
            {
                StyleId         = "startInteractionButton",
                Text            = "START INTERACTION",
                BackgroundColor = AppColors.Green,
                CssStyle        = "button",
                BorderRadius    = 0,
                HeightRequest   = AppSettings.ButtonHeight,
                IsEnabled       = false
            };
            var flashButton = new StyledButton
            {
                StyleId         = "flashBinaryButton",
                Text            = "FLASH NEW APP",
                BackgroundColor = AppColors.Purple,
                CssStyle        = "button",
                BorderRadius    = 0,
                HeightRequest   = AppSettings.ButtonHeight,
                IsEnabled       = false
            };

            var boxConstraint = Constraint.RelativeToParent(p => p.Width / 2 - AppSettings.Margin - AppSettings.ItemPadding / 2);

            layout.Children.Add(deviceName,
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.Constant(Device.OnPlatform(AppSettings.Margin, 10, 10)),
                                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2)
                                );
            layout.Children.Add(currentAppLabel,
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.RelativeToView(deviceName, (p, v) => v.Y + v.Height + 5),
                                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                                heightConstraint: Constraint.RelativeToView(deviceName, (p, v) => v.Height)
                                );
            layout.Children.Add(variableWidget,
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.RelativeToView(currentAppLabel, (p, v) => Device.OnPlatform(
                                                                           v.Y + v.Height + 5,
                                                                           v.Y + v.Height,
                                                                           v.Y + v.Height)
                                                                       ),
                                widthConstraint: boxConstraint,
                                heightConstraint: boxConstraint
                                );
            layout.Children.Add(functionWidget,
                                xConstraint: Constraint.RelativeToParent(p => p.Width / 2 + AppSettings.ItemPadding / 2),
                                yConstraint: Constraint.RelativeToView(variableWidget, (p, v) => v.Y),
                                widthConstraint: boxConstraint,
                                heightConstraint: boxConstraint
                                );
            layout.Children.Add(new ScrollView {
                Content = appDescription
            },
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.RelativeToView(functionWidget, (p, v) => v.Y + v.Height + 10),
                                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                                heightConstraint: Constraint.RelativeToView(functionWidget, (p, v) => p.Height - v.Y - v.Height - 10 - AppSettings.Margin - 2 * AppSettings.ButtonHeight - 20)
                                );
            layout.Children.Add(flashButton,
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.RelativeToParent(p => p.Height - AppSettings.Margin - AppSettings.ButtonHeight),
                                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                                heightConstraint: Constraint.Constant(AppSettings.ButtonHeight)
                                );
            layout.Children.Add(interactButton,
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.RelativeToView(flashButton, (p, v) => v.Y - AppSettings.ButtonHeight - 10),
                                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                                heightConstraint: Constraint.Constant(AppSettings.ButtonHeight)
                                );
            layout.Children.Add(indicator,
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.RelativeToView(functionWidget, (p, v) => v.Y + v.Height + 10),
                                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                                heightConstraint: Constraint.RelativeToView(functionWidget, (p, v) => p.Height - v.Y - v.Height - 10 - AppSettings.Margin - 2 * AppSettings.ButtonHeight - 20)
                                );

            variableWidget.WidgetTitle.Text = "Variables";
            functionWidget.WidgetTitle.Text = "Functions";

            if (Device.OS == TargetPlatform.iOS)
            {
                interactButton.TextColor = Color.FromHex("#ffffff");
                flashButton.TextColor    = Color.FromHex("#ffffff");
            }

            Content = layout;
            ToolbarItems.Add(refreshDevice);
            ToolbarItems.Add(back);

            indicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");
            if (Device.OS != TargetPlatform.iOS && Device.OS != TargetPlatform.Android)
            {
                indicator.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy");
            }

            deviceName.SetBinding(Label.TextProperty, "Device.Name");
            currentAppLabel.SetBinding(Label.TextProperty, "CurrentApp");
            deviceConnected.SetBinding(Image.IsVisibleProperty, "DeviceConnected");
            variableWidget.WidgetCount.SetBinding(Label.TextProperty, "VariableCount");
            functionWidget.WidgetCount.SetBinding(Label.TextProperty, "FunctionCount");
            interactButton.SetBinding(Button.IsEnabledProperty, "InteractButtonLock");
            flashButton.SetBinding(Button.IsEnabledProperty, "FlashButtonLock");
            refreshDevice.SetBinding(ToolbarItem.CommandProperty, "RefreshDeviceCommand");
            appDescription.SetBinding(Label.TextProperty, "AppDescription");

            interactButton.Clicked += async(object sender, EventArgs e) =>
            {
                if (ViewModel.CurrentApp.ToLower().Contains("rgb led picker"))
                {
                    await Navigation.PushAsync(new ChangeLEDColorPage(ViewModel.Device, ViewModel.variables));
                }
                else if (ViewModel.CurrentApp.ToLower().Contains("simonsays"))
                {
                    await Navigation.PushAsync(new SimonSaysPage(ViewModel.Device));
                }
                else
                {
                    DisplayAlert("Sorry...", "There isn't a mobile interaction with this IoT app. Try flashing either the 'Simon Says' or ' RBG LED' app.", "Ok");
                }
            };

            flashButton.Clicked += async(object sender, EventArgs e) =>
            {
                var result = await DisplayActionSheet("Pick File to Flash", "Cancel", null, "RGB LED", "Shake LED", "Simon Says", "Follow me LED");

                if (result != "Cancel")
                {
                    var success = await ViewModel.TryFlashFileAsync(result);

                    if (!success)
                    {
                        await DisplayAlert("Error", "The Device connection timed out. Please try again once the device breaths a solid cyan light", "Ok");
                    }
                }
            };

            back.Clicked += async(object sender, EventArgs e) =>
            {
                var success = await ViewModel.Device.UnclaimAsync();

                //if (success)
                Navigation.PopModalAsync(true);
            };
        }
Exemplo n.º 29
0
        public static List <Pin> GetDevicePins(ParticleDevice particleDevice)
        {
            List <Pin> allPins = new List <Pin>();

            switch (particleDevice.KnownPlatformId)
            {
            case ParticleDeviceType.ParticleCore:
                allPins.Add(new Pin("TinkerA7", PinType.A, "A7", AllFunctions));
                allPins.Add(new Pin("TinkerA6", PinType.A, "A6", AllFunctions));
                allPins.Add(new Pin("TinkerA5", PinType.A, "A5", AllFunctions));
                allPins.Add(new Pin("TinkerA4", PinType.A, "A4", NoAnalogWrite));
                allPins.Add(new Pin("TinkerA3", PinType.A, "A3", NoAnalogWrite));
                allPins.Add(new Pin("TinkerA2", PinType.A, "A2", AllFunctions));
                allPins.Add(new Pin("TinkerA1", PinType.A, "A1", AllFunctions));
                allPins.Add(new Pin("TinkerA0", PinType.A, "A0", AllFunctions));

                allPins.Add(new Pin("TinkerD7", PinType.D, "D7", DigitalOnly));
                allPins.Add(new Pin("TinkerD6", PinType.D, "D6", DigitalOnly));
                allPins.Add(new Pin("TinkerD5", PinType.D, "D5", DigitalOnly));
                allPins.Add(new Pin("TinkerD4", PinType.D, "D4", DigitalOnly));
                allPins.Add(new Pin("TinkerD3", PinType.D, "D3", DigitalOnly));
                allPins.Add(new Pin("TinkerD2", PinType.D, "D2", DigitalOnly));
                allPins.Add(new Pin("TinkerD1", PinType.D, "D1", NoAnalogRead));
                allPins.Add(new Pin("TinkerD0", PinType.D, "D0", NoAnalogRead));

                break;

            case ParticleDeviceType.ParticlePhoton:
            case ParticleDeviceType.ParticleP1:
            case ParticleDeviceType.RedBearDuo:     // TODO: RedBearDuo is assumed
                allPins.Add(new Pin("TinkerA7", PinType.A, "A7", AllFunctions, "WKP", AnalogWriteMax));
                allPins.Add(new Pin("TinkerA6", PinType.A, "A6", AllFunctionsDAC, "DAC", AnalogWriteMaxAlt));
                allPins.Add(new Pin("TinkerA5", PinType.A, "A5", AllFunctions));
                allPins.Add(new Pin("TinkerA4", PinType.A, "A4", AllFunctions));
                allPins.Add(new Pin("TinkerA3", PinType.A, "A3", AllFunctionsDAC, "A3", AnalogWriteMaxAlt));
                allPins.Add(new Pin("TinkerA2", PinType.A, "A2", NoAnalogWrite));
                allPins.Add(new Pin("TinkerA1", PinType.A, "A1", NoAnalogWrite));
                allPins.Add(new Pin("TinkerA0", PinType.A, "A0", NoAnalogWrite));

                allPins.Add(new Pin("TinkerD7", PinType.D, "D7", DigitalOnly));
                allPins.Add(new Pin("TinkerD6", PinType.D, "D6", DigitalOnly));
                allPins.Add(new Pin("TinkerD5", PinType.D, "D5", DigitalOnly));
                allPins.Add(new Pin("TinkerD4", PinType.D, "D4", DigitalOnly));
                allPins.Add(new Pin("TinkerD3", PinType.D, "D3", NoAnalogRead));
                allPins.Add(new Pin("TinkerD2", PinType.D, "D2", NoAnalogRead));
                allPins.Add(new Pin("TinkerD1", PinType.D, "D1", NoAnalogRead));
                allPins.Add(new Pin("TinkerD0", PinType.D, "D0", NoAnalogRead));

                break;

            case ParticleDeviceType.ParticleElectron:
                allPins.Add(new Pin("TinkerA7", PinType.A, "A7", AllFunctions, "WKP", AnalogWriteMax));
                allPins.Add(new Pin("TinkerA6", PinType.A, "A6", AllFunctionsDAC, "DAC", AnalogWriteMaxAlt));
                allPins.Add(new Pin("TinkerA5", PinType.A, "A5", AllFunctions));
                allPins.Add(new Pin("TinkerA4", PinType.A, "A4", AllFunctions));
                allPins.Add(new Pin("TinkerA3", PinType.A, "A3", AllFunctionsDAC, "A3", AnalogWriteMaxAlt));
                allPins.Add(new Pin("TinkerA2", PinType.A, "A2", NoAnalogWrite));
                allPins.Add(new Pin("TinkerA1", PinType.A, "A1", NoAnalogWrite));
                allPins.Add(new Pin("TinkerA0", PinType.A, "A0", NoAnalogWrite));

                allPins.Add(new Pin("TinkerB5", PinType.B, "B5", NoAnalogWrite));
                allPins.Add(new Pin("TinkerB4", PinType.B, "B4", AllFunctions));
                allPins.Add(new Pin("TinkerB3", PinType.B, "B3", AllFunctions));
                allPins.Add(new Pin("TinkerB2", PinType.B, "B2", AllFunctions));
                allPins.Add(new Pin("TinkerB1", PinType.B, "B1", NoAnalogRead));
                allPins.Add(new Pin("TinkerB0", PinType.B, "B0", DigitalOnly));

                allPins.Add(new Pin("TinkerD7", PinType.D, "D7", DigitalOnly));
                allPins.Add(new Pin("TinkerD6", PinType.D, "D6", DigitalOnly));
                allPins.Add(new Pin("TinkerD5", PinType.D, "D5", DigitalOnly));
                allPins.Add(new Pin("TinkerD4", PinType.D, "D4", DigitalOnly));
                allPins.Add(new Pin("TinkerD3", PinType.D, "D3", NoAnalogRead));
                allPins.Add(new Pin("TinkerD2", PinType.D, "D2", NoAnalogRead));
                allPins.Add(new Pin("TinkerD1", PinType.D, "D1", NoAnalogRead));
                allPins.Add(new Pin("TinkerD0", PinType.D, "D0", NoAnalogRead));

                allPins.Add(new Pin("TinkerC5", PinType.C, "C5", NoAnalogRead));
                allPins.Add(new Pin("TinkerC4", PinType.C, "C4", NoAnalogRead));
                allPins.Add(new Pin("TinkerC3", PinType.C, "C3", DigitalOnly));
                allPins.Add(new Pin("TinkerC2", PinType.C, "C2", DigitalOnly));
                allPins.Add(new Pin("TinkerC1", PinType.C, "C1", DigitalOnly));
                allPins.Add(new Pin("TinkerC0", PinType.C, "C0", DigitalOnly));

                break;

            case ParticleDeviceType.DigistumpOak:     // TODO: DigistumpOak is assumed
                allPins.Add(new Pin("TinkerA7", PinType.A, "A0", AnalogReadOnly));
                allPins.Add(new Pin("TinkerA6", PinType.A, "10", NoAnalogRead));
                allPins.Add(new Pin("TinkerA5", PinType.A, "9", NoAnalogRead));
                allPins.Add(new Pin("TinkerA4", PinType.A, "8", NoAnalogRead));
                allPins.Add(new Pin("TinkerA3", PinType.A, "7", NoAnalogRead));
                allPins.Add(new Pin("TinkerA2", PinType.A, "6", NoAnalogRead));

                allPins.Add(new Pin("TinkerD7", PinType.D, "5", NoAnalogRead));
                allPins.Add(new Pin("TinkerD6", PinType.D, "4", NoAnalogRead));
                allPins.Add(new Pin("TinkerD5", PinType.D, "3", NoAnalogRead));
                allPins.Add(new Pin("TinkerD4", PinType.D, "2", NoAnalogRead));
                allPins.Add(new Pin("TinkerD3", PinType.D, "1", NoAnalogRead));
                allPins.Add(new Pin("TinkerD2", PinType.D, "0", NoAnalogRead));

                break;

            case ParticleDeviceType.BluzDK:
                allPins.Add(new Pin("TinkerA7", PinType.A, "A7", NoAnalogRead));
                allPins.Add(new Pin("TinkerA6", PinType.A, "A6", NoAnalogRead));
                allPins.Add(new Pin("TinkerA5", PinType.A, "A5", AllFunctions));
                allPins.Add(new Pin("TinkerA4", PinType.A, "A4", AllFunctions));
                allPins.Add(new Pin("TinkerA3", PinType.A, "A3", AllFunctions));
                allPins.Add(new Pin("TinkerA2", PinType.A, "A2", NoAnalogWrite));
                allPins.Add(new Pin("TinkerA1", PinType.A, "A1", NoAnalogWrite));
                allPins.Add(new Pin("TinkerA0", PinType.A, "A0", NoAnalogWrite));

                allPins.Add(new Pin("TinkerD7", PinType.D, "D7", NoAnalogRead));
                allPins.Add(new Pin("TinkerD6", PinType.D, "D6", NoAnalogRead));
                allPins.Add(new Pin("TinkerD5", PinType.D, "D5", NoAnalogRead));
                allPins.Add(new Pin("TinkerD4", PinType.D, "D4", NoAnalogRead));
                allPins.Add(new Pin("TinkerD3", PinType.D, "D3", NoAnalogRead));
                allPins.Add(new Pin("TinkerD2", PinType.D, "D2", NoAnalogRead));
                allPins.Add(new Pin("TinkerD1", PinType.D, "D1", NoAnalogRead));
                allPins.Add(new Pin("TinkerD0", PinType.D, "D0", NoAnalogRead));

                break;
            }

            foreach (var pin in allPins)
            {
                pin.ParticleDevice = particleDevice;
            }

            return(allPins);
        }
Exemplo n.º 30
0
        public SimonSaysPage(ParticleDevice device)
        {
            ViewModel       = new SimonSaysViewModel(device);
            BindingContext  = ViewModel;
            BackgroundColor = AppColors.BackgroundColor;
            Title           = $"{device.Name} Says";

            red = new Button {
                StyleId = "red", BackgroundColor = SimonSaysColors.Red, BorderRadius = 0
            };
            blue = new Button {
                StyleId = "blue", BackgroundColor = SimonSaysColors.Blue, BorderRadius = 0
            };
            green = new Button {
                StyleId = "green", BackgroundColor = SimonSaysColors.Green, BorderRadius = 0
            };
            yellow = new Button {
                StyleId = "yellow", BackgroundColor = SimonSaysColors.Yellow, BorderRadius = 0
            };

            l1 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            l2 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            l3 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            l4 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            l5 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            l6 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            l7 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            l8 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            l9 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            l10 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            var         stackPadding = 2d;
            StackLayout lightStack   = new StackLayout
            {
                Orientation     = StackOrientation.Horizontal,
                Children        = { l1, l2, l3, l4, l5, l6, l7, l8, l9, l10 },
                Padding         = new Thickness(stackPadding, 0, stackPadding, 0),
                BackgroundColor = Color.Transparent
            };

            var clearSubmission = new Button
            {
                StyleId         = "clearMoveButton",
                Text            = "X",
                FontSize        = Device.OnPlatform(10, 8, 10),
                TextColor       = Color.Black,
                FontAttributes  = FontAttributes.Bold,
                BorderRadius    = 10,
                BackgroundColor = Color.White,
                BorderColor     = Color.Black,
                BorderWidth     = 1
            };
            StyledButton actionButton = new StyledButton {
                StyleId = "actionButton", BorderRadius = 0, TextColor = Color.White, CssStyle = "button", BorderColor = AppColors.Blue
            };

            var layout = new RelativeLayout();

            var buttonConstraint = Constraint.RelativeToParent((p) => (p.Width / 2) - AppSettings.Margin - AppSettings.ItemPadding / 2);

            layout.Children.Add(red,
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.Constant(AppSettings.Margin),
                                widthConstraint: buttonConstraint,
                                heightConstraint: buttonConstraint
                                );

            layout.Children.Add(yellow,
                                xConstraint: Constraint.RelativeToParent((p) => (p.Width / 2) + AppSettings.ItemPadding / 2),
                                yConstraint: Constraint.Constant(AppSettings.Margin),
                                widthConstraint: buttonConstraint,
                                heightConstraint: buttonConstraint
                                );

            layout.Children.Add(blue,
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.RelativeToView(red, (p, v) => v.Height + v.Y + AppSettings.ItemPadding),
                                widthConstraint: buttonConstraint,
                                heightConstraint: buttonConstraint
                                );

            layout.Children.Add(green,
                                xConstraint: Constraint.RelativeToParent((p) => (p.Width / 2) + AppSettings.ItemPadding / 2),
                                yConstraint: Constraint.RelativeToView(yellow, (p, v) => v.Height + v.Y + AppSettings.ItemPadding),
                                widthConstraint: buttonConstraint,
                                heightConstraint: buttonConstraint
                                );

            layout.Children.Add(lightStack,
                                xConstraint: Constraint.Constant(AppSettings.Margin - stackPadding),
                                yConstraint: Constraint.RelativeToView(blue, (p, v) => v.Height + v.Y + AppSettings.ItemPadding * 2),
                                widthConstraint: Constraint.RelativeToParent((p) => p.Width - AppSettings.Margin * 2 + stackPadding * 2),
                                heightConstraint: Constraint.Constant(25) // TODO calculate the square size based on the width of the view
                                );
            layout.Children.Add(clearSubmission,
                                xConstraint: Constraint.RelativeToParent((p) => p.Width - AppSettings.Margin - Device.OnPlatform(10, 15, 15)),
                                yConstraint: Constraint.RelativeToView(lightStack, (p, v) => Device.OnPlatform(
                                                                           v.Y - 10,
                                                                           v.Y - 15,
                                                                           v.Y - 15
                                                                           )
                                                                       ),
                                widthConstraint: Constraint.Constant(Device.OnPlatform(25, 30, 30)),
                                heightConstraint: Constraint.Constant(Device.OnPlatform(25, 30, 30))
                                );

            layout.Children.Add(actionButton,
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.RelativeToParent(p => p.Height - AppSettings.Margin - AppSettings.ButtonHeight),
                                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                                heightConstraint: Constraint.Constant(50)
                                );

            Content = layout;

            red.Clicked += async(object sender, EventArgs e) =>
            {
                await ViewModel.PlayerPressButtonAsync("r");
            };
            blue.Clicked += async(object sender, EventArgs e) =>
            {
                await ViewModel.PlayerPressButtonAsync("b");
            };
            green.Clicked += async(object sender, EventArgs e) =>
            {
                await ViewModel.PlayerPressButtonAsync("g");
            };
            yellow.Clicked += async(object sender, EventArgs e) =>
            {
                await ViewModel.PlayerPressButtonAsync("y");
            };
            clearSubmission.Clicked += (object sender, EventArgs e) =>
            {
                ViewModel.ClearPlayerEntry();
            };

            red.SetBinding(Button.OpacityProperty, "RedOpacity");
            green.SetBinding(Button.OpacityProperty, "GreenOpacity");
            blue.SetBinding(Button.OpacityProperty, "BlueOpacity");
            yellow.SetBinding(Button.OpacityProperty, "YellowOpacity");

            l1.SetBinding(ContentView.BackgroundColorProperty, "L1");
            l2.SetBinding(ContentView.BackgroundColorProperty, "L2");
            l3.SetBinding(ContentView.BackgroundColorProperty, "L3");
            l4.SetBinding(ContentView.BackgroundColorProperty, "L4");
            l5.SetBinding(ContentView.BackgroundColorProperty, "L5");
            l6.SetBinding(ContentView.BackgroundColorProperty, "L6");
            l7.SetBinding(ContentView.BackgroundColorProperty, "L7");
            l8.SetBinding(ContentView.BackgroundColorProperty, "L8");
            l9.SetBinding(ContentView.BackgroundColorProperty, "L9");
            l10.SetBinding(ContentView.BackgroundColorProperty, "L10");

            clearSubmission.SetBinding(Button.IsVisibleProperty, "ShowClearButton");
            actionButton.SetBinding(Button.BackgroundColorProperty, "ActionColor");
            actionButton.SetBinding(Button.TextProperty, "ActionText");
            actionButton.SetBinding(Button.CommandProperty, "ActionCommand");
        }
Exemplo n.º 31
0
 public SimonSaysViewModel(ParticleDevice device)
 {
     InternetButton = device;
 }
Exemplo n.º 32
0
        public ChangeLEDColorPage(ParticleDevice device, Dictionary <string, string> variables)
        {
            var labelStyle = new Style(typeof(Label))
            {
                Setters =
                {
                    new Setter {
                        Property = Label.TextColorProperty, Value = Color.White
                    },
                    new Setter {
                        Property = Label.FontFamilyProperty, Value = Device.OnPlatform("AppleSDGothicNeo-Light", "Droid Sans Mono", "Comic Sans MS")
                    },
                }
            };

            var buttonStyle = new Style(typeof(Button))
            {
                Setters =
                {
                    new Setter {
                        Property = Button.TextColorProperty, Value = Color.White
                    },
                    new Setter {
                        Property = Button.FontFamilyProperty, Value = Device.OnPlatform("AppleSDGothicNeo-Light", "Droid Sans Mono", "Comic Sans MS")
                    },
                }
            };

            Resources = new ResourceDictionary();
            Resources.Add(labelStyle);
            Resources.Add(buttonStyle);

            ViewModel      = new ChangeLEDColorViewModel(variables);
            BindingContext = ViewModel;

            redSlider = new Slider {
                Minimum = 0,
                Maximum = 255,
                Value   = 0,
            };
            greenSlider = new Slider {
                Minimum = 0,
                Maximum = 255,
                Value   = 0,
            };
            blueSlider = new Slider {
                Minimum = 0,
                Maximum = 255,
                Value   = 0,
            };
            push = new Button {
                Text = "Push To Photon"
            };
            lightShow = new Button {
                Text = "Start a light show!"
            };

            off = new ToolbarItem {
                Text = "Off"
            };
            refresh = new ToolbarItem {
                Text = "Refresh"
            };

            StackLayout layout = new StackLayout
            {
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Padding         = new Thickness(20, 0, 20, 0)
            };

            layout.Children.Add(new Label {
                Text = "R Value", HorizontalOptions = LayoutOptions.Start
            });
            layout.Children.Add(redSlider);
            layout.Children.Add(new Label {
                Text = "G Value", HorizontalOptions = LayoutOptions.Start
            });
            layout.Children.Add(greenSlider);
            layout.Children.Add(new Label {
                Text = "B Value", HorizontalOptions = LayoutOptions.Start
            });
            layout.Children.Add(blueSlider);
            layout.Children.Add(push);
            layout.Children.Add(lightShow);

            Content = layout;
            Padding = new Thickness(10, 0, 10, 0);

            push.Clicked      += PushColorToPhoton;
            lightShow.Clicked += StartLightShow;
            off.Clicked       += TurnOffLeds;
            refresh.Clicked   += RefreshFile;

            redSlider.SetBinding(Slider.ValueProperty, "R", BindingMode.TwoWay);
            greenSlider.SetBinding(Slider.ValueProperty, "G", BindingMode.TwoWay);
            blueSlider.SetBinding(Slider.ValueProperty, "B", BindingMode.TwoWay);
            this.SetBinding(ContentPage.BackgroundColorProperty, "ColorBoxColor");

            ToolbarItems.Add(off);
            ToolbarItems.Add(refresh);

            particleDevice = device;
        }
Exemplo n.º 33
0
 public DeviceManager(DeviceFactory deviceFactory, EventHistory eventHistory)
 {
     _device       = deviceFactory.GetDeviceAsync().Result;
     _eventHistory = eventHistory;
     ParticleCloud.SharedCloud.SubscribeToDeviceEventsWithPrefixAsync(OnParticleEvent, _device.Id).Wait();
 }
Exemplo n.º 34
0
        public static List<Pin> GetDevicePins(ParticleDevice particleDevice)
        {
            List<Pin> allPins = new List<Pin>();

            switch (particleDevice.ProductId)
            {
                case ParticleDeviceType.Core:
                    allPins.Add(new Pin("TinkerA7", PinType.A, "A7", AllFunctions));
                    allPins.Add(new Pin("TinkerA6", PinType.A, "A6", AllFunctions));
                    allPins.Add(new Pin("TinkerA5", PinType.A, "A5", AllFunctions));
                    allPins.Add(new Pin("TinkerA4", PinType.A, "A4", NoAnalogWrite));
                    allPins.Add(new Pin("TinkerA3", PinType.A, "A3", NoAnalogWrite));
                    allPins.Add(new Pin("TinkerA2", PinType.A, "A2", AllFunctions));
                    allPins.Add(new Pin("TinkerA1", PinType.A, "A1", AllFunctions));
                    allPins.Add(new Pin("TinkerA0", PinType.A, "A0", AllFunctions));

                    allPins.Add(new Pin("TinkerD7", PinType.D, "D7", DigitalOnly));
                    allPins.Add(new Pin("TinkerD6", PinType.D, "D6", DigitalOnly));
                    allPins.Add(new Pin("TinkerD5", PinType.D, "D5", DigitalOnly));
                    allPins.Add(new Pin("TinkerD4", PinType.D, "D4", DigitalOnly));
                    allPins.Add(new Pin("TinkerD3", PinType.D, "D3", DigitalOnly));
                    allPins.Add(new Pin("TinkerD2", PinType.D, "D2", DigitalOnly));
                    allPins.Add(new Pin("TinkerD1", PinType.D, "D1", NoAnalogRead));
                    allPins.Add(new Pin("TinkerD0", PinType.D, "D0", NoAnalogRead));

                    break;

                case ParticleDeviceType.Photon:
                case ParticleDeviceType.P1:
                    allPins.Add(new Pin("TinkerA7", PinType.A, "A7", AllFunctions, "WKP", AnalogWriteMax));
                    allPins.Add(new Pin("TinkerA6", PinType.A, "A6", AllFunctionsDAC, "DAC", AnalogWriteMaxAlt));
                    allPins.Add(new Pin("TinkerA5", PinType.A, "A5", AllFunctions));
                    allPins.Add(new Pin("TinkerA4", PinType.A, "A4", AllFunctions));
                    allPins.Add(new Pin("TinkerA3", PinType.A, "A3", AllFunctionsDAC, "A3", AnalogWriteMaxAlt));
                    allPins.Add(new Pin("TinkerA2", PinType.A, "A2", NoAnalogWrite));
                    allPins.Add(new Pin("TinkerA1", PinType.A, "A1", NoAnalogWrite));
                    allPins.Add(new Pin("TinkerA0", PinType.A, "A0", NoAnalogWrite));

                    allPins.Add(new Pin("TinkerD7", PinType.D, "D7", DigitalOnly));
                    allPins.Add(new Pin("TinkerD6", PinType.D, "D6", DigitalOnly));
                    allPins.Add(new Pin("TinkerD5", PinType.D, "D5", DigitalOnly));
                    allPins.Add(new Pin("TinkerD4", PinType.D, "D4", DigitalOnly));
                    allPins.Add(new Pin("TinkerD3", PinType.D, "D3", NoAnalogRead));
                    allPins.Add(new Pin("TinkerD2", PinType.D, "D2", NoAnalogRead));
                    allPins.Add(new Pin("TinkerD1", PinType.D, "D1", NoAnalogRead));
                    allPins.Add(new Pin("TinkerD0", PinType.D, "D0", NoAnalogRead));
                    break;

                case ParticleDeviceType.Electron:
                    allPins.Add(new Pin("TinkerA7", PinType.A, "A7", AllFunctions, "WKP", AnalogWriteMax));
                    allPins.Add(new Pin("TinkerA6", PinType.A, "A6", AllFunctionsDAC, "DAC", AnalogWriteMaxAlt));
                    allPins.Add(new Pin("TinkerA5", PinType.A, "A5", AllFunctions));
                    allPins.Add(new Pin("TinkerA4", PinType.A, "A4", AllFunctions));
                    allPins.Add(new Pin("TinkerA3", PinType.A, "A3", AllFunctionsDAC, "A3", AnalogWriteMaxAlt));
                    allPins.Add(new Pin("TinkerA2", PinType.A, "A2", NoAnalogWrite));
                    allPins.Add(new Pin("TinkerA1", PinType.A, "A1", NoAnalogWrite));
                    allPins.Add(new Pin("TinkerA0", PinType.A, "A0", NoAnalogWrite));

                    allPins.Add(new Pin("TinkerB5", PinType.B, "B5", NoAnalogWrite));
                    allPins.Add(new Pin("TinkerB4", PinType.B, "B4", AllFunctions));
                    allPins.Add(new Pin("TinkerB3", PinType.B, "B3", AllFunctions));
                    allPins.Add(new Pin("TinkerB2", PinType.B, "B2", AllFunctions));
                    allPins.Add(new Pin("TinkerB1", PinType.B, "B1", NoAnalogRead));
                    allPins.Add(new Pin("TinkerB0", PinType.B, "B0", DigitalOnly));

                    allPins.Add(new Pin("TinkerD7", PinType.D, "D7", DigitalOnly));
                    allPins.Add(new Pin("TinkerD6", PinType.D, "D6", DigitalOnly));
                    allPins.Add(new Pin("TinkerD5", PinType.D, "D5", DigitalOnly));
                    allPins.Add(new Pin("TinkerD4", PinType.D, "D4", DigitalOnly));
                    allPins.Add(new Pin("TinkerD3", PinType.D, "D3", NoAnalogRead));
                    allPins.Add(new Pin("TinkerD2", PinType.D, "D2", NoAnalogRead));
                    allPins.Add(new Pin("TinkerD1", PinType.D, "D1", NoAnalogRead));
                    allPins.Add(new Pin("TinkerD0", PinType.D, "D0", NoAnalogRead));

                    allPins.Add(new Pin("TinkerC5", PinType.C, "C5", NoAnalogRead));
                    allPins.Add(new Pin("TinkerC4", PinType.C, "C4", NoAnalogRead));
                    allPins.Add(new Pin("TinkerC3", PinType.C, "C3", DigitalOnly));
                    allPins.Add(new Pin("TinkerC2", PinType.C, "C2", DigitalOnly));
                    allPins.Add(new Pin("TinkerC1", PinType.C, "C1", DigitalOnly));
                    allPins.Add(new Pin("TinkerC0", PinType.C, "C0", DigitalOnly));
                    break;
            }

            foreach (var pin in allPins)
                pin.ParticleDevice = particleDevice;

            return allPins;
        }