example code using statis library for temperature measurement with LM35 and LM335

Dependencies:   mbed statis

Files at this revision

API Documentation at this revision

Comitter:
greletj
Date:
Sun Dec 02 16:38:15 2012 +0000
Parent:
6:95195b0995dd
Commit message:
example code using statis lib

Changed in this revision

include/bitmsk.h Show diff for this revision Revisions of this file
include/debug.h Show diff for this revision Revisions of this file
include/ring.h Show diff for this revision Revisions of this file
include/statis.h Show diff for this revision Revisions of this file
include/temperatureSensor.h Show annotated file Show diff for this revision Revisions of this file
include/util.h Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
statis.cpp Show diff for this revision Revisions of this file
statis.lib Show annotated file Show diff for this revision Revisions of this file
temperatureSensor.cpp Show annotated file Show diff for this revision Revisions of this file
util.cpp Show diff for this revision Revisions of this file
--- a/include/bitmsk.h	Wed Nov 28 18:48:22 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * bitmsk.h
- */
-
-#ifndef bitmsk_H
-#define bitmsk_H
-
-#include <string.h>
-
-#define MAX_TACHES  32          // Maxi arbitraire
-#define BITMSK_SIZE MAX_TACHES / 8
-#define BITMSK_RIEN 0
-typedef unsigned char BITMSK;
-
-typedef enum          { ADD,
-                        REM,
-                        SETF,
-                        SETB,
-                        SETA,
-                        IS
-                      } TMODE;          // cf Win::seta()
-
-// #define NOPID   -1    // DOS
-
-#define NOPIDUNIX   -1
-typedef int     PID;            // De NOPID a MAX_TACHES
-
-#define BITMODE TMODE           // cf. video.h
-
-class Bitmsk
-{
-    // Membres
-private:
-    BITMSK    bits[ BITMSK_SIZE ];
-
-    // Methodes
-public:
-    bool     requete( BITMODE mode,PID pid );
-    void     raz(     void );
-
-    // Constructeurs
-public:
-    Bitmsk(  PID nb = 0,... );
-    Bitmsk(  Bitmsk &modele );
-};
-
-/*****************************************************************************
- * Prototypes des fonctions d'interface                                      *
- *****************************************************************************/
-BITMSK setmsk( BITMSK *bitmsk,BITMODE mode,BITMSK new_msk );
-
-#endif
--- a/include/debug.h	Wed Nov 28 18:48:22 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-// debug.h
-
-#ifdef DEBUG
-#  define DPRINTF( message ) pc.printf message
-#  define DEXEC(       fct ) fct
-#  define DGETC(           ) if( tgetc() == ESC ) exit( 1 )
-#else
-#  define DPRINTF( message )
-#  define DEXEC(       fct )
-#  define DGETC(           )
-#endif
--- a/include/ring.h	Wed Nov 28 18:48:22 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,226 +0,0 @@
-/*****************************************************************************
- *                                                                           *
- * ring.cpp : Module template de gestion de buffers circulaires tous types   *
- *                                                                           *
- *          Jacques Grelet      Mars 1992                                    *
- *          Bruno Buisson       Aout 92                                      *
- *          - Modif lecture buffer : si plein, on perd la plus   *
- *                                   ancienne valeur, pas toutes *
- *          - Nouvelles fonctions : vide_ring_x() vide le buffer *
- *                                  term_ring_x() libere la mem  *
- *                                  pr_ring_list() (debug)       *
- *                                  swap_ring_x() construit list *
- *                                  libre_ring_x() taille dispo  *
- *                                                                           *
- *          Bruno Buisson       Novembre 95                                  *
- *                      - Ajout de la fonction top_ring_x() qui retourne sans*
- *                        supprimer du ring le premier de la liste           *
- *                                                                           *
- *                              Avril 96                                     *
- *                      - Version template                                   *
- *                        Modification des fonctions fct_x(r,) en r.fct()    *
- *                        Suppression des fonctions init et term             *
- *                        (constructeur / destructeur)                       *
- *                        Les fonctions ont ete renommees                    *
- *                        Nouvelle fonction shift( n ) : supprime n elements *
- *                                                                           *
- *****************************************************************************/
-
-#ifdef DEBUG
-#include "mbed.h"
-#include "debug.h"
-extern Serial pc;
-
-#endif
-
-#ifndef ring_H
-#define ring_H
-
-#include "util.h"
-
-
-// Definition du template Ring
-template <class T_elem>
-class Ring
-{
-    // Type generique
-#define P_ELEM T_elem  *
-
-    // Membres;
-private:
-    unsigned taille,
-             libre;
-    P_ELEM   lecture;
-    P_ELEM   ecriture;
-    P_ELEM   tampon;
-
-public:
-    P_ELEM   list;
-
-    // Methodes inline
-private:
-    inline void        incr(     P_ELEM &ptr              );
-
-public:
-    inline unsigned     nb_libre( void                     );
-
-    // Methodes
-public:
-    bool                put(      T_elem elem              );
-    bool                get(      T_elem &valeur           );
-    bool                top(      T_elem &valeur           );
-    unsigned            shift(    unsigned nb = 1          );
-    void                vide(     void                     );
-    unsigned            store(    void                     );
-
-    // Constructeurs
-public:
-    Ring(     unsigned size = 0        );
-    ~Ring();
-};
-
-/*****************************************************************************
- * Si le pointeur ptr depasse la taille maxi du tampon,                      *
- * il revient pointer au debut.                                              *
- * inline                                                                    *
- *****************************************************************************/
-template <class T_elem>
-void  Ring<T_elem>::incr( P_ELEM &ptr )
-{
-    if( ++ptr - tampon >= taille ) ptr = tampon;
-}
-
-/*****************************************************************************
- * Met un element dans un Ring                                               *
- * Lorsque Ring est plein, deplace egalement de pointeur de lecture et la    *
- * valeur la plus ancienne est perdue.                                       *
- *****************************************************************************/
-template <class T_elem>
-bool Ring<T_elem>::put( T_elem elem )
-{
-    if( taille == 0 ) return( false );
-    *ecriture = elem;
-    incr( ecriture );
-    if( libre > 0 ) libre--;
-    else            incr( lecture );
-    return( true );
-}
-
-/*****************************************************************************
- * Lit une valeur dans le Ring et la stocke dans le parametre recu           *
- * Le pointeur de lecture est incremente par cette fonction                  *
- * Retourne FALSE si le Ring est vide                                        *
- *****************************************************************************/
-template <class T_elem>
-bool Ring<T_elem>::get( T_elem &valeur )
-{
-    if( libre == taille ) return( FALSE );
-    valeur = *lecture;
-    incr( lecture );
-    libre++;
-    return( TRUE );
-}
-
-/*****************************************************************************
- * Lit une valeur dans le Ring et la stocke dans le parametre recu           *
- * Le pointeur de lecture n'est pas modifié par cette fonction, cf. get()    *
- * Retourne FALSE si le Ring est vide                                        *
- *****************************************************************************/
-template <class T_elem>
-bool Ring<T_elem>::top( T_elem &valeur )
-{
-    if( libre == taille ) return( FALSE );
-    valeur = *lecture;
-    return( TRUE );
-}
-
-/*****************************************************************************
- * Supprime n elements du sommet du ring                                     *
- * Retourne le nb d'elements reellement supprimes                            *
- *****************************************************************************/
-template <class T_elem>
-unsigned Ring<T_elem>::shift( unsigned nb /*=1*/ )
-{
-    unsigned i;
-    T_elem   val;
-
-    for( i = 0; i < nb && get( val ); i++ );
-    return( i );
-}
-
-/*****************************************************************************
- * Reinitialise les pointeurs de Ring. Le Ring est vide                      *
- *****************************************************************************/
-template <class T_elem>
-void  Ring<T_elem>::vide( void )
-{
-    libre    = taille;
-    lecture  =
-        ecriture = tampon;
-}
-
-/*****************************************************************************
- * Construction du tableau list.                                             *
- * Déplace les données contenues dans le buffer circulaire de Ring vers le   *
- * tableau list[]. Les donnéees de list[] ne seront écrasées que par un autre*
- * appel a cette fonction                                                    *
- * Retourne le nombre de valeurs transférées (0 si Ring est vide)            *
- * Version 02/02/94 : Ring est vide apres l'appel                            *
- *****************************************************************************/
-template <class T_elem>
-unsigned Ring<T_elem>::store( void )
-{
-    unsigned nb_elem = taille - libre,
-             i;
-
-    //DPRINTF( ("\r\nList: ") );
-    for( i = 0; i < nb_elem; i++ ) {
-        list[ i ] = *lecture;
-        //DPRINTF( ("%4.3g ", list[ i ] ));
-        incr( lecture );
-    }
-    //DPRINTF( ("\r\n") );
-    libre    = taille;
-    lecture  =
-        ecriture = tampon;
-    return( nb_elem );
-}
-
-/*****************************************************************************
- * inline                                                                    *
- *****************************************************************************/
-template <class T_elem>
-unsigned Ring<T_elem>::nb_libre( void )
-{
-    return( libre );
-}
-
-/*****************************************************************************
- *****************************************************************************/
-template <class T_elem>
-Ring<T_elem>::Ring( unsigned size /*=0*/ )
-{
-    lecture  =
-        ecriture =
-            tampon   = ( size == 0 ? (P_ELEM) NULL : FARALLOUE( size,T_elem ) );
-    list     = ( size == 0 ? (P_ELEM) NULL : FARALLOUE( size,T_elem ) );
-    libre    =
-        taille   = ( tampon ? size : 0 );
-}
-
-/*****************************************************************************
- *****************************************************************************/
-template <class T_elem>
-Ring<T_elem>::~Ring()
-{
-    FARLIBERE( tampon );
-    FARLIBERE( list   );
-    libre    =
-        taille   = 0;
-    lecture  =
-        ecriture =
-            tampon   =
-                list     = (P_ELEM) NULL;
-}
-
-#endif
--- a/include/statis.h	Wed Nov 28 18:48:22 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-/*
- * statis.h
- */
-
-#include "bitmsk.h"
-#include "ring.h"
-
-#define FLOAT_ERREUR 1.e36  // valeur en cas d'erreur de mesure
-
-#ifndef statis_H
-#define statis_H
-
-class Mediane_item
-{
-    // Membres
-public:
-    float     valeur;
-    int       indice;
-
-    // Methodes
-public:
-    void      raz( void );
-
-    // Constructeur
-public:
-    Mediane_item( void );
-};
-
-class Mediane
-{
-    // Methodes virtuelles
-public:
-    virtual Mediane_item &mediane( Mediane_item list[],unsigned n_elem );
-};
-
-class Mediane_circ : public Mediane
-{
-    // Membres
-private:
-    float         maxi,
-                  moitie;
-
-    // Methodes virtuelles
-public:
-    virtual Mediane_item &mediane(      Mediane_item list[],unsigned n_elem );
-
-    // Constructeurs
-public:
-    Mediane_circ( float a_maxi );
-};
-
-enum STAT_CALCULS { STAT_MED_NORM   = 0x01,
-                    STAT_MED_CIRC   = 0x02,
-                    STAT_MED        = 0x03,
-                    STAT_MOYENNE    = 0x04,
-                    STAT_ECART_TYPE = 0x08
-                  };
-
-class Statis_data
-{
-    // Membres
-private:
-    bool          stat_on;
-    BITMSK        calculs;
-    Ring<float>  ring;
-    Mediane_item *mediane_liste;
-    Mediane      *mediane_methode;
-
-public:
-    Mediane_item  med;
-    float         moy,
-                  ecart,
-                  instant,
-                  borne_inf,
-                  borne_sup;
-    unsigned      n_elem;
-
-    // Methodes
-private:
-    Mediane_item *cons_liste(  void );
-    bool          verifie(     float &val );
-    bool          mediane(     void );
-    bool          moyenne(     void );
-    bool          ecart_type(  void );
-
-public:
-    float        put(        float val );
-    void         calcule(     void );
-
-    // Constructeurs
-public:
-    Statis_data( BITMSK calc,unsigned taille,
-                 float b_inf = 0,float b_sup = 0 );
-    ~Statis_data();
-};
-
-#endif
--- a/include/temperatureSensor.h	Wed Nov 28 18:48:22 2012 +0000
+++ b/include/temperatureSensor.h	Sun Dec 02 16:38:15 2012 +0000
@@ -23,6 +23,7 @@
     float       _scaleTemp;
     float       _scaleFactor;
     float       _temperature;
