Skip to content

fix: small UI bug in robotic arm screen #2763

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

Merged
merged 2 commits into from
Jul 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/providers/robotic_arm_state_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ class RoboticArmStateProvider extends ChangeNotifier {
List<FlSpot> spots = [];
List<double> dutyCycles = [];
List<double> angleList = [];
List<Map<String, dynamic>> dutyLabelPoints = [];

double time = 0;

Expand All @@ -254,6 +255,12 @@ class RoboticArmStateProvider extends ChangeNotifier {
final duty = (pulseHigh / period) * 100;
dutyCycles.add(duty);

final mid = time + highMs / 2;
dutyLabelPoints.add({
'x': mid,
'label': '${duty.toStringAsFixed(1)}$percentage',
});

spots.add(FlSpot(time, 0));
spots.add(FlSpot(time, 1));
spots.add(FlSpot(time + highMs, 1));
Expand Down Expand Up @@ -287,6 +294,7 @@ class RoboticArmStateProvider extends ChangeNotifier {
'avgAngle': avgAngle,
'minAngle': minAngle,
'maxAngle': maxAngleVal,
'dutyLabelPoints': dutyLabelPoints,
};
}
}
27 changes: 12 additions & 15 deletions lib/view/widgets/robotic_arm_summary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class _PlaybackSummaryDialogState extends State<PlaybackSummaryDialog> {
final double avg = data['avgAngle'];
final double max = data['maxAngle'];
final double min = data['minAngle'];
final List<Map<String, dynamic>> labelPoints = data['dutyLabelPoints'];

return Dialog(
backgroundColor: Colors.white,
Expand Down Expand Up @@ -235,23 +236,18 @@ class _PlaybackSummaryDialogState extends State<PlaybackSummaryDialog> {
reservedSize: 12,
interval: 1,
getTitlesWidget: (value, _) {
final double period =
1000 / widget.frequency;
for (int i = 0;
i < data['dutyList'].length;
i++) {
final double start =
i * period;
final double high =
(data['dutyList'][i] /
100) *
period;
final double mid =
start + high / 2;
if ((value - mid).abs() <
if (pwmSpots.isEmpty) {
return const SizedBox
.shrink();
}

for (final label
in labelPoints) {
if ((label['x'] - value)
.abs() <
0.5) {
return Text(
'${data['dutyList'][i].toStringAsFixed(1)}$percentage',
label['label'],
style: const TextStyle(
color: Colors.white70,
fontSize: 9,
Expand All @@ -261,6 +257,7 @@ class _PlaybackSummaryDialogState extends State<PlaybackSummaryDialog> {
);
}
}

return const SizedBox.shrink();
},
),
Expand Down