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)); } }
public void Shutdown() { if (!IsAlreadyInit) { return; } ConfigManager?.SaveConfig().ConfigureAwait(false); EventManager?.StopAllEventGenerators(); PinController.GetDriver()?.ShutdownDriver(); }