Brendon Ky / Mbed 2 deprecated cs_335_speedometer

Dependencies:   mbed mbed-rtos

Revision:
7:12eed49f95fc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/input_driver.cpp.orig	Mon Nov 30 22:34:25 2020 +0000
@@ -0,0 +1,26 @@
+# define LIGHT_SENSOR_PIN p15
+
+#include "mbed.h"
+# include <stdbool.h>
+
+AnalogIn  lightSensorVoltage(LIGHT_SENSOR_PIN);
+
+bool flashDetected = false;
+
+int main() {
+    int voltage0 = 0; // previous voltage
+    int voltage1 = 0; // previous-previous voltage
+    
+    while(1) {
+        // detects if there was in an inflection point in the voltage, where it went from increasing, to decreasing
+        flashDetected = (voltage1 < voltage0) && (voltage0 > lightSensorVoltage);
+        
+        // update stored values
+        voltage1 = voltage0;
+        voltage0 = lightSensorVoltage;
+    }
+}
+
+bool getFlashDetected() {
+    return flashDetected;
+}
\ No newline at end of file