def check_voltage(self, voltstr, alerton=11.5): """Alert if VOLTSTR falls lower than ALERTON.""" vm = self.vre.match(voltstr) if vm: vval = float(vm.groups()[0]) if vval < alerton: print "LOW BATTERY! " + voltstr play_sound("alert1.wav")
def draw(self, tick, surf): newstatus = self.d100.status if newstatus != self.prevstatus: # Needs redraw self.clear() # Draw signal bar boff = 0 yoff = 60 for i in range(EVDO_LEVEL_FIVE + 1): col = (0, 200, 0) if i <= newstatus.get("evdoLevel", 0) else (50, 50, 50) pygame.draw.rect( self.surf, col, pygame.Rect(boff, yoff - i * 10, 8, 10 + i * 10), 0) boff += 10 # ppstate - color for network_type pstate = newstatus.get("pppState", -1) ntype = self.get_contype(newstatus) # print "NTYPE", ntype, "SYSINFO", newstatus.get("sysinfo", None) if pstate == PPP_CONNECTED: nv = 36 * ntype if nv > 255: nv = 255 pcol = (0, nv, 0) elif pstate == PPP_CONNECTING: pcol = (200, 200, 0) else: pcol = (200, 0, 0) ntlabel = NTYPES.get(ntype, "UNK" + str(ntype)) self.surf.blit(self.fnt.render(ntlabel, True, pcol), (0, 64)) # Play sound if pstate == PPP_CONNECTED: ptype = self.get_contype(self.prevstatus) if ptype < HSUPA and ntype >= HSUPA and ntype <= HSPA: play_sound("laugh1.wav") elif ptype < EDGE and ntype >= EDGE and ntype <= HSPA: play_sound("jump1.wav") self.redraw_into(surf) self.prevstatus = newstatus
def draw(self, tick, surf): newstatus = self.d100.status if newstatus != self.prevstatus: # Needs redraw self.clear() # Draw signal bar boff = 0 yoff = 60 for i in range(EVDO_LEVEL_FIVE+1): col = (0, 200, 0) if i <= newstatus.get("evdoLevel", 0) else (50, 50, 50) pygame.draw.rect(self.surf, col, pygame.Rect(boff, yoff-i*10, 8, 10+i*10), 0) boff += 10 # ppstate - color for network_type pstate = newstatus.get("pppState", -1) ntype = self.get_contype(newstatus) # print "NTYPE", ntype, "SYSINFO", newstatus.get("sysinfo", None) if pstate == PPP_CONNECTED: nv = 36*ntype if nv > 255: nv = 255 pcol = (0, nv, 0) elif pstate == PPP_CONNECTING: pcol = (200, 200, 0) else: pcol = (200, 0, 0) ntlabel = NTYPES.get(ntype, "UNK"+str(ntype)) self.surf.blit(self.fnt.render(ntlabel, True, pcol), (0, 64)) # Play sound if pstate == PPP_CONNECTED: ptype = self.get_contype(self.prevstatus) if ptype < HSUPA and ntype >= HSUPA and ntype <= HSPA: play_sound("laugh1.wav") elif ptype < EDGE and ntype >= EDGE and ntype <= HSPA: play_sound("jump1.wav") self.redraw_into(surf) self.prevstatus = newstatus