Changeset 1089
- Timestamp:
- 11/04/08 05:16:40 (2 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
analog/pyeac/branches/pyeac_pygame/eeepc/pyeac.py
r1086 r1089 24 24 if __name__ == '__main__': 25 25 from visualizer import Visualizer 26 # from eac_sim import eac27 26 from eac_physical import ueac 28 27 import pygame … … 43 42 phyeac.write_i(5,5,100) # write pin (5,5) as current source 44 43 45 # simeac = eac()46 # simeac.set_dim(5,5,30000)47 # simeac.lla_add('lla1',(3,3,18))48 # simeac.isrc_add('I1',(1,1,'-100u'))49 # simeac.isrc_add('I2',(5,5,'-100u'))50 51 44 pygame.init() 52 45 screen = pygame.display.set_mode((790,535)) … … 56 49 57 50 58 phyeac_vis = Visualizer( (0,0,100))51 phyeac_vis = Visualizer(absolute=True) 59 52 phyeac_vis.update(phyeac.voltage_values) 60 61 # simeac_vis = Visualizer()62 # simeac_vis.update(simeac.evaluate())63 53 64 54 form = gui.Form() … … 81 71 if changes != None: 82 72 phyeac.update(changes,_form) 83 # simeac.update(_form)84 # simeac_vis.update(simeac.evaluate())85 73 86 74 for event in pygame.event.get(): … … 94 82 screen.fill((0,0,0)) 95 83 screen.blit(phyeac_vis.surface,(0,0)) 96 # screen.blit(simeac_vis.surface,(485,0))97 84 app.paint(screen) 98 85 99 86 pygame.display.flip() 100 # print clock.tick()101 87 102 88 analog/pyeac/branches/pyeac_pygame/eeepc/visualizer.py
r1086 r1089 7 7 from pygame.locals import * 8 8 9 class Visualizer :9 class Visualizer(): 10 10 11 def __init__(self, fill_color=(100,0,0)): 12 self.fill_color = fill_color 11 def __init__(self, absolute=True): 12 self.absolute = absolute 13 self.fill_color = (100,0,0) 13 14 self.palette = self.createpalette() 14 15 self.surface = pygame.Surface((300,300)) … … 16 17 for y in range(5): 17 18 for x in range(5): 18 self.surface.fill( fill_color,fill_window)19 self.surface.fill(self.fill_color,fill_window) 19 20 fill_window = fill_window.move(60,0) 20 21 fill_window = fill_window.move(-300,60) … … 29 30 30 31 def update(self,vdata): 31 for y in range(5): 32 for x in range(5): 33 if self.fill_color[2]==0: 34 cdata = self.palette[int((vdata[y][x]/5.0)*255)] 35 else: 36 cdata = self.palette[int((vdata[y][x]/5.0)*255)] 37 self.set_block((x,y),cdata) 38 32 print self.absolute 33 if self.absolute == True: 34 max = 5.0 35 min = 0.0 36 for y in range(5): 37 for x in range(5): 38 voltage = float(vdata[y][x]) 39 if voltage > max: 40 voltage = max 41 elif voltage < min: 42 voltage = min 43 cdata = self.palette[int((voltage/max)*255)] 44 self.set_block((x,y),cdata) 45 else: 46 max = 0.0 47 min = 5.0 48 for y in range(5): 49 for x in range(5): 50 voltage = float(vdata[y][x]) 51 if voltage > max: 52 max = voltage 53 if voltage < min: 54 min = voltage 55 span = max-min 56 print "coming from vis update",min, max, span 57 if span > 0: 58 for y in range(5): 59 for x in range(5): 60 voltage = float(vdata[y][x]) 61 vnorm = (voltage - min)/span 62 cdata = self.palette[int(vnorm*255)] 63 self.set_block((x,y),cdata) 64 65 39 66 def createpalette(self): 67 """function to create thermal type palette 68 69 used from the heat tutorial at http://www.penzilla.net/tutorials/python/pygame/heat/ 70 71 """ 40 72 r,g,b = -1,0,256 41 73 palette = []
