library for S11059 color sensor with SoftI2C
Diff: S11059-SoftI2C.cpp
- Revision:
- 0:96df923acec7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/S11059-SoftI2C.cpp Fri May 15 07:21:49 2015 +0000 @@ -0,0 +1,22 @@ +#include "S11059-SoftI2C.h" + +S11059::S11059(PinName sda, PinName scl): _i2c(sda,scl){ + wait(0.2); + _i2c.setFrequency(400000); + _i2c.initialise(); + wait(0.2); + _i2c.randomWrite(S11059_ADDR,0x00,0x8a); + _i2c.randomWrite(S11059_ADDR,0x00,0x0a); + wait(1); +} + +void S11059::update(){ + uint8_t buf[8]; + _i2c.randomRead(S11059_ADDR,0x03,buf,8); + r=buf[0]<<8|buf[1]; + g=buf[2]<<8|buf[3]; + b=buf[4]<<8|buf[5]; +} + +S11059::~S11059(){ +} \ No newline at end of file