-
Notifications
You must be signed in to change notification settings - Fork 815
feat: added remaining Oscilloscope functionality #2750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideImplements remaining Oscilloscope functionality—auto-scale, run/pause controls, recording UI, and automated measurements—by refactoring the screen UI for provider-driven state, extending the state provider with scaling and measurement logic, adding supporting models/widgets, and adjusting analytics FFT handling. Entity relationship diagram for Oscilloscope channel measurementserDiagram
OSCILLOSCOPE_MEASUREMENTS {
string channel
double frequency
double period
double amplitude
double positivePeak
double negativePeak
}
OSCILLOSCOPE_MEASUREMENTS ||--o{ CHANNEL : has
CHANNEL {
string name
}
Class diagram for Oscilloscope measurements and state managementclassDiagram
class OscilloscopeStateProvider {
+bool isRunning
+bool isMeasurementsChecked
+List<List<FlSpot>> dataEntries
+List<String> dataParamsChannels
+bool autoScale()
+notifyListeners()
...
}
class OscilloscopeMeasurements {
+static Map<String, Map<ChannelMeasurements, double>> channel
}
class MeasurementsList {
+List<String> dataParamsChannels
}
OscilloscopeStateProvider --> OscilloscopeMeasurements : updates
MeasurementsList --> OscilloscopeMeasurements : reads
OscilloscopeStateProvider --> MeasurementsList : provides dataParamsChannels
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @AsCress - I've reviewed your changes - here's some feedback:
- Consider refactoring the measurement/calculation logic into a shared helper or service rather than duplicating it in both
_getData
andautoScale
to improve maintainability. - Avoid using
setState
to toggle provider fields (isRunning
,isMeasurementsChecked
)—instead update the provider and callnotifyListeners
so the UI rebuilds consistently through the ChangeNotifier. - The static
OscilloscopeMeasurements.channel
map introduces global mutable state; move measurement storage into the provider instance to prevent cross-component interference and improve testability.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider refactoring the measurement/calculation logic into a shared helper or service rather than duplicating it in both `_getData` and `autoScale` to improve maintainability.
- Avoid using `setState` to toggle provider fields (`isRunning`, `isMeasurementsChecked`)—instead update the provider and call `notifyListeners` so the UI rebuilds consistently through the ChangeNotifier.
- The static `OscilloscopeMeasurements.channel` map introduces global mutable state; move measurement storage into the provider instance to prevent cross-component interference and improve testability.
## Individual Comments
### Comment 1
<location> `lib/providers/oscilloscope_state_provider.dart:614` </location>
<code_context>
}
+ bool autoScale() {
+ double minY = double.maxFinite;
+ double maxY = double.minPositive;
+ double maxPeriod = -1 * double.minPositive;
+ double yRange;
</code_context>
<issue_to_address>
Initialization of maxY and maxPeriod may not handle negative values correctly.
minPositive only works for positive values. Use -double.maxFinite for initialization to handle negative data correctly.
</issue_to_address>
### Comment 2
<location> `lib/view/widgets/measurements_list.dart:18` </location>
<code_context>
+
+class _MeasurementsListState extends State<MeasurementsList> {
+ String formatFrequency(double? freq) {
+ return freq! >= 1000
+ ? '${(freq / 1000).toStringAsFixed(2)} kHz'
+ : '${freq.toStringAsFixed(2)} Hz';
+ }
+
</code_context>
<issue_to_address>
Potential null dereference in formatFrequency.
Handle cases where freq is null to prevent runtime exceptions from force-unwrapping.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Build successful. APKs to test: https://github.com/fossasia/pslab-android/actions/runs/15936483509/artifacts/3422646133 |
Fixes #2745.
Adds the following remaining functionality to the Oscilloscope:
Screenshots/Recordings
Screen_recording_20250622_193304.mp4
@marcnause Would you like to test these additions ?
Summary by Sourcery
Add missing Oscilloscope features: automatic axis scaling, acquisition run control, and an overlay for automated channel measurements.
New Features:
Enhancements:
Documentation: