const  SI1145_PARAM_QUERY = &H80
const  SI1145_PARAM_SET = &HA0
const  SI1145_NOP = &H0
const  SI1145_RESET    = &H01
const  SI1145_BUSADDR    = &H02
const  SI1145_PS_FORCE    = &H05
const  SI1145_ALS_FORCE    = &H06
const  SI1145_PSALS_FORCE   = &H07
const  SI1145_PS_PAUSE    = &H09
const  SI1145_ALS_PAUSE    = &H0A
const  SI1145_PSALS_PAUSE    = &HB
const  SI1145_PS_AUTO    = &H0D
const  SI1145_ALS_AUTO   = &H0E
const  SI1145_PSALS_AUTO = &H0F
const  SI1145_GET_CAL    = &H12

' Parameters 
const  SI1145_PARAM_I2CADDR = &H00
const  SI1145_PARAM_CHLIST   = &H01
const  SI1145_PARAM_CHLIST_ENUV = &H80
const  SI1145_PARAM_CHLIST_ENAUX = &H40
const  SI1145_PARAM_CHLIST_ENALSIR = &H20
const  SI1145_PARAM_CHLIST_ENALSVIS = &H10
const  SI1145_PARAM_CHLIST_ENPS1 = &H01
const  SI1145_PARAM_CHLIST_ENPS2 = &H02
const  SI1145_PARAM_CHLIST_ENPS3 = &H04

const  SI1145_PARAM_PSLED12SEL   = &H02
const  SI1145_PARAM_PSLED12SEL_PS2NONE = &H00
const  SI1145_PARAM_PSLED12SEL_PS2LED1 = &H10
const  SI1145_PARAM_PSLED12SEL_PS2LED2 = &H20
const  SI1145_PARAM_PSLED12SEL_PS2LED3 = &H40
const  SI1145_PARAM_PSLED12SEL_PS1NONE = &H00
const  SI1145_PARAM_PSLED12SEL_PS1LED1 = &H01
const  SI1145_PARAM_PSLED12SEL_PS1LED2 = &H02
const  SI1145_PARAM_PSLED12SEL_PS1LED3 = &H04

const  SI1145_PARAM_PSLED3SEL   = &H03
const  SI1145_PARAM_PSENCODE    = &H05
const  SI1145_PARAM_ALSENCODE   = &H06

const  SI1145_PARAM_PS1ADCMUX   = &H07
const  SI1145_PARAM_PS2ADCMUX   = &H08
const  SI1145_PARAM_PS3ADCMUX   = &H09
const  SI1145_PARAM_PSADCOUNTER   = &H0A
const  SI1145_PARAM_PSADCGAIN = &H0B
const  SI1145_PARAM_PSADCMISC = &H0C
const  SI1145_PARAM_PSADCMISC_RANGE = &H20
const  SI1145_PARAM_PSADCMISC_PSMODE = &H04

const  SI1145_PARAM_ALSIRADCMUX   = &H0E
const  SI1145_PARAM_AUXADCMUX   = &H0F

const  SI1145_PARAM_ALSVISADCOUNTER   = &H10
const  SI1145_PARAM_ALSVISADCGAIN = &H11
const  SI1145_PARAM_ALSVISADCMISC = &H12
const  SI1145_PARAM_ALSVISADCMISC_VISRANGE = &H20

const  SI1145_PARAM_ALSIRADCOUNTER   = &H1D
const  SI1145_PARAM_ALSIRADCGAIN = &H1E
const  SI1145_PARAM_ALSIRADCMISC = &H1F
const  SI1145_PARAM_ALSIRADCMISC_RANGE = &H20

const  SI1145_PARAM_ADCCOUNTER_511CLK = &H70

const  SI1145_PARAM_ADCMUX_SMALLIR  = &H00
const  SI1145_PARAM_ADCMUX_LARGEIR  = &H03



' REGISTERS 
const  SI1145_REG_PARTID  = &H00
const  SI1145_REG_REVID  = &H01
const  SI1145_REG_SEQID  = &H02

const  SI1145_REG_INTCFG  = &H03
const  SI1145_REG_INTCFG_INTOE = &H01
const  SI1145_REG_INTCFG_INTMODE = &H02

const  SI1145_REG_IRQEN  = &H04
const  SI1145_REG_IRQEN_ALSEVERYSAMPLE = &H01
const  SI1145_REG_IRQEN_PS1EVERYSAMPLE = &H04
const  SI1145_REG_IRQEN_PS2EVERYSAMPLE = &H08
const  SI1145_REG_IRQEN_PS3EVERYSAMPLE = &H10


const  SI1145_REG_IRQMODE1 = &H05
const  SI1145_REG_IRQMODE2 = &H06

const  SI1145_REG_HWKEY  = &H07
const  SI1145_REG_MEASRATE0 = &H08
const  SI1145_REG_MEASRATE1  = &H09
const  SI1145_REG_PSRATE  = &H0A
const  SI1145_REG_PSLED21  = &H0F
const  SI1145_REG_PSLED3  = &H10
const  SI1145_REG_UCOEFF0  = &H13
const  SI1145_REG_UCOEFF1  = &H14
const  SI1145_REG_UCOEFF2  = &H15
const  SI1145_REG_UCOEFF3  = &H16
const  SI1145_REG_PARAMWR  = &H17
const  SI1145_REG_COMMAND  = &H18
const  SI1145_REG_RESPONSE  = &H20
const  SI1145_REG_IRQSTAT  = &H21
const  SI1145_REG_IRQSTAT_ALS  = &H01

const  SI1145_REG_ALSVISDATA0 = &H22
const  SI1145_REG_ALSVISDATA1 = &H23
const  SI1145_REG_ALSIRDATA0 = &H24
const  SI1145_REG_ALSIRDATA1 = &H25
const  SI1145_REG_PS1DATA0 = &H26
const  SI1145_REG_PS1DATA1 = &H27
const  SI1145_REG_PS2DATA0 = &H28
const  SI1145_REG_PS2DATA1 = &H29
const  SI1145_REG_PS3DATA0 = &H2A
const  SI1145_REG_PS3DATA1 = &H2B
const  SI1145_REG_UVINDEX0 = &H2C
const  SI1145_REG_UVINDEX1 = &H2D
const  SI1145_REG_PARAMRD = &H2E
const  SI1145_REG_CHIPSTAT = &H30

const  SI1145_ADDR = &H60








i2c open 400,1000 'device will run at full speed 



class Adafruit_SI1145  {
 public:
  Adafruit_SI1145(void);
  boolean begin();
  void reset();

  uint16_t readUV();
  uint16_t readIR();
  uint16_t readVisible();
  uint16_t readProx();

 private:
  uint16_t read16(uint8_t addr);
  uint8_t read8(uint8_t addr);
  void write8(uint8_t reg, uint8_t val);
  uint8_t readParam(uint8_t p);
  uint8_t writeParam(uint8_t p, uint8_t v);

  uint8_t _addr;
};
