808

Committer:
nikmaos
Date:
Sat Aug 08 18:22:59 2020 +0000
Revision:
1:2c55cbb1e270
Parent:
0:48636371d2d3
808

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vitlog 0:48636371d2d3 1 #include "lm35.h"
vitlog 0:48636371d2d3 2 Ticker lm35_temp;
vitlog 0:48636371d2d3 3 AnalogIn LMtemp(A0);
vitlog 0:48636371d2d3 4 uint16_t cnt=KF;
vitlog 0:48636371d2d3 5 float sum;
vitlog 0:48636371d2d3 6 LM35_t LM35_0;
vitlog 0:48636371d2d3 7 void read()
vitlog 0:48636371d2d3 8 {
vitlog 0:48636371d2d3 9 if(cnt--){
vitlog 0:48636371d2d3 10 sum+=330*LMtemp.read();
vitlog 0:48636371d2d3 11 }
vitlog 0:48636371d2d3 12 else {//сообщить о готовности результата и записать результат в переменную.
vitlog 0:48636371d2d3 13 LM35_0.ready=1;
vitlog 0:48636371d2d3 14 LM35_0.temp=sum/KF;
vitlog 0:48636371d2d3 15 sum=0;
vitlog 0:48636371d2d3 16 cnt=KF;
vitlog 0:48636371d2d3 17 }
vitlog 0:48636371d2d3 18 }
vitlog 0:48636371d2d3 19
vitlog 0:48636371d2d3 20 void LM35_start(float per)
vitlog 0:48636371d2d3 21 {
vitlog 0:48636371d2d3 22 lm35_temp.attach(&read,per/KF);
vitlog 0:48636371d2d3 23 }
vitlog 0:48636371d2d3 24
vitlog 0:48636371d2d3 25 void LM35_stop(void)
vitlog 0:48636371d2d3 26 {
vitlog 0:48636371d2d3 27 lm35_temp.detach();
vitlog 0:48636371d2d3 28 }