Skip to content

Commit 45f22b3

Browse files
display posture status via rgb led of earable
1 parent f419e47 commit 45f22b3

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

open_earable/ios/Podfile.lock

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ PODS:
55
- three3d_egl (~> 0.1.3)
66
- flutter_native_splash (0.0.1):
77
- Flutter
8-
- location (0.0.1):
9-
- Flutter
108
- open_file (0.0.1):
119
- Flutter
1210
- path_provider_foundation (0.0.1):
@@ -26,7 +24,6 @@ DEPENDENCIES:
2624
- Flutter (from `Flutter`)
2725
- flutter_gl (from `.symlinks/plugins/flutter_gl/ios`)
2826
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
29-
- location (from `.symlinks/plugins/location/ios`)
3027
- open_file (from `.symlinks/plugins/open_file/ios`)
3128
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
3229
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
@@ -45,8 +42,6 @@ EXTERNAL SOURCES:
4542
:path: ".symlinks/plugins/flutter_gl/ios"
4643
flutter_native_splash:
4744
:path: ".symlinks/plugins/flutter_native_splash/ios"
48-
location:
49-
:path: ".symlinks/plugins/location/ios"
5045
open_file:
5146
:path: ".symlinks/plugins/open_file/ios"
5247
path_provider_foundation:
@@ -60,7 +55,6 @@ SPEC CHECKSUMS:
6055
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
6156
flutter_gl: 5a5603f35db897697f064027864a32b15d0c421d
6257
flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef
63-
location: d5cf8598915965547c3f36761ae9cc4f4e87d22e
6458
open_file: 02eb5cb6b21264bd3a696876f5afbfb7ca4f4b7d
6559
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
6660
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
@@ -71,4 +65,4 @@ SPEC CHECKSUMS:
7165

7266
PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189
7367

74-
COCOAPODS: 1.11.3
68+
COCOAPODS: 1.12.1

open_earable/lib/apps/posture_tracker/model/bad_posture_reminder.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class BadPostureReminder {
5050

5151
BadPostureReminder(this._openEarable, this._attitudeTracker);
5252

53+
bool? _lastPostureWasBad = null;
54+
5355
void start() {
5456
_timestamps.lastReset = DateTime.now();
5557
_timestamps.lastBadPosture = null;
@@ -64,6 +66,10 @@ class BadPostureReminder {
6466

6567
DateTime now = DateTime.now();
6668
if (_isBadPosture(attitude)) {
69+
if (!(_lastPostureWasBad ?? false)) {
70+
_openEarable.rgbLed.writeLedColor(r: 255, g: 0, b: 0);
71+
}
72+
6773
// If this is the first time the program enters the bad state, store the current time
6874
if (_timestamps.lastBadPosture == null) {
6975
_timestamps.lastBadPosture = now;
@@ -81,6 +87,10 @@ class BadPostureReminder {
8187
// Reset the last good state time
8288
_timestamps.lastGoodPosture = null;
8389
} else {
90+
if (_lastPostureWasBad ?? false) {
91+
_openEarable.rgbLed.writeLedColor(r: 0, g: 255, b: 0);
92+
}
93+
8494
// If this is the first time the program enters the good state, store the current time
8595
if (_timestamps.lastGoodPosture == null) {
8696
_timestamps.lastGoodPosture = now;
@@ -95,6 +105,7 @@ class BadPostureReminder {
95105
}
96106
}
97107
}
108+
_lastPostureWasBad = _isBadPosture(attitude);
98109
});
99110
}
100111

open_earable/lib/apps/posture_tracker/model/earable_attitude_tracker.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class EarableAttitudeTracker extends AttitudeTracker {
4141

4242
@override
4343
void stop() {
44+
_openEarable.rgbLed.writeLedColor(r: 0, g: 0, b: 0);
4445
_subscription?.pause();
4546
}
4647

0 commit comments

Comments
 (0)