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: SFE_APDS9960 mbed
Revision 3:d046bb79dbbe, committed 2016-04-20
- Comitter:
- yzh344612058
- Date:
- Wed Apr 20 15:30:25 2016 +0000
- Parent:
- 2:6b5764a79ccf
- Child:
- 4:6dfbdf48fd16
- Commit message:
- ??????
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Apr 20 03:12:28 2016 +0000
+++ b/main.cpp Wed Apr 20 15:30:25 2016 +0000
@@ -3,17 +3,27 @@
#include "led.h"
Serial pc(P0_23,P0_25); // TX Pin, RX Pin
-I2C i2c(P0_8, P0_9);
+I2C i2c(P0_14, P0_13);
SparkFun_APDS9960 apds(i2c);
-DigitalIn interrupt(P0_10);
+InterruptIn SparkFun_Int(P0_16);
+
+int isr_flag = 0;
- void handleGesture();
+void handleGesture();
+
+
+void SparkFun_Interrupt(){
+ isr_flag = 1;
+}
int main()
{
pc.printf("Hello world!\n");
- if(apds.init(40000))
+ SparkFun_Int.fall(&SparkFun_Interrupt);
+
+
+ if(apds.init(100000))
pc.printf("APDS-9960 initialization complete\n");
else
pc.printf("Something went wrong during APDS-9960 init!\n");
@@ -23,16 +33,13 @@
else
printf("Something went wrong during gesture sensor init!\n");
-
while(1)
{
- Led_Blink();
- if(!interrupt)
- {
- wait_ms(10);
- if(!interrupt)
- handleGesture();
- }
+ if(isr_flag == 1)
+ {
+ handleGesture();
+ isr_flag = 0;
+ }
}
}