teste de publish
Dependencies: DS1820 HighSpeedAnalogIn devices mbed
Diff: DS18B20_SensorTemperatura.cpp
- Revision:
- 1:0e0967c88590
- Child:
- 2:55b7b466e742
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DS18B20_SensorTemperatura.cpp Thu Mar 30 19:54:09 2017 +0000 @@ -0,0 +1,35 @@ +#include "DS18B20_SensorTemperatura.h" + +DS1820* probe[MAX_PROBES]; +int num_temperatureSensors = 0; +float temperaturas[MAX_PROBES]; + +void inicializaSensoresTemperatura(){ + // Initialize the probe array to DS1820 objects + while(DS1820::unassignedProbe(DATA_PIN)) { + probe[num_temperatureSensors] = new DS1820(DATA_PIN); + num_temperatureSensors++; + if (num_temperatureSensors == MAX_PROBES) + break; + } + printf("Found %d device(s)\r\n\n", num_temperatureSensors); +} + +void refreshSensoresTemperatura(){ + if(num_temperatureSensors){ + probe[0]->convertTemperature(true, DS1820::all_devices); //Start temperature conversion, wait until ready + for (int i = 0; i<num_temperatureSensors; i++){ + temperaturas[i] = probe[i]->temperature(); + printf("Device %d returns %3.1foC\r\n", i, temperaturas[i]); + } + } +} + + /* + while(1) { + probe[0]->convertTemperature(true, DS1820::all_devices); //Start temperature conversion, wait until ready + for (int i = 0; i<num_temperatureSensors; i++) + printf("Device %d returns %3.1foC\r\n", i, probe[i]->temperature()); + wait(1); + } + */ \ No newline at end of file