Skip to content

Instantly share code, notes, and snippets.

View tscholze's full-sized avatar
💭
I may be slow to respond.

Tobias Scholze tscholze

💭
I may be slow to respond.
View GitHub Profile
fun readPressure(): Double {
val temperature = readTemperature(asFinite = true)
val msb = device.read(REGISTER_MSB_PRESSURE, 1U).toInt()
val lsb = device.read(REGISTER_LSB_PRESSURE, 1U).toInt()
val xlsb = device.read(REGISTER_XLSB_PRESSURE, 1U).toInt()
val rawValue = (msb shl 12) + (lsb shl 4) + (xlsb shr 4)
var part1 = temperature / 2.0 - 64000.0
var part2 = part1 * part1 * calibration.pressure6 / 32768.0
part2 += part1 * calibration.pressure5 * 2
fun readPressure(): Double {
val temperature = readTemperature(asFinite = true)
val msb = device.read(REGISTER_MSB_PRESSURE, 1U).toInt()
val lsb = device.read(REGISTER_LSB_PRESSURE, 1U).toInt()
val xlsb = device.read(REGISTER_XLSB_PRESSURE, 1U).toInt()
val rawValue = (msb shl 12) + (lsb shl 4) + (xlsb shr 4)
var part1 = temperature / 2.0 - 64000.0
var part2 = part1 * part1 * calibration.pressure6 / 32768.0
part2 += part1 * calibration.pressure5 * 2
companion object {
/** I2C command bit mask */
private const val REGISTER_COMMAND = 0b10000000
/** I2C command to auto increment */
private const val REGISTER_COMMAND_AUTO_INC = 0b00100000
/** I2C address of the TCS3472. */
const val TCS3472_ADDRESS: UByte = 0x29U
@tscholze
tscholze / MainActivity.java
Created September 29, 2018 19:02
Trying to save an image from the Rasp Pi camera to a temp folder to ship it via an embedded web server - Step 1.
/**
Error:
E/AndroidRuntime: FATAL EXCEPTION: CameraThread
Process: xxxx, PID: 2634
java.lang.IllegalStateException: buffer has been freed
*/
private ImageReader.OnImageAvailableListener onImageAvailableListener = new ImageReader.OnImageAvailableListener()
{
@Override
@tscholze
tscholze / manifest.json
Created January 12, 2014 09:41
MG-Chrome-Extension
{
"name": "MobileGeeks Top 5",
"version": "0.1",
"manifest_version": 2,
"description": "Presents you the latest five article of mobilegeeks.de",
"homepage_url": "http://www.mobilegeeks.de",
"browser_action":
{
"default_icon": "icon48.png",
"default_popup": "popup.html"