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 Rohm

Files at this revision

API Documentation at this revision

Comitter:
MikkoZ
Date:
Tue Sep 20 11:16:04 2016 +0000
Parent:
3:e22f64655c63
Commit message:
Refactored main.

Changed in this revision

main_classic.cpp Show annotated file Show diff for this revision Revisions of this file
rohm-rpr0521.lib Show annotated file Show diff for this revision Revisions of this file
diff -r e22f64655c63 -r 6a931904c92a main_classic.cpp
--- 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);
     }
 }
diff -r e22f64655c63 -r 6a931904c92a rohm-rpr0521.lib
--- a/rohm-rpr0521.lib	Mon Sep 12 09:55:47 2016 +0000
+++ b/rohm-rpr0521.lib	Tue Sep 20 11:16:04 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/Rohm/code/rohm-rpr0521/#0bcc203c5c75
+https://developer.mbed.org/teams/Rohm/code/rohm-rpr0521/#145f11782373