def get_charge(self): """ Converts the given raw value to a percentage. @param raw_value: the raw signal value to be converted to a percentage @return: the raw input value as a percentage (100 = full, 0 = empty) """ raw_value = self.board.state[self.port] return int(saturate(raw_value, self.empty, self.full, 0, 100))
def get_nodes(self, coord, size, wrap=False): width = self.width height = self.height x1, y1 = coord x1 = saturate(x1, 0, width) y1 = saturate(y1, 0, height) w, h = size x2, y2 = (x+w, y+h) x = saturate(x, 0, width) y = saturate(y, 0, height) if x1 > x2: x1, x2 = x2, x1 if y1 > y2: y1, y2 = y2, y1 wrap_x, wrap_y = self._wrap_functions nodes = self.nodes return [self.nodes[y_coord][x1:x2] for y_coord in xrange(y1, y2)]
def get_nodes(self, coord, size, wrap=False): width = self.width height = self.height x1, y1 = coord x1 = saturate(x1, 0, width) y1 = saturate(y1, 0, height) w, h = size x2, y2 = (x + w, y + h) x = saturate(x, 0, width) y = saturate(y, 0, height) if x1 > x2: x1, x2 = x2, x1 if y1 > y2: y1, y2 = y2, y1 wrap_x, wrap_y = self._wrap_functions nodes = self.nodes return [self.nodes[y_coord][x1:x2] for y_coord in range(y1, y2)]