Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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 |
--- 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);
}
}

Rohm BH1745NUC | RGB Color Sensor