![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
True leaf photo frame,gesture sensing APDS9960,motor fan,color LED
Dependencies: SFE_APDS9960 mbed
Diff: main.cpp
- Revision:
- 3:d046bb79dbbe
- Parent:
- 2:6b5764a79ccf
- Child:
- 4:6dfbdf48fd16
--- 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; + } } }