I think v is constantly being reset to 0 every loop so your runnable won't
ever do anything.
Try making your 'v' a class field instead outside of the loop and then
access it from there.
On Saturday, May 3, 2014 2:55:07 AM UTC-5, harshad wrote:
>
> hi,
>
> I am doing ECG plotting application using IOIO. Currently getting almost
> proper realtime ECG wave.PFA for plot. But unable to retrive Heart Rate in
> BPM.
>
> Thus,*I want to measure time difference between to successive analog
> peaks (2.1 V)*
>
>
>
> **
>
> This analog input voltage is varying between 1.5 V to 2.5V
>
> my code: i am using simpleIOIO app as reference
>
> *1) to get voltage from analog input pin 40,*
>
> public void loop() throws ConnectionLostException, InterruptedException {
>
> // TODO Auto-generated method stub
>
> super.loop();
>
> v = 0;
>
> try {
>
> actualTime = System.currentTimeMillis(); // reading system
> time in milliseconds
>
> newTime1 = actualTime;
>
> led_.write(!mEcgOn.isChecked());
>
> v = inPin.getVoltage();
>
> Thread.sleep(100);
>
> } catch (InterruptedException e) {
>
> inPin.close();
>
>
> // // TODO Auto-generated catch block
>
> e.printStackTrace();
>
> }
>
> *2) To compare the peak to peak voltage using an UI thread*
>
> runOnUiThread(new Runnable() {
>
> @Override
>
> public void run()
>
> if(v>2.1)
>
> {
>
> newTime2=newTime1;
>
> timeDiff1 = actualTime-newTime2;
>
> }
>
> voltsText = Long.toString(timeDiff1);
>
> voltsText1 = Long.toString(actualTime);
>
> mHRateDisplay.setText(voltsText);
>
> mTempDisplay.setText(voltsText1);
>
> }
>
> });
>
> * Logic: i am capturing system time in millisecoonds. Then
> as voltage is available , stored this time in newTime1. Now by running new
> UI thread comparing new peak at 2.1V while storing new time2 and
> calculating time the difference.*
>
> *But its not giving any output. *
>
> *Please help..*
>
>
> *Regards,*
>
> *Harshad *
>
--
You received this message because you are subscribed to the Google Groups
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.