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:
- 1:4f9effb20c29
- Parent:
- 0:a35011a2fdaa
- Child:
- 2:2b5233355986
--- a/ACS712.h Wed Mar 09 04:19:10 2016 +0000 +++ b/ACS712.h Sun Mar 13 16:43:23 2016 +0000 @@ -7,16 +7,11 @@ float read(); float operator=(ACS712&); - //void sampleInterval(float); - //void sampleFrequency(float); - //void bufferLength(int); - //float[] readBuffer(); + operator float() { return read(); } private: AnalogIn sensor; float translate(float); - //float[] circularBuffer; - //float interval; float ratio; short type; @@ -47,10 +42,12 @@ float ACS712::read(){ - return ACS712::translate(sensor); + return ACS712::translate(sensor * 3.3); } -float ACS712::operator=(ACS712& rhs){ - return rhs.read(); +ACS712& ACS712::operator=(ACS712& rhs){ + sensor = rhs.sensor; + ratio = rhs.ratio; + type = rhs.type; + return this; } -