diff --git a/lib/services/globals.dart b/lib/services/globals.dart index 5dfb2356..9a3901e2 100644 --- a/lib/services/globals.dart +++ b/lib/services/globals.dart @@ -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 { diff --git a/lib/services/shuffleboard_nt_listener.dart b/lib/services/shuffleboard_nt_listener.dart index 1e24e908..6e1199a6 100644 --- a/lib/services/shuffleboard_nt_listener.dart +++ b/lib/services/shuffleboard_nt_listener.dart @@ -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); @@ -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', () => {}); 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]!); @@ -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( @@ -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); diff --git a/lib/widgets/nt4_widgets/single_topic/graph.dart b/lib/widgets/nt4_widgets/single_topic/graph.dart index 4deb7213..93d062c8 100644 --- a/lib/widgets/nt4_widgets/single_topic/graph.dart +++ b/lib/widgets/nt4_widgets/single_topic/graph.dart @@ -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, @@ -39,7 +39,7 @@ class GraphWidget extends StatelessWidget with NT4Widget { GraphWidget.fromJson({super.key, required Map 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;