+    unsigned    _n_elem;
 
 
 public:
--- a/include/util.h	Wed Nov 28 18:48:22 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/* anciennement sys.h */
-
-// typedef void           procedure;
-// typedef unsigned char  booleen;
-typedef void          *pointeur;
-
-#ifndef FALSE
-#  define FALSE 0
-#endif
-#ifndef TRUE
-#  define TRUE  1
-#endif
-
-#define ALLOUE( nb,type )      (type *) calloc( nb,sizeof( type ) )
-#define LIBERE(     var )        if( var ) free( (void *) var )
-
-#define FARALLOUE( nb,type )   (type *) calloc( nb, sizeof( type ) )
-#define FARLIBERE(     var )     if( var ) free( (void *) var )
-
-/* util.h */
-
-typedef char           STRING[ 41 ];
-#define MAX_CHAR_POOL 4096      /* 4Ko de chaines */
-
-
-double convert_position( double data );
-double temps( unsigned jour_julien, double heure );
-
-
-STRING *gen_str( unsigned taille /*= 80*/ );
-
--- a/main.cpp	Wed Nov 28 18:48:22 2012 +0000
+++ b/main.cpp	Sun Dec 02 16:38:15 2012 +0000
@@ -1,17 +1,23 @@
 #include "mbed.h"
