/// <summary> /// Sets the function type of the specified pin /// </summary> /// <param name="gpioNumber"> GPIO Pin Number </param> /// <param name="function"> Function type </param> public async Task <GPIOFunctions> SetGPIOFunction(int gpioNumber, GPIOFunctions function) { var response = await _client.PostAsync(GetFullUrl($"/GPIO/{gpioNumber}/function/{GetStringFromFunction(function)}"), null); response.EnsureSuccessStatusCode(); return(GetFunctionFromString(await response.Content.ReadAsStringAsync())); }
private static string GetStringFromFunction(GPIOFunctions value) { switch (value) { case GPIOFunctions.In: return("in"); case GPIOFunctions.Out: return("out"); case GPIOFunctions.PWM: return("pwm"); default: throw new ArgumentException($"Unknown GPIOFunctions enum member '{value}'"); } }
/// <summary> /// Sets the function type of the specified pin /// </summary> /// <param name="gpioNumber"> GPIO Pin Number </param> /// <param name="function"> Function type </param> public Task <GPIOFunctions> SetGPIOFunction(int gpioNumber, GPIOFunctions function) { _list.Single(p => p.PinNumber == gpioNumber).Function = function; return(Task.FromResult(_list.Single(p => p.PinNumber == gpioNumber).Function)); }