Skip to content

Commit

Permalink
update UI of Step Counter, count steps per minute instead of steps pe…
Browse files Browse the repository at this point in the history
…r second (more common unit for cadence) and remove developer settings
  • Loading branch information
o-bagge committed Mar 13, 2024
1 parent 70a6c89 commit 0efd07f
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 167 deletions.
2 changes: 1 addition & 1 deletion open_earable/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion open_earable/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
4 changes: 2 additions & 2 deletions open_earable/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
app_settings: 017320c6a680cdc94c799949d95b84cb69389ebc
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_gl: 5a5603f35db897697f064027864a32b15d0c421d
flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef
open_file: 02eb5cb6b21264bd3a696876f5afbfb7ca4f4b7d
Expand All @@ -69,6 +69,6 @@ SPEC CHECKSUMS:
SwiftProtobuf: b70d65f419fbfe61a2d58003456ca5da58e337d6
three3d_egl: de2cd4950ad2d5f2122166c36583bde4c812e7b5

PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189
PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796

COCOAPODS: 1.12.1
6 changes: 3 additions & 3 deletions open_earable/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
Expand Down Expand Up @@ -601,7 +601,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -650,7 +650,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
Expand Down
130 changes: 57 additions & 73 deletions open_earable/lib/apps/stepCounter/step_counter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:open_earable/apps/stepCounter/step_counter_settings.dart';
import 'package:open_earable/widgets/earable_not_connected_warning.dart';
import 'dart:async';
import 'package:open_earable_flutter/src/open_earable_flutter.dart';

Expand Down Expand Up @@ -103,11 +103,11 @@ class _StepCounterState extends State<StepCounter> {
}

/**
* Berachnet die durchschnittliche Geschwindigkeit in Schritte pro Sekunde
* Berechnet die durchschnittlichen Schritte pro Minute
*/
String _formatAvgSpeed(int steps, Duration duration) {
String _formatAvgCadence(int steps, Duration duration) {
if (duration.inSeconds != 0) {
return (steps / duration.inSeconds).toStringAsFixed(2);
return (60.0 * steps / duration.inSeconds.toDouble()).toStringAsFixed(2);
}
return ""; // Wenn durch 0 geteilt wird
}
Expand All @@ -121,6 +121,7 @@ class _StepCounterState extends State<StepCounter> {
}
setState(() {
_countedSteps = 0;
_duration = Duration.zero;
});
}

Expand Down Expand Up @@ -149,6 +150,9 @@ class _StepCounterState extends State<StepCounter> {
* Ruft die Sensordaten vom Earable ab und verarbeitet dies.
*/
_setupListeners() {
OpenEarableSensorConfig config =
OpenEarableSensorConfig(sensorId: 0, samplingRate: 30, latency: 0);
_openEarable.sensorManager.writeSensorConfig(config);
_imuSubscription =
_openEarable.sensorManager.subscribeToSensorData(0).listen((data) {
if (!_startStepCount) {
Expand Down Expand Up @@ -219,34 +223,7 @@ class _StepCounterState extends State<StepCounter> {
return Scaffold(
backgroundColor: Theme.of(context).colorScheme.background,
appBar: AppBar(
title: Text('StepInformation'),
actions: [
IconButton(
onPressed: () async {
var result = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SettingsPage(
widget.stoppedTimeController,
widget.countedStepsController,
),
),
);

if (result != null) {
setState(() {
widget.stoppedTimeController.text =
result['stoppedTime'] ?? '';
widget.countedStepsController.text =
result['countedSteps'] ?? '';
updateValues(result['stoppedTime'] ?? '',
result['countedSteps'] ?? '');
});
}
},
icon: Icon(Icons.settings),
),
],
title: Text('StepCounter'),
),
// Beschränkt die GUI auf nicht von Betriebssystem verwendeten Bereich. Funktioniert nicht auf jedem Gerät.
body: SafeArea(
Expand Down Expand Up @@ -279,50 +256,55 @@ class _StepCounterState extends State<StepCounter> {
* Erstellt die GUI im Landscape Modus
*/
Widget _buildRow() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
_buildListTile(_formatDuration(_duration), "Stopped Time", 45),
_buildListTile(_countedSteps.toString(), "Counted Steps", 45),
_buildListTile(_formatAvgSpeed(_countedSteps, _duration),
"Avg. Walking Speed", 45),
],
),
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
return !_openEarable.bleManager.connected
? EarableNotConnectedWarning()
: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
_buildControlButtons(),
if (!_openEarable.bleManager.connected)
_buildText("Not connected to OpenEarable device", 15),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
_buildListTile(
_formatDuration(_duration), "Stopped Time", 40),
_buildListTile(
_countedSteps.toString(), "Counted Steps", 40),
_buildListTile(_formatAvgCadence(_countedSteps, _duration),
"Avg. Cadence\n(Steps per Minute)", 40),
],
),
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_buildControlButtons(),
],
),
),
],
),
),
],
);
);
}

/**
* Erstellt die GUI im Portait Modus
*/
Widget _buildColumn() {
return Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
_buildListTile(_formatDuration(_duration), "Stopped Time", 45),
_buildListTile(_countedSteps.toString(), "Counted Steps", 45),
_buildListTile(_formatAvgSpeed(_countedSteps, _duration),
"Avg. Walking Speed", 45),
_buildControlButtons(),
if (!_openEarable.bleManager.connected)
_buildText("Not connected to OpenEarable device", 15),
],
);
return !_openEarable.bleManager.connected
? EarableNotConnectedWarning()
: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Spacer(),
_buildListTile(_formatDuration(_duration), "Stopped Time", 45),
_buildListTile(_countedSteps.toString(), "Counted Steps", 45),
_buildListTile(_formatAvgCadence(_countedSteps, _duration),
"Avg. Cadence", 45),
Spacer(),
_buildControlButtons(),
Spacer(),
],
);
}

/**
Expand All @@ -334,10 +316,10 @@ class _StepCounterState extends State<StepCounter> {
children: [
_buildButton(
onPressed: startStopStepCount,
label: _startStepCount ? "Stop StepCounting" : "Start StepCounting",
label: _startStepCount ? "Stop Counting" : "Start Counting",
),
_buildButton(
onPressed: _resetStepCount,
onPressed: _startStepCount ? null : _resetStepCount,
label: "Reset Steps",
),
],
Expand All @@ -351,11 +333,13 @@ class _StepCounterState extends State<StepCounter> {
String leadingText, String trailingText, double fontSize) {
return ListTile(
contentPadding: EdgeInsets.all(8),
title: _buildText(leadingText, fontSize),
subtitle: Text(
title: Center(child: _buildText(leadingText, fontSize)),
subtitle: Center(
child: Text(
trailingText,
style: TextStyle(fontSize: fontSize * 0.6),
),
textAlign: TextAlign.center,
)),
);
}

Expand Down
87 changes: 0 additions & 87 deletions open_earable/lib/apps/stepCounter/step_counter_settings.dart

This file was deleted.

0 comments on commit 0efd07f

Please sign in to comment.