AM2321 library
Dependents: mbed_AM2321_copy mbed_AM2321
See http://developer.mbed.org/users/yasuyuki/notebook/AM2321/
Revision 1:39f20504d5c5, committed 2015-07-10
- Comitter:
- yasuyuki
- Date:
- Fri Jul 10 14:59:04 2015 +0000
- Parent:
- 0:3656aea4e6f6
- Commit message:
- minus
Changed in this revision
diff -r 3656aea4e6f6 -r 39f20504d5c5 AM2321.cpp --- a/AM2321.cpp Wed Oct 08 02:48:36 2014 +0000 +++ b/AM2321.cpp Fri Jul 10 14:59:04 2015 +0000 @@ -37,7 +37,7 @@ } -int AM2321::humidity() +unsigned short AM2321::humidity() { // get hum @@ -48,14 +48,18 @@ } -int AM2321::temperature() +signed short AM2321::temperature() { // get temp get(); temp.byte.HB=buf[4]; temp.byte.LB=buf[5]; - return temp.Val; + if(temp.Val&0x8000){ + temp.Val&=0x7FFF; + temp.Val=0xFFFF-temp.Val+1; + } + return temp.S; }
diff -r 3656aea4e6f6 -r 39f20504d5c5 AM2321.h --- a/AM2321.h Wed Oct 08 02:48:36 2014 +0000 +++ b/AM2321.h Fri Jul 10 14:59:04 2015 +0000 @@ -22,8 +22,8 @@ AM2321 (I2C& p_i2c); void get(); - int humidity(); - int temperature(); + unsigned short humidity(); + signed short temperature(); protected: @@ -38,3 +38,4 @@ #endif /* AM2321_H_ */ +
diff -r 3656aea4e6f6 -r 39f20504d5c5 typedef.h --- a/typedef.h Wed Oct 08 02:48:36 2014 +0000 +++ b/typedef.h Fri Jul 10 14:59:04 2015 +0000 @@ -19,6 +19,7 @@ { WORD Val; BYTE v[2]; + signed short S; struct { BYTE LB;