Esempio n. 1
0
        public static async Task InitAsync()
        {
            Pumps = new Pumps();

            Ingredients = new Ingredients();
            Ingredients.Load();

            Recipes = new Recipes();
            Recipes.Load();


            gpio = GpioController.GetDefault();
            if (gpio != null)
            {
                pinEnable = gpio.OpenPin(PIN_ENABLE);
                pinEnable.Write(GpioPinValue.High);
                pinEnable.SetDriveMode(GpioPinDriveMode.Output);

                pinDirection = gpio.OpenPin(PIN_DIRECTION);
                pinDirection.Write(GpioPinValue.Low);
                pinDirection.SetDriveMode(GpioPinDriveMode.Output);

                SetPumpDirectionIn();
                SetPumpDirectionOut();
            }

            #region Pumps

            AddPump("A1", "", 4);
            AddPump("A2", "", 17);
            AddPump("A3", "", 27);
            AddPump("A4", "", 22);

            AddPump("B1", "", 10);
            AddPump("B2", "", 9);
            AddPump("B3", "", 11);
            AddPump("B4", "", 5);

            AddPump("C1", "", 6);
            AddPump("C2", "", 13);
            AddPump("C3", "", 19);
            AddPump("C4", "", 26);

            Pumps.LoadConfiguration();

            #endregion

            StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/make.mp3"));

            player          = BackgroundMediaPlayer.Current;
            player.AutoPlay = false;
            player.SetFileSource(file);

            _ = Windows.System.Threading.ThreadPool.RunAsync(StepTicThread, Windows.System.Threading.WorkItemPriority.Normal);
        }
Esempio n. 2
0
        public static async Task ExecuteRecipe(Recipe recipe)
        {
            player.Position = TimeSpan.Zero;
            player.Play();
            LoadRecipeOntoPumps(recipe);
            Pumps.DebugPumpUsage();
            SetPumpDirectionOut();

            ProgressBar.Maximum = Pumps.MaxSteps;
            ProgressBar.Value   = 0;

            EnableMotorDrivers();
        }
Esempio n. 3
0
        static Pump AddPump(string ID, string ingredientName, int pinNumber)
        {
            Pump pump = new Pump();

            pump.ID         = ID;
            pump.Ingredient = ingredientName;

            if (gpio != null && pinNumber > 0)
            {
                GpioPin pin = gpio.OpenPin(pinNumber);
                pin.Write(GpioPinValue.High);
                pin.SetDriveMode(GpioPinDriveMode.Output);
                pump.Pin = pin;
            }

            Pumps.Add(pump);
            return(pump);
        }