protected void TestCapacitive() { while (true) { Console.WriteLine("Humidity:" + capacitive.Read()); Thread.Sleep(2000); } }
protected async Task TestCapacitiveSensorAsync() { while (true) { float moisture = await capacitive.Read(); Console.WriteLine(moisture); Thread.Sleep(1000); } }
async Task TestCapacitiveRead() { Console.WriteLine("TestCapacitiveSensor..."); while (true) { FloatChangeResult moisture = await capacitive.Read(); Console.WriteLine($"Moisture New Value { moisture.New}"); Console.WriteLine($"Moisture Old Value { moisture.Old}"); Console.WriteLine($"Moisture Delta Value { moisture.Delta}"); Thread.Sleep(1000); } }
async void ButtonClicked(object sender, EventArgs e) { onboardLed.SetColor(Color.Orange); var newMoisture = await capacitive.Read(); var newTemperature = await analogTemperature.Read(); displayController.UpdateMoisturePercentage(newMoisture.New, moisture.New); moisture = newMoisture; displayController.UpdateTemperatureValue(newTemperature.Temperature.Value, temperature.Temperature.Value); temperature = newTemperature; onboardLed.SetColor(Color.Green); }
void TestCapacitiveRead() { Console.WriteLine("TestCapacitiveSensor..."); // Use Read(); to get soil moisture value from 0f - 1f while (true) { float moisture = capacitive.Read().Result; if (moisture > 1.0f) { moisture = 1.0f; } else if (moisture < 0) { moisture = 0; } Console.WriteLine($"Moisture {(int) (moisture * 100)}%"); Thread.Sleep(1000); } }
async Task StartReading() { while (true) { var reading = await capacitive.Read(); double moisture = reading; if (moisture > 1) { moisture = 1f; } else if (moisture < 0) { moisture = 0f; } ledBarGraph.Percentage = (float)moisture; Console.WriteLine($"Moisture {moisture * 100}%"); Thread.Sleep(1000); } }