library for S11059 color sensor with SoftI2C

Dependencies:   SoftwareI2C

Committer:
maruta
Date:
Fri May 15 07:21:49 2015 +0000
Revision:
0:96df923acec7
initial commit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maruta 0:96df923acec7 1 #include "S11059-SoftI2C.h"
maruta 0:96df923acec7 2
maruta 0:96df923acec7 3 S11059::S11059(PinName sda, PinName scl): _i2c(sda,scl){
maruta 0:96df923acec7 4 wait(0.2);
maruta 0:96df923acec7 5 _i2c.setFrequency(400000);
maruta 0:96df923acec7 6 _i2c.initialise();
maruta 0:96df923acec7 7 wait(0.2);
maruta 0:96df923acec7 8 _i2c.randomWrite(S11059_ADDR,0x00,0x8a);
maruta 0:96df923acec7 9 _i2c.randomWrite(S11059_ADDR,0x00,0x0a);
maruta 0:96df923acec7 10 wait(1);
maruta 0:96df923acec7 11 }
maruta 0:96df923acec7 12
maruta 0:96df923acec7 13 void S11059::update(){
maruta 0:96df923acec7 14 uint8_t buf[8];
maruta 0:96df923acec7 15 _i2c.randomRead(S11059_ADDR,0x03,buf,8);
maruta 0:96df923acec7 16 r=buf[0]<<8|buf[1];
maruta 0:96df923acec7 17 g=buf[2]<<8|buf[3];
maruta 0:96df923acec7 18 b=buf[4]<<8|buf[5];
maruta 0:96df923acec7 19 }
maruta 0:96df923acec7 20
maruta 0:96df923acec7 21 S11059::~S11059(){
maruta 0:96df923acec7 22 }