Rose-Hulman Robotics Team

Changeset 507

Show
Ignore:
Timestamp:
06/03/09 17:58:17 (3 years ago)
Author:
mosttw
Message:

Fixed speedgraph to not break with no data.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/software/rb/gui/speedgraph.py

    r504 r507  
    1818import gtk 
    1919 
    20  
    2120DATA_WINDOW = 500 # How many updates to graph 
     21STAT_SCALE = 1.0 / 32767.0 # Motor stat coefficient 
     22# Motor stats are multiplied by this number, which should put them in a -1..1 range. 
    2223 
    2324class SpeedGraph(gtk.DrawingArea): 
     
    7475         
    7576        def draw_line(self, context, center_y, start_x, step_x, color, data): 
     77                if not data: 
     78                        return 
    7679                x = start_x 
    7780                context.move_to(x, center_y + (data.pop(0) * center_y)) 
     
    8992                lst, rst = self.drive.getstat() 
    9093                new_data = [lt, rt, ls, rs] 
    91                 new_data += [s / 32767.0 for s in (lst + rst)] 
     94                new_data += [s * STAT_SCALE for s in (lst + rst)] 
    9295                 
    9396                for datum, list in zip(new_data, self.data):