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.
Diff: main.cpp
- Revision:
- 7:596c792ff02d
- Parent:
- 6:95195b0995dd
diff -r 95195b0995dd -r 596c792ff02d main.cpp
--- 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");
+
}