Skip to content

Commit

Permalink
Changed default period to 100 ms
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 committed Nov 17, 2023
1 parent 3141057 commit 33fbff4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
3 changes: 2 additions & 1 deletion lib/services/globals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class Globals {
static bool snapToGrid = true;
static bool showGrid = false;

static const double defaultPeriod = 0.033;
static const double defaultPeriod = 0.1;
static const double defaultGraphPeriod = 0.033;
}

class PrefKeys {
Expand Down
23 changes: 16 additions & 7 deletions lib/services/shuffleboard_nt_listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ class ShuffleboardNTListener {
await Future.delayed(const Duration(seconds: 2, milliseconds: 750), () {
currentJsonData.putIfAbsent(jsonKey, () => {});

String type = (!isCameraStream) ? widget!.type : 'Camera Stream';

currentJsonData[jsonKey]!.putIfAbsent('title', () => componentName);
currentJsonData[jsonKey]!.putIfAbsent('x', () => 0.0);
currentJsonData[jsonKey]!.putIfAbsent('y', () => 0.0);
Expand All @@ -353,14 +355,16 @@ class ShuffleboardNTListener {
? widgetContainer!.height
: Globals.gridSize * 2);
currentJsonData[jsonKey]!.putIfAbsent('tab', () => tabName);
currentJsonData[jsonKey]!.putIfAbsent(
'type', () => (!isCameraStream) ? widget!.type : 'Camera Stream');
currentJsonData[jsonKey]!.putIfAbsent('type', () => type);
currentJsonData[jsonKey]!
.putIfAbsent('properties', () => <String, dynamic>{});
currentJsonData[jsonKey]!['properties']
.putIfAbsent('topic', () => widgetRow.topic);
currentJsonData[jsonKey]!['properties']
.putIfAbsent('period', () => Globals.defaultPeriod);
currentJsonData[jsonKey]!['properties'].putIfAbsent(
'period',
() => (type != 'Graph')
? Globals.defaultPeriod
: Globals.defaultGraphPeriod);

onWidgetAdded?.call(currentJsonData[jsonKey]!);

Expand Down Expand Up @@ -435,8 +439,9 @@ class ShuffleboardNTListener {
child['properties']['topic'] = '/CameraPublisher/$cameraName';
}

child.putIfAbsent(
'type', () => (!isCameraStream) ? widget!.type : 'Camera Stream');
String type = (!isCameraStream) ? widget!.type : 'Camera Stream';

child.putIfAbsent('type', () => type);
child.putIfAbsent('x', () => 0.0);
child.putIfAbsent('y', () => 0.0);
child.putIfAbsent(
Expand All @@ -451,7 +456,11 @@ class ShuffleboardNTListener {
: Globals.gridSize * 2);

child['properties']!.putIfAbsent('topic', () => childRow.topic);
child['properties']!.putIfAbsent('period', () => Globals.defaultPeriod);
child['properties']!.putIfAbsent(
'period',
() => (type != 'Graph')
? Globals.defaultPeriod
: Globals.defaultGraphPeriod);

widget?.unSubscribe();
widget?.dispose(deleting: true);
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/nt4_widgets/single_topic/graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class GraphWidget extends StatelessWidget with NT4Widget {
GraphWidget({
super.key,
required topic,
period = Globals.defaultPeriod,
period = Globals.defaultGraphPeriod,
this.timeDisplayed = 5.0,
this.minValue,
this.maxValue,
Expand All @@ -39,7 +39,7 @@ class GraphWidget extends StatelessWidget with NT4Widget {

GraphWidget.fromJson({super.key, required Map<String, dynamic> jsonData}) {
topic = tryCast(jsonData['topic']) ?? '';
period = tryCast(jsonData['period']) ?? Globals.defaultPeriod;
period = tryCast(jsonData['period']) ?? Globals.defaultGraphPeriod;
timeDisplayed = tryCast(jsonData['time_displayed']) ??
tryCast(jsonData['visibleTime']) ??
5.0;
Expand Down

0 comments on commit 33fbff4

Please sign in to comment.