Hello world for Rohm BH1726 ALS dual channel sensor. Uses Rohm sensor hal and bh1726 driver.

Dependencies:   mbed rohm-bh1726 rohm-sensor-hal

Fork of rohm-bh1745-hello by Rohm

Revision:
7:0baf8142fdef
Parent:
5:a8feb1b6e6b5
--- a/main_classic.cpp	Mon Sep 19 12:25:34 2016 +0000
+++ b/main_classic.cpp	Tue Sep 20 10:36:12 2016 +0000
@@ -21,6 +21,19 @@
 
 Serial pc(USBTX, USBRX);
 
+void bh1726_print_one_value(){
+    bool error;
+    uint16_t data[2];       //2 channels of 16-bit data
+
+    error = bh1726_read_data(&data[0]);
+    if (!error) {
+        pc.printf("ALS Data0[%4u], Data1[%4u]\n\r", data[0], data[1]);
+        }
+    else {
+        pc.printf("\n\r");
+        }
+}
+
 void bh1726_print_raw_values(){
     pc.printf("\nbh1726 library test program.\n\r");
     I2CCommonBegin();
@@ -31,16 +44,7 @@
 //    bh1726_dumpregs(BH1726_REGISTER_DUMP_START, BH1726_REGISTER_DUMP_END);
     
     while(1) {
-        bool error;
-        uint16_t data[2];       //2 channels of 16-bit data
-
-        error = bh1726_read_data(&data[0]);
-        if (!error) {
-            pc.printf("ALS Data0[%4u], Data1[%4u]\n\r", data[0], data[1]);
-            }
-        else {
-            pc.printf("\n\r");
-            }
+        bh1726_print_one_value();
         wait(0.2);
     }
 }