Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 2:86f6d5733ae7, committed 2019-06-11
- Comitter:
- achille
- Date:
- Tue Jun 11 11:49:26 2019 +0000
- Parent:
- 1:3f5287e5fa3c
- Commit message:
- volatile ?
Changed in this revision
--- a/fonctions.cpp Wed Jun 05 09:47:13 2019 +0000
+++ b/fonctions.cpp Tue Jun 11 11:49:26 2019 +0000
@@ -1,4 +1,4 @@
-#include"fonctions.h"
+#include "fonctions.h"
void led_set(int flagV, int flagR1,int flagR2)
@@ -88,6 +88,33 @@
return t2-t1;
}
+float pvmax(donnees *t){
+ float max=0,tt=0;
+ int f1=0,f2=0;
+ for(int i=0;i<REC;i++){
+ if(t[i].V>max){
+ max=t[i].V;
+ }
+ }
+ int j=0;
+ float t1=0,t2=0;
+ while(f2==0){
+ if((t[j].V>(max-(float)0.2))&&f1==0){
+ t1=t[j].T;
+ f1=1;
+ }
+ else{if((t[j].V>(max-(float)0.2))&&f2==0){
+ t2=t[j].T;
+ f2=1;
+ }
+ }
+ j++;
+ }
+ tt=t2-t1;
+ return tt;
+ }
+
+
void affichage(float fIn,float fV, int *flagV, int *flagR1, int *flagR2){
*flagV=0;
*flagR1=0;
--- a/fonctions.h Wed Jun 05 09:47:13 2019 +0000 +++ b/fonctions.h Tue Jun 11 11:49:26 2019 +0000 @@ -13,5 +13,7 @@ void recup(volatile donnees *t, float time, int i); float moy(volatile donnees *t); float period(volatile donnees *t, float mo); + +float pvmax(donnees *t); void affichage(float fIn,float fV, int *flagV, int *flagR1, int *flagR2); float frequ(float fIn); \ No newline at end of file
--- a/main.cpp Wed Jun 05 09:47:13 2019 +0000
+++ b/main.cpp Tue Jun 11 11:49:26 2019 +0000
@@ -7,7 +7,7 @@
-volatile donnees t[REC];
+donnees t[REC];
volatile int i;
volatile int flag;
@@ -48,18 +48,19 @@
}
tps.stop();*/
recupp.detach();
- float mo=moy(t);
- port.printf("la moyenne %f \r\n ",mo);
- float pf=period(t,mo);
+ /*float mo=moy(t);
+ port.printf("la moyenne %f \r\n ",mo);*/
+ float pf=0;
+ pf=pvmax(t);
pf=1/pf;
port.printf("la freq %f\r\n ",pf);
affichage(pf,frequ(pf),&flagV,&flagR1,&flagR2);
led_set(flagV,flagR1,flagR2);
- wait(0.5);
- flagV=0;
+ /*wait(0.5);*/
+ /*flagV=0;
flagR1=0;
flagR2=0;
- led_set(flagV,flagR1,flagR2);
+ led_set(flagV,flagR1,flagR2); */
i=0;
flag=0;
tps.start();
@@ -67,3 +68,29 @@
}
}
}
+
+float toto(donnees *t){
+ float max=0,tt=0;
+ int f1=0,f2=0;
+ for(int i=0;i<REC;i++){
+ if(t[i].V>max){
+ max=t[i].V;
+ }
+ }
+ int j=0;
+ float t1=0,t2=0;
+ while(f2==0){
+ if((t[j].V>(max-(float)0.2))&&f1==0){
+ t1=t[j].T;
+ f1=1;
+ }
+ else{if((t[j].V>(max-(float)0.2))&&f2==0){
+ t2=t[j].T;
+ f2=1;
+ }
+ }
+ j++;
+ }
+ tt=t2-t1;
+ return tt;
+ }