examples/webbluetooth/tisensortag/app.js
function calculateLux(data)
{
	// Get 16 bit value from data buffer in little endian format.
	var value = data.getUint16(0, true)

	// Extraction of luxometer value, based on sfloatExp2ToDouble
	// from BLEUtility.m in Texas Instruments TI BLE SensorTag
	// iOS app source code.
	var mantissa = value & 0x0FFF
	var exponent = value >> 12

	var magnitude = Math.pow(2, exponent)
	var output = (mantissa * magnitude)

	var lux = output / 100.0

	// Return result.
	return lux
}
function calculateLux(data)
{
	// Get 16 bit value from data buffer in little endian format.
	var value = data.getUint16(0, true)

	// Extraction of luxometer value, based on sfloatExp2ToDouble
	// from BLEUtility.m in Texas Instruments TI BLE SensorTag
	// iOS app source code.
	var mantissa = value & 0x0FFF
	var exponent = value >> 12

	var magnitude = Math.pow(2, exponent)
	var output = (mantissa * magnitude)

	var lux = output / 100.0

	// Return result.
	return lux
}
function calculateLux ( data ) { // Get 16 bit value from data buffer in little endian format. var value = data . getUint16 ( 0 , true ) // Extraction of luxometer value, based on sfloatExp2ToDouble // from BLEUtility.m in Texas Instruments TI BLE SensorTag // iOS app source code. var mantissa = value & 0x0FFF var exponent = value >> 12 var magnitude = Math . pow ( 2 , exponent ) var output = ( mantissa * magnitude ) var lux = output / 100.0 // Return result. return lux }
Calculate the light level from raw sensor data. Return light level in lux.
Calculate the light level from raw sensor data . Return light level in lux .