]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/tests/mbed/analog_pot/main.cpp
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / tests / mbed / analog_pot / main.cpp
1 #include "mbed.h"
2 #include "test_env.h"
3
4 AnalogIn pot1(A0);
5 AnalogIn pot2(A1);
6
7 #define TEST_ITERATIONS 20
8 #define MEASURE_MIN 0.01
9
10 int main(void) {
11 MBED_HOSTTEST_TIMEOUT(10);
12 MBED_HOSTTEST_SELECT(default_auto);
13 MBED_HOSTTEST_DESCRIPTION(AnalogIn potentiometer test);
14 MBED_HOSTTEST_START("analog_pot");
15
16 bool result = false;
17 float val1, val2;
18
19 for (int i = 0; i < TEST_ITERATIONS; i++) {
20 val1 = pot1.read();
21 val2 = pot2.read();
22
23 const char *succes_str = val1 > MEASURE_MIN || val2 > MEASURE_MIN ? "[OK]" : "[FAIL]";
24 result = result || (val1 > MEASURE_MIN || val2 > MEASURE_MIN);
25 printf("Pot values %f, %f\r\n", val1, val2);
26 wait(0.001);
27 }
28 MBED_HOSTTEST_RESULT(result);
29 }
Imprint / Impressum