Go to Post You win Worlds by innovation. You win Worlds by determination. You win Worlds by engineering a robot so solid, that it successfully completes the game. - Zach O [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 10-01-2013, 15:25
Stonemotmot Stonemotmot is offline
Registered User
FRC #0486
 
Join Date: Sep 2011
Location: United States, Pa
Posts: 53
Stonemotmot is an unknown quantity at this point
Can I create a looping SmartdashBoard widget

Hello, I was wondering how to set up a smartdashboard widget to loop continuesly? I know how to make a widget I'm just not sure if any of the functions are called repeatedly like a loop or they only run on call.
Reply With Quote
  #2   Spotlight this post!  
Unread 10-01-2013, 20:46
timothyb89 timothyb89 is offline
code monkey
FRC #1977 (Loveland High Robotics)
Team Role: Alumni
 
Join Date: Oct 2008
Rookie Year: 2009
Location: Loveland, Colorado
Posts: 45
timothyb89 will become famous soon enough
Re: Can I create a looping SmartdashBoard widget

If memory serves, the SmartDashboard widgets are just Swing components. The constructor would be executed once during initialization, and then the drawing methods (paint, paintComponent, etc) are run periodically as determined by Swing and the OS. Doing any kind of looping or long-executing tasks in these places would cause significant slowness in the UI, unfortunately.

If you want something to update continuously you're best off doing it from a background thread. The official camera widget does this to fetch new images: [source]
(Note that this code is a snapshot from the smartdashboard svn as of last year, but I doubt all that much has changed since then. Also know that this code does some bad things like calling System.gc() which is a pretty terrible idea)

The images are fetched in the background and then a call to repaint() is queued in the UI thread with SwingUtils.invokeLater(). The repaint() method will then be called "later" which then displays the fetched image and in theory should never cause any noticeable lag in the UI.
__________________
FRC-DB: A detailed, web-based scouting database for FRC teams with lots of interesting statistics.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:01.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi