Rohm RPR0521 proximity-als-ir -sensor hello world application. Uses rpr0521-driver and rohm-sensor-hal -libraries.
Dependencies: mbed rohm-rpr0521 rohm-sensor-hal
Fork of KX022_Hello by
Diff: main_classic.cpp
- Revision:
- 4:6a931904c92a
- Parent:
- 2:edc916d1a86d
--- a/main_classic.cpp Mon Sep 12 09:55:47 2016 +0000 +++ b/main_classic.cpp Tue Sep 20 11:16:04 2016 +0000 @@ -21,6 +21,19 @@ Serial pc(USBTX, USBRX); +void rpr0521_print_one_value(){ + bool error; + uint16_t data[3]; + + error = rpr0521_read_data(&data[0]); + if (!error) { + pc.printf("PS[%4u], Als0[%4u], Als1[%4u]\n\r", data[0], data[1], data[2]); + } + else { + pc.printf("\n\r"); + } +} + void rpr0521_print_raw_values(){ pc.printf("\nRPR0521 library test program.\n\r"); I2CCommonBegin(); @@ -31,16 +44,7 @@ wait(1); while(1) { - bool error; - uint16_t data[3]; - - error = rpr0521_read_data(&data[0]); - if (!error) { - pc.printf("PS[%4u], Als0[%4u], Als1[%4u]\n\r", data[0], data[1], data[2]); - } - else { - pc.printf("\n\r"); - } + rpr0521_print_one_value(); wait(0.1); } }