Ethernetwebsoc
Dependencies: C12832_lcd LM75B WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip
LM75B/LM75B.cpp@0:0ed2a7c7190c, 2013-05-31 (annotated)
- Committer:
- GordonSin
- Date:
- Fri May 31 04:09:54 2013 +0000
- Revision:
- 0:0ed2a7c7190c
31/5/2013;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GordonSin | 0:0ed2a7c7190c | 1 | #include "LM75B.h" |
GordonSin | 0:0ed2a7c7190c | 2 | |
GordonSin | 0:0ed2a7c7190c | 3 | LM75B::LM75B(PinName sda, PinName scl) : i2c(sda, scl) |
GordonSin | 0:0ed2a7c7190c | 4 | { |
GordonSin | 0:0ed2a7c7190c | 5 | char cmd[2]; |
GordonSin | 0:0ed2a7c7190c | 6 | cmd[0] = LM75B_Conf; |
GordonSin | 0:0ed2a7c7190c | 7 | cmd[1] = 0x0; |
GordonSin | 0:0ed2a7c7190c | 8 | i2c.write( LM75B_ADDR, cmd, 2); |
GordonSin | 0:0ed2a7c7190c | 9 | } |
GordonSin | 0:0ed2a7c7190c | 10 | |
GordonSin | 0:0ed2a7c7190c | 11 | |
GordonSin | 0:0ed2a7c7190c | 12 | |
GordonSin | 0:0ed2a7c7190c | 13 | LM75B::~LM75B() |
GordonSin | 0:0ed2a7c7190c | 14 | { |
GordonSin | 0:0ed2a7c7190c | 15 | |
GordonSin | 0:0ed2a7c7190c | 16 | } |
GordonSin | 0:0ed2a7c7190c | 17 | |
GordonSin | 0:0ed2a7c7190c | 18 | float LM75B::read() |
GordonSin | 0:0ed2a7c7190c | 19 | { |
GordonSin | 0:0ed2a7c7190c | 20 | char cmd[2]; |
GordonSin | 0:0ed2a7c7190c | 21 | cmd[0] = LM75B_Temp; |
GordonSin | 0:0ed2a7c7190c | 22 | |
GordonSin | 0:0ed2a7c7190c | 23 | i2c.write( LM75B_ADDR, cmd, 1); // Send command string |
GordonSin | 0:0ed2a7c7190c | 24 | i2c.read( LM75B_ADDR, cmd, 2); // Send command string |
GordonSin | 0:0ed2a7c7190c | 25 | return ( float((cmd[0]<<8)|cmd[1]) / 256.0 ); |
GordonSin | 0:0ed2a7c7190c | 26 | } |