Skip to content

Commit

Permalink
fix renaming issues
Browse files Browse the repository at this point in the history
  • Loading branch information
o-bagge committed Feb 20, 2024
1 parent 650065d commit de9788c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 30 deletions.
2 changes: 1 addition & 1 deletion open_earable/lib/apps/powernapper/home_screen.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/ufiiu/timerscreen.dart';
import 'package:open_earable/apps/powernapper/timerscreen.dart';
import 'package:open_earable_flutter/src/open_earable_flutter.dart';

import 'interact.dart';
Expand Down
5 changes: 1 addition & 4 deletions open_earable/lib/apps/powernapper/interact.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@ import 'package:open_earable_flutter/src/open_earable_flutter.dart';
///Interaction class for the earable. All actions executed on the earable are accessible through this class.
///For example rings or led colors.
class Interact {

final OpenEarable _openEarable;

//Constructor
Interact(this._openEarable);


//Getter for the Earable
OpenEarable getEarable() {
return _openEarable;
}


///Lets the OpenEarable play the jingel-ID: '1'.
void ring() {
try {
Expand All @@ -24,4 +21,4 @@ class Interact {
print('ERROR: Jingle konnte nicht gespielt werden!');
}
}
}
}
29 changes: 9 additions & 20 deletions open_earable/lib/apps/powernapper/movementTracker.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import 'dart:async';

import 'package:open_earable/apps/ufiiu/interact.dart';
import 'package:open_earable/apps/ufiiu/sensor_datatypes.dart';
import 'package:open_earable/apps/powernapper/interact.dart';
import 'package:open_earable/apps/powernapper/sensor_datatypes.dart';
import 'package:open_earable_flutter/src/open_earable_flutter.dart';

/// Movement Tracker has lgoic for timer & movement validation.
class MovementTracker {

//Incetaction variables
final Interact _interact;
late final OpenEarable _openEarable;
Expand All @@ -16,7 +15,6 @@ class MovementTracker {
//Stream Subscription
StreamSubscription<Map<String, dynamic>>? _subscription;


//Constructor
MovementTracker(this._interact) {
this._openEarable = _interact.getEarable();
Expand All @@ -27,7 +25,6 @@ class MovementTracker {
/// Input: [minutes] for the time before the ring.
/// Input: [updateText] as an void callback function for the textupdate.
void start(int minutes, void Function(SensorDataType s) updateText) {

//Timer (re-)start
stop();
_startTimer(minutes);
Expand All @@ -36,8 +33,8 @@ class MovementTracker {
_openEarable.sensorManager.writeSensorConfig(_buildSensorConfig());

//Starts listening to the subscription
_subscription = _openEarable.sensorManager.subscribeToSensorData(0).listen((event) {

_subscription =
_openEarable.sensorManager.subscribeToSensorData(0).listen((event) {
//Display update callback
updateText(Gyroscope(event));

Expand Down Expand Up @@ -68,7 +65,7 @@ class MovementTracker {
///
/// Uses the [SensorDataType] to validate update and int [minutes] to restart the timer.
void _update(SensorDataType dt, int minutes) {
if(_validMovement(dt)) {
if (_validMovement(dt)) {
_timer?.cancel();
_startTimer(minutes);
}
Expand All @@ -78,17 +75,13 @@ class MovementTracker {
///
/// Input: [SensorDataType] with the data to be validated.
bool _validMovement(SensorDataType dt) {

Gyroscope gyro;

if(dt is Gyroscope) {
if (dt is Gyroscope) {
gyro = dt;

//Threshold validating for gyroscope data.
if(gyro.x.abs() > 5
|| gyro.y.abs() > 5
|| gyro.z.abs() > 5
) {
if (gyro.x.abs() > 5 || gyro.y.abs() > 5 || gyro.z.abs() > 5) {
return true;
}
}
Expand All @@ -97,10 +90,6 @@ class MovementTracker {

///Sensor Config for the earable.
OpenEarableSensorConfig _buildSensorConfig() {
return OpenEarableSensorConfig(
sensorId: 0,
samplingRate: 30,
latency: 0
);
return OpenEarableSensorConfig(sensorId: 0, samplingRate: 30, latency: 0);
}
}
}
2 changes: 1 addition & 1 deletion open_earable/lib/apps/powernapper/sensor_datatypes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ class EulerAngles extends SensorDataType {
/// Placeholder data without any information in case no sensor data is available.
class NullData extends SensorDataType {
NullData() : super({"X": 0.0, "Y": 0.0, "Z": 0.0});
}
}
4 changes: 2 additions & 2 deletions open_earable/lib/apps/powernapper/timerscreen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:open_earable/apps/ufiiu/movementTracker.dart';
import 'package:open_earable/apps/ufiiu/sensor_datatypes.dart';
import 'package:open_earable/apps/powernapper/movementTracker.dart';
import 'package:open_earable/apps/powernapper/sensor_datatypes.dart';
import 'package:open_earable/ble_controller.dart';
import 'package:open_earable/widgets/earable_not_connected_warning.dart';
import 'package:provider/provider.dart';
Expand Down
3 changes: 1 addition & 2 deletions open_earable/lib/apps_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import 'package:open_earable/apps/recorder.dart';
import 'package:open_earable/apps/jump_height_test/jump_height_test.dart';
import 'package:open_earable_flutter/src/open_earable_flutter.dart';
import 'package:open_earable/apps/jump_rope_counter.dart';

import 'apps/ufiiu/home_screen.dart';
import 'apps/powernapper/home_screen.dart';

class AppInfo {
final IconData iconData;
Expand Down

0 comments on commit de9788c

Please sign in to comment.