-#include "include/util.h"
-#include "include/bitmsk.h"
-#include "include/ring.h"
+#include "util.h"
+#include "bitmsk.h"
+#include "ring.h"
 #include "tickerEvent.h"
 #include "temperatureSensor.h"
 
 Serial pc(USBTX, USBRX);
 
-// tickerEvent initialisation
+// Ticker initialisation
 tickerEvent led1(LED1, 1);
-//tickerEvent led2(LED2, 0.9);
-//tickerEvent led3(LED3, 0.7);
-//tickerEvent led4(LED4, 0.1);
+Ticker disp;
+
+float DISP_RATE   = 2;
+
+float LM35_FREQ   = 10;
+int   LM35_SIZE   = 19;
+
+float LM335_FREQ  = 10;
+int   LM335_SIZE  = 19;
 
 // temperature sensor intialisation
 /* Statistical declaration is a bitmsk of type:
@@ -22,24 +28,32 @@
  STAT_ECART_TYPE -> standard deviation
  */
 // LM35 temperature sensor out is connected to Mbed pin : p19
-temperatureSensor LM35(p19, 0.05, 0, STAT_MED_NORM|STAT_MED | STAT_MOYENNE | STAT_ECART_TYPE, 19);
+temperatureSensor LM35(p19, 1.0/LM35_FREQ, 0, STAT_MED_NORM | STAT_MED | STAT_MOYENNE | STAT_ECART_TYPE, LM35_SIZE);
 
 // LM335 temperature sensor out is connected to Mbed pin : p20
