test

Dependencies:   BLE_API nRF51822 mbed

Fork of KS7 by masaaki makabe

Revision:
0:08c8325a21ec
Child:
2:09bf05d66065
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 22 04:40:32 2015 +0000
@@ -0,0 +1,39 @@
+#include "mbed.h"
+#include "io.h"
+
+io io;
+
+Ticker tk; // 1s timer for switch check & weighgt measure
+float weight;
+uint8_t fPow = 0;
+
+ // 1s timer for switch check & weighgt measure
+ void ticker_1s()
+{
+    io.analog_pow(1); // turn analog power on
+    weight = io.get_weight(); // get weight [g]
+    // check switch, and control power flag (fPower)
+    if (fPow == 0 && io.get_switch() == 1){
+        while(io.get_switch() == 1); // wait until switch released
+        fPow = 1;
+    }
+    if (fPow == 1 && io.get_switch() == 1){
+        while(io.get_switch() == 1); // wait until switch released
+        fPow = 0;
+    }
+    io.analog_pow(0); // turn analog power off
+}
+
+int main()
+{
+    tk.attach(&ticker_1s, 1);
+    io.calibrate_weight(); // initial calibration
+    while(1){
+        for (float i = 0.0; i < 1.0; i+=0.05){
+            io.display(i); // change display brightneess
+            wait(0.1);
+            io.display_value = (uint16_t)(io.get_weight() * 9999.0); // dummy display
+        }
+    }
+}
+    
\ No newline at end of file