GithubHelp home page GithubHelp logo

victorkemboi / composesensors Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mutualmobile/composesensors

0.0 1.0 0.0 1.2 MB

Access sensor data for any Android device easily using Jetpack Compose ๐ŸŒก๏ธ ๐Ÿงฒ ๐Ÿงญ

License: Apache License 2.0

Kotlin 100.00%

composesensors's Introduction

Compose Sensors

Sonatype Sonatype

Accessing sensor data of your Android devices just became quick and easy โšก๏ธ

This library provides a convenience wrapper over the Sensor APIs for Android to be used with Jetpack Compose.

Demo โค๏ธ

Screen Recording 2023-04-03 at 1 00 08 PM

WIP ๐Ÿšง

This library is a work-in-progress and is subject to major changes. Our team is working hard to get it stable as soon as possible. Thank you for your patience ๐ŸŒบ

Usage ๐Ÿš€

Install dependency ๐Ÿ“ฒ

Kotlin build.gradle.kts (:module-name)

dependencies {
    ...
    implementation("com.mutualmobile:composesensors:x.y.z")
}

Groovy build.gradle (:module-name)

dependencies {
    ...
    implementation 'com.mutualmobile:composesensors:x.y.z'
}

Snapshots ๐Ÿ“ธ

Add https://oss.sonatype.org/content/repositories/snapshots as a maven repository resource to be able to access SNAPSHOT versions of this library. Check tags for the latest library version.

Kotlin settings.gradle.kts

dependencyResolutionManagement {
    ...
    repositories {
        ...
        maven("https://oss.sonatype.org/content/repositories/snapshots")
    }
}

Groovy settings.gradle

dependencyResolutionManagement {
    ...
    repositories {
        ...
        maven {
            url = 'https://oss.sonatype.org/content/repositories/snapshots'
        }
    }
}

The library provides straightforward state methods for multiple sensors like Accelerometer, Gyroscope, etc (more mentioned below). Following is an example on how to get the current values from the Accelerometer:

val accelerometerState = rememberAccelerometerSensorState()

Use it in an example:

val accelerometerState = rememberAccelerometerSensorState()
// Optional: You could also write: rememberAccelerometerSensorState(sensorDelay = SensorDelay.Fastest) for fetching sensor data faster

Text(
    text = "Force X: ${accelerometerState.xForce}" +
    "\nForce Y: ${accelerometerState.yForce}" +
    "\nForce Z: ${accelerometerState.zForce}" +
    "\nIs Available?: ${accelerometerState.isAvailable}"
)

Sensors Supported ๐Ÿ“ฑ

ComposeSensors plans to support the following Android sensors:

Sensor Status Composable
Accelerometer โœ… rememberAccelerometerSensorState()
Magnetic Field โœ… rememberMagneticFieldSensorState()
Gyroscope โœ… rememberGyroscopeSensorState()
Light โœ…๏ธ rememberLightSensorState()
Pressure โœ…๏ธ rememberPressureSensorState()
Proximity โœ…๏ธ๏ธ rememberProximitySensorState()
Gravity โœ…๏ธ rememberGravitySensorState()
Linear Acceleration โœ…๏ธ rememberLinearAccelerationSensorState()
Rotation Vector โœ…๏ธ๏ธ rememberRotationVectorSensorState()
Relative Humidity โš ๏ธ WIP
Ambient Temperature โœ…๏ธ rememberAmbientTemperatureSensorState()
Magnetic Field (Uncalibrated) โœ…๏ธ๏ธ rememberUncalibratedMagneticFieldSensorState()
GameRotation Vector โœ…๏ธ rememberGameRotationVectorSensorState()
Gyroscope (Uncalibrated) โš ๏ธ WIP
Significant Motion โ€” N/A
Step Detector โœ…๏ธ rememberStepDetectorSensorState()
Step Counter โœ…๏ธ rememberStepCounterSensorState()
Geomagnetic Rotation Vector โœ…๏ธ๏ธ rememberGeomagneticRotationVectorSensorState()
Heart Rate โœ…๏ธ rememberHeartRateSensorState()
Pose6DOF โ€” N/A
Stationary Detect โš ๏ธ WIP
Motion Detect โš ๏ธ WIP
Heart Beat โ€” N/A
Low Latency Off-Body Detect โ€” N/A
Accelerometer (Uncalibrated) โš ๏ธ WIP
Hinge Angle โœ…๏ธ rememberHingeAngleSensorState()
Head Tracker โ€” N/A
Accelerometer Limited Axes โš ๏ธ WIP
Gyroscope Limited Axes โœ…๏ธ๏ธ rememberLimitedAxesGyroscopeSensorState()
Accelerometer Limited Axes (Uncalibrated) โš ๏ธ WIP
Gyroscope Limited Axes (Uncalibrated) โ€” N/A
Heading โš ๏ธ WIP
All โ€” N/A

License ๐Ÿ”–

Copyright 2023 MutualMobile

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.