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.
Dependents: Chromatograph_Mobile
Revision 0:48636371d2d3, committed 2020-06-22
- Comitter:
- vitlog
- Date:
- Mon Jun 22 09:52:16 2020 +0000
- Commit message:
- Termometer
Changed in this revision
lm35.cpp | Show annotated file Show diff for this revision Revisions of this file |
lm35.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 48636371d2d3 lm35.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lm35.cpp Mon Jun 22 09:52:16 2020 +0000 @@ -0,0 +1,28 @@ +#include "lm35.h" +Ticker lm35_temp; +AnalogIn LMtemp(A0); +uint16_t cnt=KF; +float sum; +LM35_t LM35_0; +void read() +{ + if(cnt--){ + sum+=330*LMtemp.read(); + } + else {//сообщить о готовности результата и записать результат в переменную. + LM35_0.ready=1; + LM35_0.temp=sum/KF; + sum=0; + cnt=KF; + } +} + +void LM35_start(float per) +{ + lm35_temp.attach(&read,per/KF); +} + +void LM35_stop(void) +{ + lm35_temp.detach(); +} \ No newline at end of file
diff -r 000000000000 -r 48636371d2d3 lm35.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lm35.h Mon Jun 22 09:52:16 2020 +0000 @@ -0,0 +1,13 @@ +#ifndef _LM35_H /* Guard against multiple inclusion */ +#define _LM35_H +#include "PerifConfig.h" +#define KF 1000 +typedef struct { + //фильтрованное значение температуры + float temp; + uint8_t ready; + } LM35_t; + extern LM35_t LM35_0; +void LM35_start(float per); +void LM35_stop(void); +#endif \ No newline at end of file