Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 8:c1551694a71a, committed 2018-03-22
- Comitter:
- dzoni
- Date:
- Thu Mar 22 19:09:19 2018 +0000
- Parent:
- 6:5beda7c318d5
- Child:
- 9:af77e61b4845
- Commit message:
- Refactoring - coding rules.
Changed in this revision
| Distance_HC_SR04.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Distance_HC_SR04.cpp Tue Dec 22 12:00:15 2015 +0000
+++ b/Distance_HC_SR04.cpp Thu Mar 22 19:09:19 2018 +0000
@@ -75,11 +75,11 @@
*
*/
void Distance_HC_SR04::trigger(void) {
- if (_state == IDLE && _echo == 0) {
+ if ((IDLE == _state) && (0 = _echo) {
_trig = 1;
wait_us(TRIG_PULSE_US);
_trig = 0;
- if (_echo == 0) {
+ if (0 == _echo) {
_state = STARTED;
_timeout.attach_us(this, &Distance_HC_SR04::_tout, TIMEOUT_DELAY_US);
_echo.rise(this, &Distance_HC_SR04::_rising);
@@ -89,7 +89,7 @@
}
}
- if (_state == IDLE) {
+ if (IDLE == _state) {
_state = ERROR_SIG;
_ticks_us = 0;
}
@@ -156,7 +156,7 @@
* void -
*/
void Distance_HC_SR04::_tout(void) {
- if (_state == STARTED)
+ if (STARTED == _state)
_state = TIMEOUT;
}
@@ -167,7 +167,7 @@
* void -
*/
void Distance_HC_SR04::_rising(void) {
- if (_state == STARTED) {
+ if (STARTED == _state) {
_timer.start();
}
}
@@ -179,7 +179,7 @@
* void -
*/
void Distance_HC_SR04::_falling(void) {
- if (_state == STARTED) {
+ if (STARTED == _state) {
_timer.stop();
_ticks_us = _timer.read_us();