Skip to content

Commit bb9cb59

Browse files
committed
fix milesburton#97 - replace char with int8_t to make type explicitly signed
1 parent 736506f commit bb9cb59

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

DallasTemperature.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ float DallasTemperature::rawToFahrenheit(int16_t raw) {
636636
// accepts a float, but the alarm resolution will ignore anything
637637
// after a decimal point. valid range is -55C - 125C
638638
void DallasTemperature::setHighAlarmTemp(const uint8_t* deviceAddress,
639-
char celsius) {
639+
int8_t celsius) {
640640

641641
// return when stored value == new value
642642
if (getHighAlarmTemp(deviceAddress) == celsius)
@@ -660,7 +660,7 @@ void DallasTemperature::setHighAlarmTemp(const uint8_t* deviceAddress,
660660
// accepts a float, but the alarm resolution will ignore anything
661661
// after a decimal point. valid range is -55C - 125C
662662
void DallasTemperature::setLowAlarmTemp(const uint8_t* deviceAddress,
663-
char celsius) {
663+
int8_t celsius) {
664664

665665
// return when stored value == new value
666666
if (getLowAlarmTemp(deviceAddress) == celsius)
@@ -680,24 +680,24 @@ void DallasTemperature::setLowAlarmTemp(const uint8_t* deviceAddress,
680680

681681
}
682682

683-
// returns a char with the current high alarm temperature or
683+
// returns a int8_t with the current high alarm temperature or
684684
// DEVICE_DISCONNECTED for an address
685-
char DallasTemperature::getHighAlarmTemp(const uint8_t* deviceAddress) {
685+
int8_t DallasTemperature::getHighAlarmTemp(const uint8_t* deviceAddress) {
686686

687687
ScratchPad scratchPad;
688688
if (isConnected(deviceAddress, scratchPad))
689-
return (char) scratchPad[HIGH_ALARM_TEMP];
689+
return (int8_t) scratchPad[HIGH_ALARM_TEMP];
690690
return DEVICE_DISCONNECTED_C;
691691

692692
}
693693

694-
// returns a char with the current low alarm temperature or
694+
// returns a int8_t with the current low alarm temperature or
695695
// DEVICE_DISCONNECTED for an address
696-
char DallasTemperature::getLowAlarmTemp(const uint8_t* deviceAddress) {
696+
int8_t DallasTemperature::getLowAlarmTemp(const uint8_t* deviceAddress) {
697697

698698
ScratchPad scratchPad;
699699
if (isConnected(deviceAddress, scratchPad))
700-
return (char) scratchPad[LOW_ALARM_TEMP];
700+
return (int8_t) scratchPad[LOW_ALARM_TEMP];
701701
return DEVICE_DISCONNECTED_C;
702702

703703
}
@@ -728,7 +728,7 @@ void DallasTemperature::resetAlarmSearch() {
728728
bool DallasTemperature::alarmSearch(uint8_t* newAddr) {
729729

730730
uint8_t i;
731-
char lastJunction = -1;
731+
int8_t lastJunction = -1;
732732
uint8_t done = 1;
733733

734734
if (alarmSearchExhausted)
@@ -800,14 +800,14 @@ bool DallasTemperature::hasAlarm(const uint8_t* deviceAddress) {
800800
ScratchPad scratchPad;
801801
if (isConnected(deviceAddress, scratchPad)) {
802802

803-
char temp = calculateTemperature(deviceAddress, scratchPad) >> 7;
803+
int8_t temp = calculateTemperature(deviceAddress, scratchPad) >> 7;
804804

805805
// check low alarm
806-
if (temp <= (char) scratchPad[LOW_ALARM_TEMP])
806+
if (temp <= (int8_t) scratchPad[LOW_ALARM_TEMP])
807807
return true;
808808

809809
// check high alarm
810-
if (temp >= (char) scratchPad[HIGH_ALARM_TEMP])
810+
if (temp >= (int8_t) scratchPad[HIGH_ALARM_TEMP])
811811
return true;
812812
}
813813

DallasTemperature.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef DallasTemperature_h
22
#define DallasTemperature_h
33

4-
#define DALLASTEMPLIBVERSION "3.7.7" // To be deprecated
4+
#define DALLASTEMPLIBVERSION "3.7.8" // To be deprecated
55

66
// This library is free software; you can redistribute it and/or
77
// modify it under the terms of the GNU Lesser General Public
@@ -135,20 +135,20 @@ class DallasTemperature {
135135
typedef void AlarmHandler(const uint8_t*);
136136

137137
// sets the high alarm temperature for a device
138-
// accepts a char. valid range is -55C - 125C
139-
void setHighAlarmTemp(const uint8_t*, char);
138+
// accepts a int8_t. valid range is -55C - 125C
139+
void setHighAlarmTemp(const uint8_t*, int8_t);
140140

141141
// sets the low alarm temperature for a device
142-
// accepts a char. valid range is -55C - 125C
143-
void setLowAlarmTemp(const uint8_t*, char);
142+
// accepts a int8_t. valid range is -55C - 125C
143+
void setLowAlarmTemp(const uint8_t*, int8_t);
144144

145-
// returns a signed char with the current high alarm temperature for a device
145+
// returns a int8_t with the current high alarm temperature for a device
146146
// in the range -55C - 125C
147-
char getHighAlarmTemp(const uint8_t*);
147+
int8_t getHighAlarmTemp(const uint8_t*);
148148

149-
// returns a signed char with the current low alarm temperature for a device
149+
// returns a int8_t with the current low alarm temperature for a device
150150
// in the range -55C - 125C
151-
char getLowAlarmTemp(const uint8_t*);
151+
int8_t getLowAlarmTemp(const uint8_t*);
152152

153153
// resets internal variables used for the alarm search
154154
void resetAlarmSearch(void);
@@ -239,7 +239,7 @@ class DallasTemperature {
239239

240240
// required for alarmSearch
241241
uint8_t alarmSearchAddress[8];
242-
char alarmSearchJunction;
242+
int8_t alarmSearchJunction;
243243
uint8_t alarmSearchExhausted;
244244

245245
// the alarm handler function pointer

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"authors": "Paul Stoffregen",
3535
"frameworks": "arduino"
3636
},
37-
"version": "3.7.7",
37+
"version": "3.7.8",
3838
"frameworks": "arduino",
3939
"platforms": "*"
4040
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=DallasTemperature
2-
version=3.7.7
2+
version=3.7.8
33
author=Miles Burton <miles@mnetcs.com>, Tim Newsome <nuisance@casualhacker.net>, Guil Barros <gfbarros@bappos.com>, Rob Tillaart <rob.tillaart@gmail.com>
44
maintainer=Miles Burton <miles@mnetcs.com>
55
sentence=Arduino Library for Dallas Temperature ICs

0 commit comments

Comments
 (0)