-temperatureSensor LM335(p20, 0.05, 273.15, STAT_MED_NORM|STAT_MED | STAT_MOYENNE | STAT_ECART_TYPE , 19);
+temperatureSensor LM335(p20, 1.0/LM35_SIZE, 273.15, STAT_MED_NORM | STAT_MED | STAT_MOYENNE | STAT_ECART_TYPE , LM335_SIZE);
+
+// function call by Ticker objet disp
+void display()
+{
+    LM35.calcule();
+    pc.printf("LM35:  %+4.4g C, %+4.4g C, std: %03.1g ind: %2d (%3u)\t",
+              LM35.mediane(), LM35.moyenne(), LM35.ecart_type(), LM35.indice(), LM35.n_element());
+    LM335.calcule();              
+    pc.printf("LM335: %+4.4g C, %+4.4g C, std: %03.1g ind: %2d (%3u)\r",
+              LM335.mediane(), LM335.moyenne(), LM335.ecart_type(), LM335.indice(), LM335.n_element());
+}
 
 // main program
 int main()
 {
-    pc.printf("\r\nStarting ...\r\n");
+    disp.attach( &display, DISP_RATE );
+
+    pc.printf("\r\nStarting at %5.0f Hz ...\r\n", LM35_FREQ);
     pc.printf("Sensor: mediane, average, std-dev, indice\r\n");
+
     while (1) {
-        //for ( int i = 0; i < 5; i++ ) {
-        //pc.printf("Status LED1: %d\r\n", led1.read());
-        wait(2);
-        LM35.calcule();
-        LM335.calcule();
-        pc.printf("LM35:  %4.3g C, %4.3g C, std: %3.1g ind: %2d (%3u)\t\t", LM35.mediane(), LM35.moyenne(), LM35.ecart_type(), LM35.indice()), LM35.n_element();
-        pc.printf("LM335: %4.3g C, %4.3g C, std: %3.0g ind: %2d\r", LM335.mediane(), LM335.moyenne(), LM335.ecart_type(), LM335.indice());
+
     }
-    //pc.printf("End ...\r\n");
+
 }
