Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.0.3
Calculate tilt depends on the device plan either the device is parallel to the ground or standing upward

## 0.0.2
Remove uneccessary dependency to flutter_web_plugins

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ StreamBuilder<Tilt>(
samplingRateMs: 20,
initialTilt: const Tilt(0, 0),
filterGain: 0.1,
devicePlane = 0,
).stream,
builder: (context, snapshot) {
if (snapshot.hasData && snapshot.data != null) {
Expand All @@ -31,6 +32,7 @@ StreamBuilder<Tilt>(
* `samplingRateMs` determines how often the stream emitts updates. It's recommended to keep this value relatively small (i.e., update frequently), otherwise the complementary filter won't be able to correct the tilt values as accurately.
* `initialTilt` can be optionally provided, in case you know the exact tilt of the device when you subscribe to the stream. Even if incorrectly assuming (0, 0) as the initial tilt, which is the default behavior, the values will correct themselves over time, thanks to accelerometer data.
* `filterGain` determines the proportion of gyroscope and accelerometer data present in the final result. If set to `0`, the final estimate is based solely on accelerometer data, while a value of `1` would mean that only gyroscope data determines the tilt. Neither of these extremes are recommended.
* `devicePlane` Device standing up side(Portrait) or device parallel to ground(landscape)/device screen facing sky. 0 == parallel to the ground, device screen facing sky. 1 == standing upward, top of the device is up. Default value is 0.

# What about yaw?

Expand Down
9 changes: 4 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ group 'me.recki.tilt'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:8.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -25,6 +25,7 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
namespace "me.recki.tilt"
compileSdkVersion 31

compileOptions {
Expand All @@ -45,6 +46,4 @@ android {
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
dependencies {}
8 changes: 4 additions & 4 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (localPropertiesFile.exists()) {

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
throw GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
Expand All @@ -25,7 +25,9 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"


android {
namespace "me.recki.tilt_example"
compileSdkVersion flutter.compileSdkVersion

compileOptions {
Expand Down Expand Up @@ -63,6 +65,4 @@ flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
dependencies {}
6 changes: 3 additions & 3 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:8.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
2 changes: 2 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class MyApp extends StatelessWidget {
samplingRateMs: 20,
initialTilt: const Tilt(0, 0),
filterGain: 0.1,
devicePlane:
0, // change this value to 0 or 1 to get correct tilt in your device plane.
).stream,
builder: (context, snapshot) {
if (snapshot.hasData && snapshot.data != null) {
Expand Down
Loading