public void Update(DeviceConfig config)
        {
            Config = config;

            for (int i = 0; i < Config.PinConfig.Count; i++)
            {
                if (Config.PinConfig[i] == PinType.TLE501x_CS || Config.PinConfig[i] == PinType.Axis_Analog)
                {
                    foreach (var axis in Axes)
                    {
                        if (!axis.AllowedSources.Contains((AxisSourceType)i))
                        {
                            axis.AllowedSources.Add((AxisSourceType)i);
                        }
                    }
                }
                else
                {
                    foreach (var axis in Axes)
                    {
                        if (axis.AxisConfig.SourceMain == (AxisSourceType)i)
                        {
                            axis.AxisConfig.SourceMain = AxisSourceType.Buttons;
                        }
                        axis.AllowedSources.Remove((AxisSourceType)i);
                    }
                }
            }

            for (int i = 0; i < Config.AxisConfig.Count; i++)
            {
                Axes[i].AxisConfig = Config.AxisConfig[i];
            }


            AxesCurvesVM.Update(Config);
        }
Example #2
0
        public void Update(DeviceConfig config)
        {
            Config = config;

            for (int i = 0; i < Config.PinConfig.Count; i++)
            {
                if (Config.PinConfig[i] == PinType.Axis_Analog ||
                    Config.PinConfig[i] == PinType.TLE5011_CS ||
                    Config.PinConfig[i] == PinType.MCP3201_CS ||
                    Config.PinConfig[i] == PinType.MCP3202_CS ||
                    Config.PinConfig[i] == PinType.MCP3204_CS ||
                    Config.PinConfig[i] == PinType.MCP3208_CS ||
                    Config.PinConfig[i] == PinType.MLX90393_CS)
                {
                    foreach (var axis in Axes)
                    {
                        if (!axis.AllowedSources.Contains((AxisSourceType)i))
                        {
                            axis.AllowedSources.Add((AxisSourceType)i);
                        }
                    }
                }
                else
                {
                    foreach (var axis in Axes)
                    {
                        if (axis.AxisConfig.SourceMain == (AxisSourceType)i)
                        {
                            axis.AxisConfig.SourceMain = AxisSourceType.Buttons;
                        }
                        axis.AllowedSources.Remove((AxisSourceType)i);
                        //
                    }
                }
            }

            if (Config.PinConfig[19] == PinType.I2C_SCL && Config.PinConfig[20] == PinType.I2C_SDA)    // PB8 and PB9
            {
                foreach (var axis in Axes)
                {
                    if (!axis.AllowedSources.Contains(AxisSourceType.I2C))
                    {
                        axis.AllowedSources.Add(AxisSourceType.I2C);
                    }
                }
            }
            else
            {
                foreach (var axis in Axes)
                {
                    if (axis.AxisConfig.SourceMain == AxisSourceType.I2C)
                    {
                        axis.AxisConfig.SourceMain = AxisSourceType.Buttons;
                    }
                    if (axis.AllowedSources.Contains(AxisSourceType.I2C))
                    {
                        axis.AllowedSources.Remove(AxisSourceType.I2C);
                    }
                }
            }

            for (int i = 0; i < Config.AxisConfig.Count; i++)
            {
                Axes[i].AxisConfig = Config.AxisConfig[i];
            }


            AxesCurvesVM.Update(Config);
        }