application: minor, slight voltage reading improvement

This commit is contained in:
King Kévin 2021-03-16 12:18:55 +01:00
parent d83f26e126
commit 79a8357308
1 changed files with 2 additions and 0 deletions

View File

@ -347,6 +347,7 @@ static void command_types(void* argument)
puts(" ");
gpio_clear(GPIO_PORT(SIGNAL_PD_PIN), GPIO_PIN(SIGNAL_PD_PIN)); // pull down signal
sleep_us(10); // wait a tiny bit for voltage to settle
voltages = measure_voltages(); // measure pulled down voltages
gpio_set(GPIO_PORT(SIGNAL_PD_PIN), GPIO_PIN(SIGNAL_PD_PIN)); // remove pull-down
voltages[2] *= 2.0; // pulling creates a voltage divider (to ground)
@ -364,6 +365,7 @@ static void command_types(void* argument)
puts(" ");
gpio_clear(GPIO_PORT(SIGNAL_PU_PIN), GPIO_PIN(SIGNAL_PU_PIN)); // pull up signal
sleep_us(10); // wait a tiny bit for voltage to settle
voltages = measure_voltages(); // measure pulled up voltages
gpio_set(GPIO_PORT(SIGNAL_PU_PIN), GPIO_PIN(SIGNAL_PU_PIN)); // remove pull-up
voltages[2] = voltages[2] * 2.0 - voltages[1]; // pulling creates a voltage divider (to target)