--- a/statis.cpp	Wed Nov 28 18:48:22 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,278 +0,0 @@
-/*****************************************************************************
- * Statis.c                                                                  *
- *                                                                           *
- *    Module de calcul statistique utilisees par le logiciel THERMO          *
- *       Ce module dans la version 1.0 calcule : la mediane                  *
- *                                               la moyenne                  *
- *                                               l'ecart type                *
- *    Les fonctions prennent toutes comme argumemts un tableau FAR list[]    *
- *    et les n_elem sur lequel est realise le calcul.                        *
- *                                                                           *
- *                      Jacques Grelet      Mars 1992                        *
- *                      Bruno Buisson       Aout 92                          *
- *                                          Septembre 1992                   *
- *                                          Septembre 1994                   *
- *****************************************************************************/
-#define DEBUG
-#include "mbed.h"
-extern Serial pc;
-
-//#undef DEBUG
-
-#include <debug.h>
-#include <math.h>
-#include <stdlib.h>             // cf. qsort(),fabs()
-
-// ring
-#include "include/ring.h"     // cf. statis.h
-
-// statis
-
-#include "include/bitmsk.h"     // cf. statis.h
-#define _STATIS
-#include "statis.h"
-#undef  _STATIS
-
-/*****************************************************************************
- * classe Mediane_item                                                       *
- *****************************************************************************/
-
-/*****************************************************************************
- *****************************************************************************/
-void Mediane_item::raz( void )
-{
- valeur = FLOAT_ERREUR;
- indice = 0;
-}
-
-/*****************************************************************************
- *****************************************************************************/
-Mediane_item::Mediane_item( void )
-{
- raz();
-}
-
-/*****************************************************************************
- * fonction utilitaire de qsort(),donc pas membre de classe                  *
- * si a < b retourne -1                                                      *
- * si a = b           0                                                      *
- * si a > b           1                                                      *
- *****************************************************************************/
-static int compare( const void *a,const void *b )
-{
- register float c = ((Mediane_item *)a)->valeur - ((Mediane_item *)b)->valeur;
-
- return( ( c == 0.0 ) ? 0 : ( ( c > 0.0 ) ? 1 : -1 ) );
-}
-
-/*****************************************************************************
- * classe Mediane                                                            *
- *****************************************************************************/
-
-/*****************************************************************************
- * n_elem est forcement impair (protege par Statis_data::mediane())          *
- *****************************************************************************/
-Mediane_item &Mediane::mediane( Mediane_item list[],unsigned n_elem )
-{
- switch( n_elem ) {
-   case  1 : return( list[ 0 ] );
-   default : qsort( (Mediane_item *)list,n_elem,sizeof( list[ 0 ] ),compare );
-             return( list[ ( n_elem - 1 ) / 2 ] );
- }
-}
-
-/*****************************************************************************
- * classe Mediane_circ                                                       *
- *****************************************************************************/
-
-/*****************************************************************************
- * n_elem est forcement impair (protege par Statis_data::mediane())          *
- *****************************************************************************/
-Mediane_item &Mediane_circ::mediane( Mediane_item list[],unsigned n_elem )
-{
- int           delta_nord,
-               delta_sud,
-               borne_25,
-               borne_75;
- Mediane_item *result;
-
- if( n_elem == 1 ) return( list[ 0 ] );
- qsort( (Mediane_item *)list,n_elem,sizeof( list[ 0 ] ),compare );
- borne_25   =     n_elem / 4;           // 25%
- borne_75   = 3 * n_elem / 4;           // 75%
- delta_nord = int( list[ borne_75 ].valeur - list[ borne_25 ].valeur );
- delta_sud  = abs( delta_nord - (int)(int)maxi );
- if( delta_sud < delta_nord ) {         // si plus de 50% de valeurs dans
-   for( unsigned i = 0; i < n_elem; i++ )   // le nord, on change de repere
-   if( list[ i ].valeur > moitie && list[ i ].valeur < maxi )   //  180/360
-     list[ i ].valeur -= maxi;                  // -180/180
-   qsort( (Mediane_item *)list,n_elem,sizeof( list[ 0 ] ),compare );
- }
- result = &list[ ( n_elem - 1 ) / 2 ];
- if( result->valeur < 0 ) result->valeur += maxi;
- return( *result );
-}
-
-/*****************************************************************************
- *****************************************************************************/
-Mediane_circ::Mediane_circ( float a_maxi )
-{
- moitie = ( maxi = fabs( a_maxi ) ) / 2;
-}
-
-/*****************************************************************************
- * classe Statis_data                                                        *
- *****************************************************************************/
-
-/*****************************************************************************
- *****************************************************************************/
-bool Statis_data::verifie( float &val )
-{
- if( ( borne_inf == borne_sup ) || ( val >= borne_inf && val <= borne_sup ) )
-   return( true );
- val = FLOAT_ERREUR;
- return( false );
-}
-
-/*****************************************************************************
- *****************************************************************************/
-Mediane_item *Statis_data::cons_liste( void )
-{
- for( unsigned i = 0; i < n_elem; i++ ) {
-   mediane_liste[ i ].indice = i;
-   mediane_liste[ i ].valeur = ring.list[ i ];
- }
- return( mediane_liste );
-}
-
-/*****************************************************************************
- *****************************************************************************/
-bool Statis_data::mediane( void )
-{
- if( !mediane_methode || n_elem == 0 ) {
-   med.raz();
-   return( false );
- }
- med = mediane_methode->mediane( cons_liste(),
-                                 ( n_elem % 2 == 0 ) ? n_elem - 1 : n_elem );
- return( verifie( med.valeur ) );
-}
-
-/*****************************************************************************
- *****************************************************************************/
-bool Statis_data::moyenne( void )
-{
- if( n_elem == 0 ) {
-   moy = FLOAT_ERREUR;
-   return( false );
- }
- moy = 0;
- for( unsigned i = 0; i < n_elem; moy += ring.list[ i++ ] );
- moy /= (float) n_elem;
- return( verifie( moy ) );
-}
-
-/*****************************************************************************
- *****************************************************************************/
-bool Statis_data::ecart_type( void )
-{
- float      somme_xi_carre = 0.0,
-             somme_xi       = 0.0,
-             x_bar          = 0.0;
- float *ptxi;
- unsigned    i;
-
- switch( n_elem ) {
-   case  0 :
-   case  1 :
-   case  2 : ecart = FLOAT_ERREUR;
-             return( false );
-   default : for( i = 0,ptxi = ring.list; i < n_elem;
-                  i++,ptxi++ ) {
-               somme_xi       += *ptxi;
-               somme_xi_carre += *ptxi * *ptxi;
-             }
-             x_bar = somme_xi / (float) n_elem;
-             ecart = sqrt( fabs( somme_xi_carre / (float) n_elem -
-                                 x_bar * x_bar                      ) );
-             return( true );
- }
-}
-
-/*****************************************************************************
- *****************************************************************************/
-void Statis_data::calcule( void )
-{
- DPRINTF( ("\r\nStatis::calcule:stat_on=%u,calculs=%x\r\n",stat_on,calculs) );
- if( stat_on ) {
-   n_elem = ring.store();
-   DPRINTF( ("n_elem=%u.",n_elem) );
-   if( calculs & STAT_MED     ) mediane();
-   if( calculs & STAT_MOYENNE ) {
-     moyenne();
-     if( calculs & STAT_ECART_TYPE ) ecart_type();
-   }
- }
- else {
-   ecart      = 0;
-   moy        =
-   med.valeur = ( n_elem > 0 ) ? instant : FLOAT_ERREUR;
-   med.indice = 0;
- }
- DPRINTF( ("med=%5.4g,moy=%5.4g,instant=%5.4g\r\n",
-           med.valeur,moy,instant) );
- n_elem = 0;
-}
-
-/*****************************************************************************
- *****************************************************************************/
-float Statis_data::put( float val )
-{
- instant = val;
- if( stat_on ) ring.put( instant );
- else          n_elem = 1;
- return( instant );
-}
-
-/*****************************************************************************
- *****************************************************************************/
-Statis_data::Statis_data( BITMSK calc,unsigned taille,
-                          float b_inf /*= 0*/,float b_sup /*= 0*/ )
-           : ring(        taille ),
-             med()
-{      
- moy             =
- ecart           =
- instant         = FLOAT_ERREUR;
- borne_inf       = b_inf;
- borne_sup       = b_sup;
- n_elem          = 0;
- 
- stat_on = taille > 1 ? true : false;
- if( stat_on ) {
-//   init_ring_d( &ring,taille );
-   mediane_methode = ( ( calculs = calc ) & STAT_MED_NORM )
-                         ? new Mediane
-                         : ( calc & STAT_MED_CIRC ) ? new Mediane_circ( b_sup )
-                                                    : NULL;
-   if( mediane_methode )                                                 
-     mediane_liste = new Mediane_item[ taille ];
-   else
-     mediane_liste = NULL;
- }
- else {
-   mediane_methode = NULL;
-   mediane_liste   = NULL;
- }
-}
-
-/*****************************************************************************
- *****************************************************************************/
-Statis_data::~Statis_data()
-{
- if( stat_on ) {
-//   term_ring_d( &ring );
-   if( mediane_methode ) delete mediane_methode;
-   if( mediane_liste   ) delete [] mediane_liste;
- }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/statis.lib	Sun Dec 02 16:38:15 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/greletj/code/statis/#27019c77bf90
--- a/temperatureSensor.cpp	Wed Nov 28 18:48:22 2012 +0000
+++ b/temperatureSensor.cpp	Sun Dec 02 16:38:15 2012 +0000
@@ -36,9 +36,9 @@
     _filter.put( _temperature );
 }
 
