808
Dependents: Chromatograph_Mobile
Diff: lm35.cpp
- Revision:
- 0:48636371d2d3
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