code: func (d *TSL2561Driver) CalculateLux(broadband uint16, ir uint16) (lux uint32) {
  	var channel1 uint32
  	var channel0 uint32
  
  	// Set cliplevel and scaling based on integration time
  	clipThreshold, chScale := d.getClipScaling()
  
  	// Saturated sensor
  	if (broadband > clipThreshold) || (ir > clipThreshold) {
  		return 65536
  	}
  
  	// Adjust scale for gain
  	if d.gain == TSL2561Gain1X {
  		chScale = chScale * 16
  	}
  
  	channel0 = (uint32(broadband) * chScale) >> tsl2561LuxChScale
  	channel1 = (uint32(ir) * chScale) >> tsl2561LuxChScale
  
  	// Find the ratio of the channel values (channel1 / channel0)
  	var ratio1 uint32
  	if channel0 != 0 {
  		ratio1 = (channel1 << (tsl2561LuxRatioScale + 1)) / channel0
  	}
  
  	// Round the ratio value
  	ratio := (ratio1 + 1) / 2
  
  	b, m := d.getBM(ratio)
  	temp := (channel0 * b) - (channel1 * m)
  
  	// Negative lux not allowed
  	if temp < 0 {
  		temp = 0
  	}
  
  	// Round lsb (2^(LUX_SCALE+1))
  	temp += (1 << (tsl2561LuxLuxScale - 1))
  
  	// Strip off fractional portion
  	lux = temp >> tsl2561LuxLuxScale
  
  	return lux
  }
docs: // CalculateLux converts raw sensor values to the standard SI Lux equivalent.
  // Returns 65536 if the sensor is saturated.