@@ -14,6 +14,32 @@ extern "C" {
1414}
1515#endif
1616
17+ // OneWire commands
18+ #define STARTCONVO 0x44 // Tells device to take a temperature reading and put it on the scratchpad
19+ #define COPYSCRATCH 0x48 // Copy EEPROM
20+ #define READSCRATCH 0xBE // Read EEPROM
21+ #define WRITESCRATCH 0x4E // Write to EEPROM
22+ #define RECALLSCRATCH 0xB8 // Reload from last known
23+ #define READPOWERSUPPLY 0xB4 // Determine if device needs parasite power
24+ #define ALARMSEARCH 0xEC // Query bus for devices with an alarm condition
25+
26+ // Scratchpad locations
27+ #define TEMP_LSB 0
28+ #define TEMP_MSB 1
29+ #define HIGH_ALARM_TEMP 2
30+ #define LOW_ALARM_TEMP 3
31+ #define CONFIGURATION 4
32+ #define INTERNAL_BYTE 5
33+ #define COUNT_REMAIN 6
34+ #define COUNT_PER_C 7
35+ #define SCRATCHPAD_CRC 8
36+
37+ // Device resolution
38+ #define TEMP_9_BIT 0x1F // 9 bit
39+ #define TEMP_10_BIT 0x3F // 10 bit
40+ #define TEMP_11_BIT 0x5F // 11 bit
41+ #define TEMP_12_BIT 0x7F // 12 bit
42+
1743DallasTemperature::DallasTemperature () {}
1844DallasTemperature::DallasTemperature (OneWire* _oneWire)
1945
@@ -200,7 +226,7 @@ bool DallasTemperature::setResolution(const uint8_t* deviceAddress, uint8_t newR
200226
201227 // ensure same behavior as setResolution(uint8_t newResolution)
202228 newResolution = constrain (newResolution, 9 , 12 );
203-
229+
204230 // return when stored value == new value
205231 if (getResolution (deviceAddress) == newResolution) return true ;
206232
@@ -229,7 +255,7 @@ bool DallasTemperature::setResolution(const uint8_t* deviceAddress, uint8_t newR
229255
230256 // without calculation we can always set it to max
231257 bitResolution = max (bitResolution, newResolution);
232-
258+
233259 if (!skipGlobalBitResolutionCalculation && (bitResolution > newResolution)){
234260 bitResolution = newResolution;
235261 DeviceAddress deviceAddr;
@@ -354,15 +380,15 @@ bool DallasTemperature::requestTemperaturesByAddress(const uint8_t* deviceAddres
354380
355381// Continue to check if the IC has responded with a temperature
356382void DallasTemperature::blockTillConversionComplete (uint8_t bitResolution){
357-
383+
358384 int delms = millisToWaitForConversion (bitResolution);
359385 if (checkForConversion && !parasite){
360386 unsigned long now = millis ();
361387 while (!isConversionComplete () && (millis () - delms < now));
362388 } else {
363389 delay (delms);
364390 }
365-
391+
366392}
367393
368394// returns number of milliseconds to wait till conversion is complete (based on IC datasheet)
@@ -622,7 +648,7 @@ void DallasTemperature::setHighAlarmTemp(const uint8_t* deviceAddress, char cels
622648// accepts a float, but the alarm resolution will ignore anything
623649// after a decimal point. valid range is -55C - 125C
624650void DallasTemperature::setLowAlarmTemp (const uint8_t * deviceAddress, char celsius){
625-
651+
626652 // return when stored value == new value
627653 if (getLowAlarmTemp (deviceAddress) == celsius) return ;
628654
0 commit comments