Skip to content

Commit

Permalink
display posture status via rgb led of earable
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisMoschina committed Dec 11, 2023
1 parent f419e47 commit 45f22b3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 1 addition & 7 deletions open_earable/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ PODS:
- three3d_egl (~> 0.1.3)
- flutter_native_splash (0.0.1):
- Flutter
- location (0.0.1):
- Flutter
- open_file (0.0.1):
- Flutter
- path_provider_foundation (0.0.1):
Expand All @@ -26,7 +24,6 @@ DEPENDENCIES:
- Flutter (from `Flutter`)
- flutter_gl (from `.symlinks/plugins/flutter_gl/ios`)
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
- location (from `.symlinks/plugins/location/ios`)
- open_file (from `.symlinks/plugins/open_file/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
Expand All @@ -45,8 +42,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_gl/ios"
flutter_native_splash:
:path: ".symlinks/plugins/flutter_native_splash/ios"
location:
:path: ".symlinks/plugins/location/ios"
open_file:
:path: ".symlinks/plugins/open_file/ios"
path_provider_foundation:
Expand All @@ -60,7 +55,6 @@ SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_gl: 5a5603f35db897697f064027864a32b15d0c421d
flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef
location: d5cf8598915965547c3f36761ae9cc4f4e87d22e
open_file: 02eb5cb6b21264bd3a696876f5afbfb7ca4f4b7d
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
Expand All @@ -71,4 +65,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189

COCOAPODS: 1.11.3
COCOAPODS: 1.12.1
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class BadPostureReminder {

BadPostureReminder(this._openEarable, this._attitudeTracker);

bool? _lastPostureWasBad = null;

void start() {
_timestamps.lastReset = DateTime.now();
_timestamps.lastBadPosture = null;
Expand All @@ -64,6 +66,10 @@ class BadPostureReminder {

DateTime now = DateTime.now();
if (_isBadPosture(attitude)) {
if (!(_lastPostureWasBad ?? false)) {
_openEarable.rgbLed.writeLedColor(r: 255, g: 0, b: 0);
}

// If this is the first time the program enters the bad state, store the current time
if (_timestamps.lastBadPosture == null) {
_timestamps.lastBadPosture = now;
Expand All @@ -81,6 +87,10 @@ class BadPostureReminder {
// Reset the last good state time
_timestamps.lastGoodPosture = null;
} else {
if (_lastPostureWasBad ?? false) {
_openEarable.rgbLed.writeLedColor(r: 0, g: 255, b: 0);
}

// If this is the first time the program enters the good state, store the current time
if (_timestamps.lastGoodPosture == null) {
_timestamps.lastGoodPosture = now;
Expand All @@ -95,6 +105,7 @@ class BadPostureReminder {
}
}
}
_lastPostureWasBad = _isBadPosture(attitude);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class EarableAttitudeTracker extends AttitudeTracker {

@override
void stop() {
_openEarable.rgbLed.writeLedColor(r: 0, g: 0, b: 0);
_subscription?.pause();
}

Expand Down

0 comments on commit 45f22b3

Please sign in to comment.