private async Task InitPinConfigs() { bool isLoadSuccess = await ConfigManager.LoadConfiguration().ConfigureAwait(false); if (!isLoadSuccess || PinConfigManager.GetConfiguration().PinConfigs.Count <= 0 || (isLoadSuccess && PinConfigManager.GetConfiguration().PinConfigs.Count <= 0)) { generateConfigs(); await ConfigManager.SaveConfig().ConfigureAwait(false); } void generateConfigs() { List <Pin> pinConfigs = new List <Pin>(); for (int i = 0; i < Constants.BcmGpioPins.Length; i++) { Pin config = PinController.GetDriver().GetPinConfig(Constants.BcmGpioPins[i]); pinConfigs.Add(config); Logger.Trace($"Generated pin config for {Pi.Gpio[i].PhysicalPinNumber} gpio pin."); } ConfigManager.Init(new PinConfig(pinConfigs, false)); } }
private void GeneratePinConfiguration(IGpioControllerDriver _driver) { List <Pin> pinConfigs = new List <Pin>(); for (int i = 0; i < Constants.BcmGpioPins.Length; i++) { pinConfigs.Add(_driver.GetPinConfig(Constants.BcmGpioPins[i])); Logger.Trace($"Generated pin config for '{Constants.BcmGpioPins[i]}' gpio pin."); } ConfigManager.Init(new PinConfig(pinConfigs, false)); }