fix: Implement update period in barometer#3364
Merged
Merged
Conversation
e2586cb to
be59f43
Compare
Contributor
Reviewer's GuideImplements configurable update period handling for barometer recording and playback, wiring config changes into the barometer state provider and aligning playback timing with recorded timestamps. Sequence diagram for barometer update period reacting to config changessequenceDiagram
participant ConfigProvider
participant BarometerStateProvider
participant Timer
ConfigProvider->>BarometerStateProvider: addListener(_onConfigChanged)
ConfigProvider-->>BarometerStateProvider: config.activeSensor
ConfigProvider-->>BarometerStateProvider: config.updatePeriod
BarometerStateProvider->>BarometerStateProvider: _currentSensorType = activeSensor
BarometerStateProvider->>BarometerStateProvider: _currentUpdatePeriod = updatePeriod
ConfigProvider-->>BarometerStateProvider: _onConfigChanged()
BarometerStateProvider->>BarometerStateProvider: read config.activeSensor
BarometerStateProvider->>BarometerStateProvider: read config.updatePeriod
alt sensor type or update period changed
BarometerStateProvider->>BarometerStateProvider: _currentSensorType = newSensorType
BarometerStateProvider->>BarometerStateProvider: _currentUpdatePeriod = newUpdatePeriod
BarometerStateProvider->>BarometerStateProvider: _reinitializeSensors()
end
BarometerStateProvider->>BarometerStateProvider: _startRecording()
BarometerStateProvider->>BarometerStateProvider: intervalMs = config.updatePeriod
BarometerStateProvider->>Timer: Timer.periodic(Duration(milliseconds: intervalMs))
Timer-->>BarometerStateProvider: callback
BarometerStateProvider->>BarometerStateProvider: _currentTime update
BarometerStateProvider->>BarometerStateProvider: _updateData()
BarometerStateProvider->>BarometerStateProvider: notifyListeners()
Sequence diagram for barometer playback using recorded timestampssequenceDiagram
participant BarometerStateProvider
participant DataList as PlaybackData
BarometerStateProvider->>BarometerStateProvider: startPlayback(data)
BarometerStateProvider->>BarometerStateProvider: validate data.length > 2
BarometerStateProvider->>PlaybackData: read data[2][0]
PlaybackData-->>BarometerStateProvider: timestamp string
BarometerStateProvider->>BarometerStateProvider: _playbackStartTimestamp = int.tryParse(...)
BarometerStateProvider->>BarometerStateProvider: _isPlayingBack = true
loop each playback step
BarometerStateProvider->>PlaybackData: read currentRow = data[_playbackIndex]
BarometerStateProvider->>PlaybackData: read currentRow[0]
PlaybackData-->>BarometerStateProvider: timestamp string
BarometerStateProvider->>BarometerStateProvider: timestamp = int.tryParse(...)
alt timestamp and _playbackStartTimestamp not null
BarometerStateProvider->>BarometerStateProvider: _currentTime = (timestamp - _playbackStartTimestamp) / 1000.0
end
BarometerStateProvider->>BarometerStateProvider: _updateData()
BarometerStateProvider->>BarometerStateProvider: _playbackIndex++
BarometerStateProvider->>BarometerStateProvider: notifyListeners()
end
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider resetting
_playbackStartTimestamptonullinstopPlayback/reset flows to avoid accidentally reusing a stale timestamp if another playback is started with malformed or very short data. - In
_startRecording, you already track_currentUpdatePeriod; using that instead of re-readingupdatePeriodfrom_configProvider.configwould keep the timer interval source consistent with_onConfigChangedand the cached state.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider resetting `_playbackStartTimestamp` to `null` in `stopPlayback`/reset flows to avoid accidentally reusing a stale timestamp if another playback is started with malformed or very short data.
- In `_startRecording`, you already track `_currentUpdatePeriod`; using that instead of re-reading `updatePeriod` from `_configProvider.config` would keep the timer interval source consistent with `_onConfigChanged` and the cached state.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
Build StatusBuild successful. APKs to test: https://github.com/fossasia/pslab-app/actions/runs/28189185237/artifacts/7886490127. Screenshots |
be59f43 to
9ef94d3
Compare
Contributor
Author
|
Ready for review |
rahul31124
approved these changes
Jun 26, 2026
rahul31124
left a comment
Member
There was a problem hiding this comment.
Looks good! Thanks for fixing
9ef94d3 to
2a51ab4
Compare
marcnause
approved these changes
Jun 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.







-1_instruments_screen.png?raw=true)
-2_nav_drawer.png?raw=true)
-3_accelerometer.png?raw=true)
-4_power_source.png?raw=true)
-5_multimeter.png?raw=true)
-6_wave_generator.png?raw=true)
-7_oscilloscope.png?raw=true)
Fixes #3361
Changes
Screenshots / Recordings
Screencast.From.2026-06-25.23-14-31.mp4
Checklist:
constants.dartor localization files instead of hard-coded values.dart formator the IDE formatter.flutter analyzeand tests run influtter test.Summary by Sourcery
Implement configurable update periods for barometer readings and align playback timing with recorded timestamps.
New Features:
Bug Fixes:
Enhancements: