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.
Dependencies: ESP8266 Servo TextLCD mbed
Fork of ACS712HelloWorldDemo by
Diff: ACS712.h
- Revision:
- 4:f6c160553ca3
- Parent:
- 3:9cae7baf7ccd
- Child:
- 5:a022ca4aaa1e
diff -r 9cae7baf7ccd -r f6c160553ca3 ACS712.h
--- a/ACS712.h Sun Mar 13 17:14:35 2016 +0000
+++ b/ACS712.h Sun Mar 13 17:29:44 2016 +0000
@@ -45,7 +45,7 @@
* @return current value in amps
*/
float read();
- float operator=(ACS712&);
+ ACS712& operator=(const ACS712&);
/** Read the value of the measured current in amps
* Allows the ACS712 object to be used in a float context
@@ -62,26 +62,21 @@
};
-ACS712::ACS712(PinName _pin, float voltDivRatio, short type) : sensor(_pin){
+ACS712::ACS712(PinName _pin, float voltDivRatio, short sensorType) : sensor(_pin){
ratio = voltDivRatio;
- this.type = type;
+ type = sensorType;
}
float ACS712::translate(float val){
switch(type){
case 5:
return (val*ratio - 2.5*ratio)/(.185*ratio);
- break;
case 20:
return (val*ratio - 2.5*ratio)/(.1*ratio);
- break;
case 30:
return (val*ratio - 2.5*ratio)/(.066*ratio);
- break;
default:
return 999;
- break;
-
}
}
@@ -90,9 +85,9 @@
return ACS712::translate(sensor * 3.3);
}
-ACS712& ACS712::operator=(ACS712& rhs){
+ACS712& ACS712::operator=(const ACS712& rhs){
sensor = rhs.sensor;
ratio = rhs.ratio;
type = rhs.type;
- return this;
+ return *this;
}