-void    temperatureSensor::calcule(void)
+void temperatureSensor::calcule(void)
 {
-    _filter.calcule();
+    _n_elem = _filter.calcule();
 }
 
 // return temperature measurement
@@ -55,7 +55,7 @@
 
 unsigned temperatureSensor::n_element(void)
 {
-    return _filter.n_elem;
+    return _n_elem;
 }
 
 float temperatureSensor::moyenne(void)
--- a/util.cpp	Wed Nov 28 18:48:22 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-// util.cpp
-
-#include <string.h>
-//#include <sys/types.h>
-#include <time.h>
-#include <math.h>
-#include <ctype.h>
-#include "util.h"
-
-
-#define COMPACT 0   /* Supprime les blancs a la lecture du descripteur   */
-#define CONT_CHAR '\\'  /* Caractere de continuation au milieu d'un champs   */
-#define TOKEN_SIZE 240      // Taille maxi d'un element du descripteur
-
-
-/*****************************************************************************
- *****************************************************************************/
-/*
-booleen Delais::claque( void ){
-  time( &tloc );
-  if( ( tloc - tick ) < arme )
-    return( FALSE );
-  else{
-    tick = tloc;
-    return( TRUE );
-  }
-}
-*/
-
-/*****************************************************************************
- *****************************************************************************/
-/*
-Delais::Delais( long nb ){
-  arme = nb;
-  tick = time( &tloc );
-}
-*/
-/*****************************************************************************
- Convertit la position exprimee en degres/minutes en degres decimaux
- lat = -1328.837 -> -13.4806
- *****************************************************************************/
-double convert_position( double data )
-{
-    double integer;
-    double dec;
-
-    dec = (double)( modf( data / 100.0 , &integer ) );
-    dec /= 0.60;
-
-    data = ( (double)( integer ) + dec ) * 100000.0;
-    return( rint( data ) / 100000.0 );
-}
-
-/*****************************************************************************
- Convertit le temps date/heure en jour julien decimal
- *****************************************************************************/
-double temps( unsigned jour_julien, double heure_decimal )
-{
-    double heure,
-           minute,
-           seconde,
-           dec;
-
-    dec = modf( heure_decimal / 100.0 , &heure );
-    seconde = ( modf( dec * 100.0 , &minute ) );
-    return( (double)jour_julien + ( ( (heure * 3600.0) + (minute * 60.0 ) + seconde) / 86400.0 ) );
-}
-
-
-/*****************************************************************************
- *****************************************************************************/
-STRING *gen_str( unsigned taille /*= 80*/ )
-{
-    static char    liste_str[ MAX_CHAR_POOL ];
-    static STRING *courant                    = (STRING *) &liste_str;
-    STRING        *retour;
-
-    ++taille;              // Pour le \0 en plus
-    if( *courant + taille >= liste_str + MAX_CHAR_POOL ) {
-        courant = (STRING *) &liste_str;
-    }
-    retour  = courant;
-    memset( *retour,'\0',taille );     // Initialise la zone avec \0
-    courant = (STRING *) ( (char *) courant + taille );    // Bon deplacement
-    return( retour );
-}