*** SET 1-Wire Flasher Address from 0x0EE0 to 0x0EC0 **** for more freedom to impleme...
[owSlave2.git] / common / I2C / MAX44009.c
index eabcda6..8ec682d 100644 (file)
 #include "USI_TWI_Master.h"
 #include "MAX44009.h"
 
-double MAX44009getlux()  {
+double MAX44009getlux(uint8_t nr)  {
        volatile uint8_t b1,b2;
-       
+       nr=(nr<<1)&0x02f;
        
        I2c_StartCondition();
-       I2c_WriteByte(0b10010100);
+       I2c_WriteByte(0b10010100|nr);
        I2c_WriteByte(0x03);
        I2c_StartCondition();
-       I2c_WriteByte (0b10010101);
+       I2c_WriteByte (0b10010101|nr);
        b1 =I2c_ReadByte(NO_ACK);
        I2c_StopCondition();
        I2c_StartCondition();
-       I2c_WriteByte(0b10010100);
+       I2c_WriteByte(0b10010100|nr);
        I2c_WriteByte(0x04);
        I2c_StartCondition();
-       I2c_WriteByte (0b10010101);
+       I2c_WriteByte (0b10010101|nr);
        b2 =I2c_ReadByte(NO_ACK);
        I2c_StopCondition();
        uint8_t exponent = (b1 & 0xF0) >> 4;// upper four bits of high byte register