Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation errors with ESP8266 toolchain. #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions PingSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ PingSerial::read (uint8_t count=1)
} else {
for (i = 0; i < count; i++) {
_hw_serial->read();
}
}
}
} else {
if (count == 1) {
Expand Down Expand Up @@ -159,7 +159,7 @@ PingSerial::data_available (void)
request_distance();
} else {
// Got valid data
_max_op_duration_ms = max(millis() - _op_started, _max_op_duration_ms);
_max_op_duration_ms = max(millis() - _op_started, (unsigned long)_max_op_duration_ms);
_distance = (read() * 256) + read();
_distance_pending = FALSE;
_distance_avail = TRUE;
Expand Down Expand Up @@ -192,7 +192,7 @@ PingSerial::data_available (void)
// Increment counter but make sure if we've looped we set it to 1
// (we've lost info, but better than thinking we've had no timeouts)
_timeout_count++;
_timeout_count = max(_timeout_count, 1);
_timeout_count = max(_timeout_count, (uint16_t)1);

if (_hw_serial) {
available = _hw_serial->available();
Expand Down
6 changes: 3 additions & 3 deletions PingSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class PingSerial {

// Reads data from serial connection to US-100.
// Returns value with DISTANCE or TEMPERATURE flags set indicating which values are available
// (not necessarily just received, the flags are cleared only when the values are retrieved).
// (not necessarily just received, the flags are cleared only when the values are retrieved).
byte data_available(void);

// Get the stored values, if data_available() indicates a value is available. Returns zero on error (which could be a valid temperature).
Expand Down Expand Up @@ -112,7 +112,7 @@ class PingSerial {
uint16_t _distance = 0; // Distance is always positive, max (255 * 256 + 255) = 65535
int _temperature = 0; // Temperature returned is (byte) - 45 (so ranges from -45 to 256-45)

// If values are out of range then distance returned will be 0 or UINT16_MAX respectively
// If values are out of range then distance returned will be 0 or UINT16_MAX respectively
uint16_t _min_mm_distance = 0;
uint16_t _max_mm_distance = UINT16_MAX;

Expand All @@ -128,4 +128,4 @@ class PingSerial {
bool _distance_request_queued = FALSE;
bool _temperature_request_queued = FALSE;
};
#endif __PINGSERIAL_H__
#endif // __PINGSERIAL_H__