teste de publish
Dependencies: DS1820 HighSpeedAnalogIn devices mbed
DS18B20_SensorTemperatura.cpp@15:0f78bf9c13ec, 2017-12-27 (annotated)
- Committer:
- brunofgc
- Date:
- Wed Dec 27 13:10:09 2017 +0000
- Revision:
- 15:0f78bf9c13ec
- Parent:
- 7:ae9c47f62946
- Child:
- 18:1eefda1f7736
Vers?o otimizada quanto ? resposta do webbrowser e demais funcionalidades executadas via "*ServerCommand*/". Bootloader com problema. Vers?o instalada no HSR.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
brunofgc | 1:0e0967c88590 | 1 | #include "DS18B20_SensorTemperatura.h" |
brunofgc | 1:0e0967c88590 | 2 | |
brunofgc | 1:0e0967c88590 | 3 | DS1820* probe[MAX_PROBES]; |
brunofgc | 1:0e0967c88590 | 4 | int num_temperatureSensors = 0; |
brunofgc | 1:0e0967c88590 | 5 | float temperaturas[MAX_PROBES]; |
brunofgc | 1:0e0967c88590 | 6 | |
brunofgc | 1:0e0967c88590 | 7 | void inicializaSensoresTemperatura(){ |
brunofgc | 1:0e0967c88590 | 8 | // Initialize the probe array to DS1820 objects |
brunofgc | 1:0e0967c88590 | 9 | while(DS1820::unassignedProbe(DATA_PIN)) { |
brunofgc | 1:0e0967c88590 | 10 | probe[num_temperatureSensors] = new DS1820(DATA_PIN); |
brunofgc | 1:0e0967c88590 | 11 | num_temperatureSensors++; |
brunofgc | 1:0e0967c88590 | 12 | if (num_temperatureSensors == MAX_PROBES) |
brunofgc | 1:0e0967c88590 | 13 | break; |
brunofgc | 1:0e0967c88590 | 14 | } |
brunofgc | 15:0f78bf9c13ec | 15 | printf("Found %d device(s)\r\n\n", num_temperatureSensors); |
brunofgc | 15:0f78bf9c13ec | 16 | refreshSensoresTemperatura(); |
brunofgc | 1:0e0967c88590 | 17 | } |
brunofgc | 1:0e0967c88590 | 18 | |
brunofgc | 1:0e0967c88590 | 19 | void refreshSensoresTemperatura(){ |
brunofgc | 2:55b7b466e742 | 20 | float aux; |
brunofgc | 1:0e0967c88590 | 21 | if(num_temperatureSensors){ |
brunofgc | 1:0e0967c88590 | 22 | probe[0]->convertTemperature(true, DS1820::all_devices); //Start temperature conversion, wait until ready |
brunofgc | 1:0e0967c88590 | 23 | for (int i = 0; i<num_temperatureSensors; i++){ |
brunofgc | 2:55b7b466e742 | 24 | if((aux = probe[i]->temperature()) != -1000.0){ |
brunofgc | 2:55b7b466e742 | 25 | temperaturas[i] = aux; |
brunofgc | 2:55b7b466e742 | 26 | } |
brunofgc | 7:ae9c47f62946 | 27 | //printf("Device %d returns %3.1foC\r\n", i, temperaturas[i]); |
brunofgc | 1:0e0967c88590 | 28 | } |
brunofgc | 1:0e0967c88590 | 29 | } |
brunofgc | 1:0e0967c88590 | 30 | } |
brunofgc | 15:0f78bf9c13ec | 31 |