def switch(self): telemetry_py.send_telemetry(TelemetryEvent.CPX_API_SWITCH) return self.__state[CONSTANTS.EXPRESS_STATE.SWITCH]
def __init__(self): utils.print_for_unimplemented_functions( AudioFrame.__init__.__qualname__) telemetry_py.send_telemetry(TelemetryEvent.MICROBIT_API_AUDIO)
def __init__( self, bitmap, pixel_shader, default_tile=0, tile_width=None, tile_height=None, x=0, y=0, position=None, ): self.x = None """ .. attribute:: x X position of the left edge in the parent. """ self.y = None """ .. attribute:: y Y position of the top edge in the parent. """ self.pixel_shader = pixel_shader """ .. attribute:: pixel_shader The pixel shader of the tilegrid. """ self.hidden = False """ .. attribute:: hidden True when the TileGrid is hidden. This may be False even when a part of a hidden Group. """ self.__bitmap = bitmap self.__tile_width = None self.__tile_height = None if tile_width is None: self.__tile_width = bitmap.width else: self.__tile_width = tile_width if tile_height is None: self.__tile_height = bitmap.height else: self.__tile_height = tile_height if position and isinstance(position, tuple): self.x = position[0] self.y = position[1] else: self.x = x self.y = y self.__parent = None # unimplemented features self.__flip_x = False self.__flip_y = False self.__transpose_xy = False telemetry_py.send_telemetry(TelemetryEvent.CLUE_API_TILE_GRID)
def brightness(self, brightness): if not self.__valid_brightness(brightness): raise ValueError(CONSTANTS.BRIGHTNESS_RANGE_ERROR) telemetry_py.send_telemetry(TelemetryEvent.CPX_API_BRIGHTNESS) self.__state[CONSTANTS.EXPRESS_STATE.BRIGHTNESS] = brightness self.__show_if_auto_write()
def __getitem__(self, index): if type(index) is not slice: if not self.__valid_index(index): raise IndexError(CONSTANTS.INDEX_ERROR) telemetry_py.send_telemetry(TelemetryEvent.CPX_API_PIXELS) return self.__state[CONSTANTS.EXPRESS_STATE.PIXELS][index]
def brightness(self): telemetry_py.send_telemetry(TelemetryEvent.CPX_API_BRIGHTNESS) return self.__state[CONSTANTS.EXPRESS_STATE.BRIGHTNESS]
def copy(self): """ Return an exact copy of the image. """ telemetry_py.send_telemetry(TelemetryEvent.MICROBIT_API_IMAGE_OTHER) return Image(self.__create_string())
def shift_down(self, n): """ Return a new image created by shifting the picture down by ``n`` rows. """ telemetry_py.send_telemetry(TelemetryEvent.MICROBIT_API_IMAGE_OTHER) return self.__shift_vertical(n)
def height(self): """ Return the numbers of rows in the image. """ telemetry_py.send_telemetry(TelemetryEvent.MICROBIT_API_IMAGE_OTHER) return len(self.__LED)
def sleep_us(us): """ Delay for given number of microseconds, should be positive or 0. """ time.sleep(us / 1000000) telemetry_py.send_telemetry(TelemetryEvent.MICROBIT_API_UTIME)