test

Dependencies:   BLE_API nRF51822 mbed

Fork of KS7 by masaaki makabe

Revision:
4:edd6e262de9e
Parent:
3:2398a9368c9b
Child:
5:1730064b94bd
--- a/main.cpp	Thu Oct 22 10:41:39 2015 +0000
+++ b/main.cpp	Sat Oct 24 11:13:19 2015 +0000
@@ -1,6 +1,28 @@
 #include "mbed.h"
 #include "io.h"
 
+//Serial pc(P0_9, P0_8);// TX=P0_9
+
+/*
+Serial pc(P0_9, P0_8);// TX=P0_9
+AnalogIn vin(P0_1);
+
+int main()
+{
+    pc.baud(9600);
+    while(1){
+        pc.printf("CONFIG=%x\r\n", NRF_ADC->CONFIG); // 0x0000046a 
+// EXTREFSEL=00 (none)
+// PSEL=00000100 (use AnalogInput2)
+// REFSEL=11 (VDD with 1/3 prescale)
+// INPSEL=010 (prescale=1/3)
+// RES=10 (10bit)
+        pc.printf("%f %d\r\n", vin.read(), NRF_ADC->RESULT);
+        wait(0.1);
+    }
+}
+*/    
+
 io io;
 
 Ticker tk; // 1s timer for switch check & weighgt measure
@@ -13,7 +35,6 @@
     io.analog_pow(1); // turn analog power on
     weight = io.get_weight(); // get weight [g]
 /*
-    note: this routine should be re-arranged (akita11)
     // check switch, and control power flag (fPower)
     if (fPow == 0 && io.get_switch() == 1){
         while(io.get_switch() == 1); // wait until switch released
@@ -24,17 +45,38 @@
         fPow = 0;
     }
 */
+
+//    io.display_value = (uint16_t)(io.get_weight_raw() * 9999.0); // dummy display
+//    io.display_value = (int)(io.get_x() * 9900 + io.get_y() * 99); // test: display joystick XY value
+//    io.display_value = (uint16_t)(io.get_x() * 9999.0); // dummy display
+
+
     io.analog_pow(0); // turn analog power off
 }
 
 int main()
 {
-    tk.attach(&ticker_1s, 1);
-    io.calibrate_weight(); // initial calibration
-    io.display(0.8); // display intensity 80%
+    tk.attach(&ticker_1s, 0.1);
+//    io.calibrate_weight(); // initial calibration
     while(1){
-        io.display_value = (uint16_t)(weight * 9999.0); // dummy display
-        wait(0.1);
+        io.display(1);        
+        for (int i = 0; i < 50; i++){
+            io.display_value = (uint16_t)(io.get_weight() * 9999.0); // dummy display
+            wait(0.1);
+        }
+        io.display(0.3);        
+        for (int i = 0; i < 50; i++){
+            io.display_value = (int)(io.get_x() * 9900 + io.get_y() * 99); // test: display joystick XY value
+            wait(0.1);
+        }
+//        io.display_value = (uint16_t)(io.get_weight() * 9999.0); // dummy display
+//        wait(0.1);
+//        for (float i = 0; i < 1.0; i+=0.05){
+//            if (i <0.5) io.display(1.0-i);
+//            else 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