Rohm BH1745 red-green-blue-clear -color sensor hello world. Uses Rohm sensor hal for i2c commands and rohm-bh1745 -driver for sensor specific commands.
Dependencies: mbed rohm-bh1745 rohm-sensor-hal
Fork of rohm-rpr0521-hello by
Revision 6:cdf8e9ef435d, committed 2016-09-20
- Comitter:
- MikkoZ
- Date:
- Tue Sep 20 11:20:22 2016 +0000
- Parent:
- 5:e1c654fe0f42
- Commit message:
- Refactored main.
Changed in this revision
main_classic.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r e1c654fe0f42 -r cdf8e9ef435d main_classic.cpp --- a/main_classic.cpp Mon Sep 19 12:32:46 2016 +0000 +++ b/main_classic.cpp Tue Sep 20 11:20:22 2016 +0000 @@ -21,6 +21,19 @@ Serial pc(USBTX, USBRX); +void bh1745_print_one_value(){ + bool error; + uint16_t data[4]; //4 channels of 16-bit data + + error = bh1745_read_data(&data[0]); + if (!error) { + pc.printf("Red[%4u], Green[%4u], Blue[%4u], Clear[%4u]\n\r", data[0], data[1], data[2], data[3]); + } + else { + pc.printf("\n\r"); + } +} + void bh1745_print_raw_values(){ pc.printf("\nbh1745 library test program.\n\r"); I2CCommonBegin(); @@ -31,16 +44,7 @@ wait(1); while(1) { - bool error; - uint16_t data[4]; //4 channels of 16-bit data - - error = bh1745_read_data(&data[0]); - if (!error) { - pc.printf("Red[%4u], Green[%4u], Blue[%4u], Clear[%4u]\n\r", data[0], data[1], data[2], data[3]); - } - else { - pc.printf("\n\r"); - } + bh1745_print_one_value(); wait(0.2); } }